@zeedhi/common 1.113.0 → 1.114.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.
@@ -1923,6 +1923,7 @@
1923
1923
  this.internalDisplayValue = '';
1924
1924
  this.internalValue = null;
1925
1925
  this.formParent = this.getFormParent();
1926
+ this.grid = {};
1926
1927
  this.lastInputValue = '';
1927
1928
  this.callInputEvent = debounce__default["default"](({ event, element, component }) => {
1928
1929
  this.callEvent('input', { event, element, component });
@@ -1950,6 +1951,7 @@
1950
1951
  this.value = this.getInitValue('value', props.value, this.value);
1951
1952
  this.validations = this.getInitValue('validations', props.validations, this.validations);
1952
1953
  this.autoRegister = this.getInitValue('autoRegister', props.autoRegister, this.autoRegister);
1954
+ this.grid = this.getInitValue('grid', props.grid, this.grid);
1953
1955
  this.parseValidations(props.validations || {});
1954
1956
  if (this.autoRegister && this.formParent) {
1955
1957
  this.formParent.registerInput(this);
@@ -5865,7 +5867,24 @@
5865
5867
  && (!this.searchVisibleOnly || column.isVisible)
5866
5868
  && (this.searchIn === undefined || this.searchIn === column.name);
5867
5869
  }
5868
- }
5870
+ }
5871
+ core.Messages.add({
5872
+ 'pt-BR': {
5873
+ translation: {
5874
+ gridPageText: '{{firstRow}} - {{lastRow}} de {{total}}',
5875
+ },
5876
+ },
5877
+ 'en-US': {
5878
+ translation: {
5879
+ gridPageText: '{{firstRow}} - {{lastRow}} of {{total}}',
5880
+ },
5881
+ },
5882
+ 'es-CL': {
5883
+ translation: {
5884
+ gridPageText: '{{firstRow}} - {{lastRow}} de {{total}}',
5885
+ },
5886
+ },
5887
+ });
5869
5888
 
5870
5889
  /**
5871
5890
  * Delete rows error
@@ -7064,6 +7083,9 @@
7064
7083
  });
7065
7084
  }
7066
7085
  }
7086
+ /**
7087
+ * Retrieves the visible value of a cell, which is the corresponding cell in edited row or in the default row
7088
+ */
7067
7089
  getVisibleValue(row, column) {
7068
7090
  const key = row[this.datasource.uniqueKey];
7069
7091
  if (this.editedRows[key] && Object.prototype.hasOwnProperty.call(this.editedRows[key], column.valueIn)) {
@@ -7071,6 +7093,18 @@
7071
7093
  }
7072
7094
  return row[column.valueIn];
7073
7095
  }
7096
+ /**
7097
+ * Retrieves the visible values of a row
7098
+ * @param row
7099
+ * @returns
7100
+ */
7101
+ getVisibleRow(row) {
7102
+ const visibleRow = Object.assign({}, row);
7103
+ this.columns.forEach((column) => {
7104
+ visibleRow[column.valueIn] = this.getVisibleValue(row, column);
7105
+ });
7106
+ return visibleRow;
7107
+ }
7074
7108
  /**
7075
7109
  * Returns editable component properties based on the column definition
7076
7110
  * @param column Column definition
@@ -7166,6 +7200,15 @@
7166
7200
  delete this.invalidComponents[component.name];
7167
7201
  }
7168
7202
  }
7203
+ clearInvalidComponentsForRow(rowKey) {
7204
+ const cloneInvalidComponents = Object.assign({}, this.invalidComponents);
7205
+ Object.keys(cloneInvalidComponents).forEach((compName) => {
7206
+ if (compName.includes(`_editable_${rowKey}`)) {
7207
+ delete cloneInvalidComponents[compName];
7208
+ }
7209
+ });
7210
+ this.invalidComponents = cloneInvalidComponents;
7211
+ }
7169
7212
  /**
7170
7213
  * change event of editable components
7171
7214
  */
@@ -7277,6 +7320,7 @@
7277
7320
  delete cloneAddedRows[key];
7278
7321
  this.editedRows = cloneEditedRows;
7279
7322
  this.addedRows = cloneAddedRows;
7323
+ this.clearInvalidComponentsForRow(key);
7280
7324
  const { data, uniqueKey } = this.datasource;
7281
7325
  const index = data.findIndex((row) => row[uniqueKey] === key);
7282
7326
  data.splice(index, 1);
@@ -7290,6 +7334,8 @@
7290
7334
  for (let index = allData.length - 1; index >= 0; index -= 1) {
7291
7335
  const row = allData[index];
7292
7336
  if (this.addedRows[row[this.datasource.uniqueKey]]) {
7337
+ const key = row[this.datasource.uniqueKey];
7338
+ this.clearInvalidComponentsForRow(key);
7293
7339
  allData.splice(index, 1);
7294
7340
  }
7295
7341
  }
@@ -7310,13 +7356,17 @@
7310
7356
  saveEditedRows(revalidate = false) {
7311
7357
  return __awaiter(this, void 0, void 0, function* () {
7312
7358
  const { page } = this.datasource;
7359
+ // Verificar se o grid é válido antes de tentar salvar
7360
+ if (!this.isGridValid(revalidate)) {
7361
+ throw new Error('Invalid rows');
7362
+ }
7363
+ // Só cancelar as linhas adicionadas se todas forem válidas
7313
7364
  yield this.cancelAddedRows();
7314
- const response = yield Promise.all(this.getEditedRows(revalidate).map((row) => this.addDataRow(row)));
7365
+ const response = yield Promise.all(this.getEditedRows(revalidate, true).map((row) => this.addDataRow(row)));
7315
7366
  this.editing = false;
7316
7367
  this.editedRows = {};
7317
7368
  this.addedRows = {};
7318
7369
  this.invalidComponents = {};
7319
- this.addedRows = {};
7320
7370
  yield this.datasource.setPage(page);
7321
7371
  return response;
7322
7372
  });
@@ -7567,6 +7617,8 @@
7567
7617
  const rows = Object.assign({}, this.editedRows);
7568
7618
  delete rows[foundRow[uniqueKey]];
7569
7619
  this.editedRows = rows;
7620
+ const key = foundRow[uniqueKey];
7621
+ this.clearInvalidComponentsForRow(key);
7570
7622
  }
7571
7623
  /**
7572
7624
  * Makes the cell enter edit mode
@@ -9854,6 +9906,77 @@
9854
9906
  }
9855
9907
  }
9856
9908
 
9909
+ class DatasourceSearcher {
9910
+ constructor() {
9911
+ this.dsSearch = {
9912
+ SEARCH: (value, searchIn) => ({
9913
+ searchIn: [searchIn],
9914
+ search: String(value || ''),
9915
+ }),
9916
+ FILTER: (value, searchIn) => ({
9917
+ filter: {
9918
+ [searchIn]: value,
9919
+ },
9920
+ }),
9921
+ FIND: (value, searchIn) => ({
9922
+ find: {
9923
+ [searchIn]: value,
9924
+ },
9925
+ }),
9926
+ DYNAMIC_FILTER: (value, search_in) => {
9927
+ const arrayValue = Array.isArray(value) ? value : Array.of(value);
9928
+ const filter = arrayValue.map((item) => ({ operation: 'EQUALS', relation: 'OR', value: item }));
9929
+ const dynamicFilter = { [search_in]: filter };
9930
+ return { dynamicFilter };
9931
+ },
9932
+ };
9933
+ }
9934
+ search(datasource, searchValue, searchIn, searchParam) {
9935
+ return __awaiter(this, void 0, void 0, function* () {
9936
+ // using filter/find/dynamicFilter should make only 1 request
9937
+ // using normal search should make one request per search value
9938
+ if (!Array.isArray(searchValue)) {
9939
+ return this.searchRequest(datasource, searchValue, searchIn, searchParam);
9940
+ }
9941
+ if (searchParam !== 'SEARCH') {
9942
+ const items = yield this.searchRequest(datasource, searchValue, searchIn, searchParam);
9943
+ return items;
9944
+ }
9945
+ const searchedItems = [];
9946
+ const promises = searchValue.map((value) => __awaiter(this, void 0, void 0, function* () {
9947
+ const [item] = yield this.searchRequest(datasource, value, searchIn, searchParam);
9948
+ searchedItems.push(item);
9949
+ }));
9950
+ yield Promise.all(promises);
9951
+ return searchedItems;
9952
+ });
9953
+ }
9954
+ searchRequest(datasource, searchValue, searchIn, searchParam) {
9955
+ return __awaiter(this, void 0, void 0, function* () {
9956
+ const config = Object.assign(Object.assign(Object.assign({}, datasource.clone()), this.dsSearch[searchParam](searchValue, searchIn)), { lazyLoad: true, loadAll: Array.isArray(searchValue) });
9957
+ const cloneDatasource = core.DatasourceFactory.factory(config);
9958
+ const items = yield cloneDatasource.get();
9959
+ cloneDatasource.destroy();
9960
+ if (Array.isArray(searchValue)) {
9961
+ return items.filter((item) => searchValue.includes(item[searchIn]));
9962
+ }
9963
+ return items.filter((row) => row[searchIn] === searchValue);
9964
+ });
9965
+ }
9966
+ }
9967
+
9968
+ const uniqueBy = (a, key) => {
9969
+ const seen = {};
9970
+ return a.filter((item) => {
9971
+ const k = item[key] || JSON.stringify(item);
9972
+ if (!seen[k]) {
9973
+ seen[k] = true;
9974
+ return true;
9975
+ }
9976
+ return false;
9977
+ });
9978
+ };
9979
+
9857
9980
  /**
9858
9981
  * Base class for Select component.
9859
9982
  */
@@ -10144,18 +10267,13 @@
10144
10267
  * Finds and retrieves items searching by value
10145
10268
  * @param value Default value
10146
10269
  */
10147
- getItemsBySearchValue(value, searchIn) {
10270
+ getItemsBySearchValue(value) {
10148
10271
  return __awaiter(this, void 0, void 0, function* () {
10149
- const config = Object.assign(Object.assign(Object.assign({}, this.datasource.clone()), this.dsSearch[this.searchParam](value, searchIn)), { lazyLoad: true, loadAll: Array.isArray(value) });
10150
10272
  this.datasource.loading = true;
10151
- const datasource = core.DatasourceFactory.factory(config);
10152
- const items = yield datasource.get();
10273
+ const datasourceSearcher = new DatasourceSearcher();
10274
+ const result = yield datasourceSearcher.search(this.datasource, value, this.dataValue, this.searchParam);
10153
10275
  this.datasource.loading = false;
10154
- datasource.destroy();
10155
- if (Array.isArray(value)) {
10156
- return items.filter((item) => value.includes(item[this.dataValue]));
10157
- }
10158
- return items.filter(this.getCondition(value));
10276
+ return result;
10159
10277
  });
10160
10278
  }
10161
10279
  getCondition(filterValue) {
@@ -10180,17 +10298,6 @@
10180
10298
  this.updateSearch(this.dirtySearchValue);
10181
10299
  });
10182
10300
  }
10183
- uniqueBy(a, key) {
10184
- const seen = {};
10185
- return a.filter((item) => {
10186
- const k = item[key] || JSON.stringify(item);
10187
- if (!seen[k]) {
10188
- seen[k] = true;
10189
- return true;
10190
- }
10191
- return false;
10192
- });
10193
- }
10194
10301
  afterLoad() {
10195
10302
  if (this.manualMode)
10196
10303
  return;
@@ -10256,11 +10363,10 @@
10256
10363
  else {
10257
10364
  filterValue = value;
10258
10365
  }
10259
- const searchIn = this.dataValue;
10260
10366
  const foundInData = this.datasource.data.find(this.getCondition(filterValue));
10261
10367
  let searchValue = foundInData;
10262
10368
  if (!foundInData && !this.manualMode) {
10263
- [searchValue] = yield this.getItemsBySearchValue(filterValue, searchIn);
10369
+ [searchValue] = yield this.getItemsBySearchValue(filterValue);
10264
10370
  }
10265
10371
  if (!searchValue) {
10266
10372
  this.setFieldRowValue(null);
@@ -10893,15 +10999,12 @@
10893
10999
  this.createAccessors();
10894
11000
  }
10895
11001
  addSlashes(value) {
10896
- if (typeof value === 'string') {
10897
- return value.replace(/\\/g, '\\\\')
10898
- .replace(/\t/g, '\\t')
10899
- .replace(/\n/g, '\\n')
10900
- .replace(/\f/g, '\\f')
10901
- .replace(/\r/g, '\\r')
10902
- .replace(/"/g, '\\"');
10903
- }
10904
- return value;
11002
+ return value.replace(/\\/g, '\\\\')
11003
+ .replace(/\t/g, '\\t')
11004
+ .replace(/\n/g, '\\n')
11005
+ .replace(/\f/g, '\\f')
11006
+ .replace(/\r/g, '\\r')
11007
+ .replace(/"/g, '\\"');
10905
11008
  }
10906
11009
  /**
10907
11010
  * Returns the iterable component metadata based on row data
@@ -10914,14 +11017,13 @@
10914
11017
  .replace(rowExp, JSON.stringify(row))
10915
11018
  .replace(exp, (match) => {
10916
11019
  const propPath = match.replace(/<<|>>|"/g, '').split('.').splice(1).join('.');
10917
- const value = this.addSlashes(get__default["default"](row, propPath));
11020
+ let value = get__default["default"](row, propPath);
11021
+ if (value === undefined || value === null)
11022
+ value = '';
10918
11023
  if (typeof value === 'string') {
10919
- if (match.startsWith('"') && match.endsWith('"'))
10920
- return `"${value}"`;
10921
- return value;
11024
+ const escaped = this.addSlashes(value);
11025
+ return match.startsWith('"') && match.endsWith('"') ? `"${escaped}"` : escaped;
10922
11026
  }
10923
- if (value === undefined)
10924
- return '""';
10925
11027
  return value;
10926
11028
  });
10927
11029
  return JSON.parse(metadata);
@@ -12599,19 +12701,10 @@
12599
12701
  this.insertedValues.push(item);
12600
12702
  pushed = true;
12601
12703
  });
12602
- // using filter/find/dynamicFilter should make only 1 request
12603
- // using normal search should make one request per search value
12604
- if (this.searchParam !== 'SEARCH') {
12605
- const items = yield this.getItemsBySearchValue(searchedValues, this.dataValue);
12704
+ if (searchedValues.length) {
12705
+ const items = yield this.getItemsBySearchValue(searchedValues);
12606
12706
  items.forEach(insertItem);
12607
12707
  }
12608
- else {
12609
- const promises = searchedValues.map((searchedValue) => __awaiter(this, void 0, void 0, function* () {
12610
- const [item] = yield this.getItemsBySearchValue(searchedValue, this.dataValue);
12611
- insertItem(item);
12612
- }));
12613
- yield Promise.all(promises);
12614
- }
12615
12708
  if (foundValues.length > 0) {
12616
12709
  this.setFieldRowValue(foundValues);
12617
12710
  }
@@ -12849,7 +12942,7 @@
12849
12942
  if (this.manualMode)
12850
12943
  return;
12851
12944
  if (this.insertedValues.length) {
12852
- this.datasource.data = this.uniqueBy(this.insertedValues.concat(this.datasource.data), this.datasource.uniqueKey);
12945
+ this.datasource.data = uniqueBy(this.insertedValues.concat(this.datasource.data), this.datasource.uniqueKey);
12853
12946
  const values = this.insertedValues.map((inserted) => inserted[this.dataValue]);
12854
12947
  // prevent caching insertedValues
12855
12948
  this.cachedData = this.datasource.data.filter((row) => !values.includes(row[this.dataValue]));
@@ -13084,6 +13177,7 @@
13084
13177
  * Defines if should wait and not execute GET method when Datasource is created
13085
13178
  */
13086
13179
  this.lazyLoad = true;
13180
+ this.selectValue = null;
13087
13181
  /**
13088
13182
  * Uses delayed loading to load tree branches
13089
13183
  */
@@ -13105,6 +13199,10 @@
13105
13199
  */
13106
13200
  this.dataValueOutFormName = '';
13107
13201
  this.formatterFn = core.FormatterParserProvider.getFormatter('ZdSelectTree');
13202
+ /**
13203
+ * Defines if data handling should be manual or automatic
13204
+ */
13205
+ this.searchParam = 'SEARCH';
13108
13206
  this.savedNodes = undefined;
13109
13207
  this.search = '';
13110
13208
  this.debounceSearch = debounce__default["default"](this.searchChange, 500);
@@ -13132,6 +13230,7 @@
13132
13230
  this.autoSelection = this.getInitValue('autoSelection', props.autoSelection, this.autoSelection);
13133
13231
  this.dataValueOut = this.getInitValue('dataValueOut', props.dataValueOut, this.dataValueOut);
13134
13232
  this.dataValueOutFormName = this.getInitValue('dataValueOutFormName', props.dataValueOutFormName, this.dataValueOutFormName);
13233
+ this.searchParam = this.getInitValue('searchParam', props.searchParam, this.searchParam);
13135
13234
  if (props.datasource && Object.keys(props.datasource).length) {
13136
13235
  this.lazyLoad = props.datasource.lazyLoad !== false;
13137
13236
  const searchFields = Array.isArray(this.dataText) ? this.dataText : [this.dataText];
@@ -13201,6 +13300,9 @@
13201
13300
  this.nodes = this.createChildrenNodes(firstLevelNodes);
13202
13301
  }
13203
13302
  }
13303
+ /**
13304
+ * Creates a Tree Node from a datasource row
13305
+ */
13204
13306
  createNodeFromRow(row) {
13205
13307
  let children;
13206
13308
  if (this.fetchOnDemand && !this.datasource.search) {
@@ -13340,31 +13442,71 @@
13340
13442
  });
13341
13443
  return result;
13342
13444
  }
13445
+ clearNodeRow(row) {
13446
+ return this.clearRow(row.row || row);
13447
+ }
13448
+ /**
13449
+ * Finds and retrieves items searching by value
13450
+ * @param value Default value
13451
+ */
13452
+ getItemsBySearchValue(value) {
13453
+ return __awaiter(this, void 0, void 0, function* () {
13454
+ this.datasource.loading = true;
13455
+ const datasourceSearcher = new DatasourceSearcher();
13456
+ const result = yield datasourceSearcher.search(this.datasource, value, this.dataValue, this.searchParam);
13457
+ this.datasource.loading = false;
13458
+ return result;
13459
+ });
13460
+ }
13343
13461
  get value() {
13344
13462
  if (!this.selectValue)
13345
13463
  return this.selectValue;
13346
13464
  if (this.returnObject) {
13347
- return this.clearRow(this.selectValue.row || this.selectValue);
13465
+ return this.clearNodeRow(this.selectValue);
13348
13466
  }
13349
- return this.selectValue;
13467
+ const key = this.datasource ? this.dataValue : 'id';
13468
+ return this.selectValue[key];
13350
13469
  }
13351
13470
  set value(value) {
13352
13471
  this.setValue(value);
13353
13472
  }
13354
13473
  setValue(value) {
13355
- let val = value;
13356
- const key = this.datasource ? this.dataValue : 'id';
13357
- if (typeof value === 'object' && !Array.isArray(value) && value !== null) {
13358
- val = value[key];
13359
- }
13360
- else if (!value && value !== 0) {
13361
- val = null;
13362
- }
13363
- if (this.returnObject) {
13364
- this.selectValue = val ? { id: val } : null;
13365
- return;
13366
- }
13367
- this.selectValue = val;
13474
+ return __awaiter(this, void 0, void 0, function* () {
13475
+ let val = null;
13476
+ const key = this.datasource ? this.dataValue : 'id';
13477
+ if (!value && value !== 0) {
13478
+ val = null;
13479
+ }
13480
+ else if (typeof value === 'object') {
13481
+ val = value[key];
13482
+ }
13483
+ else {
13484
+ val = value;
13485
+ }
13486
+ if (!val) {
13487
+ this.selectValue = null;
13488
+ return;
13489
+ }
13490
+ if (!this.datasource) {
13491
+ this.selectValue = { id: val };
13492
+ return;
13493
+ }
13494
+ const searchIn = this.dataValue;
13495
+ const foundInData = this.datasource.data.find((row) => row[searchIn] === val);
13496
+ let foundValue = foundInData;
13497
+ if (!foundInData) {
13498
+ [foundValue] = yield this.getItemsBySearchValue(val);
13499
+ }
13500
+ if (!foundValue) {
13501
+ if (typeof value === 'object') {
13502
+ this.selectValue = Object.assign({ id: val }, value);
13503
+ return;
13504
+ }
13505
+ this.selectValue = { id: val };
13506
+ return;
13507
+ }
13508
+ this.selectValue = foundValue;
13509
+ });
13368
13510
  }
13369
13511
  loadChildren(parentNode) {
13370
13512
  return __awaiter(this, void 0, void 0, function* () {
@@ -13417,6 +13559,7 @@
13417
13559
  * Selected Nodes
13418
13560
  */
13419
13561
  this.selectedNodes = [];
13562
+ this.selectValue = [];
13420
13563
  /**
13421
13564
  * Changes the behavior of checked nodes that will be displayed in the array of values
13422
13565
  */
@@ -13435,7 +13578,9 @@
13435
13578
  * Triggered after selected nodes change
13436
13579
  */
13437
13580
  changeSelectedNodes(selectedNodes, element) {
13438
- this.callEvent('onChangeSelectedNodes', { element, component: this, selectedNodes });
13581
+ const selection = this.returnObject
13582
+ ? selectedNodes.map((value) => this.clearNodeRow(value)) : selectedNodes.map((node) => node.id);
13583
+ this.callEvent('onChangeSelectedNodes', { element, component: this, selectedNodes: selection });
13439
13584
  }
13440
13585
  /**
13441
13586
  * Triggered deselecting an node
@@ -13447,34 +13592,58 @@
13447
13592
  if (!this.selectValue)
13448
13593
  return [];
13449
13594
  if (this.returnObject) {
13450
- return this.selectValue.map((value) => this.clearRow(value.row || value));
13595
+ return this.selectValue.map((value) => this.clearNodeRow(value));
13451
13596
  }
13452
- return this.selectValue;
13597
+ const key = this.datasource ? this.dataValue : 'id';
13598
+ return this.selectValue.map((item) => item[key]);
13453
13599
  }
13454
13600
  set value(value) {
13455
13601
  this.setValue(value);
13456
13602
  }
13457
13603
  setValue(value) {
13458
- if (!value) {
13459
- this.selectValue = [];
13460
- return;
13461
- }
13462
- const arrValue = Array.isArray(value) ? value : [value];
13463
- const key = this.datasource ? this.dataValue : 'id';
13464
- if (!this.returnObject) {
13465
- this.selectValue = arrValue.map((item) => {
13604
+ return __awaiter(this, void 0, void 0, function* () {
13605
+ if (!value) {
13606
+ this.selectValue = [];
13607
+ return;
13608
+ }
13609
+ const arrValue = Array.isArray(value) ? value : [value];
13610
+ const key = this.datasource ? this.dataValue : 'id';
13611
+ if (!this.datasource) {
13612
+ this.selectValue = arrValue.map((item) => {
13613
+ if (item && typeof item === 'object') {
13614
+ return item;
13615
+ }
13616
+ return { [key]: item };
13617
+ });
13618
+ return;
13619
+ }
13620
+ const valuesToSearch = [];
13621
+ const foundValues = [];
13622
+ const insertItem = (item) => __awaiter(this, void 0, void 0, function* () {
13623
+ if (!item)
13624
+ return;
13625
+ foundValues.push(item);
13626
+ });
13627
+ arrValue.forEach((item) => __awaiter(this, void 0, void 0, function* () {
13628
+ const searchIn = this.dataValue;
13629
+ if (!item)
13630
+ return;
13466
13631
  if (typeof item === 'object') {
13467
- return item[key];
13632
+ insertItem(item);
13633
+ return;
13468
13634
  }
13469
- return item;
13470
- });
13471
- return;
13472
- }
13473
- this.selectValue = arrValue.map((item) => {
13474
- if (typeof item !== 'object') {
13475
- return { id: item };
13635
+ const foundInData = this.datasource.data.find((row) => row[searchIn] === item);
13636
+ if (!foundInData) {
13637
+ valuesToSearch.push(item);
13638
+ return;
13639
+ }
13640
+ insertItem(foundInData);
13641
+ }));
13642
+ if (valuesToSearch.length) {
13643
+ const items = yield this.getItemsBySearchValue(valuesToSearch);
13644
+ items.forEach(insertItem);
13476
13645
  }
13477
- return { id: item[key] };
13646
+ this.selectValue = foundValues;
13478
13647
  });
13479
13648
  }
13480
13649
  /**
@@ -13522,16 +13691,18 @@
13522
13691
  */
13523
13692
  selectAllItems(nodes = this.nodes) {
13524
13693
  var _a;
13525
- if (((_a = this.datasource) === null || _a === void 0 ? void 0 : _a.data) && this.fetchOnDemand) {
13526
- this.setValue(this.datasource.data);
13527
- return;
13528
- }
13529
- const allNodes = this.getAllNodes(nodes, !this.search);
13530
- // merge all nodes with the current value before setting it
13531
- const currentValue = this.getValueAsObject();
13532
- const nodeMap = this.createMergeMap(currentValue, allNodes);
13533
- const uniqueArray = Array.from(nodeMap.values());
13534
- this.setValue(uniqueArray);
13694
+ return __awaiter(this, void 0, void 0, function* () {
13695
+ if (((_a = this.datasource) === null || _a === void 0 ? void 0 : _a.data) && this.fetchOnDemand) {
13696
+ yield this.setValue(this.datasource.data);
13697
+ return;
13698
+ }
13699
+ const allNodes = this.getAllNodes(nodes, !this.search);
13700
+ // merge all nodes with the current value before setting it
13701
+ const currentValue = this.getValueAsObject();
13702
+ const nodeMap = this.createMergeMap(currentValue, allNodes);
13703
+ const uniqueArray = Array.from(nodeMap.values());
13704
+ yield this.setValue(uniqueArray);
13705
+ });
13535
13706
  }
13536
13707
  /**
13537
13708
  * Unelects all items in the tree \
@@ -13543,21 +13714,23 @@
13543
13714
  */
13544
13715
  unSelectAllItems(nodes = this.nodes) {
13545
13716
  var _a;
13546
- if (((_a = this.datasource) === null || _a === void 0 ? void 0 : _a.data) && this.fetchOnDemand) {
13547
- this.setValue([]);
13548
- return;
13549
- }
13550
- const allNodes = this.getAllNodes(nodes, !this.search);
13551
- // merge all nodes with the current value before setting it
13552
- const currentValue = this.getValueAsObject();
13553
- const nodeMap = this.createMergeMap(currentValue);
13554
- // remove the current visible nodes from the array
13555
- const valuesToRemove = allNodes.map((node) => node.id);
13556
- valuesToRemove.forEach((value) => {
13557
- nodeMap.delete(value);
13717
+ return __awaiter(this, void 0, void 0, function* () {
13718
+ if (((_a = this.datasource) === null || _a === void 0 ? void 0 : _a.data) && this.fetchOnDemand) {
13719
+ yield this.setValue([]);
13720
+ return;
13721
+ }
13722
+ const allNodes = this.getAllNodes(nodes, !this.search);
13723
+ // merge all nodes with the current value before setting it
13724
+ const currentValue = this.getValueAsObject();
13725
+ const nodeMap = this.createMergeMap(currentValue);
13726
+ // remove the current visible nodes from the array
13727
+ const valuesToRemove = allNodes.map((node) => node.id);
13728
+ valuesToRemove.forEach((value) => {
13729
+ nodeMap.delete(value);
13730
+ });
13731
+ const uniqueArray = Array.from(nodeMap.values());
13732
+ yield this.setValue(uniqueArray);
13558
13733
  });
13559
- const uniqueArray = Array.from(nodeMap.values());
13560
- this.setValue(uniqueArray);
13561
13734
  }
13562
13735
  /**
13563
13736
  * Takes two arrays and creates a map of the unique values
@@ -13579,10 +13752,9 @@
13579
13752
  return this.value;
13580
13753
  }
13581
13754
  getValueAsObject() {
13582
- return this.value.map((row) => {
13583
- if (this.returnObject)
13584
- return row;
13585
- return { id: row };
13755
+ return this.selectValue.map((row) => {
13756
+ const key = this.datasource ? this.dataValue : 'id';
13757
+ return Object.assign({ id: row[key] }, row);
13586
13758
  });
13587
13759
  }
13588
13760
  }
@@ -16124,6 +16296,7 @@
16124
16296
  exports.Currency = Currency;
16125
16297
  exports.Dashboard = Dashboard;
16126
16298
  exports.DataValueOutHelper = DataValueOutHelper;
16299
+ exports.DatasourceSearcher = DatasourceSearcher;
16127
16300
  exports.Date = Date$1;
16128
16301
  exports.DateRange = DateRange;
16129
16302
  exports.Dialog = Dialog;
@@ -16210,6 +16383,7 @@
16210
16383
  exports.XLS3Report = XLS3Report;
16211
16384
  exports.XLSReport = XLSReport;
16212
16385
  exports.initTheme = initTheme;
16386
+ exports.uniqueBy = uniqueBy;
16213
16387
 
16214
16388
  Object.defineProperty(exports, '__esModule', { value: true });
16215
16389
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zeedhi/common",
3
- "version": "1.113.0",
3
+ "version": "1.114.0",
4
4
  "description": "Zeedhi Common",
5
5
  "author": "Zeedhi <zeedhi@teknisa.com>",
6
6
  "license": "ISC",
@@ -43,5 +43,5 @@
43
43
  "lodash.times": "4.3.*",
44
44
  "mockdate": "3.0.*"
45
45
  },
46
- "gitHead": "09c421e9201842e6426485730c44dc9a817b9698"
46
+ "gitHead": "de1ca24dc7963c2b201defc04d50e054225e54bc"
47
47
  }