Skip to content

Commit b16e346

Browse files
author
Çağatay Çivici
committed
1 parent 55fc852 commit b16e346

File tree

25 files changed

+267
-113
lines changed

25 files changed

+267
-113
lines changed

components/autocomplete/autocomplete.ts

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
import {NgModule,Component,ElementRef,AfterViewInit,AfterViewChecked,DoCheck,Input,Output,EventEmitter,ContentChild,TemplateRef,IterableDiffers,Renderer,forwardRef} from '@angular/core';
1+
import {NgModule,Component,ElementRef,AfterViewInit,AfterContentInit,AfterViewChecked,DoCheck,Input,Output,EventEmitter,ContentChildren,QueryList,TemplateRef,IterableDiffers,Renderer,forwardRef} from '@angular/core';
22
import {CommonModule} from '@angular/common';
33
import {InputTextModule} from '../inputtext/inputtext';
44
import {ButtonModule} from '../button/button';
5-
import {SharedModule} from '../common/shared';
5+
import {SharedModule,PrimeTemplate} from '../common/shared';
66
import {DomHandler} from '../dom/domhandler';
77
import {NG_VALUE_ACCESSOR, ControlValueAccessor} from '@angular/forms';
88

@@ -92,7 +92,9 @@ export class AutoComplete implements AfterViewInit,DoCheck,AfterViewChecked,Cont
9292

9393
@Input() multiple: boolean;
9494

95-
@ContentChild(TemplateRef) itemTemplate: TemplateRef<any>;
95+
@ContentChildren(PrimeTemplate) templates: QueryList<any>;
96+
97+
public itemTemplate: TemplateRef<any>;
9698

9799
value: any;
98100

@@ -143,6 +145,20 @@ export class AutoComplete implements AfterViewInit,DoCheck,AfterViewChecked,Cont
143145
}
144146
}
145147

148+
ngAfterContentInit() {
149+
this.templates.forEach((item) => {
150+
switch(item.getType()) {
151+
case 'item':
152+
this.itemTemplate = item.template;
153+
break;
154+
155+
default:
156+
this.itemTemplate = item.template;
157+
break;
158+
}
159+
});
160+
}
161+
146162
ngAfterViewInit() {
147163
this.input = this.domHandler.findSingle(this.el.nativeElement, 'input');
148164
this.panel = this.domHandler.findSingle(this.el.nativeElement, 'div.ui-autocomplete-panel');

components/carousel/carousel.ts

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
import {NgModule,Component,ElementRef,OnInit,AfterViewInit,AfterViewChecked,DoCheck,OnDestroy,Input,Output,IterableDiffers,TemplateRef,ContentChild,Renderer} from '@angular/core';
1+
import {NgModule,Component,ElementRef,OnInit,AfterViewInit,AfterViewChecked,AfterContentInit,DoCheck,OnDestroy,Input,Output,IterableDiffers,TemplateRef,ContentChildren,QueryList,Renderer} from '@angular/core';
22
import {DomHandler} from '../dom/domhandler';
3-
import {SharedModule} from '../common/shared';
3+
import {SharedModule,PrimeTemplate} from '../common/shared';
44
import {CommonModule} from '@angular/common';
55

66
@Component({
@@ -64,7 +64,9 @@ export class Carousel implements OnInit,AfterViewChecked,AfterViewInit,DoCheck,O
6464

6565
@Input() styleClass: string;
6666

67-
@ContentChild(TemplateRef) itemTemplate: TemplateRef<any>;
67+
@ContentChildren(PrimeTemplate) templates: QueryList<any>;
68+
69+
public itemTemplate: TemplateRef<any>;
6870

6971
public container: any;
7072

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

105+
ngAfterContentInit() {
106+
this.templates.forEach((item) => {
107+
switch(item.getType()) {
108+
case 'item':
109+
this.itemTemplate = item.template;
110+
break;
111+
112+
default:
113+
this.itemTemplate = item.template;
114+
break;
115+
}
116+
});
117+
}
118+
103119
ngDoCheck() {
104120
let changes = this.differ.diff(this.value);
105121

components/chips/chips.ts

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
import {NgModule,Component,ElementRef,Input,Output,EventEmitter,ContentChild,TemplateRef,IterableDiffers,forwardRef} from '@angular/core';
1+
import {NgModule,Component,ElementRef,Input,Output,EventEmitter,AfterContentInit,ContentChildren,QueryList,TemplateRef,IterableDiffers,forwardRef} from '@angular/core';
22
import {CommonModule} from '@angular/common';
3-
import {SharedModule} from '../common/shared';
3+
import {SharedModule,PrimeTemplate} from '../common/shared';
44
import {InputTextModule} from '../inputtext/inputtext';
55
import {DomHandler} from '../dom/domhandler';
66
import {NG_VALUE_ACCESSOR, ControlValueAccessor} from '@angular/forms';
@@ -30,7 +30,7 @@ export const CHIPS_VALUE_ACCESSOR: any = {
3030
`,
3131
providers: [DomHandler,CHIPS_VALUE_ACCESSOR]
3232
})
33-
export class Chips implements ControlValueAccessor {
33+
export class Chips implements AfterContentInit,ControlValueAccessor {
3434

3535
@Input() style: any;
3636

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

4949
@Input() max: number;
5050

51-
@ContentChild(TemplateRef) itemTemplate: TemplateRef<any>;
51+
@ContentChildren(PrimeTemplate) templates: QueryList<any>;
52+
53+
public itemTemplate: TemplateRef<any>;
5254

5355
value: any;
5456

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

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

67+
ngAfterContentInit() {
68+
this.templates.forEach((item) => {
69+
switch(item.getType()) {
70+
case 'item':
71+
this.itemTemplate = item.template;
72+
break;
73+
74+
default:
75+
this.itemTemplate = item.template;
76+
break;
77+
}
78+
});
79+
}
80+
6581
writeValue(value: any) : void {
6682
this.value = value;
6783
}

components/datagrid/datagrid.ts

Lines changed: 22 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
1-
import {NgModule,Component,ElementRef,AfterViewInit,OnDestroy,DoCheck,Input,Output,SimpleChange,EventEmitter,ContentChild,IterableDiffers,TemplateRef} from '@angular/core';
1+
import {NgModule,Component,ElementRef,AfterViewInit,AfterContentInit,OnDestroy,DoCheck,Input,Output,SimpleChange,EventEmitter,ContentChild,ContentChildren,QueryList,IterableDiffers,TemplateRef} from '@angular/core';
22
import {CommonModule} from '@angular/common';
3-
import {Header} from '../common/shared';
4-
import {Footer} from '../common/shared';
3+
import {Header,Footer,PrimeTemplate,SharedModule} from '../common/shared';
54
import {PaginatorModule} from '../paginator/paginator';
65
import {BlockableUI} from '../common/api';
76

@@ -27,7 +26,7 @@ import {BlockableUI} from '../common/api';
2726
</div>
2827
`
2928
})
30-
export class DataGrid implements AfterViewInit,DoCheck,BlockableUI {
29+
export class DataGrid implements AfterViewInit,AfterContentInit,DoCheck,BlockableUI {
3130

3231
@Input() value: any[];
3332

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

5655
@ContentChild(Footer) footer;
5756

58-
@ContentChild(TemplateRef) itemTemplate: TemplateRef<any>;
57+
@ContentChildren(PrimeTemplate) templates: QueryList<any>;
58+
59+
public itemTemplate: TemplateRef<any>;
5960

6061
public dataToRender: any[];
6162

@@ -78,6 +79,20 @@ export class DataGrid implements AfterViewInit,DoCheck,BlockableUI {
7879
}
7980
}
8081

82+
ngAfterContentInit() {
83+
this.templates.forEach((item) => {
84+
switch(item.getType()) {
85+
case 'item':
86+
this.itemTemplate = item.template;
87+
break;
88+
89+
default:
90+
this.itemTemplate = item.template;
91+
break;
92+
}
93+
});
94+
}
95+
8196
ngDoCheck() {
8297
let changes = this.differ.diff(this.value);
8398

@@ -146,8 +161,8 @@ export class DataGrid implements AfterViewInit,DoCheck,BlockableUI {
146161
}
147162

148163
@NgModule({
149-
imports: [CommonModule,PaginatorModule],
150-
exports: [DataGrid],
164+
imports: [CommonModule,SharedModule,PaginatorModule],
165+
exports: [DataGrid,SharedModule],
151166
declarations: [DataGrid]
152167
})
153168
export class DataGridModule { }

components/datalist/datalist.ts

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
1-
import {NgModule,Component,ElementRef,AfterViewInit,OnDestroy,DoCheck,Input,Output,SimpleChange,EventEmitter,ContentChild,IterableDiffers,TemplateRef} from '@angular/core';
1+
import {NgModule,Component,ElementRef,AfterViewInit,AfterContentInit,OnDestroy,DoCheck,Input,Output,SimpleChange,EventEmitter,ContentChild,ContentChildren,IterableDiffers,TemplateRef,QueryList} from '@angular/core';
22
import {CommonModule} from '@angular/common';
3-
import {Header} from '../common/shared';
4-
import {Footer} from '../common/shared';
5-
import {SharedModule} from '../common/shared';
3+
import {SharedModule,Header,Footer,PrimeTemplate} from '../common/shared';
64
import {PaginatorModule} from '../paginator/paginator';
75
import {BlockableUI} from '../common/api';
86

@@ -30,7 +28,7 @@ import {BlockableUI} from '../common/api';
3028
</div>
3129
`
3230
})
33-
export class DataList implements AfterViewInit,DoCheck,BlockableUI {
31+
export class DataList implements AfterViewInit,AfterContentInit,DoCheck,BlockableUI {
3432

3533
@Input() value: any[];
3634

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

5957
@ContentChild(Footer) footer;
6058

61-
@ContentChild(TemplateRef) itemTemplate: TemplateRef<any>;
59+
@ContentChildren(PrimeTemplate) templates: QueryList<any>;
60+
61+
public itemTemplate: TemplateRef<any>;
6262

6363
public dataToRender: any[];
6464

@@ -71,6 +71,20 @@ export class DataList implements AfterViewInit,DoCheck,BlockableUI {
7171
constructor(public el: ElementRef, differs: IterableDiffers) {
7272
this.differ = differs.find([]).create(null);
7373
}
74+
75+
ngAfterContentInit() {
76+
this.templates.forEach((item) => {
77+
switch(item.getType()) {
78+
case 'item':
79+
this.itemTemplate = item.template;
80+
break;
81+
82+
default:
83+
this.itemTemplate = item.template;
84+
break;
85+
}
86+
});
87+
}
7488

7589
ngAfterViewInit() {
7690
if(this.lazy) {

components/datascroller/datascroller.ts

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
1-
import {NgModule,Component,ElementRef,AfterViewInit,OnDestroy,DoCheck,Input,Output,Renderer,EventEmitter,ContentChild,IterableDiffers,TemplateRef} from '@angular/core';
1+
import {NgModule,Component,ElementRef,AfterViewInit,AfterContentInit,OnDestroy,DoCheck,Input,Output,Renderer,EventEmitter,ContentChild,ContentChildren,QueryList,IterableDiffers,TemplateRef} from '@angular/core';
22
import {CommonModule} from '@angular/common';
3-
import {Header} from '../common/shared';
4-
import {Footer} from '../common/shared';
5-
import {SharedModule} from '../common/shared';
3+
import {Header,Footer,PrimeTemplate,SharedModule} from '../common/shared';
64
import {DomHandler} from '../dom/domhandler';
75

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

4745
@Input() scrollHeight: any;
46+
47+
@Input() loader: any;
4848

4949
@ContentChild(Header) header;
5050

5151
@ContentChild(Footer) footer;
5252

53-
@ContentChild(TemplateRef) itemTemplate: TemplateRef<any>;
53+
@ContentChildren(PrimeTemplate) templates: QueryList<any>;
5454

55-
@Input() loader: any;
55+
public itemTemplate: TemplateRef<any>;
5656

5757
public dataToRender: any[] = [];
5858

@@ -83,6 +83,20 @@ export class DataScroller implements AfterViewInit,DoCheck,OnDestroy {
8383
}
8484
}
8585

86+
ngAfterContentInit() {
87+
this.templates.forEach((item) => {
88+
switch(item.getType()) {
89+
case 'item':
90+
this.itemTemplate = item.template;
91+
break;
92+
93+
default:
94+
this.itemTemplate = item.template;
95+
break;
96+
}
97+
});
98+
}
99+
86100
ngDoCheck() {
87101
let changes = this.differ.diff(this.value);
88102

components/dropdown/dropdown.ts

Lines changed: 26 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
import {NgModule,Component,ElementRef,OnInit,AfterViewInit,AfterViewChecked,DoCheck,OnDestroy,Input,Output,Renderer,EventEmitter,ContentChild,ViewChild,TemplateRef,IterableDiffers,forwardRef} from '@angular/core';
1+
import {NgModule,Component,ElementRef,OnInit,AfterViewInit,AfterViewChecked,DoCheck,OnDestroy,Input,Output,Renderer,EventEmitter,ContentChildren,QueryList,ViewChild,TemplateRef,IterableDiffers,forwardRef} from '@angular/core';
22
import {CommonModule} from '@angular/common';
33
import {SelectItem} from '../common/api';
4-
import {SharedModule} from '../common/shared';
4+
import {SharedModule,PrimeTemplate} from '../common/shared';
55
import {DomHandler} from '../dom/domhandler';
66
import {NG_VALUE_ACCESSOR, ControlValueAccessor} from '@angular/forms';
77

@@ -53,7 +53,7 @@ export const DROPDOWN_VALUE_ACCESSOR: any = {
5353
`,
5454
providers: [DomHandler,DROPDOWN_VALUE_ACCESSOR]
5555
})
56-
export class Dropdown implements OnInit,AfterViewInit,AfterViewChecked,DoCheck,OnDestroy,ControlValueAccessor {
56+
export class Dropdown implements OnInit,AfterViewInit,AfterContentInit,AfterViewChecked,DoCheck,OnDestroy,ControlValueAccessor {
5757

5858
@Input() options: SelectItem[];
5959

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

8282
@Output() onBlur: EventEmitter<any> = new EventEmitter();
83-
84-
@ContentChild(TemplateRef) itemTemplate: TemplateRef<any>;
85-
83+
8684
@ViewChild('container') containerViewChild: ElementRef;
8785

8886
@ViewChild('panel') panelViewChild: ElementRef;
8987

9088
@ViewChild('itemswrapper') itemsWrapperViewChild: ElementRef;
91-
92-
constructor(public el: ElementRef, public domHandler: DomHandler, public renderer: Renderer, differs: IterableDiffers) {
93-
this.differ = differs.find([]).create(null);
94-
}
89+
90+
@ContentChildren(PrimeTemplate) templates: QueryList<any>;
91+
92+
public itemTemplate: TemplateRef<any>;
9593

9694
selectedOption: SelectItem;
9795

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

132130
public selectedOptionUpdated: boolean;
131+
132+
constructor(public el: ElementRef, public domHandler: DomHandler, public renderer: Renderer, differs: IterableDiffers) {
133+
this.differ = differs.find([]).create(null);
134+
}
135+
136+
ngAfterContentInit() {
137+
this.templates.forEach((item) => {
138+
switch(item.getType()) {
139+
case 'item':
140+
this.itemTemplate = item.template;
141+
break;
142+
143+
default:
144+
this.itemTemplate = item.template;
145+
break;
146+
}
147+
});
148+
}
133149

134150
ngOnInit() {
135151
this.optionsToDisplay = this.options;

0 commit comments

Comments
 (0)