@zeedhi/common 1.37.0 → 1.39.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/zd-common.esm.js +390 -46
- package/dist/zd-common.umd.js +390 -46
- package/package.json +2 -2
- package/types/components/zd-grid/grid-editable.d.ts +1 -1
- package/types/components/zd-iterable/column.d.ts +4 -2
- package/types/components/zd-select/select.d.ts +2 -0
- package/types/components/zd-select-multiple/select-multiple.d.ts +4 -0
- package/types/components/zd-select-tree/select-tree.d.ts +7 -1
- package/types/components/zd-select-tree-multiple/select-tree-multiple.d.ts +4 -0
- package/types/components/zd-tree-grid/interfaces.d.ts +3 -1
- package/types/components/zd-tree-grid/tree-grid-editable.d.ts +4 -3
- package/types/utils/report/report-type/interfaces.d.ts +7 -2
- package/types/utils/report/report-type/xls-report.d.ts +17 -1
- package/types/components/zd-apex-chart/apex_chart.d.ts +0 -55
- package/types/components/zd-button-group/button_group.d.ts +0 -83
- package/types/components/zd-checkbox-multiple/checkbox_multiple.d.ts +0 -42
- package/types/components/zd-code-editor/code_editor.d.ts +0 -58
- package/types/components/zd-code-editor/prism.d.ts +0 -14
- package/types/components/zd-collapse-card/collapse_card.d.ts +0 -56
- package/types/components/zd-component/child_not_found.d.ts +0 -6
- package/types/components/zd-component/component_render.d.ts +0 -16
- package/types/components/zd-component/invalid_accessor.d.ts +0 -6
- package/types/components/zd-date/date_range.d.ts +0 -124
- package/types/components/zd-grid/errors/not_editing.d.ts +0 -6
- package/types/components/zd-grid/errors/row_not_found.d.ts +0 -6
- package/types/components/zd-grid/grid_column.d.ts +0 -52
- package/types/components/zd-grid/grid_column_editable.d.ts +0 -13
- package/types/components/zd-grid/grid_editable.d.ts +0 -162
- package/types/components/zd-iterable/column_not_found.d.ts +0 -6
- package/types/components/zd-iterable/iterable_columns_button.d.ts +0 -29
- package/types/components/zd-iterable/iterable_columns_button_controller.d.ts +0 -6
- package/types/components/zd-iterable/iterable_page_component.d.ts +0 -27
- package/types/components/zd-iterable/iterable_page_info.d.ts +0 -7
- package/types/components/zd-iterable/iterable_page_size.d.ts +0 -62
- package/types/components/zd-iterable/iterable_pagination.d.ts +0 -28
- package/types/components/zd-list/item_not_found.d.ts +0 -6
- package/types/components/zd-list/list_group.d.ts +0 -30
- package/types/components/zd-list/list_item.d.ts +0 -49
- package/types/components/zd-master-detail/detail_not_found.d.ts +0 -6
- package/types/components/zd-master-detail/master_detail.d.ts +0 -20
- package/types/components/zd-master-detail/master_not_found.d.ts +0 -6
- package/types/components/zd-menu/menu_button.d.ts +0 -28
- package/types/components/zd-menu/menu_group.d.ts +0 -53
- package/types/components/zd-menu/menu_link.d.ts +0 -46
- package/types/components/zd-menu/menu_separator.d.ts +0 -7
- package/types/components/zd-modal/modal_close_button.d.ts +0 -28
- package/types/components/zd-svg-map/svg_map.d.ts +0 -78
- package/types/components/zd-tabs/tab_not_found.d.ts +0 -11
- package/types/components/zd-text-input/text_input.d.ts +0 -90
- package/types/components/zd-tree-grid/errors/not_editing.d.ts +0 -6
- package/types/components/zd-tree-grid/errors/row_not_found.d.ts +0 -6
- package/types/components/zd-tree-grid/tree-data-structure.d.ts +0 -144
- package/types/components/zd-tree-grid/tree_data_structure.d.ts +0 -144
- package/types/components/zd-tree-grid/tree_grid.d.ts +0 -77
- package/types/components/zd-tree-grid/tree_grid_column.d.ts +0 -52
- package/types/components/zd-tree-grid/tree_grid_column_editable.d.ts +0 -13
- package/types/components/zd-tree-grid/tree_grid_editable.d.ts +0 -157
package/dist/zd-common.umd.js
CHANGED
|
@@ -2502,7 +2502,7 @@
|
|
|
2502
2502
|
*/
|
|
2503
2503
|
this.text = 'Loading';
|
|
2504
2504
|
this.isVisible = false;
|
|
2505
|
-
this.zIndex =
|
|
2505
|
+
this.zIndex = 999;
|
|
2506
2506
|
this.text = this.getInitValue('text', props.text, this.text);
|
|
2507
2507
|
this.zIndex = this.getInitValue('zIndex', props.zIndex, this.zIndex);
|
|
2508
2508
|
this.defaultText = this.text;
|
|
@@ -4320,11 +4320,11 @@
|
|
|
4320
4320
|
* Apply conditions
|
|
4321
4321
|
* @param row Datasource row
|
|
4322
4322
|
*/
|
|
4323
|
-
applyCondition(row) {
|
|
4323
|
+
applyCondition(row, factoredConditions = this.factoredConditions) {
|
|
4324
4324
|
const appliedConditions = {};
|
|
4325
|
-
Object.keys(
|
|
4326
|
-
const conditionFunction =
|
|
4327
|
-
set__default["default"](appliedConditions, condition, conditionFunction({ row }));
|
|
4325
|
+
Object.keys(factoredConditions).forEach((condition) => {
|
|
4326
|
+
const conditionFunction = factoredConditions[condition];
|
|
4327
|
+
set__default["default"](appliedConditions, condition, conditionFunction({ row, column: this }));
|
|
4328
4328
|
});
|
|
4329
4329
|
return appliedConditions;
|
|
4330
4330
|
}
|
|
@@ -4338,11 +4338,7 @@
|
|
|
4338
4338
|
const appliedConditions = {};
|
|
4339
4339
|
Object.keys(this.actionFactoredConditions).forEach((action) => {
|
|
4340
4340
|
const factoredConditions = this.actionFactoredConditions[action];
|
|
4341
|
-
appliedConditions[action] = {};
|
|
4342
|
-
Object.keys(factoredConditions).forEach((condition) => {
|
|
4343
|
-
const conditionFunction = factoredConditions[condition];
|
|
4344
|
-
set__default["default"](appliedConditions[action], condition, conditionFunction({ row }));
|
|
4345
|
-
});
|
|
4341
|
+
appliedConditions[action] = Object.assign({}, this.applyCondition(row, factoredConditions));
|
|
4346
4342
|
});
|
|
4347
4343
|
return appliedConditions;
|
|
4348
4344
|
}
|
|
@@ -5075,7 +5071,6 @@
|
|
|
5075
5071
|
if (this.editing)
|
|
5076
5072
|
return;
|
|
5077
5073
|
if (column.editable) {
|
|
5078
|
-
this.selectedRows = [];
|
|
5079
5074
|
this.editing = true;
|
|
5080
5075
|
this.preventRowClick = true;
|
|
5081
5076
|
this.datasource.currentRow = row;
|
|
@@ -5145,7 +5140,7 @@
|
|
|
5145
5140
|
else {
|
|
5146
5141
|
colValue = row[column.name];
|
|
5147
5142
|
}
|
|
5148
|
-
const componentProps = merge__default["default"]({}, column.componentProps, cellProps.componentProps);
|
|
5143
|
+
const componentProps = merge__default["default"]({}, column.componentProps, cellProps === null || cellProps === void 0 ? void 0 : cellProps.componentProps);
|
|
5149
5144
|
let compEvents = {};
|
|
5150
5145
|
if (componentProps && componentProps.events) {
|
|
5151
5146
|
compEvents = core.Event.factory(componentProps.events);
|
|
@@ -5855,7 +5850,7 @@
|
|
|
5855
5850
|
*/
|
|
5856
5851
|
constructor(props) {
|
|
5857
5852
|
var _a, _b;
|
|
5858
|
-
super(props);
|
|
5853
|
+
super(Object.assign(Object.assign({}, props), { value: undefined }));
|
|
5859
5854
|
/**
|
|
5860
5855
|
* Field used to display values
|
|
5861
5856
|
*/
|
|
@@ -5938,6 +5933,7 @@
|
|
|
5938
5933
|
this.cachedData = [];
|
|
5939
5934
|
this.cachedTotal = 0;
|
|
5940
5935
|
this.formatterFn = core.FormatterParserProvider.getFormatter('ZdSelect');
|
|
5936
|
+
this.pushedValue = null;
|
|
5941
5937
|
this.loadMoreQtty = 0;
|
|
5942
5938
|
this.debounceSearch = debounce__default["default"](this.doSearch, 500);
|
|
5943
5939
|
this.appendIcon = this.getInitValue('appendIcon', props.appendIcon, 'expand');
|
|
@@ -5959,7 +5955,13 @@
|
|
|
5959
5955
|
this.dataText = [this.dataText];
|
|
5960
5956
|
const defaultDatasource = this.getDefaultDatasource(props);
|
|
5961
5957
|
this.datasource = core.DatasourceFactory.factory(defaultDatasource);
|
|
5962
|
-
this.
|
|
5958
|
+
this.overrideGet();
|
|
5959
|
+
let defaultValue = props.value;
|
|
5960
|
+
if (core.Accessor.isAccessorDefinition(props.value)) {
|
|
5961
|
+
defaultValue = this.getAccessorValue(props.value);
|
|
5962
|
+
this.getInitValue('value', props.value, this.value);
|
|
5963
|
+
}
|
|
5964
|
+
this.setDefaultValue(defaultValue, (_b = props.datasource) === null || _b === void 0 ? void 0 : _b.lazyLoad);
|
|
5963
5965
|
this.preventLoadOnFocus = !defaultDatasource.lazyLoad;
|
|
5964
5966
|
this.preventLoadOnFocus = this.getInitValue('preventLoadOnFocus', props.preventLoadOnFocus, this.preventLoadOnFocus);
|
|
5965
5967
|
this.loadMoreQtty = this.datasource.limit;
|
|
@@ -5968,6 +5970,11 @@
|
|
|
5968
5970
|
this.createAccessors();
|
|
5969
5971
|
this.initialized = true;
|
|
5970
5972
|
}
|
|
5973
|
+
getAccessorValue(accessorName) {
|
|
5974
|
+
const [controller, accessor] = core.Accessor.getAccessor(accessorName);
|
|
5975
|
+
const instance = core.Loader.getInstance(controller);
|
|
5976
|
+
return instance[accessor];
|
|
5977
|
+
}
|
|
5971
5978
|
/**
|
|
5972
5979
|
* Retrieves datasource structure applying infinity scroll
|
|
5973
5980
|
* @param field Field structure
|
|
@@ -5979,6 +5986,16 @@
|
|
|
5979
5986
|
const searchIn = (((_a = field.datasource) === null || _a === void 0 ? void 0 : _a.searchIn) || []).concat(searchInDefault);
|
|
5980
5987
|
return Object.assign(Object.assign({}, field.datasource), { searchIn, lazyLoad: (field.value !== '' && field.value !== undefined) || (field.datasource && field.datasource.lazyLoad) });
|
|
5981
5988
|
}
|
|
5989
|
+
overrideGet() {
|
|
5990
|
+
const oldGet = this.datasource.get;
|
|
5991
|
+
this.datasource.get = () => __awaiter(this, void 0, void 0, function* () {
|
|
5992
|
+
yield oldGet.call(this.datasource);
|
|
5993
|
+
if (this.indexOf(this.value) !== -1 || this.datasource.search || this.isFocused)
|
|
5994
|
+
return;
|
|
5995
|
+
yield this.setValue(this.value, false);
|
|
5996
|
+
this.removePushedValue();
|
|
5997
|
+
});
|
|
5998
|
+
}
|
|
5982
5999
|
get search() {
|
|
5983
6000
|
return this.searchValue;
|
|
5984
6001
|
}
|
|
@@ -6005,7 +6022,7 @@
|
|
|
6005
6022
|
}
|
|
6006
6023
|
if (this.manualMode)
|
|
6007
6024
|
return;
|
|
6008
|
-
this.cachedData = this.datasource.data;
|
|
6025
|
+
this.cachedData = [...this.datasource.data];
|
|
6009
6026
|
this.cachedTotal = this.datasource.total;
|
|
6010
6027
|
if (pushed) {
|
|
6011
6028
|
this.pushedValue = this.selectedData;
|
|
@@ -6064,10 +6081,14 @@
|
|
|
6064
6081
|
if (!this.pushedValue && this.isFilledObj(this.selectValue) && this.indexOf(this.selectValue) === -1) {
|
|
6065
6082
|
this.pushedValue = this.selectValue;
|
|
6066
6083
|
}
|
|
6067
|
-
|
|
6084
|
+
const index = this.indexOf(this.pushedValue);
|
|
6085
|
+
if (this.isFilledObj(this.pushedValue) && index === -1) {
|
|
6068
6086
|
this.datasource.data.unshift(this.pushedValue);
|
|
6069
6087
|
}
|
|
6070
|
-
|
|
6088
|
+
else if (index !== 0) {
|
|
6089
|
+
this.pushedValue = null;
|
|
6090
|
+
}
|
|
6091
|
+
this.cachedData = [...this.datasource.data];
|
|
6071
6092
|
this.cachedTotal = this.datasource.total;
|
|
6072
6093
|
}
|
|
6073
6094
|
/**
|
|
@@ -6126,6 +6147,7 @@
|
|
|
6126
6147
|
}
|
|
6127
6148
|
if (!searchValue) {
|
|
6128
6149
|
this.setFieldRowValue(null);
|
|
6150
|
+
this.selectValue = this.selectedData;
|
|
6129
6151
|
return false;
|
|
6130
6152
|
}
|
|
6131
6153
|
this.setFieldRowValue(searchValue);
|
|
@@ -6236,7 +6258,7 @@
|
|
|
6236
6258
|
else {
|
|
6237
6259
|
this.removePushedValue();
|
|
6238
6260
|
this.datasource.search = this.searchValue;
|
|
6239
|
-
this.datasource.data = this.cachedData;
|
|
6261
|
+
this.datasource.data = [...this.cachedData];
|
|
6240
6262
|
this.datasource.total = this.cachedTotal;
|
|
6241
6263
|
}
|
|
6242
6264
|
});
|
|
@@ -6249,6 +6271,11 @@
|
|
|
6249
6271
|
yield this.datasource.setLimit(this.datasource.limit + this.loadMoreQtty);
|
|
6250
6272
|
if (!this.datasource.search) {
|
|
6251
6273
|
this.afterLoad();
|
|
6274
|
+
const { dataValue } = this;
|
|
6275
|
+
const isSelected = this.selectValue && this.pushedValue && this.selectValue[dataValue] === this.pushedValue[dataValue];
|
|
6276
|
+
if (isSelected)
|
|
6277
|
+
return;
|
|
6278
|
+
this.removePushedValue();
|
|
6252
6279
|
}
|
|
6253
6280
|
});
|
|
6254
6281
|
}
|
|
@@ -6262,7 +6289,7 @@
|
|
|
6262
6289
|
this.datasource.search = '';
|
|
6263
6290
|
this.dirtySearchValue = '';
|
|
6264
6291
|
if (!this.manualMode) {
|
|
6265
|
-
this.datasource.data = this.cachedData;
|
|
6292
|
+
this.datasource.data = [...this.cachedData];
|
|
6266
6293
|
this.datasource.total = this.cachedTotal;
|
|
6267
6294
|
}
|
|
6268
6295
|
this.checkValueOnBlur();
|
|
@@ -6275,13 +6302,17 @@
|
|
|
6275
6302
|
}
|
|
6276
6303
|
if (this.manualMode)
|
|
6277
6304
|
return;
|
|
6278
|
-
if (this.isFilledObj(this.selectValue)) {
|
|
6279
|
-
if (this.
|
|
6280
|
-
this.
|
|
6281
|
-
this.pushedValue = this.selectValue;
|
|
6305
|
+
if (this.isFilledObj(this.selectValue) && this.indexOf(this.selectValue) === -1) {
|
|
6306
|
+
if (this.pushedValue) {
|
|
6307
|
+
this.removePushedValue();
|
|
6282
6308
|
}
|
|
6309
|
+
this.datasource.data.unshift(this.selectValue);
|
|
6310
|
+
this.pushedValue = this.selectValue;
|
|
6283
6311
|
return;
|
|
6284
6312
|
}
|
|
6313
|
+
const { dataValue } = this;
|
|
6314
|
+
if (this.pushedValue && this.selectValue && this.selectValue[dataValue] === this.pushedValue[dataValue])
|
|
6315
|
+
return;
|
|
6285
6316
|
this.removePushedValue();
|
|
6286
6317
|
}
|
|
6287
6318
|
showLoadMore() {
|
|
@@ -7871,7 +7902,6 @@
|
|
|
7871
7902
|
*/
|
|
7872
7903
|
constructor(props) {
|
|
7873
7904
|
super(props);
|
|
7874
|
-
this.selectedValue = [];
|
|
7875
7905
|
/**
|
|
7876
7906
|
* Selected items that were added to datasource
|
|
7877
7907
|
*/
|
|
@@ -7885,6 +7915,9 @@
|
|
|
7885
7915
|
*/
|
|
7886
7916
|
this.moreChip = 0;
|
|
7887
7917
|
this.showSelectAll = false;
|
|
7918
|
+
if (!this.selectedValue) {
|
|
7919
|
+
this.selectedValue = [];
|
|
7920
|
+
}
|
|
7888
7921
|
this.showSelectAll = this.getInitValue('showSelectAll', props.showSelectAll, this.showSelectAll);
|
|
7889
7922
|
this.createAccessors();
|
|
7890
7923
|
}
|
|
@@ -7924,20 +7957,23 @@
|
|
|
7924
7957
|
set selectValue(rows) {
|
|
7925
7958
|
if (!Array.isArray(rows))
|
|
7926
7959
|
return;
|
|
7927
|
-
if (!this.manualMode
|
|
7928
|
-
this.insertsRemoved = [];
|
|
7960
|
+
if (!this.manualMode) {
|
|
7929
7961
|
const values = rows.map((row) => row[this.dataValue]);
|
|
7930
|
-
this.insertedValues
|
|
7931
|
-
|
|
7932
|
-
if (removed) {
|
|
7933
|
-
this.insertsRemoved.push(inserted);
|
|
7934
|
-
}
|
|
7935
|
-
return !removed;
|
|
7936
|
-
});
|
|
7962
|
+
this.cutFromAToB(this.insertedValues, this.insertsRemoved, (value) => !values.includes(value[this.dataValue]));
|
|
7963
|
+
this.cutFromAToB(this.insertsRemoved, this.insertedValues, (value) => values.includes(value[this.dataValue]));
|
|
7937
7964
|
}
|
|
7938
7965
|
this.selectedValue = rows;
|
|
7939
7966
|
this.setFieldValue(this.getValues(rows));
|
|
7940
7967
|
}
|
|
7968
|
+
/**
|
|
7969
|
+
* Removes item from array a and add it to array b if condition is satisfied
|
|
7970
|
+
*/
|
|
7971
|
+
cutFromAToB(a, b, condition) {
|
|
7972
|
+
const indices = a.reduce((result, value, index) => (condition(value) ? [...result, index] : result), []);
|
|
7973
|
+
indices.forEach((index) => {
|
|
7974
|
+
b.push(a.splice(index)[0]);
|
|
7975
|
+
});
|
|
7976
|
+
}
|
|
7941
7977
|
setFieldValue(value) {
|
|
7942
7978
|
return __awaiter(this, void 0, void 0, function* () {
|
|
7943
7979
|
const promises = [];
|
|
@@ -7967,7 +8003,9 @@
|
|
|
7967
8003
|
}));
|
|
7968
8004
|
}
|
|
7969
8005
|
});
|
|
7970
|
-
|
|
8006
|
+
if (promises.length) {
|
|
8007
|
+
yield Promise.all(promises);
|
|
8008
|
+
}
|
|
7971
8009
|
if (searchValues.length > 0) {
|
|
7972
8010
|
this.setFieldRowValue(searchValues);
|
|
7973
8011
|
}
|
|
@@ -8112,7 +8150,7 @@
|
|
|
8112
8150
|
showLoadMore() {
|
|
8113
8151
|
return !!this.datasource.data.length
|
|
8114
8152
|
&& !this.datasource.loadAll
|
|
8115
|
-
&& (this.datasource.data.length - this.insertedValues.length) < this.datasource.total;
|
|
8153
|
+
&& (this.datasource.data.length - this.insertedValues.length - this.insertsRemoved.length) < this.datasource.total;
|
|
8116
8154
|
}
|
|
8117
8155
|
/**
|
|
8118
8156
|
* Load more data
|
|
@@ -8120,10 +8158,16 @@
|
|
|
8120
8158
|
loadMore() {
|
|
8121
8159
|
return __awaiter(this, void 0, void 0, function* () {
|
|
8122
8160
|
yield this.datasource.setLimit(this.datasource.limit + this.loadMoreQtty);
|
|
8161
|
+
this.insertsRemoved = this.insertsRemoved.filter((insert) => {
|
|
8162
|
+
const value = insert[this.dataValue];
|
|
8163
|
+
const foundInData = this.datasource.data.find(this.getCondition(value));
|
|
8164
|
+
return !foundInData;
|
|
8165
|
+
});
|
|
8166
|
+
this.insertSelected();
|
|
8123
8167
|
if (!this.datasource.search) {
|
|
8124
8168
|
this.setCache();
|
|
8125
8169
|
}
|
|
8126
|
-
this.
|
|
8170
|
+
this.removePushedValue();
|
|
8127
8171
|
});
|
|
8128
8172
|
}
|
|
8129
8173
|
/**
|
|
@@ -8317,6 +8361,9 @@
|
|
|
8317
8361
|
}
|
|
8318
8362
|
return item;
|
|
8319
8363
|
});
|
|
8364
|
+
if (parent) { // remove all existing children to add new ones
|
|
8365
|
+
this.treeData = this.treeData.filter((item) => item.tree__parent !== parent);
|
|
8366
|
+
}
|
|
8320
8367
|
if (!parent) {
|
|
8321
8368
|
this.treeData = childData;
|
|
8322
8369
|
}
|
|
@@ -8500,7 +8547,7 @@
|
|
|
8500
8547
|
this.treeStructure = {};
|
|
8501
8548
|
const childData = this.originalDatasource.data.map((row) => (Object.assign(Object.assign({}, row), { tree__children: [], tree__opened: false, tree__searched: true, tree__level: 1, tree__parent: undefined })));
|
|
8502
8549
|
this.treeData = childData;
|
|
8503
|
-
this.treeStructure['no-parent'] =
|
|
8550
|
+
this.treeStructure['no-parent'] = childData;
|
|
8504
8551
|
}
|
|
8505
8552
|
/**
|
|
8506
8553
|
* Search value against a memory datasource
|
|
@@ -8635,6 +8682,7 @@
|
|
|
8635
8682
|
* Defines if should wait and not execute GET method when Datasource is created
|
|
8636
8683
|
*/
|
|
8637
8684
|
this.lazyLoad = true;
|
|
8685
|
+
this.selectValue = null;
|
|
8638
8686
|
this.nodes = this.getInitValue('nodes', props.nodes, this.nodes);
|
|
8639
8687
|
this.alwaysOpen = this.getInitValue('alwaysOpen', props.alwaysOpen, this.alwaysOpen);
|
|
8640
8688
|
this.flattenSearchResults = this.getInitValue('flattenSearchResults', props.flattenSearchResults, this.flattenSearchResults);
|
|
@@ -8802,8 +8850,41 @@
|
|
|
8802
8850
|
get searchValue() {
|
|
8803
8851
|
return this.lastInputValue;
|
|
8804
8852
|
}
|
|
8853
|
+
clearRow(row) {
|
|
8854
|
+
const result = Object.assign({}, row);
|
|
8855
|
+
Object.keys(result).forEach((key) => {
|
|
8856
|
+
if (key.indexOf('tree__') === 0) {
|
|
8857
|
+
delete result[key];
|
|
8858
|
+
}
|
|
8859
|
+
});
|
|
8860
|
+
return result;
|
|
8861
|
+
}
|
|
8862
|
+
get value() {
|
|
8863
|
+
if (!this.selectValue)
|
|
8864
|
+
return this.selectValue;
|
|
8865
|
+
if (this.returnObject) {
|
|
8866
|
+
return this.clearRow(this.selectValue.row);
|
|
8867
|
+
}
|
|
8868
|
+
return this.selectValue;
|
|
8869
|
+
}
|
|
8870
|
+
set value(value) {
|
|
8871
|
+
this.selectValue = value;
|
|
8872
|
+
}
|
|
8805
8873
|
setValue(value) {
|
|
8806
|
-
this.
|
|
8874
|
+
if (this.returnObject) {
|
|
8875
|
+
if (typeof value !== 'object') {
|
|
8876
|
+
this.value = { id: value };
|
|
8877
|
+
}
|
|
8878
|
+
else {
|
|
8879
|
+
this.value = { id: value[this.dataValue] };
|
|
8880
|
+
}
|
|
8881
|
+
}
|
|
8882
|
+
else if (typeof value === 'object') {
|
|
8883
|
+
this.value = value[this.dataValue];
|
|
8884
|
+
}
|
|
8885
|
+
else {
|
|
8886
|
+
this.value = value;
|
|
8887
|
+
}
|
|
8807
8888
|
}
|
|
8808
8889
|
}
|
|
8809
8890
|
|
|
@@ -8829,6 +8910,7 @@
|
|
|
8829
8910
|
* Selected Nodes
|
|
8830
8911
|
*/
|
|
8831
8912
|
this.selectedNodes = [];
|
|
8913
|
+
this.selectValue = [];
|
|
8832
8914
|
this.flat = this.getInitValue('flat', props.flat, this.flat);
|
|
8833
8915
|
this.limit = this.getInitValue('limit', props.limit, this.limit);
|
|
8834
8916
|
this.createAccessors();
|
|
@@ -8845,6 +8927,34 @@
|
|
|
8845
8927
|
deselect(node, element) {
|
|
8846
8928
|
this.callEvent('onDeselect', { element, component: this, node });
|
|
8847
8929
|
}
|
|
8930
|
+
get value() {
|
|
8931
|
+
if (this.returnObject) {
|
|
8932
|
+
return this.selectValue.map((value) => this.clearRow(value.row));
|
|
8933
|
+
}
|
|
8934
|
+
return this.selectValue;
|
|
8935
|
+
}
|
|
8936
|
+
set value(value) {
|
|
8937
|
+
this.selectValue = value;
|
|
8938
|
+
}
|
|
8939
|
+
setValue(value) {
|
|
8940
|
+
const arrValue = Array.isArray(value) ? value : [value];
|
|
8941
|
+
if (this.returnObject) {
|
|
8942
|
+
this.value = arrValue.map((item) => {
|
|
8943
|
+
if (typeof item !== 'object') {
|
|
8944
|
+
return { id: item };
|
|
8945
|
+
}
|
|
8946
|
+
return { id: item[this.dataValue] };
|
|
8947
|
+
});
|
|
8948
|
+
}
|
|
8949
|
+
else {
|
|
8950
|
+
this.value = arrValue.map((item) => {
|
|
8951
|
+
if (typeof item === 'object') {
|
|
8952
|
+
return item[this.dataValue];
|
|
8953
|
+
}
|
|
8954
|
+
return item;
|
|
8955
|
+
});
|
|
8956
|
+
}
|
|
8957
|
+
}
|
|
8848
8958
|
}
|
|
8849
8959
|
|
|
8850
8960
|
/**
|
|
@@ -10114,7 +10224,6 @@
|
|
|
10114
10224
|
if (this.editing)
|
|
10115
10225
|
return;
|
|
10116
10226
|
if (column.editable) {
|
|
10117
|
-
this.selectedRows = [];
|
|
10118
10227
|
this.editing = true;
|
|
10119
10228
|
this.preventRowClick = true;
|
|
10120
10229
|
this.datasource.currentRow = row;
|
|
@@ -11063,17 +11172,37 @@
|
|
|
11063
11172
|
}
|
|
11064
11173
|
|
|
11065
11174
|
class XLSReport extends BaseReport {
|
|
11066
|
-
constructor() {
|
|
11067
|
-
super(
|
|
11175
|
+
constructor(type) {
|
|
11176
|
+
super();
|
|
11068
11177
|
this.route = '/generateXLS';
|
|
11178
|
+
this.expressionZeedhiToXls = {
|
|
11179
|
+
AVG: 'AVERAGE',
|
|
11180
|
+
COUNT: 'COUNTA',
|
|
11181
|
+
MAX: 'MAX',
|
|
11182
|
+
MIN: 'MIN',
|
|
11183
|
+
SUM: 'SUM',
|
|
11184
|
+
};
|
|
11185
|
+
this.colunmXLS = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ';
|
|
11186
|
+
this.type = type || 'xls';
|
|
11069
11187
|
}
|
|
11070
|
-
buildDataset(data, columns) {
|
|
11188
|
+
buildDataset(data, columns, metadata) {
|
|
11189
|
+
let result;
|
|
11190
|
+
if (this.type === 'xls') {
|
|
11191
|
+
result = this.formatRawDataSet(data, columns);
|
|
11192
|
+
}
|
|
11193
|
+
else if (metadata) {
|
|
11194
|
+
result = this.formatDataSet(metadata, data);
|
|
11195
|
+
}
|
|
11196
|
+
return JSON.stringify(result);
|
|
11197
|
+
}
|
|
11198
|
+
// formata o dataset para o formato "cru" xls
|
|
11199
|
+
formatRawDataSet(data, columns) {
|
|
11071
11200
|
const columnNames = columns.map((col) => col.name);
|
|
11072
11201
|
const result = data.reduce((reduced, row) => {
|
|
11073
11202
|
const values = columnNames.map((col) => row[col] || '');
|
|
11074
11203
|
return [...reduced, values];
|
|
11075
11204
|
}, [columnNames]);
|
|
11076
|
-
return
|
|
11205
|
+
return result;
|
|
11077
11206
|
}
|
|
11078
11207
|
buildMetadata(name, title, columns, filter) {
|
|
11079
11208
|
const builtCols = this.buildColumns(columns);
|
|
@@ -11102,9 +11231,215 @@
|
|
|
11102
11231
|
orientation: 'PORTRAIT',
|
|
11103
11232
|
columns: builtCols,
|
|
11104
11233
|
filter: builtFilters,
|
|
11234
|
+
reportXLS: true,
|
|
11235
|
+
xlsMergedCell: [],
|
|
11105
11236
|
};
|
|
11106
11237
|
return Promise.resolve(JSON.stringify(metadataObj));
|
|
11107
11238
|
}
|
|
11239
|
+
isFormat3(format) {
|
|
11240
|
+
return format === 'xls3';
|
|
11241
|
+
}
|
|
11242
|
+
// Ordenar o nome das colunas de acordo com seu index, excluindo o nome das colunas agrupadas
|
|
11243
|
+
getColumnsNameFormat3(columns, metaData) {
|
|
11244
|
+
const columnsNameGroup = metaData.groups.map((row) => row.field);
|
|
11245
|
+
let columnsName = [];
|
|
11246
|
+
Object.entries(columns).forEach((row) => {
|
|
11247
|
+
const columnName = row[0];
|
|
11248
|
+
if (columnsNameGroup.indexOf(columnName) === -1) {
|
|
11249
|
+
const index = row[1].sequence;
|
|
11250
|
+
columnsName[index] = columnName;
|
|
11251
|
+
}
|
|
11252
|
+
});
|
|
11253
|
+
columnsName = columnsName.filter((columnName) => typeof columnName === 'string');
|
|
11254
|
+
return columnsName;
|
|
11255
|
+
}
|
|
11256
|
+
// Ordenar o nome das colunas de acordo com seu index, e sempre deixando as colunas agrupadas nas primeiras posições
|
|
11257
|
+
getColumnsName(columns, metaData, lengthGroup) {
|
|
11258
|
+
const columnsNameGroup = metaData.groups.map((row) => row.field);
|
|
11259
|
+
let columnsName = [];
|
|
11260
|
+
Object.entries(columns).forEach((row) => {
|
|
11261
|
+
const columnName = row[0];
|
|
11262
|
+
const index = row[1].sequence;
|
|
11263
|
+
if (columnsNameGroup.indexOf(columnName) === -1) {
|
|
11264
|
+
columnsName[index + lengthGroup] = columnName;
|
|
11265
|
+
}
|
|
11266
|
+
else {
|
|
11267
|
+
columnsName[index] = columnName;
|
|
11268
|
+
}
|
|
11269
|
+
});
|
|
11270
|
+
columnsName = columnsName.filter((columnName) => typeof columnName === 'string');
|
|
11271
|
+
return columnsName;
|
|
11272
|
+
}
|
|
11273
|
+
// Inicializa alguns valores auxiliares
|
|
11274
|
+
initVars(metaData, type) {
|
|
11275
|
+
metaData.xlsMergedCell = [];
|
|
11276
|
+
const { columns } = metaData;
|
|
11277
|
+
const lengthGroup = metaData.groups.length;
|
|
11278
|
+
const indexLastGroup = lengthGroup - 1;
|
|
11279
|
+
let columnsName = [];
|
|
11280
|
+
if (this.isFormat3(type)) {
|
|
11281
|
+
columnsName = this.getColumnsNameFormat3(columns, metaData);
|
|
11282
|
+
}
|
|
11283
|
+
else {
|
|
11284
|
+
columnsName = this.getColumnsName(columns, metaData, lengthGroup);
|
|
11285
|
+
}
|
|
11286
|
+
const rowValues = [];
|
|
11287
|
+
const formatedDataSet = [];
|
|
11288
|
+
const groups = [];
|
|
11289
|
+
groups.groupEnd = {};
|
|
11290
|
+
groups.groupEnd.cellsfunc = {};
|
|
11291
|
+
return {
|
|
11292
|
+
columns, indexLastGroup, columnsName, rowValues, formatedDataSet, groups,
|
|
11293
|
+
};
|
|
11294
|
+
}
|
|
11295
|
+
// formata a linha do grupo de acordo com o formato xls3
|
|
11296
|
+
setRowGroupFormat3(row, rowValuesParam, groups, formatedDataSet, columnsName, columns, indexLastGroup) {
|
|
11297
|
+
let rowValues = rowValuesParam;
|
|
11298
|
+
const label = `${row.groupLabel}:${row.groupValue}`;
|
|
11299
|
+
const index = row.groupIndex;
|
|
11300
|
+
if (row.groupHeader) {
|
|
11301
|
+
rowValues[index] = label;
|
|
11302
|
+
groups[index] = { init: null, end: null };
|
|
11303
|
+
formatedDataSet.push(rowValues);
|
|
11304
|
+
rowValues = [];
|
|
11305
|
+
}
|
|
11306
|
+
else if (row.groupFooter) {
|
|
11307
|
+
if (!row.groupLabel) {
|
|
11308
|
+
rowValues.push('Total');
|
|
11309
|
+
}
|
|
11310
|
+
else {
|
|
11311
|
+
rowValues.push(`Total (${label})`);
|
|
11312
|
+
}
|
|
11313
|
+
formatedDataSet.push(rowValues);
|
|
11314
|
+
rowValues = [];
|
|
11315
|
+
const funcXls = null;
|
|
11316
|
+
columnsName.forEach((column) => {
|
|
11317
|
+
this.formatRowFunc(column, columns, row, index, rowValues, funcXls, groups, indexLastGroup);
|
|
11318
|
+
});
|
|
11319
|
+
}
|
|
11320
|
+
return rowValues;
|
|
11321
|
+
}
|
|
11322
|
+
// formata as expressões da linha
|
|
11323
|
+
formatRowFunc(column, columns, row, index, rowValues, funcXlsParam, groups, indexLastGroup) {
|
|
11324
|
+
let funcXls = funcXlsParam;
|
|
11325
|
+
if ((row[column] === 0 || row[column]) && index !== undefined) {
|
|
11326
|
+
const letter = this.colunmXLS[rowValues.length];
|
|
11327
|
+
funcXls = this.expressionZeedhiToXls[columns[column].expression];
|
|
11328
|
+
const cellsfunc = `${letter + groups[index].init}:${letter}${groups[index].end}`;
|
|
11329
|
+
let expression = '';
|
|
11330
|
+
if (indexLastGroup === index) {
|
|
11331
|
+
expression = `=${funcXls}(${cellsfunc})`;
|
|
11332
|
+
}
|
|
11333
|
+
else {
|
|
11334
|
+
expression = `=${funcXls}(${groups[index].cellsfunc[column]})`;
|
|
11335
|
+
if (index === 0) {
|
|
11336
|
+
if (groups.groupEnd.cellsfunc[column]) {
|
|
11337
|
+
groups.groupEnd.cellsfunc[column] += `,${groups[index].cellsfunc[column]}`;
|
|
11338
|
+
}
|
|
11339
|
+
else {
|
|
11340
|
+
groups.groupEnd.cellsfunc[column] = groups[index].cellsfunc[column];
|
|
11341
|
+
}
|
|
11342
|
+
}
|
|
11343
|
+
groups[index].cellsfunc[column] = null;
|
|
11344
|
+
}
|
|
11345
|
+
rowValues.push(expression);
|
|
11346
|
+
groups.forEach((group, indexGroup) => {
|
|
11347
|
+
if (indexGroup !== indexLastGroup) {
|
|
11348
|
+
if (!group.cellsfunc) {
|
|
11349
|
+
group.cellsfunc = {};
|
|
11350
|
+
}
|
|
11351
|
+
if (group.cellsfunc[column]) {
|
|
11352
|
+
group.cellsfunc[column] += `,${cellsfunc}`;
|
|
11353
|
+
}
|
|
11354
|
+
else {
|
|
11355
|
+
group.cellsfunc[column] = cellsfunc;
|
|
11356
|
+
}
|
|
11357
|
+
}
|
|
11358
|
+
});
|
|
11359
|
+
}
|
|
11360
|
+
else {
|
|
11361
|
+
let cell = row[column];
|
|
11362
|
+
if (row.groupSummary) {
|
|
11363
|
+
const groupEndFunc = groups.groupEnd.cellsfunc;
|
|
11364
|
+
if (groupEndFunc[column]) {
|
|
11365
|
+
funcXls = this.expressionZeedhiToXls[columns[column].expression];
|
|
11366
|
+
cell = `=${funcXls}(${groupEndFunc[column]})`;
|
|
11367
|
+
}
|
|
11368
|
+
}
|
|
11369
|
+
rowValues.push(cell);
|
|
11370
|
+
}
|
|
11371
|
+
}
|
|
11372
|
+
// formata a linha de grupo de acordo com o formato xls2
|
|
11373
|
+
setRowGroup(row, rowValues, groups, metaData, formatedDataSet, columnsName, columns, indexLastGroup) {
|
|
11374
|
+
const label = `${row.groupLabel}:${row.groupValue}`;
|
|
11375
|
+
const index = row.groupIndex;
|
|
11376
|
+
if (row.groupHeader) {
|
|
11377
|
+
rowValues[index] = label;
|
|
11378
|
+
groups[index] = { init: null, end: null };
|
|
11379
|
+
}
|
|
11380
|
+
else if (row.groupFooter) {
|
|
11381
|
+
if (!row.groupLabel) {
|
|
11382
|
+
rowValues.push('Total');
|
|
11383
|
+
}
|
|
11384
|
+
else {
|
|
11385
|
+
rowValues.push(`Total (${label})`);
|
|
11386
|
+
}
|
|
11387
|
+
const funcXls = null;
|
|
11388
|
+
if (groups[index]) {
|
|
11389
|
+
metaData.xlsMergedCell.push({
|
|
11390
|
+
start_row: groups[index].init,
|
|
11391
|
+
start_col: this.colunmXLS[index],
|
|
11392
|
+
end_row: formatedDataSet.length + 2,
|
|
11393
|
+
end_col: this.colunmXLS[index],
|
|
11394
|
+
});
|
|
11395
|
+
}
|
|
11396
|
+
columnsName.forEach((column, columnIndex) => {
|
|
11397
|
+
if (!(row.groupFooter && columnIndex === 0)) {
|
|
11398
|
+
this.formatRowFunc(column, columns, row, index, rowValues, funcXls, groups, indexLastGroup);
|
|
11399
|
+
}
|
|
11400
|
+
});
|
|
11401
|
+
}
|
|
11402
|
+
return rowValues;
|
|
11403
|
+
}
|
|
11404
|
+
// Defina o index dos grupos
|
|
11405
|
+
setIndexGroups(groups, formatedDataSet) {
|
|
11406
|
+
groups.forEach((group) => {
|
|
11407
|
+
if (!group.init) {
|
|
11408
|
+
group.init = formatedDataSet.length + 2;
|
|
11409
|
+
}
|
|
11410
|
+
group.end = formatedDataSet.length + 2;
|
|
11411
|
+
});
|
|
11412
|
+
}
|
|
11413
|
+
// Preenche uma linha "normal"
|
|
11414
|
+
setRowNormal(columnsName, rowValues, row) {
|
|
11415
|
+
columnsName.forEach((column) => {
|
|
11416
|
+
rowValues.push(row[column]);
|
|
11417
|
+
});
|
|
11418
|
+
}
|
|
11419
|
+
formatDataSet(metaData, dataSet) {
|
|
11420
|
+
const initVars = this.initVars(metaData, this.type);
|
|
11421
|
+
const { columns, indexLastGroup, columnsName, formatedDataSet, groups, } = initVars;
|
|
11422
|
+
let { rowValues } = initVars;
|
|
11423
|
+
dataSet.forEach((row) => {
|
|
11424
|
+
if (row.group || row.groupFooter) {
|
|
11425
|
+
if (this.isFormat3(this.type)) {
|
|
11426
|
+
rowValues = this.setRowGroupFormat3(row, rowValues, groups, formatedDataSet, columnsName, columns, indexLastGroup);
|
|
11427
|
+
}
|
|
11428
|
+
else {
|
|
11429
|
+
rowValues = this.setRowGroup(row, rowValues, groups, metaData, formatedDataSet, columnsName, columns, indexLastGroup);
|
|
11430
|
+
}
|
|
11431
|
+
}
|
|
11432
|
+
else {
|
|
11433
|
+
this.setIndexGroups(groups, formatedDataSet);
|
|
11434
|
+
this.setRowNormal(columnsName, rowValues, row);
|
|
11435
|
+
}
|
|
11436
|
+
if (!row.groupHeader) {
|
|
11437
|
+
formatedDataSet.push(rowValues);
|
|
11438
|
+
}
|
|
11439
|
+
rowValues = [];
|
|
11440
|
+
});
|
|
11441
|
+
return [columnsName].concat(formatedDataSet);
|
|
11442
|
+
}
|
|
11108
11443
|
}
|
|
11109
11444
|
|
|
11110
11445
|
class Report {
|
|
@@ -11140,8 +11475,8 @@
|
|
|
11140
11475
|
if (type === 'pdf') {
|
|
11141
11476
|
return new PDFReport();
|
|
11142
11477
|
}
|
|
11143
|
-
if (type === 'xls') {
|
|
11144
|
-
return new XLSReport();
|
|
11478
|
+
if (type === 'xls' || type === 'xls2' || type === 'xls3') {
|
|
11479
|
+
return new XLSReport(type);
|
|
11145
11480
|
}
|
|
11146
11481
|
throw new Error(`Invalid report type: ${type}`);
|
|
11147
11482
|
}
|
|
@@ -11156,9 +11491,18 @@
|
|
|
11156
11491
|
const reportType = this.getReportType(type);
|
|
11157
11492
|
const { route } = reportType;
|
|
11158
11493
|
const { name, columns, datasource } = this.iterable;
|
|
11494
|
+
const { groupedData } = Object.assign({}, this.iterable);
|
|
11159
11495
|
const formattedColumns = this.removeActionColumns(columns);
|
|
11160
|
-
const dataset = reportType.buildDataset(data, formattedColumns);
|
|
11161
11496
|
const metadataObj = yield reportType.buildMetadata(name, this.title, formattedColumns, datasource.filter, portrait);
|
|
11497
|
+
let dataset;
|
|
11498
|
+
if ((reportType.type === 'xls2' || reportType.type === 'xls3') && groupedData) {
|
|
11499
|
+
const rowMetadata = rowObj.metaData;
|
|
11500
|
+
const metadataObjClone = merge__default["default"](rowMetadata, JSON.parse(metadataObj));
|
|
11501
|
+
dataset = reportType.buildDataset(groupedData, formattedColumns, metadataObjClone);
|
|
11502
|
+
}
|
|
11503
|
+
else {
|
|
11504
|
+
dataset = reportType.buildDataset(data, formattedColumns);
|
|
11505
|
+
}
|
|
11162
11506
|
const filter = '[]';
|
|
11163
11507
|
let row = {};
|
|
11164
11508
|
if (rowObj) {
|