Skip to content

Commit

Permalink
refactor(igxTreeGrid): remove path splice in merge, #2921
Browse files Browse the repository at this point in the history
Also fix incorrect test.
  • Loading branch information
wnvko committed Dec 6, 2018
1 parent e7c973a commit b7d28dd
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -523,13 +523,13 @@ function testMerging() {
id: data[2].Employees[0].ID,
newValue: updateChildRow1,
type: TransactionType.UPDATE,
path: [data[2].ID, data[2].Employees[0].ID]
path: [data[2].ID]
},
{
id: (data[0].Employees[2] as any).Employees[0].ID,
newValue: updateChildRow2,
type: TransactionType.UPDATE,
path: [data[0].ID, data[0].Employees[2].ID, (data[0].Employees[2] as any).Employees[0].ID]
path: [data[0].ID, data[0].Employees[2].ID]
},
];

Expand All @@ -548,13 +548,13 @@ function testMerging() {
const data = SampleTestData.employeeSmallTreeData();
const transactions: HierarchicalTransaction[] = [
// root row with no children
{ id: data[1].ID, newValue: null, type: TransactionType.DELETE, path: [data[1].ID] },
{ id: data[1].ID, newValue: null, type: TransactionType.DELETE, path: [] },
// root row with children
{ id: data[2].ID, newValue: null, type: TransactionType.DELETE, path: [data[2].ID] },
{ id: data[2].ID, newValue: null, type: TransactionType.DELETE, path: [] },
// child row with no children
{ id: data[0].Employees[0].ID, newValue: null, type: TransactionType.DELETE, path: [data[0].ID, data[0].Employees[0].ID] },
{ id: data[0].Employees[0].ID, newValue: null, type: TransactionType.DELETE, path: [data[0].ID] },
// child row with children
{ id: data[0].Employees[2].ID, newValue: null, type: TransactionType.DELETE, path: [data[0].ID, data[0].Employees[2].ID] }
{ id: data[0].Employees[2].ID, newValue: null, type: TransactionType.DELETE, path: [data[0].ID] }
];

DataUtil.mergeHierarchicalTransactions(data, transactions, 'Employees', 'ID', true);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -230,14 +230,7 @@ export class DataUtil {
const transaction = transactions[i];

if (transaction.path) {
const path = [...transaction.path];
// We need to get parent data row. If there is a path and path contains this row id,
// this is the case for UPDATE and DELETE transactions type, remove the last id from
// the path
if (path.find(id => id === transaction.id)) {
path.splice(-1, 1);
}
const dataRow = this.findDataRowFromPath(data, primaryKey, childDataKey, path);
const dataRow = this.findDataRowFromPath(data, primaryKey, childDataKey, transaction.path);
switch (transaction.type) {
case TransactionType.ADD:
// if there is no dataRow this is ADD row at root level
Expand Down

0 comments on commit b7d28dd

Please sign in to comment.