@zeedhi/common 1.112.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 +351 -156
- package/dist/zd-common.umd.js +352 -155
- package/package.json +2 -2
- package/types/components/zd-grid/grid-editable.d.ts +12 -0
- package/types/components/zd-input/input.d.ts +3 -1
- 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/formatters/column-zdtextinput.d.ts +1 -0
- package/types/formatters/index.d.ts +1 -0
- 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/report/report-type/base-report.d.ts +6 -2
- package/types/utils/report/report-type/csv-report.d.ts +2 -1
- package/types/utils/report/report-type/interfaces.d.ts +6 -2
- package/types/utils/report/report-type/pdf-report.d.ts +3 -1
- package/types/utils/report/report-type/xls-report.d.ts +2 -1
- package/types/utils/report/report-type/xls2-report.d.ts +2 -2
- package/types/utils/report/report-type/xls3-report.d.ts +2 -2
- package/types/utils/report/report.d.ts +0 -1
- 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);
|
|
@@ -2831,7 +2833,7 @@ class TextInput extends Input {
|
|
|
2831
2833
|
return mask;
|
|
2832
2834
|
}
|
|
2833
2835
|
}
|
|
2834
|
-
FormatterParserProvider.registerFormatter('ZdTextInput', (value, { valueWithPrefix = textInputDefaults.valueWithPrefix, prefix = textInputDefaults.prefix, valueWithSuffix = textInputDefaults.valueWithSuffix, suffix = textInputDefaults.suffix, mask = textInputDefaults.mask, } = {}) => {
|
|
2836
|
+
FormatterParserProvider.registerFormatter('ZdTextInput', (value, { valueWithPrefix = textInputDefaults.valueWithPrefix, prefix = textInputDefaults.prefix, valueWithSuffix = textInputDefaults.valueWithSuffix, suffix = textInputDefaults.suffix, mask = textInputDefaults.mask, eagerMask, } = {}) => {
|
|
2835
2837
|
let formatted = value;
|
|
2836
2838
|
if (formatted) {
|
|
2837
2839
|
formatted = valueWithPrefix ? formatted.substring(prefix.length) : formatted;
|
|
@@ -2842,7 +2844,10 @@ FormatterParserProvider.registerFormatter('ZdTextInput', (value, { valueWithPref
|
|
|
2842
2844
|
maskDef = Loader.getInstance(controller)[accessor];
|
|
2843
2845
|
}
|
|
2844
2846
|
const maskValue = typeof (maskDef) === 'function' ? maskDef(Mask.getValueWithoutMask(formatted)) : maskDef;
|
|
2845
|
-
|
|
2847
|
+
if (maskValue) {
|
|
2848
|
+
const valueWithoutMask = Mask.getValueWithoutMask(formatted);
|
|
2849
|
+
formatted = Mask.getValueWithMask(valueWithoutMask, maskValue, false, eagerMask);
|
|
2850
|
+
}
|
|
2846
2851
|
}
|
|
2847
2852
|
return formatted;
|
|
2848
2853
|
});
|
|
@@ -3138,8 +3143,10 @@ class AlertService {
|
|
|
3138
3143
|
* Hides alert by index. Default index is 0
|
|
3139
3144
|
*/
|
|
3140
3145
|
static hide(index = 0) {
|
|
3141
|
-
this.alertsManager.visibleInstances[index]
|
|
3142
|
-
|
|
3146
|
+
if (this.alertsManager.visibleInstances[index]) {
|
|
3147
|
+
this.alertsManager.visibleInstances[index].hide();
|
|
3148
|
+
this.remove(index);
|
|
3149
|
+
}
|
|
3143
3150
|
}
|
|
3144
3151
|
/**
|
|
3145
3152
|
* Hides alert by alert id (returned by the `show` method)
|
|
@@ -5853,7 +5860,24 @@ class Iterable extends ComponentRender {
|
|
|
5853
5860
|
&& (!this.searchVisibleOnly || column.isVisible)
|
|
5854
5861
|
&& (this.searchIn === undefined || this.searchIn === column.name);
|
|
5855
5862
|
}
|
|
5856
|
-
}
|
|
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
|
+
});
|
|
5857
5881
|
|
|
5858
5882
|
/**
|
|
5859
5883
|
* Delete rows error
|
|
@@ -7052,6 +7076,9 @@ class GridEditable extends Grid {
|
|
|
7052
7076
|
});
|
|
7053
7077
|
}
|
|
7054
7078
|
}
|
|
7079
|
+
/**
|
|
7080
|
+
* Retrieves the visible value of a cell, which is the corresponding cell in edited row or in the default row
|
|
7081
|
+
*/
|
|
7055
7082
|
getVisibleValue(row, column) {
|
|
7056
7083
|
const key = row[this.datasource.uniqueKey];
|
|
7057
7084
|
if (this.editedRows[key] && Object.prototype.hasOwnProperty.call(this.editedRows[key], column.valueIn)) {
|
|
@@ -7059,6 +7086,18 @@ class GridEditable extends Grid {
|
|
|
7059
7086
|
}
|
|
7060
7087
|
return row[column.valueIn];
|
|
7061
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
|
+
}
|
|
7062
7101
|
/**
|
|
7063
7102
|
* Returns editable component properties based on the column definition
|
|
7064
7103
|
* @param column Column definition
|
|
@@ -7154,6 +7193,15 @@ class GridEditable extends Grid {
|
|
|
7154
7193
|
delete this.invalidComponents[component.name];
|
|
7155
7194
|
}
|
|
7156
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
|
+
}
|
|
7157
7205
|
/**
|
|
7158
7206
|
* change event of editable components
|
|
7159
7207
|
*/
|
|
@@ -7265,6 +7313,7 @@ class GridEditable extends Grid {
|
|
|
7265
7313
|
delete cloneAddedRows[key];
|
|
7266
7314
|
this.editedRows = cloneEditedRows;
|
|
7267
7315
|
this.addedRows = cloneAddedRows;
|
|
7316
|
+
this.clearInvalidComponentsForRow(key);
|
|
7268
7317
|
const { data, uniqueKey } = this.datasource;
|
|
7269
7318
|
const index = data.findIndex((row) => row[uniqueKey] === key);
|
|
7270
7319
|
data.splice(index, 1);
|
|
@@ -7278,6 +7327,8 @@ class GridEditable extends Grid {
|
|
|
7278
7327
|
for (let index = allData.length - 1; index >= 0; index -= 1) {
|
|
7279
7328
|
const row = allData[index];
|
|
7280
7329
|
if (this.addedRows[row[this.datasource.uniqueKey]]) {
|
|
7330
|
+
const key = row[this.datasource.uniqueKey];
|
|
7331
|
+
this.clearInvalidComponentsForRow(key);
|
|
7281
7332
|
allData.splice(index, 1);
|
|
7282
7333
|
}
|
|
7283
7334
|
}
|
|
@@ -7298,13 +7349,17 @@ class GridEditable extends Grid {
|
|
|
7298
7349
|
saveEditedRows(revalidate = false) {
|
|
7299
7350
|
return __awaiter(this, void 0, void 0, function* () {
|
|
7300
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
|
|
7301
7357
|
yield this.cancelAddedRows();
|
|
7302
|
-
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)));
|
|
7303
7359
|
this.editing = false;
|
|
7304
7360
|
this.editedRows = {};
|
|
7305
7361
|
this.addedRows = {};
|
|
7306
7362
|
this.invalidComponents = {};
|
|
7307
|
-
this.addedRows = {};
|
|
7308
7363
|
yield this.datasource.setPage(page);
|
|
7309
7364
|
return response;
|
|
7310
7365
|
});
|
|
@@ -7555,6 +7610,8 @@ class GridEditable extends Grid {
|
|
|
7555
7610
|
const rows = Object.assign({}, this.editedRows);
|
|
7556
7611
|
delete rows[foundRow[uniqueKey]];
|
|
7557
7612
|
this.editedRows = rows;
|
|
7613
|
+
const key = foundRow[uniqueKey];
|
|
7614
|
+
this.clearInvalidComponentsForRow(key);
|
|
7558
7615
|
}
|
|
7559
7616
|
/**
|
|
7560
7617
|
* Makes the cell enter edit mode
|
|
@@ -8527,18 +8584,26 @@ class BaseReport {
|
|
|
8527
8584
|
SUM: 'SUM',
|
|
8528
8585
|
};
|
|
8529
8586
|
this.colunmXLS = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ';
|
|
8587
|
+
this.labelFormatter = labelFormatter;
|
|
8530
8588
|
this.reportColumnTransformer = this.getReportColumnTransformer(labelFormatter);
|
|
8531
8589
|
}
|
|
8532
8590
|
getReportColumnTransformer(labelFormatter) {
|
|
8533
8591
|
return new ReportColumnTransformer({ labelFormatter, fileType: this.getFileType() });
|
|
8534
8592
|
}
|
|
8593
|
+
getColumnLabel(key, column) {
|
|
8594
|
+
if (!column)
|
|
8595
|
+
return key;
|
|
8596
|
+
if (!this.labelFormatter)
|
|
8597
|
+
return column.label || key;
|
|
8598
|
+
return this.labelFormatter({ column, fileType: this.getFileType() });
|
|
8599
|
+
}
|
|
8535
8600
|
buildFilter(filter, columns) {
|
|
8536
8601
|
return Object.keys(filter).map((key) => {
|
|
8537
|
-
|
|
8538
|
-
return
|
|
8539
|
-
label:
|
|
8602
|
+
const column = columns.find((col) => col.name === key);
|
|
8603
|
+
return {
|
|
8604
|
+
label: this.getColumnLabel(key, column),
|
|
8540
8605
|
value: I18n.translate('IS_EQUAL', { value: filter[key] }),
|
|
8541
|
-
}
|
|
8606
|
+
};
|
|
8542
8607
|
});
|
|
8543
8608
|
}
|
|
8544
8609
|
formatLangCode(lang) {
|
|
@@ -8547,6 +8612,12 @@ class BaseReport {
|
|
|
8547
8612
|
}
|
|
8548
8613
|
return lang.toLowerCase().replace('-', '_');
|
|
8549
8614
|
}
|
|
8615
|
+
filterColumns(columns) {
|
|
8616
|
+
return columns.filter((item) => (item.type !== 'action' && item.isVisible !== false));
|
|
8617
|
+
}
|
|
8618
|
+
buildCols(columns) {
|
|
8619
|
+
return this.reportColumnTransformer.transform(this.filterColumns(columns));
|
|
8620
|
+
}
|
|
8550
8621
|
}
|
|
8551
8622
|
|
|
8552
8623
|
class CSVReport extends BaseReport {
|
|
@@ -8557,8 +8628,9 @@ class CSVReport extends BaseReport {
|
|
|
8557
8628
|
getFileType() {
|
|
8558
8629
|
return 'csv';
|
|
8559
8630
|
}
|
|
8560
|
-
buildDataset(data, columns) {
|
|
8561
|
-
const
|
|
8631
|
+
buildDataset({ data, columns }) {
|
|
8632
|
+
const filteredColumns = this.filterColumns(columns);
|
|
8633
|
+
const columnNames = filteredColumns.map((col) => col.name);
|
|
8562
8634
|
const result = data.reduce((reduced, row) => {
|
|
8563
8635
|
const values = columnNames.map((col) => row[col] || '');
|
|
8564
8636
|
return [...reduced, values];
|
|
@@ -8566,7 +8638,7 @@ class CSVReport extends BaseReport {
|
|
|
8566
8638
|
return JSON.stringify(result);
|
|
8567
8639
|
}
|
|
8568
8640
|
buildMetadata(name, title, columns, filter) {
|
|
8569
|
-
const builtCols = this.
|
|
8641
|
+
const builtCols = this.buildCols(columns);
|
|
8570
8642
|
const builtFilters = this.buildFilter(filter || {}, columns);
|
|
8571
8643
|
const lang = this.formatLangCode(I18n.instance.language);
|
|
8572
8644
|
const clientLogo = '';
|
|
@@ -8610,7 +8682,7 @@ class PDFReport extends BaseReport {
|
|
|
8610
8682
|
const fileType = this.getFileType();
|
|
8611
8683
|
return new ReportColumnTransformer({ getFormatFn, labelFormatter, fileType });
|
|
8612
8684
|
}
|
|
8613
|
-
buildDataset(data) {
|
|
8685
|
+
buildDataset({ data }) {
|
|
8614
8686
|
return JSON.stringify(data);
|
|
8615
8687
|
}
|
|
8616
8688
|
getFormatOfColumn(column) {
|
|
@@ -8660,7 +8732,7 @@ class PDFReport extends BaseReport {
|
|
|
8660
8732
|
}
|
|
8661
8733
|
buildMetadata(name, title, columns, filter, portrait = true) {
|
|
8662
8734
|
return __awaiter(this, void 0, void 0, function* () {
|
|
8663
|
-
const builtCols = this.
|
|
8735
|
+
const builtCols = this.buildCols(columns);
|
|
8664
8736
|
const builtFilters = this.buildFilter(filter || {}, columns);
|
|
8665
8737
|
const lang = this.formatLangCode(I18n.instance.language);
|
|
8666
8738
|
let clientLogo = '';
|
|
@@ -8748,8 +8820,8 @@ class XLSReport extends BaseReport {
|
|
|
8748
8820
|
getFileType() {
|
|
8749
8821
|
return 'xls';
|
|
8750
8822
|
}
|
|
8751
|
-
buildDataset(data, columns) {
|
|
8752
|
-
const result = this.formatRawDataSet(data, columns);
|
|
8823
|
+
buildDataset({ data, columns }) {
|
|
8824
|
+
const result = this.formatRawDataSet(data, this.filterColumns(columns));
|
|
8753
8825
|
return JSON.stringify(result);
|
|
8754
8826
|
}
|
|
8755
8827
|
// formata o dataset para o formato "cru" xls
|
|
@@ -8762,7 +8834,7 @@ class XLSReport extends BaseReport {
|
|
|
8762
8834
|
return result;
|
|
8763
8835
|
}
|
|
8764
8836
|
buildMetadata(name, title, columns, filter) {
|
|
8765
|
-
const builtCols = this.
|
|
8837
|
+
const builtCols = this.buildCols(columns);
|
|
8766
8838
|
const builtFilters = this.buildFilter(filter || {}, columns);
|
|
8767
8839
|
const lang = this.formatLangCode(I18n.instance.language);
|
|
8768
8840
|
const clientLogo = '';
|
|
@@ -8805,12 +8877,12 @@ class XLS2Report extends BaseReport {
|
|
|
8805
8877
|
getFileType() {
|
|
8806
8878
|
return 'xls';
|
|
8807
8879
|
}
|
|
8808
|
-
buildDataset(data, metadata) {
|
|
8880
|
+
buildDataset({ data, metadata }) {
|
|
8809
8881
|
const result = this.formatDataSet(metadata, data);
|
|
8810
8882
|
return JSON.stringify(result);
|
|
8811
8883
|
}
|
|
8812
8884
|
buildMetadata(name, title, columns, filter) {
|
|
8813
|
-
const builtCols = this.
|
|
8885
|
+
const builtCols = this.buildCols(columns);
|
|
8814
8886
|
const builtFilters = this.buildFilter(filter || {}, columns);
|
|
8815
8887
|
const lang = this.formatLangCode(I18n.instance.language);
|
|
8816
8888
|
const clientLogo = '';
|
|
@@ -9005,12 +9077,12 @@ class XLS3Report extends BaseReport {
|
|
|
9005
9077
|
getFileType() {
|
|
9006
9078
|
return 'xls';
|
|
9007
9079
|
}
|
|
9008
|
-
buildDataset(data, metadata) {
|
|
9080
|
+
buildDataset({ data, metadata }) {
|
|
9009
9081
|
const result = this.formatDataSet(metadata, data);
|
|
9010
9082
|
return JSON.stringify(result);
|
|
9011
9083
|
}
|
|
9012
9084
|
buildMetadata(name, title, columns, filter) {
|
|
9013
|
-
const builtCols = this.
|
|
9085
|
+
const builtCols = this.buildCols(columns);
|
|
9014
9086
|
const builtFilters = this.buildFilter(filter || {}, columns);
|
|
9015
9087
|
const lang = this.formatLangCode(I18n.instance.language);
|
|
9016
9088
|
const clientLogo = '';
|
|
@@ -9330,21 +9402,20 @@ class Report {
|
|
|
9330
9402
|
const { route } = reportType;
|
|
9331
9403
|
const { name, columns, datasource } = this.iterable;
|
|
9332
9404
|
const { groupedData } = Object.assign({}, this.iterable);
|
|
9333
|
-
const
|
|
9334
|
-
const metadataObj = yield reportType.buildMetadata(name, this.title, formattedColumns, datasource.filter, portrait);
|
|
9405
|
+
const metadataObj = yield reportType.buildMetadata(name, this.title, columns, datasource.filter, portrait);
|
|
9335
9406
|
let dataset;
|
|
9336
9407
|
if ((reportType instanceof XLS2Report || reportType instanceof XLS3Report) && groupedData) {
|
|
9337
9408
|
const rowMetadata = rowObj.metaData;
|
|
9338
9409
|
const metadataObjClone = merge(rowMetadata, JSON.parse(metadataObj));
|
|
9339
|
-
dataset = reportType.buildDataset(groupedData, metadataObjClone);
|
|
9410
|
+
dataset = reportType.buildDataset({ data: groupedData, metadata: metadataObjClone });
|
|
9340
9411
|
}
|
|
9341
9412
|
else if (reportType instanceof PDFReport && groupedData && groupedData.length > 0) {
|
|
9342
9413
|
const formatter = new GroupedPDFFormatter();
|
|
9343
9414
|
const pdfGroupedData = formatter.format(groupedData);
|
|
9344
|
-
dataset = reportType.buildDataset(pdfGroupedData);
|
|
9415
|
+
dataset = reportType.buildDataset({ data: pdfGroupedData });
|
|
9345
9416
|
}
|
|
9346
9417
|
else {
|
|
9347
|
-
dataset = reportType.buildDataset(data,
|
|
9418
|
+
dataset = reportType.buildDataset({ data, metadata: metadataObj, columns });
|
|
9348
9419
|
}
|
|
9349
9420
|
const filter = '[]';
|
|
9350
9421
|
let row = {
|
|
@@ -9373,9 +9444,6 @@ class Report {
|
|
|
9373
9444
|
return new URL(reportFile, this.fileEndPoint).href;
|
|
9374
9445
|
});
|
|
9375
9446
|
}
|
|
9376
|
-
filterColumns(columns) {
|
|
9377
|
-
return columns.filter((item) => (item.type !== 'action' && item.isVisible));
|
|
9378
|
-
}
|
|
9379
9447
|
}
|
|
9380
9448
|
|
|
9381
9449
|
class TreeDataStructure {
|
|
@@ -9831,6 +9899,77 @@ class DataValueOutHelper {
|
|
|
9831
9899
|
}
|
|
9832
9900
|
}
|
|
9833
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
|
+
|
|
9834
9973
|
/**
|
|
9835
9974
|
* Base class for Select component.
|
|
9836
9975
|
*/
|
|
@@ -10121,18 +10260,13 @@ class Select extends TextInput {
|
|
|
10121
10260
|
* Finds and retrieves items searching by value
|
|
10122
10261
|
* @param value Default value
|
|
10123
10262
|
*/
|
|
10124
|
-
getItemsBySearchValue(value
|
|
10263
|
+
getItemsBySearchValue(value) {
|
|
10125
10264
|
return __awaiter(this, void 0, void 0, function* () {
|
|
10126
|
-
const config = Object.assign(Object.assign(Object.assign({}, this.datasource.clone()), this.dsSearch[this.searchParam](value, searchIn)), { lazyLoad: true, loadAll: Array.isArray(value) });
|
|
10127
10265
|
this.datasource.loading = true;
|
|
10128
|
-
const
|
|
10129
|
-
const
|
|
10266
|
+
const datasourceSearcher = new DatasourceSearcher();
|
|
10267
|
+
const result = yield datasourceSearcher.search(this.datasource, value, this.dataValue, this.searchParam);
|
|
10130
10268
|
this.datasource.loading = false;
|
|
10131
|
-
|
|
10132
|
-
if (Array.isArray(value)) {
|
|
10133
|
-
return items.filter((item) => value.includes(item[this.dataValue]));
|
|
10134
|
-
}
|
|
10135
|
-
return items.filter(this.getCondition(value));
|
|
10269
|
+
return result;
|
|
10136
10270
|
});
|
|
10137
10271
|
}
|
|
10138
10272
|
getCondition(filterValue) {
|
|
@@ -10157,17 +10291,6 @@ class Select extends TextInput {
|
|
|
10157
10291
|
this.updateSearch(this.dirtySearchValue);
|
|
10158
10292
|
});
|
|
10159
10293
|
}
|
|
10160
|
-
uniqueBy(a, key) {
|
|
10161
|
-
const seen = {};
|
|
10162
|
-
return a.filter((item) => {
|
|
10163
|
-
const k = item[key] || JSON.stringify(item);
|
|
10164
|
-
if (!seen[k]) {
|
|
10165
|
-
seen[k] = true;
|
|
10166
|
-
return true;
|
|
10167
|
-
}
|
|
10168
|
-
return false;
|
|
10169
|
-
});
|
|
10170
|
-
}
|
|
10171
10294
|
afterLoad() {
|
|
10172
10295
|
if (this.manualMode)
|
|
10173
10296
|
return;
|
|
@@ -10233,11 +10356,10 @@ class Select extends TextInput {
|
|
|
10233
10356
|
else {
|
|
10234
10357
|
filterValue = value;
|
|
10235
10358
|
}
|
|
10236
|
-
const searchIn = this.dataValue;
|
|
10237
10359
|
const foundInData = this.datasource.data.find(this.getCondition(filterValue));
|
|
10238
10360
|
let searchValue = foundInData;
|
|
10239
10361
|
if (!foundInData && !this.manualMode) {
|
|
10240
|
-
[searchValue] = yield this.getItemsBySearchValue(filterValue
|
|
10362
|
+
[searchValue] = yield this.getItemsBySearchValue(filterValue);
|
|
10241
10363
|
}
|
|
10242
10364
|
if (!searchValue) {
|
|
10243
10365
|
this.setFieldRowValue(null);
|
|
@@ -10535,7 +10657,7 @@ class Select extends TextInput {
|
|
|
10535
10657
|
});
|
|
10536
10658
|
}
|
|
10537
10659
|
}
|
|
10538
|
-
FormatterParserProvider.registerFormatter('ZdSelect', (value, { dataText, dataTextSeparator = ' | ', }) => {
|
|
10660
|
+
FormatterParserProvider.registerFormatter('ZdSelect', (value, { dataText, dataTextSeparator = ' | ', eagerMask, }) => {
|
|
10539
10661
|
if (value === null || value === undefined) {
|
|
10540
10662
|
return null;
|
|
10541
10663
|
}
|
|
@@ -10567,7 +10689,7 @@ FormatterParserProvider.registerFormatter('ZdSelect', (value, { dataText, dataTe
|
|
|
10567
10689
|
let masked = value[column];
|
|
10568
10690
|
if (masks[index]) {
|
|
10569
10691
|
const maskValue = typeof masks[index] === 'function' ? masks[index](value[column]) : masks[index];
|
|
10570
|
-
masked = Mask.getValueWithMask(value[column], maskValue);
|
|
10692
|
+
masked = Mask.getValueWithMask(value[column], maskValue, false, eagerMask);
|
|
10571
10693
|
}
|
|
10572
10694
|
return result + separator + masked;
|
|
10573
10695
|
}
|
|
@@ -10870,15 +10992,12 @@ class IterableComponentRender extends Iterable {
|
|
|
10870
10992
|
this.createAccessors();
|
|
10871
10993
|
}
|
|
10872
10994
|
addSlashes(value) {
|
|
10873
|
-
|
|
10874
|
-
|
|
10875
|
-
|
|
10876
|
-
|
|
10877
|
-
|
|
10878
|
-
|
|
10879
|
-
.replace(/"/g, '\\"');
|
|
10880
|
-
}
|
|
10881
|
-
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, '\\"');
|
|
10882
11001
|
}
|
|
10883
11002
|
/**
|
|
10884
11003
|
* Returns the iterable component metadata based on row data
|
|
@@ -10891,14 +11010,13 @@ class IterableComponentRender extends Iterable {
|
|
|
10891
11010
|
.replace(rowExp, JSON.stringify(row))
|
|
10892
11011
|
.replace(exp, (match) => {
|
|
10893
11012
|
const propPath = match.replace(/<<|>>|"/g, '').split('.').splice(1).join('.');
|
|
10894
|
-
|
|
11013
|
+
let value = get(row, propPath);
|
|
11014
|
+
if (value === undefined || value === null)
|
|
11015
|
+
value = '';
|
|
10895
11016
|
if (typeof value === 'string') {
|
|
10896
|
-
|
|
10897
|
-
|
|
10898
|
-
return value;
|
|
11017
|
+
const escaped = this.addSlashes(value);
|
|
11018
|
+
return match.startsWith('"') && match.endsWith('"') ? `"${escaped}"` : escaped;
|
|
10899
11019
|
}
|
|
10900
|
-
if (value === undefined)
|
|
10901
|
-
return '""';
|
|
10902
11020
|
return value;
|
|
10903
11021
|
});
|
|
10904
11022
|
return JSON.parse(metadata);
|
|
@@ -12178,7 +12296,8 @@ FormatterParserProvider.registerParser('ZdMonth', (value, { dateFormat = Config.
|
|
|
12178
12296
|
}
|
|
12179
12297
|
}
|
|
12180
12298
|
return value;
|
|
12181
|
-
});
|
|
12299
|
+
});
|
|
12300
|
+
InputFactory.register('ZdMonth', Month);
|
|
12182
12301
|
|
|
12183
12302
|
/**
|
|
12184
12303
|
* Base class for Password component.
|
|
@@ -12575,19 +12694,10 @@ class SelectMultiple extends Select {
|
|
|
12575
12694
|
this.insertedValues.push(item);
|
|
12576
12695
|
pushed = true;
|
|
12577
12696
|
});
|
|
12578
|
-
|
|
12579
|
-
|
|
12580
|
-
if (this.searchParam !== 'SEARCH') {
|
|
12581
|
-
const items = yield this.getItemsBySearchValue(searchedValues, this.dataValue);
|
|
12697
|
+
if (searchedValues.length) {
|
|
12698
|
+
const items = yield this.getItemsBySearchValue(searchedValues);
|
|
12582
12699
|
items.forEach(insertItem);
|
|
12583
12700
|
}
|
|
12584
|
-
else {
|
|
12585
|
-
const promises = searchedValues.map((searchedValue) => __awaiter(this, void 0, void 0, function* () {
|
|
12586
|
-
const [item] = yield this.getItemsBySearchValue(searchedValue, this.dataValue);
|
|
12587
|
-
insertItem(item);
|
|
12588
|
-
}));
|
|
12589
|
-
yield Promise.all(promises);
|
|
12590
|
-
}
|
|
12591
12701
|
if (foundValues.length > 0) {
|
|
12592
12702
|
this.setFieldRowValue(foundValues);
|
|
12593
12703
|
}
|
|
@@ -12825,7 +12935,7 @@ class SelectMultiple extends Select {
|
|
|
12825
12935
|
if (this.manualMode)
|
|
12826
12936
|
return;
|
|
12827
12937
|
if (this.insertedValues.length) {
|
|
12828
|
-
this.datasource.data =
|
|
12938
|
+
this.datasource.data = uniqueBy(this.insertedValues.concat(this.datasource.data), this.datasource.uniqueKey);
|
|
12829
12939
|
const values = this.insertedValues.map((inserted) => inserted[this.dataValue]);
|
|
12830
12940
|
// prevent caching insertedValues
|
|
12831
12941
|
this.cachedData = this.datasource.data.filter((row) => !values.includes(row[this.dataValue]));
|
|
@@ -12968,7 +13078,8 @@ FormatterParserProvider.registerFormatter('ZdSelectMultiple', (value, props) =>
|
|
|
12968
13078
|
return formattedRow;
|
|
12969
13079
|
});
|
|
12970
13080
|
return formattedValue;
|
|
12971
|
-
});
|
|
13081
|
+
});
|
|
13082
|
+
InputFactory.register('ZdSelectMultiple', SelectMultiple);
|
|
12972
13083
|
|
|
12973
13084
|
/**
|
|
12974
13085
|
* Base class for Select Tree component.
|
|
@@ -13059,6 +13170,7 @@ class SelectTree extends TextInput {
|
|
|
13059
13170
|
* Defines if should wait and not execute GET method when Datasource is created
|
|
13060
13171
|
*/
|
|
13061
13172
|
this.lazyLoad = true;
|
|
13173
|
+
this.selectValue = null;
|
|
13062
13174
|
/**
|
|
13063
13175
|
* Uses delayed loading to load tree branches
|
|
13064
13176
|
*/
|
|
@@ -13080,6 +13192,10 @@ class SelectTree extends TextInput {
|
|
|
13080
13192
|
*/
|
|
13081
13193
|
this.dataValueOutFormName = '';
|
|
13082
13194
|
this.formatterFn = FormatterParserProvider.getFormatter('ZdSelectTree');
|
|
13195
|
+
/**
|
|
13196
|
+
* Defines if data handling should be manual or automatic
|
|
13197
|
+
*/
|
|
13198
|
+
this.searchParam = 'SEARCH';
|
|
13083
13199
|
this.savedNodes = undefined;
|
|
13084
13200
|
this.search = '';
|
|
13085
13201
|
this.debounceSearch = debounce(this.searchChange, 500);
|
|
@@ -13107,6 +13223,7 @@ class SelectTree extends TextInput {
|
|
|
13107
13223
|
this.autoSelection = this.getInitValue('autoSelection', props.autoSelection, this.autoSelection);
|
|
13108
13224
|
this.dataValueOut = this.getInitValue('dataValueOut', props.dataValueOut, this.dataValueOut);
|
|
13109
13225
|
this.dataValueOutFormName = this.getInitValue('dataValueOutFormName', props.dataValueOutFormName, this.dataValueOutFormName);
|
|
13226
|
+
this.searchParam = this.getInitValue('searchParam', props.searchParam, this.searchParam);
|
|
13110
13227
|
if (props.datasource && Object.keys(props.datasource).length) {
|
|
13111
13228
|
this.lazyLoad = props.datasource.lazyLoad !== false;
|
|
13112
13229
|
const searchFields = Array.isArray(this.dataText) ? this.dataText : [this.dataText];
|
|
@@ -13176,6 +13293,9 @@ class SelectTree extends TextInput {
|
|
|
13176
13293
|
this.nodes = this.createChildrenNodes(firstLevelNodes);
|
|
13177
13294
|
}
|
|
13178
13295
|
}
|
|
13296
|
+
/**
|
|
13297
|
+
* Creates a Tree Node from a datasource row
|
|
13298
|
+
*/
|
|
13179
13299
|
createNodeFromRow(row) {
|
|
13180
13300
|
let children;
|
|
13181
13301
|
if (this.fetchOnDemand && !this.datasource.search) {
|
|
@@ -13315,31 +13435,71 @@ class SelectTree extends TextInput {
|
|
|
13315
13435
|
});
|
|
13316
13436
|
return result;
|
|
13317
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
|
+
}
|
|
13318
13454
|
get value() {
|
|
13319
13455
|
if (!this.selectValue)
|
|
13320
13456
|
return this.selectValue;
|
|
13321
13457
|
if (this.returnObject) {
|
|
13322
|
-
return this.
|
|
13458
|
+
return this.clearNodeRow(this.selectValue);
|
|
13323
13459
|
}
|
|
13324
|
-
|
|
13460
|
+
const key = this.datasource ? this.dataValue : 'id';
|
|
13461
|
+
return this.selectValue[key];
|
|
13325
13462
|
}
|
|
13326
13463
|
set value(value) {
|
|
13327
13464
|
this.setValue(value);
|
|
13328
13465
|
}
|
|
13329
13466
|
setValue(value) {
|
|
13330
|
-
|
|
13331
|
-
|
|
13332
|
-
|
|
13333
|
-
|
|
13334
|
-
|
|
13335
|
-
|
|
13336
|
-
|
|
13337
|
-
|
|
13338
|
-
|
|
13339
|
-
|
|
13340
|
-
|
|
13341
|
-
|
|
13342
|
-
|
|
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
|
+
});
|
|
13343
13503
|
}
|
|
13344
13504
|
loadChildren(parentNode) {
|
|
13345
13505
|
return __awaiter(this, void 0, void 0, function* () {
|
|
@@ -13392,6 +13552,7 @@ class SelectTreeMultiple extends SelectTree {
|
|
|
13392
13552
|
* Selected Nodes
|
|
13393
13553
|
*/
|
|
13394
13554
|
this.selectedNodes = [];
|
|
13555
|
+
this.selectValue = [];
|
|
13395
13556
|
/**
|
|
13396
13557
|
* Changes the behavior of checked nodes that will be displayed in the array of values
|
|
13397
13558
|
*/
|
|
@@ -13410,7 +13571,9 @@ class SelectTreeMultiple extends SelectTree {
|
|
|
13410
13571
|
* Triggered after selected nodes change
|
|
13411
13572
|
*/
|
|
13412
13573
|
changeSelectedNodes(selectedNodes, element) {
|
|
13413
|
-
|
|
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 });
|
|
13414
13577
|
}
|
|
13415
13578
|
/**
|
|
13416
13579
|
* Triggered deselecting an node
|
|
@@ -13422,34 +13585,58 @@ class SelectTreeMultiple extends SelectTree {
|
|
|
13422
13585
|
if (!this.selectValue)
|
|
13423
13586
|
return [];
|
|
13424
13587
|
if (this.returnObject) {
|
|
13425
|
-
return this.selectValue.map((value) => this.
|
|
13588
|
+
return this.selectValue.map((value) => this.clearNodeRow(value));
|
|
13426
13589
|
}
|
|
13427
|
-
|
|
13590
|
+
const key = this.datasource ? this.dataValue : 'id';
|
|
13591
|
+
return this.selectValue.map((item) => item[key]);
|
|
13428
13592
|
}
|
|
13429
13593
|
set value(value) {
|
|
13430
13594
|
this.setValue(value);
|
|
13431
13595
|
}
|
|
13432
13596
|
setValue(value) {
|
|
13433
|
-
|
|
13434
|
-
|
|
13435
|
-
|
|
13436
|
-
|
|
13437
|
-
|
|
13438
|
-
|
|
13439
|
-
|
|
13440
|
-
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;
|
|
13441
13624
|
if (typeof item === 'object') {
|
|
13442
|
-
|
|
13625
|
+
insertItem(item);
|
|
13626
|
+
return;
|
|
13443
13627
|
}
|
|
13444
|
-
|
|
13445
|
-
|
|
13446
|
-
|
|
13447
|
-
|
|
13448
|
-
|
|
13449
|
-
|
|
13450
|
-
|
|
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);
|
|
13451
13638
|
}
|
|
13452
|
-
|
|
13639
|
+
this.selectValue = foundValues;
|
|
13453
13640
|
});
|
|
13454
13641
|
}
|
|
13455
13642
|
/**
|
|
@@ -13497,16 +13684,18 @@ class SelectTreeMultiple extends SelectTree {
|
|
|
13497
13684
|
*/
|
|
13498
13685
|
selectAllItems(nodes = this.nodes) {
|
|
13499
13686
|
var _a;
|
|
13500
|
-
|
|
13501
|
-
|
|
13502
|
-
|
|
13503
|
-
|
|
13504
|
-
|
|
13505
|
-
|
|
13506
|
-
|
|
13507
|
-
|
|
13508
|
-
|
|
13509
|
-
|
|
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
|
+
});
|
|
13510
13699
|
}
|
|
13511
13700
|
/**
|
|
13512
13701
|
* Unelects all items in the tree \
|
|
@@ -13518,21 +13707,23 @@ class SelectTreeMultiple extends SelectTree {
|
|
|
13518
13707
|
*/
|
|
13519
13708
|
unSelectAllItems(nodes = this.nodes) {
|
|
13520
13709
|
var _a;
|
|
13521
|
-
|
|
13522
|
-
this.
|
|
13523
|
-
|
|
13524
|
-
|
|
13525
|
-
|
|
13526
|
-
|
|
13527
|
-
|
|
13528
|
-
|
|
13529
|
-
|
|
13530
|
-
|
|
13531
|
-
|
|
13532
|
-
|
|
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);
|
|
13533
13726
|
});
|
|
13534
|
-
const uniqueArray = Array.from(nodeMap.values());
|
|
13535
|
-
this.setValue(uniqueArray);
|
|
13536
13727
|
}
|
|
13537
13728
|
/**
|
|
13538
13729
|
* Takes two arrays and creates a map of the unique values
|
|
@@ -13554,15 +13745,15 @@ class SelectTreeMultiple extends SelectTree {
|
|
|
13554
13745
|
return this.value;
|
|
13555
13746
|
}
|
|
13556
13747
|
getValueAsObject() {
|
|
13557
|
-
return this.
|
|
13558
|
-
|
|
13559
|
-
|
|
13560
|
-
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);
|
|
13561
13751
|
});
|
|
13562
13752
|
}
|
|
13563
13753
|
}
|
|
13564
13754
|
const selectFormatterFn = FormatterParserProvider.getFormatter('ZdSelectMultiple');
|
|
13565
|
-
FormatterParserProvider.registerFormatter('ZdSelectTreeMultiple', selectFormatterFn);
|
|
13755
|
+
FormatterParserProvider.registerFormatter('ZdSelectTreeMultiple', selectFormatterFn);
|
|
13756
|
+
InputFactory.register('ZdSelectTreeMultiple', SelectTreeMultiple);
|
|
13566
13757
|
|
|
13567
13758
|
/**
|
|
13568
13759
|
* Base class for SelectableList component.
|
|
@@ -15987,7 +16178,7 @@ const storeOrRetrieveLookup = (column, row, value, dataValue, componentProps) =>
|
|
|
15987
16178
|
}
|
|
15988
16179
|
return row;
|
|
15989
16180
|
};
|
|
15990
|
-
const formatter$
|
|
16181
|
+
const formatter$2 = ({ column, value, row, componentProps, }) => {
|
|
15991
16182
|
if (value === null || value === undefined)
|
|
15992
16183
|
return '';
|
|
15993
16184
|
const { dataText, formatterDataText, dataTextSeparator, dataValue, dataTextDiscrete, foreignColumns, } = componentProps;
|
|
@@ -16018,12 +16209,12 @@ const formatter$1 = ({ column, value, row, componentProps, }) => {
|
|
|
16018
16209
|
return currentRow[textColumn] || value;
|
|
16019
16210
|
}
|
|
16020
16211
|
const formatterFn = FormatterParserProvider.getFormatter('ZdSelect');
|
|
16021
|
-
return formatterFn(currentRow, { dataText: textColumn, dataTextSeparator });
|
|
16212
|
+
return formatterFn(currentRow, { dataText: textColumn, dataTextSeparator, eagerMask: false });
|
|
16022
16213
|
};
|
|
16023
|
-
FormatterParserProvider.registerFormatter('column_ZdSelect', formatter$
|
|
16024
|
-
FormatterParserProvider.registerFormatter('column_ZdSelectTree', formatter$
|
|
16214
|
+
FormatterParserProvider.registerFormatter('column_ZdSelect', formatter$2);
|
|
16215
|
+
FormatterParserProvider.registerFormatter('column_ZdSelectTree', formatter$2);
|
|
16025
16216
|
|
|
16026
|
-
const formatter = ({ column, value, row, componentProps, }) => {
|
|
16217
|
+
const formatter$1 = ({ column, value, row, componentProps, }) => {
|
|
16027
16218
|
if (!value || !Array.isArray(value) || value.length === 0)
|
|
16028
16219
|
return '';
|
|
16029
16220
|
const { formatterDataText, foreignColumns, dataText } = componentProps;
|
|
@@ -16061,11 +16252,15 @@ const formatter = ({ column, value, row, componentProps, }) => {
|
|
|
16061
16252
|
});
|
|
16062
16253
|
return result.join(', ');
|
|
16063
16254
|
};
|
|
16064
|
-
FormatterParserProvider.registerFormatter('column_ZdSelectMultiple', formatter);
|
|
16065
|
-
FormatterParserProvider.registerFormatter('column_ZdSelectTreeMultiple', formatter);
|
|
16255
|
+
FormatterParserProvider.registerFormatter('column_ZdSelectMultiple', formatter$1);
|
|
16256
|
+
FormatterParserProvider.registerFormatter('column_ZdSelectTreeMultiple', formatter$1);
|
|
16257
|
+
|
|
16258
|
+
const defaultFormatter = FormatterParserProvider.getFormatter('ZdTextInput');
|
|
16259
|
+
const formatter = ({ value, componentProps, }) => defaultFormatter(value, Object.assign(Object.assign({}, componentProps), { eagerMask: false }));
|
|
16260
|
+
FormatterParserProvider.registerFormatter('column_ZdTextInput', formatter);
|
|
16066
16261
|
|
|
16067
16262
|
const AutoNumeric = require('@zeedhi/autonumeric/dist/autoNumeric');
|
|
16068
16263
|
const packageContent = require('../package.json');
|
|
16069
16264
|
VersionService.addPackageVersion(packageContent.name, packageContent.version);
|
|
16070
16265
|
|
|
16071
|
-
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 };
|