Skip to content

Commit eaf763f

Browse files
authored
Merge branch 'master' into simeonoff/dockmgr-theme
2 parents e9ab628 + 67b4fbb commit eaf763f

File tree

2 files changed

+23
-2
lines changed

2 files changed

+23
-2
lines changed

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ export class IgxHierarchicalTransactionService<T extends HierarchicalTransaction
5555
* Applies all transactions over the provided data
5656
* @param data Data source to update
5757
* @param primaryKey Primary key of the hierarchical data
58-
* @param childDataKey Kye of child data collection
58+
* @param childDataKey Key of child data collection
5959
* @param id Optional record id to commit transactions for
6060
*/
6161
public commit(data: any[], primaryKey?: any, childDataKey?: any, id?: any): void {
@@ -65,10 +65,10 @@ export class IgxHierarchicalTransactionService<T extends HierarchicalTransaction
6565
transactions = transactions.filter(t => t.id === id);
6666
}
6767
DataUtil.mergeHierarchicalTransactions(data, transactions, childDataKey, primaryKey, true);
68+
this.clear(id);
6869
} else {
6970
super.commit(data, id);
7071
}
71-
this.clear(id);
7272
}
7373

7474
// TODO: remove this method. Force cloning to strip child arrays when needed instead

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

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -945,5 +945,26 @@ describe('IgxTransaction', () => {
945945
expect(transaction.canUndo).toBeFalsy();
946946
expect(transaction.getAggregatedChanges(false).length).toBe(0);
947947
});
948+
949+
it('Should emit onStateUpdate once when commiting a hierarchical transaction', () => {
950+
const data = SampleTestData.employeeTreeData();
951+
const transaction = new IgxHierarchicalTransactionService();
952+
spyOn(transaction.onStateUpdate, 'emit').and.callThrough();
953+
expect(transaction).toBeDefined();
954+
955+
const updateTransaction: HierarchicalTransaction = {
956+
id: 475,
957+
type: TransactionType.UPDATE,
958+
newValue: {
959+
Age: 60
960+
},
961+
path: [data[0].ID]
962+
};
963+
transaction.add(updateTransaction, data[0].Employees[0]);
964+
expect(transaction.onStateUpdate.emit).toHaveBeenCalledTimes(1);
965+
966+
transaction.commit(data, 'ID');
967+
expect(transaction.onStateUpdate.emit).toHaveBeenCalledTimes(2);
968+
});
948969
});
949970
});

0 commit comments

Comments
 (0)