igniteui-angular 12.3.5 → 12.3.6
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.
- package/bundles/igniteui-angular.umd.js +87 -20
- package/bundles/igniteui-angular.umd.js.map +1 -1
- package/esm2015/lib/core/utils.js +14 -2
- package/esm2015/lib/data-operations/data-clone-strategy.js +7 -0
- package/esm2015/lib/data-operations/data-util.js +7 -6
- package/esm2015/lib/grids/api.service.js +2 -2
- package/esm2015/lib/grids/common/crud.service.js +4 -3
- package/esm2015/lib/grids/common/grid.interface.js +1 -1
- package/esm2015/lib/grids/common/pipes.js +2 -2
- package/esm2015/lib/grids/grid-base.directive.js +25 -1
- package/esm2015/lib/grids/grid-public-row.js +3 -4
- package/esm2015/lib/grids/row.directive.js +2 -3
- package/esm2015/lib/grids/summaries/grid-summary.service.js +2 -2
- package/esm2015/lib/grids/tree-grid/tree-grid.pipes.js +3 -3
- package/esm2015/lib/services/transaction/base-transaction.js +17 -4
- package/esm2015/lib/services/transaction/igx-hierarchical-transaction.js +3 -4
- package/esm2015/lib/services/transaction/igx-transaction.js +3 -3
- package/esm2015/lib/services/transaction/transaction-factory.service.js +1 -2
- package/esm2015/lib/services/transaction/transaction.js +1 -1
- package/esm2015/public_api.js +2 -1
- package/fesm2015/igniteui-angular.js +74 -21
- package/fesm2015/igniteui-angular.js.map +1 -1
- package/igniteui-angular.metadata.json +1 -1
- package/lib/core/utils.d.ts +8 -0
- package/lib/data-operations/data-clone-strategy.d.ts +6 -0
- package/lib/data-operations/data-util.d.ts +3 -2
- package/lib/grids/common/grid.interface.d.ts +2 -0
- package/lib/grids/grid-base.directive.d.ts +12 -0
- package/lib/services/transaction/base-transaction.d.ts +7 -0
- package/lib/services/transaction/transaction.d.ts +5 -0
- package/package.json +1 -1
- package/public_api.d.ts +1 -0
|
@@ -1334,6 +1334,18 @@
|
|
|
1334
1334
|
}
|
|
1335
1335
|
return result;
|
|
1336
1336
|
};
|
|
1337
|
+
/**
|
|
1338
|
+
* Creates an object with prototype from provided source and copies
|
|
1339
|
+
* all properties descriptors from provided source
|
|
1340
|
+
*
|
|
1341
|
+
* @param obj Source to copy prototype and descriptors from
|
|
1342
|
+
* @returns New object with cloned prototype and property descriptors
|
|
1343
|
+
*/
|
|
1344
|
+
var copyDescriptors = function (obj) {
|
|
1345
|
+
if (obj) {
|
|
1346
|
+
return Object.create(Object.getPrototypeOf(obj), Object.getOwnPropertyDescriptors(obj));
|
|
1347
|
+
}
|
|
1348
|
+
};
|
|
1337
1349
|
/**
|
|
1338
1350
|
* Deep clones all first level keys of Obj2 and merges them to Obj1
|
|
1339
1351
|
*
|
|
@@ -1421,7 +1433,7 @@
|
|
|
1421
1433
|
* @returns true if provided variable is Object
|
|
1422
1434
|
* @hidden
|
|
1423
1435
|
*/
|
|
1424
|
-
var isObject = function (value) { return value && value.toString() === '[object Object]'; };
|
|
1436
|
+
var isObject = function (value) { return !!(value && value.toString() === '[object Object]'); };
|
|
1425
1437
|
/**
|
|
1426
1438
|
* Checks if provided variable is Date
|
|
1427
1439
|
*
|
|
@@ -2505,6 +2517,15 @@
|
|
|
2505
2517
|
TransactionEventOrigin["END"] = "endPending";
|
|
2506
2518
|
})(exports.TransactionEventOrigin || (exports.TransactionEventOrigin = {}));
|
|
2507
2519
|
|
|
2520
|
+
var DefaultDataCloneStrategy = /** @class */ (function () {
|
|
2521
|
+
function DefaultDataCloneStrategy() {
|
|
2522
|
+
}
|
|
2523
|
+
DefaultDataCloneStrategy.prototype.clone = function (data) {
|
|
2524
|
+
return cloneValue(data);
|
|
2525
|
+
};
|
|
2526
|
+
return DefaultDataCloneStrategy;
|
|
2527
|
+
}());
|
|
2528
|
+
|
|
2508
2529
|
/**
|
|
2509
2530
|
* @hidden
|
|
2510
2531
|
*/
|
|
@@ -2619,13 +2640,14 @@
|
|
|
2619
2640
|
* @param deleteRows Should delete rows with DELETE transaction type from data
|
|
2620
2641
|
* @returns Provided data collections updated with all provided transactions
|
|
2621
2642
|
*/
|
|
2622
|
-
DataUtil.mergeTransactions = function (data, transactions, primaryKey, deleteRows) {
|
|
2643
|
+
DataUtil.mergeTransactions = function (data, transactions, primaryKey, cloneStrategy, deleteRows) {
|
|
2644
|
+
if (cloneStrategy === void 0) { cloneStrategy = new DefaultDataCloneStrategy(); }
|
|
2623
2645
|
if (deleteRows === void 0) { deleteRows = false; }
|
|
2624
2646
|
data.forEach(function (item, index) {
|
|
2625
2647
|
var rowId = primaryKey ? item[primaryKey] : item;
|
|
2626
2648
|
var transaction = transactions.find(function (t) { return t.id === rowId; });
|
|
2627
2649
|
if (transaction && transaction.type === exports.TransactionType.UPDATE) {
|
|
2628
|
-
data[index] = transaction.newValue;
|
|
2650
|
+
data[index] = mergeObjects(cloneStrategy.clone(data[index]), transaction.newValue);
|
|
2629
2651
|
}
|
|
2630
2652
|
});
|
|
2631
2653
|
if (deleteRows) {
|
|
@@ -2653,8 +2675,9 @@
|
|
|
2653
2675
|
* @param deleteRows Should delete rows with DELETE transaction type from data
|
|
2654
2676
|
* @returns Provided data collections updated with all provided transactions
|
|
2655
2677
|
*/
|
|
2656
|
-
DataUtil.mergeHierarchicalTransactions = function (data, transactions, childDataKey, primaryKey, deleteRows) {
|
|
2678
|
+
DataUtil.mergeHierarchicalTransactions = function (data, transactions, childDataKey, primaryKey, cloneStrategy, deleteRows) {
|
|
2657
2679
|
var e_1, _a;
|
|
2680
|
+
if (cloneStrategy === void 0) { cloneStrategy = new DefaultDataCloneStrategy(); }
|
|
2658
2681
|
if (deleteRows === void 0) { deleteRows = false; }
|
|
2659
2682
|
var _loop_1 = function (transaction) {
|
|
2660
2683
|
if (transaction.path) {
|
|
@@ -2671,7 +2694,7 @@
|
|
|
2671
2694
|
case exports.TransactionType.UPDATE:
|
|
2672
2695
|
var updateIndex = collection.findIndex(function (x) { return x[primaryKey] === transaction.id; });
|
|
2673
2696
|
if (updateIndex !== -1) {
|
|
2674
|
-
collection[updateIndex] = mergeObjects(
|
|
2697
|
+
collection[updateIndex] = mergeObjects(cloneStrategy.clone(collection[updateIndex]), transaction.newValue);
|
|
2675
2698
|
}
|
|
2676
2699
|
break;
|
|
2677
2700
|
case exports.TransactionType.DELETE:
|
|
@@ -7187,7 +7210,8 @@
|
|
|
7187
7210
|
var rowInEditMode = grid.gridAPI.crudService.row;
|
|
7188
7211
|
row.newData = value !== null && value !== void 0 ? value : rowInEditMode.transactionState;
|
|
7189
7212
|
if (rowInEditMode && row.id === rowInEditMode.id) {
|
|
7190
|
-
|
|
7213
|
+
// do not use spread operator here as it will copy everything over an empty object with no descriptors
|
|
7214
|
+
row.data = Object.assign(copyDescriptors(row.data), row.data, rowInEditMode.transactionState);
|
|
7191
7215
|
// TODO: Workaround for updating a row in edit mode through the API
|
|
7192
7216
|
}
|
|
7193
7217
|
else if (this.grid.transactions.enabled) {
|
|
@@ -7460,7 +7484,7 @@
|
|
|
7460
7484
|
}
|
|
7461
7485
|
if (!data) {
|
|
7462
7486
|
if (grid.transactions.enabled) {
|
|
7463
|
-
data = DataUtil.mergeTransactions(cloneArray(grid.data), grid.transactions.getAggregatedChanges(true), grid.primaryKey);
|
|
7487
|
+
data = DataUtil.mergeTransactions(cloneArray(grid.data), grid.transactions.getAggregatedChanges(true), grid.primaryKey, grid.dataCloneStrategy);
|
|
7464
7488
|
var deletedRows = grid.transactions.getTransactionLog().filter(function (t) { return t.type === exports.TransactionType.DELETE; }).map(function (t) { return t.id; });
|
|
7465
7489
|
deletedRows.forEach(function (rowID) {
|
|
7466
7490
|
var tempData = grid.primaryKey ? data.map(function (rec) { return rec[grid.primaryKey]; }) : data;
|
|
@@ -8608,7 +8632,7 @@
|
|
|
8608
8632
|
*/
|
|
8609
8633
|
get: function () {
|
|
8610
8634
|
if (this.inEditMode) {
|
|
8611
|
-
return mergeWith__default["default"](
|
|
8635
|
+
return mergeWith__default["default"](this.grid.dataCloneStrategy.clone(this._rowData), this.grid.transactions.getAggregatedValue(this.rowID, false), function (objValue, srcValue) {
|
|
8612
8636
|
if (Array.isArray(srcValue)) {
|
|
8613
8637
|
return objValue = srcValue;
|
|
8614
8638
|
}
|
|
@@ -16906,7 +16930,23 @@
|
|
|
16906
16930
|
this._isPending = false;
|
|
16907
16931
|
this._pendingTransactions = [];
|
|
16908
16932
|
this._pendingStates = new Map();
|
|
16933
|
+
this._cloneStrategy = new DefaultDataCloneStrategy();
|
|
16909
16934
|
}
|
|
16935
|
+
Object.defineProperty(IgxBaseTransactionService.prototype, "cloneStrategy", {
|
|
16936
|
+
/**
|
|
16937
|
+
* @inheritdoc
|
|
16938
|
+
*/
|
|
16939
|
+
get: function () {
|
|
16940
|
+
return this._cloneStrategy;
|
|
16941
|
+
},
|
|
16942
|
+
set: function (strategy) {
|
|
16943
|
+
if (strategy) {
|
|
16944
|
+
this._cloneStrategy = strategy;
|
|
16945
|
+
}
|
|
16946
|
+
},
|
|
16947
|
+
enumerable: false,
|
|
16948
|
+
configurable: true
|
|
16949
|
+
});
|
|
16910
16950
|
Object.defineProperty(IgxBaseTransactionService.prototype, "canRedo", {
|
|
16911
16951
|
/**
|
|
16912
16952
|
* @inheritdoc
|
|
@@ -17034,7 +17074,7 @@
|
|
|
17034
17074
|
}
|
|
17035
17075
|
}
|
|
17036
17076
|
else {
|
|
17037
|
-
state = { value:
|
|
17077
|
+
state = { value: this.cloneStrategy.clone(transaction.newValue), recordRef: recordRef, type: transaction.type };
|
|
17038
17078
|
states.set(transaction.id, state);
|
|
17039
17079
|
}
|
|
17040
17080
|
};
|
|
@@ -17056,7 +17096,7 @@
|
|
|
17056
17096
|
*/
|
|
17057
17097
|
IgxBaseTransactionService.prototype.mergeValues = function (first, second) {
|
|
17058
17098
|
if (isObject(first) || isObject(second)) {
|
|
17059
|
-
return mergeObjects(
|
|
17099
|
+
return mergeObjects(this.cloneStrategy.clone(first), second);
|
|
17060
17100
|
}
|
|
17061
17101
|
else {
|
|
17062
17102
|
return second ? second : first;
|
|
@@ -17382,7 +17422,7 @@
|
|
|
17382
17422
|
}
|
|
17383
17423
|
}
|
|
17384
17424
|
else {
|
|
17385
|
-
state = { value:
|
|
17425
|
+
state = { value: this.cloneStrategy.clone(transaction.newValue), recordRef: recordRef, type: transaction.type };
|
|
17386
17426
|
states.set(transaction.id, state);
|
|
17387
17427
|
}
|
|
17388
17428
|
// should not clean pending state. This will happen automatically on endPending call
|
|
@@ -17473,7 +17513,7 @@
|
|
|
17473
17513
|
var _this = this;
|
|
17474
17514
|
var result = [];
|
|
17475
17515
|
this._states.forEach(function (state, key) {
|
|
17476
|
-
var value = mergeChanges ? _this.mergeValues(state.recordRef, state.value) :
|
|
17516
|
+
var value = mergeChanges ? _this.mergeValues(state.recordRef, state.value) : _this.cloneStrategy.clone(state.value);
|
|
17477
17517
|
_this.clearArraysFromObject(value);
|
|
17478
17518
|
result.push({ id: key, path: state.path, newValue: value, type: state.type });
|
|
17479
17519
|
});
|
|
@@ -17485,7 +17525,7 @@
|
|
|
17485
17525
|
if (id !== undefined) {
|
|
17486
17526
|
transactions = transactions.filter(function (t) { return t.id === id; });
|
|
17487
17527
|
}
|
|
17488
|
-
DataUtil.mergeHierarchicalTransactions(data, transactions, childDataKey, primaryKeyOrId, true);
|
|
17528
|
+
DataUtil.mergeHierarchicalTransactions(data, transactions, childDataKey, primaryKeyOrId, this.cloneStrategy, true);
|
|
17489
17529
|
this.clear(id);
|
|
17490
17530
|
}
|
|
17491
17531
|
else {
|
|
@@ -17591,7 +17631,6 @@
|
|
|
17591
17631
|
switch (type) {
|
|
17592
17632
|
case ("Base" /* Base */):
|
|
17593
17633
|
return new IgxHierarchicalTransactionService();
|
|
17594
|
-
;
|
|
17595
17634
|
default:
|
|
17596
17635
|
return new IgxBaseTransactionService();
|
|
17597
17636
|
}
|
|
@@ -49274,7 +49313,7 @@
|
|
|
49274
49313
|
var summaryIDs = [];
|
|
49275
49314
|
var data = this.grid.data;
|
|
49276
49315
|
if (this.grid.transactions.enabled) {
|
|
49277
|
-
data = DataUtil.mergeTransactions(cloneArray(this.grid.data), this.grid.transactions.getAggregatedChanges(true), this.grid.primaryKey);
|
|
49316
|
+
data = DataUtil.mergeTransactions(cloneArray(this.grid.data), this.grid.transactions.getAggregatedChanges(true), this.grid.primaryKey, this.grid.dataCloneStrategy);
|
|
49278
49317
|
}
|
|
49279
49318
|
var rowData = this.grid.primaryKey ? data.find(function (rec) { return rec[_this.grid.primaryKey] === rowID; }) : rowID;
|
|
49280
49319
|
var id = '{ ';
|
|
@@ -55535,6 +55574,7 @@
|
|
|
55535
55574
|
outlet: _this.rowOutletDirective,
|
|
55536
55575
|
positionStrategy: _this.rowEditPositioningStrategy
|
|
55537
55576
|
};
|
|
55577
|
+
_this._dataCloneStrategy = new DefaultDataCloneStrategy();
|
|
55538
55578
|
_this.transactionChange$ = new rxjs.Subject();
|
|
55539
55579
|
_this._rendered = false;
|
|
55540
55580
|
_this.DRAG_SCROLL_DELTA = 10;
|
|
@@ -55557,6 +55597,7 @@
|
|
|
55557
55597
|
_this.currencyPipe = new i2.CurrencyPipe(_this.locale);
|
|
55558
55598
|
_this.percentPipe = new i2.PercentPipe(_this.locale);
|
|
55559
55599
|
_this._transactions = _this.transactionFactory.create("None" /* None */);
|
|
55600
|
+
_this._transactions.cloneStrategy = _this.dataCloneStrategy;
|
|
55560
55601
|
_this.cdr.detach();
|
|
55561
55602
|
return _this;
|
|
55562
55603
|
}
|
|
@@ -55567,6 +55608,27 @@
|
|
|
55567
55608
|
enumerable: false,
|
|
55568
55609
|
configurable: true
|
|
55569
55610
|
});
|
|
55611
|
+
Object.defineProperty(IgxGridBaseDirective.prototype, "dataCloneStrategy", {
|
|
55612
|
+
/**
|
|
55613
|
+
* Gets/Sets the data clone strategy of the grid when in edit mode.
|
|
55614
|
+
*
|
|
55615
|
+
* @example
|
|
55616
|
+
* ```html
|
|
55617
|
+
* <igx-grid #grid [data]="localData" [dataCloneStrategy]="customCloneStrategy"></igx-grid>
|
|
55618
|
+
* ```
|
|
55619
|
+
*/
|
|
55620
|
+
get: function () {
|
|
55621
|
+
return this._dataCloneStrategy;
|
|
55622
|
+
},
|
|
55623
|
+
set: function (strategy) {
|
|
55624
|
+
if (strategy) {
|
|
55625
|
+
this._dataCloneStrategy = strategy;
|
|
55626
|
+
this._transactions.cloneStrategy = strategy;
|
|
55627
|
+
}
|
|
55628
|
+
},
|
|
55629
|
+
enumerable: false,
|
|
55630
|
+
configurable: true
|
|
55631
|
+
});
|
|
55570
55632
|
Object.defineProperty(IgxGridBaseDirective.prototype, "headerContainer", {
|
|
55571
55633
|
get: function () {
|
|
55572
55634
|
return this.theadRow.headerContainer;
|
|
@@ -60247,6 +60309,9 @@
|
|
|
60247
60309
|
else {
|
|
60248
60310
|
this._transactions = this.transactionFactory.create("None" /* None */);
|
|
60249
60311
|
}
|
|
60312
|
+
if (this.dataCloneStrategy) {
|
|
60313
|
+
this._transactions.cloneStrategy = this.dataCloneStrategy;
|
|
60314
|
+
}
|
|
60250
60315
|
};
|
|
60251
60316
|
IgxGridBaseDirective.prototype.subscribeToTransactions = function () {
|
|
60252
60317
|
this.transactionChange$.next();
|
|
@@ -61636,6 +61701,7 @@
|
|
|
61636
61701
|
primaryKey: [{ type: i0.Input }],
|
|
61637
61702
|
uniqueColumnValuesStrategy: [{ type: i0.Input }],
|
|
61638
61703
|
excelStyleFilteringComponents: [{ type: i0.ContentChildren, args: [IgxGridExcelStyleFilteringComponent, { read: IgxGridExcelStyleFilteringComponent, descendants: false },] }],
|
|
61704
|
+
dataCloneStrategy: [{ type: i0.Input }],
|
|
61639
61705
|
cellClick: [{ type: i0.Output }],
|
|
61640
61706
|
selected: [{ type: i0.Output }],
|
|
61641
61707
|
rowSelected: [{ type: i0.Output }],
|
|
@@ -61884,7 +61950,7 @@
|
|
|
61884
61950
|
get: function () {
|
|
61885
61951
|
var _a, _b;
|
|
61886
61952
|
if (this.inEditMode) {
|
|
61887
|
-
return mergeWith__default["default"](
|
|
61953
|
+
return mergeWith__default["default"](this.grid.dataCloneStrategy.clone((_a = this._data) !== null && _a !== void 0 ? _a : this.grid.dataView[this.index]), this.grid.transactions.getAggregatedValue(this.key, false), function (objValue, srcValue) {
|
|
61888
61954
|
if (Array.isArray(srcValue)) {
|
|
61889
61955
|
return objValue = srcValue;
|
|
61890
61956
|
}
|
|
@@ -62244,7 +62310,7 @@
|
|
|
62244
62310
|
get: function () {
|
|
62245
62311
|
var _a;
|
|
62246
62312
|
if (this.inEditMode) {
|
|
62247
|
-
return mergeWith__default["default"](
|
|
62313
|
+
return mergeWith__default["default"](this.grid.dataCloneStrategy.clone((_a = this._data) !== null && _a !== void 0 ? _a : this.grid.dataView[this.index]), this.grid.transactions.getAggregatedValue(this.key, false), function (objValue, srcValue) {
|
|
62248
62314
|
if (Array.isArray(srcValue)) {
|
|
62249
62315
|
return objValue = srcValue;
|
|
62250
62316
|
}
|
|
@@ -64600,7 +64666,7 @@
|
|
|
64600
64666
|
IgxGridTransactionPipe.prototype.transform = function (collection, _id, _pipeTrigger) {
|
|
64601
64667
|
var grid = this.gridAPI.grid;
|
|
64602
64668
|
if (grid.transactions.enabled) {
|
|
64603
|
-
var result = DataUtil.mergeTransactions(cloneArray(collection), grid.transactions.getAggregatedChanges(true), grid.primaryKey);
|
|
64669
|
+
var result = DataUtil.mergeTransactions(cloneArray(collection), grid.transactions.getAggregatedChanges(true), grid.primaryKey, grid.dataCloneStrategy);
|
|
64604
64670
|
return result;
|
|
64605
64671
|
}
|
|
64606
64672
|
return collection;
|
|
@@ -74403,11 +74469,11 @@
|
|
|
74403
74469
|
var childDataKey = grid.childDataKey;
|
|
74404
74470
|
if (foreignKey) {
|
|
74405
74471
|
var flatDataClone = cloneArray(collection);
|
|
74406
|
-
return DataUtil.mergeTransactions(flatDataClone, aggregatedChanges, grid.primaryKey);
|
|
74472
|
+
return DataUtil.mergeTransactions(flatDataClone, aggregatedChanges, grid.primaryKey, grid.dataCloneStrategy);
|
|
74407
74473
|
}
|
|
74408
74474
|
else if (childDataKey) {
|
|
74409
74475
|
var hierarchicalDataClone = cloneHierarchicalArray(collection, childDataKey);
|
|
74410
|
-
return DataUtil.mergeHierarchicalTransactions(hierarchicalDataClone, aggregatedChanges, childDataKey, grid.primaryKey);
|
|
74476
|
+
return DataUtil.mergeHierarchicalTransactions(hierarchicalDataClone, aggregatedChanges, childDataKey, grid.primaryKey, grid.dataCloneStrategy);
|
|
74411
74477
|
}
|
|
74412
74478
|
}
|
|
74413
74479
|
}
|
|
@@ -86035,6 +86101,7 @@
|
|
|
86035
86101
|
exports.DEFAULT_OWNER = DEFAULT_OWNER;
|
|
86036
86102
|
exports.DataUtil = DataUtil;
|
|
86037
86103
|
exports.DateRangePickerFormatPipe = DateRangePickerFormatPipe;
|
|
86104
|
+
exports.DefaultDataCloneStrategy = DefaultDataCloneStrategy;
|
|
86038
86105
|
exports.DefaultSortingStrategy = DefaultSortingStrategy;
|
|
86039
86106
|
exports.DisplayDensity = DisplayDensity;
|
|
86040
86107
|
exports.DisplayDensityBase = DisplayDensityBase;
|