Skip to content

Commit

Permalink
Fixed #1655
Browse files Browse the repository at this point in the history
  • Loading branch information
Çağatay Çivici committed Jan 9, 2017
1 parent 55fc852 commit b16e346
Show file tree
Hide file tree
Showing 25 changed files with 267 additions and 113 deletions.
22 changes: 19 additions & 3 deletions components/autocomplete/autocomplete.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import {NgModule,Component,ElementRef,AfterViewInit,AfterViewChecked,DoCheck,Input,Output,EventEmitter,ContentChild,TemplateRef,IterableDiffers,Renderer,forwardRef} from '@angular/core';
import {NgModule,Component,ElementRef,AfterViewInit,AfterContentInit,AfterViewChecked,DoCheck,Input,Output,EventEmitter,ContentChildren,QueryList,TemplateRef,IterableDiffers,Renderer,forwardRef} from '@angular/core';
import {CommonModule} from '@angular/common';
import {InputTextModule} from '../inputtext/inputtext';
import {ButtonModule} from '../button/button';
import {SharedModule} from '../common/shared';
import {SharedModule,PrimeTemplate} from '../common/shared';
import {DomHandler} from '../dom/domhandler';
import {NG_VALUE_ACCESSOR, ControlValueAccessor} from '@angular/forms';

Expand Down Expand Up @@ -92,7 +92,9 @@ export class AutoComplete implements AfterViewInit,DoCheck,AfterViewChecked,Cont

@Input() multiple: boolean;

@ContentChild(TemplateRef) itemTemplate: TemplateRef<any>;
@ContentChildren(PrimeTemplate) templates: QueryList<any>;

public itemTemplate: TemplateRef<any>;

value: any;

Expand Down Expand Up @@ -143,6 +145,20 @@ export class AutoComplete implements AfterViewInit,DoCheck,AfterViewChecked,Cont
}
}

ngAfterContentInit() {
this.templates.forEach((item) => {
switch(item.getType()) {
case 'item':
this.itemTemplate = item.template;
break;

default:
this.itemTemplate = item.template;
break;
}
});
}

ngAfterViewInit() {
this.input = this.domHandler.findSingle(this.el.nativeElement, 'input');
this.panel = this.domHandler.findSingle(this.el.nativeElement, 'div.ui-autocomplete-panel');
Expand Down
22 changes: 19 additions & 3 deletions components/carousel/carousel.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import {NgModule,Component,ElementRef,OnInit,AfterViewInit,AfterViewChecked,DoCheck,OnDestroy,Input,Output,IterableDiffers,TemplateRef,ContentChild,Renderer} from '@angular/core';
import {NgModule,Component,ElementRef,OnInit,AfterViewInit,AfterViewChecked,AfterContentInit,DoCheck,OnDestroy,Input,Output,IterableDiffers,TemplateRef,ContentChildren,QueryList,Renderer} from '@angular/core';
import {DomHandler} from '../dom/domhandler';
import {SharedModule} from '../common/shared';
import {SharedModule,PrimeTemplate} from '../common/shared';
import {CommonModule} from '@angular/common';

@Component({
Expand Down Expand Up @@ -64,7 +64,9 @@ export class Carousel implements OnInit,AfterViewChecked,AfterViewInit,DoCheck,O

@Input() styleClass: string;

@ContentChild(TemplateRef) itemTemplate: TemplateRef<any>;
@ContentChildren(PrimeTemplate) templates: QueryList<any>;

public itemTemplate: TemplateRef<any>;

public container: any;

Expand Down Expand Up @@ -100,6 +102,20 @@ export class Carousel implements OnInit,AfterViewChecked,AfterViewInit,DoCheck,O
this.differ = differs.find([]).create(null);
}

ngAfterContentInit() {
this.templates.forEach((item) => {
switch(item.getType()) {
case 'item':
this.itemTemplate = item.template;
break;

default:
this.itemTemplate = item.template;
break;
}
});
}

ngDoCheck() {
let changes = this.differ.diff(this.value);

Expand Down
24 changes: 20 additions & 4 deletions components/chips/chips.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import {NgModule,Component,ElementRef,Input,Output,EventEmitter,ContentChild,TemplateRef,IterableDiffers,forwardRef} from '@angular/core';
import {NgModule,Component,ElementRef,Input,Output,EventEmitter,AfterContentInit,ContentChildren,QueryList,TemplateRef,IterableDiffers,forwardRef} from '@angular/core';
import {CommonModule} from '@angular/common';
import {SharedModule} from '../common/shared';
import {SharedModule,PrimeTemplate} from '../common/shared';
import {InputTextModule} from '../inputtext/inputtext';
import {DomHandler} from '../dom/domhandler';
import {NG_VALUE_ACCESSOR, ControlValueAccessor} from '@angular/forms';
Expand Down Expand Up @@ -30,7 +30,7 @@ export const CHIPS_VALUE_ACCESSOR: any = {
`,
providers: [DomHandler,CHIPS_VALUE_ACCESSOR]
})
export class Chips implements ControlValueAccessor {
export class Chips implements AfterContentInit,ControlValueAccessor {

@Input() style: any;

Expand All @@ -48,7 +48,9 @@ export class Chips implements ControlValueAccessor {

@Input() max: number;

@ContentChild(TemplateRef) itemTemplate: TemplateRef<any>;
@ContentChildren(PrimeTemplate) templates: QueryList<any>;

public itemTemplate: TemplateRef<any>;

value: any;

Expand All @@ -62,6 +64,20 @@ export class Chips implements ControlValueAccessor {

constructor(public el: ElementRef, public domHandler: DomHandler) {}

ngAfterContentInit() {
this.templates.forEach((item) => {
switch(item.getType()) {
case 'item':
this.itemTemplate = item.template;
break;

default:
this.itemTemplate = item.template;
break;
}
});
}

writeValue(value: any) : void {
this.value = value;
}
Expand Down
29 changes: 22 additions & 7 deletions components/datagrid/datagrid.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import {NgModule,Component,ElementRef,AfterViewInit,OnDestroy,DoCheck,Input,Output,SimpleChange,EventEmitter,ContentChild,IterableDiffers,TemplateRef} from '@angular/core';
import {NgModule,Component,ElementRef,AfterViewInit,AfterContentInit,OnDestroy,DoCheck,Input,Output,SimpleChange,EventEmitter,ContentChild,ContentChildren,QueryList,IterableDiffers,TemplateRef} from '@angular/core';
import {CommonModule} from '@angular/common';
import {Header} from '../common/shared';
import {Footer} from '../common/shared';
import {Header,Footer,PrimeTemplate,SharedModule} from '../common/shared';
import {PaginatorModule} from '../paginator/paginator';
import {BlockableUI} from '../common/api';

Expand All @@ -27,7 +26,7 @@ import {BlockableUI} from '../common/api';
</div>
`
})
export class DataGrid implements AfterViewInit,DoCheck,BlockableUI {
export class DataGrid implements AfterViewInit,AfterContentInit,DoCheck,BlockableUI {

@Input() value: any[];

Expand Down Expand Up @@ -55,7 +54,9 @@ export class DataGrid implements AfterViewInit,DoCheck,BlockableUI {

@ContentChild(Footer) footer;

@ContentChild(TemplateRef) itemTemplate: TemplateRef<any>;
@ContentChildren(PrimeTemplate) templates: QueryList<any>;

public itemTemplate: TemplateRef<any>;

public dataToRender: any[];

Expand All @@ -78,6 +79,20 @@ export class DataGrid implements AfterViewInit,DoCheck,BlockableUI {
}
}

ngAfterContentInit() {
this.templates.forEach((item) => {
switch(item.getType()) {
case 'item':
this.itemTemplate = item.template;
break;

default:
this.itemTemplate = item.template;
break;
}
});
}

ngDoCheck() {
let changes = this.differ.diff(this.value);

Expand Down Expand Up @@ -146,8 +161,8 @@ export class DataGrid implements AfterViewInit,DoCheck,BlockableUI {
}

@NgModule({
imports: [CommonModule,PaginatorModule],
exports: [DataGrid],
imports: [CommonModule,SharedModule,PaginatorModule],
exports: [DataGrid,SharedModule],
declarations: [DataGrid]
})
export class DataGridModule { }
26 changes: 20 additions & 6 deletions components/datalist/datalist.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
import {NgModule,Component,ElementRef,AfterViewInit,OnDestroy,DoCheck,Input,Output,SimpleChange,EventEmitter,ContentChild,IterableDiffers,TemplateRef} from '@angular/core';
import {NgModule,Component,ElementRef,AfterViewInit,AfterContentInit,OnDestroy,DoCheck,Input,Output,SimpleChange,EventEmitter,ContentChild,ContentChildren,IterableDiffers,TemplateRef,QueryList} from '@angular/core';
import {CommonModule} from '@angular/common';
import {Header} from '../common/shared';
import {Footer} from '../common/shared';
import {SharedModule} from '../common/shared';
import {SharedModule,Header,Footer,PrimeTemplate} from '../common/shared';
import {PaginatorModule} from '../paginator/paginator';
import {BlockableUI} from '../common/api';

Expand Down Expand Up @@ -30,7 +28,7 @@ import {BlockableUI} from '../common/api';
</div>
`
})
export class DataList implements AfterViewInit,DoCheck,BlockableUI {
export class DataList implements AfterViewInit,AfterContentInit,DoCheck,BlockableUI {

@Input() value: any[];

Expand Down Expand Up @@ -58,7 +56,9 @@ export class DataList implements AfterViewInit,DoCheck,BlockableUI {

@ContentChild(Footer) footer;

@ContentChild(TemplateRef) itemTemplate: TemplateRef<any>;
@ContentChildren(PrimeTemplate) templates: QueryList<any>;

public itemTemplate: TemplateRef<any>;

public dataToRender: any[];

Expand All @@ -71,6 +71,20 @@ export class DataList implements AfterViewInit,DoCheck,BlockableUI {
constructor(public el: ElementRef, differs: IterableDiffers) {
this.differ = differs.find([]).create(null);
}

ngAfterContentInit() {
this.templates.forEach((item) => {
switch(item.getType()) {
case 'item':
this.itemTemplate = item.template;
break;

default:
this.itemTemplate = item.template;
break;
}
});
}

ngAfterViewInit() {
if(this.lazy) {
Expand Down
26 changes: 20 additions & 6 deletions components/datascroller/datascroller.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
import {NgModule,Component,ElementRef,AfterViewInit,OnDestroy,DoCheck,Input,Output,Renderer,EventEmitter,ContentChild,IterableDiffers,TemplateRef} from '@angular/core';
import {NgModule,Component,ElementRef,AfterViewInit,AfterContentInit,OnDestroy,DoCheck,Input,Output,Renderer,EventEmitter,ContentChild,ContentChildren,QueryList,IterableDiffers,TemplateRef} from '@angular/core';
import {CommonModule} from '@angular/common';
import {Header} from '../common/shared';
import {Footer} from '../common/shared';
import {SharedModule} from '../common/shared';
import {Header,Footer,PrimeTemplate,SharedModule} from '../common/shared';
import {DomHandler} from '../dom/domhandler';

@Component({
Expand Down Expand Up @@ -45,14 +43,16 @@ export class DataScroller implements AfterViewInit,DoCheck,OnDestroy {
@Input() inline: boolean;

@Input() scrollHeight: any;

@Input() loader: any;

@ContentChild(Header) header;

@ContentChild(Footer) footer;

@ContentChild(TemplateRef) itemTemplate: TemplateRef<any>;
@ContentChildren(PrimeTemplate) templates: QueryList<any>;

@Input() loader: any;
public itemTemplate: TemplateRef<any>;

public dataToRender: any[] = [];

Expand Down Expand Up @@ -83,6 +83,20 @@ export class DataScroller implements AfterViewInit,DoCheck,OnDestroy {
}
}

ngAfterContentInit() {
this.templates.forEach((item) => {
switch(item.getType()) {
case 'item':
this.itemTemplate = item.template;
break;

default:
this.itemTemplate = item.template;
break;
}
});
}

ngDoCheck() {
let changes = this.differ.diff(this.value);

Expand Down
36 changes: 26 additions & 10 deletions components/dropdown/dropdown.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import {NgModule,Component,ElementRef,OnInit,AfterViewInit,AfterViewChecked,DoCheck,OnDestroy,Input,Output,Renderer,EventEmitter,ContentChild,ViewChild,TemplateRef,IterableDiffers,forwardRef} from '@angular/core';
import {NgModule,Component,ElementRef,OnInit,AfterViewInit,AfterViewChecked,DoCheck,OnDestroy,Input,Output,Renderer,EventEmitter,ContentChildren,QueryList,ViewChild,TemplateRef,IterableDiffers,forwardRef} from '@angular/core';
import {CommonModule} from '@angular/common';
import {SelectItem} from '../common/api';
import {SharedModule} from '../common/shared';
import {SharedModule,PrimeTemplate} from '../common/shared';
import {DomHandler} from '../dom/domhandler';
import {NG_VALUE_ACCESSOR, ControlValueAccessor} from '@angular/forms';

Expand Down Expand Up @@ -53,7 +53,7 @@ export const DROPDOWN_VALUE_ACCESSOR: any = {
`,
providers: [DomHandler,DROPDOWN_VALUE_ACCESSOR]
})
export class Dropdown implements OnInit,AfterViewInit,AfterViewChecked,DoCheck,OnDestroy,ControlValueAccessor {
export class Dropdown implements OnInit,AfterViewInit,AfterContentInit,AfterViewChecked,DoCheck,OnDestroy,ControlValueAccessor {

@Input() options: SelectItem[];

Expand All @@ -80,18 +80,16 @@ export class Dropdown implements OnInit,AfterViewInit,AfterViewChecked,DoCheck,O
@Output() onFocus: EventEmitter<any> = new EventEmitter();

@Output() onBlur: EventEmitter<any> = new EventEmitter();

@ContentChild(TemplateRef) itemTemplate: TemplateRef<any>;


@ViewChild('container') containerViewChild: ElementRef;

@ViewChild('panel') panelViewChild: ElementRef;

@ViewChild('itemswrapper') itemsWrapperViewChild: ElementRef;

constructor(public el: ElementRef, public domHandler: DomHandler, public renderer: Renderer, differs: IterableDiffers) {
this.differ = differs.find([]).create(null);
}
@ContentChildren(PrimeTemplate) templates: QueryList<any>;

public itemTemplate: TemplateRef<any>;

selectedOption: SelectItem;

Expand Down Expand Up @@ -130,6 +128,24 @@ export class Dropdown implements OnInit,AfterViewInit,AfterViewChecked,DoCheck,O
public hoveredItem: any;

public selectedOptionUpdated: boolean;

constructor(public el: ElementRef, public domHandler: DomHandler, public renderer: Renderer, differs: IterableDiffers) {
this.differ = differs.find([]).create(null);
}

ngAfterContentInit() {
this.templates.forEach((item) => {
switch(item.getType()) {
case 'item':
this.itemTemplate = item.template;
break;

default:
this.itemTemplate = item.template;
break;
}
});
}

ngOnInit() {
this.optionsToDisplay = this.options;
Expand Down
Loading

0 comments on commit b16e346

Please sign in to comment.