Skip to content

Commit 9fe6be1

Browse files
Merge branch 'master' into astaev/issue6260-master
2 parents 2d1ec24 + fdbd5cd commit 9fe6be1

File tree

10 files changed

+38
-84
lines changed

10 files changed

+38
-84
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ All notable changes for each version of this project will be documented in this
1515
- `IgxMonthPickerBase` -> `IgxMonthPickerBaseDirective`
1616

1717
- `IgxGrid`, `IgxTreeGrid`, `IgxHierarchicalGrid`
18+
- **Breaking Change** - Hierarchical grid children no longer use the same `IgxTransactionService` instance and transaction handling should be modified to address each grid's transactions separately.
1819
- **Behavioral Change** - Pinning columns is no longer automatically prevented when the pinning area would exceed the size of the grid.
1920
- `igxGridState` directive added to make it easy for developers to save and restore the grid state. The directive exposes the `getState` and `setState` methods to save/restore the state and an `options` input property to exclude features.
2021
- `IgxCarousel`:

projects/igniteui-angular/src/lib/carousel/carousel.component.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,12 @@ import {
2121
Injectable
2222
} from '@angular/core';
2323
import { IgxIconModule } from '../icon/index';
24-
import { IBaseEventArgs } from '../core/utils';
24+
import { IBaseEventArgs, PlatformUtil } from '../core/utils';
2525
import { Subject, merge } from 'rxjs';
2626
import { takeUntil } from 'rxjs/operators';
2727
import { IgxCarouselIndicatorDirective, IgxCarouselNextButtonDirective, IgxCarouselPrevButtonDirective } from './carousel.directives';
2828
import { useAnimation, AnimationBuilder, AnimationPlayer, AnimationReferenceMetadata } from '@angular/animations';
29-
import { slideInLeft, fadeIn, rotateInCenter } from '../animations/main';
29+
import { slideInLeft, fadeIn } from '../animations/main';
3030
import { IgxSlideComponent, Direction } from './slide.component';
3131
import { ICarouselResourceStrings } from '../core/i18n/carousel-resources';
3232
import { CurrentResourceStrings } from '../core/i18n/resources';
@@ -436,7 +436,8 @@ export class IgxCarouselComponent implements OnDestroy, AfterContentInit {
436436
private animationPosition = 0;
437437
private newDuration = 0;
438438

439-
constructor(private element: ElementRef, private iterableDiffers: IterableDiffers, private builder: AnimationBuilder) {
439+
constructor(private element: ElementRef, private iterableDiffers: IterableDiffers,
440+
private builder: AnimationBuilder, private platformUtil: PlatformUtil) {
440441
this.differ = this.iterableDiffers.find([]).create(null);
441442
}
442443

@@ -887,7 +888,7 @@ export class IgxCarouselComponent implements OnDestroy, AfterContentInit {
887888
private restartInterval() {
888889
this.resetInterval();
889890

890-
if (!isNaN(this.interval) && this.interval > 0) {
891+
if (!isNaN(this.interval) && this.interval > 0 && this.platformUtil.isBrowser) {
891892
this.lastInterval = setInterval(() => {
892893
const tick = +this.interval;
893894
if (this.playing && this.total && !isNaN(tick) && tick > 0) {

projects/igniteui-angular/src/lib/grids/grid-base.directive.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -330,7 +330,7 @@ export class IgxGridBaseDirective extends DisplayDensityBase implements
330330
}
331331

332332
/**
333-
* Emitted before filtering is performed.
333+
* Emitted after filtering is performed.
334334
* Returns the filtering expressions tree of the column for which filtering was performed.
335335
* ```typescript
336336
* filteringExprTreeChange(event: IFilteringExpressionsTree){
@@ -347,7 +347,7 @@ export class IgxGridBaseDirective extends DisplayDensityBase implements
347347
public filteringExpressionsTreeChange = new EventEmitter<IFilteringExpressionsTree>();
348348

349349
/**
350-
* Emitted before advanced filtering is performed.
350+
* Emitted after advanced filtering is performed.
351351
* Returns the advanced filtering expressions tree.
352352
* ```typescript
353353
* advancedFilteringExprTreeChange(event: IFilteringExpressionsTree){

projects/igniteui-angular/src/lib/grids/hierarchical-grid/hierarchical-grid-base.directive.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ import { IgxRowIslandComponent } from './row-island.component';
1919
import { IgxFilteringService } from '../filtering/grid-filtering.service';
2020
import { IDisplayDensityOptions, DisplayDensityToken } from '../../core/displayDensity';
2121
import { IgxSummaryOperand } from '../summaries/grid-summary';
22-
import { IgxHierarchicalTransactionService, IgxOverlayService } from '../../services/index';
22+
import { IgxOverlayService, IgxTransactionService, Transaction, TransactionService, State } from '../../services/index';
2323
import { DOCUMENT } from '@angular/common';
2424
import { IgxHierarchicalGridNavigationService } from './hierarchical-grid-navigation.service';
2525
import { IgxGridSummaryService } from '../summaries/grid-summary.service';
@@ -36,7 +36,7 @@ export const IgxHierarchicalTransactionServiceFactory = {
3636
};
3737

3838
export function hierarchicalTransactionServiceFactory() {
39-
return () => new IgxHierarchicalTransactionService();
39+
return new IgxTransactionService();
4040
}
4141

4242
export interface IPathSegment {
@@ -126,7 +126,7 @@ export class IgxHierarchicalGridBaseDirective extends IgxGridBaseDirective {
126126
crudService: IgxGridCRUDService,
127127
public colResizingService: IgxColumnResizingService,
128128
gridAPI: GridBaseAPIService<IgxGridBaseDirective & GridType>,
129-
@Inject(IgxGridTransaction) protected transactionFactory: any,
129+
@Inject(IgxGridTransaction) protected transactionFactory: TransactionService<Transaction, State>,
130130
elementRef: ElementRef,
131131
zone: NgZone,
132132
@Inject(DOCUMENT) public document,
@@ -144,7 +144,7 @@ export class IgxHierarchicalGridBaseDirective extends IgxGridBaseDirective {
144144
crudService,
145145
colResizingService,
146146
gridAPI,
147-
typeof transactionFactory === 'function' ? transactionFactory() : transactionFactory,
147+
transactionFactory,
148148
elementRef,
149149
zone,
150150
document,

projects/igniteui-angular/src/lib/grids/hierarchical-grid/hierarchical-grid.component.ts

Lines changed: 7 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -10,38 +10,29 @@ import {
1010
QueryList,
1111
ContentChildren,
1212
ElementRef,
13-
NgZone,
14-
ChangeDetectorRef,
15-
IterableDiffers,
16-
ViewContainerRef,
17-
Inject,
18-
ComponentFactoryResolver,
1913
AfterViewInit,
2014
AfterContentInit,
21-
Optional,
2215
OnInit,
2316
OnDestroy,
2417
DoCheck,
2518
EventEmitter,
2619
Output
2720
} from '@angular/core';
28-
import { IgxGridBaseDirective, IgxGridTransaction } from '../grid-base.directive';
21+
import { IgxGridBaseDirective } from '../grid-base.directive';
2922
import { GridBaseAPIService } from '../api.service';
3023
import { IgxHierarchicalGridAPIService } from './hierarchical-grid-api.service';
3124
import { IgxRowIslandComponent } from './row-island.component';
3225
import { IgxChildGridRowComponent } from './child-grid-row.component';
3326
import { IgxFilteringService } from '../filtering/grid-filtering.service';
34-
import { IDisplayDensityOptions, DisplayDensityToken, DisplayDensity } from '../../core/displayDensity';
27+
import { DisplayDensity } from '../../core/displayDensity';
3528
import { IgxColumnComponent, } from '../columns/column.component';
36-
import { DOCUMENT } from '@angular/common';
3729
import { IgxHierarchicalGridNavigationService } from './hierarchical-grid-navigation.service';
3830
import { IgxGridSummaryService } from '../summaries/grid-summary.service';
3931
import { IgxHierarchicalGridBaseDirective } from './hierarchical-grid-base.directive';
4032
import { takeUntil } from 'rxjs/operators';
4133
import { IgxTemplateOutletDirective } from '../../directives/template-outlet/template_outlet.directive';
4234
import { IgxGridSelectionService, IgxGridCRUDService } from '../selection/selection.service';
43-
import { IgxOverlayService } from '../../services/index';
44-
import { IgxColumnResizingService } from '../resizing/resizing.service';
35+
import { IgxTransactionService } from '../../services/index';
4536
import { IgxForOfSyncService, IgxForOfScrollSyncService } from '../../directives/for-of/for_of.sync.service';
4637
import { GridType } from '../common/grid.interface';
4738
import { IgxRowIslandAPIService } from './row-island-api.service';
@@ -310,53 +301,14 @@ export class IgxHierarchicalGridComponent extends IgxHierarchicalGridBaseDirecti
310301
private scrollTop = 0;
311302
private scrollLeft = 0;
312303

313-
protected _transactions: any;
314-
315-
constructor(
316-
public selectionService: IgxGridSelectionService,
317-
crudService: IgxGridCRUDService,
318-
public colResizingService: IgxColumnResizingService,
319-
gridAPI: GridBaseAPIService<IgxGridBaseDirective & GridType>,
320-
@Inject(IgxGridTransaction) protected transactionFactory: any,
321-
elementRef: ElementRef,
322-
zone: NgZone,
323-
@Inject(DOCUMENT) public document,
324-
cdr: ChangeDetectorRef,
325-
resolver: ComponentFactoryResolver,
326-
differs: IterableDiffers,
327-
viewRef: ViewContainerRef,
328-
navigation: IgxHierarchicalGridNavigationService,
329-
filteringService: IgxFilteringService,
330-
@Inject(IgxOverlayService) protected overlayService: IgxOverlayService,
331-
public summaryService: IgxGridSummaryService,
332-
@Optional() @Inject(DisplayDensityToken) protected _displayDensityOptions: IDisplayDensityOptions) {
333-
super(
334-
selectionService,
335-
crudService,
336-
colResizingService,
337-
gridAPI,
338-
typeof transactionFactory === 'function' ? transactionFactory() : transactionFactory,
339-
elementRef,
340-
zone,
341-
document,
342-
cdr,
343-
resolver,
344-
differs,
345-
viewRef,
346-
navigation,
347-
filteringService,
348-
overlayService,
349-
summaryService,
350-
_displayDensityOptions);
351-
this.hgridAPI = <IgxHierarchicalGridAPIService>gridAPI;
352-
}
353-
354-
355304
/**
356305
* @hidden
357306
*/
358307
ngOnInit() {
359-
this._transactions = this.parentIsland ? this.parentIsland.transactions : this._transactions;
308+
if (this._transactions instanceof IgxTransactionService) {
309+
// transaction service cannot be injected in a derived class in a factory manner
310+
this._transactions = new IgxTransactionService();
311+
}
360312
super.ngOnInit();
361313
}
362314

projects/igniteui-angular/src/lib/grids/hierarchical-grid/hierarchical-grid.integration.spec.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -142,8 +142,8 @@ describe('IgxHierarchicalGrid Integration #hGrid', () => {
142142
fixture.detectChanges();
143143
// test instances
144144
expect(firstLayoutInstances.length).toEqual(2);
145-
expect(hierarchicalGrid.transactions).not.toEqual(firstLayoutInstances[0].transactions);
146-
expect(firstLayoutInstances[0].transactions).toEqual(firstLayoutInstances[1].transactions);
145+
expect(hierarchicalGrid.transactions).not.toBe(firstLayoutInstances[0].transactions);
146+
expect(firstLayoutInstances[0].transactions).not.toBe(firstLayoutInstances[1].transactions);
147147
}));
148148

149149
it('should contain all transactions for a row island', fakeAsync(/** row toggle rAF */() => {
@@ -160,7 +160,8 @@ describe('IgxHierarchicalGrid Integration #hGrid', () => {
160160
firstLayoutInstances[0].updateRow({ ProductName: 'Changed' }, '00');
161161
firstLayoutInstances[1].updateRow({ ProductName: 'Changed' }, '10');
162162
expect(hierarchicalGrid.transactions.getTransactionLog().length).toEqual(0);
163-
expect(fixture.componentInstance.rowIsland.transactions.getTransactionLog().length).toEqual(2);
163+
expect(firstLayoutInstances[0].transactions.getTransactionLog().length).toEqual(1);
164+
expect(fixture.componentInstance.rowIsland.transactions.getTransactionLog().length).toEqual(0);
164165
}));
165166

166167
it('should remove expand indicator for uncommitted added rows', (async () => {

projects/igniteui-angular/src/lib/grids/hierarchical-grid/row-island.component.ts

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -166,15 +166,6 @@ export class IgxRowIslandComponent extends IgxHierarchicalGridBaseDirective
166166
return lvl + 1;
167167
}
168168

169-
/**
170-
* Get transactions service for the children grid components.
171-
* @experimental @hidden
172-
*/
173-
get transactions(): TransactionService<Transaction, State> {
174-
const grids = this.rowIslandAPI.getChildGrids();
175-
return grids.length ? grids[0].transactions : this._transactions;
176-
}
177-
178169
/**
179170
* @hidden
180171
*/

projects/igniteui-angular/src/lib/grids/state.directive.spec.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,11 @@ import { IgxBooleanFilteringOperand } from '../data-operations/filtering-conditi
1414
import { IGroupingState } from '../data-operations/groupby-state.interface';
1515
import { IGroupByExpandState } from '../data-operations/groupby-expand-state.interface';
1616
import { GridSelectionMode } from './common/enums';
17+
import { configureTestSuite } from '../test-utils/configure-suite';
1718

1819
describe('IgxGridState - input properties #grid', () => {
20+
configureTestSuite();
21+
1922
beforeEach(async(() => {
2023
TestBed.configureTestingModule({
2124
declarations: [

src/app/hierarchical-grid-updating/hierarchical-grid-updating.sample.html

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
<button igxButton="raised" (click)="addRow()">Add Row Parent</button>
2-
<button igxButton="raised" (click)="deleteRow()">Delete Row Parent</button>
2+
<button igxButton="raised" (click)="deleteRow()">Delete Row Child 1</button>
33
<button igxButton="raised" (click)="logTransactionsMain()">Parent Transactions</button>
44
<button igxButton="raised" (click)="logTransactionsIsland1()">RI1 Transactions</button>
5+
<button igxButton="raised" (click)="commitTransactionsIsland1()">Commit R1 Transactions</button>
56
<div class="wrapper">
67
<igx-hierarchical-grid #grid1 [data]="remoteData" [rowEditable]="true" [primaryKey]="'CustomerID'" [autoGenerate]="false"
78
[height]="'800px'" [width]="'100%'" #hGrid>
@@ -11,10 +12,9 @@
1112
<igx-column field="ContactTitle"></igx-column>
1213
<igx-column field="Country"></igx-column>
1314
<igx-column field="Phone"></igx-column>
14-
<igx-row-island #rowIsland1 [key]="'Orders'" [primaryKey]="'MyID'" [autoGenerate]="false"
15+
<igx-row-island #rowIsland1 [key]="'Orders'" [primaryKey]="'OrderID'" [autoGenerate]="false"
1516
[rowSelectable]='isRowSelectable' (onGridCreated)="gridCreated($event, rowIsland1)"
1617
[rowEditable]="true">
17-
<igx-column field="MyID"></igx-column>
1818
<igx-column field="OrderID"></igx-column>
1919
<igx-column field="OrderDate" [dataType]='"date"'></igx-column>
2020
<igx-column field="ShipCountry"></igx-column>

src/app/hierarchical-grid-updating/hierarchical-grid-updating.sample.ts

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,7 @@ import {
33
IgxRowIslandComponent,
44
IgxHierarchicalGridComponent,
55
IGridCreatedEventArgs,
6-
IgxHierarchicalTransactionServiceFactory,
7-
IgxHierarchicalTransactionService,
8-
IgxGridTransaction
6+
IgxHierarchicalTransactionServiceFactory
97
} from 'igniteui-angular';
108
import { RemoteService } from '../shared/remote.service';
119

@@ -96,7 +94,8 @@ export class HierarchicalGridUpdatingSampleComponent implements AfterViewInit {
9694
}
9795

9896
deleteRow() {
99-
this.hGrid.deleteRow('ALFKI');
97+
const grid = this.rowIsland1.hgridAPI.getChildGrids()[0];
98+
grid.deleteRow(grid.data[0]['OrderID']);
10099
}
101100

102101
logTransactionsMain() {
@@ -107,4 +106,10 @@ export class HierarchicalGridUpdatingSampleComponent implements AfterViewInit {
107106
console.log(this.rowIsland1.transactions.getTransactionLog());
108107
}
109108

109+
commitTransactionsIsland1() {
110+
this.rowIsland1.rowIslandAPI.getChildGrids().forEach((grid: IgxHierarchicalGridComponent) => {
111+
grid.transactions.commit(grid.data);
112+
});
113+
}
114+
110115
}

0 commit comments

Comments
 (0)