Skip to content

Commit

Permalink
feat(tree-grid): update flat data transaction, #2921
Browse files Browse the repository at this point in the history
_useInUndo flag added to IgxTreeGrid. When cascading delete rows in flat data
set this flag to false and push add it this way in transaction. This allow undo
to skip this transactions.
  • Loading branch information
wnvko committed Nov 14, 2018
1 parent fee032f commit 0e89cf3
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ let NEXT_ID = 0;
})
export class IgxTreeGridComponent extends IgxGridBaseComponent {
private _id = `igx-tree-grid-${NEXT_ID++}`;
private _useInUndoStack = true;

/**
* An @Input property that sets the value of the `id` attribute. If not provided it will be automatically generated.
Expand Down Expand Up @@ -430,7 +431,9 @@ export class IgxTreeGridComponent extends IgxGridBaseComponent {
if (treeRecord && treeRecord.children && treeRecord.children.length > 0) {
for (let i = 0; i < treeRecord.children.length; i++) {
const child = treeRecord.children[i];
this._useInUndoStack = false;
super.deleteRowById(child.rowID);
this._useInUndoStack = true;
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,13 @@ import { IgxTransactionService } from '..';
export class IgxHierarchicalTransactionService<T extends HierarchicalTransaction, S extends HierarchicalState>
extends IgxTransactionService<T, S> {


public add(transaction: T, recordRef?: any, useInUndo = true): void {
const states = this._isPending ? this._pendingStates : this._states;
this.verifyAddedTransaction(states, transaction, recordRef);
super.addTransaction(transaction, states, recordRef, useInUndo);
}

public getAggregatedChanges(mergeChanges: boolean): T[] {
const result: T[] = [];
this._states.forEach((state: S, key: any) => {
Expand Down

0 comments on commit 0e89cf3

Please sign in to comment.