@zeedhi/common 1.109.0 → 1.110.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 +398 -239
- package/dist/zd-common.umd.js +397 -238
- package/package.json +2 -2
- package/types/components/zd-grid/grid-editable.d.ts +14 -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/types/utils/report/report-type/base-report.d.ts +6 -6
- package/types/utils/report/report-type/csv-report.d.ts +1 -0
- package/types/utils/report/report-type/interfaces.d.ts +32 -0
- package/types/utils/report/report-type/pdf-report.d.ts +4 -2
- package/types/utils/report/report-type/report-column-transformer.d.ts +9 -0
- package/types/utils/report/report-type/xls-report.d.ts +1 -0
- package/types/utils/report/report-type/xls2-report.d.ts +1 -0
- package/types/utils/report/report-type/xls3-report.d.ts +1 -0
- package/types/utils/report/report.d.ts +2 -1
package/dist/zd-common.esm.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { AccessorManager, Event, KeyMap, MethodNotAssignedError, Metadata, Accessor, I18n, FormatterParserProvider, Validation, Mask, DatasourceFactory, Loader, Config, dayjs, Utils, DateHelper, Router, Messages, InstanceNotFoundError, ViewService,
|
|
1
|
+
import { AccessorManager, Event, KeyMap, MethodNotAssignedError, Metadata, Accessor, I18n, FormatterParserProvider, Validation, Mask, DatasourceFactory, Loader, Config, dayjs, Utils, DateHelper, Router, Messages, InstanceNotFoundError, ViewService, URL as URL$1, Http, Cookie, VersionService } from '@zeedhi/core';
|
|
2
2
|
import merge from 'lodash.merge';
|
|
3
3
|
import cloneDeep from 'lodash.clonedeep';
|
|
4
4
|
import debounce from 'lodash.debounce';
|
|
@@ -5625,6 +5625,18 @@ class Column extends Component {
|
|
|
5625
5625
|
super.onBeforeDestroy();
|
|
5626
5626
|
(_a = this.lookupDatasource) === null || _a === void 0 ? void 0 : _a.destroy();
|
|
5627
5627
|
}
|
|
5628
|
+
/**
|
|
5629
|
+
* Retrieves a row from lookup using its key
|
|
5630
|
+
* @returns the row object when found, null when it is not found or empty
|
|
5631
|
+
*/
|
|
5632
|
+
getLookupRow(value) {
|
|
5633
|
+
const row = this.lookupData[value];
|
|
5634
|
+
if (!row)
|
|
5635
|
+
return null;
|
|
5636
|
+
if (Object.keys(row).length === 0)
|
|
5637
|
+
return null;
|
|
5638
|
+
return row;
|
|
5639
|
+
}
|
|
5628
5640
|
}
|
|
5629
5641
|
|
|
5630
5642
|
/**
|
|
@@ -5924,98 +5936,6 @@ class GridColumn extends Column {
|
|
|
5924
5936
|
}
|
|
5925
5937
|
}
|
|
5926
5938
|
}
|
|
5927
|
-
FormatterParserProvider.registerFormatter('column_ZdSelect', ({ column, value, row, componentProps, }) => {
|
|
5928
|
-
if (value === null || value === undefined)
|
|
5929
|
-
return '';
|
|
5930
|
-
const { dataText, formatterDataText, dataTextSeparator, dataValue, dataTextDiscrete, foreignColumns, } = componentProps;
|
|
5931
|
-
let currentRow = row;
|
|
5932
|
-
const dataTextColumns = Array.isArray(dataText) ? dataText : [dataText];
|
|
5933
|
-
if (dataValue) {
|
|
5934
|
-
const columns = Array.isArray(formatterDataText) ? formatterDataText : [formatterDataText];
|
|
5935
|
-
if (foreignColumns) {
|
|
5936
|
-
const loopkupRow = {};
|
|
5937
|
-
dataTextColumns.forEach((item) => {
|
|
5938
|
-
const dataTextName = typeof item === 'string' ? item : item.name;
|
|
5939
|
-
loopkupRow[dataTextName] = currentRow[foreignColumns[dataTextName] || dataTextName];
|
|
5940
|
-
});
|
|
5941
|
-
loopkupRow[dataValue] = currentRow[column.name];
|
|
5942
|
-
column.lookupData[currentRow[column.name]] = loopkupRow;
|
|
5943
|
-
}
|
|
5944
|
-
else if (!formatterDataText) {
|
|
5945
|
-
currentRow = column.getLookupData(dataValue, value[dataValue] || value);
|
|
5946
|
-
}
|
|
5947
|
-
else if (columns.length === dataTextColumns.length) {
|
|
5948
|
-
const loopkupRow = {};
|
|
5949
|
-
columns.forEach((item, index) => {
|
|
5950
|
-
const dataTextValue = dataTextColumns[index];
|
|
5951
|
-
const dataTextName = typeof dataTextValue === 'string' ? dataTextValue : dataTextValue.name;
|
|
5952
|
-
loopkupRow[dataTextName] = currentRow[typeof item === 'string' ? item : item.name];
|
|
5953
|
-
});
|
|
5954
|
-
loopkupRow[dataValue] = currentRow[column.name];
|
|
5955
|
-
column.lookupData[currentRow[column.name]] = loopkupRow;
|
|
5956
|
-
}
|
|
5957
|
-
}
|
|
5958
|
-
if (!Object.keys(currentRow).length)
|
|
5959
|
-
return typeof value === 'object' ? '' : value;
|
|
5960
|
-
let dataTextForeign = dataText;
|
|
5961
|
-
if (dataText && foreignColumns) {
|
|
5962
|
-
if (typeof dataText === 'string') {
|
|
5963
|
-
dataTextForeign = foreignColumns[dataText] || dataText;
|
|
5964
|
-
}
|
|
5965
|
-
else {
|
|
5966
|
-
dataTextForeign = dataTextColumns.map((item) => {
|
|
5967
|
-
const itemName = typeof item === 'string' ? item : item.name;
|
|
5968
|
-
return foreignColumns[itemName] || itemName;
|
|
5969
|
-
});
|
|
5970
|
-
}
|
|
5971
|
-
}
|
|
5972
|
-
const textColumn = dataTextDiscrete || formatterDataText || dataTextForeign;
|
|
5973
|
-
if (!textColumn)
|
|
5974
|
-
return value;
|
|
5975
|
-
if (typeof textColumn === 'string') {
|
|
5976
|
-
return currentRow[textColumn] || value;
|
|
5977
|
-
}
|
|
5978
|
-
const formatterFn = FormatterParserProvider.getFormatter('ZdSelect');
|
|
5979
|
-
return formatterFn(currentRow, { dataText: textColumn, dataTextSeparator });
|
|
5980
|
-
});
|
|
5981
|
-
FormatterParserProvider.registerFormatter('column_ZdSelectMultiple', ({ column, value, row, componentProps, }) => {
|
|
5982
|
-
if (!value || !Array.isArray(value) || value.length === 0)
|
|
5983
|
-
return '';
|
|
5984
|
-
const { formatterDataText, foreignColumns, dataText } = componentProps;
|
|
5985
|
-
const formatterFn = FormatterParserProvider.getFormatter('column_ZdSelect');
|
|
5986
|
-
const result = value.map((item, index) => {
|
|
5987
|
-
let formatterRow = Object.assign({}, row);
|
|
5988
|
-
const rowOverride = {};
|
|
5989
|
-
if (formatterDataText && formatterDataText.length > 0) {
|
|
5990
|
-
const columns = Array.isArray(formatterDataText) ? formatterDataText : [formatterDataText];
|
|
5991
|
-
columns.forEach((col) => {
|
|
5992
|
-
const textName = typeof col === 'string' ? col : col.name;
|
|
5993
|
-
rowOverride[textName] = row[textName][index];
|
|
5994
|
-
});
|
|
5995
|
-
formatterRow = Object.assign(Object.assign({}, row), rowOverride);
|
|
5996
|
-
}
|
|
5997
|
-
else if (foreignColumns && dataText) {
|
|
5998
|
-
let dataTextForeign = dataText;
|
|
5999
|
-
if (typeof dataText === 'string') {
|
|
6000
|
-
dataTextForeign = [foreignColumns[dataText] || dataText];
|
|
6001
|
-
}
|
|
6002
|
-
else {
|
|
6003
|
-
dataTextForeign = dataText.map((col) => {
|
|
6004
|
-
const colName = typeof col === 'string' ? col : col.name;
|
|
6005
|
-
return foreignColumns[colName] || colName;
|
|
6006
|
-
});
|
|
6007
|
-
}
|
|
6008
|
-
dataTextForeign.forEach((col) => {
|
|
6009
|
-
rowOverride[col] = row[col][index];
|
|
6010
|
-
});
|
|
6011
|
-
formatterRow = Object.assign(Object.assign({}, row), rowOverride);
|
|
6012
|
-
}
|
|
6013
|
-
return formatterFn({
|
|
6014
|
-
column, value: item, row: formatterRow, componentProps,
|
|
6015
|
-
});
|
|
6016
|
-
});
|
|
6017
|
-
return result.join(', ');
|
|
6018
|
-
});
|
|
6019
5939
|
const toggleableFormatter = ({ value, componentProps }) => {
|
|
6020
5940
|
const { trueValue, falseValue, trueIcon, falseIcon, trueDisplayValue, falseDisplayValue, } = componentProps;
|
|
6021
5941
|
const trueDefined = isUndefined(trueValue) ? true : trueValue;
|
|
@@ -6901,6 +6821,8 @@ class GridEditable extends Grid {
|
|
|
6901
6821
|
this.viewEnterEdit = null;
|
|
6902
6822
|
this.showCancelColumn = false;
|
|
6903
6823
|
this.newRowIdentifier = '__added_row';
|
|
6824
|
+
this.positionIdentifier = '__position';
|
|
6825
|
+
this.pageIdentifier = '__page';
|
|
6904
6826
|
this.createGridController();
|
|
6905
6827
|
this.doubleClickEdit = this.getInitValue('doubleClickEdit', props.doubleClickEdit, this.doubleClickEdit);
|
|
6906
6828
|
this.canEditRow = this.getInitValue('canEditRow', props.canEditRow, this.canEditRow);
|
|
@@ -6909,6 +6831,7 @@ class GridEditable extends Grid {
|
|
|
6909
6831
|
this.showCancelColumn = this.getInitValue('showCancelColumn', props.showCancelColumn, this.showCancelColumn);
|
|
6910
6832
|
this.createAccessors();
|
|
6911
6833
|
this.addCancelColumn();
|
|
6834
|
+
this.registerDatasourceCallback();
|
|
6912
6835
|
}
|
|
6913
6836
|
setViewEnterEdit(viewEnterEdit) {
|
|
6914
6837
|
this.viewEnterEdit = viewEnterEdit;
|
|
@@ -6964,6 +6887,35 @@ class GridEditable extends Grid {
|
|
|
6964
6887
|
instantiateCancelColumn() {
|
|
6965
6888
|
return new GridColumnEditable(this.getCancelColumnProps());
|
|
6966
6889
|
}
|
|
6890
|
+
registerDatasourceCallback() {
|
|
6891
|
+
const callback = () => {
|
|
6892
|
+
const addedRows = Object.keys(this.addedRows).map((key) => this.addedRows[key]);
|
|
6893
|
+
if (addedRows.length === 0)
|
|
6894
|
+
return;
|
|
6895
|
+
let dataWithNewRow = null;
|
|
6896
|
+
const { page } = this.datasource;
|
|
6897
|
+
addedRows.forEach((row) => {
|
|
6898
|
+
const { originalRow } = row;
|
|
6899
|
+
const rowToInsert = originalRow || row;
|
|
6900
|
+
const rowPage = rowToInsert[this.pageIdentifier];
|
|
6901
|
+
const lastPage = this.datasource.getLastPage() || 1;
|
|
6902
|
+
// if the row's page is greater than the last page, should insert the row in the last page
|
|
6903
|
+
// if the row's page is not greater than the last page, should insert the row in the correct page
|
|
6904
|
+
if (rowPage > lastPage) {
|
|
6905
|
+
if (page !== lastPage)
|
|
6906
|
+
return;
|
|
6907
|
+
}
|
|
6908
|
+
else if (rowPage !== page) {
|
|
6909
|
+
return;
|
|
6910
|
+
}
|
|
6911
|
+
dataWithNewRow = this.insertRowInDatasource(rowToInsert, rowToInsert[this.positionIdentifier]);
|
|
6912
|
+
});
|
|
6913
|
+
if (dataWithNewRow) {
|
|
6914
|
+
this.datasource.updatePageData(dataWithNewRow);
|
|
6915
|
+
}
|
|
6916
|
+
};
|
|
6917
|
+
this.datasource.registerGetCallback(callback);
|
|
6918
|
+
}
|
|
6967
6919
|
createGridController() {
|
|
6968
6920
|
const controller = new GridEditableController(this);
|
|
6969
6921
|
Loader.addController(`GridEditableController_${this.name}`, controller);
|
|
@@ -7155,23 +7107,23 @@ class GridEditable extends Grid {
|
|
|
7155
7107
|
if (Array.isArray(colValue)) {
|
|
7156
7108
|
colValue.forEach((item) => {
|
|
7157
7109
|
const value = typeof item === 'object' ? item[componentProps.dataValue] : item;
|
|
7158
|
-
|
|
7159
|
-
componentProps.datasource.data.push(column.lookupData[value]);
|
|
7160
|
-
}
|
|
7110
|
+
this.pushLookupRow(column, componentProps, value);
|
|
7161
7111
|
});
|
|
7162
7112
|
return;
|
|
7163
7113
|
}
|
|
7164
7114
|
if (colValue && typeof colValue === 'object'
|
|
7165
7115
|
&& Object.prototype.hasOwnProperty.call(colValue, componentProps.dataValue)) {
|
|
7166
7116
|
const value = colValue[componentProps.dataValue];
|
|
7167
|
-
|
|
7168
|
-
componentProps.datasource.data.push(column.lookupData[value]);
|
|
7169
|
-
}
|
|
7117
|
+
this.pushLookupRow(column, componentProps, value);
|
|
7170
7118
|
return;
|
|
7171
7119
|
}
|
|
7172
|
-
|
|
7173
|
-
|
|
7174
|
-
|
|
7120
|
+
this.pushLookupRow(column, componentProps, colValue);
|
|
7121
|
+
}
|
|
7122
|
+
pushLookupRow(column, componentProps, value) {
|
|
7123
|
+
const lookupRow = column.getLookupRow(value);
|
|
7124
|
+
if (!lookupRow)
|
|
7125
|
+
return;
|
|
7126
|
+
componentProps.datasource.data.push(lookupRow);
|
|
7175
7127
|
}
|
|
7176
7128
|
checkCompValidity(component) {
|
|
7177
7129
|
if (!component.isValid()) {
|
|
@@ -7276,6 +7228,7 @@ class GridEditable extends Grid {
|
|
|
7276
7228
|
return __awaiter(this, void 0, void 0, function* () {
|
|
7277
7229
|
const { page } = this.datasource;
|
|
7278
7230
|
yield this.cancelAddedRows();
|
|
7231
|
+
this.addedRows = {};
|
|
7279
7232
|
yield this.datasource.setPage(page);
|
|
7280
7233
|
this.editing = false;
|
|
7281
7234
|
this.editedRows = {};
|
|
@@ -7293,14 +7246,10 @@ class GridEditable extends Grid {
|
|
|
7293
7246
|
delete cloneAddedRows[key];
|
|
7294
7247
|
this.editedRows = cloneEditedRows;
|
|
7295
7248
|
this.addedRows = cloneAddedRows;
|
|
7296
|
-
|
|
7297
|
-
if (this.datasource instanceof MemoryDatasource) {
|
|
7298
|
-
data = this.datasource.allData;
|
|
7299
|
-
}
|
|
7300
|
-
const { uniqueKey } = this.datasource;
|
|
7249
|
+
const { data, uniqueKey } = this.datasource;
|
|
7301
7250
|
const index = data.findIndex((row) => row[uniqueKey] === key);
|
|
7302
7251
|
data.splice(index, 1);
|
|
7303
|
-
return this.datasource.
|
|
7252
|
+
return this.datasource.updatePageData(data);
|
|
7304
7253
|
});
|
|
7305
7254
|
}
|
|
7306
7255
|
cancelAddedRows() {
|
|
@@ -7313,7 +7262,7 @@ class GridEditable extends Grid {
|
|
|
7313
7262
|
allData.splice(index, 1);
|
|
7314
7263
|
}
|
|
7315
7264
|
}
|
|
7316
|
-
yield this.datasource.
|
|
7265
|
+
yield this.datasource.updatePageData(allData);
|
|
7317
7266
|
});
|
|
7318
7267
|
}
|
|
7319
7268
|
addDataRow(row) {
|
|
@@ -7352,6 +7301,8 @@ class GridEditable extends Grid {
|
|
|
7352
7301
|
const row = Object.assign(Object.assign({}, this.editedRows[key].originalRow), this.editedRows[key]);
|
|
7353
7302
|
delete row.originalRow;
|
|
7354
7303
|
delete row[this.newRowIdentifier];
|
|
7304
|
+
delete row[this.positionIdentifier];
|
|
7305
|
+
delete row[this.pageIdentifier];
|
|
7355
7306
|
Object.keys(row).forEach((attr) => {
|
|
7356
7307
|
if (Object.prototype.hasOwnProperty.call(row, `${attr}_original`)) {
|
|
7357
7308
|
delete row[`${attr}_original`];
|
|
@@ -7373,6 +7324,8 @@ class GridEditable extends Grid {
|
|
|
7373
7324
|
const row = Object.assign(Object.assign({}, this.addedRows[key].originalRow), this.addedRows[key]);
|
|
7374
7325
|
delete row.originalRow;
|
|
7375
7326
|
delete row[this.newRowIdentifier];
|
|
7327
|
+
delete row[this.positionIdentifier];
|
|
7328
|
+
delete row[this.pageIdentifier];
|
|
7376
7329
|
Object.keys(row).forEach((attr) => {
|
|
7377
7330
|
if (Object.prototype.hasOwnProperty.call(row, `${attr}_original`)) {
|
|
7378
7331
|
delete row[`${attr}_original`];
|
|
@@ -7443,10 +7396,14 @@ class GridEditable extends Grid {
|
|
|
7443
7396
|
return __awaiter(this, void 0, void 0, function* () {
|
|
7444
7397
|
const data = this.insertRowInDatasource(row, position);
|
|
7445
7398
|
this.saveRowReference(row);
|
|
7446
|
-
yield this.datasource.
|
|
7399
|
+
yield this.datasource.updatePageData(data);
|
|
7447
7400
|
this.editing = true;
|
|
7448
7401
|
});
|
|
7449
7402
|
}
|
|
7403
|
+
/**
|
|
7404
|
+
* Saves a row reference in editedRows and addedRows
|
|
7405
|
+
* @param row Row to be saved
|
|
7406
|
+
*/
|
|
7450
7407
|
saveRowReference(row) {
|
|
7451
7408
|
const id = row[this.datasource.uniqueKey];
|
|
7452
7409
|
if (id) {
|
|
@@ -7454,15 +7411,18 @@ class GridEditable extends Grid {
|
|
|
7454
7411
|
this.addedRows = Object.assign(Object.assign({}, this.addedRows), { [id]: Object.assign({}, row) });
|
|
7455
7412
|
}
|
|
7456
7413
|
}
|
|
7414
|
+
/**
|
|
7415
|
+
* Inserts a row in datasource depending on the position
|
|
7416
|
+
* @param row Row to be inserted
|
|
7417
|
+
* @param position Position, 'end' or 'start'
|
|
7418
|
+
* @returns the data containing the newly added row
|
|
7419
|
+
*/
|
|
7457
7420
|
insertRowInDatasource(row, position) {
|
|
7458
|
-
|
|
7459
|
-
if (this.datasource instanceof MemoryDatasource) {
|
|
7460
|
-
data = this.datasource.allData;
|
|
7461
|
-
}
|
|
7462
|
-
else {
|
|
7463
|
-
data = this.datasource.data;
|
|
7464
|
-
}
|
|
7421
|
+
const { data } = this.datasource;
|
|
7465
7422
|
row[this.newRowIdentifier] = true;
|
|
7423
|
+
row[this.positionIdentifier] = position;
|
|
7424
|
+
if (!row[this.pageIdentifier])
|
|
7425
|
+
row[this.pageIdentifier] = this.datasource.page;
|
|
7466
7426
|
if (position === 'start') {
|
|
7467
7427
|
data.unshift(row);
|
|
7468
7428
|
}
|
|
@@ -8473,16 +8433,11 @@ class WatchURL {
|
|
|
8473
8433
|
WatchURL.watchers = {};
|
|
8474
8434
|
WatchURL.originalEvents = new Map();
|
|
8475
8435
|
|
|
8476
|
-
class
|
|
8477
|
-
constructor() {
|
|
8478
|
-
this.
|
|
8479
|
-
|
|
8480
|
-
|
|
8481
|
-
MAX: 'MAX',
|
|
8482
|
-
MIN: 'MIN',
|
|
8483
|
-
SUM: 'SUM',
|
|
8484
|
-
};
|
|
8485
|
-
this.colunmXLS = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ';
|
|
8436
|
+
class ReportColumnTransformer {
|
|
8437
|
+
constructor({ getFormatFn, labelFormatter, fileType }) {
|
|
8438
|
+
this.getFormatFn = getFormatFn;
|
|
8439
|
+
this.labelFormatter = labelFormatter;
|
|
8440
|
+
this.fileType = fileType;
|
|
8486
8441
|
}
|
|
8487
8442
|
getColumnsWidth(columns) {
|
|
8488
8443
|
const widths = {};
|
|
@@ -8500,7 +8455,7 @@ class BaseReport {
|
|
|
8500
8455
|
}
|
|
8501
8456
|
return { widths, totalWidth };
|
|
8502
8457
|
}
|
|
8503
|
-
|
|
8458
|
+
transform(columns) {
|
|
8504
8459
|
const { widths, totalWidth } = this.getColumnsWidth(columns);
|
|
8505
8460
|
return columns.reduce((result, col, index) => {
|
|
8506
8461
|
let size;
|
|
@@ -8510,18 +8465,36 @@ class BaseReport {
|
|
|
8510
8465
|
else {
|
|
8511
8466
|
size = Math.floor((widths[col.name] * 100) / totalWidth);
|
|
8512
8467
|
}
|
|
8468
|
+
const description = this.labelFormatter ? this.labelFormatter({ column: col, fileType: this.fileType }) : col.label;
|
|
8469
|
+
const format = this.getFormatFn ? this.getFormatFn(col) : undefined;
|
|
8513
8470
|
const row = {
|
|
8471
|
+
format,
|
|
8472
|
+
description,
|
|
8514
8473
|
align: col.align || 'left',
|
|
8515
|
-
description: col.label,
|
|
8516
8474
|
sequence: index,
|
|
8517
8475
|
size: `${size}%`,
|
|
8476
|
+
xlsType: col.xlsType,
|
|
8518
8477
|
};
|
|
8519
|
-
if (col.xlsType) {
|
|
8520
|
-
row.xlsType = col.xlsType;
|
|
8521
|
-
}
|
|
8522
8478
|
return Object.assign(Object.assign({}, result), { [col.name]: row });
|
|
8523
8479
|
}, {});
|
|
8524
8480
|
}
|
|
8481
|
+
}
|
|
8482
|
+
|
|
8483
|
+
class BaseReport {
|
|
8484
|
+
constructor(labelFormatter) {
|
|
8485
|
+
this.expressionZeedhiToXls = {
|
|
8486
|
+
AVG: 'AVERAGE',
|
|
8487
|
+
COUNT: 'COUNTA',
|
|
8488
|
+
MAX: 'MAX',
|
|
8489
|
+
MIN: 'MIN',
|
|
8490
|
+
SUM: 'SUM',
|
|
8491
|
+
};
|
|
8492
|
+
this.colunmXLS = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ';
|
|
8493
|
+
this.reportColumnTransformer = this.getReportColumnTransformer(labelFormatter);
|
|
8494
|
+
}
|
|
8495
|
+
getReportColumnTransformer(labelFormatter) {
|
|
8496
|
+
return new ReportColumnTransformer({ labelFormatter, fileType: this.getFileType() });
|
|
8497
|
+
}
|
|
8525
8498
|
buildFilter(filter, columns) {
|
|
8526
8499
|
return Object.keys(filter).map((key) => {
|
|
8527
8500
|
var _a;
|
|
@@ -8544,6 +8517,9 @@ class CSVReport extends BaseReport {
|
|
|
8544
8517
|
super(...arguments);
|
|
8545
8518
|
this.route = '/generateCSV';
|
|
8546
8519
|
}
|
|
8520
|
+
getFileType() {
|
|
8521
|
+
return 'csv';
|
|
8522
|
+
}
|
|
8547
8523
|
buildDataset(data, columns) {
|
|
8548
8524
|
const columnNames = columns.map((col) => col.name);
|
|
8549
8525
|
const result = data.reduce((reduced, row) => {
|
|
@@ -8553,7 +8529,7 @@ class CSVReport extends BaseReport {
|
|
|
8553
8529
|
return JSON.stringify(result);
|
|
8554
8530
|
}
|
|
8555
8531
|
buildMetadata(name, title, columns, filter) {
|
|
8556
|
-
const builtCols = this.
|
|
8532
|
+
const builtCols = this.reportColumnTransformer.transform(columns);
|
|
8557
8533
|
const builtFilters = this.buildFilter(filter || {}, columns);
|
|
8558
8534
|
const lang = this.formatLangCode(I18n.instance.language);
|
|
8559
8535
|
const clientLogo = '';
|
|
@@ -8589,30 +8565,17 @@ class PDFReport extends BaseReport {
|
|
|
8589
8565
|
super(...arguments);
|
|
8590
8566
|
this.route = '/generateReport';
|
|
8591
8567
|
}
|
|
8568
|
+
getFileType() {
|
|
8569
|
+
return 'pdf';
|
|
8570
|
+
}
|
|
8571
|
+
getReportColumnTransformer(labelFormatter) {
|
|
8572
|
+
const getFormatFn = this.getFormatOfColumn.bind(this);
|
|
8573
|
+
const fileType = this.getFileType();
|
|
8574
|
+
return new ReportColumnTransformer({ getFormatFn, labelFormatter, fileType });
|
|
8575
|
+
}
|
|
8592
8576
|
buildDataset(data) {
|
|
8593
8577
|
return JSON.stringify(data);
|
|
8594
8578
|
}
|
|
8595
|
-
buildColumns(columns) {
|
|
8596
|
-
const { widths, totalWidth } = this.getColumnsWidth(columns);
|
|
8597
|
-
return columns.reduce((result, col, index) => {
|
|
8598
|
-
let size;
|
|
8599
|
-
if (!totalWidth) {
|
|
8600
|
-
size = Math.floor(100 / columns.length);
|
|
8601
|
-
}
|
|
8602
|
-
else {
|
|
8603
|
-
size = Math.floor((widths[col.name] * 100) / totalWidth);
|
|
8604
|
-
}
|
|
8605
|
-
const row = {
|
|
8606
|
-
align: col.align || 'left',
|
|
8607
|
-
description: col.label,
|
|
8608
|
-
sequence: index,
|
|
8609
|
-
format: this.getFormatOfColumn(col),
|
|
8610
|
-
size: `${size}%`,
|
|
8611
|
-
xlsType: col.xlsType,
|
|
8612
|
-
};
|
|
8613
|
-
return Object.assign(Object.assign({}, result), { [col.name]: row });
|
|
8614
|
-
}, {});
|
|
8615
|
-
}
|
|
8616
8579
|
getFormatOfColumn(column) {
|
|
8617
8580
|
let format;
|
|
8618
8581
|
let { mask } = column;
|
|
@@ -8660,7 +8623,7 @@ class PDFReport extends BaseReport {
|
|
|
8660
8623
|
}
|
|
8661
8624
|
buildMetadata(name, title, columns, filter, portrait = true) {
|
|
8662
8625
|
return __awaiter(this, void 0, void 0, function* () {
|
|
8663
|
-
const builtCols = this.
|
|
8626
|
+
const builtCols = this.reportColumnTransformer.transform(columns);
|
|
8664
8627
|
const builtFilters = this.buildFilter(filter || {}, columns);
|
|
8665
8628
|
const lang = this.formatLangCode(I18n.instance.language);
|
|
8666
8629
|
let clientLogo = '';
|
|
@@ -8745,6 +8708,9 @@ class XLSReport extends BaseReport {
|
|
|
8745
8708
|
super(...arguments);
|
|
8746
8709
|
this.route = '/generateXLS';
|
|
8747
8710
|
}
|
|
8711
|
+
getFileType() {
|
|
8712
|
+
return 'xls';
|
|
8713
|
+
}
|
|
8748
8714
|
buildDataset(data, columns) {
|
|
8749
8715
|
const result = this.formatRawDataSet(data, columns);
|
|
8750
8716
|
return JSON.stringify(result);
|
|
@@ -8759,7 +8725,7 @@ class XLSReport extends BaseReport {
|
|
|
8759
8725
|
return result;
|
|
8760
8726
|
}
|
|
8761
8727
|
buildMetadata(name, title, columns, filter) {
|
|
8762
|
-
const builtCols = this.
|
|
8728
|
+
const builtCols = this.reportColumnTransformer.transform(columns);
|
|
8763
8729
|
const builtFilters = this.buildFilter(filter || {}, columns);
|
|
8764
8730
|
const lang = this.formatLangCode(I18n.instance.language);
|
|
8765
8731
|
const clientLogo = '';
|
|
@@ -8799,12 +8765,15 @@ class XLS2Report extends BaseReport {
|
|
|
8799
8765
|
super(...arguments);
|
|
8800
8766
|
this.route = '/generateXLS';
|
|
8801
8767
|
}
|
|
8768
|
+
getFileType() {
|
|
8769
|
+
return 'xls';
|
|
8770
|
+
}
|
|
8802
8771
|
buildDataset(data, metadata) {
|
|
8803
8772
|
const result = this.formatDataSet(metadata, data);
|
|
8804
8773
|
return JSON.stringify(result);
|
|
8805
8774
|
}
|
|
8806
8775
|
buildMetadata(name, title, columns, filter) {
|
|
8807
|
-
const builtCols = this.
|
|
8776
|
+
const builtCols = this.reportColumnTransformer.transform(columns);
|
|
8808
8777
|
const builtFilters = this.buildFilter(filter || {}, columns);
|
|
8809
8778
|
const lang = this.formatLangCode(I18n.instance.language);
|
|
8810
8779
|
const clientLogo = '';
|
|
@@ -8996,12 +8965,15 @@ class XLS3Report extends BaseReport {
|
|
|
8996
8965
|
super(...arguments);
|
|
8997
8966
|
this.route = '/generateXLS';
|
|
8998
8967
|
}
|
|
8968
|
+
getFileType() {
|
|
8969
|
+
return 'xls';
|
|
8970
|
+
}
|
|
8999
8971
|
buildDataset(data, metadata) {
|
|
9000
8972
|
const result = this.formatDataSet(metadata, data);
|
|
9001
8973
|
return JSON.stringify(result);
|
|
9002
8974
|
}
|
|
9003
8975
|
buildMetadata(name, title, columns, filter) {
|
|
9004
|
-
const builtCols = this.
|
|
8976
|
+
const builtCols = this.reportColumnTransformer.transform(columns);
|
|
9005
8977
|
const builtFilters = this.buildFilter(filter || {}, columns);
|
|
9006
8978
|
const lang = this.formatLangCode(I18n.instance.language);
|
|
9007
8979
|
const clientLogo = '';
|
|
@@ -9288,25 +9260,25 @@ class Report {
|
|
|
9288
9260
|
return formattedData;
|
|
9289
9261
|
});
|
|
9290
9262
|
}
|
|
9291
|
-
getReportType(type) {
|
|
9263
|
+
getReportType(type, labelFormatter) {
|
|
9292
9264
|
if (type === 'csv') {
|
|
9293
|
-
return new CSVReport();
|
|
9265
|
+
return new CSVReport(labelFormatter);
|
|
9294
9266
|
}
|
|
9295
9267
|
if (type === 'pdf') {
|
|
9296
|
-
return new PDFReport();
|
|
9268
|
+
return new PDFReport(labelFormatter);
|
|
9297
9269
|
}
|
|
9298
9270
|
if (type === 'xls') {
|
|
9299
|
-
return new XLSReport();
|
|
9271
|
+
return new XLSReport(labelFormatter);
|
|
9300
9272
|
}
|
|
9301
9273
|
if (type === 'xls2') {
|
|
9302
|
-
return new XLS2Report();
|
|
9274
|
+
return new XLS2Report(labelFormatter);
|
|
9303
9275
|
}
|
|
9304
9276
|
if (type === 'xls3') {
|
|
9305
|
-
return new XLS3Report();
|
|
9277
|
+
return new XLS3Report(labelFormatter);
|
|
9306
9278
|
}
|
|
9307
9279
|
throw new Error(`Invalid report type: ${type}`);
|
|
9308
9280
|
}
|
|
9309
|
-
getReport(type, portrait = true, rowObj, beforeReportEvent) {
|
|
9281
|
+
getReport(type, portrait = true, rowObj, beforeReportEvent, labelFormatter) {
|
|
9310
9282
|
var _a;
|
|
9311
9283
|
return __awaiter(this, void 0, void 0, function* () {
|
|
9312
9284
|
const data = (_a = this.data) !== null && _a !== void 0 ? _a : yield this.getData();
|
|
@@ -9317,7 +9289,7 @@ class Report {
|
|
|
9317
9289
|
containerLabel: this.title,
|
|
9318
9290
|
widgetLabel: this.title,
|
|
9319
9291
|
};
|
|
9320
|
-
const reportType = this.getReportType(type);
|
|
9292
|
+
const reportType = this.getReportType(type, labelFormatter);
|
|
9321
9293
|
const { route } = reportType;
|
|
9322
9294
|
const { name, columns, datasource } = this.iterable;
|
|
9323
9295
|
const { groupedData } = Object.assign({}, this.iterable);
|
|
@@ -12475,6 +12447,7 @@ class SelectMultiple extends Select {
|
|
|
12475
12447
|
this.limit = null;
|
|
12476
12448
|
this.showSelectAll = false;
|
|
12477
12449
|
this.showCheckboxAll = false;
|
|
12450
|
+
this.formatterFn = FormatterParserProvider.getFormatter('ZdSelectMultiple');
|
|
12478
12451
|
this.checkboxAllValue = false;
|
|
12479
12452
|
if (!this.selectedValue) {
|
|
12480
12453
|
this.selectedValue = [];
|
|
@@ -12691,22 +12664,6 @@ class SelectMultiple extends Select {
|
|
|
12691
12664
|
});
|
|
12692
12665
|
this.insertsRemoved = [];
|
|
12693
12666
|
}
|
|
12694
|
-
/**
|
|
12695
|
-
* Return formatted dataText and values
|
|
12696
|
-
*/
|
|
12697
|
-
formatter(value) {
|
|
12698
|
-
if (!value || value.length === 0) {
|
|
12699
|
-
return [];
|
|
12700
|
-
}
|
|
12701
|
-
const selectFormatter = FormatterParserProvider.getFormatter('ZdSelect');
|
|
12702
|
-
const formattedValue = value.map((row) => {
|
|
12703
|
-
const isDisabled = this.dataDisabled && row[this.dataDisabled];
|
|
12704
|
-
const formattedRow = { value: row[this.dataValue], disabled: isDisabled, originalRow: row };
|
|
12705
|
-
formattedRow.text = selectFormatter(row, this);
|
|
12706
|
-
return formattedRow;
|
|
12707
|
-
});
|
|
12708
|
-
return formattedValue;
|
|
12709
|
-
}
|
|
12710
12667
|
/**
|
|
12711
12668
|
* Returns the text shown when there's one or more selected items that doesn't fit in the input
|
|
12712
12669
|
*/
|
|
@@ -12952,7 +12909,21 @@ class SelectMultiple extends Select {
|
|
|
12952
12909
|
};
|
|
12953
12910
|
return modalSelectionDef;
|
|
12954
12911
|
}
|
|
12955
|
-
}
|
|
12912
|
+
}
|
|
12913
|
+
FormatterParserProvider.registerFormatter('ZdSelectMultiple', (value, props) => {
|
|
12914
|
+
const { dataDisabled, dataValue } = props;
|
|
12915
|
+
if (!value || value.length === 0) {
|
|
12916
|
+
return [];
|
|
12917
|
+
}
|
|
12918
|
+
const selectFormatter = FormatterParserProvider.getFormatter('ZdSelect');
|
|
12919
|
+
const formattedValue = value.map((row) => {
|
|
12920
|
+
const isDisabled = dataDisabled && row[dataDisabled];
|
|
12921
|
+
const formattedRow = { value: row[dataValue], disabled: isDisabled, originalRow: row };
|
|
12922
|
+
formattedRow.text = selectFormatter(row, props);
|
|
12923
|
+
return formattedRow;
|
|
12924
|
+
});
|
|
12925
|
+
return formattedValue;
|
|
12926
|
+
});
|
|
12956
12927
|
|
|
12957
12928
|
/**
|
|
12958
12929
|
* Base class for Select Tree component.
|
|
@@ -13043,7 +13014,6 @@ class SelectTree extends TextInput {
|
|
|
13043
13014
|
* Defines if should wait and not execute GET method when Datasource is created
|
|
13044
13015
|
*/
|
|
13045
13016
|
this.lazyLoad = true;
|
|
13046
|
-
this.selectValue = null;
|
|
13047
13017
|
/**
|
|
13048
13018
|
* Uses delayed loading to load tree branches
|
|
13049
13019
|
*/
|
|
@@ -13064,7 +13034,9 @@ class SelectTree extends TextInput {
|
|
|
13064
13034
|
* Defines the name of the form target to set using dataValueOut
|
|
13065
13035
|
*/
|
|
13066
13036
|
this.dataValueOutFormName = '';
|
|
13037
|
+
this.formatterFn = FormatterParserProvider.getFormatter('ZdSelectTree');
|
|
13067
13038
|
this.savedNodes = undefined;
|
|
13039
|
+
this.search = '';
|
|
13068
13040
|
this.debounceSearch = debounce(this.searchChange, 500);
|
|
13069
13041
|
this.nodes = this.getInitValue('nodes', props.nodes, this.nodes);
|
|
13070
13042
|
this.alwaysOpen = this.getInitValue('alwaysOpen', props.alwaysOpen, this.alwaysOpen);
|
|
@@ -13084,7 +13056,6 @@ class SelectTree extends TextInput {
|
|
|
13084
13056
|
this.dataValue = this.getInitValue('dataValue', props.dataValue, this.dataValue);
|
|
13085
13057
|
this.dataDisabled = this.getInitValue('dataDisabled', props.dataDisabled, this.dataDisabled);
|
|
13086
13058
|
this.disabledItems = this.getInitValue('disabledItems', props.disabledItems, this.disabledItems);
|
|
13087
|
-
this.preventLoadOnFocus = this.getInitValue('preventLoadOnFocus', props.preventLoadOnFocus, this.preventLoadOnFocus);
|
|
13088
13059
|
this.fetchOnDemand = this.getInitValue('fetchOnDemand', props.fetchOnDemand, this.fetchOnDemand);
|
|
13089
13060
|
this.fieldHasChild = this.getInitValue('fieldHasChild', props.fieldHasChild, this.fieldHasChild);
|
|
13090
13061
|
this.menuMaxWidth = this.getInitValue('menuMaxWidth', props.menuMaxWidth, this.menuMaxWidth);
|
|
@@ -13102,8 +13073,21 @@ class SelectTree extends TextInput {
|
|
|
13102
13073
|
this.datasource = DatasourceFactory.factory(Object.assign(Object.assign({}, props.datasource), { searchIn: props.datasource.searchIn || searchFieldNames, lazyLoad: true, loadAll: true }));
|
|
13103
13074
|
this.createDataStructure();
|
|
13104
13075
|
}
|
|
13076
|
+
if (this.dataTextDiscrete && !Array.isArray(this.dataTextDiscrete))
|
|
13077
|
+
this.dataTextDiscrete = [this.dataTextDiscrete];
|
|
13078
|
+
this.discreteProps = {
|
|
13079
|
+
dataText: this.dataTextDiscrete,
|
|
13080
|
+
dataTextSeparator: this.dataTextSeparator,
|
|
13081
|
+
};
|
|
13082
|
+
this.preventLoadOnFocus = !this.datasource || !this.lazyLoad;
|
|
13083
|
+
this.preventLoadOnFocus = this.getInitValue('preventLoadOnFocus', props.preventLoadOnFocus, this.preventLoadOnFocus);
|
|
13084
|
+
this.value = this.getInitValue('value', props.value, this.value);
|
|
13105
13085
|
this.createAccessors();
|
|
13106
13086
|
}
|
|
13087
|
+
/**
|
|
13088
|
+
* Returns the currentRow in the dataText key
|
|
13089
|
+
*/
|
|
13090
|
+
formatter(value, props) { return this.formatterFn(value, props !== null && props !== void 0 ? props : this); }
|
|
13107
13091
|
focus(event, element) {
|
|
13108
13092
|
const _super = Object.create(null, {
|
|
13109
13093
|
focus: { get: () => super.focus }
|
|
@@ -13158,8 +13142,8 @@ class SelectTree extends TextInput {
|
|
|
13158
13142
|
children = undefined;
|
|
13159
13143
|
}
|
|
13160
13144
|
}
|
|
13161
|
-
const dataText = this.
|
|
13162
|
-
const dataTextDiscrete = this.
|
|
13145
|
+
const dataText = this.formatter(row);
|
|
13146
|
+
const dataTextDiscrete = this.formatter(row, this.discreteProps);
|
|
13163
13147
|
return {
|
|
13164
13148
|
id: row[this.dataValue],
|
|
13165
13149
|
label: dataText,
|
|
@@ -13179,40 +13163,6 @@ class SelectTree extends TextInput {
|
|
|
13179
13163
|
});
|
|
13180
13164
|
return newNodes;
|
|
13181
13165
|
}
|
|
13182
|
-
formatRow(dataText, row) {
|
|
13183
|
-
const dataTextArr = Array.isArray(dataText) ? dataText : [dataText];
|
|
13184
|
-
const dataTextNames = [];
|
|
13185
|
-
const masks = [];
|
|
13186
|
-
dataTextArr.forEach((text) => {
|
|
13187
|
-
if (typeof text === 'string') {
|
|
13188
|
-
dataTextNames.push(text);
|
|
13189
|
-
masks.push('');
|
|
13190
|
-
}
|
|
13191
|
-
else {
|
|
13192
|
-
dataTextNames.push(text.name);
|
|
13193
|
-
if (Accessor.isAccessorDefinition(text.mask)) {
|
|
13194
|
-
const [controller, accessor] = Accessor.getAccessor(text.mask);
|
|
13195
|
-
masks.push(Loader.getInstance(controller)[accessor]);
|
|
13196
|
-
}
|
|
13197
|
-
else {
|
|
13198
|
-
masks.push(text.mask);
|
|
13199
|
-
}
|
|
13200
|
-
}
|
|
13201
|
-
});
|
|
13202
|
-
const rowText = dataTextNames.reduce((result, column, index) => {
|
|
13203
|
-
if (row[column]) {
|
|
13204
|
-
const separator = index > 0 ? this.dataTextSeparator : '';
|
|
13205
|
-
let masked = row[column];
|
|
13206
|
-
if (masks[index]) {
|
|
13207
|
-
const maskValue = typeof masks[index] === 'function' ? masks[index](row[column]) : masks[index];
|
|
13208
|
-
masked = Mask.getValueWithMask(row[column], maskValue);
|
|
13209
|
-
}
|
|
13210
|
-
return result + separator + masked;
|
|
13211
|
-
}
|
|
13212
|
-
return result;
|
|
13213
|
-
}, '');
|
|
13214
|
-
return rowText;
|
|
13215
|
-
}
|
|
13216
13166
|
/**
|
|
13217
13167
|
* Triggered when the menu opens
|
|
13218
13168
|
*/
|
|
@@ -13236,6 +13186,7 @@ class SelectTree extends TextInput {
|
|
|
13236
13186
|
* Triggered after the search query changes
|
|
13237
13187
|
*/
|
|
13238
13188
|
searchChange(searchQuery, element) {
|
|
13189
|
+
this.search = searchQuery;
|
|
13239
13190
|
if (this.fetchOnDemand) {
|
|
13240
13191
|
if (!searchQuery && this.savedNodes) {
|
|
13241
13192
|
this.nodes = this.savedNodes;
|
|
@@ -13323,7 +13274,7 @@ class SelectTree extends TextInput {
|
|
|
13323
13274
|
if (!this.selectValue)
|
|
13324
13275
|
return this.selectValue;
|
|
13325
13276
|
if (this.returnObject) {
|
|
13326
|
-
return this.clearRow(this.selectValue.row);
|
|
13277
|
+
return this.clearRow(this.selectValue.row || this.selectValue);
|
|
13327
13278
|
}
|
|
13328
13279
|
return this.selectValue;
|
|
13329
13280
|
}
|
|
@@ -13370,6 +13321,8 @@ class SelectTree extends TextInput {
|
|
|
13370
13321
|
}
|
|
13371
13322
|
}
|
|
13372
13323
|
}
|
|
13324
|
+
const selectFormatterFn$1 = FormatterParserProvider.getFormatter('ZdSelect');
|
|
13325
|
+
FormatterParserProvider.registerFormatter('ZdSelectTree', selectFormatterFn$1);
|
|
13373
13326
|
InputFactory.register('ZdSelectTree', SelectTree);
|
|
13374
13327
|
|
|
13375
13328
|
/**
|
|
@@ -13394,7 +13347,6 @@ class SelectTreeMultiple extends SelectTree {
|
|
|
13394
13347
|
* Selected Nodes
|
|
13395
13348
|
*/
|
|
13396
13349
|
this.selectedNodes = [];
|
|
13397
|
-
this.selectValue = [];
|
|
13398
13350
|
/**
|
|
13399
13351
|
* Changes the behavior of checked nodes that will be displayed in the array of values
|
|
13400
13352
|
*/
|
|
@@ -13422,19 +13374,25 @@ class SelectTreeMultiple extends SelectTree {
|
|
|
13422
13374
|
this.callEvent('onDeselect', { element, component: this, node });
|
|
13423
13375
|
}
|
|
13424
13376
|
get value() {
|
|
13377
|
+
if (!this.selectValue)
|
|
13378
|
+
return [];
|
|
13425
13379
|
if (this.returnObject) {
|
|
13426
|
-
return this.selectValue.map((value) => this.clearRow(value.row));
|
|
13380
|
+
return this.selectValue.map((value) => this.clearRow(value.row || value));
|
|
13427
13381
|
}
|
|
13428
13382
|
return this.selectValue;
|
|
13429
13383
|
}
|
|
13430
13384
|
set value(value) {
|
|
13431
|
-
this.
|
|
13385
|
+
this.setValue(value);
|
|
13432
13386
|
}
|
|
13433
13387
|
setValue(value) {
|
|
13388
|
+
if (!value) {
|
|
13389
|
+
this.selectValue = [];
|
|
13390
|
+
return;
|
|
13391
|
+
}
|
|
13434
13392
|
const arrValue = Array.isArray(value) ? value : [value];
|
|
13435
13393
|
const key = this.datasource ? this.dataValue : 'id';
|
|
13436
13394
|
if (!this.returnObject) {
|
|
13437
|
-
this.
|
|
13395
|
+
this.selectValue = arrValue.map((item) => {
|
|
13438
13396
|
if (typeof item === 'object') {
|
|
13439
13397
|
return item[key];
|
|
13440
13398
|
}
|
|
@@ -13442,19 +13400,27 @@ class SelectTreeMultiple extends SelectTree {
|
|
|
13442
13400
|
});
|
|
13443
13401
|
return;
|
|
13444
13402
|
}
|
|
13445
|
-
this.
|
|
13403
|
+
this.selectValue = arrValue.map((item) => {
|
|
13446
13404
|
if (typeof item !== 'object') {
|
|
13447
13405
|
return { id: item };
|
|
13448
13406
|
}
|
|
13449
13407
|
return { id: item[key] };
|
|
13450
13408
|
});
|
|
13451
13409
|
}
|
|
13452
|
-
|
|
13453
|
-
|
|
13410
|
+
/**
|
|
13411
|
+
* Retrieves all nodes in the tree as a flat array. Nodes that are not matched are excluded
|
|
13412
|
+
* Nodes that are not matched but whose parent is matched are included
|
|
13413
|
+
* @param nodes
|
|
13414
|
+
* @param matched defines whether the parent of the current node branch is matched
|
|
13415
|
+
* @returns all nodes in the tree as a flat array, filtering unmatched nodes
|
|
13416
|
+
*/
|
|
13417
|
+
getAllNodes(nodes = this.nodes, matched = true) {
|
|
13418
|
+
let result = [...nodes];
|
|
13419
|
+
result = result.filter((node) => node.isMatched || matched);
|
|
13454
13420
|
nodes.forEach((node) => {
|
|
13455
13421
|
if (!node.children)
|
|
13456
13422
|
return;
|
|
13457
|
-
const childNodes = this.getAllNodes(node.children);
|
|
13423
|
+
const childNodes = this.getAllNodes(node.children, node.isMatched || matched);
|
|
13458
13424
|
result = [...result, ...childNodes];
|
|
13459
13425
|
});
|
|
13460
13426
|
return result;
|
|
@@ -13462,28 +13428,96 @@ class SelectTreeMultiple extends SelectTree {
|
|
|
13462
13428
|
/**
|
|
13463
13429
|
* Dispatches select/unselect event
|
|
13464
13430
|
*/
|
|
13465
|
-
onSelectAll(isSelected, event, element) {
|
|
13431
|
+
onSelectAll(isSelected, event, element, nodes = this.nodes) {
|
|
13466
13432
|
if (isSelected) {
|
|
13467
13433
|
this.callEvent('selectedAll', { event, element, component: this });
|
|
13468
13434
|
if (!event.defaultPrevented) {
|
|
13469
|
-
this.selectAllItems();
|
|
13435
|
+
this.selectAllItems(nodes);
|
|
13470
13436
|
}
|
|
13471
13437
|
}
|
|
13472
13438
|
else {
|
|
13473
13439
|
this.callEvent('unselectedAll', { event, element, component: this });
|
|
13474
13440
|
if (!event.defaultPrevented) {
|
|
13475
|
-
this.unSelectAllItems();
|
|
13441
|
+
this.unSelectAllItems(nodes);
|
|
13476
13442
|
}
|
|
13477
13443
|
}
|
|
13478
13444
|
}
|
|
13479
|
-
|
|
13480
|
-
|
|
13481
|
-
|
|
13445
|
+
/**
|
|
13446
|
+
* Selects all items in the tree \
|
|
13447
|
+
* If the component is fetchOnDemand, it will select all values from datasource.data \
|
|
13448
|
+
* If not, it will select all nodes from the tree, unless the nodes to be selected are specified
|
|
13449
|
+
* @param nodes nodes to be selected. These are the nodes that are currently visible in the tree
|
|
13450
|
+
* (if the user is searching, selects only the searched nodes)
|
|
13451
|
+
* @returns
|
|
13452
|
+
*/
|
|
13453
|
+
selectAllItems(nodes = this.nodes) {
|
|
13454
|
+
var _a;
|
|
13455
|
+
if (((_a = this.datasource) === null || _a === void 0 ? void 0 : _a.data) && this.fetchOnDemand) {
|
|
13456
|
+
this.setValue(this.datasource.data);
|
|
13457
|
+
return;
|
|
13458
|
+
}
|
|
13459
|
+
const allNodes = this.getAllNodes(nodes, !this.search);
|
|
13460
|
+
// merge all nodes with the current value before setting it
|
|
13461
|
+
const currentValue = this.getValueAsObject();
|
|
13462
|
+
const nodeMap = this.createMergeMap(currentValue, allNodes);
|
|
13463
|
+
const uniqueArray = Array.from(nodeMap.values());
|
|
13464
|
+
this.setValue(uniqueArray);
|
|
13482
13465
|
}
|
|
13483
|
-
|
|
13484
|
-
|
|
13466
|
+
/**
|
|
13467
|
+
* Unelects all items in the tree \
|
|
13468
|
+
* If the component is fetchOnDemand, it will select all values from datasource.data \
|
|
13469
|
+
* If not, it will select all nodes from the tree, unless the nodes to be selected are specified
|
|
13470
|
+
* @param nodes nodes to be selected. These are the nodes that are currently visible in the tree
|
|
13471
|
+
* (if the user is searching, selects only the searched nodes)
|
|
13472
|
+
* @returns
|
|
13473
|
+
*/
|
|
13474
|
+
unSelectAllItems(nodes = this.nodes) {
|
|
13475
|
+
var _a;
|
|
13476
|
+
if (((_a = this.datasource) === null || _a === void 0 ? void 0 : _a.data) && this.fetchOnDemand) {
|
|
13477
|
+
this.setValue([]);
|
|
13478
|
+
return;
|
|
13479
|
+
}
|
|
13480
|
+
const allNodes = this.getAllNodes(nodes, !this.search);
|
|
13481
|
+
// merge all nodes with the current value before setting it
|
|
13482
|
+
const currentValue = this.getValueAsObject();
|
|
13483
|
+
const nodeMap = this.createMergeMap(currentValue);
|
|
13484
|
+
// remove the current visible nodes from the array
|
|
13485
|
+
const valuesToRemove = allNodes.map((node) => node.id);
|
|
13486
|
+
valuesToRemove.forEach((value) => {
|
|
13487
|
+
nodeMap.delete(value);
|
|
13488
|
+
});
|
|
13489
|
+
const uniqueArray = Array.from(nodeMap.values());
|
|
13490
|
+
this.setValue(uniqueArray);
|
|
13485
13491
|
}
|
|
13486
|
-
|
|
13492
|
+
/**
|
|
13493
|
+
* Takes two arrays and creates a map of the unique values
|
|
13494
|
+
* @returns map of a merge between the two arrays, removing duplicates
|
|
13495
|
+
*/
|
|
13496
|
+
createMergeMap(arr1, arr2 = []) {
|
|
13497
|
+
const mergedNodes = arr1.concat(arr2);
|
|
13498
|
+
// filter out duplicate nodes
|
|
13499
|
+
const uniqueMap = new Map();
|
|
13500
|
+
mergedNodes.forEach((node) => {
|
|
13501
|
+
uniqueMap.set(node.id, node);
|
|
13502
|
+
});
|
|
13503
|
+
return uniqueMap;
|
|
13504
|
+
}
|
|
13505
|
+
getValueIds() {
|
|
13506
|
+
if (this.returnObject) {
|
|
13507
|
+
return this.value.map((item) => item.id);
|
|
13508
|
+
}
|
|
13509
|
+
return this.value;
|
|
13510
|
+
}
|
|
13511
|
+
getValueAsObject() {
|
|
13512
|
+
return this.value.map((row) => {
|
|
13513
|
+
if (this.returnObject)
|
|
13514
|
+
return row;
|
|
13515
|
+
return { id: row };
|
|
13516
|
+
});
|
|
13517
|
+
}
|
|
13518
|
+
}
|
|
13519
|
+
const selectFormatterFn = FormatterParserProvider.getFormatter('ZdSelectMultiple');
|
|
13520
|
+
FormatterParserProvider.registerFormatter('ZdSelectTreeMultiple', selectFormatterFn);
|
|
13487
13521
|
|
|
13488
13522
|
/**
|
|
13489
13523
|
* Base class for SelectableList component.
|
|
@@ -15860,6 +15894,131 @@ class TreeGridEditable extends TreeGrid {
|
|
|
15860
15894
|
}
|
|
15861
15895
|
}
|
|
15862
15896
|
|
|
15897
|
+
const asArray = (value) => (Array.isArray(value) ? value : [value]);
|
|
15898
|
+
const getForeignLookupRow = (column, row, dataValue, dataTextColumns, foreignColumns) => {
|
|
15899
|
+
const lookupRow = {};
|
|
15900
|
+
dataTextColumns.forEach((item) => {
|
|
15901
|
+
const dataTextName = typeof item === 'string' ? item : item.name;
|
|
15902
|
+
lookupRow[dataTextName] = row[foreignColumns[dataTextName] || dataTextName];
|
|
15903
|
+
});
|
|
15904
|
+
lookupRow[dataValue] = row[column.name];
|
|
15905
|
+
return lookupRow;
|
|
15906
|
+
};
|
|
15907
|
+
const getFormatterLookupRow = (column, row, dataValue, formatterDataTextColumns, dataTextColumns) => {
|
|
15908
|
+
const lookupRow = {};
|
|
15909
|
+
formatterDataTextColumns.forEach((item, index) => {
|
|
15910
|
+
const dataTextValue = dataTextColumns[index];
|
|
15911
|
+
const dataTextName = typeof dataTextValue === 'string' ? dataTextValue : dataTextValue.name;
|
|
15912
|
+
const formatterDataTextColumn = typeof item === 'string' ? item : item.name;
|
|
15913
|
+
lookupRow[dataTextName] = row[formatterDataTextColumn];
|
|
15914
|
+
});
|
|
15915
|
+
lookupRow[dataValue] = row[column.name];
|
|
15916
|
+
return lookupRow;
|
|
15917
|
+
};
|
|
15918
|
+
/**
|
|
15919
|
+
* Stores data in column.lookupData when using foreignColumns or formatterDataText.
|
|
15920
|
+
* Makes a lookup when not using foreignColumns or formatterDataText
|
|
15921
|
+
* @returns the row from grid's datasource when using foreignColumns or formatterDataText. Otherwise,
|
|
15922
|
+
* returns the row from the column's component datasource
|
|
15923
|
+
*/
|
|
15924
|
+
const storeOrRetrieveLookup = (column, row, value, dataValue, componentProps) => {
|
|
15925
|
+
const { dataText, foreignColumns, formatterDataText, } = componentProps;
|
|
15926
|
+
const dataTextColumns = asArray(dataText);
|
|
15927
|
+
// when using foreignColumns, should store foreign keys information in lookupData
|
|
15928
|
+
if (foreignColumns) {
|
|
15929
|
+
column.lookupData[row[column.name]] = getForeignLookupRow(column, row, dataValue, dataTextColumns, foreignColumns);
|
|
15930
|
+
return row;
|
|
15931
|
+
}
|
|
15932
|
+
// when not using formatterDataText, should fetch data from datasource to be able to format this cell
|
|
15933
|
+
if (!formatterDataText) {
|
|
15934
|
+
return column.getLookupData(dataValue, value[dataValue] || value);
|
|
15935
|
+
}
|
|
15936
|
+
const formatterDataTextColumns = asArray(formatterDataText);
|
|
15937
|
+
// when using formatterDataText, should store dataText information in lookupData
|
|
15938
|
+
if (formatterDataTextColumns.length === dataTextColumns.length) {
|
|
15939
|
+
const rowColumn = row[column.name];
|
|
15940
|
+
column.lookupData[rowColumn] = getFormatterLookupRow(column, row, dataValue, formatterDataTextColumns, dataTextColumns);
|
|
15941
|
+
return row;
|
|
15942
|
+
}
|
|
15943
|
+
return row;
|
|
15944
|
+
};
|
|
15945
|
+
const formatter$1 = ({ column, value, row, componentProps, }) => {
|
|
15946
|
+
if (value === null || value === undefined)
|
|
15947
|
+
return '';
|
|
15948
|
+
const { dataText, formatterDataText, dataTextSeparator, dataValue, dataTextDiscrete, foreignColumns, } = componentProps;
|
|
15949
|
+
let currentRow = row;
|
|
15950
|
+
const dataTextColumns = asArray(dataText);
|
|
15951
|
+
// when dataValue is defined, should try to store or retrieve row data from lookupData
|
|
15952
|
+
if (dataValue) {
|
|
15953
|
+
currentRow = storeOrRetrieveLookup(column, row, value, dataValue, componentProps);
|
|
15954
|
+
}
|
|
15955
|
+
if (!Object.keys(currentRow).length)
|
|
15956
|
+
return typeof value === 'object' ? '' : value;
|
|
15957
|
+
let dataTextForeign = dataText;
|
|
15958
|
+
if (dataText && foreignColumns) {
|
|
15959
|
+
if (typeof dataText === 'string') {
|
|
15960
|
+
dataTextForeign = foreignColumns[dataText] || dataText;
|
|
15961
|
+
}
|
|
15962
|
+
else {
|
|
15963
|
+
dataTextForeign = dataTextColumns.map((item) => {
|
|
15964
|
+
const itemName = typeof item === 'string' ? item : item.name;
|
|
15965
|
+
return foreignColumns[itemName] || itemName;
|
|
15966
|
+
});
|
|
15967
|
+
}
|
|
15968
|
+
}
|
|
15969
|
+
const textColumn = dataTextDiscrete || formatterDataText || dataTextForeign;
|
|
15970
|
+
if (!textColumn)
|
|
15971
|
+
return value;
|
|
15972
|
+
if (typeof textColumn === 'string') {
|
|
15973
|
+
return currentRow[textColumn] || value;
|
|
15974
|
+
}
|
|
15975
|
+
const formatterFn = FormatterParserProvider.getFormatter('ZdSelect');
|
|
15976
|
+
return formatterFn(currentRow, { dataText: textColumn, dataTextSeparator });
|
|
15977
|
+
};
|
|
15978
|
+
FormatterParserProvider.registerFormatter('column_ZdSelect', formatter$1);
|
|
15979
|
+
FormatterParserProvider.registerFormatter('column_ZdSelectTree', formatter$1);
|
|
15980
|
+
|
|
15981
|
+
const formatter = ({ column, value, row, componentProps, }) => {
|
|
15982
|
+
if (!value || !Array.isArray(value) || value.length === 0)
|
|
15983
|
+
return '';
|
|
15984
|
+
const { formatterDataText, foreignColumns, dataText } = componentProps;
|
|
15985
|
+
const formatterFn = FormatterParserProvider.getFormatter('column_ZdSelect');
|
|
15986
|
+
const result = value.map((item, index) => {
|
|
15987
|
+
let formatterRow = Object.assign({}, row);
|
|
15988
|
+
const rowOverride = {};
|
|
15989
|
+
if (formatterDataText && formatterDataText.length > 0) {
|
|
15990
|
+
const columns = Array.isArray(formatterDataText) ? formatterDataText : [formatterDataText];
|
|
15991
|
+
columns.forEach((col) => {
|
|
15992
|
+
const textName = typeof col === 'string' ? col : col.name;
|
|
15993
|
+
rowOverride[textName] = row[textName][index];
|
|
15994
|
+
});
|
|
15995
|
+
formatterRow = Object.assign(Object.assign({}, row), rowOverride);
|
|
15996
|
+
}
|
|
15997
|
+
else if (foreignColumns && dataText) {
|
|
15998
|
+
let dataTextForeign = dataText;
|
|
15999
|
+
if (typeof dataText === 'string') {
|
|
16000
|
+
dataTextForeign = [foreignColumns[dataText] || dataText];
|
|
16001
|
+
}
|
|
16002
|
+
else {
|
|
16003
|
+
dataTextForeign = dataText.map((col) => {
|
|
16004
|
+
const colName = typeof col === 'string' ? col : col.name;
|
|
16005
|
+
return foreignColumns[colName] || colName;
|
|
16006
|
+
});
|
|
16007
|
+
}
|
|
16008
|
+
dataTextForeign.forEach((col) => {
|
|
16009
|
+
rowOverride[col] = row[col][index];
|
|
16010
|
+
});
|
|
16011
|
+
formatterRow = Object.assign(Object.assign({}, row), rowOverride);
|
|
16012
|
+
}
|
|
16013
|
+
return formatterFn({
|
|
16014
|
+
column, value: item, row: formatterRow, componentProps,
|
|
16015
|
+
});
|
|
16016
|
+
});
|
|
16017
|
+
return result.join(', ');
|
|
16018
|
+
};
|
|
16019
|
+
FormatterParserProvider.registerFormatter('column_ZdSelectMultiple', formatter);
|
|
16020
|
+
FormatterParserProvider.registerFormatter('column_ZdSelectTreeMultiple', formatter);
|
|
16021
|
+
|
|
15863
16022
|
const AutoNumeric = require('@zeedhi/autonumeric/dist/autoNumeric');
|
|
15864
16023
|
const packageContent = require('../package.json');
|
|
15865
16024
|
VersionService.addPackageVersion(packageContent.name, packageContent.version);
|