1
1
import {
2
2
AfterContentInit ,
3
+ AfterViewInit ,
3
4
ChangeDetectionStrategy ,
5
+ ChangeDetectorRef ,
4
6
Component ,
7
+ ComponentFactoryResolver ,
8
+ ContentChild ,
5
9
ContentChildren ,
6
- Input ,
7
- QueryList ,
8
- OnInit ,
9
- Inject ,
10
+ DoCheck ,
10
11
ElementRef ,
11
- ChangeDetectorRef ,
12
- ComponentFactoryResolver ,
12
+ EventEmitter ,
13
+ Inject ,
14
+ Input ,
15
+ IterableChangeRecord ,
13
16
IterableDiffers ,
14
- ViewContainerRef ,
15
17
NgZone ,
16
- AfterViewInit ,
17
18
OnChanges ,
18
- Output ,
19
- EventEmitter ,
20
- Optional ,
21
19
OnDestroy ,
22
- DoCheck ,
23
- IterableChangeRecord
20
+ OnInit ,
21
+ Optional ,
22
+ Output ,
23
+ QueryList ,
24
+ TemplateRef ,
25
+ ViewContainerRef
24
26
} from '@angular/core' ;
25
27
import { IgxHierarchicalGridComponent } from './hierarchical-grid.component' ;
26
28
import { IgxGridTransaction , IgxGridBaseDirective } from '../grid-base.directive' ;
@@ -29,19 +31,18 @@ import { IgxHierarchicalGridAPIService } from './hierarchical-grid-api.service';
29
31
import { DOCUMENT } from '@angular/common' ;
30
32
import { IgxFilteringService } from '../filtering/grid-filtering.service' ;
31
33
import { IDisplayDensityOptions , DisplayDensityToken } from '../../core/displayDensity' ;
32
- import { TransactionService , Transaction , State } from '../../services/public_api' ;
33
34
import { IgxGridSummaryService } from '../summaries/grid-summary.service' ;
34
35
import { IgxHierarchicalGridBaseDirective } from './hierarchical-grid-base.directive' ;
35
36
import { IgxHierarchicalGridNavigationService } from './hierarchical-grid-navigation.service' ;
36
37
import { IgxGridSelectionService , IgxGridCRUDService } from '../selection/selection.service' ;
37
-
38
38
import { IgxOverlayService } from '../../services/public_api' ;
39
39
import { takeUntil } from 'rxjs/operators' ;
40
40
import { IgxColumnComponent } from '../columns/column.component' ;
41
41
import { IgxRowIslandAPIService } from './row-island-api.service' ;
42
42
import { IBaseEventArgs } from '../../core/utils' ;
43
43
import { IgxColumnResizingService } from '../resizing/resizing.service' ;
44
44
import { GridType } from '../common/grid.interface' ;
45
+ import { IgxGridToolbarDirective , IgxGridToolbarTemplateContext } from '../toolbar/common' ;
45
46
export interface IGridCreatedEventArgs extends IBaseEventArgs {
46
47
owner : IgxRowIslandComponent ;
47
48
parentID : any ;
@@ -53,10 +54,10 @@ export interface IGridCreatedEventArgs extends IBaseEventArgs {
53
54
selector : 'igx-row-island' ,
54
55
template : `` ,
55
56
providers : [ IgxRowIslandAPIService ,
56
- IgxGridSelectionService ]
57
+ IgxGridSelectionService ]
57
58
} )
58
59
export class IgxRowIslandComponent extends IgxHierarchicalGridBaseDirective
59
- implements AfterContentInit , AfterViewInit , OnChanges , OnInit , OnDestroy , DoCheck {
60
+ implements AfterContentInit , AfterViewInit , OnChanges , OnInit , OnDestroy , DoCheck {
60
61
/**
61
62
* Sets the key of the row island by which child data would be taken from the row data if such is provided.
62
63
* ```html
@@ -84,7 +85,7 @@ export class IgxRowIslandComponent extends IgxHierarchicalGridBaseDirective
84
85
*/
85
86
@Input ( )
86
87
set expandChildren ( value : boolean ) {
87
- this . _defaultExpandState = value ;
88
+ this . _defaultExpandState = value ;
88
89
this . rowIslandAPI . getChildGrids ( ) . forEach ( ( grid ) => {
89
90
if ( document . body . contains ( grid . nativeElement ) ) {
90
91
// Detect changes right away if the grid is visible
@@ -120,6 +121,9 @@ export class IgxRowIslandComponent extends IgxHierarchicalGridBaseDirective
120
121
@ContentChildren ( IgxColumnComponent , { read : IgxColumnComponent , descendants : false } )
121
122
public childColumns = new QueryList < IgxColumnComponent > ( ) ;
122
123
124
+ @ContentChild ( IgxGridToolbarDirective , { read : TemplateRef } )
125
+ public islandToolbarTemplate : TemplateRef < IgxGridToolbarTemplateContext > ;
126
+
123
127
/**
124
128
* @hidden
125
129
*/
@@ -160,14 +164,14 @@ export class IgxRowIslandComponent extends IgxHierarchicalGridBaseDirective
160
164
*/
161
165
get id ( ) {
162
166
const pId = this . parentId ? this . parentId . substring ( this . parentId . indexOf ( this . layout_id ) + this . layout_id . length ) + '-' : '' ;
163
- return this . layout_id + pId + this . key ;
167
+ return this . layout_id + pId + this . key ;
164
168
}
165
169
166
170
/**
167
171
* @hidden
168
172
*/
169
173
get parentId ( ) {
170
- return this . parentIsland ? this . parentIsland . id : null ;
174
+ return this . parentIsland ? this . parentIsland . id : null ;
171
175
}
172
176
173
177
/**
@@ -259,16 +263,20 @@ export class IgxRowIslandComponent extends IgxHierarchicalGridBaseDirective
259
263
* @hidden
260
264
*/
261
265
ngAfterContentInit ( ) {
266
+ // TODO: Discuss should it always take the parent toolbar if present
267
+ this . onGridCreated . pipe ( takeUntil ( this . destroy$ ) ) . subscribe ( e => {
268
+ e . grid . toolbarTemplate = this . islandToolbarTemplate || e . grid . parent . toolbarTemplate ;
269
+ } ) ;
262
270
this . updateChildren ( ) ;
263
271
this . children . notifyOnChanges ( ) ;
264
272
this . children . changes . pipe ( takeUntil ( this . destroy$ ) )
265
- . subscribe ( ( change ) => {
266
- this . updateChildren ( ) ;
267
- // update existing grids since their child ri have been changed.
268
- this . getGridsForIsland ( this . key ) . forEach ( grid => {
269
- ( grid as any ) . onRowIslandChange ( this . children ) ;
273
+ . subscribe ( ( change ) => {
274
+ this . updateChildren ( ) ;
275
+ // update existing grids since their child ri have been changed.
276
+ this . getGridsForIsland ( this . key ) . forEach ( grid => {
277
+ ( grid as any ) . onRowIslandChange ( this . children ) ;
278
+ } ) ;
270
279
} ) ;
271
- } ) ;
272
280
const nestedColumns = this . children . map ( ( layout ) => layout . columnList . toArray ( ) ) ;
273
281
const colsArray = [ ] . concat . apply ( [ ] , nestedColumns ) ;
274
282
const topCols = this . columnList . filter ( ( item ) => {
@@ -279,19 +287,19 @@ export class IgxRowIslandComponent extends IgxHierarchicalGridBaseDirective
279
287
Promise . resolve ( ) . then ( ( ) => {
280
288
this . updateColumnList ( ) ;
281
289
} ) ;
282
- } ) ;
290
+ } ) ;
283
291
284
- // handle column changes so that they are passed to child grid instances when onColumnChange is emitted.
285
- this . ri_columnListDiffer . diff ( this . childColumns ) ;
286
- this . childColumns . toArray ( ) . forEach ( x => x . onColumnChange . pipe ( takeUntil ( x . destroy$ ) ) . subscribe ( ( ) => this . updateColumnList ( ) ) ) ;
287
- this . childColumns . changes . pipe ( takeUntil ( this . destroy$ ) ) . subscribe ( ( change : QueryList < IgxColumnComponent > ) => {
292
+ // handle column changes so that they are passed to child grid instances when onColumnChange is emitted.
293
+ this . ri_columnListDiffer . diff ( this . childColumns ) ;
294
+ this . childColumns . toArray ( ) . forEach ( x => x . onColumnChange . pipe ( takeUntil ( x . destroy$ ) ) . subscribe ( ( ) => this . updateColumnList ( ) ) ) ;
295
+ this . childColumns . changes . pipe ( takeUntil ( this . destroy$ ) ) . subscribe ( ( change : QueryList < IgxColumnComponent > ) => {
288
296
const diff = this . ri_columnListDiffer . diff ( change ) ;
289
297
if ( diff ) {
290
298
diff . forEachAddedItem ( ( record : IterableChangeRecord < IgxColumnComponent > ) => {
291
299
record . item . onColumnChange . pipe ( takeUntil ( record . item . destroy$ ) ) . subscribe ( ( ) => this . updateColumnList ( ) ) ;
292
300
} ) ;
293
301
}
294
- } ) ;
302
+ } ) ;
295
303
}
296
304
297
305
protected updateChildren ( ) {
@@ -358,12 +366,12 @@ export class IgxRowIslandComponent extends IgxHierarchicalGridBaseDirective
358
366
/**
359
367
* @hidden
360
368
*/
361
- reflow ( ) { }
369
+ reflow ( ) { }
362
370
363
371
/**
364
372
* @hidden
365
373
*/
366
- calculateGridHeight ( ) { }
374
+ calculateGridHeight ( ) { }
367
375
368
376
protected updateColumnList ( ) {
369
377
const nestedColumns = this . children . map ( ( layout ) => layout . columnList . toArray ( ) ) ;
0 commit comments