@zeedhi/common 1.77.3 → 1.78.1
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 +146 -53
- package/dist/zd-common.umd.js +146 -53
- 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
|
@@ -5544,6 +5544,17 @@ const toggleableFormatter = ({ value, componentProps }) => {
|
|
|
5544
5544
|
FormatterParserProvider.registerFormatter('column_ZdCheckbox', toggleableFormatter);
|
|
5545
5545
|
FormatterParserProvider.registerFormatter('column_ZdSwitch', toggleableFormatter);
|
|
5546
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
|
+
|
|
5547
5558
|
/**
|
|
5548
5559
|
* Base class for Grid component
|
|
5549
5560
|
*/
|
|
@@ -5697,6 +5708,11 @@ class Grid extends Iterable {
|
|
|
5697
5708
|
*/
|
|
5698
5709
|
this.resizeColumns = false;
|
|
5699
5710
|
this.showSelectAll = true;
|
|
5711
|
+
this.selectAllPages = Config.gridSelectAllPages;
|
|
5712
|
+
this.selectionState = {
|
|
5713
|
+
allSelected: false,
|
|
5714
|
+
except: [],
|
|
5715
|
+
};
|
|
5700
5716
|
this.navigationKeyMapping = {
|
|
5701
5717
|
up: {
|
|
5702
5718
|
event: this.navigateUp.bind(this),
|
|
@@ -5751,6 +5767,7 @@ class Grid extends Iterable {
|
|
|
5751
5767
|
this.noResultsText = this.getInitValue('noResultsText', props.noResultsText, this.noResultsText);
|
|
5752
5768
|
this.disableSelection = this.getInitValue('disableSelection', props.disableSelection, this.disableSelection);
|
|
5753
5769
|
this.showSelectAll = this.getInitValue('showSelectAll', props.showSelectAll, this.showSelectAll);
|
|
5770
|
+
this.selectAllPages = this.getInitValue('selectAllPages', props.selectAllPages, this.selectAllPages);
|
|
5754
5771
|
this.createAccessors();
|
|
5755
5772
|
}
|
|
5756
5773
|
onMounted(element) {
|
|
@@ -5861,25 +5878,69 @@ class Grid extends Iterable {
|
|
|
5861
5878
|
}
|
|
5862
5879
|
}
|
|
5863
5880
|
selectAll(isSelected) {
|
|
5864
|
-
if (this.selectable)
|
|
5865
|
-
|
|
5866
|
-
|
|
5867
|
-
|
|
5868
|
-
|
|
5869
|
-
|
|
5870
|
-
|
|
5871
|
-
|
|
5872
|
-
|
|
5873
|
-
|
|
5874
|
-
|
|
5875
|
-
|
|
5876
|
-
|
|
5877
|
-
|
|
5878
|
-
|
|
5879
|
-
|
|
5880
|
-
|
|
5881
|
-
|
|
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);
|
|
5882
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);
|
|
5883
5944
|
}
|
|
5884
5945
|
}
|
|
5885
5946
|
navigateUp() {
|
|
@@ -5920,6 +5981,9 @@ class Grid extends Iterable {
|
|
|
5920
5981
|
}
|
|
5921
5982
|
deleteRows() {
|
|
5922
5983
|
return __awaiter(this, void 0, void 0, function* () {
|
|
5984
|
+
if (this.selectAllPages) {
|
|
5985
|
+
throw new DeleteRowsError();
|
|
5986
|
+
}
|
|
5923
5987
|
const response = yield Promise.all(this.selectedRows.map((row) => this.datasource.delete(row)));
|
|
5924
5988
|
yield this.datasource.get();
|
|
5925
5989
|
this.selectedRows = [];
|
|
@@ -12193,6 +12257,9 @@ class TreeGrid extends Grid {
|
|
|
12193
12257
|
*/
|
|
12194
12258
|
deleteRows() {
|
|
12195
12259
|
return __awaiter(this, void 0, void 0, function* () {
|
|
12260
|
+
if (this.selectAllPages) {
|
|
12261
|
+
throw new DeleteRowsError();
|
|
12262
|
+
}
|
|
12196
12263
|
const response = yield Promise.all(this.selectedRows.map((row) => this.datasource.delete(row)));
|
|
12197
12264
|
this.treeDataStructure.treeData = [];
|
|
12198
12265
|
this.buildTree();
|
|
@@ -12267,27 +12334,45 @@ class TreeGrid extends Grid {
|
|
|
12267
12334
|
/**
|
|
12268
12335
|
* Select/deselect rows
|
|
12269
12336
|
* @param row selected row
|
|
12270
|
-
* @param
|
|
12337
|
+
* @param select row is selected
|
|
12271
12338
|
*/
|
|
12272
|
-
selectRow(row,
|
|
12339
|
+
selectRow(row, select) {
|
|
12273
12340
|
const childrenRows = !this.flat
|
|
12274
12341
|
? this.treeDataStructure.getChildren(row)
|
|
12275
12342
|
: [];
|
|
12276
12343
|
const rows = [row, ...childrenRows];
|
|
12277
|
-
|
|
12278
|
-
|
|
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) {
|
|
12279
12371
|
// check if all the children of the parent are selected.
|
|
12280
|
-
|
|
12281
|
-
this.selectParents(row);
|
|
12372
|
+
this.selectParents(row);
|
|
12282
12373
|
}
|
|
12283
12374
|
else {
|
|
12284
|
-
|
|
12285
|
-
const index = this.treeDataStructure.findDataIndex(this.selectedRows, item[this.datasource.uniqueKey]);
|
|
12286
|
-
if (index > -1)
|
|
12287
|
-
this.selectedRows.splice(index, 1);
|
|
12288
|
-
});
|
|
12289
|
-
if (!this.flat)
|
|
12290
|
-
this.unselectParents(row);
|
|
12375
|
+
this.unselectParents(row);
|
|
12291
12376
|
}
|
|
12292
12377
|
}
|
|
12293
12378
|
/**
|
|
@@ -12313,31 +12398,39 @@ class TreeGrid extends Grid {
|
|
|
12313
12398
|
});
|
|
12314
12399
|
}
|
|
12315
12400
|
selectParents(row) {
|
|
12316
|
-
if (row[this.parentField])
|
|
12317
|
-
|
|
12318
|
-
|
|
12319
|
-
|
|
12320
|
-
|
|
12321
|
-
|
|
12322
|
-
|
|
12323
|
-
|
|
12324
|
-
|
|
12325
|
-
|
|
12326
|
-
|
|
12327
|
-
|
|
12328
|
-
|
|
12329
|
-
|
|
12330
|
-
|
|
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;
|
|
12331
12422
|
}
|
|
12423
|
+
this.selectParents(parentRow);
|
|
12332
12424
|
}
|
|
12333
12425
|
unselectParents(row) {
|
|
12334
|
-
if (row[this.parentField])
|
|
12335
|
-
|
|
12336
|
-
|
|
12337
|
-
|
|
12338
|
-
|
|
12339
|
-
|
|
12340
|
-
|
|
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);
|
|
12341
12434
|
}
|
|
12342
12435
|
}
|
|
12343
12436
|
|
package/dist/zd-common.umd.js
CHANGED
|
@@ -5551,6 +5551,17 @@
|
|
|
5551
5551
|
core.FormatterParserProvider.registerFormatter('column_ZdCheckbox', toggleableFormatter);
|
|
5552
5552
|
core.FormatterParserProvider.registerFormatter('column_ZdSwitch', toggleableFormatter);
|
|
5553
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
|
+
|
|
5554
5565
|
/**
|
|
5555
5566
|
* Base class for Grid component
|
|
5556
5567
|
*/
|
|
@@ -5704,6 +5715,11 @@
|
|
|
5704
5715
|
*/
|
|
5705
5716
|
this.resizeColumns = false;
|
|
5706
5717
|
this.showSelectAll = true;
|
|
5718
|
+
this.selectAllPages = core.Config.gridSelectAllPages;
|
|
5719
|
+
this.selectionState = {
|
|
5720
|
+
allSelected: false,
|
|
5721
|
+
except: [],
|
|
5722
|
+
};
|
|
5707
5723
|
this.navigationKeyMapping = {
|
|
5708
5724
|
up: {
|
|
5709
5725
|
event: this.navigateUp.bind(this),
|
|
@@ -5758,6 +5774,7 @@
|
|
|
5758
5774
|
this.noResultsText = this.getInitValue('noResultsText', props.noResultsText, this.noResultsText);
|
|
5759
5775
|
this.disableSelection = this.getInitValue('disableSelection', props.disableSelection, this.disableSelection);
|
|
5760
5776
|
this.showSelectAll = this.getInitValue('showSelectAll', props.showSelectAll, this.showSelectAll);
|
|
5777
|
+
this.selectAllPages = this.getInitValue('selectAllPages', props.selectAllPages, this.selectAllPages);
|
|
5761
5778
|
this.createAccessors();
|
|
5762
5779
|
}
|
|
5763
5780
|
onMounted(element) {
|
|
@@ -5868,25 +5885,69 @@
|
|
|
5868
5885
|
}
|
|
5869
5886
|
}
|
|
5870
5887
|
selectAll(isSelected) {
|
|
5871
|
-
if (this.selectable)
|
|
5872
|
-
|
|
5873
|
-
|
|
5874
|
-
|
|
5875
|
-
|
|
5876
|
-
|
|
5877
|
-
|
|
5878
|
-
|
|
5879
|
-
|
|
5880
|
-
|
|
5881
|
-
|
|
5882
|
-
|
|
5883
|
-
|
|
5884
|
-
|
|
5885
|
-
|
|
5886
|
-
|
|
5887
|
-
|
|
5888
|
-
|
|
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);
|
|
5889
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);
|
|
5890
5951
|
}
|
|
5891
5952
|
}
|
|
5892
5953
|
navigateUp() {
|
|
@@ -5927,6 +5988,9 @@
|
|
|
5927
5988
|
}
|
|
5928
5989
|
deleteRows() {
|
|
5929
5990
|
return __awaiter(this, void 0, void 0, function* () {
|
|
5991
|
+
if (this.selectAllPages) {
|
|
5992
|
+
throw new DeleteRowsError();
|
|
5993
|
+
}
|
|
5930
5994
|
const response = yield Promise.all(this.selectedRows.map((row) => this.datasource.delete(row)));
|
|
5931
5995
|
yield this.datasource.get();
|
|
5932
5996
|
this.selectedRows = [];
|
|
@@ -12200,6 +12264,9 @@
|
|
|
12200
12264
|
*/
|
|
12201
12265
|
deleteRows() {
|
|
12202
12266
|
return __awaiter(this, void 0, void 0, function* () {
|
|
12267
|
+
if (this.selectAllPages) {
|
|
12268
|
+
throw new DeleteRowsError();
|
|
12269
|
+
}
|
|
12203
12270
|
const response = yield Promise.all(this.selectedRows.map((row) => this.datasource.delete(row)));
|
|
12204
12271
|
this.treeDataStructure.treeData = [];
|
|
12205
12272
|
this.buildTree();
|
|
@@ -12274,27 +12341,45 @@
|
|
|
12274
12341
|
/**
|
|
12275
12342
|
* Select/deselect rows
|
|
12276
12343
|
* @param row selected row
|
|
12277
|
-
* @param
|
|
12344
|
+
* @param select row is selected
|
|
12278
12345
|
*/
|
|
12279
|
-
selectRow(row,
|
|
12346
|
+
selectRow(row, select) {
|
|
12280
12347
|
const childrenRows = !this.flat
|
|
12281
12348
|
? this.treeDataStructure.getChildren(row)
|
|
12282
12349
|
: [];
|
|
12283
12350
|
const rows = [row, ...childrenRows];
|
|
12284
|
-
|
|
12285
|
-
|
|
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) {
|
|
12286
12378
|
// check if all the children of the parent are selected.
|
|
12287
|
-
|
|
12288
|
-
this.selectParents(row);
|
|
12379
|
+
this.selectParents(row);
|
|
12289
12380
|
}
|
|
12290
12381
|
else {
|
|
12291
|
-
|
|
12292
|
-
const index = this.treeDataStructure.findDataIndex(this.selectedRows, item[this.datasource.uniqueKey]);
|
|
12293
|
-
if (index > -1)
|
|
12294
|
-
this.selectedRows.splice(index, 1);
|
|
12295
|
-
});
|
|
12296
|
-
if (!this.flat)
|
|
12297
|
-
this.unselectParents(row);
|
|
12382
|
+
this.unselectParents(row);
|
|
12298
12383
|
}
|
|
12299
12384
|
}
|
|
12300
12385
|
/**
|
|
@@ -12320,31 +12405,39 @@
|
|
|
12320
12405
|
});
|
|
12321
12406
|
}
|
|
12322
12407
|
selectParents(row) {
|
|
12323
|
-
if (row[this.parentField])
|
|
12324
|
-
|
|
12325
|
-
|
|
12326
|
-
|
|
12327
|
-
|
|
12328
|
-
|
|
12329
|
-
|
|
12330
|
-
|
|
12331
|
-
|
|
12332
|
-
|
|
12333
|
-
|
|
12334
|
-
|
|
12335
|
-
|
|
12336
|
-
|
|
12337
|
-
|
|
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;
|
|
12338
12429
|
}
|
|
12430
|
+
this.selectParents(parentRow);
|
|
12339
12431
|
}
|
|
12340
12432
|
unselectParents(row) {
|
|
12341
|
-
if (row[this.parentField])
|
|
12342
|
-
|
|
12343
|
-
|
|
12344
|
-
|
|
12345
|
-
|
|
12346
|
-
|
|
12347
|
-
|
|
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);
|
|
12348
12441
|
}
|
|
12349
12442
|
}
|
|
12350
12443
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zeedhi/common",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.78.1",
|
|
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": "391eafe389538fe262f4076b258c6a0c2d96e5c2"
|
|
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
|