@zeedhi/common 1.77.2 → 1.78.0
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/dist/zd-common.esm.js +150 -54
- package/dist/zd-common.umd.js +150 -54
- package/package.json +2 -2
- package/types/components/zd-grid/errors/delete-rows.d.ts +6 -0
- package/types/components/zd-grid/grid.d.ts +7 -0
- package/types/components/zd-grid/interfaces.d.ts +1 -0
- package/types/components/zd-tree-grid/tree-grid.d.ts +2 -2
package/dist/zd-common.esm.js
CHANGED
|
@@ -559,7 +559,7 @@ class ApexChart extends ComponentRender {
|
|
|
559
559
|
return series;
|
|
560
560
|
}
|
|
561
561
|
translateOptions(propOptions = {}) {
|
|
562
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x;
|
|
562
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y;
|
|
563
563
|
let value;
|
|
564
564
|
value = this.getPropValue((_c = (_b = (_a = propOptions.annotations) === null || _a === void 0 ? void 0 : _a.yaxis) === null || _b === void 0 ? void 0 : _b.label) === null || _c === void 0 ? void 0 : _c.text);
|
|
565
565
|
if (value)
|
|
@@ -599,6 +599,9 @@ class ApexChart extends ComponentRender {
|
|
|
599
599
|
value = this.getPropValue((_x = (_w = propOptions.yaxis) === null || _w === void 0 ? void 0 : _w.title) === null || _x === void 0 ? void 0 : _x.text);
|
|
600
600
|
if (value)
|
|
601
601
|
propOptions.yaxis.title.text = I18n.translate(value);
|
|
602
|
+
value = this.getPropValue((_y = propOptions.noData) === null || _y === void 0 ? void 0 : _y.text);
|
|
603
|
+
if (value)
|
|
604
|
+
propOptions.noData.text = I18n.translate(value);
|
|
602
605
|
return propOptions;
|
|
603
606
|
}
|
|
604
607
|
/**
|
|
@@ -5541,6 +5544,17 @@ const toggleableFormatter = ({ value, componentProps }) => {
|
|
|
5541
5544
|
FormatterParserProvider.registerFormatter('column_ZdCheckbox', toggleableFormatter);
|
|
5542
5545
|
FormatterParserProvider.registerFormatter('column_ZdSwitch', toggleableFormatter);
|
|
5543
5546
|
|
|
5547
|
+
/**
|
|
5548
|
+
* Delete rows error
|
|
5549
|
+
*/
|
|
5550
|
+
class DeleteRowsError extends Error {
|
|
5551
|
+
constructor() {
|
|
5552
|
+
super('Grid can\'t automatically delete rows when selectAllPages property is true.'
|
|
5553
|
+
+ ' You should delete them manually');
|
|
5554
|
+
this.name = 'DeleteRowsError';
|
|
5555
|
+
}
|
|
5556
|
+
}
|
|
5557
|
+
|
|
5544
5558
|
/**
|
|
5545
5559
|
* Base class for Grid component
|
|
5546
5560
|
*/
|
|
@@ -5694,6 +5708,11 @@ class Grid extends Iterable {
|
|
|
5694
5708
|
*/
|
|
5695
5709
|
this.resizeColumns = false;
|
|
5696
5710
|
this.showSelectAll = true;
|
|
5711
|
+
this.selectAllPages = Config.gridSelectAllPages;
|
|
5712
|
+
this.selectionState = {
|
|
5713
|
+
allSelected: false,
|
|
5714
|
+
except: [],
|
|
5715
|
+
};
|
|
5697
5716
|
this.navigationKeyMapping = {
|
|
5698
5717
|
up: {
|
|
5699
5718
|
event: this.navigateUp.bind(this),
|
|
@@ -5748,6 +5767,7 @@ class Grid extends Iterable {
|
|
|
5748
5767
|
this.noResultsText = this.getInitValue('noResultsText', props.noResultsText, this.noResultsText);
|
|
5749
5768
|
this.disableSelection = this.getInitValue('disableSelection', props.disableSelection, this.disableSelection);
|
|
5750
5769
|
this.showSelectAll = this.getInitValue('showSelectAll', props.showSelectAll, this.showSelectAll);
|
|
5770
|
+
this.selectAllPages = this.getInitValue('selectAllPages', props.selectAllPages, this.selectAllPages);
|
|
5751
5771
|
this.createAccessors();
|
|
5752
5772
|
}
|
|
5753
5773
|
onMounted(element) {
|
|
@@ -5858,25 +5878,69 @@ class Grid extends Iterable {
|
|
|
5858
5878
|
}
|
|
5859
5879
|
}
|
|
5860
5880
|
selectAll(isSelected) {
|
|
5861
|
-
if (this.selectable)
|
|
5862
|
-
|
|
5863
|
-
|
|
5864
|
-
|
|
5865
|
-
|
|
5866
|
-
|
|
5867
|
-
|
|
5868
|
-
|
|
5869
|
-
|
|
5870
|
-
|
|
5871
|
-
|
|
5872
|
-
|
|
5873
|
-
|
|
5874
|
-
|
|
5875
|
-
|
|
5876
|
-
|
|
5877
|
-
|
|
5878
|
-
|
|
5881
|
+
if (!this.selectable)
|
|
5882
|
+
return;
|
|
5883
|
+
this.selectionState = { allSelected: isSelected, except: [] };
|
|
5884
|
+
if (!isSelected) {
|
|
5885
|
+
this.datasource.data.forEach((row) => {
|
|
5886
|
+
const index = this.selectedRows.indexOf(row);
|
|
5887
|
+
if (index > -1) {
|
|
5888
|
+
this.selectedRows.splice(index, 1);
|
|
5889
|
+
}
|
|
5890
|
+
});
|
|
5891
|
+
return;
|
|
5892
|
+
}
|
|
5893
|
+
this.datasource.data.forEach((row) => {
|
|
5894
|
+
if (this.callDisableSelection(row))
|
|
5895
|
+
return;
|
|
5896
|
+
const key = row[this.datasource.uniqueKey];
|
|
5897
|
+
if (key && this.selectedRows.indexOf(row) === -1) {
|
|
5898
|
+
this.selectedRows.push(row);
|
|
5879
5899
|
}
|
|
5900
|
+
});
|
|
5901
|
+
}
|
|
5902
|
+
toggleRow(row) {
|
|
5903
|
+
// array that references the selected rows
|
|
5904
|
+
let arrSelection;
|
|
5905
|
+
if (this.selectAllPages) {
|
|
5906
|
+
arrSelection = this.selectionState.except;
|
|
5907
|
+
}
|
|
5908
|
+
else {
|
|
5909
|
+
arrSelection = this.selectedRows;
|
|
5910
|
+
}
|
|
5911
|
+
const { uniqueKey } = this.datasource;
|
|
5912
|
+
const index = arrSelection.findIndex((selectedRow) => selectedRow[uniqueKey] === row[uniqueKey]);
|
|
5913
|
+
const isSelected = index !== -1;
|
|
5914
|
+
if (!isSelected) {
|
|
5915
|
+
arrSelection.push(row);
|
|
5916
|
+
return;
|
|
5917
|
+
}
|
|
5918
|
+
if (isSelected) {
|
|
5919
|
+
arrSelection.splice(index, 1);
|
|
5920
|
+
}
|
|
5921
|
+
}
|
|
5922
|
+
selectRow(row, select) {
|
|
5923
|
+
// array that references the selected rows
|
|
5924
|
+
let arrSelection;
|
|
5925
|
+
// stores whether this row should be added/removed from arrSelection
|
|
5926
|
+
let shouldBeSelected;
|
|
5927
|
+
if (this.selectAllPages) {
|
|
5928
|
+
arrSelection = this.selectionState.except;
|
|
5929
|
+
shouldBeSelected = select !== this.selectionState.allSelected;
|
|
5930
|
+
}
|
|
5931
|
+
else {
|
|
5932
|
+
arrSelection = this.selectedRows;
|
|
5933
|
+
shouldBeSelected = select;
|
|
5934
|
+
}
|
|
5935
|
+
const { uniqueKey } = this.datasource;
|
|
5936
|
+
const index = arrSelection.findIndex((selectedRow) => selectedRow[uniqueKey] === row[uniqueKey]);
|
|
5937
|
+
const isSelected = index !== -1;
|
|
5938
|
+
if (!isSelected && shouldBeSelected) {
|
|
5939
|
+
arrSelection.push(row);
|
|
5940
|
+
return;
|
|
5941
|
+
}
|
|
5942
|
+
if (isSelected && !shouldBeSelected) {
|
|
5943
|
+
arrSelection.splice(index, 1);
|
|
5880
5944
|
}
|
|
5881
5945
|
}
|
|
5882
5946
|
navigateUp() {
|
|
@@ -5917,6 +5981,9 @@ class Grid extends Iterable {
|
|
|
5917
5981
|
}
|
|
5918
5982
|
deleteRows() {
|
|
5919
5983
|
return __awaiter(this, void 0, void 0, function* () {
|
|
5984
|
+
if (this.selectAllPages) {
|
|
5985
|
+
throw new DeleteRowsError();
|
|
5986
|
+
}
|
|
5920
5987
|
const response = yield Promise.all(this.selectedRows.map((row) => this.datasource.delete(row)));
|
|
5921
5988
|
yield this.datasource.get();
|
|
5922
5989
|
this.selectedRows = [];
|
|
@@ -12190,6 +12257,9 @@ class TreeGrid extends Grid {
|
|
|
12190
12257
|
*/
|
|
12191
12258
|
deleteRows() {
|
|
12192
12259
|
return __awaiter(this, void 0, void 0, function* () {
|
|
12260
|
+
if (this.selectAllPages) {
|
|
12261
|
+
throw new DeleteRowsError();
|
|
12262
|
+
}
|
|
12193
12263
|
const response = yield Promise.all(this.selectedRows.map((row) => this.datasource.delete(row)));
|
|
12194
12264
|
this.treeDataStructure.treeData = [];
|
|
12195
12265
|
this.buildTree();
|
|
@@ -12264,27 +12334,45 @@ class TreeGrid extends Grid {
|
|
|
12264
12334
|
/**
|
|
12265
12335
|
* Select/deselect rows
|
|
12266
12336
|
* @param row selected row
|
|
12267
|
-
* @param
|
|
12337
|
+
* @param select row is selected
|
|
12268
12338
|
*/
|
|
12269
|
-
selectRow(row,
|
|
12339
|
+
selectRow(row, select) {
|
|
12270
12340
|
const childrenRows = !this.flat
|
|
12271
12341
|
? this.treeDataStructure.getChildren(row)
|
|
12272
12342
|
: [];
|
|
12273
12343
|
const rows = [row, ...childrenRows];
|
|
12274
|
-
|
|
12275
|
-
|
|
12344
|
+
// array that references the selected rows
|
|
12345
|
+
let arrSelection;
|
|
12346
|
+
// stores whether this row should be added/removed from arrSelection
|
|
12347
|
+
let shouldBeSelected;
|
|
12348
|
+
if (this.selectAllPages) {
|
|
12349
|
+
arrSelection = this.selectionState.except;
|
|
12350
|
+
shouldBeSelected = select !== this.selectionState.allSelected;
|
|
12351
|
+
}
|
|
12352
|
+
else {
|
|
12353
|
+
arrSelection = this.selectedRows;
|
|
12354
|
+
shouldBeSelected = select;
|
|
12355
|
+
}
|
|
12356
|
+
rows.forEach((rowToSelect) => {
|
|
12357
|
+
const { uniqueKey } = this.datasource;
|
|
12358
|
+
const index = arrSelection.findIndex((selectedRow) => selectedRow[uniqueKey] === rowToSelect[uniqueKey]);
|
|
12359
|
+
const isSelected = index !== -1;
|
|
12360
|
+
if (!isSelected && shouldBeSelected) {
|
|
12361
|
+
arrSelection.push(rowToSelect);
|
|
12362
|
+
return;
|
|
12363
|
+
}
|
|
12364
|
+
if (isSelected && !shouldBeSelected) {
|
|
12365
|
+
arrSelection.splice(index, 1);
|
|
12366
|
+
}
|
|
12367
|
+
});
|
|
12368
|
+
if (this.flat)
|
|
12369
|
+
return;
|
|
12370
|
+
if (shouldBeSelected) {
|
|
12276
12371
|
// check if all the children of the parent are selected.
|
|
12277
|
-
|
|
12278
|
-
this.selectParents(row);
|
|
12372
|
+
this.selectParents(row);
|
|
12279
12373
|
}
|
|
12280
12374
|
else {
|
|
12281
|
-
|
|
12282
|
-
const index = this.treeDataStructure.findDataIndex(this.selectedRows, item[this.datasource.uniqueKey]);
|
|
12283
|
-
if (index > -1)
|
|
12284
|
-
this.selectedRows.splice(index, 1);
|
|
12285
|
-
});
|
|
12286
|
-
if (!this.flat)
|
|
12287
|
-
this.unselectParents(row);
|
|
12375
|
+
this.unselectParents(row);
|
|
12288
12376
|
}
|
|
12289
12377
|
}
|
|
12290
12378
|
/**
|
|
@@ -12310,31 +12398,39 @@ class TreeGrid extends Grid {
|
|
|
12310
12398
|
});
|
|
12311
12399
|
}
|
|
12312
12400
|
selectParents(row) {
|
|
12313
|
-
if (row[this.parentField])
|
|
12314
|
-
|
|
12315
|
-
|
|
12316
|
-
|
|
12317
|
-
|
|
12318
|
-
|
|
12319
|
-
|
|
12320
|
-
|
|
12321
|
-
|
|
12322
|
-
|
|
12323
|
-
|
|
12324
|
-
|
|
12325
|
-
|
|
12326
|
-
|
|
12327
|
-
|
|
12401
|
+
if (!row[this.parentField])
|
|
12402
|
+
return;
|
|
12403
|
+
let arrSelection = this.selectAllPages ? this.selectionState.except : this.selectedRows;
|
|
12404
|
+
const parentRow = this.treeDataStructure.getRowData(row).tree__parent;
|
|
12405
|
+
const every = this.treeDataStructure
|
|
12406
|
+
.getChildren(parentRow)
|
|
12407
|
+
.every((item) => {
|
|
12408
|
+
const index = this.treeDataStructure.findDataIndex(arrSelection, item[this.datasource.uniqueKey]);
|
|
12409
|
+
if (index > -1)
|
|
12410
|
+
return true;
|
|
12411
|
+
return false;
|
|
12412
|
+
});
|
|
12413
|
+
const rows = [];
|
|
12414
|
+
if (every || (this.selectAllPages && this.selectionState.allSelected))
|
|
12415
|
+
rows.push(parentRow);
|
|
12416
|
+
arrSelection = this.removeDuplicates(arrSelection.concat(rows), this.datasource.uniqueKey);
|
|
12417
|
+
if (this.selectAllPages) {
|
|
12418
|
+
this.selectionState.except = arrSelection;
|
|
12419
|
+
}
|
|
12420
|
+
else {
|
|
12421
|
+
this.selectedRows = arrSelection;
|
|
12328
12422
|
}
|
|
12423
|
+
this.selectParents(parentRow);
|
|
12329
12424
|
}
|
|
12330
12425
|
unselectParents(row) {
|
|
12331
|
-
if (row[this.parentField])
|
|
12332
|
-
|
|
12333
|
-
|
|
12334
|
-
|
|
12335
|
-
|
|
12336
|
-
|
|
12337
|
-
|
|
12426
|
+
if (!row[this.parentField])
|
|
12427
|
+
return;
|
|
12428
|
+
const arrSelection = this.selectAllPages ? this.selectionState.except : this.selectedRows;
|
|
12429
|
+
const index = this.treeDataStructure.findDataIndex(arrSelection, row[this.parentField]);
|
|
12430
|
+
if (index > -1)
|
|
12431
|
+
arrSelection.splice(index, 1);
|
|
12432
|
+
const parentRow = this.treeDataStructure.getRowData(row).tree__parent;
|
|
12433
|
+
this.unselectParents(parentRow);
|
|
12338
12434
|
}
|
|
12339
12435
|
}
|
|
12340
12436
|
|
package/dist/zd-common.umd.js
CHANGED
|
@@ -566,7 +566,7 @@
|
|
|
566
566
|
return series;
|
|
567
567
|
}
|
|
568
568
|
translateOptions(propOptions = {}) {
|
|
569
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x;
|
|
569
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y;
|
|
570
570
|
let value;
|
|
571
571
|
value = this.getPropValue((_c = (_b = (_a = propOptions.annotations) === null || _a === void 0 ? void 0 : _a.yaxis) === null || _b === void 0 ? void 0 : _b.label) === null || _c === void 0 ? void 0 : _c.text);
|
|
572
572
|
if (value)
|
|
@@ -606,6 +606,9 @@
|
|
|
606
606
|
value = this.getPropValue((_x = (_w = propOptions.yaxis) === null || _w === void 0 ? void 0 : _w.title) === null || _x === void 0 ? void 0 : _x.text);
|
|
607
607
|
if (value)
|
|
608
608
|
propOptions.yaxis.title.text = core.I18n.translate(value);
|
|
609
|
+
value = this.getPropValue((_y = propOptions.noData) === null || _y === void 0 ? void 0 : _y.text);
|
|
610
|
+
if (value)
|
|
611
|
+
propOptions.noData.text = core.I18n.translate(value);
|
|
609
612
|
return propOptions;
|
|
610
613
|
}
|
|
611
614
|
/**
|
|
@@ -5548,6 +5551,17 @@
|
|
|
5548
5551
|
core.FormatterParserProvider.registerFormatter('column_ZdCheckbox', toggleableFormatter);
|
|
5549
5552
|
core.FormatterParserProvider.registerFormatter('column_ZdSwitch', toggleableFormatter);
|
|
5550
5553
|
|
|
5554
|
+
/**
|
|
5555
|
+
* Delete rows error
|
|
5556
|
+
*/
|
|
5557
|
+
class DeleteRowsError extends Error {
|
|
5558
|
+
constructor() {
|
|
5559
|
+
super('Grid can\'t automatically delete rows when selectAllPages property is true.'
|
|
5560
|
+
+ ' You should delete them manually');
|
|
5561
|
+
this.name = 'DeleteRowsError';
|
|
5562
|
+
}
|
|
5563
|
+
}
|
|
5564
|
+
|
|
5551
5565
|
/**
|
|
5552
5566
|
* Base class for Grid component
|
|
5553
5567
|
*/
|
|
@@ -5701,6 +5715,11 @@
|
|
|
5701
5715
|
*/
|
|
5702
5716
|
this.resizeColumns = false;
|
|
5703
5717
|
this.showSelectAll = true;
|
|
5718
|
+
this.selectAllPages = core.Config.gridSelectAllPages;
|
|
5719
|
+
this.selectionState = {
|
|
5720
|
+
allSelected: false,
|
|
5721
|
+
except: [],
|
|
5722
|
+
};
|
|
5704
5723
|
this.navigationKeyMapping = {
|
|
5705
5724
|
up: {
|
|
5706
5725
|
event: this.navigateUp.bind(this),
|
|
@@ -5755,6 +5774,7 @@
|
|
|
5755
5774
|
this.noResultsText = this.getInitValue('noResultsText', props.noResultsText, this.noResultsText);
|
|
5756
5775
|
this.disableSelection = this.getInitValue('disableSelection', props.disableSelection, this.disableSelection);
|
|
5757
5776
|
this.showSelectAll = this.getInitValue('showSelectAll', props.showSelectAll, this.showSelectAll);
|
|
5777
|
+
this.selectAllPages = this.getInitValue('selectAllPages', props.selectAllPages, this.selectAllPages);
|
|
5758
5778
|
this.createAccessors();
|
|
5759
5779
|
}
|
|
5760
5780
|
onMounted(element) {
|
|
@@ -5865,25 +5885,69 @@
|
|
|
5865
5885
|
}
|
|
5866
5886
|
}
|
|
5867
5887
|
selectAll(isSelected) {
|
|
5868
|
-
if (this.selectable)
|
|
5869
|
-
|
|
5870
|
-
|
|
5871
|
-
|
|
5872
|
-
|
|
5873
|
-
|
|
5874
|
-
|
|
5875
|
-
|
|
5876
|
-
|
|
5877
|
-
|
|
5878
|
-
|
|
5879
|
-
|
|
5880
|
-
|
|
5881
|
-
|
|
5882
|
-
|
|
5883
|
-
|
|
5884
|
-
|
|
5885
|
-
|
|
5888
|
+
if (!this.selectable)
|
|
5889
|
+
return;
|
|
5890
|
+
this.selectionState = { allSelected: isSelected, except: [] };
|
|
5891
|
+
if (!isSelected) {
|
|
5892
|
+
this.datasource.data.forEach((row) => {
|
|
5893
|
+
const index = this.selectedRows.indexOf(row);
|
|
5894
|
+
if (index > -1) {
|
|
5895
|
+
this.selectedRows.splice(index, 1);
|
|
5896
|
+
}
|
|
5897
|
+
});
|
|
5898
|
+
return;
|
|
5899
|
+
}
|
|
5900
|
+
this.datasource.data.forEach((row) => {
|
|
5901
|
+
if (this.callDisableSelection(row))
|
|
5902
|
+
return;
|
|
5903
|
+
const key = row[this.datasource.uniqueKey];
|
|
5904
|
+
if (key && this.selectedRows.indexOf(row) === -1) {
|
|
5905
|
+
this.selectedRows.push(row);
|
|
5886
5906
|
}
|
|
5907
|
+
});
|
|
5908
|
+
}
|
|
5909
|
+
toggleRow(row) {
|
|
5910
|
+
// array that references the selected rows
|
|
5911
|
+
let arrSelection;
|
|
5912
|
+
if (this.selectAllPages) {
|
|
5913
|
+
arrSelection = this.selectionState.except;
|
|
5914
|
+
}
|
|
5915
|
+
else {
|
|
5916
|
+
arrSelection = this.selectedRows;
|
|
5917
|
+
}
|
|
5918
|
+
const { uniqueKey } = this.datasource;
|
|
5919
|
+
const index = arrSelection.findIndex((selectedRow) => selectedRow[uniqueKey] === row[uniqueKey]);
|
|
5920
|
+
const isSelected = index !== -1;
|
|
5921
|
+
if (!isSelected) {
|
|
5922
|
+
arrSelection.push(row);
|
|
5923
|
+
return;
|
|
5924
|
+
}
|
|
5925
|
+
if (isSelected) {
|
|
5926
|
+
arrSelection.splice(index, 1);
|
|
5927
|
+
}
|
|
5928
|
+
}
|
|
5929
|
+
selectRow(row, select) {
|
|
5930
|
+
// array that references the selected rows
|
|
5931
|
+
let arrSelection;
|
|
5932
|
+
// stores whether this row should be added/removed from arrSelection
|
|
5933
|
+
let shouldBeSelected;
|
|
5934
|
+
if (this.selectAllPages) {
|
|
5935
|
+
arrSelection = this.selectionState.except;
|
|
5936
|
+
shouldBeSelected = select !== this.selectionState.allSelected;
|
|
5937
|
+
}
|
|
5938
|
+
else {
|
|
5939
|
+
arrSelection = this.selectedRows;
|
|
5940
|
+
shouldBeSelected = select;
|
|
5941
|
+
}
|
|
5942
|
+
const { uniqueKey } = this.datasource;
|
|
5943
|
+
const index = arrSelection.findIndex((selectedRow) => selectedRow[uniqueKey] === row[uniqueKey]);
|
|
5944
|
+
const isSelected = index !== -1;
|
|
5945
|
+
if (!isSelected && shouldBeSelected) {
|
|
5946
|
+
arrSelection.push(row);
|
|
5947
|
+
return;
|
|
5948
|
+
}
|
|
5949
|
+
if (isSelected && !shouldBeSelected) {
|
|
5950
|
+
arrSelection.splice(index, 1);
|
|
5887
5951
|
}
|
|
5888
5952
|
}
|
|
5889
5953
|
navigateUp() {
|
|
@@ -5924,6 +5988,9 @@
|
|
|
5924
5988
|
}
|
|
5925
5989
|
deleteRows() {
|
|
5926
5990
|
return __awaiter(this, void 0, void 0, function* () {
|
|
5991
|
+
if (this.selectAllPages) {
|
|
5992
|
+
throw new DeleteRowsError();
|
|
5993
|
+
}
|
|
5927
5994
|
const response = yield Promise.all(this.selectedRows.map((row) => this.datasource.delete(row)));
|
|
5928
5995
|
yield this.datasource.get();
|
|
5929
5996
|
this.selectedRows = [];
|
|
@@ -12197,6 +12264,9 @@
|
|
|
12197
12264
|
*/
|
|
12198
12265
|
deleteRows() {
|
|
12199
12266
|
return __awaiter(this, void 0, void 0, function* () {
|
|
12267
|
+
if (this.selectAllPages) {
|
|
12268
|
+
throw new DeleteRowsError();
|
|
12269
|
+
}
|
|
12200
12270
|
const response = yield Promise.all(this.selectedRows.map((row) => this.datasource.delete(row)));
|
|
12201
12271
|
this.treeDataStructure.treeData = [];
|
|
12202
12272
|
this.buildTree();
|
|
@@ -12271,27 +12341,45 @@
|
|
|
12271
12341
|
/**
|
|
12272
12342
|
* Select/deselect rows
|
|
12273
12343
|
* @param row selected row
|
|
12274
|
-
* @param
|
|
12344
|
+
* @param select row is selected
|
|
12275
12345
|
*/
|
|
12276
|
-
selectRow(row,
|
|
12346
|
+
selectRow(row, select) {
|
|
12277
12347
|
const childrenRows = !this.flat
|
|
12278
12348
|
? this.treeDataStructure.getChildren(row)
|
|
12279
12349
|
: [];
|
|
12280
12350
|
const rows = [row, ...childrenRows];
|
|
12281
|
-
|
|
12282
|
-
|
|
12351
|
+
// array that references the selected rows
|
|
12352
|
+
let arrSelection;
|
|
12353
|
+
// stores whether this row should be added/removed from arrSelection
|
|
12354
|
+
let shouldBeSelected;
|
|
12355
|
+
if (this.selectAllPages) {
|
|
12356
|
+
arrSelection = this.selectionState.except;
|
|
12357
|
+
shouldBeSelected = select !== this.selectionState.allSelected;
|
|
12358
|
+
}
|
|
12359
|
+
else {
|
|
12360
|
+
arrSelection = this.selectedRows;
|
|
12361
|
+
shouldBeSelected = select;
|
|
12362
|
+
}
|
|
12363
|
+
rows.forEach((rowToSelect) => {
|
|
12364
|
+
const { uniqueKey } = this.datasource;
|
|
12365
|
+
const index = arrSelection.findIndex((selectedRow) => selectedRow[uniqueKey] === rowToSelect[uniqueKey]);
|
|
12366
|
+
const isSelected = index !== -1;
|
|
12367
|
+
if (!isSelected && shouldBeSelected) {
|
|
12368
|
+
arrSelection.push(rowToSelect);
|
|
12369
|
+
return;
|
|
12370
|
+
}
|
|
12371
|
+
if (isSelected && !shouldBeSelected) {
|
|
12372
|
+
arrSelection.splice(index, 1);
|
|
12373
|
+
}
|
|
12374
|
+
});
|
|
12375
|
+
if (this.flat)
|
|
12376
|
+
return;
|
|
12377
|
+
if (shouldBeSelected) {
|
|
12283
12378
|
// check if all the children of the parent are selected.
|
|
12284
|
-
|
|
12285
|
-
this.selectParents(row);
|
|
12379
|
+
this.selectParents(row);
|
|
12286
12380
|
}
|
|
12287
12381
|
else {
|
|
12288
|
-
|
|
12289
|
-
const index = this.treeDataStructure.findDataIndex(this.selectedRows, item[this.datasource.uniqueKey]);
|
|
12290
|
-
if (index > -1)
|
|
12291
|
-
this.selectedRows.splice(index, 1);
|
|
12292
|
-
});
|
|
12293
|
-
if (!this.flat)
|
|
12294
|
-
this.unselectParents(row);
|
|
12382
|
+
this.unselectParents(row);
|
|
12295
12383
|
}
|
|
12296
12384
|
}
|
|
12297
12385
|
/**
|
|
@@ -12317,31 +12405,39 @@
|
|
|
12317
12405
|
});
|
|
12318
12406
|
}
|
|
12319
12407
|
selectParents(row) {
|
|
12320
|
-
if (row[this.parentField])
|
|
12321
|
-
|
|
12322
|
-
|
|
12323
|
-
|
|
12324
|
-
|
|
12325
|
-
|
|
12326
|
-
|
|
12327
|
-
|
|
12328
|
-
|
|
12329
|
-
|
|
12330
|
-
|
|
12331
|
-
|
|
12332
|
-
|
|
12333
|
-
|
|
12334
|
-
|
|
12408
|
+
if (!row[this.parentField])
|
|
12409
|
+
return;
|
|
12410
|
+
let arrSelection = this.selectAllPages ? this.selectionState.except : this.selectedRows;
|
|
12411
|
+
const parentRow = this.treeDataStructure.getRowData(row).tree__parent;
|
|
12412
|
+
const every = this.treeDataStructure
|
|
12413
|
+
.getChildren(parentRow)
|
|
12414
|
+
.every((item) => {
|
|
12415
|
+
const index = this.treeDataStructure.findDataIndex(arrSelection, item[this.datasource.uniqueKey]);
|
|
12416
|
+
if (index > -1)
|
|
12417
|
+
return true;
|
|
12418
|
+
return false;
|
|
12419
|
+
});
|
|
12420
|
+
const rows = [];
|
|
12421
|
+
if (every || (this.selectAllPages && this.selectionState.allSelected))
|
|
12422
|
+
rows.push(parentRow);
|
|
12423
|
+
arrSelection = this.removeDuplicates(arrSelection.concat(rows), this.datasource.uniqueKey);
|
|
12424
|
+
if (this.selectAllPages) {
|
|
12425
|
+
this.selectionState.except = arrSelection;
|
|
12426
|
+
}
|
|
12427
|
+
else {
|
|
12428
|
+
this.selectedRows = arrSelection;
|
|
12335
12429
|
}
|
|
12430
|
+
this.selectParents(parentRow);
|
|
12336
12431
|
}
|
|
12337
12432
|
unselectParents(row) {
|
|
12338
|
-
if (row[this.parentField])
|
|
12339
|
-
|
|
12340
|
-
|
|
12341
|
-
|
|
12342
|
-
|
|
12343
|
-
|
|
12344
|
-
|
|
12433
|
+
if (!row[this.parentField])
|
|
12434
|
+
return;
|
|
12435
|
+
const arrSelection = this.selectAllPages ? this.selectionState.except : this.selectedRows;
|
|
12436
|
+
const index = this.treeDataStructure.findDataIndex(arrSelection, row[this.parentField]);
|
|
12437
|
+
if (index > -1)
|
|
12438
|
+
arrSelection.splice(index, 1);
|
|
12439
|
+
const parentRow = this.treeDataStructure.getRowData(row).tree__parent;
|
|
12440
|
+
this.unselectParents(parentRow);
|
|
12345
12441
|
}
|
|
12346
12442
|
}
|
|
12347
12443
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zeedhi/common",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.78.0",
|
|
4
4
|
"description": "Zeedhi Common",
|
|
5
5
|
"author": "Zeedhi <zeedhi@teknisa.com>",
|
|
6
6
|
"license": "ISC",
|
|
@@ -39,5 +39,5 @@
|
|
|
39
39
|
"lodash.times": "4.3.*",
|
|
40
40
|
"mockdate": "3.0.*"
|
|
41
41
|
},
|
|
42
|
-
"gitHead": "
|
|
42
|
+
"gitHead": "24806e6ae8a481321c4ab19e4b053199f1ee58bb"
|
|
43
43
|
}
|
|
@@ -133,6 +133,11 @@ export declare class Grid extends Iterable implements IGrid {
|
|
|
133
133
|
component: Grid;
|
|
134
134
|
}) => boolean;
|
|
135
135
|
showSelectAll: boolean;
|
|
136
|
+
selectAllPages: boolean;
|
|
137
|
+
selectionState: {
|
|
138
|
+
allSelected: boolean;
|
|
139
|
+
except: IDictionary<any>[];
|
|
140
|
+
};
|
|
136
141
|
/**
|
|
137
142
|
* Creates a new Grid.
|
|
138
143
|
* @param props Grid properties
|
|
@@ -189,6 +194,8 @@ export declare class Grid extends Iterable implements IGrid {
|
|
|
189
194
|
*/
|
|
190
195
|
selectAllClick(isSelected: boolean, event: Event, element: any): void;
|
|
191
196
|
selectAll(isSelected: boolean): void;
|
|
197
|
+
toggleRow(row: IDictionary): void;
|
|
198
|
+
selectRow(row: IDictionary, select: boolean): void;
|
|
192
199
|
protected navigateUp(): void;
|
|
193
200
|
protected navigateDown(): void;
|
|
194
201
|
protected navigatePageUp(): void;
|
|
@@ -96,9 +96,9 @@ export declare class TreeGrid extends Grid implements ITreeGrid {
|
|
|
96
96
|
/**
|
|
97
97
|
* Select/deselect rows
|
|
98
98
|
* @param row selected row
|
|
99
|
-
* @param
|
|
99
|
+
* @param select row is selected
|
|
100
100
|
*/
|
|
101
|
-
selectRow(row: IDictionary<any>,
|
|
101
|
+
selectRow(row: IDictionary<any>, select: boolean): void;
|
|
102
102
|
/**
|
|
103
103
|
* Select children rows
|
|
104
104
|
* @param row Row to unselect children
|