Skip to content

Commit d63a7cf

Browse files
authored
Merge branch 'master' into rkaraivanov/column-formatters-performance
2 parents bdd76a0 + 3d14147 commit d63a7cf

File tree

5 files changed

+34
-13
lines changed

5 files changed

+34
-13
lines changed

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ import {
2424
TransactionEventOrigin,
2525
StateUpdateEvent
2626
} from '../../services/transaction/transaction';
27-
import { IgxHierarchicalTransactionService } from '../../services/public_api';
27+
import { HierarchicalTransactionService } from '../../services/public_api';
2828
import { IgxFilteringService } from '../filtering/grid-filtering.service';
2929
import { IgxGridSummaryService } from '../summaries/grid-summary.service';
3030
import { IgxGridSelectionService, IgxGridCRUDService } from '../selection/selection.service';
@@ -78,7 +78,7 @@ export class IgxTreeGridComponent extends IgxGridBaseDirective implements GridTy
7878
private _id = `igx-tree-grid-${NEXT_ID++}`;
7979
private _data;
8080
private _rowLoadingIndicatorTemplate: TemplateRef<any>;
81-
protected _transactions: IgxHierarchicalTransactionService<HierarchicalTransaction, HierarchicalState>;
81+
protected _transactions: HierarchicalTransactionService<HierarchicalTransaction, HierarchicalState>;
8282

8383
/**
8484
* An @Input property that sets the value of the `id` attribute. If not provided it will be automatically generated.

projects/igniteui-angular/src/lib/services/public_api.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,3 +17,4 @@ export * from './transaction/igx-transaction';
1717
export * from './transaction/base-transaction';
1818
export * from './transaction/transaction';
1919
export * from './transaction/igx-hierarchical-transaction';
20+
export * from './transaction/hierarchical-transaction';

projects/igniteui-angular/src/lib/services/transaction/README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,3 +47,9 @@ and then inject it in the component's constructor:
4747
|clear | Clears all transactions | id? |
4848
|startPending | Starts pending transactions. All transactions passed after call to startPending will not be added to transaction log | - |
4949
|endPending | Clears all pending transactions and aggregated pending state. If commit is set to true commits pending states as single transaction | commit |
50+
51+
### HierarchicalTransactionService
52+
53+
| Name | Description | Parameters |
54+
|-----------------------|---------------------------------------------------------------|---------------------------|
55+
|commit | Applies all transactions over the provided data | data, primaryKey, childDataKey, id? |
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import { TransactionService, HierarchicalState, HierarchicalTransaction } from './transaction';
2+
3+
export interface HierarchicalTransactionService<T extends HierarchicalTransaction, S extends HierarchicalState>
4+
extends TransactionService<T, S> {
5+
/**
6+
* Applies all transactions over the provided data
7+
* @param data Data source to update
8+
* @param id Optional record id to commit transactions for
9+
*/
10+
commit(data: any[], id?: any): void;
11+
/**
12+
* Applies all transactions over the provided data
13+
* @param data Data source to update
14+
* @param primaryKey Primary key of the hierarchical data
15+
* @param childDataKey Key of child data collection
16+
* @param id Optional record id to commit transactions for
17+
*/
18+
// tslint:disable-next-line: unified-signatures
19+
commit(data: any[], primaryKey: any, childDataKey: any, id?: any): void;
20+
}

projects/igniteui-angular/src/lib/services/transaction/igx-hierarchical-transaction.ts

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,12 @@ import { Injectable } from '@angular/core';
33
import { IgxTransactionService } from './igx-transaction';
44
import { DataUtil } from '../../data-operations/data-util';
55
import { cloneValue } from '../../core/utils';
6+
import { HierarchicalTransactionService } from './hierarchical-transaction';
67

78
/** @experimental @hidden */
89
@Injectable()
910
export class IgxHierarchicalTransactionService<T extends HierarchicalTransaction, S extends HierarchicalState>
10-
extends IgxTransactionService<T, S> {
11+
extends IgxTransactionService<T, S> implements HierarchicalTransactionService<T, S> {
1112

1213
public getAggregatedChanges(mergeChanges: boolean): T[] {
1314
const result: T[] = [];
@@ -51,23 +52,16 @@ export class IgxHierarchicalTransactionService<T extends HierarchicalTransaction
5152
}
5253
}
5354

54-
/**
55-
* Applies all transactions over the provided data
56-
* @param data Data source to update
57-
* @param primaryKey Primary key of the hierarchical data
58-
* @param childDataKey Key of child data collection
59-
* @param id Optional record id to commit transactions for
60-
*/
61-
public commit(data: any[], primaryKey?: any, childDataKey?: any, id?: any): void {
55+
public commit(data: any[], primaryKeyOrId?: any, childDataKey?: any, id?: any): void {
6256
if (childDataKey !== undefined) {
6357
let transactions = this.getAggregatedChanges(true);
6458
if (id !== undefined) {
6559
transactions = transactions.filter(t => t.id === id);
6660
}
67-
DataUtil.mergeHierarchicalTransactions(data, transactions, childDataKey, primaryKey, true);
61+
DataUtil.mergeHierarchicalTransactions(data, transactions, childDataKey, primaryKeyOrId, true);
6862
this.clear(id);
6963
} else {
70-
super.commit(data, id);
64+
super.commit(data, primaryKeyOrId);
7165
}
7266
}
7367

0 commit comments

Comments
 (0)