ng-prime-tools 1.1.28 → 1.1.29
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -300,6 +300,21 @@ class PTAdvancedPrimeTableComponent {
|
|
|
300
300
|
const incomingData = (dataChange.currentValue ?? []);
|
|
301
301
|
if (this.isPendingReorderEcho(incomingData)) {
|
|
302
302
|
this.data = incomingData;
|
|
303
|
+
/*
|
|
304
|
+
* The consumer commonly returns cloned rows after a reorder (for
|
|
305
|
+
* example to update an order/rank property). Keep the current visual
|
|
306
|
+
* order, but replace the internal row references with the latest input
|
|
307
|
+
* objects. Otherwise, the next reorder compares objects originating
|
|
308
|
+
* from two different array instances and cannot merge the movement.
|
|
309
|
+
*/
|
|
310
|
+
this.tableData = this.reconcileRowsByIdentity(this.tableData, incomingData);
|
|
311
|
+
if (this.dt) {
|
|
312
|
+
this.dt.value = this.tableData;
|
|
313
|
+
if (Array.isArray(this.dt.filteredValue)) {
|
|
314
|
+
this.dt.filteredValue = this.reconcileRowsByIdentity(this.dt.filteredValue, incomingData);
|
|
315
|
+
}
|
|
316
|
+
}
|
|
317
|
+
this.refreshReorderIndexes();
|
|
303
318
|
this.pendingReorderSignature = null;
|
|
304
319
|
return;
|
|
305
320
|
}
|
|
@@ -556,10 +571,10 @@ class PTAdvancedPrimeTableComponent {
|
|
|
556
571
|
return reorderedRows;
|
|
557
572
|
}
|
|
558
573
|
mergeReorderedRows(sourceRows, activeRows, reorderedActiveRows) {
|
|
559
|
-
const
|
|
574
|
+
const activeRowIdentities = new Set(activeRows.map((row) => this.getRowIdentity(row)));
|
|
560
575
|
let activeRowIndex = 0;
|
|
561
576
|
return (sourceRows ?? []).map((row) => {
|
|
562
|
-
if (!
|
|
577
|
+
if (!activeRowIdentities.has(this.getRowIdentity(row))) {
|
|
563
578
|
return row;
|
|
564
579
|
}
|
|
565
580
|
const reorderedRow = reorderedActiveRows[activeRowIndex];
|
|
@@ -567,6 +582,13 @@ class PTAdvancedPrimeTableComponent {
|
|
|
567
582
|
return reorderedRow;
|
|
568
583
|
});
|
|
569
584
|
}
|
|
585
|
+
reconcileRowsByIdentity(orderedRows, incomingRows) {
|
|
586
|
+
const incomingByIdentity = new Map();
|
|
587
|
+
(incomingRows ?? []).forEach((row) => {
|
|
588
|
+
incomingByIdentity.set(this.getRowIdentity(row), row);
|
|
589
|
+
});
|
|
590
|
+
return (orderedRows ?? []).map((row) => incomingByIdentity.get(this.getRowIdentity(row)) ?? row);
|
|
591
|
+
}
|
|
570
592
|
reorderRows(oldIndex, newIndex) {
|
|
571
593
|
const activeRows = this.activeRowsForReorder;
|
|
572
594
|
if (oldIndex < 0 ||
|