@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.
- package/dist/zd-common.esm.js +288 -116
- package/dist/zd-common.umd.js +289 -115
- package/package.json +2 -2
- package/types/components/zd-grid/grid-editable.d.ts +12 -0
- package/types/components/zd-input/input.d.ts +2 -0
- package/types/components/zd-input/interfaces.d.ts +2 -0
- package/types/components/zd-select/interfaces.d.ts +0 -1
- package/types/components/zd-select/select.d.ts +3 -3
- package/types/components/zd-select-tree/interfaces.d.ts +2 -1
- package/types/components/zd-select-tree/select-tree.d.ts +26 -3
- package/types/components/zd-select-tree-multiple/interfaces.d.ts +2 -0
- package/types/components/zd-select-tree-multiple/select-tree-multiple.d.ts +8 -6
- package/types/utils/datasource-searcher/datasource-searcher.d.ts +7 -0
- package/types/utils/datasource-searcher/index.d.ts +2 -0
- package/types/utils/datasource-searcher/interfaces.d.ts +5 -0
- package/types/utils/index.d.ts +2 -0
- package/types/utils/unique-by/index.d.ts +1 -0
- package/types/utils/unique-by/unique-by.d.ts +3 -0
- package/types/utils/unique-by.d.ts +3 -0
package/dist/zd-common.esm.js
CHANGED
|
@@ -1916,6 +1916,7 @@ class Input extends ComponentRender {
|
|
|
1916
1916
|
this.internalDisplayValue = '';
|
|
1917
1917
|
this.internalValue = null;
|
|
1918
1918
|
this.formParent = this.getFormParent();
|
|
1919
|
+
this.grid = {};
|
|
1919
1920
|
this.lastInputValue = '';
|
|
1920
1921
|
this.callInputEvent = debounce(({ event, element, component }) => {
|
|
1921
1922
|
this.callEvent('input', { event, element, component });
|
|
@@ -1943,6 +1944,7 @@ class Input extends ComponentRender {
|
|
|
1943
1944
|
this.value = this.getInitValue('value', props.value, this.value);
|
|
1944
1945
|
this.validations = this.getInitValue('validations', props.validations, this.validations);
|
|
1945
1946
|
this.autoRegister = this.getInitValue('autoRegister', props.autoRegister, this.autoRegister);
|
|
1947
|
+
this.grid = this.getInitValue('grid', props.grid, this.grid);
|
|
1946
1948
|
this.parseValidations(props.validations || {});
|
|
1947
1949
|
if (this.autoRegister && this.formParent) {
|
|
1948
1950
|
this.formParent.registerInput(this);
|
|
@@ -5858,7 +5860,24 @@ class Iterable extends ComponentRender {
|
|
|
5858
5860
|
&& (!this.searchVisibleOnly || column.isVisible)
|
|
5859
5861
|
&& (this.searchIn === undefined || this.searchIn === column.name);
|
|
5860
5862
|
}
|
|
5861
|
-
}
|
|
5863
|
+
}
|
|
5864
|
+
Messages.add({
|
|
5865
|
+
'pt-BR': {
|
|
5866
|
+
translation: {
|
|
5867
|
+
gridPageText: '{{firstRow}} - {{lastRow}} de {{total}}',
|
|
5868
|
+
},
|
|
5869
|
+
},
|
|
5870
|
+
'en-US': {
|
|
5871
|
+
translation: {
|
|
5872
|
+
gridPageText: '{{firstRow}} - {{lastRow}} of {{total}}',
|
|
5873
|
+
},
|
|
5874
|
+
},
|
|
5875
|
+
'es-CL': {
|
|
5876
|
+
translation: {
|
|
5877
|
+
gridPageText: '{{firstRow}} - {{lastRow}} de {{total}}',
|
|
5878
|
+
},
|
|
5879
|
+
},
|
|
5880
|
+
});
|
|
5862
5881
|
|
|
5863
5882
|
/**
|
|
5864
5883
|
* Delete rows error
|
|
@@ -7057,6 +7076,9 @@ class GridEditable extends Grid {
|
|
|
7057
7076
|
});
|
|
7058
7077
|
}
|
|
7059
7078
|
}
|
|
7079
|
+
/**
|
|
7080
|
+
* Retrieves the visible value of a cell, which is the corresponding cell in edited row or in the default row
|
|
7081
|
+
*/
|
|
7060
7082
|
getVisibleValue(row, column) {
|
|
7061
7083
|
const key = row[this.datasource.uniqueKey];
|
|
7062
7084
|
if (this.editedRows[key] && Object.prototype.hasOwnProperty.call(this.editedRows[key], column.valueIn)) {
|
|
@@ -7064,6 +7086,18 @@ class GridEditable extends Grid {
|
|
|
7064
7086
|
}
|
|
7065
7087
|
return row[column.valueIn];
|
|
7066
7088
|
}
|
|
7089
|
+
/**
|
|
7090
|
+
* Retrieves the visible values of a row
|
|
7091
|
+
* @param row
|
|
7092
|
+
* @returns
|
|
7093
|
+
*/
|
|
7094
|
+
getVisibleRow(row) {
|
|
7095
|
+
const visibleRow = Object.assign({}, row);
|
|
7096
|
+
this.columns.forEach((column) => {
|
|
7097
|
+
visibleRow[column.valueIn] = this.getVisibleValue(row, column);
|
|
7098
|
+
});
|
|
7099
|
+
return visibleRow;
|
|
7100
|
+
}
|
|
7067
7101
|
/**
|
|
7068
7102
|
* Returns editable component properties based on the column definition
|
|
7069
7103
|
* @param column Column definition
|
|
@@ -7159,6 +7193,15 @@ class GridEditable extends Grid {
|
|
|
7159
7193
|
delete this.invalidComponents[component.name];
|
|
7160
7194
|
}
|
|
7161
7195
|
}
|
|
7196
|
+
clearInvalidComponentsForRow(rowKey) {
|
|
7197
|
+
const cloneInvalidComponents = Object.assign({}, this.invalidComponents);
|
|
7198
|
+
Object.keys(cloneInvalidComponents).forEach((compName) => {
|
|
7199
|
+
if (compName.includes(`_editable_${rowKey}`)) {
|
|
7200
|
+
delete cloneInvalidComponents[compName];
|
|
7201
|
+
}
|
|
7202
|
+
});
|
|
7203
|
+
this.invalidComponents = cloneInvalidComponents;
|
|
7204
|
+
}
|
|
7162
7205
|
/**
|
|
7163
7206
|
* change event of editable components
|
|
7164
7207
|
*/
|
|
@@ -7270,6 +7313,7 @@ class GridEditable extends Grid {
|
|
|
7270
7313
|
delete cloneAddedRows[key];
|
|
7271
7314
|
this.editedRows = cloneEditedRows;
|
|
7272
7315
|
this.addedRows = cloneAddedRows;
|
|
7316
|
+
this.clearInvalidComponentsForRow(key);
|
|
7273
7317
|
const { data, uniqueKey } = this.datasource;
|
|
7274
7318
|
const index = data.findIndex((row) => row[uniqueKey] === key);
|
|
7275
7319
|
data.splice(index, 1);
|
|
@@ -7283,6 +7327,8 @@ class GridEditable extends Grid {
|
|
|
7283
7327
|
for (let index = allData.length - 1; index >= 0; index -= 1) {
|
|
7284
7328
|
const row = allData[index];
|
|
7285
7329
|
if (this.addedRows[row[this.datasource.uniqueKey]]) {
|
|
7330
|
+
const key = row[this.datasource.uniqueKey];
|
|
7331
|
+
this.clearInvalidComponentsForRow(key);
|
|
7286
7332
|
allData.splice(index, 1);
|
|
7287
7333
|
}
|
|
7288
7334
|
}
|
|
@@ -7303,13 +7349,17 @@ class GridEditable extends Grid {
|
|
|
7303
7349
|
saveEditedRows(revalidate = false) {
|
|
7304
7350
|
return __awaiter(this, void 0, void 0, function* () {
|
|
7305
7351
|
const { page } = this.datasource;
|
|
7352
|
+
// Verificar se o grid é válido antes de tentar salvar
|
|
7353
|
+
if (!this.isGridValid(revalidate)) {
|
|
7354
|
+
throw new Error('Invalid rows');
|
|
7355
|
+
}
|
|
7356
|
+
// Só cancelar as linhas adicionadas se todas forem válidas
|
|
7306
7357
|
yield this.cancelAddedRows();
|
|
7307
|
-
const response = yield Promise.all(this.getEditedRows(revalidate).map((row) => this.addDataRow(row)));
|
|
7358
|
+
const response = yield Promise.all(this.getEditedRows(revalidate, true).map((row) => this.addDataRow(row)));
|
|
7308
7359
|
this.editing = false;
|
|
7309
7360
|
this.editedRows = {};
|
|
7310
7361
|
this.addedRows = {};
|
|
7311
7362
|
this.invalidComponents = {};
|
|
7312
|
-
this.addedRows = {};
|
|
7313
7363
|
yield this.datasource.setPage(page);
|
|
7314
7364
|
return response;
|
|
7315
7365
|
});
|
|
@@ -7560,6 +7610,8 @@ class GridEditable extends Grid {
|
|
|
7560
7610
|
const rows = Object.assign({}, this.editedRows);
|
|
7561
7611
|
delete rows[foundRow[uniqueKey]];
|
|
7562
7612
|
this.editedRows = rows;
|
|
7613
|
+
const key = foundRow[uniqueKey];
|
|
7614
|
+
this.clearInvalidComponentsForRow(key);
|
|
7563
7615
|
}
|
|
7564
7616
|
/**
|
|
7565
7617
|
* Makes the cell enter edit mode
|
|
@@ -9847,6 +9899,77 @@ class DataValueOutHelper {
|
|
|
9847
9899
|
}
|
|
9848
9900
|
}
|
|
9849
9901
|
|
|
9902
|
+
class DatasourceSearcher {
|
|
9903
|
+
constructor() {
|
|
9904
|
+
this.dsSearch = {
|
|
9905
|
+
SEARCH: (value, searchIn) => ({
|
|
9906
|
+
searchIn: [searchIn],
|
|
9907
|
+
search: String(value || ''),
|
|
9908
|
+
}),
|
|
9909
|
+
FILTER: (value, searchIn) => ({
|
|
9910
|
+
filter: {
|
|
9911
|
+
[searchIn]: value,
|
|
9912
|
+
},
|
|
9913
|
+
}),
|
|
9914
|
+
FIND: (value, searchIn) => ({
|
|
9915
|
+
find: {
|
|
9916
|
+
[searchIn]: value,
|
|
9917
|
+
},
|
|
9918
|
+
}),
|
|
9919
|
+
DYNAMIC_FILTER: (value, search_in) => {
|
|
9920
|
+
const arrayValue = Array.isArray(value) ? value : Array.of(value);
|
|
9921
|
+
const filter = arrayValue.map((item) => ({ operation: 'EQUALS', relation: 'OR', value: item }));
|
|
9922
|
+
const dynamicFilter = { [search_in]: filter };
|
|
9923
|
+
return { dynamicFilter };
|
|
9924
|
+
},
|
|
9925
|
+
};
|
|
9926
|
+
}
|
|
9927
|
+
search(datasource, searchValue, searchIn, searchParam) {
|
|
9928
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
9929
|
+
// using filter/find/dynamicFilter should make only 1 request
|
|
9930
|
+
// using normal search should make one request per search value
|
|
9931
|
+
if (!Array.isArray(searchValue)) {
|
|
9932
|
+
return this.searchRequest(datasource, searchValue, searchIn, searchParam);
|
|
9933
|
+
}
|
|
9934
|
+
if (searchParam !== 'SEARCH') {
|
|
9935
|
+
const items = yield this.searchRequest(datasource, searchValue, searchIn, searchParam);
|
|
9936
|
+
return items;
|
|
9937
|
+
}
|
|
9938
|
+
const searchedItems = [];
|
|
9939
|
+
const promises = searchValue.map((value) => __awaiter(this, void 0, void 0, function* () {
|
|
9940
|
+
const [item] = yield this.searchRequest(datasource, value, searchIn, searchParam);
|
|
9941
|
+
searchedItems.push(item);
|
|
9942
|
+
}));
|
|
9943
|
+
yield Promise.all(promises);
|
|
9944
|
+
return searchedItems;
|
|
9945
|
+
});
|
|
9946
|
+
}
|
|
9947
|
+
searchRequest(datasource, searchValue, searchIn, searchParam) {
|
|
9948
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
9949
|
+
const config = Object.assign(Object.assign(Object.assign({}, datasource.clone()), this.dsSearch[searchParam](searchValue, searchIn)), { lazyLoad: true, loadAll: Array.isArray(searchValue) });
|
|
9950
|
+
const cloneDatasource = DatasourceFactory.factory(config);
|
|
9951
|
+
const items = yield cloneDatasource.get();
|
|
9952
|
+
cloneDatasource.destroy();
|
|
9953
|
+
if (Array.isArray(searchValue)) {
|
|
9954
|
+
return items.filter((item) => searchValue.includes(item[searchIn]));
|
|
9955
|
+
}
|
|
9956
|
+
return items.filter((row) => row[searchIn] === searchValue);
|
|
9957
|
+
});
|
|
9958
|
+
}
|
|
9959
|
+
}
|
|
9960
|
+
|
|
9961
|
+
const uniqueBy = (a, key) => {
|
|
9962
|
+
const seen = {};
|
|
9963
|
+
return a.filter((item) => {
|
|
9964
|
+
const k = item[key] || JSON.stringify(item);
|
|
9965
|
+
if (!seen[k]) {
|
|
9966
|
+
seen[k] = true;
|
|
9967
|
+
return true;
|
|
9968
|
+
}
|
|
9969
|
+
return false;
|
|
9970
|
+
});
|
|
9971
|
+
};
|
|
9972
|
+
|
|
9850
9973
|
/**
|
|
9851
9974
|
* Base class for Select component.
|
|
9852
9975
|
*/
|
|
@@ -10137,18 +10260,13 @@ class Select extends TextInput {
|
|
|
10137
10260
|
* Finds and retrieves items searching by value
|
|
10138
10261
|
* @param value Default value
|
|
10139
10262
|
*/
|
|
10140
|
-
getItemsBySearchValue(value
|
|
10263
|
+
getItemsBySearchValue(value) {
|
|
10141
10264
|
return __awaiter(this, void 0, void 0, function* () {
|
|
10142
|
-
const config = Object.assign(Object.assign(Object.assign({}, this.datasource.clone()), this.dsSearch[this.searchParam](value, searchIn)), { lazyLoad: true, loadAll: Array.isArray(value) });
|
|
10143
10265
|
this.datasource.loading = true;
|
|
10144
|
-
const
|
|
10145
|
-
const
|
|
10266
|
+
const datasourceSearcher = new DatasourceSearcher();
|
|
10267
|
+
const result = yield datasourceSearcher.search(this.datasource, value, this.dataValue, this.searchParam);
|
|
10146
10268
|
this.datasource.loading = false;
|
|
10147
|
-
|
|
10148
|
-
if (Array.isArray(value)) {
|
|
10149
|
-
return items.filter((item) => value.includes(item[this.dataValue]));
|
|
10150
|
-
}
|
|
10151
|
-
return items.filter(this.getCondition(value));
|
|
10269
|
+
return result;
|
|
10152
10270
|
});
|
|
10153
10271
|
}
|
|
10154
10272
|
getCondition(filterValue) {
|
|
@@ -10173,17 +10291,6 @@ class Select extends TextInput {
|
|
|
10173
10291
|
this.updateSearch(this.dirtySearchValue);
|
|
10174
10292
|
});
|
|
10175
10293
|
}
|
|
10176
|
-
uniqueBy(a, key) {
|
|
10177
|
-
const seen = {};
|
|
10178
|
-
return a.filter((item) => {
|
|
10179
|
-
const k = item[key] || JSON.stringify(item);
|
|
10180
|
-
if (!seen[k]) {
|
|
10181
|
-
seen[k] = true;
|
|
10182
|
-
return true;
|
|
10183
|
-
}
|
|
10184
|
-
return false;
|
|
10185
|
-
});
|
|
10186
|
-
}
|
|
10187
10294
|
afterLoad() {
|
|
10188
10295
|
if (this.manualMode)
|
|
10189
10296
|
return;
|
|
@@ -10249,11 +10356,10 @@ class Select extends TextInput {
|
|
|
10249
10356
|
else {
|
|
10250
10357
|
filterValue = value;
|
|
10251
10358
|
}
|
|
10252
|
-
const searchIn = this.dataValue;
|
|
10253
10359
|
const foundInData = this.datasource.data.find(this.getCondition(filterValue));
|
|
10254
10360
|
let searchValue = foundInData;
|
|
10255
10361
|
if (!foundInData && !this.manualMode) {
|
|
10256
|
-
[searchValue] = yield this.getItemsBySearchValue(filterValue
|
|
10362
|
+
[searchValue] = yield this.getItemsBySearchValue(filterValue);
|
|
10257
10363
|
}
|
|
10258
10364
|
if (!searchValue) {
|
|
10259
10365
|
this.setFieldRowValue(null);
|
|
@@ -10886,15 +10992,12 @@ class IterableComponentRender extends Iterable {
|
|
|
10886
10992
|
this.createAccessors();
|
|
10887
10993
|
}
|
|
10888
10994
|
addSlashes(value) {
|
|
10889
|
-
|
|
10890
|
-
|
|
10891
|
-
|
|
10892
|
-
|
|
10893
|
-
|
|
10894
|
-
|
|
10895
|
-
.replace(/"/g, '\\"');
|
|
10896
|
-
}
|
|
10897
|
-
return value;
|
|
10995
|
+
return value.replace(/\\/g, '\\\\')
|
|
10996
|
+
.replace(/\t/g, '\\t')
|
|
10997
|
+
.replace(/\n/g, '\\n')
|
|
10998
|
+
.replace(/\f/g, '\\f')
|
|
10999
|
+
.replace(/\r/g, '\\r')
|
|
11000
|
+
.replace(/"/g, '\\"');
|
|
10898
11001
|
}
|
|
10899
11002
|
/**
|
|
10900
11003
|
* Returns the iterable component metadata based on row data
|
|
@@ -10907,14 +11010,13 @@ class IterableComponentRender extends Iterable {
|
|
|
10907
11010
|
.replace(rowExp, JSON.stringify(row))
|
|
10908
11011
|
.replace(exp, (match) => {
|
|
10909
11012
|
const propPath = match.replace(/<<|>>|"/g, '').split('.').splice(1).join('.');
|
|
10910
|
-
|
|
11013
|
+
let value = get(row, propPath);
|
|
11014
|
+
if (value === undefined || value === null)
|
|
11015
|
+
value = '';
|
|
10911
11016
|
if (typeof value === 'string') {
|
|
10912
|
-
|
|
10913
|
-
|
|
10914
|
-
return value;
|
|
11017
|
+
const escaped = this.addSlashes(value);
|
|
11018
|
+
return match.startsWith('"') && match.endsWith('"') ? `"${escaped}"` : escaped;
|
|
10915
11019
|
}
|
|
10916
|
-
if (value === undefined)
|
|
10917
|
-
return '""';
|
|
10918
11020
|
return value;
|
|
10919
11021
|
});
|
|
10920
11022
|
return JSON.parse(metadata);
|
|
@@ -12592,19 +12694,10 @@ class SelectMultiple extends Select {
|
|
|
12592
12694
|
this.insertedValues.push(item);
|
|
12593
12695
|
pushed = true;
|
|
12594
12696
|
});
|
|
12595
|
-
|
|
12596
|
-
|
|
12597
|
-
if (this.searchParam !== 'SEARCH') {
|
|
12598
|
-
const items = yield this.getItemsBySearchValue(searchedValues, this.dataValue);
|
|
12697
|
+
if (searchedValues.length) {
|
|
12698
|
+
const items = yield this.getItemsBySearchValue(searchedValues);
|
|
12599
12699
|
items.forEach(insertItem);
|
|
12600
12700
|
}
|
|
12601
|
-
else {
|
|
12602
|
-
const promises = searchedValues.map((searchedValue) => __awaiter(this, void 0, void 0, function* () {
|
|
12603
|
-
const [item] = yield this.getItemsBySearchValue(searchedValue, this.dataValue);
|
|
12604
|
-
insertItem(item);
|
|
12605
|
-
}));
|
|
12606
|
-
yield Promise.all(promises);
|
|
12607
|
-
}
|
|
12608
12701
|
if (foundValues.length > 0) {
|
|
12609
12702
|
this.setFieldRowValue(foundValues);
|
|
12610
12703
|
}
|
|
@@ -12842,7 +12935,7 @@ class SelectMultiple extends Select {
|
|
|
12842
12935
|
if (this.manualMode)
|
|
12843
12936
|
return;
|
|
12844
12937
|
if (this.insertedValues.length) {
|
|
12845
|
-
this.datasource.data =
|
|
12938
|
+
this.datasource.data = uniqueBy(this.insertedValues.concat(this.datasource.data), this.datasource.uniqueKey);
|
|
12846
12939
|
const values = this.insertedValues.map((inserted) => inserted[this.dataValue]);
|
|
12847
12940
|
// prevent caching insertedValues
|
|
12848
12941
|
this.cachedData = this.datasource.data.filter((row) => !values.includes(row[this.dataValue]));
|
|
@@ -13077,6 +13170,7 @@ class SelectTree extends TextInput {
|
|
|
13077
13170
|
* Defines if should wait and not execute GET method when Datasource is created
|
|
13078
13171
|
*/
|
|
13079
13172
|
this.lazyLoad = true;
|
|
13173
|
+
this.selectValue = null;
|
|
13080
13174
|
/**
|
|
13081
13175
|
* Uses delayed loading to load tree branches
|
|
13082
13176
|
*/
|
|
@@ -13098,6 +13192,10 @@ class SelectTree extends TextInput {
|
|
|
13098
13192
|
*/
|
|
13099
13193
|
this.dataValueOutFormName = '';
|
|
13100
13194
|
this.formatterFn = FormatterParserProvider.getFormatter('ZdSelectTree');
|
|
13195
|
+
/**
|
|
13196
|
+
* Defines if data handling should be manual or automatic
|
|
13197
|
+
*/
|
|
13198
|
+
this.searchParam = 'SEARCH';
|
|
13101
13199
|
this.savedNodes = undefined;
|
|
13102
13200
|
this.search = '';
|
|
13103
13201
|
this.debounceSearch = debounce(this.searchChange, 500);
|
|
@@ -13125,6 +13223,7 @@ class SelectTree extends TextInput {
|
|
|
13125
13223
|
this.autoSelection = this.getInitValue('autoSelection', props.autoSelection, this.autoSelection);
|
|
13126
13224
|
this.dataValueOut = this.getInitValue('dataValueOut', props.dataValueOut, this.dataValueOut);
|
|
13127
13225
|
this.dataValueOutFormName = this.getInitValue('dataValueOutFormName', props.dataValueOutFormName, this.dataValueOutFormName);
|
|
13226
|
+
this.searchParam = this.getInitValue('searchParam', props.searchParam, this.searchParam);
|
|
13128
13227
|
if (props.datasource && Object.keys(props.datasource).length) {
|
|
13129
13228
|
this.lazyLoad = props.datasource.lazyLoad !== false;
|
|
13130
13229
|
const searchFields = Array.isArray(this.dataText) ? this.dataText : [this.dataText];
|
|
@@ -13194,6 +13293,9 @@ class SelectTree extends TextInput {
|
|
|
13194
13293
|
this.nodes = this.createChildrenNodes(firstLevelNodes);
|
|
13195
13294
|
}
|
|
13196
13295
|
}
|
|
13296
|
+
/**
|
|
13297
|
+
* Creates a Tree Node from a datasource row
|
|
13298
|
+
*/
|
|
13197
13299
|
createNodeFromRow(row) {
|
|
13198
13300
|
let children;
|
|
13199
13301
|
if (this.fetchOnDemand && !this.datasource.search) {
|
|
@@ -13333,31 +13435,71 @@ class SelectTree extends TextInput {
|
|
|
13333
13435
|
});
|
|
13334
13436
|
return result;
|
|
13335
13437
|
}
|
|
13438
|
+
clearNodeRow(row) {
|
|
13439
|
+
return this.clearRow(row.row || row);
|
|
13440
|
+
}
|
|
13441
|
+
/**
|
|
13442
|
+
* Finds and retrieves items searching by value
|
|
13443
|
+
* @param value Default value
|
|
13444
|
+
*/
|
|
13445
|
+
getItemsBySearchValue(value) {
|
|
13446
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
13447
|
+
this.datasource.loading = true;
|
|
13448
|
+
const datasourceSearcher = new DatasourceSearcher();
|
|
13449
|
+
const result = yield datasourceSearcher.search(this.datasource, value, this.dataValue, this.searchParam);
|
|
13450
|
+
this.datasource.loading = false;
|
|
13451
|
+
return result;
|
|
13452
|
+
});
|
|
13453
|
+
}
|
|
13336
13454
|
get value() {
|
|
13337
13455
|
if (!this.selectValue)
|
|
13338
13456
|
return this.selectValue;
|
|
13339
13457
|
if (this.returnObject) {
|
|
13340
|
-
return this.
|
|
13458
|
+
return this.clearNodeRow(this.selectValue);
|
|
13341
13459
|
}
|
|
13342
|
-
|
|
13460
|
+
const key = this.datasource ? this.dataValue : 'id';
|
|
13461
|
+
return this.selectValue[key];
|
|
13343
13462
|
}
|
|
13344
13463
|
set value(value) {
|
|
13345
13464
|
this.setValue(value);
|
|
13346
13465
|
}
|
|
13347
13466
|
setValue(value) {
|
|
13348
|
-
|
|
13349
|
-
|
|
13350
|
-
|
|
13351
|
-
|
|
13352
|
-
|
|
13353
|
-
|
|
13354
|
-
|
|
13355
|
-
|
|
13356
|
-
|
|
13357
|
-
|
|
13358
|
-
|
|
13359
|
-
|
|
13360
|
-
|
|
13467
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
13468
|
+
let val = null;
|
|
13469
|
+
const key = this.datasource ? this.dataValue : 'id';
|
|
13470
|
+
if (!value && value !== 0) {
|
|
13471
|
+
val = null;
|
|
13472
|
+
}
|
|
13473
|
+
else if (typeof value === 'object') {
|
|
13474
|
+
val = value[key];
|
|
13475
|
+
}
|
|
13476
|
+
else {
|
|
13477
|
+
val = value;
|
|
13478
|
+
}
|
|
13479
|
+
if (!val) {
|
|
13480
|
+
this.selectValue = null;
|
|
13481
|
+
return;
|
|
13482
|
+
}
|
|
13483
|
+
if (!this.datasource) {
|
|
13484
|
+
this.selectValue = { id: val };
|
|
13485
|
+
return;
|
|
13486
|
+
}
|
|
13487
|
+
const searchIn = this.dataValue;
|
|
13488
|
+
const foundInData = this.datasource.data.find((row) => row[searchIn] === val);
|
|
13489
|
+
let foundValue = foundInData;
|
|
13490
|
+
if (!foundInData) {
|
|
13491
|
+
[foundValue] = yield this.getItemsBySearchValue(val);
|
|
13492
|
+
}
|
|
13493
|
+
if (!foundValue) {
|
|
13494
|
+
if (typeof value === 'object') {
|
|
13495
|
+
this.selectValue = Object.assign({ id: val }, value);
|
|
13496
|
+
return;
|
|
13497
|
+
}
|
|
13498
|
+
this.selectValue = { id: val };
|
|
13499
|
+
return;
|
|
13500
|
+
}
|
|
13501
|
+
this.selectValue = foundValue;
|
|
13502
|
+
});
|
|
13361
13503
|
}
|
|
13362
13504
|
loadChildren(parentNode) {
|
|
13363
13505
|
return __awaiter(this, void 0, void 0, function* () {
|
|
@@ -13410,6 +13552,7 @@ class SelectTreeMultiple extends SelectTree {
|
|
|
13410
13552
|
* Selected Nodes
|
|
13411
13553
|
*/
|
|
13412
13554
|
this.selectedNodes = [];
|
|
13555
|
+
this.selectValue = [];
|
|
13413
13556
|
/**
|
|
13414
13557
|
* Changes the behavior of checked nodes that will be displayed in the array of values
|
|
13415
13558
|
*/
|
|
@@ -13428,7 +13571,9 @@ class SelectTreeMultiple extends SelectTree {
|
|
|
13428
13571
|
* Triggered after selected nodes change
|
|
13429
13572
|
*/
|
|
13430
13573
|
changeSelectedNodes(selectedNodes, element) {
|
|
13431
|
-
|
|
13574
|
+
const selection = this.returnObject
|
|
13575
|
+
? selectedNodes.map((value) => this.clearNodeRow(value)) : selectedNodes.map((node) => node.id);
|
|
13576
|
+
this.callEvent('onChangeSelectedNodes', { element, component: this, selectedNodes: selection });
|
|
13432
13577
|
}
|
|
13433
13578
|
/**
|
|
13434
13579
|
* Triggered deselecting an node
|
|
@@ -13440,34 +13585,58 @@ class SelectTreeMultiple extends SelectTree {
|
|
|
13440
13585
|
if (!this.selectValue)
|
|
13441
13586
|
return [];
|
|
13442
13587
|
if (this.returnObject) {
|
|
13443
|
-
return this.selectValue.map((value) => this.
|
|
13588
|
+
return this.selectValue.map((value) => this.clearNodeRow(value));
|
|
13444
13589
|
}
|
|
13445
|
-
|
|
13590
|
+
const key = this.datasource ? this.dataValue : 'id';
|
|
13591
|
+
return this.selectValue.map((item) => item[key]);
|
|
13446
13592
|
}
|
|
13447
13593
|
set value(value) {
|
|
13448
13594
|
this.setValue(value);
|
|
13449
13595
|
}
|
|
13450
13596
|
setValue(value) {
|
|
13451
|
-
|
|
13452
|
-
|
|
13453
|
-
|
|
13454
|
-
|
|
13455
|
-
|
|
13456
|
-
|
|
13457
|
-
|
|
13458
|
-
this.
|
|
13597
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
13598
|
+
if (!value) {
|
|
13599
|
+
this.selectValue = [];
|
|
13600
|
+
return;
|
|
13601
|
+
}
|
|
13602
|
+
const arrValue = Array.isArray(value) ? value : [value];
|
|
13603
|
+
const key = this.datasource ? this.dataValue : 'id';
|
|
13604
|
+
if (!this.datasource) {
|
|
13605
|
+
this.selectValue = arrValue.map((item) => {
|
|
13606
|
+
if (item && typeof item === 'object') {
|
|
13607
|
+
return item;
|
|
13608
|
+
}
|
|
13609
|
+
return { [key]: item };
|
|
13610
|
+
});
|
|
13611
|
+
return;
|
|
13612
|
+
}
|
|
13613
|
+
const valuesToSearch = [];
|
|
13614
|
+
const foundValues = [];
|
|
13615
|
+
const insertItem = (item) => __awaiter(this, void 0, void 0, function* () {
|
|
13616
|
+
if (!item)
|
|
13617
|
+
return;
|
|
13618
|
+
foundValues.push(item);
|
|
13619
|
+
});
|
|
13620
|
+
arrValue.forEach((item) => __awaiter(this, void 0, void 0, function* () {
|
|
13621
|
+
const searchIn = this.dataValue;
|
|
13622
|
+
if (!item)
|
|
13623
|
+
return;
|
|
13459
13624
|
if (typeof item === 'object') {
|
|
13460
|
-
|
|
13625
|
+
insertItem(item);
|
|
13626
|
+
return;
|
|
13461
13627
|
}
|
|
13462
|
-
|
|
13463
|
-
|
|
13464
|
-
|
|
13465
|
-
|
|
13466
|
-
|
|
13467
|
-
|
|
13468
|
-
|
|
13628
|
+
const foundInData = this.datasource.data.find((row) => row[searchIn] === item);
|
|
13629
|
+
if (!foundInData) {
|
|
13630
|
+
valuesToSearch.push(item);
|
|
13631
|
+
return;
|
|
13632
|
+
}
|
|
13633
|
+
insertItem(foundInData);
|
|
13634
|
+
}));
|
|
13635
|
+
if (valuesToSearch.length) {
|
|
13636
|
+
const items = yield this.getItemsBySearchValue(valuesToSearch);
|
|
13637
|
+
items.forEach(insertItem);
|
|
13469
13638
|
}
|
|
13470
|
-
|
|
13639
|
+
this.selectValue = foundValues;
|
|
13471
13640
|
});
|
|
13472
13641
|
}
|
|
13473
13642
|
/**
|
|
@@ -13515,16 +13684,18 @@ class SelectTreeMultiple extends SelectTree {
|
|
|
13515
13684
|
*/
|
|
13516
13685
|
selectAllItems(nodes = this.nodes) {
|
|
13517
13686
|
var _a;
|
|
13518
|
-
|
|
13519
|
-
|
|
13520
|
-
|
|
13521
|
-
|
|
13522
|
-
|
|
13523
|
-
|
|
13524
|
-
|
|
13525
|
-
|
|
13526
|
-
|
|
13527
|
-
|
|
13687
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
13688
|
+
if (((_a = this.datasource) === null || _a === void 0 ? void 0 : _a.data) && this.fetchOnDemand) {
|
|
13689
|
+
yield this.setValue(this.datasource.data);
|
|
13690
|
+
return;
|
|
13691
|
+
}
|
|
13692
|
+
const allNodes = this.getAllNodes(nodes, !this.search);
|
|
13693
|
+
// merge all nodes with the current value before setting it
|
|
13694
|
+
const currentValue = this.getValueAsObject();
|
|
13695
|
+
const nodeMap = this.createMergeMap(currentValue, allNodes);
|
|
13696
|
+
const uniqueArray = Array.from(nodeMap.values());
|
|
13697
|
+
yield this.setValue(uniqueArray);
|
|
13698
|
+
});
|
|
13528
13699
|
}
|
|
13529
13700
|
/**
|
|
13530
13701
|
* Unelects all items in the tree \
|
|
@@ -13536,21 +13707,23 @@ class SelectTreeMultiple extends SelectTree {
|
|
|
13536
13707
|
*/
|
|
13537
13708
|
unSelectAllItems(nodes = this.nodes) {
|
|
13538
13709
|
var _a;
|
|
13539
|
-
|
|
13540
|
-
this.
|
|
13541
|
-
|
|
13542
|
-
|
|
13543
|
-
|
|
13544
|
-
|
|
13545
|
-
|
|
13546
|
-
|
|
13547
|
-
|
|
13548
|
-
|
|
13549
|
-
|
|
13550
|
-
|
|
13710
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
13711
|
+
if (((_a = this.datasource) === null || _a === void 0 ? void 0 : _a.data) && this.fetchOnDemand) {
|
|
13712
|
+
yield this.setValue([]);
|
|
13713
|
+
return;
|
|
13714
|
+
}
|
|
13715
|
+
const allNodes = this.getAllNodes(nodes, !this.search);
|
|
13716
|
+
// merge all nodes with the current value before setting it
|
|
13717
|
+
const currentValue = this.getValueAsObject();
|
|
13718
|
+
const nodeMap = this.createMergeMap(currentValue);
|
|
13719
|
+
// remove the current visible nodes from the array
|
|
13720
|
+
const valuesToRemove = allNodes.map((node) => node.id);
|
|
13721
|
+
valuesToRemove.forEach((value) => {
|
|
13722
|
+
nodeMap.delete(value);
|
|
13723
|
+
});
|
|
13724
|
+
const uniqueArray = Array.from(nodeMap.values());
|
|
13725
|
+
yield this.setValue(uniqueArray);
|
|
13551
13726
|
});
|
|
13552
|
-
const uniqueArray = Array.from(nodeMap.values());
|
|
13553
|
-
this.setValue(uniqueArray);
|
|
13554
13727
|
}
|
|
13555
13728
|
/**
|
|
13556
13729
|
* Takes two arrays and creates a map of the unique values
|
|
@@ -13572,10 +13745,9 @@ class SelectTreeMultiple extends SelectTree {
|
|
|
13572
13745
|
return this.value;
|
|
13573
13746
|
}
|
|
13574
13747
|
getValueAsObject() {
|
|
13575
|
-
return this.
|
|
13576
|
-
|
|
13577
|
-
|
|
13578
|
-
return { id: row };
|
|
13748
|
+
return this.selectValue.map((row) => {
|
|
13749
|
+
const key = this.datasource ? this.dataValue : 'id';
|
|
13750
|
+
return Object.assign({ id: row[key] }, row);
|
|
13579
13751
|
});
|
|
13580
13752
|
}
|
|
13581
13753
|
}
|
|
@@ -16091,4 +16263,4 @@ const AutoNumeric = require('@zeedhi/autonumeric/dist/autoNumeric');
|
|
|
16091
16263
|
const packageContent = require('../package.json');
|
|
16092
16264
|
VersionService.addPackageVersion(packageContent.name, packageContent.version);
|
|
16093
16265
|
|
|
16094
|
-
export { Alert, AlertService, ApexChart, AutoNumeric, Badge, Breadcrumbs, Button, ButtonGroup, CSVReport, Card, Carousel, Checkbox, CheckboxMultiple, ChildNotFoundError, Chip, CodeEditor, Col, CollapseCard, Column, ColumnNotFoundError, Component, ComponentRender, Container, Currency, Dashboard, DataValueOutHelper, Date$1 as Date, DateRange, Dialog, DialogService, Divider, Dropdown, EmptyDataError, FileInput, Footer, Form, Frame, FramePage, Grid, GridColumn, GridColumnEditable, GridEditable, GroupedPDFFormatter, Header, Icon, Icons, Image, Increment, Input, InputFactory, Iterable, IterableColumnsButton, IterableColumnsButtonController, IterableComponentRender, IterablePageComponent, IterablePageInfo, IterablePageSize, IterablePagination, List, ListGroup, ListItem, Loading, LoadingService, Login, LoginButton, MasterDetail, Menu, MenuButton, MenuGroup, MenuLink, MenuSeparator, Modal, ModalCloseButton, ModalService, Month, Number$1 as Number, PDFReport, Password, Progress, Radio, RangeSlider, Report, Row, Search, Select, SelectMultiple, SelectTree, SelectTreeMultiple, SelectableList, SpeedDial, Steppers, SvgMap, Switch, Tab, Table, Tabs, Tag, Text, TextInput, Textarea, Time, Toggleable, Tooltip, Tree, TreeDataStructure, TreeGrid, TreeGridEditable, WatchURL, XLS2Report, XLS3Report, XLSReport, initTheme };
|
|
16266
|
+
export { Alert, AlertService, ApexChart, AutoNumeric, Badge, Breadcrumbs, Button, ButtonGroup, CSVReport, Card, Carousel, Checkbox, CheckboxMultiple, ChildNotFoundError, Chip, CodeEditor, Col, CollapseCard, Column, ColumnNotFoundError, Component, ComponentRender, Container, Currency, Dashboard, DataValueOutHelper, DatasourceSearcher, Date$1 as Date, DateRange, Dialog, DialogService, Divider, Dropdown, EmptyDataError, FileInput, Footer, Form, Frame, FramePage, Grid, GridColumn, GridColumnEditable, GridEditable, GroupedPDFFormatter, Header, Icon, Icons, Image, Increment, Input, InputFactory, Iterable, IterableColumnsButton, IterableColumnsButtonController, IterableComponentRender, IterablePageComponent, IterablePageInfo, IterablePageSize, IterablePagination, List, ListGroup, ListItem, Loading, LoadingService, Login, LoginButton, MasterDetail, Menu, MenuButton, MenuGroup, MenuLink, MenuSeparator, Modal, ModalCloseButton, ModalService, Month, Number$1 as Number, PDFReport, Password, Progress, Radio, RangeSlider, Report, Row, Search, Select, SelectMultiple, SelectTree, SelectTreeMultiple, SelectableList, SpeedDial, Steppers, SvgMap, Switch, Tab, Table, Tabs, Tag, Text, TextInput, Textarea, Time, Toggleable, Tooltip, Tree, TreeDataStructure, TreeGrid, TreeGridEditable, WatchURL, XLS2Report, XLS3Report, XLSReport, initTheme, uniqueBy };
|