@zeedhi/common 1.109.0 → 1.109.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 +281 -174
- package/dist/zd-common.umd.js +281 -174
- package/package.json +2 -2
- package/types/components/zd-grid/grid-editable.d.ts +1 -0
- package/types/components/zd-iterable/column.d.ts +5 -0
- package/types/components/zd-select-multiple/select-multiple.d.ts +1 -4
- package/types/components/zd-select-tree/interfaces.d.ts +1 -0
- package/types/components/zd-select-tree/select-tree.d.ts +10 -1
- package/types/components/zd-select-tree-multiple/select-tree-multiple.d.ts +35 -4
- package/types/formatters/column-zdselect.d.ts +1 -0
- package/types/formatters/column-zdselectmultiple.d.ts +1 -0
- package/types/formatters/index.d.ts +2 -0
- package/types/index.d.ts +1 -0
package/dist/zd-common.umd.js
CHANGED
|
@@ -5632,6 +5632,18 @@
|
|
|
5632
5632
|
super.onBeforeDestroy();
|
|
5633
5633
|
(_a = this.lookupDatasource) === null || _a === void 0 ? void 0 : _a.destroy();
|
|
5634
5634
|
}
|
|
5635
|
+
/**
|
|
5636
|
+
* Retrieves a row from lookup using its key
|
|
5637
|
+
* @returns the row object when found, null when it is not found or empty
|
|
5638
|
+
*/
|
|
5639
|
+
getLookupRow(value) {
|
|
5640
|
+
const row = this.lookupData[value];
|
|
5641
|
+
if (!row)
|
|
5642
|
+
return null;
|
|
5643
|
+
if (Object.keys(row).length === 0)
|
|
5644
|
+
return null;
|
|
5645
|
+
return row;
|
|
5646
|
+
}
|
|
5635
5647
|
}
|
|
5636
5648
|
|
|
5637
5649
|
/**
|
|
@@ -5931,98 +5943,6 @@
|
|
|
5931
5943
|
}
|
|
5932
5944
|
}
|
|
5933
5945
|
}
|
|
5934
|
-
core.FormatterParserProvider.registerFormatter('column_ZdSelect', ({ column, value, row, componentProps, }) => {
|
|
5935
|
-
if (value === null || value === undefined)
|
|
5936
|
-
return '';
|
|
5937
|
-
const { dataText, formatterDataText, dataTextSeparator, dataValue, dataTextDiscrete, foreignColumns, } = componentProps;
|
|
5938
|
-
let currentRow = row;
|
|
5939
|
-
const dataTextColumns = Array.isArray(dataText) ? dataText : [dataText];
|
|
5940
|
-
if (dataValue) {
|
|
5941
|
-
const columns = Array.isArray(formatterDataText) ? formatterDataText : [formatterDataText];
|
|
5942
|
-
if (foreignColumns) {
|
|
5943
|
-
const loopkupRow = {};
|
|
5944
|
-
dataTextColumns.forEach((item) => {
|
|
5945
|
-
const dataTextName = typeof item === 'string' ? item : item.name;
|
|
5946
|
-
loopkupRow[dataTextName] = currentRow[foreignColumns[dataTextName] || dataTextName];
|
|
5947
|
-
});
|
|
5948
|
-
loopkupRow[dataValue] = currentRow[column.name];
|
|
5949
|
-
column.lookupData[currentRow[column.name]] = loopkupRow;
|
|
5950
|
-
}
|
|
5951
|
-
else if (!formatterDataText) {
|
|
5952
|
-
currentRow = column.getLookupData(dataValue, value[dataValue] || value);
|
|
5953
|
-
}
|
|
5954
|
-
else if (columns.length === dataTextColumns.length) {
|
|
5955
|
-
const loopkupRow = {};
|
|
5956
|
-
columns.forEach((item, index) => {
|
|
5957
|
-
const dataTextValue = dataTextColumns[index];
|
|
5958
|
-
const dataTextName = typeof dataTextValue === 'string' ? dataTextValue : dataTextValue.name;
|
|
5959
|
-
loopkupRow[dataTextName] = currentRow[typeof item === 'string' ? item : item.name];
|
|
5960
|
-
});
|
|
5961
|
-
loopkupRow[dataValue] = currentRow[column.name];
|
|
5962
|
-
column.lookupData[currentRow[column.name]] = loopkupRow;
|
|
5963
|
-
}
|
|
5964
|
-
}
|
|
5965
|
-
if (!Object.keys(currentRow).length)
|
|
5966
|
-
return typeof value === 'object' ? '' : value;
|
|
5967
|
-
let dataTextForeign = dataText;
|
|
5968
|
-
if (dataText && foreignColumns) {
|
|
5969
|
-
if (typeof dataText === 'string') {
|
|
5970
|
-
dataTextForeign = foreignColumns[dataText] || dataText;
|
|
5971
|
-
}
|
|
5972
|
-
else {
|
|
5973
|
-
dataTextForeign = dataTextColumns.map((item) => {
|
|
5974
|
-
const itemName = typeof item === 'string' ? item : item.name;
|
|
5975
|
-
return foreignColumns[itemName] || itemName;
|
|
5976
|
-
});
|
|
5977
|
-
}
|
|
5978
|
-
}
|
|
5979
|
-
const textColumn = dataTextDiscrete || formatterDataText || dataTextForeign;
|
|
5980
|
-
if (!textColumn)
|
|
5981
|
-
return value;
|
|
5982
|
-
if (typeof textColumn === 'string') {
|
|
5983
|
-
return currentRow[textColumn] || value;
|
|
5984
|
-
}
|
|
5985
|
-
const formatterFn = core.FormatterParserProvider.getFormatter('ZdSelect');
|
|
5986
|
-
return formatterFn(currentRow, { dataText: textColumn, dataTextSeparator });
|
|
5987
|
-
});
|
|
5988
|
-
core.FormatterParserProvider.registerFormatter('column_ZdSelectMultiple', ({ column, value, row, componentProps, }) => {
|
|
5989
|
-
if (!value || !Array.isArray(value) || value.length === 0)
|
|
5990
|
-
return '';
|
|
5991
|
-
const { formatterDataText, foreignColumns, dataText } = componentProps;
|
|
5992
|
-
const formatterFn = core.FormatterParserProvider.getFormatter('column_ZdSelect');
|
|
5993
|
-
const result = value.map((item, index) => {
|
|
5994
|
-
let formatterRow = Object.assign({}, row);
|
|
5995
|
-
const rowOverride = {};
|
|
5996
|
-
if (formatterDataText && formatterDataText.length > 0) {
|
|
5997
|
-
const columns = Array.isArray(formatterDataText) ? formatterDataText : [formatterDataText];
|
|
5998
|
-
columns.forEach((col) => {
|
|
5999
|
-
const textName = typeof col === 'string' ? col : col.name;
|
|
6000
|
-
rowOverride[textName] = row[textName][index];
|
|
6001
|
-
});
|
|
6002
|
-
formatterRow = Object.assign(Object.assign({}, row), rowOverride);
|
|
6003
|
-
}
|
|
6004
|
-
else if (foreignColumns && dataText) {
|
|
6005
|
-
let dataTextForeign = dataText;
|
|
6006
|
-
if (typeof dataText === 'string') {
|
|
6007
|
-
dataTextForeign = [foreignColumns[dataText] || dataText];
|
|
6008
|
-
}
|
|
6009
|
-
else {
|
|
6010
|
-
dataTextForeign = dataText.map((col) => {
|
|
6011
|
-
const colName = typeof col === 'string' ? col : col.name;
|
|
6012
|
-
return foreignColumns[colName] || colName;
|
|
6013
|
-
});
|
|
6014
|
-
}
|
|
6015
|
-
dataTextForeign.forEach((col) => {
|
|
6016
|
-
rowOverride[col] = row[col][index];
|
|
6017
|
-
});
|
|
6018
|
-
formatterRow = Object.assign(Object.assign({}, row), rowOverride);
|
|
6019
|
-
}
|
|
6020
|
-
return formatterFn({
|
|
6021
|
-
column, value: item, row: formatterRow, componentProps,
|
|
6022
|
-
});
|
|
6023
|
-
});
|
|
6024
|
-
return result.join(', ');
|
|
6025
|
-
});
|
|
6026
5946
|
const toggleableFormatter = ({ value, componentProps }) => {
|
|
6027
5947
|
const { trueValue, falseValue, trueIcon, falseIcon, trueDisplayValue, falseDisplayValue, } = componentProps;
|
|
6028
5948
|
const trueDefined = isUndefined__default["default"](trueValue) ? true : trueValue;
|
|
@@ -7162,23 +7082,23 @@
|
|
|
7162
7082
|
if (Array.isArray(colValue)) {
|
|
7163
7083
|
colValue.forEach((item) => {
|
|
7164
7084
|
const value = typeof item === 'object' ? item[componentProps.dataValue] : item;
|
|
7165
|
-
|
|
7166
|
-
componentProps.datasource.data.push(column.lookupData[value]);
|
|
7167
|
-
}
|
|
7085
|
+
this.pushLookupRow(column, componentProps, value);
|
|
7168
7086
|
});
|
|
7169
7087
|
return;
|
|
7170
7088
|
}
|
|
7171
7089
|
if (colValue && typeof colValue === 'object'
|
|
7172
7090
|
&& Object.prototype.hasOwnProperty.call(colValue, componentProps.dataValue)) {
|
|
7173
7091
|
const value = colValue[componentProps.dataValue];
|
|
7174
|
-
|
|
7175
|
-
componentProps.datasource.data.push(column.lookupData[value]);
|
|
7176
|
-
}
|
|
7092
|
+
this.pushLookupRow(column, componentProps, value);
|
|
7177
7093
|
return;
|
|
7178
7094
|
}
|
|
7179
|
-
|
|
7180
|
-
|
|
7181
|
-
|
|
7095
|
+
this.pushLookupRow(column, componentProps, colValue);
|
|
7096
|
+
}
|
|
7097
|
+
pushLookupRow(column, componentProps, value) {
|
|
7098
|
+
const lookupRow = column.getLookupRow(value);
|
|
7099
|
+
if (!lookupRow)
|
|
7100
|
+
return;
|
|
7101
|
+
componentProps.datasource.data.push(lookupRow);
|
|
7182
7102
|
}
|
|
7183
7103
|
checkCompValidity(component) {
|
|
7184
7104
|
if (!component.isValid()) {
|
|
@@ -12482,6 +12402,7 @@
|
|
|
12482
12402
|
this.limit = null;
|
|
12483
12403
|
this.showSelectAll = false;
|
|
12484
12404
|
this.showCheckboxAll = false;
|
|
12405
|
+
this.formatterFn = core.FormatterParserProvider.getFormatter('ZdSelectMultiple');
|
|
12485
12406
|
this.checkboxAllValue = false;
|
|
12486
12407
|
if (!this.selectedValue) {
|
|
12487
12408
|
this.selectedValue = [];
|
|
@@ -12698,22 +12619,6 @@
|
|
|
12698
12619
|
});
|
|
12699
12620
|
this.insertsRemoved = [];
|
|
12700
12621
|
}
|
|
12701
|
-
/**
|
|
12702
|
-
* Return formatted dataText and values
|
|
12703
|
-
*/
|
|
12704
|
-
formatter(value) {
|
|
12705
|
-
if (!value || value.length === 0) {
|
|
12706
|
-
return [];
|
|
12707
|
-
}
|
|
12708
|
-
const selectFormatter = core.FormatterParserProvider.getFormatter('ZdSelect');
|
|
12709
|
-
const formattedValue = value.map((row) => {
|
|
12710
|
-
const isDisabled = this.dataDisabled && row[this.dataDisabled];
|
|
12711
|
-
const formattedRow = { value: row[this.dataValue], disabled: isDisabled, originalRow: row };
|
|
12712
|
-
formattedRow.text = selectFormatter(row, this);
|
|
12713
|
-
return formattedRow;
|
|
12714
|
-
});
|
|
12715
|
-
return formattedValue;
|
|
12716
|
-
}
|
|
12717
12622
|
/**
|
|
12718
12623
|
* Returns the text shown when there's one or more selected items that doesn't fit in the input
|
|
12719
12624
|
*/
|
|
@@ -12959,7 +12864,21 @@
|
|
|
12959
12864
|
};
|
|
12960
12865
|
return modalSelectionDef;
|
|
12961
12866
|
}
|
|
12962
|
-
}
|
|
12867
|
+
}
|
|
12868
|
+
core.FormatterParserProvider.registerFormatter('ZdSelectMultiple', (value, props) => {
|
|
12869
|
+
const { dataDisabled, dataValue } = props;
|
|
12870
|
+
if (!value || value.length === 0) {
|
|
12871
|
+
return [];
|
|
12872
|
+
}
|
|
12873
|
+
const selectFormatter = core.FormatterParserProvider.getFormatter('ZdSelect');
|
|
12874
|
+
const formattedValue = value.map((row) => {
|
|
12875
|
+
const isDisabled = dataDisabled && row[dataDisabled];
|
|
12876
|
+
const formattedRow = { value: row[dataValue], disabled: isDisabled, originalRow: row };
|
|
12877
|
+
formattedRow.text = selectFormatter(row, props);
|
|
12878
|
+
return formattedRow;
|
|
12879
|
+
});
|
|
12880
|
+
return formattedValue;
|
|
12881
|
+
});
|
|
12963
12882
|
|
|
12964
12883
|
/**
|
|
12965
12884
|
* Base class for Select Tree component.
|
|
@@ -13050,7 +12969,6 @@
|
|
|
13050
12969
|
* Defines if should wait and not execute GET method when Datasource is created
|
|
13051
12970
|
*/
|
|
13052
12971
|
this.lazyLoad = true;
|
|
13053
|
-
this.selectValue = null;
|
|
13054
12972
|
/**
|
|
13055
12973
|
* Uses delayed loading to load tree branches
|
|
13056
12974
|
*/
|
|
@@ -13071,7 +12989,9 @@
|
|
|
13071
12989
|
* Defines the name of the form target to set using dataValueOut
|
|
13072
12990
|
*/
|
|
13073
12991
|
this.dataValueOutFormName = '';
|
|
12992
|
+
this.formatterFn = core.FormatterParserProvider.getFormatter('ZdSelectTree');
|
|
13074
12993
|
this.savedNodes = undefined;
|
|
12994
|
+
this.search = '';
|
|
13075
12995
|
this.debounceSearch = debounce__default["default"](this.searchChange, 500);
|
|
13076
12996
|
this.nodes = this.getInitValue('nodes', props.nodes, this.nodes);
|
|
13077
12997
|
this.alwaysOpen = this.getInitValue('alwaysOpen', props.alwaysOpen, this.alwaysOpen);
|
|
@@ -13091,7 +13011,6 @@
|
|
|
13091
13011
|
this.dataValue = this.getInitValue('dataValue', props.dataValue, this.dataValue);
|
|
13092
13012
|
this.dataDisabled = this.getInitValue('dataDisabled', props.dataDisabled, this.dataDisabled);
|
|
13093
13013
|
this.disabledItems = this.getInitValue('disabledItems', props.disabledItems, this.disabledItems);
|
|
13094
|
-
this.preventLoadOnFocus = this.getInitValue('preventLoadOnFocus', props.preventLoadOnFocus, this.preventLoadOnFocus);
|
|
13095
13014
|
this.fetchOnDemand = this.getInitValue('fetchOnDemand', props.fetchOnDemand, this.fetchOnDemand);
|
|
13096
13015
|
this.fieldHasChild = this.getInitValue('fieldHasChild', props.fieldHasChild, this.fieldHasChild);
|
|
13097
13016
|
this.menuMaxWidth = this.getInitValue('menuMaxWidth', props.menuMaxWidth, this.menuMaxWidth);
|
|
@@ -13109,8 +13028,21 @@
|
|
|
13109
13028
|
this.datasource = core.DatasourceFactory.factory(Object.assign(Object.assign({}, props.datasource), { searchIn: props.datasource.searchIn || searchFieldNames, lazyLoad: true, loadAll: true }));
|
|
13110
13029
|
this.createDataStructure();
|
|
13111
13030
|
}
|
|
13031
|
+
if (this.dataTextDiscrete && !Array.isArray(this.dataTextDiscrete))
|
|
13032
|
+
this.dataTextDiscrete = [this.dataTextDiscrete];
|
|
13033
|
+
this.discreteProps = {
|
|
13034
|
+
dataText: this.dataTextDiscrete,
|
|
13035
|
+
dataTextSeparator: this.dataTextSeparator,
|
|
13036
|
+
};
|
|
13037
|
+
this.preventLoadOnFocus = !this.datasource || !this.lazyLoad;
|
|
13038
|
+
this.preventLoadOnFocus = this.getInitValue('preventLoadOnFocus', props.preventLoadOnFocus, this.preventLoadOnFocus);
|
|
13039
|
+
this.value = this.getInitValue('value', props.value, this.value);
|
|
13112
13040
|
this.createAccessors();
|
|
13113
13041
|
}
|
|
13042
|
+
/**
|
|
13043
|
+
* Returns the currentRow in the dataText key
|
|
13044
|
+
*/
|
|
13045
|
+
formatter(value, props) { return this.formatterFn(value, props !== null && props !== void 0 ? props : this); }
|
|
13114
13046
|
focus(event, element) {
|
|
13115
13047
|
const _super = Object.create(null, {
|
|
13116
13048
|
focus: { get: () => super.focus }
|
|
@@ -13165,8 +13097,8 @@
|
|
|
13165
13097
|
children = undefined;
|
|
13166
13098
|
}
|
|
13167
13099
|
}
|
|
13168
|
-
const dataText = this.
|
|
13169
|
-
const dataTextDiscrete = this.
|
|
13100
|
+
const dataText = this.formatter(row);
|
|
13101
|
+
const dataTextDiscrete = this.formatter(row, this.discreteProps);
|
|
13170
13102
|
return {
|
|
13171
13103
|
id: row[this.dataValue],
|
|
13172
13104
|
label: dataText,
|
|
@@ -13186,40 +13118,6 @@
|
|
|
13186
13118
|
});
|
|
13187
13119
|
return newNodes;
|
|
13188
13120
|
}
|
|
13189
|
-
formatRow(dataText, row) {
|
|
13190
|
-
const dataTextArr = Array.isArray(dataText) ? dataText : [dataText];
|
|
13191
|
-
const dataTextNames = [];
|
|
13192
|
-
const masks = [];
|
|
13193
|
-
dataTextArr.forEach((text) => {
|
|
13194
|
-
if (typeof text === 'string') {
|
|
13195
|
-
dataTextNames.push(text);
|
|
13196
|
-
masks.push('');
|
|
13197
|
-
}
|
|
13198
|
-
else {
|
|
13199
|
-
dataTextNames.push(text.name);
|
|
13200
|
-
if (core.Accessor.isAccessorDefinition(text.mask)) {
|
|
13201
|
-
const [controller, accessor] = core.Accessor.getAccessor(text.mask);
|
|
13202
|
-
masks.push(core.Loader.getInstance(controller)[accessor]);
|
|
13203
|
-
}
|
|
13204
|
-
else {
|
|
13205
|
-
masks.push(text.mask);
|
|
13206
|
-
}
|
|
13207
|
-
}
|
|
13208
|
-
});
|
|
13209
|
-
const rowText = dataTextNames.reduce((result, column, index) => {
|
|
13210
|
-
if (row[column]) {
|
|
13211
|
-
const separator = index > 0 ? this.dataTextSeparator : '';
|
|
13212
|
-
let masked = row[column];
|
|
13213
|
-
if (masks[index]) {
|
|
13214
|
-
const maskValue = typeof masks[index] === 'function' ? masks[index](row[column]) : masks[index];
|
|
13215
|
-
masked = core.Mask.getValueWithMask(row[column], maskValue);
|
|
13216
|
-
}
|
|
13217
|
-
return result + separator + masked;
|
|
13218
|
-
}
|
|
13219
|
-
return result;
|
|
13220
|
-
}, '');
|
|
13221
|
-
return rowText;
|
|
13222
|
-
}
|
|
13223
13121
|
/**
|
|
13224
13122
|
* Triggered when the menu opens
|
|
13225
13123
|
*/
|
|
@@ -13243,6 +13141,7 @@
|
|
|
13243
13141
|
* Triggered after the search query changes
|
|
13244
13142
|
*/
|
|
13245
13143
|
searchChange(searchQuery, element) {
|
|
13144
|
+
this.search = searchQuery;
|
|
13246
13145
|
if (this.fetchOnDemand) {
|
|
13247
13146
|
if (!searchQuery && this.savedNodes) {
|
|
13248
13147
|
this.nodes = this.savedNodes;
|
|
@@ -13330,7 +13229,7 @@
|
|
|
13330
13229
|
if (!this.selectValue)
|
|
13331
13230
|
return this.selectValue;
|
|
13332
13231
|
if (this.returnObject) {
|
|
13333
|
-
return this.clearRow(this.selectValue.row);
|
|
13232
|
+
return this.clearRow(this.selectValue.row || this.selectValue);
|
|
13334
13233
|
}
|
|
13335
13234
|
return this.selectValue;
|
|
13336
13235
|
}
|
|
@@ -13377,6 +13276,8 @@
|
|
|
13377
13276
|
}
|
|
13378
13277
|
}
|
|
13379
13278
|
}
|
|
13279
|
+
const selectFormatterFn$1 = core.FormatterParserProvider.getFormatter('ZdSelect');
|
|
13280
|
+
core.FormatterParserProvider.registerFormatter('ZdSelectTree', selectFormatterFn$1);
|
|
13380
13281
|
InputFactory.register('ZdSelectTree', SelectTree);
|
|
13381
13282
|
|
|
13382
13283
|
/**
|
|
@@ -13401,7 +13302,6 @@
|
|
|
13401
13302
|
* Selected Nodes
|
|
13402
13303
|
*/
|
|
13403
13304
|
this.selectedNodes = [];
|
|
13404
|
-
this.selectValue = [];
|
|
13405
13305
|
/**
|
|
13406
13306
|
* Changes the behavior of checked nodes that will be displayed in the array of values
|
|
13407
13307
|
*/
|
|
@@ -13429,19 +13329,25 @@
|
|
|
13429
13329
|
this.callEvent('onDeselect', { element, component: this, node });
|
|
13430
13330
|
}
|
|
13431
13331
|
get value() {
|
|
13332
|
+
if (!this.selectValue)
|
|
13333
|
+
return [];
|
|
13432
13334
|
if (this.returnObject) {
|
|
13433
|
-
return this.selectValue.map((value) => this.clearRow(value.row));
|
|
13335
|
+
return this.selectValue.map((value) => this.clearRow(value.row || value));
|
|
13434
13336
|
}
|
|
13435
13337
|
return this.selectValue;
|
|
13436
13338
|
}
|
|
13437
13339
|
set value(value) {
|
|
13438
|
-
this.
|
|
13340
|
+
this.setValue(value);
|
|
13439
13341
|
}
|
|
13440
13342
|
setValue(value) {
|
|
13343
|
+
if (!value) {
|
|
13344
|
+
this.selectValue = [];
|
|
13345
|
+
return;
|
|
13346
|
+
}
|
|
13441
13347
|
const arrValue = Array.isArray(value) ? value : [value];
|
|
13442
13348
|
const key = this.datasource ? this.dataValue : 'id';
|
|
13443
13349
|
if (!this.returnObject) {
|
|
13444
|
-
this.
|
|
13350
|
+
this.selectValue = arrValue.map((item) => {
|
|
13445
13351
|
if (typeof item === 'object') {
|
|
13446
13352
|
return item[key];
|
|
13447
13353
|
}
|
|
@@ -13449,19 +13355,27 @@
|
|
|
13449
13355
|
});
|
|
13450
13356
|
return;
|
|
13451
13357
|
}
|
|
13452
|
-
this.
|
|
13358
|
+
this.selectValue = arrValue.map((item) => {
|
|
13453
13359
|
if (typeof item !== 'object') {
|
|
13454
13360
|
return { id: item };
|
|
13455
13361
|
}
|
|
13456
13362
|
return { id: item[key] };
|
|
13457
13363
|
});
|
|
13458
13364
|
}
|
|
13459
|
-
|
|
13460
|
-
|
|
13365
|
+
/**
|
|
13366
|
+
* Retrieves all nodes in the tree as a flat array. Nodes that are not matched are excluded
|
|
13367
|
+
* Nodes that are not matched but whose parent is matched are included
|
|
13368
|
+
* @param nodes
|
|
13369
|
+
* @param matched defines whether the parent of the current node branch is matched
|
|
13370
|
+
* @returns all nodes in the tree as a flat array, filtering unmatched nodes
|
|
13371
|
+
*/
|
|
13372
|
+
getAllNodes(nodes = this.nodes, matched = true) {
|
|
13373
|
+
let result = [...nodes];
|
|
13374
|
+
result = result.filter((node) => node.isMatched || matched);
|
|
13461
13375
|
nodes.forEach((node) => {
|
|
13462
13376
|
if (!node.children)
|
|
13463
13377
|
return;
|
|
13464
|
-
const childNodes = this.getAllNodes(node.children);
|
|
13378
|
+
const childNodes = this.getAllNodes(node.children, node.isMatched || matched);
|
|
13465
13379
|
result = [...result, ...childNodes];
|
|
13466
13380
|
});
|
|
13467
13381
|
return result;
|
|
@@ -13469,28 +13383,96 @@
|
|
|
13469
13383
|
/**
|
|
13470
13384
|
* Dispatches select/unselect event
|
|
13471
13385
|
*/
|
|
13472
|
-
onSelectAll(isSelected, event, element) {
|
|
13386
|
+
onSelectAll(isSelected, event, element, nodes = this.nodes) {
|
|
13473
13387
|
if (isSelected) {
|
|
13474
13388
|
this.callEvent('selectedAll', { event, element, component: this });
|
|
13475
13389
|
if (!event.defaultPrevented) {
|
|
13476
|
-
this.selectAllItems();
|
|
13390
|
+
this.selectAllItems(nodes);
|
|
13477
13391
|
}
|
|
13478
13392
|
}
|
|
13479
13393
|
else {
|
|
13480
13394
|
this.callEvent('unselectedAll', { event, element, component: this });
|
|
13481
13395
|
if (!event.defaultPrevented) {
|
|
13482
|
-
this.unSelectAllItems();
|
|
13396
|
+
this.unSelectAllItems(nodes);
|
|
13483
13397
|
}
|
|
13484
13398
|
}
|
|
13485
13399
|
}
|
|
13486
|
-
|
|
13487
|
-
|
|
13488
|
-
|
|
13400
|
+
/**
|
|
13401
|
+
* Selects all items in the tree \
|
|
13402
|
+
* If the component is fetchOnDemand, it will select all values from datasource.data \
|
|
13403
|
+
* If not, it will select all nodes from the tree, unless the nodes to be selected are specified
|
|
13404
|
+
* @param nodes nodes to be selected. These are the nodes that are currently visible in the tree
|
|
13405
|
+
* (if the user is searching, selects only the searched nodes)
|
|
13406
|
+
* @returns
|
|
13407
|
+
*/
|
|
13408
|
+
selectAllItems(nodes = this.nodes) {
|
|
13409
|
+
var _a;
|
|
13410
|
+
if (((_a = this.datasource) === null || _a === void 0 ? void 0 : _a.data) && this.fetchOnDemand) {
|
|
13411
|
+
this.setValue(this.datasource.data);
|
|
13412
|
+
return;
|
|
13413
|
+
}
|
|
13414
|
+
const allNodes = this.getAllNodes(nodes, !this.search);
|
|
13415
|
+
// merge all nodes with the current value before setting it
|
|
13416
|
+
const currentValue = this.getValueAsObject();
|
|
13417
|
+
const nodeMap = this.createMergeMap(currentValue, allNodes);
|
|
13418
|
+
const uniqueArray = Array.from(nodeMap.values());
|
|
13419
|
+
this.setValue(uniqueArray);
|
|
13489
13420
|
}
|
|
13490
|
-
|
|
13491
|
-
|
|
13421
|
+
/**
|
|
13422
|
+
* Unelects all items in the tree \
|
|
13423
|
+
* If the component is fetchOnDemand, it will select all values from datasource.data \
|
|
13424
|
+
* If not, it will select all nodes from the tree, unless the nodes to be selected are specified
|
|
13425
|
+
* @param nodes nodes to be selected. These are the nodes that are currently visible in the tree
|
|
13426
|
+
* (if the user is searching, selects only the searched nodes)
|
|
13427
|
+
* @returns
|
|
13428
|
+
*/
|
|
13429
|
+
unSelectAllItems(nodes = this.nodes) {
|
|
13430
|
+
var _a;
|
|
13431
|
+
if (((_a = this.datasource) === null || _a === void 0 ? void 0 : _a.data) && this.fetchOnDemand) {
|
|
13432
|
+
this.setValue([]);
|
|
13433
|
+
return;
|
|
13434
|
+
}
|
|
13435
|
+
const allNodes = this.getAllNodes(nodes, !this.search);
|
|
13436
|
+
// merge all nodes with the current value before setting it
|
|
13437
|
+
const currentValue = this.getValueAsObject();
|
|
13438
|
+
const nodeMap = this.createMergeMap(currentValue);
|
|
13439
|
+
// remove the current visible nodes from the array
|
|
13440
|
+
const valuesToRemove = allNodes.map((node) => node.id);
|
|
13441
|
+
valuesToRemove.forEach((value) => {
|
|
13442
|
+
nodeMap.delete(value);
|
|
13443
|
+
});
|
|
13444
|
+
const uniqueArray = Array.from(nodeMap.values());
|
|
13445
|
+
this.setValue(uniqueArray);
|
|
13492
13446
|
}
|
|
13493
|
-
|
|
13447
|
+
/**
|
|
13448
|
+
* Takes two arrays and creates a map of the unique values
|
|
13449
|
+
* @returns map of a merge between the two arrays, removing duplicates
|
|
13450
|
+
*/
|
|
13451
|
+
createMergeMap(arr1, arr2 = []) {
|
|
13452
|
+
const mergedNodes = arr1.concat(arr2);
|
|
13453
|
+
// filter out duplicate nodes
|
|
13454
|
+
const uniqueMap = new Map();
|
|
13455
|
+
mergedNodes.forEach((node) => {
|
|
13456
|
+
uniqueMap.set(node.id, node);
|
|
13457
|
+
});
|
|
13458
|
+
return uniqueMap;
|
|
13459
|
+
}
|
|
13460
|
+
getValueIds() {
|
|
13461
|
+
if (this.returnObject) {
|
|
13462
|
+
return this.value.map((item) => item.id);
|
|
13463
|
+
}
|
|
13464
|
+
return this.value;
|
|
13465
|
+
}
|
|
13466
|
+
getValueAsObject() {
|
|
13467
|
+
return this.value.map((row) => {
|
|
13468
|
+
if (this.returnObject)
|
|
13469
|
+
return row;
|
|
13470
|
+
return { id: row };
|
|
13471
|
+
});
|
|
13472
|
+
}
|
|
13473
|
+
}
|
|
13474
|
+
const selectFormatterFn = core.FormatterParserProvider.getFormatter('ZdSelectMultiple');
|
|
13475
|
+
core.FormatterParserProvider.registerFormatter('ZdSelectTreeMultiple', selectFormatterFn);
|
|
13494
13476
|
|
|
13495
13477
|
/**
|
|
13496
13478
|
* Base class for SelectableList component.
|
|
@@ -15867,6 +15849,131 @@
|
|
|
15867
15849
|
}
|
|
15868
15850
|
}
|
|
15869
15851
|
|
|
15852
|
+
const asArray = (value) => (Array.isArray(value) ? value : [value]);
|
|
15853
|
+
const getForeignLookupRow = (column, row, dataValue, dataTextColumns, foreignColumns) => {
|
|
15854
|
+
const lookupRow = {};
|
|
15855
|
+
dataTextColumns.forEach((item) => {
|
|
15856
|
+
const dataTextName = typeof item === 'string' ? item : item.name;
|
|
15857
|
+
lookupRow[dataTextName] = row[foreignColumns[dataTextName] || dataTextName];
|
|
15858
|
+
});
|
|
15859
|
+
lookupRow[dataValue] = row[column.name];
|
|
15860
|
+
return lookupRow;
|
|
15861
|
+
};
|
|
15862
|
+
const getFormatterLookupRow = (column, row, dataValue, formatterDataTextColumns, dataTextColumns) => {
|
|
15863
|
+
const lookupRow = {};
|
|
15864
|
+
formatterDataTextColumns.forEach((item, index) => {
|
|
15865
|
+
const dataTextValue = dataTextColumns[index];
|
|
15866
|
+
const dataTextName = typeof dataTextValue === 'string' ? dataTextValue : dataTextValue.name;
|
|
15867
|
+
const formatterDataTextColumn = typeof item === 'string' ? item : item.name;
|
|
15868
|
+
lookupRow[dataTextName] = row[formatterDataTextColumn];
|
|
15869
|
+
});
|
|
15870
|
+
lookupRow[dataValue] = row[column.name];
|
|
15871
|
+
return lookupRow;
|
|
15872
|
+
};
|
|
15873
|
+
/**
|
|
15874
|
+
* Stores data in column.lookupData when using foreignColumns or formatterDataText.
|
|
15875
|
+
* Makes a lookup when not using foreignColumns or formatterDataText
|
|
15876
|
+
* @returns the row from grid's datasource when using foreignColumns or formatterDataText. Otherwise,
|
|
15877
|
+
* returns the row from the column's component datasource
|
|
15878
|
+
*/
|
|
15879
|
+
const storeOrRetrieveLookup = (column, row, value, dataValue, componentProps) => {
|
|
15880
|
+
const { dataText, foreignColumns, formatterDataText, } = componentProps;
|
|
15881
|
+
const dataTextColumns = asArray(dataText);
|
|
15882
|
+
// when using foreignColumns, should store foreign keys information in lookupData
|
|
15883
|
+
if (foreignColumns) {
|
|
15884
|
+
column.lookupData[row[column.name]] = getForeignLookupRow(column, row, dataValue, dataTextColumns, foreignColumns);
|
|
15885
|
+
return row;
|
|
15886
|
+
}
|
|
15887
|
+
// when not using formatterDataText, should fetch data from datasource to be able to format this cell
|
|
15888
|
+
if (!formatterDataText) {
|
|
15889
|
+
return column.getLookupData(dataValue, value[dataValue] || value);
|
|
15890
|
+
}
|
|
15891
|
+
const formatterDataTextColumns = asArray(formatterDataText);
|
|
15892
|
+
// when using formatterDataText, should store dataText information in lookupData
|
|
15893
|
+
if (formatterDataTextColumns.length === dataTextColumns.length) {
|
|
15894
|
+
const rowColumn = row[column.name];
|
|
15895
|
+
column.lookupData[rowColumn] = getFormatterLookupRow(column, row, dataValue, formatterDataTextColumns, dataTextColumns);
|
|
15896
|
+
return row;
|
|
15897
|
+
}
|
|
15898
|
+
return row;
|
|
15899
|
+
};
|
|
15900
|
+
const formatter$1 = ({ column, value, row, componentProps, }) => {
|
|
15901
|
+
if (value === null || value === undefined)
|
|
15902
|
+
return '';
|
|
15903
|
+
const { dataText, formatterDataText, dataTextSeparator, dataValue, dataTextDiscrete, foreignColumns, } = componentProps;
|
|
15904
|
+
let currentRow = row;
|
|
15905
|
+
const dataTextColumns = asArray(dataText);
|
|
15906
|
+
// when dataValue is defined, should try to store or retrieve row data from lookupData
|
|
15907
|
+
if (dataValue) {
|
|
15908
|
+
currentRow = storeOrRetrieveLookup(column, row, value, dataValue, componentProps);
|
|
15909
|
+
}
|
|
15910
|
+
if (!Object.keys(currentRow).length)
|
|
15911
|
+
return typeof value === 'object' ? '' : value;
|
|
15912
|
+
let dataTextForeign = dataText;
|
|
15913
|
+
if (dataText && foreignColumns) {
|
|
15914
|
+
if (typeof dataText === 'string') {
|
|
15915
|
+
dataTextForeign = foreignColumns[dataText] || dataText;
|
|
15916
|
+
}
|
|
15917
|
+
else {
|
|
15918
|
+
dataTextForeign = dataTextColumns.map((item) => {
|
|
15919
|
+
const itemName = typeof item === 'string' ? item : item.name;
|
|
15920
|
+
return foreignColumns[itemName] || itemName;
|
|
15921
|
+
});
|
|
15922
|
+
}
|
|
15923
|
+
}
|
|
15924
|
+
const textColumn = dataTextDiscrete || formatterDataText || dataTextForeign;
|
|
15925
|
+
if (!textColumn)
|
|
15926
|
+
return value;
|
|
15927
|
+
if (typeof textColumn === 'string') {
|
|
15928
|
+
return currentRow[textColumn] || value;
|
|
15929
|
+
}
|
|
15930
|
+
const formatterFn = core.FormatterParserProvider.getFormatter('ZdSelect');
|
|
15931
|
+
return formatterFn(currentRow, { dataText: textColumn, dataTextSeparator });
|
|
15932
|
+
};
|
|
15933
|
+
core.FormatterParserProvider.registerFormatter('column_ZdSelect', formatter$1);
|
|
15934
|
+
core.FormatterParserProvider.registerFormatter('column_ZdSelectTree', formatter$1);
|
|
15935
|
+
|
|
15936
|
+
const formatter = ({ column, value, row, componentProps, }) => {
|
|
15937
|
+
if (!value || !Array.isArray(value) || value.length === 0)
|
|
15938
|
+
return '';
|
|
15939
|
+
const { formatterDataText, foreignColumns, dataText } = componentProps;
|
|
15940
|
+
const formatterFn = core.FormatterParserProvider.getFormatter('column_ZdSelect');
|
|
15941
|
+
const result = value.map((item, index) => {
|
|
15942
|
+
let formatterRow = Object.assign({}, row);
|
|
15943
|
+
const rowOverride = {};
|
|
15944
|
+
if (formatterDataText && formatterDataText.length > 0) {
|
|
15945
|
+
const columns = Array.isArray(formatterDataText) ? formatterDataText : [formatterDataText];
|
|
15946
|
+
columns.forEach((col) => {
|
|
15947
|
+
const textName = typeof col === 'string' ? col : col.name;
|
|
15948
|
+
rowOverride[textName] = row[textName][index];
|
|
15949
|
+
});
|
|
15950
|
+
formatterRow = Object.assign(Object.assign({}, row), rowOverride);
|
|
15951
|
+
}
|
|
15952
|
+
else if (foreignColumns && dataText) {
|
|
15953
|
+
let dataTextForeign = dataText;
|
|
15954
|
+
if (typeof dataText === 'string') {
|
|
15955
|
+
dataTextForeign = [foreignColumns[dataText] || dataText];
|
|
15956
|
+
}
|
|
15957
|
+
else {
|
|
15958
|
+
dataTextForeign = dataText.map((col) => {
|
|
15959
|
+
const colName = typeof col === 'string' ? col : col.name;
|
|
15960
|
+
return foreignColumns[colName] || colName;
|
|
15961
|
+
});
|
|
15962
|
+
}
|
|
15963
|
+
dataTextForeign.forEach((col) => {
|
|
15964
|
+
rowOverride[col] = row[col][index];
|
|
15965
|
+
});
|
|
15966
|
+
formatterRow = Object.assign(Object.assign({}, row), rowOverride);
|
|
15967
|
+
}
|
|
15968
|
+
return formatterFn({
|
|
15969
|
+
column, value: item, row: formatterRow, componentProps,
|
|
15970
|
+
});
|
|
15971
|
+
});
|
|
15972
|
+
return result.join(', ');
|
|
15973
|
+
};
|
|
15974
|
+
core.FormatterParserProvider.registerFormatter('column_ZdSelectMultiple', formatter);
|
|
15975
|
+
core.FormatterParserProvider.registerFormatter('column_ZdSelectTreeMultiple', formatter);
|
|
15976
|
+
|
|
15870
15977
|
const AutoNumeric = require('@zeedhi/autonumeric/dist/autoNumeric');
|
|
15871
15978
|
const packageContent = require('../package.json');
|
|
15872
15979
|
core.VersionService.addPackageVersion(packageContent.name, packageContent.version);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zeedhi/common",
|
|
3
|
-
"version": "1.109.
|
|
3
|
+
"version": "1.109.1",
|
|
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": "
|
|
46
|
+
"gitHead": "7260f4ea8769c7f86c4f6c3e379e141f6ac401c0"
|
|
47
47
|
}
|
|
@@ -140,6 +140,7 @@ export declare class GridEditable extends Grid implements IGridEditable {
|
|
|
140
140
|
* If the row[column.name] has a selected value, pushes it
|
|
141
141
|
*/
|
|
142
142
|
private checkLookupData;
|
|
143
|
+
private pushLookupRow;
|
|
143
144
|
private checkCompValidity;
|
|
144
145
|
/**
|
|
145
146
|
* change event of editable components
|
|
@@ -89,4 +89,9 @@ export declare class Column extends Component implements IColumn {
|
|
|
89
89
|
*/
|
|
90
90
|
applyActionCondition(row: IDictionary<any>): IDictionary<IDictionary<any>>;
|
|
91
91
|
onBeforeDestroy(): void;
|
|
92
|
+
/**
|
|
93
|
+
* Retrieves a row from lookup using its key
|
|
94
|
+
* @returns the row object when found, null when it is not found or empty
|
|
95
|
+
*/
|
|
96
|
+
getLookupRow(value: any): IDictionary | null;
|
|
92
97
|
}
|