igniteui-angular 12.2.6 → 12.2.7
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
|
@@ -1336,6 +1336,18 @@
|
|
|
1336
1336
|
}
|
|
1337
1337
|
return result;
|
|
1338
1338
|
};
|
|
1339
|
+
/**
|
|
1340
|
+
* Creates an object with prototype from provided source and copies
|
|
1341
|
+
* all properties descriptors from provided source
|
|
1342
|
+
*
|
|
1343
|
+
* @param obj Source to copy prototype and descriptors from
|
|
1344
|
+
* @returns New object with cloned prototype and property descriptors
|
|
1345
|
+
*/
|
|
1346
|
+
var copyDescriptors = function (obj) {
|
|
1347
|
+
if (obj) {
|
|
1348
|
+
return Object.create(Object.getPrototypeOf(obj), Object.getOwnPropertyDescriptors(obj));
|
|
1349
|
+
}
|
|
1350
|
+
};
|
|
1339
1351
|
/**
|
|
1340
1352
|
* Deep clones all first level keys of Obj2 and merges them to Obj1
|
|
1341
1353
|
*
|
|
@@ -1423,7 +1435,7 @@
|
|
|
1423
1435
|
* @returns true if provided variable is Object
|
|
1424
1436
|
* @hidden
|
|
1425
1437
|
*/
|
|
1426
|
-
var isObject = function (value) { return value && value.toString() === '[object Object]'; };
|
|
1438
|
+
var isObject = function (value) { return !!(value && value.toString() === '[object Object]'); };
|
|
1427
1439
|
/**
|
|
1428
1440
|
* Checks if provided variable is Date
|
|
1429
1441
|
*
|
|
@@ -2498,6 +2510,15 @@
|
|
|
2498
2510
|
TransactionEventOrigin["END"] = "endPending";
|
|
2499
2511
|
})(exports.TransactionEventOrigin || (exports.TransactionEventOrigin = {}));
|
|
2500
2512
|
|
|
2513
|
+
var DefaultDataCloneStrategy = /** @class */ (function () {
|
|
2514
|
+
function DefaultDataCloneStrategy() {
|
|
2515
|
+
}
|
|
2516
|
+
DefaultDataCloneStrategy.prototype.clone = function (data) {
|
|
2517
|
+
return cloneValue(data);
|
|
2518
|
+
};
|
|
2519
|
+
return DefaultDataCloneStrategy;
|
|
2520
|
+
}());
|
|
2521
|
+
|
|
2501
2522
|
/**
|
|
2502
2523
|
* @hidden
|
|
2503
2524
|
*/
|
|
@@ -2612,13 +2633,14 @@
|
|
|
2612
2633
|
* @param deleteRows Should delete rows with DELETE transaction type from data
|
|
2613
2634
|
* @returns Provided data collections updated with all provided transactions
|
|
2614
2635
|
*/
|
|
2615
|
-
DataUtil.mergeTransactions = function (data, transactions, primaryKey, deleteRows) {
|
|
2636
|
+
DataUtil.mergeTransactions = function (data, transactions, primaryKey, cloneStrategy, deleteRows) {
|
|
2637
|
+
if (cloneStrategy === void 0) { cloneStrategy = new DefaultDataCloneStrategy(); }
|
|
2616
2638
|
if (deleteRows === void 0) { deleteRows = false; }
|
|
2617
2639
|
data.forEach(function (item, index) {
|
|
2618
2640
|
var rowId = primaryKey ? item[primaryKey] : item;
|
|
2619
2641
|
var transaction = transactions.find(function (t) { return t.id === rowId; });
|
|
2620
2642
|
if (transaction && transaction.type === exports.TransactionType.UPDATE) {
|
|
2621
|
-
data[index] = transaction.newValue;
|
|
2643
|
+
data[index] = mergeObjects(cloneStrategy.clone(data[index]), transaction.newValue);
|
|
2622
2644
|
}
|
|
2623
2645
|
});
|
|
2624
2646
|
if (deleteRows) {
|
|
@@ -2646,8 +2668,9 @@
|
|
|
2646
2668
|
* @param deleteRows Should delete rows with DELETE transaction type from data
|
|
2647
2669
|
* @returns Provided data collections updated with all provided transactions
|
|
2648
2670
|
*/
|
|
2649
|
-
DataUtil.mergeHierarchicalTransactions = function (data, transactions, childDataKey, primaryKey, deleteRows) {
|
|
2671
|
+
DataUtil.mergeHierarchicalTransactions = function (data, transactions, childDataKey, primaryKey, cloneStrategy, deleteRows) {
|
|
2650
2672
|
var e_1, _a;
|
|
2673
|
+
if (cloneStrategy === void 0) { cloneStrategy = new DefaultDataCloneStrategy(); }
|
|
2651
2674
|
if (deleteRows === void 0) { deleteRows = false; }
|
|
2652
2675
|
var _loop_1 = function (transaction) {
|
|
2653
2676
|
if (transaction.path) {
|
|
@@ -2664,7 +2687,7 @@
|
|
|
2664
2687
|
case exports.TransactionType.UPDATE:
|
|
2665
2688
|
var updateIndex = collection.findIndex(function (x) { return x[primaryKey] === transaction.id; });
|
|
2666
2689
|
if (updateIndex !== -1) {
|
|
2667
|
-
collection[updateIndex] = mergeObjects(
|
|
2690
|
+
collection[updateIndex] = mergeObjects(cloneStrategy.clone(collection[updateIndex]), transaction.newValue);
|
|
2668
2691
|
}
|
|
2669
2692
|
break;
|
|
2670
2693
|
case exports.TransactionType.DELETE:
|
|
@@ -7180,7 +7203,8 @@
|
|
|
7180
7203
|
var rowInEditMode = grid.gridAPI.crudService.row;
|
|
7181
7204
|
row.newData = value !== null && value !== void 0 ? value : rowInEditMode.transactionState;
|
|
7182
7205
|
if (rowInEditMode && row.id === rowInEditMode.id) {
|
|
7183
|
-
|
|
7206
|
+
// do not use spread operator here as it will copy everything over an empty object with no descriptors
|
|
7207
|
+
row.data = Object.assign(copyDescriptors(row.data), row.data, rowInEditMode.transactionState);
|
|
7184
7208
|
// TODO: Workaround for updating a row in edit mode through the API
|
|
7185
7209
|
}
|
|
7186
7210
|
else if (this.grid.transactions.enabled) {
|
|
@@ -7453,7 +7477,7 @@
|
|
|
7453
7477
|
}
|
|
7454
7478
|
if (!data) {
|
|
7455
7479
|
if (grid.transactions.enabled) {
|
|
7456
|
-
data = DataUtil.mergeTransactions(cloneArray(grid.data), grid.transactions.getAggregatedChanges(true), grid.primaryKey);
|
|
7480
|
+
data = DataUtil.mergeTransactions(cloneArray(grid.data), grid.transactions.getAggregatedChanges(true), grid.primaryKey, grid.dataCloneStrategy);
|
|
7457
7481
|
var deletedRows = grid.transactions.getTransactionLog().filter(function (t) { return t.type === exports.TransactionType.DELETE; }).map(function (t) { return t.id; });
|
|
7458
7482
|
deletedRows.forEach(function (rowID) {
|
|
7459
7483
|
var tempData = grid.primaryKey ? data.map(function (rec) { return rec[grid.primaryKey]; }) : data;
|
|
@@ -8601,7 +8625,7 @@
|
|
|
8601
8625
|
*/
|
|
8602
8626
|
get: function () {
|
|
8603
8627
|
if (this.inEditMode) {
|
|
8604
|
-
return mergeWith__default['default'](
|
|
8628
|
+
return mergeWith__default['default'](this.grid.dataCloneStrategy.clone(this._rowData), this.grid.transactions.getAggregatedValue(this.rowID, false), function (objValue, srcValue) {
|
|
8605
8629
|
if (Array.isArray(srcValue)) {
|
|
8606
8630
|
return objValue = srcValue;
|
|
8607
8631
|
}
|
|
@@ -16860,7 +16884,23 @@
|
|
|
16860
16884
|
this._isPending = false;
|
|
16861
16885
|
this._pendingTransactions = [];
|
|
16862
16886
|
this._pendingStates = new Map();
|
|
16887
|
+
this._cloneStrategy = new DefaultDataCloneStrategy();
|
|
16863
16888
|
}
|
|
16889
|
+
Object.defineProperty(IgxBaseTransactionService.prototype, "cloneStrategy", {
|
|
16890
|
+
/**
|
|
16891
|
+
* @inheritdoc
|
|
16892
|
+
*/
|
|
16893
|
+
get: function () {
|
|
16894
|
+
return this._cloneStrategy;
|
|
16895
|
+
},
|
|
16896
|
+
set: function (strategy) {
|
|
16897
|
+
if (strategy) {
|
|
16898
|
+
this._cloneStrategy = strategy;
|
|
16899
|
+
}
|
|
16900
|
+
},
|
|
16901
|
+
enumerable: false,
|
|
16902
|
+
configurable: true
|
|
16903
|
+
});
|
|
16864
16904
|
Object.defineProperty(IgxBaseTransactionService.prototype, "canRedo", {
|
|
16865
16905
|
/**
|
|
16866
16906
|
* @inheritdoc
|
|
@@ -16988,7 +17028,7 @@
|
|
|
16988
17028
|
}
|
|
16989
17029
|
}
|
|
16990
17030
|
else {
|
|
16991
|
-
state = { value:
|
|
17031
|
+
state = { value: this.cloneStrategy.clone(transaction.newValue), recordRef: recordRef, type: transaction.type };
|
|
16992
17032
|
states.set(transaction.id, state);
|
|
16993
17033
|
}
|
|
16994
17034
|
};
|
|
@@ -17010,7 +17050,7 @@
|
|
|
17010
17050
|
*/
|
|
17011
17051
|
IgxBaseTransactionService.prototype.mergeValues = function (first, second) {
|
|
17012
17052
|
if (isObject(first) || isObject(second)) {
|
|
17013
|
-
return mergeObjects(
|
|
17053
|
+
return mergeObjects(this.cloneStrategy.clone(first), second);
|
|
17014
17054
|
}
|
|
17015
17055
|
else {
|
|
17016
17056
|
return second ? second : first;
|
|
@@ -17336,7 +17376,7 @@
|
|
|
17336
17376
|
}
|
|
17337
17377
|
}
|
|
17338
17378
|
else {
|
|
17339
|
-
state = { value:
|
|
17379
|
+
state = { value: this.cloneStrategy.clone(transaction.newValue), recordRef: recordRef, type: transaction.type };
|
|
17340
17380
|
states.set(transaction.id, state);
|
|
17341
17381
|
}
|
|
17342
17382
|
// should not clean pending state. This will happen automatically on endPending call
|
|
@@ -17427,7 +17467,7 @@
|
|
|
17427
17467
|
var _this = this;
|
|
17428
17468
|
var result = [];
|
|
17429
17469
|
this._states.forEach(function (state, key) {
|
|
17430
|
-
var value = mergeChanges ? _this.mergeValues(state.recordRef, state.value) :
|
|
17470
|
+
var value = mergeChanges ? _this.mergeValues(state.recordRef, state.value) : _this.cloneStrategy.clone(state.value);
|
|
17431
17471
|
_this.clearArraysFromObject(value);
|
|
17432
17472
|
result.push({ id: key, path: state.path, newValue: value, type: state.type });
|
|
17433
17473
|
});
|
|
@@ -17439,7 +17479,7 @@
|
|
|
17439
17479
|
if (id !== undefined) {
|
|
17440
17480
|
transactions = transactions.filter(function (t) { return t.id === id; });
|
|
17441
17481
|
}
|
|
17442
|
-
DataUtil.mergeHierarchicalTransactions(data, transactions, childDataKey, primaryKeyOrId, true);
|
|
17482
|
+
DataUtil.mergeHierarchicalTransactions(data, transactions, childDataKey, primaryKeyOrId, this.cloneStrategy, true);
|
|
17443
17483
|
this.clear(id);
|
|
17444
17484
|
}
|
|
17445
17485
|
else {
|
|
@@ -17545,7 +17585,6 @@
|
|
|
17545
17585
|
switch (type) {
|
|
17546
17586
|
case ("Base" /* Base */):
|
|
17547
17587
|
return new IgxHierarchicalTransactionService();
|
|
17548
|
-
;
|
|
17549
17588
|
default:
|
|
17550
17589
|
return new IgxBaseTransactionService();
|
|
17551
17590
|
}
|
|
@@ -48809,7 +48848,7 @@
|
|
|
48809
48848
|
var summaryIDs = [];
|
|
48810
48849
|
var data = this.grid.data;
|
|
48811
48850
|
if (this.grid.transactions.enabled) {
|
|
48812
|
-
data = DataUtil.mergeTransactions(cloneArray(this.grid.data), this.grid.transactions.getAggregatedChanges(true), this.grid.primaryKey);
|
|
48851
|
+
data = DataUtil.mergeTransactions(cloneArray(this.grid.data), this.grid.transactions.getAggregatedChanges(true), this.grid.primaryKey, this.grid.dataCloneStrategy);
|
|
48813
48852
|
}
|
|
48814
48853
|
var rowData = this.grid.primaryKey ? data.find(function (rec) { return rec[_this.grid.primaryKey] === rowID; }) : rowID;
|
|
48815
48854
|
var id = '{ ';
|
|
@@ -55058,6 +55097,7 @@
|
|
|
55058
55097
|
outlet: _this.rowOutletDirective,
|
|
55059
55098
|
positionStrategy: _this.rowEditPositioningStrategy
|
|
55060
55099
|
};
|
|
55100
|
+
_this._dataCloneStrategy = new DefaultDataCloneStrategy();
|
|
55061
55101
|
_this.transactionChange$ = new rxjs.Subject();
|
|
55062
55102
|
_this._rendered = false;
|
|
55063
55103
|
_this.DRAG_SCROLL_DELTA = 10;
|
|
@@ -55080,6 +55120,7 @@
|
|
|
55080
55120
|
_this.currencyPipe = new i2.CurrencyPipe(_this.locale);
|
|
55081
55121
|
_this.percentPipe = new i2.PercentPipe(_this.locale);
|
|
55082
55122
|
_this._transactions = _this.transactionFactory.create("None" /* None */);
|
|
55123
|
+
_this._transactions.cloneStrategy = _this.dataCloneStrategy;
|
|
55083
55124
|
_this.cdr.detach();
|
|
55084
55125
|
return _this;
|
|
55085
55126
|
}
|
|
@@ -55090,6 +55131,27 @@
|
|
|
55090
55131
|
enumerable: false,
|
|
55091
55132
|
configurable: true
|
|
55092
55133
|
});
|
|
55134
|
+
Object.defineProperty(IgxGridBaseDirective.prototype, "dataCloneStrategy", {
|
|
55135
|
+
/**
|
|
55136
|
+
* Gets/Sets the data clone strategy of the grid when in edit mode.
|
|
55137
|
+
*
|
|
55138
|
+
* @example
|
|
55139
|
+
* ```html
|
|
55140
|
+
* <igx-grid #grid [data]="localData" [dataCloneStrategy]="customCloneStrategy"></igx-grid>
|
|
55141
|
+
* ```
|
|
55142
|
+
*/
|
|
55143
|
+
get: function () {
|
|
55144
|
+
return this._dataCloneStrategy;
|
|
55145
|
+
},
|
|
55146
|
+
set: function (strategy) {
|
|
55147
|
+
if (strategy) {
|
|
55148
|
+
this._dataCloneStrategy = strategy;
|
|
55149
|
+
this._transactions.cloneStrategy = strategy;
|
|
55150
|
+
}
|
|
55151
|
+
},
|
|
55152
|
+
enumerable: false,
|
|
55153
|
+
configurable: true
|
|
55154
|
+
});
|
|
55093
55155
|
Object.defineProperty(IgxGridBaseDirective.prototype, "headerContainer", {
|
|
55094
55156
|
get: function () {
|
|
55095
55157
|
return this.theadRow.headerContainer;
|
|
@@ -59766,6 +59828,9 @@
|
|
|
59766
59828
|
else {
|
|
59767
59829
|
this._transactions = this.transactionFactory.create("None" /* None */);
|
|
59768
59830
|
}
|
|
59831
|
+
if (this.dataCloneStrategy) {
|
|
59832
|
+
this._transactions.cloneStrategy = this.dataCloneStrategy;
|
|
59833
|
+
}
|
|
59769
59834
|
};
|
|
59770
59835
|
IgxGridBaseDirective.prototype.subscribeToTransactions = function () {
|
|
59771
59836
|
this.transactionChange$.next();
|
|
@@ -61152,6 +61217,7 @@
|
|
|
61152
61217
|
primaryKey: [{ type: i0.Input }],
|
|
61153
61218
|
uniqueColumnValuesStrategy: [{ type: i0.Input }],
|
|
61154
61219
|
excelStyleFilteringComponents: [{ type: i0.ContentChildren, args: [IgxGridExcelStyleFilteringComponent, { read: IgxGridExcelStyleFilteringComponent, descendants: false },] }],
|
|
61220
|
+
dataCloneStrategy: [{ type: i0.Input }],
|
|
61155
61221
|
cellClick: [{ type: i0.Output }],
|
|
61156
61222
|
selected: [{ type: i0.Output }],
|
|
61157
61223
|
rowSelected: [{ type: i0.Output }],
|
|
@@ -61400,7 +61466,7 @@
|
|
|
61400
61466
|
get: function () {
|
|
61401
61467
|
var _a, _b;
|
|
61402
61468
|
if (this.inEditMode) {
|
|
61403
|
-
return mergeWith__default['default'](
|
|
61469
|
+
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) {
|
|
61404
61470
|
if (Array.isArray(srcValue)) {
|
|
61405
61471
|
return objValue = srcValue;
|
|
61406
61472
|
}
|
|
@@ -61760,7 +61826,7 @@
|
|
|
61760
61826
|
get: function () {
|
|
61761
61827
|
var _a;
|
|
61762
61828
|
if (this.inEditMode) {
|
|
61763
|
-
return mergeWith__default['default'](
|
|
61829
|
+
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) {
|
|
61764
61830
|
if (Array.isArray(srcValue)) {
|
|
61765
61831
|
return objValue = srcValue;
|
|
61766
61832
|
}
|
|
@@ -64114,7 +64180,7 @@
|
|
|
64114
64180
|
IgxGridTransactionPipe.prototype.transform = function (collection, _id, _pipeTrigger) {
|
|
64115
64181
|
var grid = this.gridAPI.grid;
|
|
64116
64182
|
if (grid.transactions.enabled) {
|
|
64117
|
-
var result = DataUtil.mergeTransactions(cloneArray(collection), grid.transactions.getAggregatedChanges(true), grid.primaryKey);
|
|
64183
|
+
var result = DataUtil.mergeTransactions(cloneArray(collection), grid.transactions.getAggregatedChanges(true), grid.primaryKey, grid.dataCloneStrategy);
|
|
64118
64184
|
return result;
|
|
64119
64185
|
}
|
|
64120
64186
|
return collection;
|
|
@@ -73920,11 +73986,11 @@
|
|
|
73920
73986
|
var childDataKey = grid.childDataKey;
|
|
73921
73987
|
if (foreignKey) {
|
|
73922
73988
|
var flatDataClone = cloneArray(collection);
|
|
73923
|
-
return DataUtil.mergeTransactions(flatDataClone, aggregatedChanges, grid.primaryKey);
|
|
73989
|
+
return DataUtil.mergeTransactions(flatDataClone, aggregatedChanges, grid.primaryKey, grid.dataCloneStrategy);
|
|
73924
73990
|
}
|
|
73925
73991
|
else if (childDataKey) {
|
|
73926
73992
|
var hierarchicalDataClone = cloneHierarchicalArray(collection, childDataKey);
|
|
73927
|
-
return DataUtil.mergeHierarchicalTransactions(hierarchicalDataClone, aggregatedChanges, childDataKey, grid.primaryKey);
|
|
73993
|
+
return DataUtil.mergeHierarchicalTransactions(hierarchicalDataClone, aggregatedChanges, childDataKey, grid.primaryKey, grid.dataCloneStrategy);
|
|
73928
73994
|
}
|
|
73929
73995
|
}
|
|
73930
73996
|
}
|
|
@@ -85560,6 +85626,7 @@
|
|
|
85560
85626
|
exports.DEFAULT_OWNER = DEFAULT_OWNER;
|
|
85561
85627
|
exports.DataUtil = DataUtil;
|
|
85562
85628
|
exports.DateRangePickerFormatPipe = DateRangePickerFormatPipe;
|
|
85629
|
+
exports.DefaultDataCloneStrategy = DefaultDataCloneStrategy;
|
|
85563
85630
|
exports.DefaultSortingStrategy = DefaultSortingStrategy;
|
|
85564
85631
|
exports.DisplayDensity = DisplayDensity;
|
|
85565
85632
|
exports.DisplayDensityBase = DisplayDensityBase;
|