@zeedhi/teknisa-components-common 1.88.0 → 1.89.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/coverage/clover.xml +679 -622
- package/coverage/coverage-final.json +41 -39
- package/coverage/lcov-report/index.html +31 -16
- package/coverage/lcov-report/tests/__helpers__/component-event-helper.ts.html +4 -4
- package/coverage/lcov-report/tests/__helpers__/flush-promises-helper.ts.html +2 -2
- package/coverage/lcov-report/tests/__helpers__/get-child-helper.ts.html +12 -12
- package/coverage/lcov-report/tests/__helpers__/index.html +2 -2
- package/coverage/lcov-report/tests/__helpers__/index.ts.html +5 -5
- package/coverage/lcov-report/tests/__helpers__/mock-created-helper.ts.html +4 -4
- package/coverage/lcov.info +1135 -1038
- package/dist/tek-components-common.esm.js +613 -496
- package/dist/tek-components-common.umd.js +615 -497
- package/package.json +3 -2
- package/tests/unit/components/tek-drag-grid/tek-drag-grid.spec.ts +112 -0
- package/tests/unit/components/tek-grid/grid-filter-button.spec.ts +846 -0
- package/tests/unit/components/tek-grid/grid.spec.ts +20 -769
- package/tests/unit/components/tree-grid/tree-grid.spec.ts +15 -9
- package/types/components/index.d.ts +3 -0
- package/types/components/tek-drag-grid/interfaces.d.ts +7 -0
- package/types/components/tek-drag-grid/tek-drag-grid.d.ts +36 -0
- package/types/components/tek-grid/grid-filter-button.d.ts +29 -0
- package/types/components/tek-grid/interfaces.d.ts +6 -2
- package/types/utils/grid-base/grid-base.d.ts +9 -19
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
(function (global, factory) {
|
|
2
|
-
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@zeedhi/core'), require('@zeedhi/common'), require('lodash.debounce'), require('lodash.merge'), require('@zeedhi/zd-user-info-common')) :
|
|
3
|
-
typeof define === 'function' && define.amd ? define(['exports', '@zeedhi/core', '@zeedhi/common', 'lodash.debounce', 'lodash.merge', '@zeedhi/zd-user-info-common'], factory) :
|
|
4
|
-
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global["@zeedhi/teknisa-components-common"] = {}, global["@zeedhi/core"], global.common, global.lodash.debounce, global.lodash.merge, global["@zeedhi/zd-user-info-common"]));
|
|
5
|
-
})(this, (function (exports, core, common, debounce, merge, zdUserInfoCommon) { 'use strict';
|
|
2
|
+
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@zeedhi/core'), require('@zeedhi/common'), require('lodash.debounce'), require('lodash.merge'), require('@zeedhi/zd-user-info-common'), require('@zeedhi/zd-drag-grid-common')) :
|
|
3
|
+
typeof define === 'function' && define.amd ? define(['exports', '@zeedhi/core', '@zeedhi/common', 'lodash.debounce', 'lodash.merge', '@zeedhi/zd-user-info-common', '@zeedhi/zd-drag-grid-common'], factory) :
|
|
4
|
+
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global["@zeedhi/teknisa-components-common"] = {}, global["@zeedhi/core"], global.common, global.lodash.debounce, global.lodash.merge, global["@zeedhi/zd-user-info-common"], global["@zeedhi/zd-drag-grid-common"]));
|
|
5
|
+
})(this, (function (exports, core, common, debounce, merge, zdUserInfoCommon, zdDragGridCommon) { 'use strict';
|
|
6
6
|
|
|
7
7
|
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
8
8
|
|
|
@@ -718,7 +718,6 @@
|
|
|
718
718
|
class GridBase {
|
|
719
719
|
constructor(grid) {
|
|
720
720
|
this.exportConfigButtons = [];
|
|
721
|
-
this.filterFormInputs = {};
|
|
722
721
|
this.atoms = {
|
|
723
722
|
TITLE: '_gridTitle',
|
|
724
723
|
ADD_BUTTON: '_addButton',
|
|
@@ -947,18 +946,21 @@
|
|
|
947
946
|
children: [
|
|
948
947
|
{
|
|
949
948
|
name: `${this.grid.name}_filterButton`,
|
|
950
|
-
component: '
|
|
951
|
-
|
|
952
|
-
|
|
949
|
+
component: 'TekGridFilterButton',
|
|
950
|
+
grid: this.grid,
|
|
951
|
+
gridName: this.grid.name,
|
|
953
952
|
isVisible: `{{GridController_${this.grid.componentId}.showFilterButton}}`,
|
|
954
953
|
events: {
|
|
955
|
-
|
|
954
|
+
onCreated: this.loadFilterButton.bind(this),
|
|
956
955
|
},
|
|
957
956
|
},
|
|
958
957
|
],
|
|
959
958
|
},
|
|
960
959
|
];
|
|
961
960
|
}
|
|
961
|
+
loadFilterButton({ component }) {
|
|
962
|
+
this.filterButton = component;
|
|
963
|
+
}
|
|
962
964
|
addButtonClick({ event }) {
|
|
963
965
|
if (this.grid.editNewRowsOnly) {
|
|
964
966
|
this.grid.editingNewRows = true;
|
|
@@ -1003,344 +1005,37 @@
|
|
|
1003
1005
|
this.grid.callEvent('afterCancel', { component: this.grid });
|
|
1004
1006
|
}
|
|
1005
1007
|
}
|
|
1006
|
-
filterClick({ event }) {
|
|
1007
|
-
this.grid.callEvent('filterClick', { component: this.grid, event });
|
|
1008
|
-
if (!event.defaultPrevented) {
|
|
1009
|
-
this.createFilterFromColumns();
|
|
1010
|
-
}
|
|
1011
|
-
}
|
|
1012
|
-
destroyFilterModal() {
|
|
1013
|
-
var _a;
|
|
1014
|
-
(_a = this.filterModal) === null || _a === void 0 ? void 0 : _a.destroy();
|
|
1015
|
-
}
|
|
1016
|
-
createFilterFromColumns() {
|
|
1017
|
-
if (!this.filterModal) {
|
|
1018
|
-
const originalProps = {
|
|
1019
|
-
height: 'auto',
|
|
1020
|
-
persistent: true,
|
|
1021
|
-
title: 'FILTER',
|
|
1022
|
-
};
|
|
1023
|
-
const mergeModalFilterProps = Object.assign(originalProps, this.grid.modalFilterProps);
|
|
1024
|
-
const filterModalDef = {
|
|
1025
|
-
name: `${this.grid.name}-filter-modal`,
|
|
1026
|
-
persistent: mergeModalFilterProps.persistent,
|
|
1027
|
-
grid: mergeModalFilterProps.grid,
|
|
1028
|
-
cssClass: mergeModalFilterProps.cssClass,
|
|
1029
|
-
cssStyle: mergeModalFilterProps.cssStyle,
|
|
1030
|
-
draggable: mergeModalFilterProps.draggable,
|
|
1031
|
-
dragHandle: mergeModalFilterProps.dragHandle,
|
|
1032
|
-
fullscreen: mergeModalFilterProps.fullscreen,
|
|
1033
|
-
light: mergeModalFilterProps.light,
|
|
1034
|
-
dark: mergeModalFilterProps.dark,
|
|
1035
|
-
escKeydownStop: false,
|
|
1036
|
-
children: [
|
|
1037
|
-
{
|
|
1038
|
-
name: `${this.grid.name}-filter-header-container`,
|
|
1039
|
-
component: 'ZdContainer',
|
|
1040
|
-
cssClass: 'zd-pa-0',
|
|
1041
|
-
children: [
|
|
1042
|
-
{
|
|
1043
|
-
name: `${this.grid.name}-filter-modal-header`,
|
|
1044
|
-
component: 'ZdHeader',
|
|
1045
|
-
color: 'transparent',
|
|
1046
|
-
padless: true,
|
|
1047
|
-
elevation: 0,
|
|
1048
|
-
leftSlot: [
|
|
1049
|
-
{
|
|
1050
|
-
name: `${this.grid.name}-filter-title`,
|
|
1051
|
-
component: 'ZdText',
|
|
1052
|
-
cssStyle: `color: ${'var(--v-primary-base);'}`,
|
|
1053
|
-
text: `${mergeModalFilterProps.title}`,
|
|
1054
|
-
tag: 'h3',
|
|
1055
|
-
},
|
|
1056
|
-
],
|
|
1057
|
-
rightSlot: [
|
|
1058
|
-
{
|
|
1059
|
-
name: `${this.grid.name}-filter-close-button`,
|
|
1060
|
-
component: 'ZdModalCloseButton',
|
|
1061
|
-
small: true,
|
|
1062
|
-
modalName: `${this.grid.name}-filter-modal`,
|
|
1063
|
-
},
|
|
1064
|
-
],
|
|
1065
|
-
},
|
|
1066
|
-
],
|
|
1067
|
-
},
|
|
1068
|
-
{
|
|
1069
|
-
name: `${this.grid.name}-filter-content-container`,
|
|
1070
|
-
component: 'ZdContainer',
|
|
1071
|
-
scrollView: true,
|
|
1072
|
-
cssClass: 'zd-my-2 zd-pa-0',
|
|
1073
|
-
maxHeight: '18.75rem',
|
|
1074
|
-
height: this.grid.modalFilterProps.height,
|
|
1075
|
-
children: [
|
|
1076
|
-
{
|
|
1077
|
-
name: `${this.grid.name}-filter-form`,
|
|
1078
|
-
component: 'ZdForm',
|
|
1079
|
-
cssClass: 'zd-my-2',
|
|
1080
|
-
children: this.getFilterModalComponents(),
|
|
1081
|
-
events: {
|
|
1082
|
-
onMounted: this.loadFilterValues.bind(this),
|
|
1083
|
-
},
|
|
1084
|
-
},
|
|
1085
|
-
],
|
|
1086
|
-
},
|
|
1087
|
-
{
|
|
1088
|
-
name: `${this.grid.name}-filter-footer-container`,
|
|
1089
|
-
component: 'ZdContainer',
|
|
1090
|
-
cssClass: 'zd-pa-0',
|
|
1091
|
-
children: [
|
|
1092
|
-
{
|
|
1093
|
-
name: `${this.grid.name}-filter-footer`,
|
|
1094
|
-
component: 'ZdFooter',
|
|
1095
|
-
color: 'transparent',
|
|
1096
|
-
padless: true,
|
|
1097
|
-
leftSlot: [
|
|
1098
|
-
{
|
|
1099
|
-
name: `${this.grid.name}-filter-clearButton`,
|
|
1100
|
-
component: 'ZdButton',
|
|
1101
|
-
label: 'CLEAR',
|
|
1102
|
-
outline: true,
|
|
1103
|
-
events: {
|
|
1104
|
-
click: this.clearFilter.bind(this),
|
|
1105
|
-
},
|
|
1106
|
-
},
|
|
1107
|
-
],
|
|
1108
|
-
rightSlot: [
|
|
1109
|
-
{
|
|
1110
|
-
name: `${this.grid.name}-filter-cancelButton`,
|
|
1111
|
-
component: 'ZdButton',
|
|
1112
|
-
label: 'CANCEL',
|
|
1113
|
-
keyMap: {
|
|
1114
|
-
esc: {
|
|
1115
|
-
event: this.hideFilterModal.bind(this),
|
|
1116
|
-
focus: true,
|
|
1117
|
-
visible: true,
|
|
1118
|
-
input: true,
|
|
1119
|
-
stop: true,
|
|
1120
|
-
},
|
|
1121
|
-
},
|
|
1122
|
-
outline: true,
|
|
1123
|
-
events: {
|
|
1124
|
-
click: this.hideFilterModal.bind(this),
|
|
1125
|
-
},
|
|
1126
|
-
},
|
|
1127
|
-
{
|
|
1128
|
-
name: `${this.grid.name}-filter-okButton`,
|
|
1129
|
-
component: 'ZdButton',
|
|
1130
|
-
label: 'OK',
|
|
1131
|
-
events: {
|
|
1132
|
-
click: this.applyFilter.bind(this),
|
|
1133
|
-
},
|
|
1134
|
-
keyMap: {
|
|
1135
|
-
'mod+enter': {
|
|
1136
|
-
event: this.applyFilter.bind(this),
|
|
1137
|
-
focus: true,
|
|
1138
|
-
input: true,
|
|
1139
|
-
stop: true,
|
|
1140
|
-
visible: true,
|
|
1141
|
-
},
|
|
1142
|
-
},
|
|
1143
|
-
},
|
|
1144
|
-
],
|
|
1145
|
-
},
|
|
1146
|
-
],
|
|
1147
|
-
},
|
|
1148
|
-
],
|
|
1149
|
-
};
|
|
1150
|
-
this.filterModal = common.ModalService.create(filterModalDef);
|
|
1151
|
-
}
|
|
1152
|
-
else {
|
|
1153
|
-
this.loadFilterValues({ component: core.Metadata.getInstance(`${this.grid.name}-filter-form`) });
|
|
1154
|
-
}
|
|
1155
|
-
this.filterModal.show();
|
|
1156
|
-
}
|
|
1157
1008
|
hideFilterModal() {
|
|
1158
|
-
this.
|
|
1159
|
-
}
|
|
1160
|
-
sortFilterIndex(col1, col2) {
|
|
1161
|
-
const index1 = col1.filterIndex !== undefined ? col1.filterIndex : Number.MAX_SAFE_INTEGER;
|
|
1162
|
-
const index2 = col2.filterIndex !== undefined ? col2.filterIndex : Number.MAX_SAFE_INTEGER;
|
|
1163
|
-
return index1 - index2;
|
|
1009
|
+
this.filterButton.hideFilterModal();
|
|
1164
1010
|
}
|
|
1165
|
-
|
|
1166
|
-
|
|
1167
|
-
|
|
1168
|
-
|
|
1169
|
-
|
|
1170
|
-
if (column.filterable && filterProps && filterProps.length > 0) {
|
|
1171
|
-
this.filterFormInputs[column.name] = [];
|
|
1172
|
-
filterProps.forEach((filterItem, index) => {
|
|
1173
|
-
const { datasource } = this.grid;
|
|
1174
|
-
if (datasource instanceof TekRestDatasource || datasource instanceof TekMemoryDatasource) {
|
|
1175
|
-
const relation = filterItem.relation || 'AND';
|
|
1176
|
-
const operation = filterItem.operation || 'CONTAINS';
|
|
1177
|
-
columnComponentName = `${this.grid.name}-filter-${relation}-${operation}-${column.name}-${index}`;
|
|
1178
|
-
}
|
|
1179
|
-
else {
|
|
1180
|
-
columnComponentName = `${this.grid.name}-filter-AND-CONTAINS-${column.name}-${index}`;
|
|
1181
|
-
}
|
|
1182
|
-
this.filterFormInputs[column.name].push(columnComponentName);
|
|
1183
|
-
const newColumnComponent = Object.assign(Object.assign(Object.assign({ label: column.label }, column.componentProps), filterItem), { name: columnComponentName });
|
|
1184
|
-
if (filterItem.helperOptions) {
|
|
1185
|
-
if (!newColumnComponent.events)
|
|
1186
|
-
newColumnComponent.events = {};
|
|
1187
|
-
newColumnComponent.events.change = this.changeHelperEvent.bind(this, column);
|
|
1188
|
-
}
|
|
1189
|
-
filterColumns.push(newColumnComponent);
|
|
1190
|
-
});
|
|
1191
|
-
}
|
|
1011
|
+
getFilterRelationsDatasource() {
|
|
1012
|
+
return core.DatasourceFactory.factory({
|
|
1013
|
+
data: this.getFilterOptionsData('relations'),
|
|
1014
|
+
loadAll: true,
|
|
1015
|
+
translate: ['text'],
|
|
1192
1016
|
});
|
|
1193
|
-
return filterColumns;
|
|
1194
1017
|
}
|
|
1195
|
-
|
|
1196
|
-
|
|
1197
|
-
|
|
1198
|
-
|
|
1199
|
-
|
|
1200
|
-
}
|
|
1201
|
-
else {
|
|
1202
|
-
column.filterProps.forEach((prop) => {
|
|
1203
|
-
const relationAndOperationAndName = componentName.split(`${this.grid.name}-filter-`)[1];
|
|
1204
|
-
const [relation, operation] = relationAndOperationAndName.split('-');
|
|
1205
|
-
if ((prop.relation || 'AND') === relation && (prop.operation || 'CONTAINS') === operation) {
|
|
1206
|
-
prop.helperValue = helperValue;
|
|
1207
|
-
}
|
|
1208
|
-
});
|
|
1209
|
-
}
|
|
1018
|
+
getFilterOperationsDatasource() {
|
|
1019
|
+
return core.DatasourceFactory.factory({
|
|
1020
|
+
data: this.getFilterOptionsData('operations'),
|
|
1021
|
+
loadAll: true,
|
|
1022
|
+
translate: ['text'],
|
|
1023
|
+
});
|
|
1210
1024
|
}
|
|
1211
|
-
|
|
1212
|
-
const changedCompNames = [];
|
|
1025
|
+
getFilterOptionsData(prop) {
|
|
1213
1026
|
const { datasource } = this.grid;
|
|
1214
1027
|
if (datasource instanceof TekRestDatasource || datasource instanceof TekMemoryDatasource) {
|
|
1215
|
-
|
|
1216
|
-
|
|
1217
|
-
|
|
1218
|
-
|
|
1219
|
-
|
|
1220
|
-
|
|
1221
|
-
|
|
1222
|
-
|
|
1223
|
-
|
|
1224
|
-
|
|
1225
|
-
|
|
1226
|
-
if (columnObj instanceof TekGridColumn) {
|
|
1227
|
-
const { filterProps } = columnObj;
|
|
1228
|
-
if (!Array.isArray(filterProps)) {
|
|
1229
|
-
helperValue = filterProps.helperValue || '';
|
|
1230
|
-
}
|
|
1231
|
-
else {
|
|
1232
|
-
filterProps.forEach((prop) => {
|
|
1233
|
-
if ((prop.relation || 'AND') === relation && (prop.operation || 'CONTAINS') === operation) {
|
|
1234
|
-
helperValue = prop.helperValue || '';
|
|
1235
|
-
}
|
|
1236
|
-
});
|
|
1237
|
-
}
|
|
1238
|
-
const inputObj = core.Metadata.getInstances(compName);
|
|
1239
|
-
if (helperValue && inputObj.length && inputObj[0]) {
|
|
1240
|
-
inputObj[0].hint = TekFilterHelper.getLabel(helperValue);
|
|
1241
|
-
}
|
|
1242
|
-
}
|
|
1243
|
-
});
|
|
1244
|
-
}
|
|
1245
|
-
});
|
|
1246
|
-
}
|
|
1247
|
-
else {
|
|
1248
|
-
const { filter } = datasource;
|
|
1249
|
-
Object.keys(filter).forEach((item) => {
|
|
1250
|
-
if (filter[item]) {
|
|
1251
|
-
const compName = `${this.grid.name}-filter-AND-CONTAINS-${item}-0`;
|
|
1252
|
-
changedCompNames.push(compName);
|
|
1253
|
-
component.value[compName] = filter[item];
|
|
1254
|
-
}
|
|
1255
|
-
});
|
|
1256
|
-
}
|
|
1257
|
-
Object.keys(component.value).forEach((compName) => {
|
|
1258
|
-
if (changedCompNames.indexOf(compName) === -1) {
|
|
1259
|
-
component.value[compName] = null;
|
|
1260
|
-
}
|
|
1261
|
-
});
|
|
1262
|
-
}
|
|
1263
|
-
applyFilter({ event }) {
|
|
1264
|
-
const filterForm = core.Metadata.getInstance(`${this.grid.name}-filter-form`);
|
|
1265
|
-
if (filterForm.validate()) {
|
|
1266
|
-
const { datasource } = this.grid;
|
|
1267
|
-
const filter = {};
|
|
1268
|
-
if (datasource instanceof TekRestDatasource || datasource instanceof TekMemoryDatasource) {
|
|
1269
|
-
Object.keys(filterForm.value).forEach((item) => {
|
|
1270
|
-
if (filterForm.value[item] && !(Array.isArray(filterForm.value[item]) && !filterForm.value[item].length)) {
|
|
1271
|
-
const relationAndOperationAndName = item.split(`${this.grid.name}-filter-`)[1];
|
|
1272
|
-
const [relation, operation] = relationAndOperationAndName.split('-');
|
|
1273
|
-
let columnName = relationAndOperationAndName.split(`${relation}-${operation}-`)[1];
|
|
1274
|
-
columnName = columnName.split('-').slice(0, -1).join('-'); // remove index
|
|
1275
|
-
if (!filter[columnName]) {
|
|
1276
|
-
filter[columnName] = [];
|
|
1277
|
-
}
|
|
1278
|
-
const value = filterForm.value[item];
|
|
1279
|
-
filter[columnName].push({
|
|
1280
|
-
relation,
|
|
1281
|
-
operation,
|
|
1282
|
-
value,
|
|
1283
|
-
});
|
|
1284
|
-
}
|
|
1285
|
-
});
|
|
1286
|
-
datasource.dynamicFilter = filter;
|
|
1287
|
-
this.setFilter(filter, event, datasource.setDynamicFilter.bind(datasource));
|
|
1288
|
-
}
|
|
1289
|
-
else {
|
|
1290
|
-
Object.keys(filterForm.value).forEach((item) => {
|
|
1291
|
-
let columnName = item.split(`${this.grid.name}-filter-AND-CONTAINS-`)[1];
|
|
1292
|
-
columnName = columnName.split('-').slice(0, -1).join('-'); // remove index
|
|
1293
|
-
if (filterForm.value[item]) {
|
|
1294
|
-
filter[columnName] = filterForm.value[item];
|
|
1295
|
-
}
|
|
1296
|
-
});
|
|
1297
|
-
datasource.filter = filter;
|
|
1298
|
-
this.setFilter(filter, event, datasource.setFilter.bind(datasource));
|
|
1299
|
-
}
|
|
1300
|
-
this.grid.changeLayout(event);
|
|
1301
|
-
}
|
|
1302
|
-
}
|
|
1303
|
-
setFilter(filter, event, filterFn) {
|
|
1304
|
-
this.grid.callEvent('beforeApplyFilter', { component: this.grid, event });
|
|
1305
|
-
if (event.defaultPrevented)
|
|
1306
|
-
return;
|
|
1307
|
-
filterFn(filter);
|
|
1308
|
-
this.hideFilterModal();
|
|
1309
|
-
}
|
|
1310
|
-
clearFilter() {
|
|
1311
|
-
const filterForm = core.Metadata.getInstance(`${this.grid.name}-filter-form`);
|
|
1312
|
-
Object.keys(filterForm.value).forEach((item) => {
|
|
1313
|
-
filterForm.value[item] = null;
|
|
1314
|
-
});
|
|
1315
|
-
}
|
|
1316
|
-
getFilterRelationsDatasource() {
|
|
1317
|
-
return core.DatasourceFactory.factory({
|
|
1318
|
-
data: this.getFilterOptionsData('relations'),
|
|
1319
|
-
loadAll: true,
|
|
1320
|
-
translate: ['text'],
|
|
1321
|
-
});
|
|
1322
|
-
}
|
|
1323
|
-
getFilterOperationsDatasource() {
|
|
1324
|
-
return core.DatasourceFactory.factory({
|
|
1325
|
-
data: this.getFilterOptionsData('operations'),
|
|
1326
|
-
loadAll: true,
|
|
1327
|
-
translate: ['text'],
|
|
1328
|
-
});
|
|
1329
|
-
}
|
|
1330
|
-
getFilterOptionsData(prop) {
|
|
1331
|
-
const { datasource } = this.grid;
|
|
1332
|
-
if (datasource instanceof TekRestDatasource || datasource instanceof TekMemoryDatasource) {
|
|
1333
|
-
let options;
|
|
1334
|
-
if (prop === 'relations') {
|
|
1335
|
-
options = Object.keys(datasource.dynamicFilterRelations);
|
|
1336
|
-
}
|
|
1337
|
-
else {
|
|
1338
|
-
options = Object.keys(datasource.dynamicFilterOperations);
|
|
1339
|
-
}
|
|
1340
|
-
return options.map((item) => ({
|
|
1341
|
-
text: `TEKGRID_${item}`,
|
|
1342
|
-
value: item,
|
|
1343
|
-
}));
|
|
1028
|
+
let options;
|
|
1029
|
+
if (prop === 'relations') {
|
|
1030
|
+
options = Object.keys(datasource.dynamicFilterRelations);
|
|
1031
|
+
}
|
|
1032
|
+
else {
|
|
1033
|
+
options = Object.keys(datasource.dynamicFilterOperations);
|
|
1034
|
+
}
|
|
1035
|
+
return options.map((item) => ({
|
|
1036
|
+
text: `TEKGRID_${item}`,
|
|
1037
|
+
value: item,
|
|
1038
|
+
}));
|
|
1344
1039
|
}
|
|
1345
1040
|
return [];
|
|
1346
1041
|
}
|
|
@@ -1368,12 +1063,7 @@
|
|
|
1368
1063
|
return core.Metadata.getInstance(`${this.grid.name}${this.atoms[key]}`);
|
|
1369
1064
|
}
|
|
1370
1065
|
getFilterInputs(columnName) {
|
|
1371
|
-
|
|
1372
|
-
if (columnName) {
|
|
1373
|
-
return this.filterFormInputs[columnName].map(mapper);
|
|
1374
|
-
}
|
|
1375
|
-
const values = Object.values(this.filterFormInputs);
|
|
1376
|
-
return values.reduce((result, current) => ([...result, ...current.map(mapper)]), []);
|
|
1066
|
+
return this.filterButton.getFilterInputs(columnName);
|
|
1377
1067
|
}
|
|
1378
1068
|
}
|
|
1379
1069
|
core.Messages.add({
|
|
@@ -2498,10 +2188,10 @@
|
|
|
2498
2188
|
input: true,
|
|
2499
2189
|
},
|
|
2500
2190
|
};
|
|
2191
|
+
this.createAccessors();
|
|
2501
2192
|
this.gridBase = new GridBase(this);
|
|
2502
2193
|
this.filterOperationsDatasource = this.gridBase.getFilterOperationsDatasource();
|
|
2503
2194
|
this.filterRelationsDatasource = this.gridBase.getFilterRelationsDatasource();
|
|
2504
|
-
this.createAccessors();
|
|
2505
2195
|
this.defaultLazy = (_a = props.datasource) === null || _a === void 0 ? void 0 : _a.lazyLoad;
|
|
2506
2196
|
}
|
|
2507
2197
|
onCreated() {
|
|
@@ -2527,7 +2217,6 @@
|
|
|
2527
2217
|
}
|
|
2528
2218
|
onBeforeDestroy() {
|
|
2529
2219
|
super.onBeforeDestroy();
|
|
2530
|
-
this.gridBase.destroyFilterModal();
|
|
2531
2220
|
core.KeyMap.unbind(this.keyShortcutKeyMapping, this);
|
|
2532
2221
|
}
|
|
2533
2222
|
focusSearchInput() {
|
|
@@ -2941,156 +2630,515 @@
|
|
|
2941
2630
|
if (currentRow.group) {
|
|
2942
2631
|
return row.group && row.groupValue === currentRow.groupValue;
|
|
2943
2632
|
}
|
|
2944
|
-
return row[uniqueKey] && row[uniqueKey] === currentRow[uniqueKey];
|
|
2633
|
+
return row[uniqueKey] && row[uniqueKey] === currentRow[uniqueKey];
|
|
2634
|
+
});
|
|
2635
|
+
if (rowIndex === -1)
|
|
2636
|
+
rowIndex = this.groupedData.length;
|
|
2637
|
+
const newRow = this.groupedData[rowIndex - 1];
|
|
2638
|
+
if (newRow && this.isItemVisible(newRow) && !newRow.groupFooter) {
|
|
2639
|
+
this.datasource.currentRow = newRow;
|
|
2640
|
+
}
|
|
2641
|
+
else {
|
|
2642
|
+
this.navigateUp({ index: rowIndex - 1 });
|
|
2643
|
+
}
|
|
2644
|
+
}
|
|
2645
|
+
}
|
|
2646
|
+
navigateLeft() {
|
|
2647
|
+
var _a;
|
|
2648
|
+
const { currentRow } = this.datasource;
|
|
2649
|
+
if (currentRow.group && currentRow.groupOpened) {
|
|
2650
|
+
currentRow.groupOpened = false;
|
|
2651
|
+
}
|
|
2652
|
+
else if ((_a = currentRow.groupHeaders) === null || _a === void 0 ? void 0 : _a.length) {
|
|
2653
|
+
this.datasource.currentRow = currentRow.groupHeaders[currentRow.groupHeaders.length - 1];
|
|
2654
|
+
}
|
|
2655
|
+
}
|
|
2656
|
+
navigateRight() {
|
|
2657
|
+
const { currentRow } = this.datasource;
|
|
2658
|
+
if (currentRow.group && !currentRow.groupOpened) {
|
|
2659
|
+
currentRow.groupOpened = true;
|
|
2660
|
+
}
|
|
2661
|
+
}
|
|
2662
|
+
/**
|
|
2663
|
+
* Dispatches row click event
|
|
2664
|
+
* @param row Grid row
|
|
2665
|
+
* @param event DOM event
|
|
2666
|
+
* @param element DOM Element
|
|
2667
|
+
*/
|
|
2668
|
+
rowClick(row, event, element) {
|
|
2669
|
+
if (!this.preventRowClick) {
|
|
2670
|
+
this.datasource.currentRow = row;
|
|
2671
|
+
this.callEvent('rowClick', {
|
|
2672
|
+
event,
|
|
2673
|
+
element,
|
|
2674
|
+
row,
|
|
2675
|
+
component: this,
|
|
2676
|
+
column: undefined,
|
|
2677
|
+
});
|
|
2678
|
+
}
|
|
2679
|
+
this.preventRowClick = false;
|
|
2680
|
+
}
|
|
2681
|
+
/**
|
|
2682
|
+
* Dispatches group row click event
|
|
2683
|
+
* @param row Grid row
|
|
2684
|
+
* @param event DOM event
|
|
2685
|
+
* @param element DOM Element
|
|
2686
|
+
*/
|
|
2687
|
+
groupRowClick(row, event, element) {
|
|
2688
|
+
if (!this.preventRowClick) {
|
|
2689
|
+
this.callEvent('groupRowClick', {
|
|
2690
|
+
event,
|
|
2691
|
+
element,
|
|
2692
|
+
row,
|
|
2693
|
+
component: this,
|
|
2694
|
+
column: undefined,
|
|
2695
|
+
});
|
|
2696
|
+
}
|
|
2697
|
+
this.preventRowClick = false;
|
|
2698
|
+
}
|
|
2699
|
+
/**
|
|
2700
|
+
* Dispatches group select/unselect event
|
|
2701
|
+
* @param row Group row
|
|
2702
|
+
* @param isSelected Row is selected
|
|
2703
|
+
* @param event DOM event
|
|
2704
|
+
* @param element DOM Element
|
|
2705
|
+
*/
|
|
2706
|
+
selectGroupClick(row, isSelected, event, element) {
|
|
2707
|
+
if (isSelected) {
|
|
2708
|
+
this.callEvent('groupSelected', {
|
|
2709
|
+
event,
|
|
2710
|
+
element,
|
|
2711
|
+
row,
|
|
2712
|
+
component: this,
|
|
2713
|
+
column: undefined,
|
|
2714
|
+
});
|
|
2715
|
+
}
|
|
2716
|
+
else {
|
|
2717
|
+
this.callEvent('groupUnselected', {
|
|
2718
|
+
event,
|
|
2719
|
+
element,
|
|
2720
|
+
row,
|
|
2721
|
+
component: this,
|
|
2722
|
+
column: undefined,
|
|
2723
|
+
});
|
|
2724
|
+
}
|
|
2725
|
+
}
|
|
2726
|
+
getAtomInstance(key) {
|
|
2727
|
+
return this.gridBase.getAtomInstance(key);
|
|
2728
|
+
}
|
|
2729
|
+
getFilterInputs(columnName) {
|
|
2730
|
+
return this.gridBase.getFilterInputs(columnName);
|
|
2731
|
+
}
|
|
2732
|
+
}
|
|
2733
|
+
|
|
2734
|
+
class TekGridColumnsButtonController extends common.IterableColumnsButtonController {
|
|
2735
|
+
changeGroupedColumn(column, { component, event, element }) {
|
|
2736
|
+
column.grouped = component.value;
|
|
2737
|
+
if (!column.grouped) {
|
|
2738
|
+
const index = this.iterableComponent.datasource.order.indexOf(`${column.name}.asc`);
|
|
2739
|
+
this.iterableComponent.datasource.order.splice(index, 1);
|
|
2740
|
+
}
|
|
2741
|
+
this.iterableComponent.changeLayout(event, element);
|
|
2742
|
+
}
|
|
2743
|
+
changeAggregationColumn(column, { component, event, element }) {
|
|
2744
|
+
const newValue = component.value || undefined;
|
|
2745
|
+
if (column.aggregation !== newValue) {
|
|
2746
|
+
this.iterableComponent.changeLayout(event, element);
|
|
2747
|
+
}
|
|
2748
|
+
column.aggregation = newValue;
|
|
2749
|
+
}
|
|
2750
|
+
showHideTekColumn(column, { component, event, element }) {
|
|
2751
|
+
if (!component.value && column.grouped)
|
|
2752
|
+
column.grouped = false;
|
|
2753
|
+
column.isVisible = component.value;
|
|
2754
|
+
this.iterableComponent.changeLayout(event, element);
|
|
2755
|
+
}
|
|
2756
|
+
}
|
|
2757
|
+
|
|
2758
|
+
/**
|
|
2759
|
+
* Base class for TekGrid Columns Button component
|
|
2760
|
+
*/
|
|
2761
|
+
class TekGridColumnsButton extends common.IterableColumnsButton {
|
|
2762
|
+
constructor(props) {
|
|
2763
|
+
super(props);
|
|
2764
|
+
this.hideGroups = false;
|
|
2765
|
+
this.aggregationDataSet = [];
|
|
2766
|
+
this.hideGroups = this.getInitValue('hideGroups', props.hideGroups, this.hideGroups);
|
|
2767
|
+
this.createAccessors();
|
|
2768
|
+
}
|
|
2769
|
+
onCreated() {
|
|
2770
|
+
super.onCreated();
|
|
2771
|
+
this.controller = new TekGridColumnsButtonController(this.iterableComponent);
|
|
2772
|
+
core.Loader.addController(`IterableColumnsButtonController_${this.componentId}`, this.controller);
|
|
2773
|
+
}
|
|
2774
|
+
getAggregationSelectData() {
|
|
2775
|
+
if (!this.aggregationDataSet.length) {
|
|
2776
|
+
this.aggregationDataSet = columnAggregationValues.filter(Boolean).map((value) => ({
|
|
2777
|
+
text: core.I18n.translate(`TEKGRID_AGGREGATION_${value}`),
|
|
2778
|
+
value,
|
|
2779
|
+
}));
|
|
2780
|
+
}
|
|
2781
|
+
return this.aggregationDataSet;
|
|
2782
|
+
}
|
|
2783
|
+
}
|
|
2784
|
+
|
|
2785
|
+
class TekFilterHelper {
|
|
2786
|
+
static getLabel(name) {
|
|
2787
|
+
return core.DateHelper.getLabel(name);
|
|
2788
|
+
}
|
|
2789
|
+
static getValue(name, column) {
|
|
2790
|
+
return core.DateHelper.getValue(name, column.componentProps.dateFormat);
|
|
2791
|
+
}
|
|
2792
|
+
static register(name, label, fn) {
|
|
2793
|
+
core.DateHelper.register(name, label, fn);
|
|
2794
|
+
}
|
|
2795
|
+
static unregister(name) {
|
|
2796
|
+
core.DateHelper.unregister(name);
|
|
2797
|
+
}
|
|
2798
|
+
}
|
|
2799
|
+
|
|
2800
|
+
/**
|
|
2801
|
+
* Base class for TekGrid Filter Button component
|
|
2802
|
+
*/
|
|
2803
|
+
class TekGridFilterButton extends common.Button {
|
|
2804
|
+
constructor(props) {
|
|
2805
|
+
super(props);
|
|
2806
|
+
this.filterFormInputs = {};
|
|
2807
|
+
this.gridName = this.getInitValue('gridName', props.gridName, this.gridName);
|
|
2808
|
+
this.grid = this.getInitValue('grid', props.grid, undefined);
|
|
2809
|
+
this.createAccessors();
|
|
2810
|
+
if (!this.grid)
|
|
2811
|
+
this.loadGrid();
|
|
2812
|
+
}
|
|
2813
|
+
loadGrid(gridName) {
|
|
2814
|
+
if (gridName)
|
|
2815
|
+
this.gridName = gridName;
|
|
2816
|
+
if (!this.gridName)
|
|
2817
|
+
return;
|
|
2818
|
+
this.grid = core.Metadata.getInstances(this.gridName)[0];
|
|
2819
|
+
}
|
|
2820
|
+
click(event) {
|
|
2821
|
+
this.callEvent('click', { component: this, event });
|
|
2822
|
+
this.grid.callEvent('filterClick', { component: this.grid, event });
|
|
2823
|
+
if (!event.defaultPrevented) {
|
|
2824
|
+
this.createFilterFromColumns.call(this);
|
|
2825
|
+
}
|
|
2826
|
+
}
|
|
2827
|
+
loadFilterValues({ component }) {
|
|
2828
|
+
const changedCompNames = [];
|
|
2829
|
+
const { datasource } = this.grid;
|
|
2830
|
+
if (datasource instanceof TekRestDatasource || datasource instanceof TekMemoryDatasource) {
|
|
2831
|
+
const { dynamicFilter } = datasource;
|
|
2832
|
+
Object.keys(dynamicFilter).forEach((column) => {
|
|
2833
|
+
if (dynamicFilter[column] && dynamicFilter[column].length > 0) {
|
|
2834
|
+
dynamicFilter[column].forEach((filterItem, index) => {
|
|
2835
|
+
const relation = filterItem.relation || 'AND';
|
|
2836
|
+
const operation = filterItem.operation || 'CONTAINS';
|
|
2837
|
+
const compName = `${this.grid.name}-filter-${relation}-${operation}-${column}-${index}`;
|
|
2838
|
+
changedCompNames.push(compName);
|
|
2839
|
+
component.value[compName] = filterItem.value;
|
|
2840
|
+
let helperValue = '';
|
|
2841
|
+
const columnObj = this.grid.getColumn(column);
|
|
2842
|
+
if (columnObj instanceof TekGridColumn) {
|
|
2843
|
+
const { filterProps } = columnObj;
|
|
2844
|
+
if (!Array.isArray(filterProps)) {
|
|
2845
|
+
helperValue = filterProps.helperValue || '';
|
|
2846
|
+
}
|
|
2847
|
+
else {
|
|
2848
|
+
filterProps.forEach((prop) => {
|
|
2849
|
+
if ((prop.relation || 'AND') === relation && (prop.operation || 'CONTAINS') === operation) {
|
|
2850
|
+
helperValue = prop.helperValue || '';
|
|
2851
|
+
}
|
|
2852
|
+
});
|
|
2853
|
+
}
|
|
2854
|
+
const inputObj = core.Metadata.getInstances(compName);
|
|
2855
|
+
if (helperValue && inputObj.length && inputObj[0]) {
|
|
2856
|
+
inputObj[0].hint = TekFilterHelper.getLabel(helperValue);
|
|
2857
|
+
}
|
|
2858
|
+
}
|
|
2859
|
+
});
|
|
2860
|
+
}
|
|
2861
|
+
});
|
|
2862
|
+
}
|
|
2863
|
+
else {
|
|
2864
|
+
const { filter } = datasource;
|
|
2865
|
+
Object.keys(filter).forEach((item) => {
|
|
2866
|
+
if (filter[item]) {
|
|
2867
|
+
const compName = `${this.grid.name}-filter-AND-CONTAINS-${item}-0`;
|
|
2868
|
+
changedCompNames.push(compName);
|
|
2869
|
+
component.value[compName] = filter[item];
|
|
2870
|
+
}
|
|
2871
|
+
});
|
|
2872
|
+
}
|
|
2873
|
+
Object.keys(component.value).forEach((compName) => {
|
|
2874
|
+
if (changedCompNames.indexOf(compName) === -1) {
|
|
2875
|
+
component.value[compName] = null;
|
|
2876
|
+
}
|
|
2877
|
+
});
|
|
2878
|
+
}
|
|
2879
|
+
hideFilterModal() {
|
|
2880
|
+
this.filterModal.hide();
|
|
2881
|
+
}
|
|
2882
|
+
destroyFilterModal() {
|
|
2883
|
+
this.filterModal.destroy();
|
|
2884
|
+
}
|
|
2885
|
+
createFilterFromColumns() {
|
|
2886
|
+
if (!this.filterModal) {
|
|
2887
|
+
const originalProps = {
|
|
2888
|
+
height: 'auto',
|
|
2889
|
+
persistent: true,
|
|
2890
|
+
title: 'FILTER',
|
|
2891
|
+
};
|
|
2892
|
+
const mergeModalFilterProps = Object.assign(originalProps, this.grid.modalFilterProps);
|
|
2893
|
+
const filterModalDef = {
|
|
2894
|
+
name: `${this.grid.name}-filter-modal`,
|
|
2895
|
+
persistent: mergeModalFilterProps.persistent,
|
|
2896
|
+
grid: mergeModalFilterProps.grid,
|
|
2897
|
+
cssClass: mergeModalFilterProps.cssClass,
|
|
2898
|
+
cssStyle: mergeModalFilterProps.cssStyle,
|
|
2899
|
+
draggable: mergeModalFilterProps.draggable,
|
|
2900
|
+
dragHandle: mergeModalFilterProps.dragHandle,
|
|
2901
|
+
fullscreen: mergeModalFilterProps.fullscreen,
|
|
2902
|
+
light: mergeModalFilterProps.light,
|
|
2903
|
+
dark: mergeModalFilterProps.dark,
|
|
2904
|
+
escKeydownStop: false,
|
|
2905
|
+
children: [
|
|
2906
|
+
{
|
|
2907
|
+
name: `${this.grid.name}-filter-header-container`,
|
|
2908
|
+
component: 'ZdContainer',
|
|
2909
|
+
cssClass: 'zd-pa-0',
|
|
2910
|
+
children: [
|
|
2911
|
+
{
|
|
2912
|
+
name: `${this.grid.name}-filter-modal-header`,
|
|
2913
|
+
component: 'ZdHeader',
|
|
2914
|
+
color: 'transparent',
|
|
2915
|
+
padless: true,
|
|
2916
|
+
elevation: 0,
|
|
2917
|
+
leftSlot: [
|
|
2918
|
+
{
|
|
2919
|
+
name: `${this.grid.name}-filter-title`,
|
|
2920
|
+
component: 'ZdText',
|
|
2921
|
+
cssStyle: `color: ${'var(--v-primary-base);'}`,
|
|
2922
|
+
text: `${mergeModalFilterProps.title}`,
|
|
2923
|
+
tag: 'h3',
|
|
2924
|
+
},
|
|
2925
|
+
],
|
|
2926
|
+
rightSlot: [
|
|
2927
|
+
{
|
|
2928
|
+
name: `${this.grid.name}-filter-close-button`,
|
|
2929
|
+
component: 'ZdModalCloseButton',
|
|
2930
|
+
small: true,
|
|
2931
|
+
modalName: `${this.grid.name}-filter-modal`,
|
|
2932
|
+
},
|
|
2933
|
+
],
|
|
2934
|
+
},
|
|
2935
|
+
],
|
|
2936
|
+
},
|
|
2937
|
+
{
|
|
2938
|
+
name: `${this.grid.name}-filter-content-container`,
|
|
2939
|
+
component: 'ZdContainer',
|
|
2940
|
+
scrollView: true,
|
|
2941
|
+
cssClass: 'zd-my-2 zd-pa-0',
|
|
2942
|
+
maxHeight: '18.75rem',
|
|
2943
|
+
height: this.grid.modalFilterProps.height,
|
|
2944
|
+
children: [
|
|
2945
|
+
{
|
|
2946
|
+
name: `${this.grid.name}-filter-form`,
|
|
2947
|
+
component: 'ZdForm',
|
|
2948
|
+
cssClass: 'zd-my-2',
|
|
2949
|
+
children: this.getFilterModalComponents(),
|
|
2950
|
+
events: {
|
|
2951
|
+
onMounted: this.loadFilterValues.bind(this),
|
|
2952
|
+
},
|
|
2953
|
+
},
|
|
2954
|
+
],
|
|
2955
|
+
},
|
|
2956
|
+
{
|
|
2957
|
+
name: `${this.grid.name}-filter-footer-container`,
|
|
2958
|
+
component: 'ZdContainer',
|
|
2959
|
+
cssClass: 'zd-pa-0',
|
|
2960
|
+
children: [
|
|
2961
|
+
{
|
|
2962
|
+
name: `${this.grid.name}-filter-footer`,
|
|
2963
|
+
component: 'ZdFooter',
|
|
2964
|
+
color: 'transparent',
|
|
2965
|
+
padless: true,
|
|
2966
|
+
leftSlot: [
|
|
2967
|
+
{
|
|
2968
|
+
name: `${this.grid.name}-filter-clearButton`,
|
|
2969
|
+
component: 'ZdButton',
|
|
2970
|
+
label: 'CLEAR',
|
|
2971
|
+
outline: true,
|
|
2972
|
+
events: {
|
|
2973
|
+
click: this.clearFilter.bind(this),
|
|
2974
|
+
},
|
|
2975
|
+
},
|
|
2976
|
+
],
|
|
2977
|
+
rightSlot: [
|
|
2978
|
+
{
|
|
2979
|
+
name: `${this.grid.name}-filter-cancelButton`,
|
|
2980
|
+
component: 'ZdButton',
|
|
2981
|
+
label: 'CANCEL',
|
|
2982
|
+
keyMap: {
|
|
2983
|
+
esc: {
|
|
2984
|
+
event: this.hideFilterModal.bind(this),
|
|
2985
|
+
focus: true,
|
|
2986
|
+
visible: true,
|
|
2987
|
+
input: true,
|
|
2988
|
+
stop: true,
|
|
2989
|
+
},
|
|
2990
|
+
},
|
|
2991
|
+
outline: true,
|
|
2992
|
+
events: {
|
|
2993
|
+
click: this.hideFilterModal.bind(this),
|
|
2994
|
+
},
|
|
2995
|
+
},
|
|
2996
|
+
{
|
|
2997
|
+
name: `${this.grid.name}-filter-okButton`,
|
|
2998
|
+
component: 'ZdButton',
|
|
2999
|
+
label: 'OK',
|
|
3000
|
+
events: {
|
|
3001
|
+
click: this.applyFilter.bind(this),
|
|
3002
|
+
},
|
|
3003
|
+
keyMap: {
|
|
3004
|
+
'mod+enter': {
|
|
3005
|
+
event: this.applyFilter.bind(this),
|
|
3006
|
+
focus: true,
|
|
3007
|
+
input: true,
|
|
3008
|
+
stop: true,
|
|
3009
|
+
visible: true,
|
|
3010
|
+
},
|
|
3011
|
+
},
|
|
3012
|
+
},
|
|
3013
|
+
],
|
|
3014
|
+
},
|
|
3015
|
+
],
|
|
3016
|
+
},
|
|
3017
|
+
],
|
|
3018
|
+
};
|
|
3019
|
+
this.filterModal = common.ModalService.create(filterModalDef);
|
|
3020
|
+
}
|
|
3021
|
+
else {
|
|
3022
|
+
this.loadFilterValues({ component: core.Metadata.getInstance(`${this.grid.name}-filter-form`) });
|
|
3023
|
+
}
|
|
3024
|
+
this.filterModal.show();
|
|
3025
|
+
}
|
|
3026
|
+
onBeforeDestroy() {
|
|
3027
|
+
super.onBeforeDestroy();
|
|
3028
|
+
this.destroyFilterModal();
|
|
3029
|
+
}
|
|
3030
|
+
applyFilter({ event }) {
|
|
3031
|
+
const filterForm = core.Metadata.getInstance(`${this.grid.name}-filter-form`);
|
|
3032
|
+
if (filterForm.validate()) {
|
|
3033
|
+
const { datasource } = this.grid;
|
|
3034
|
+
const filter = {};
|
|
3035
|
+
if (datasource instanceof TekRestDatasource || datasource instanceof TekMemoryDatasource) {
|
|
3036
|
+
Object.keys(filterForm.value).forEach((item) => {
|
|
3037
|
+
if (filterForm.value[item] && !(Array.isArray(filterForm.value[item]) && !filterForm.value[item].length)) {
|
|
3038
|
+
const relationAndOperationAndName = item.split(`${this.grid.name}-filter-`)[1];
|
|
3039
|
+
const [relation, operation] = relationAndOperationAndName.split('-');
|
|
3040
|
+
let columnName = relationAndOperationAndName.split(`${relation}-${operation}-`)[1];
|
|
3041
|
+
columnName = columnName.split('-').slice(0, -1).join('-'); // remove index
|
|
3042
|
+
if (!filter[columnName]) {
|
|
3043
|
+
filter[columnName] = [];
|
|
3044
|
+
}
|
|
3045
|
+
const value = filterForm.value[item];
|
|
3046
|
+
filter[columnName].push({
|
|
3047
|
+
relation,
|
|
3048
|
+
operation,
|
|
3049
|
+
value,
|
|
3050
|
+
});
|
|
3051
|
+
}
|
|
2945
3052
|
});
|
|
2946
|
-
|
|
2947
|
-
|
|
2948
|
-
const newRow = this.groupedData[rowIndex - 1];
|
|
2949
|
-
if (newRow && this.isItemVisible(newRow) && !newRow.groupFooter) {
|
|
2950
|
-
this.datasource.currentRow = newRow;
|
|
3053
|
+
datasource.dynamicFilter = filter;
|
|
3054
|
+
this.setFilter(filter, event, datasource.setDynamicFilter.bind(datasource));
|
|
2951
3055
|
}
|
|
2952
3056
|
else {
|
|
2953
|
-
|
|
3057
|
+
Object.keys(filterForm.value).forEach((item) => {
|
|
3058
|
+
let columnName = item.split(`${this.grid.name}-filter-AND-CONTAINS-`)[1];
|
|
3059
|
+
columnName = columnName.split('-').slice(0, -1).join('-'); // remove index
|
|
3060
|
+
if (filterForm.value[item]) {
|
|
3061
|
+
filter[columnName] = filterForm.value[item];
|
|
3062
|
+
}
|
|
3063
|
+
});
|
|
3064
|
+
datasource.filter = filter;
|
|
3065
|
+
this.setFilter(filter, event, datasource.setFilter.bind(datasource));
|
|
2954
3066
|
}
|
|
3067
|
+
this.grid.changeLayout(event);
|
|
2955
3068
|
}
|
|
2956
3069
|
}
|
|
2957
|
-
|
|
2958
|
-
|
|
2959
|
-
|
|
2960
|
-
|
|
2961
|
-
|
|
2962
|
-
|
|
2963
|
-
else if ((_a = currentRow.groupHeaders) === null || _a === void 0 ? void 0 : _a.length) {
|
|
2964
|
-
this.datasource.currentRow = currentRow.groupHeaders[currentRow.groupHeaders.length - 1];
|
|
2965
|
-
}
|
|
3070
|
+
setFilter(filter, event, filterFn) {
|
|
3071
|
+
this.grid.callEvent('beforeApplyFilter', { component: this.grid, event });
|
|
3072
|
+
if (event.defaultPrevented)
|
|
3073
|
+
return;
|
|
3074
|
+
filterFn(filter);
|
|
3075
|
+
this.hideFilterModal();
|
|
2966
3076
|
}
|
|
2967
|
-
|
|
2968
|
-
const
|
|
2969
|
-
|
|
2970
|
-
|
|
2971
|
-
}
|
|
3077
|
+
clearFilter() {
|
|
3078
|
+
const filterForm = core.Metadata.getInstance(`${this.grid.name}-filter-form`);
|
|
3079
|
+
Object.keys(filterForm.value).forEach((item) => {
|
|
3080
|
+
filterForm.value[item] = null;
|
|
3081
|
+
});
|
|
2972
3082
|
}
|
|
2973
|
-
|
|
2974
|
-
|
|
2975
|
-
|
|
2976
|
-
|
|
2977
|
-
* @param element DOM Element
|
|
2978
|
-
*/
|
|
2979
|
-
rowClick(row, event, element) {
|
|
2980
|
-
if (!this.preventRowClick) {
|
|
2981
|
-
this.datasource.currentRow = row;
|
|
2982
|
-
this.callEvent('rowClick', {
|
|
2983
|
-
event,
|
|
2984
|
-
element,
|
|
2985
|
-
row,
|
|
2986
|
-
component: this,
|
|
2987
|
-
column: undefined,
|
|
2988
|
-
});
|
|
2989
|
-
}
|
|
2990
|
-
this.preventRowClick = false;
|
|
3083
|
+
sortFilterIndex(col1, col2) {
|
|
3084
|
+
const index1 = col1.filterIndex !== undefined ? col1.filterIndex : Number.MAX_SAFE_INTEGER;
|
|
3085
|
+
const index2 = col2.filterIndex !== undefined ? col2.filterIndex : Number.MAX_SAFE_INTEGER;
|
|
3086
|
+
return index1 - index2;
|
|
2991
3087
|
}
|
|
2992
|
-
|
|
2993
|
-
|
|
2994
|
-
|
|
2995
|
-
|
|
2996
|
-
* @param element DOM Element
|
|
2997
|
-
*/
|
|
2998
|
-
groupRowClick(row, event, element) {
|
|
2999
|
-
if (!this.preventRowClick) {
|
|
3000
|
-
this.callEvent('groupRowClick', {
|
|
3001
|
-
event,
|
|
3002
|
-
element,
|
|
3003
|
-
row,
|
|
3004
|
-
component: this,
|
|
3005
|
-
column: undefined,
|
|
3006
|
-
});
|
|
3088
|
+
getFilterInputs(columnName) {
|
|
3089
|
+
const mapper = (name) => core.Metadata.getInstance(name);
|
|
3090
|
+
if (columnName) {
|
|
3091
|
+
return this.filterFormInputs[columnName].map(mapper);
|
|
3007
3092
|
}
|
|
3008
|
-
|
|
3093
|
+
const values = Object.values(this.filterFormInputs);
|
|
3094
|
+
return values.reduce((result, current) => ([...result, ...current.map(mapper)]), []);
|
|
3009
3095
|
}
|
|
3010
|
-
|
|
3011
|
-
|
|
3012
|
-
|
|
3013
|
-
|
|
3014
|
-
|
|
3015
|
-
|
|
3016
|
-
|
|
3017
|
-
|
|
3018
|
-
|
|
3019
|
-
|
|
3020
|
-
|
|
3021
|
-
|
|
3022
|
-
|
|
3023
|
-
|
|
3024
|
-
|
|
3025
|
-
|
|
3096
|
+
getFilterModalComponents() {
|
|
3097
|
+
const filterColumns = [];
|
|
3098
|
+
let columnComponentName;
|
|
3099
|
+
[...this.grid.columns].sort(this.sortFilterIndex).forEach((column) => {
|
|
3100
|
+
const filterProps = Array.isArray(column.filterProps) ? column.filterProps : [column.filterProps];
|
|
3101
|
+
if (column.filterable && filterProps && filterProps.length > 0) {
|
|
3102
|
+
this.filterFormInputs[column.name] = [];
|
|
3103
|
+
filterProps.forEach((filterItem, index) => {
|
|
3104
|
+
const { datasource } = this.grid;
|
|
3105
|
+
if (datasource instanceof TekRestDatasource || datasource instanceof TekMemoryDatasource) {
|
|
3106
|
+
const relation = filterItem.relation || 'AND';
|
|
3107
|
+
const operation = filterItem.operation || 'CONTAINS';
|
|
3108
|
+
columnComponentName = `${this.grid.name}-filter-${relation}-${operation}-${column.name}-${index}`;
|
|
3109
|
+
}
|
|
3110
|
+
else {
|
|
3111
|
+
columnComponentName = `${this.grid.name}-filter-AND-CONTAINS-${column.name}-${index}`;
|
|
3112
|
+
}
|
|
3113
|
+
this.filterFormInputs[column.name].push(columnComponentName);
|
|
3114
|
+
const newColumnComponent = Object.assign(Object.assign(Object.assign({ label: column.label }, column.componentProps), filterItem), { name: columnComponentName });
|
|
3115
|
+
if (filterItem.helperOptions) {
|
|
3116
|
+
if (!newColumnComponent.events)
|
|
3117
|
+
newColumnComponent.events = {};
|
|
3118
|
+
newColumnComponent.events.change = this.changeHelperEvent.bind(this, column);
|
|
3119
|
+
}
|
|
3120
|
+
filterColumns.push(newColumnComponent);
|
|
3121
|
+
});
|
|
3122
|
+
}
|
|
3123
|
+
});
|
|
3124
|
+
return filterColumns;
|
|
3125
|
+
}
|
|
3126
|
+
changeHelperEvent(column, { component }) {
|
|
3127
|
+
const { helperValue } = component;
|
|
3128
|
+
const componentName = component.name;
|
|
3129
|
+
if (!Array.isArray(column.filterProps)) {
|
|
3130
|
+
column.filterProps.helperValue = helperValue;
|
|
3026
3131
|
}
|
|
3027
3132
|
else {
|
|
3028
|
-
|
|
3029
|
-
|
|
3030
|
-
|
|
3031
|
-
|
|
3032
|
-
|
|
3033
|
-
|
|
3133
|
+
column.filterProps.forEach((prop) => {
|
|
3134
|
+
const relationAndOperationAndName = componentName.split(`${this.grid.name}-filter-`)[1];
|
|
3135
|
+
const [relation, operation] = relationAndOperationAndName.split('-');
|
|
3136
|
+
if ((prop.relation || 'AND') === relation && (prop.operation || 'CONTAINS') === operation) {
|
|
3137
|
+
prop.helperValue = helperValue;
|
|
3138
|
+
}
|
|
3034
3139
|
});
|
|
3035
3140
|
}
|
|
3036
3141
|
}
|
|
3037
|
-
getAtomInstance(key) {
|
|
3038
|
-
return this.gridBase.getAtomInstance(key);
|
|
3039
|
-
}
|
|
3040
|
-
getFilterInputs(columnName) {
|
|
3041
|
-
return this.gridBase.getFilterInputs(columnName);
|
|
3042
|
-
}
|
|
3043
|
-
}
|
|
3044
|
-
|
|
3045
|
-
class TekGridColumnsButtonController extends common.IterableColumnsButtonController {
|
|
3046
|
-
changeGroupedColumn(column, { component, event, element }) {
|
|
3047
|
-
column.grouped = component.value;
|
|
3048
|
-
if (!column.grouped) {
|
|
3049
|
-
const index = this.iterableComponent.datasource.order.indexOf(`${column.name}.asc`);
|
|
3050
|
-
this.iterableComponent.datasource.order.splice(index, 1);
|
|
3051
|
-
}
|
|
3052
|
-
this.iterableComponent.changeLayout(event, element);
|
|
3053
|
-
}
|
|
3054
|
-
changeAggregationColumn(column, { component, event, element }) {
|
|
3055
|
-
const newValue = component.value || undefined;
|
|
3056
|
-
if (column.aggregation !== newValue) {
|
|
3057
|
-
this.iterableComponent.changeLayout(event, element);
|
|
3058
|
-
}
|
|
3059
|
-
column.aggregation = newValue;
|
|
3060
|
-
}
|
|
3061
|
-
showHideTekColumn(column, { component, event, element }) {
|
|
3062
|
-
if (!component.value && column.grouped)
|
|
3063
|
-
column.grouped = false;
|
|
3064
|
-
column.isVisible = component.value;
|
|
3065
|
-
this.iterableComponent.changeLayout(event, element);
|
|
3066
|
-
}
|
|
3067
|
-
}
|
|
3068
|
-
|
|
3069
|
-
/**
|
|
3070
|
-
* Base class for TekGrid Columns Button component
|
|
3071
|
-
*/
|
|
3072
|
-
class TekGridColumnsButton extends common.IterableColumnsButton {
|
|
3073
|
-
constructor(props) {
|
|
3074
|
-
super(props);
|
|
3075
|
-
this.hideGroups = false;
|
|
3076
|
-
this.aggregationDataSet = [];
|
|
3077
|
-
this.hideGroups = this.getInitValue('hideGroups', props.hideGroups, this.hideGroups);
|
|
3078
|
-
this.createAccessors();
|
|
3079
|
-
}
|
|
3080
|
-
onCreated() {
|
|
3081
|
-
super.onCreated();
|
|
3082
|
-
this.controller = new TekGridColumnsButtonController(this.iterableComponent);
|
|
3083
|
-
core.Loader.addController(`IterableColumnsButtonController_${this.componentId}`, this.controller);
|
|
3084
|
-
}
|
|
3085
|
-
getAggregationSelectData() {
|
|
3086
|
-
if (!this.aggregationDataSet.length) {
|
|
3087
|
-
this.aggregationDataSet = columnAggregationValues.filter(Boolean).map((value) => ({
|
|
3088
|
-
text: core.I18n.translate(`TEKGRID_AGGREGATION_${value}`),
|
|
3089
|
-
value,
|
|
3090
|
-
}));
|
|
3091
|
-
}
|
|
3092
|
-
return this.aggregationDataSet;
|
|
3093
|
-
}
|
|
3094
3142
|
}
|
|
3095
3143
|
|
|
3096
3144
|
class TekGridLayoutOptions extends common.ComponentRender {
|
|
@@ -3279,21 +3327,6 @@
|
|
|
3279
3327
|
}
|
|
3280
3328
|
}
|
|
3281
3329
|
|
|
3282
|
-
class TekFilterHelper {
|
|
3283
|
-
static getLabel(name) {
|
|
3284
|
-
return core.DateHelper.getLabel(name);
|
|
3285
|
-
}
|
|
3286
|
-
static getValue(name, column) {
|
|
3287
|
-
return core.DateHelper.getValue(name, column.componentProps.dateFormat);
|
|
3288
|
-
}
|
|
3289
|
-
static register(name, label, fn) {
|
|
3290
|
-
core.DateHelper.register(name, label, fn);
|
|
3291
|
-
}
|
|
3292
|
-
static unregister(name) {
|
|
3293
|
-
core.DateHelper.unregister(name);
|
|
3294
|
-
}
|
|
3295
|
-
}
|
|
3296
|
-
|
|
3297
3330
|
/* TekTreeGrid Class */
|
|
3298
3331
|
class TekTreeGrid extends common.TreeGridEditable {
|
|
3299
3332
|
/**
|
|
@@ -3966,6 +3999,89 @@
|
|
|
3966
3999
|
}
|
|
3967
4000
|
}
|
|
3968
4001
|
|
|
4002
|
+
class TekDragGrid extends TekGrid {
|
|
4003
|
+
constructor(props) {
|
|
4004
|
+
super(Object.assign(Object.assign({}, props), { datasource: Object.assign(Object.assign({}, props.datasource), { order: [`${props.orderColumnName}.${props.orderMode || 'asc'}`] }) }));
|
|
4005
|
+
this.internalOrderColumnName = '';
|
|
4006
|
+
this.internalOrderMode = 'asc';
|
|
4007
|
+
this.internalOrderColumnName = this.getInitValue('orderColumnName', props.orderColumnName, this.orderColumnName);
|
|
4008
|
+
this.internalOrderMode = this.getInitValue('orderMode', props.orderMode, this.orderMode);
|
|
4009
|
+
this.createAccessors();
|
|
4010
|
+
this.draggable = new zdDragGridCommon.Draggable(this.orderColumnName, this.orderMode);
|
|
4011
|
+
}
|
|
4012
|
+
set orderColumnName(value) {
|
|
4013
|
+
this.internalOrderColumnName = value;
|
|
4014
|
+
this.draggable.orderColumnName = value;
|
|
4015
|
+
}
|
|
4016
|
+
get orderColumnName() {
|
|
4017
|
+
return this.internalOrderColumnName;
|
|
4018
|
+
}
|
|
4019
|
+
set orderMode(value) {
|
|
4020
|
+
this.internalOrderMode = value;
|
|
4021
|
+
this.draggable.orderColumnName = value;
|
|
4022
|
+
}
|
|
4023
|
+
get orderMode() {
|
|
4024
|
+
return this.internalOrderMode;
|
|
4025
|
+
}
|
|
4026
|
+
/**
|
|
4027
|
+
* Event triggered when dragged element is moving
|
|
4028
|
+
* @param event DOM event
|
|
4029
|
+
* @param row row being dragged
|
|
4030
|
+
* @param element HTML element
|
|
4031
|
+
* @returns return false to cancel dragging
|
|
4032
|
+
*/
|
|
4033
|
+
onDragMove(event, row, element) {
|
|
4034
|
+
this.callEvent('onDragMove', {
|
|
4035
|
+
component: this,
|
|
4036
|
+
event,
|
|
4037
|
+
row,
|
|
4038
|
+
element,
|
|
4039
|
+
});
|
|
4040
|
+
return true;
|
|
4041
|
+
}
|
|
4042
|
+
/**
|
|
4043
|
+
* Event triggered when drag starts
|
|
4044
|
+
* @param event DOM event
|
|
4045
|
+
* @param row row being dragged
|
|
4046
|
+
* @param element HTML element
|
|
4047
|
+
*/
|
|
4048
|
+
onDragStart(event, row, element) {
|
|
4049
|
+
return this.callEvent('onDragStart', {
|
|
4050
|
+
component: this,
|
|
4051
|
+
event,
|
|
4052
|
+
row,
|
|
4053
|
+
element,
|
|
4054
|
+
});
|
|
4055
|
+
}
|
|
4056
|
+
/**
|
|
4057
|
+
* Event triggered when drag ends
|
|
4058
|
+
* @param event DOM event
|
|
4059
|
+
* @param row row being dragged
|
|
4060
|
+
* @param element HTML element
|
|
4061
|
+
*/
|
|
4062
|
+
onDragEnd(event, row, element) {
|
|
4063
|
+
const { oldIndex, newIndex } = event;
|
|
4064
|
+
const changes = this.draggable.getDragChanges(oldIndex, newIndex, this.datasource, this.getEditedRows());
|
|
4065
|
+
this.editing = true;
|
|
4066
|
+
changes.forEach((change) => {
|
|
4067
|
+
this.changeEditableComponent({ name: this.orderColumnName }, change.row, change.value);
|
|
4068
|
+
});
|
|
4069
|
+
this.callEvent('inlineEdit', {
|
|
4070
|
+
event,
|
|
4071
|
+
element,
|
|
4072
|
+
row,
|
|
4073
|
+
column: { name: this.orderColumnName },
|
|
4074
|
+
component: this,
|
|
4075
|
+
});
|
|
4076
|
+
this.callEvent('onDragEnd', {
|
|
4077
|
+
component: this,
|
|
4078
|
+
event,
|
|
4079
|
+
row,
|
|
4080
|
+
element,
|
|
4081
|
+
});
|
|
4082
|
+
}
|
|
4083
|
+
}
|
|
4084
|
+
|
|
3969
4085
|
core.Messages.add({
|
|
3970
4086
|
'pt-BR': {
|
|
3971
4087
|
translation: {
|
|
@@ -4033,10 +4149,12 @@
|
|
|
4033
4149
|
exports.Loading = Loading;
|
|
4034
4150
|
exports.Notifications = Notifications;
|
|
4035
4151
|
exports.ProductCard = ProductCard;
|
|
4152
|
+
exports.TekDragGrid = TekDragGrid;
|
|
4036
4153
|
exports.TekFilterHelper = TekFilterHelper;
|
|
4037
4154
|
exports.TekGrid = TekGrid;
|
|
4038
4155
|
exports.TekGridColumn = TekGridColumn;
|
|
4039
4156
|
exports.TekGridColumnsButton = TekGridColumnsButton;
|
|
4157
|
+
exports.TekGridFilterButton = TekGridFilterButton;
|
|
4040
4158
|
exports.TekGridLayoutOptions = TekGridLayoutOptions;
|
|
4041
4159
|
exports.TekMemoryDatasource = TekMemoryDatasource;
|
|
4042
4160
|
exports.TekRestDatasource = TekRestDatasource;
|