@zeedhi/teknisa-components-common 1.94.0 → 1.96.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 +662 -640
- package/coverage/coverage-final.json +12 -12
- package/coverage/lcov-report/index.html +14 -14
- package/coverage/lcov-report/tests/__helpers__/component-event-helper.ts.html +2 -2
- package/coverage/lcov-report/tests/__helpers__/flush-promises-helper.ts.html +1 -1
- package/coverage/lcov-report/tests/__helpers__/get-child-helper.ts.html +9 -9
- package/coverage/lcov-report/tests/__helpers__/index.html +1 -1
- package/coverage/lcov-report/tests/__helpers__/index.ts.html +1 -1
- package/coverage/lcov-report/tests/__helpers__/mock-created-helper.ts.html +1 -1
- package/coverage/lcov.info +1145 -1106
- package/dist/tek-components-common.esm.js +66 -35
- package/dist/tek-components-common.umd.js +64 -33
- package/package.json +2 -2
- package/tests/unit/components/tek-grid/grid-filter-button.spec.ts +129 -2
- package/tests/unit/components/tek-image/Image.spec.ts +21 -0
- package/types/components/tek-grid/grid-filter-button.d.ts +2 -0
- package/types/components/tek-grid/grid.d.ts +1 -0
- package/types/components/tek-grid/interfaces.d.ts +4 -1
- package/types/components/tek-image/image.d.ts +1 -0
- package/types/components/tek-tree-grid/interfaces.d.ts +1 -0
- package/types/components/tek-tree-grid/tree-grid.d.ts +1 -0
- package/types/utils/config/config.d.ts +2 -0
- package/types/utils/grid-base/grid-base.d.ts +1 -0
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { KeyMap, I18n, FormatterParserProvider, Messages, DatasourceFactory, Metadata, MemoryDatasource, URL, Utils, RestDatasource, Loader, DateHelper,
|
|
2
|
-
import { Form, Button, Tooltip, GridEditable, Grid, ComponentRender, Iterable, Carousel, IterableComponentRender as IterableComponentRender$1, Loading as Loading$1, GridColumnEditable, Report, ColumnNotFoundError, IterableColumnsButtonController, IterableColumnsButton, ModalService, TreeGridEditable, List } from '@zeedhi/common';
|
|
1
|
+
import { KeyMap, I18n, FormatterParserProvider, Messages, DatasourceFactory, Metadata, MemoryDatasource, URL, Utils, RestDatasource, Config, Loader, DateHelper, Http, Singleton, VersionService } from '@zeedhi/core';
|
|
2
|
+
import { Form, Button, Tooltip, GridEditable, Grid, ComponentRender, Iterable, Carousel, IterableComponentRender as IterableComponentRender$1, Loading as Loading$1, GridColumnEditable, Report, ColumnNotFoundError, IterableColumnsButtonController, IterableColumnsButton, ModalService, SelectMultiple, TreeGridEditable, List } from '@zeedhi/common';
|
|
3
3
|
import debounce from 'lodash.debounce';
|
|
4
4
|
import merge from 'lodash.merge';
|
|
5
5
|
import { UserInfo } from '@zeedhi/zd-user-info-common';
|
|
@@ -436,6 +436,9 @@ class Image extends ComponentRender {
|
|
|
436
436
|
this.maxWidth = this.getInitValue('maxWidth', props.maxWidth, this.maxWidth);
|
|
437
437
|
this.createAccessors();
|
|
438
438
|
}
|
|
439
|
+
load(event, element) {
|
|
440
|
+
this.callEvent('load', { event, element, component: this });
|
|
441
|
+
}
|
|
439
442
|
}
|
|
440
443
|
|
|
441
444
|
/**
|
|
@@ -1029,6 +1032,7 @@ class GridBase {
|
|
|
1029
1032
|
component: 'TekGridFilterButton',
|
|
1030
1033
|
grid: this.grid,
|
|
1031
1034
|
gridName: this.grid.name,
|
|
1035
|
+
showCheckboxAll: this.grid.showCheckboxAllFilter,
|
|
1032
1036
|
isVisible: `{{GridController_${this.grid.componentId}.showFilterButton}}`,
|
|
1033
1037
|
events: {
|
|
1034
1038
|
onCreated: this.loadFilterButton.bind(this),
|
|
@@ -2217,6 +2221,7 @@ class TekGrid extends GridEditable {
|
|
|
2217
2221
|
this.groupedData = [];
|
|
2218
2222
|
this.toolbarSlotProps = false;
|
|
2219
2223
|
this.editNewRowsOnly = false;
|
|
2224
|
+
this.showCheckboxAllFilter = Config.gridShowCheckboxAllFilter || false;
|
|
2220
2225
|
this.defaultLazy = false;
|
|
2221
2226
|
this.groups = [];
|
|
2222
2227
|
this.summary = {};
|
|
@@ -2247,6 +2252,7 @@ class TekGrid extends GridEditable {
|
|
|
2247
2252
|
this.exportActions = props.exportActions || this.exportActions;
|
|
2248
2253
|
this.groupsOpened = this.getInitValue('groupsOpened', props.groupsOpened, this.groupsOpened);
|
|
2249
2254
|
this.showSummaryTotal = this.getInitValue('showSummaryTotal', props.showSummaryTotal, this.showSummaryTotal);
|
|
2255
|
+
this.showCheckboxAllFilter = this.getInitValue('showCheckboxAllFilter', props.showCheckboxAllFilter, this.showCheckboxAllFilter);
|
|
2250
2256
|
this.editNewRowsOnly = this.getInitValue('editNewRowsOnly', props.editNewRowsOnly, this.editNewRowsOnly);
|
|
2251
2257
|
this.mainGrid = this.getInitValue('mainGrid', props.mainGrid, this.mainGrid);
|
|
2252
2258
|
this.actions = props.actions || this.actions;
|
|
@@ -2450,6 +2456,7 @@ class TekGrid extends GridEditable {
|
|
|
2450
2456
|
}
|
|
2451
2457
|
updateGroupedData(lazyLoad) {
|
|
2452
2458
|
return __awaiter(this, void 0, void 0, function* () {
|
|
2459
|
+
this.initSummaryColumns();
|
|
2453
2460
|
this.groupedData = [];
|
|
2454
2461
|
this.groupColumns = this.columns.filter((column) => column.grouped);
|
|
2455
2462
|
this.groupColumnNames = this.groupColumns.map((column) => column.name);
|
|
@@ -2921,9 +2928,11 @@ class TekFilterHelper {
|
|
|
2921
2928
|
class TekGridFilterButton extends Button {
|
|
2922
2929
|
constructor(props) {
|
|
2923
2930
|
super(props);
|
|
2931
|
+
this.showCheckboxAll = false;
|
|
2924
2932
|
this.filterFormInputs = {};
|
|
2925
2933
|
this.gridName = this.getInitValue('gridName', props.gridName, this.gridName);
|
|
2926
2934
|
this.grid = this.getInitValue('grid', props.grid, undefined);
|
|
2935
|
+
this.showCheckboxAll = this.getInitValue('showCheckboxAll', props.showCheckboxAll, this.showCheckboxAll);
|
|
2927
2936
|
this.createAccessors();
|
|
2928
2937
|
if (!this.grid)
|
|
2929
2938
|
this.loadGrid();
|
|
@@ -3005,6 +3014,7 @@ class TekGridFilterButton extends Button {
|
|
|
3005
3014
|
if (!this.filterModal) {
|
|
3006
3015
|
const originalProps = {
|
|
3007
3016
|
height: 'auto',
|
|
3017
|
+
maxHeight: '18.75rem',
|
|
3008
3018
|
persistent: true,
|
|
3009
3019
|
title: 'FILTER',
|
|
3010
3020
|
};
|
|
@@ -3025,31 +3035,24 @@ class TekGridFilterButton extends Button {
|
|
|
3025
3035
|
{
|
|
3026
3036
|
name: `${this.grid.name}-filter-header-container`,
|
|
3027
3037
|
component: 'ZdContainer',
|
|
3028
|
-
cssClass: 'zd-pa-0',
|
|
3038
|
+
cssClass: 'zd-pa-0 zd-display-flex',
|
|
3029
3039
|
children: [
|
|
3030
3040
|
{
|
|
3031
|
-
name: `${this.grid.name}-filter-
|
|
3032
|
-
component: '
|
|
3033
|
-
color: '
|
|
3034
|
-
|
|
3035
|
-
|
|
3036
|
-
|
|
3037
|
-
|
|
3038
|
-
|
|
3039
|
-
|
|
3040
|
-
|
|
3041
|
-
|
|
3042
|
-
|
|
3043
|
-
|
|
3044
|
-
|
|
3045
|
-
|
|
3046
|
-
{
|
|
3047
|
-
name: `${this.grid.name}-filter-close-button`,
|
|
3048
|
-
component: 'ZdModalCloseButton',
|
|
3049
|
-
small: true,
|
|
3050
|
-
modalName: `${this.grid.name}-filter-modal`,
|
|
3051
|
-
},
|
|
3052
|
-
],
|
|
3041
|
+
name: `${this.grid.name}-filter-title`,
|
|
3042
|
+
component: 'ZdText',
|
|
3043
|
+
cssStyle: `color: ${'var(--v-primary-base);'}`,
|
|
3044
|
+
text: mergeModalFilterProps.title,
|
|
3045
|
+
tag: 'h3',
|
|
3046
|
+
},
|
|
3047
|
+
{
|
|
3048
|
+
name: `${this.grid.name}-filter-spacer`,
|
|
3049
|
+
component: 'VSpacer',
|
|
3050
|
+
},
|
|
3051
|
+
{
|
|
3052
|
+
name: `${this.grid.name}-filter-close-button`,
|
|
3053
|
+
component: 'ZdModalCloseButton',
|
|
3054
|
+
small: true,
|
|
3055
|
+
modalName: `${this.grid.name}-filter-modal`,
|
|
3053
3056
|
},
|
|
3054
3057
|
],
|
|
3055
3058
|
},
|
|
@@ -3057,14 +3060,14 @@ class TekGridFilterButton extends Button {
|
|
|
3057
3060
|
name: `${this.grid.name}-filter-content-container`,
|
|
3058
3061
|
component: 'ZdContainer',
|
|
3059
3062
|
scrollView: true,
|
|
3060
|
-
cssClass: 'zd-my-2 zd-pa-0',
|
|
3061
|
-
maxHeight:
|
|
3062
|
-
height:
|
|
3063
|
+
cssClass: 'zd-my-2 zd-pa-0 tek-grid-filter-content-container',
|
|
3064
|
+
maxHeight: mergeModalFilterProps.maxHeight,
|
|
3065
|
+
height: mergeModalFilterProps.height,
|
|
3063
3066
|
children: [
|
|
3064
3067
|
{
|
|
3065
3068
|
name: `${this.grid.name}-filter-form`,
|
|
3066
3069
|
component: 'ZdForm',
|
|
3067
|
-
cssClass: 'zd-my-2',
|
|
3070
|
+
cssClass: 'zd-my-2 zd-pa-0',
|
|
3068
3071
|
children: this.getFilterModalComponents(),
|
|
3069
3072
|
events: {
|
|
3070
3073
|
onMounted: this.loadFilterValues.bind(this),
|
|
@@ -3146,14 +3149,36 @@ class TekGridFilterButton extends Button {
|
|
|
3146
3149
|
super.onBeforeDestroy();
|
|
3147
3150
|
this.destroyFilterModal();
|
|
3148
3151
|
}
|
|
3152
|
+
formatFormValue(filterForm) {
|
|
3153
|
+
return Object.keys(filterForm.value).reduce((result, item) => {
|
|
3154
|
+
try {
|
|
3155
|
+
const itemInstance = filterForm.getChildInstance(item);
|
|
3156
|
+
if (!(itemInstance instanceof SelectMultiple) || !itemInstance.checkboxAll)
|
|
3157
|
+
return result;
|
|
3158
|
+
// when selectmultiple with checkboxAll, should either remove it from the filter or
|
|
3159
|
+
// change the value to T, depending on selectAllCompatibilityMode
|
|
3160
|
+
if (Config.selectAllCompatibilityMode) {
|
|
3161
|
+
result[item] = 'T';
|
|
3162
|
+
return result;
|
|
3163
|
+
}
|
|
3164
|
+
delete result[item];
|
|
3165
|
+
return result;
|
|
3166
|
+
}
|
|
3167
|
+
catch (e) {
|
|
3168
|
+
return result;
|
|
3169
|
+
}
|
|
3170
|
+
}, Object.assign({}, filterForm.value));
|
|
3171
|
+
}
|
|
3149
3172
|
applyFilter({ event }) {
|
|
3150
3173
|
const filterForm = Metadata.getInstance(`${this.grid.name}-filter-form`);
|
|
3151
3174
|
if (filterForm.validate()) {
|
|
3152
3175
|
const { datasource } = this.grid;
|
|
3153
3176
|
const filter = {};
|
|
3177
|
+
const formValue = this.formatFormValue(filterForm);
|
|
3154
3178
|
if (datasource instanceof TekRestDatasource || datasource instanceof TekMemoryDatasource) {
|
|
3155
|
-
Object.keys(
|
|
3156
|
-
|
|
3179
|
+
Object.keys(formValue).forEach((item) => {
|
|
3180
|
+
const itemValue = formValue[item];
|
|
3181
|
+
if (itemValue && !(Array.isArray(itemValue) && !itemValue.length)) {
|
|
3157
3182
|
const relationAndOperationAndName = item.split(`${this.grid.name}-filter-`)[1];
|
|
3158
3183
|
const [relation, operation] = relationAndOperationAndName.split('-');
|
|
3159
3184
|
let columnName = relationAndOperationAndName.split(`${relation}-${operation}-`)[1];
|
|
@@ -3161,7 +3186,7 @@ class TekGridFilterButton extends Button {
|
|
|
3161
3186
|
if (!filter[columnName]) {
|
|
3162
3187
|
filter[columnName] = [];
|
|
3163
3188
|
}
|
|
3164
|
-
const value =
|
|
3189
|
+
const value = itemValue;
|
|
3165
3190
|
filter[columnName].push({
|
|
3166
3191
|
relation,
|
|
3167
3192
|
operation,
|
|
@@ -3173,11 +3198,11 @@ class TekGridFilterButton extends Button {
|
|
|
3173
3198
|
this.setFilter(filter, event, datasource.setDynamicFilter.bind(datasource));
|
|
3174
3199
|
}
|
|
3175
3200
|
else {
|
|
3176
|
-
Object.keys(
|
|
3201
|
+
Object.keys(formValue).forEach((item) => {
|
|
3177
3202
|
let columnName = item.split(`${this.grid.name}-filter-AND-CONTAINS-`)[1];
|
|
3178
3203
|
columnName = columnName.split('-').slice(0, -1).join('-'); // remove index
|
|
3179
|
-
if (
|
|
3180
|
-
filter[columnName] =
|
|
3204
|
+
if (formValue[item]) {
|
|
3205
|
+
filter[columnName] = formValue[item];
|
|
3181
3206
|
}
|
|
3182
3207
|
});
|
|
3183
3208
|
datasource.filter = filter;
|
|
@@ -3220,6 +3245,7 @@ class TekGridFilterButton extends Button {
|
|
|
3220
3245
|
if (column.filterable && filterProps && filterProps.length > 0) {
|
|
3221
3246
|
this.filterFormInputs[column.name] = [];
|
|
3222
3247
|
filterProps.forEach((filterItem, index) => {
|
|
3248
|
+
var _a;
|
|
3223
3249
|
const { datasource } = this.grid;
|
|
3224
3250
|
if (datasource instanceof TekRestDatasource || datasource instanceof TekMemoryDatasource) {
|
|
3225
3251
|
const relation = filterItem.relation || 'AND';
|
|
@@ -3236,6 +3262,9 @@ class TekGridFilterButton extends Button {
|
|
|
3236
3262
|
newColumnComponent.events = {};
|
|
3237
3263
|
newColumnComponent.events.change = this.changeHelperEvent.bind(this, column);
|
|
3238
3264
|
}
|
|
3265
|
+
if (newColumnComponent.component === 'ZdSelectMultiple') {
|
|
3266
|
+
newColumnComponent.showCheckboxAll = (_a = newColumnComponent.showCheckboxAll) !== null && _a !== void 0 ? _a : this.showCheckboxAll;
|
|
3267
|
+
}
|
|
3239
3268
|
filterColumns.push(newColumnComponent);
|
|
3240
3269
|
});
|
|
3241
3270
|
}
|
|
@@ -3555,6 +3584,7 @@ class TekTreeGrid extends TreeGridEditable {
|
|
|
3555
3584
|
},
|
|
3556
3585
|
];
|
|
3557
3586
|
this.toolbarSlotProps = false;
|
|
3587
|
+
this.showCheckboxAllFilter = false;
|
|
3558
3588
|
this.title = this.getInitValue('title', props.title, this.title);
|
|
3559
3589
|
this.addButton = this.getInitValue('addButton', props.addButton, this.addButton);
|
|
3560
3590
|
this.deleteButton = this.getInitValue('deleteButton', props.deleteButton, this.deleteButton);
|
|
@@ -3570,6 +3600,7 @@ class TekTreeGrid extends TreeGridEditable {
|
|
|
3570
3600
|
this.showExport = this.getInitValue('showExport', props.showExport, this.showExport);
|
|
3571
3601
|
this.showReload = this.getInitValue('showReload', props.showReload, this.showReload);
|
|
3572
3602
|
this.exportConfig = this.getInitValue('exportConfig', props.exportConfig, this.exportConfig);
|
|
3603
|
+
this.showCheckboxAllFilter = this.getInitValue('showCheckboxAllFilter', props.showCheckboxAllFilter, this.showCheckboxAllFilter);
|
|
3573
3604
|
this.exportActions = props.exportActions || this.exportActions;
|
|
3574
3605
|
this.actions = props.actions || this.actions;
|
|
3575
3606
|
this.toolbarSlotProps = props.toolbarSlot !== undefined;
|
|
@@ -440,6 +440,9 @@
|
|
|
440
440
|
this.maxWidth = this.getInitValue('maxWidth', props.maxWidth, this.maxWidth);
|
|
441
441
|
this.createAccessors();
|
|
442
442
|
}
|
|
443
|
+
load(event, element) {
|
|
444
|
+
this.callEvent('load', { event, element, component: this });
|
|
445
|
+
}
|
|
443
446
|
}
|
|
444
447
|
|
|
445
448
|
/**
|
|
@@ -1033,6 +1036,7 @@
|
|
|
1033
1036
|
component: 'TekGridFilterButton',
|
|
1034
1037
|
grid: this.grid,
|
|
1035
1038
|
gridName: this.grid.name,
|
|
1039
|
+
showCheckboxAll: this.grid.showCheckboxAllFilter,
|
|
1036
1040
|
isVisible: `{{GridController_${this.grid.componentId}.showFilterButton}}`,
|
|
1037
1041
|
events: {
|
|
1038
1042
|
onCreated: this.loadFilterButton.bind(this),
|
|
@@ -2221,6 +2225,7 @@
|
|
|
2221
2225
|
this.groupedData = [];
|
|
2222
2226
|
this.toolbarSlotProps = false;
|
|
2223
2227
|
this.editNewRowsOnly = false;
|
|
2228
|
+
this.showCheckboxAllFilter = core.Config.gridShowCheckboxAllFilter || false;
|
|
2224
2229
|
this.defaultLazy = false;
|
|
2225
2230
|
this.groups = [];
|
|
2226
2231
|
this.summary = {};
|
|
@@ -2251,6 +2256,7 @@
|
|
|
2251
2256
|
this.exportActions = props.exportActions || this.exportActions;
|
|
2252
2257
|
this.groupsOpened = this.getInitValue('groupsOpened', props.groupsOpened, this.groupsOpened);
|
|
2253
2258
|
this.showSummaryTotal = this.getInitValue('showSummaryTotal', props.showSummaryTotal, this.showSummaryTotal);
|
|
2259
|
+
this.showCheckboxAllFilter = this.getInitValue('showCheckboxAllFilter', props.showCheckboxAllFilter, this.showCheckboxAllFilter);
|
|
2254
2260
|
this.editNewRowsOnly = this.getInitValue('editNewRowsOnly', props.editNewRowsOnly, this.editNewRowsOnly);
|
|
2255
2261
|
this.mainGrid = this.getInitValue('mainGrid', props.mainGrid, this.mainGrid);
|
|
2256
2262
|
this.actions = props.actions || this.actions;
|
|
@@ -2454,6 +2460,7 @@
|
|
|
2454
2460
|
}
|
|
2455
2461
|
updateGroupedData(lazyLoad) {
|
|
2456
2462
|
return __awaiter(this, void 0, void 0, function* () {
|
|
2463
|
+
this.initSummaryColumns();
|
|
2457
2464
|
this.groupedData = [];
|
|
2458
2465
|
this.groupColumns = this.columns.filter((column) => column.grouped);
|
|
2459
2466
|
this.groupColumnNames = this.groupColumns.map((column) => column.name);
|
|
@@ -2925,9 +2932,11 @@
|
|
|
2925
2932
|
class TekGridFilterButton extends common.Button {
|
|
2926
2933
|
constructor(props) {
|
|
2927
2934
|
super(props);
|
|
2935
|
+
this.showCheckboxAll = false;
|
|
2928
2936
|
this.filterFormInputs = {};
|
|
2929
2937
|
this.gridName = this.getInitValue('gridName', props.gridName, this.gridName);
|
|
2930
2938
|
this.grid = this.getInitValue('grid', props.grid, undefined);
|
|
2939
|
+
this.showCheckboxAll = this.getInitValue('showCheckboxAll', props.showCheckboxAll, this.showCheckboxAll);
|
|
2931
2940
|
this.createAccessors();
|
|
2932
2941
|
if (!this.grid)
|
|
2933
2942
|
this.loadGrid();
|
|
@@ -3009,6 +3018,7 @@
|
|
|
3009
3018
|
if (!this.filterModal) {
|
|
3010
3019
|
const originalProps = {
|
|
3011
3020
|
height: 'auto',
|
|
3021
|
+
maxHeight: '18.75rem',
|
|
3012
3022
|
persistent: true,
|
|
3013
3023
|
title: 'FILTER',
|
|
3014
3024
|
};
|
|
@@ -3029,31 +3039,24 @@
|
|
|
3029
3039
|
{
|
|
3030
3040
|
name: `${this.grid.name}-filter-header-container`,
|
|
3031
3041
|
component: 'ZdContainer',
|
|
3032
|
-
cssClass: 'zd-pa-0',
|
|
3042
|
+
cssClass: 'zd-pa-0 zd-display-flex',
|
|
3033
3043
|
children: [
|
|
3034
3044
|
{
|
|
3035
|
-
name: `${this.grid.name}-filter-
|
|
3036
|
-
component: '
|
|
3037
|
-
color: '
|
|
3038
|
-
|
|
3039
|
-
|
|
3040
|
-
|
|
3041
|
-
|
|
3042
|
-
|
|
3043
|
-
|
|
3044
|
-
|
|
3045
|
-
|
|
3046
|
-
|
|
3047
|
-
|
|
3048
|
-
|
|
3049
|
-
|
|
3050
|
-
{
|
|
3051
|
-
name: `${this.grid.name}-filter-close-button`,
|
|
3052
|
-
component: 'ZdModalCloseButton',
|
|
3053
|
-
small: true,
|
|
3054
|
-
modalName: `${this.grid.name}-filter-modal`,
|
|
3055
|
-
},
|
|
3056
|
-
],
|
|
3045
|
+
name: `${this.grid.name}-filter-title`,
|
|
3046
|
+
component: 'ZdText',
|
|
3047
|
+
cssStyle: `color: ${'var(--v-primary-base);'}`,
|
|
3048
|
+
text: mergeModalFilterProps.title,
|
|
3049
|
+
tag: 'h3',
|
|
3050
|
+
},
|
|
3051
|
+
{
|
|
3052
|
+
name: `${this.grid.name}-filter-spacer`,
|
|
3053
|
+
component: 'VSpacer',
|
|
3054
|
+
},
|
|
3055
|
+
{
|
|
3056
|
+
name: `${this.grid.name}-filter-close-button`,
|
|
3057
|
+
component: 'ZdModalCloseButton',
|
|
3058
|
+
small: true,
|
|
3059
|
+
modalName: `${this.grid.name}-filter-modal`,
|
|
3057
3060
|
},
|
|
3058
3061
|
],
|
|
3059
3062
|
},
|
|
@@ -3061,14 +3064,14 @@
|
|
|
3061
3064
|
name: `${this.grid.name}-filter-content-container`,
|
|
3062
3065
|
component: 'ZdContainer',
|
|
3063
3066
|
scrollView: true,
|
|
3064
|
-
cssClass: 'zd-my-2 zd-pa-0',
|
|
3065
|
-
maxHeight:
|
|
3066
|
-
height:
|
|
3067
|
+
cssClass: 'zd-my-2 zd-pa-0 tek-grid-filter-content-container',
|
|
3068
|
+
maxHeight: mergeModalFilterProps.maxHeight,
|
|
3069
|
+
height: mergeModalFilterProps.height,
|
|
3067
3070
|
children: [
|
|
3068
3071
|
{
|
|
3069
3072
|
name: `${this.grid.name}-filter-form`,
|
|
3070
3073
|
component: 'ZdForm',
|
|
3071
|
-
cssClass: 'zd-my-2',
|
|
3074
|
+
cssClass: 'zd-my-2 zd-pa-0',
|
|
3072
3075
|
children: this.getFilterModalComponents(),
|
|
3073
3076
|
events: {
|
|
3074
3077
|
onMounted: this.loadFilterValues.bind(this),
|
|
@@ -3150,14 +3153,36 @@
|
|
|
3150
3153
|
super.onBeforeDestroy();
|
|
3151
3154
|
this.destroyFilterModal();
|
|
3152
3155
|
}
|
|
3156
|
+
formatFormValue(filterForm) {
|
|
3157
|
+
return Object.keys(filterForm.value).reduce((result, item) => {
|
|
3158
|
+
try {
|
|
3159
|
+
const itemInstance = filterForm.getChildInstance(item);
|
|
3160
|
+
if (!(itemInstance instanceof common.SelectMultiple) || !itemInstance.checkboxAll)
|
|
3161
|
+
return result;
|
|
3162
|
+
// when selectmultiple with checkboxAll, should either remove it from the filter or
|
|
3163
|
+
// change the value to T, depending on selectAllCompatibilityMode
|
|
3164
|
+
if (core.Config.selectAllCompatibilityMode) {
|
|
3165
|
+
result[item] = 'T';
|
|
3166
|
+
return result;
|
|
3167
|
+
}
|
|
3168
|
+
delete result[item];
|
|
3169
|
+
return result;
|
|
3170
|
+
}
|
|
3171
|
+
catch (e) {
|
|
3172
|
+
return result;
|
|
3173
|
+
}
|
|
3174
|
+
}, Object.assign({}, filterForm.value));
|
|
3175
|
+
}
|
|
3153
3176
|
applyFilter({ event }) {
|
|
3154
3177
|
const filterForm = core.Metadata.getInstance(`${this.grid.name}-filter-form`);
|
|
3155
3178
|
if (filterForm.validate()) {
|
|
3156
3179
|
const { datasource } = this.grid;
|
|
3157
3180
|
const filter = {};
|
|
3181
|
+
const formValue = this.formatFormValue(filterForm);
|
|
3158
3182
|
if (datasource instanceof TekRestDatasource || datasource instanceof TekMemoryDatasource) {
|
|
3159
|
-
Object.keys(
|
|
3160
|
-
|
|
3183
|
+
Object.keys(formValue).forEach((item) => {
|
|
3184
|
+
const itemValue = formValue[item];
|
|
3185
|
+
if (itemValue && !(Array.isArray(itemValue) && !itemValue.length)) {
|
|
3161
3186
|
const relationAndOperationAndName = item.split(`${this.grid.name}-filter-`)[1];
|
|
3162
3187
|
const [relation, operation] = relationAndOperationAndName.split('-');
|
|
3163
3188
|
let columnName = relationAndOperationAndName.split(`${relation}-${operation}-`)[1];
|
|
@@ -3165,7 +3190,7 @@
|
|
|
3165
3190
|
if (!filter[columnName]) {
|
|
3166
3191
|
filter[columnName] = [];
|
|
3167
3192
|
}
|
|
3168
|
-
const value =
|
|
3193
|
+
const value = itemValue;
|
|
3169
3194
|
filter[columnName].push({
|
|
3170
3195
|
relation,
|
|
3171
3196
|
operation,
|
|
@@ -3177,11 +3202,11 @@
|
|
|
3177
3202
|
this.setFilter(filter, event, datasource.setDynamicFilter.bind(datasource));
|
|
3178
3203
|
}
|
|
3179
3204
|
else {
|
|
3180
|
-
Object.keys(
|
|
3205
|
+
Object.keys(formValue).forEach((item) => {
|
|
3181
3206
|
let columnName = item.split(`${this.grid.name}-filter-AND-CONTAINS-`)[1];
|
|
3182
3207
|
columnName = columnName.split('-').slice(0, -1).join('-'); // remove index
|
|
3183
|
-
if (
|
|
3184
|
-
filter[columnName] =
|
|
3208
|
+
if (formValue[item]) {
|
|
3209
|
+
filter[columnName] = formValue[item];
|
|
3185
3210
|
}
|
|
3186
3211
|
});
|
|
3187
3212
|
datasource.filter = filter;
|
|
@@ -3224,6 +3249,7 @@
|
|
|
3224
3249
|
if (column.filterable && filterProps && filterProps.length > 0) {
|
|
3225
3250
|
this.filterFormInputs[column.name] = [];
|
|
3226
3251
|
filterProps.forEach((filterItem, index) => {
|
|
3252
|
+
var _a;
|
|
3227
3253
|
const { datasource } = this.grid;
|
|
3228
3254
|
if (datasource instanceof TekRestDatasource || datasource instanceof TekMemoryDatasource) {
|
|
3229
3255
|
const relation = filterItem.relation || 'AND';
|
|
@@ -3240,6 +3266,9 @@
|
|
|
3240
3266
|
newColumnComponent.events = {};
|
|
3241
3267
|
newColumnComponent.events.change = this.changeHelperEvent.bind(this, column);
|
|
3242
3268
|
}
|
|
3269
|
+
if (newColumnComponent.component === 'ZdSelectMultiple') {
|
|
3270
|
+
newColumnComponent.showCheckboxAll = (_a = newColumnComponent.showCheckboxAll) !== null && _a !== void 0 ? _a : this.showCheckboxAll;
|
|
3271
|
+
}
|
|
3243
3272
|
filterColumns.push(newColumnComponent);
|
|
3244
3273
|
});
|
|
3245
3274
|
}
|
|
@@ -3559,6 +3588,7 @@
|
|
|
3559
3588
|
},
|
|
3560
3589
|
];
|
|
3561
3590
|
this.toolbarSlotProps = false;
|
|
3591
|
+
this.showCheckboxAllFilter = false;
|
|
3562
3592
|
this.title = this.getInitValue('title', props.title, this.title);
|
|
3563
3593
|
this.addButton = this.getInitValue('addButton', props.addButton, this.addButton);
|
|
3564
3594
|
this.deleteButton = this.getInitValue('deleteButton', props.deleteButton, this.deleteButton);
|
|
@@ -3574,6 +3604,7 @@
|
|
|
3574
3604
|
this.showExport = this.getInitValue('showExport', props.showExport, this.showExport);
|
|
3575
3605
|
this.showReload = this.getInitValue('showReload', props.showReload, this.showReload);
|
|
3576
3606
|
this.exportConfig = this.getInitValue('exportConfig', props.exportConfig, this.exportConfig);
|
|
3607
|
+
this.showCheckboxAllFilter = this.getInitValue('showCheckboxAllFilter', props.showCheckboxAllFilter, this.showCheckboxAllFilter);
|
|
3577
3608
|
this.exportActions = props.exportActions || this.exportActions;
|
|
3578
3609
|
this.actions = props.actions || this.actions;
|
|
3579
3610
|
this.toolbarSlotProps = props.toolbarSlot !== undefined;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zeedhi/teknisa-components-common",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.96.0",
|
|
4
4
|
"description": "Teknisa Components Common",
|
|
5
5
|
"author": "Zeedhi <zeedhi@teknisa.com>",
|
|
6
6
|
"license": "ISC",
|
|
@@ -32,5 +32,5 @@
|
|
|
32
32
|
"peerDependencies": {
|
|
33
33
|
"@zeedhi/core": "*"
|
|
34
34
|
},
|
|
35
|
-
"gitHead": "
|
|
35
|
+
"gitHead": "dfe5f1a2a802cfea057de278b8e41f6858b43073"
|
|
36
36
|
}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
/* eslint-disable no-underscore-dangle */
|
|
2
2
|
|
|
3
3
|
import {
|
|
4
|
-
Button, Date, Form, IButton, IForm, IModal, Modal, ModalService,
|
|
4
|
+
Button, Date, Form, IButton, IForm, IModal, ISelectMultiple, Modal, ModalService, SelectMultiple,
|
|
5
5
|
} from '@zeedhi/common';
|
|
6
6
|
import {
|
|
7
|
-
Http, Metadata, DateHelper,
|
|
7
|
+
Http, Metadata, DateHelper, Config,
|
|
8
8
|
} from '@zeedhi/core';
|
|
9
9
|
import {
|
|
10
10
|
IFilterPropsComponent,
|
|
@@ -207,6 +207,133 @@ describe('TekGridFilterButton', () => {
|
|
|
207
207
|
spy.mockReset();
|
|
208
208
|
});
|
|
209
209
|
|
|
210
|
+
it('when creating a SelectMultiple filter, default should not add showCheckboxAll prop', () => {
|
|
211
|
+
const instance = new TekGrid({
|
|
212
|
+
name: 'grid_filterClick5',
|
|
213
|
+
component: 'TekGrid',
|
|
214
|
+
columns: [
|
|
215
|
+
{
|
|
216
|
+
name: 'id',
|
|
217
|
+
filterable: true,
|
|
218
|
+
filterProps: [{
|
|
219
|
+
name: 'id_edit', label: 'id', component: 'ZdSelectMultiple', showCheckboxAll: false,
|
|
220
|
+
}],
|
|
221
|
+
},
|
|
222
|
+
{
|
|
223
|
+
name: 'name',
|
|
224
|
+
filterable: true,
|
|
225
|
+
filterProps: [{ name: 'name_edit', label: 'name', component: 'ZdSelectMultiple' }],
|
|
226
|
+
},
|
|
227
|
+
],
|
|
228
|
+
});
|
|
229
|
+
|
|
230
|
+
let formElements: any = [];
|
|
231
|
+
const spy = jest.spyOn(ModalService, 'create').mockImplementation((modal: IModal) => {
|
|
232
|
+
const form = getChild<IForm>(modal.children || [], `${instance.name}-filter-form`);
|
|
233
|
+
formElements = form.children;
|
|
234
|
+
|
|
235
|
+
return new Modal(modal);
|
|
236
|
+
});
|
|
237
|
+
instance.onCreated();
|
|
238
|
+
clickOnFilterButton(instance);
|
|
239
|
+
|
|
240
|
+
expect(formElements[0].showCheckboxAll).toBeFalsy();
|
|
241
|
+
expect(formElements[1].showCheckboxAll).toBeFalsy();
|
|
242
|
+
|
|
243
|
+
spy.mockReset();
|
|
244
|
+
});
|
|
245
|
+
|
|
246
|
+
it('when using the prop showCheckboxAllFilter, should add showCheckboxAll prop to SelectMultiple filters', () => {
|
|
247
|
+
const instance = new TekGrid({
|
|
248
|
+
name: 'grid_filterClick5',
|
|
249
|
+
component: 'TekGrid',
|
|
250
|
+
showCheckboxAllFilter: true,
|
|
251
|
+
columns: [
|
|
252
|
+
{
|
|
253
|
+
name: 'id',
|
|
254
|
+
filterable: true,
|
|
255
|
+
filterProps: [{
|
|
256
|
+
name: 'id_edit', label: 'id', component: 'ZdSelectMultiple', showCheckboxAll: false,
|
|
257
|
+
}],
|
|
258
|
+
},
|
|
259
|
+
{
|
|
260
|
+
name: 'name',
|
|
261
|
+
filterable: true,
|
|
262
|
+
filterProps: [{ name: 'name_edit', label: 'name', component: 'ZdSelectMultiple' }],
|
|
263
|
+
},
|
|
264
|
+
],
|
|
265
|
+
});
|
|
266
|
+
|
|
267
|
+
let formElements: any = [];
|
|
268
|
+
const spy = jest.spyOn(ModalService, 'create').mockImplementation((modal: IModal) => {
|
|
269
|
+
const form = getChild<IForm>(modal.children || [], `${instance.name}-filter-form`);
|
|
270
|
+
formElements = form.children;
|
|
271
|
+
|
|
272
|
+
return new Modal(modal);
|
|
273
|
+
});
|
|
274
|
+
instance.onCreated();
|
|
275
|
+
clickOnFilterButton(instance);
|
|
276
|
+
|
|
277
|
+
expect(formElements[0].showCheckboxAll).toBeFalsy();
|
|
278
|
+
expect(formElements[1].showCheckboxAll).toBeTruthy();
|
|
279
|
+
|
|
280
|
+
spy.mockReset();
|
|
281
|
+
});
|
|
282
|
+
|
|
283
|
+
it('when creating a SelectMultiple filter, should change the filter value depending on checkboxAll', () => {
|
|
284
|
+
const instance = new TekGrid({
|
|
285
|
+
name: 'grid_filterClick5',
|
|
286
|
+
component: 'TekGrid',
|
|
287
|
+
columns: [
|
|
288
|
+
{
|
|
289
|
+
name: 'id',
|
|
290
|
+
filterable: true,
|
|
291
|
+
filterProps: [{
|
|
292
|
+
name: 'id_edit', label: 'id', component: 'ZdSelectMultiple', showCheckboxAll: false,
|
|
293
|
+
}],
|
|
294
|
+
},
|
|
295
|
+
],
|
|
296
|
+
});
|
|
297
|
+
|
|
298
|
+
let form: IForm = { name: 'form', component: 'ZdForm' };
|
|
299
|
+
let select: ISelectMultiple = { name: 'select', component: 'ZdSelectMultiple' };
|
|
300
|
+
let applyButton: IButton = { name: 'apply', component: 'ZdButton' };
|
|
301
|
+
const spy = jest.spyOn(ModalService, 'create').mockImplementation((modal: IModal) => {
|
|
302
|
+
const modalFooter = getChild(modal.children || [], `${instance.name}-filter-footer`);
|
|
303
|
+
form = getChild(modal.children || [], `${instance.name}-filter-form`);
|
|
304
|
+
select = getChild(form.children || [], `${instance.name}-filter-AND-CONTAINS-id-0`);
|
|
305
|
+
applyButton = getChild(modalFooter.rightSlot, `${instance.name}-filter-okButton`);
|
|
306
|
+
|
|
307
|
+
return new Modal(modal);
|
|
308
|
+
});
|
|
309
|
+
instance.onCreated();
|
|
310
|
+
clickOnFilterButton(instance);
|
|
311
|
+
const applyButtonObject = new Button(applyButton);
|
|
312
|
+
|
|
313
|
+
const formObject = new Form(form);
|
|
314
|
+
const selectObject = new SelectMultiple(select);
|
|
315
|
+
jest.spyOn(Metadata, 'getInstance').mockReturnValue(formObject);
|
|
316
|
+
jest.spyOn(formObject, 'getChildInstance').mockReturnValue(selectObject);
|
|
317
|
+
|
|
318
|
+
formObject.value['grid_filterClick5-filter-AND-CONTAINS-id-0'] = ['example'];
|
|
319
|
+
setClick(applyButtonObject);
|
|
320
|
+
|
|
321
|
+
expect(instance.datasource.filter).toEqual({
|
|
322
|
+
id: ['example'],
|
|
323
|
+
});
|
|
324
|
+
|
|
325
|
+
selectObject.checkboxAll = true;
|
|
326
|
+
setClick(applyButtonObject);
|
|
327
|
+
|
|
328
|
+
expect(instance.datasource.filter).toEqual({});
|
|
329
|
+
|
|
330
|
+
(Config as any).set({ selectAllCompatibilityMode: true });
|
|
331
|
+
setClick(applyButtonObject);
|
|
332
|
+
expect(instance.datasource.filter).toEqual({ id: 'T' });
|
|
333
|
+
|
|
334
|
+
spy.mockReset();
|
|
335
|
+
});
|
|
336
|
+
|
|
210
337
|
it('should create modal with filterable and ordered form elements', () => {
|
|
211
338
|
const instance = new TekGrid({
|
|
212
339
|
name: 'grid-filter-order',
|
|
@@ -43,4 +43,25 @@ describe('Image', () => {
|
|
|
43
43
|
expect(instance.fillHeight).toBeTruthy();
|
|
44
44
|
});
|
|
45
45
|
});
|
|
46
|
+
|
|
47
|
+
describe('load event', () => {
|
|
48
|
+
it('should call load event', () => {
|
|
49
|
+
const load = jest.fn();
|
|
50
|
+
const instance = new Image({
|
|
51
|
+
name: 'image',
|
|
52
|
+
component: 'TekImage',
|
|
53
|
+
events: {
|
|
54
|
+
load,
|
|
55
|
+
},
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
const event = {} as Event;
|
|
59
|
+
const element = {} as HTMLElement;
|
|
60
|
+
instance.load(event, element);
|
|
61
|
+
|
|
62
|
+
expect(load).toHaveBeenCalledWith({
|
|
63
|
+
event, element, component: instance,
|
|
64
|
+
});
|
|
65
|
+
});
|
|
66
|
+
});
|
|
46
67
|
});
|
|
@@ -9,6 +9,7 @@ import { TekTreeGrid } from '../tek-tree-grid/tree-grid';
|
|
|
9
9
|
export declare class TekGridFilterButton extends Button implements ITekGridFilterButton {
|
|
10
10
|
gridName?: string;
|
|
11
11
|
grid: TekGrid | TekTreeGrid;
|
|
12
|
+
showCheckboxAll: boolean;
|
|
12
13
|
private filterModal?;
|
|
13
14
|
protected filterFormInputs: IDictionary<string[]>;
|
|
14
15
|
constructor(props: ITekGridFilterButton);
|
|
@@ -19,6 +20,7 @@ export declare class TekGridFilterButton extends Button implements ITekGridFilte
|
|
|
19
20
|
destroyFilterModal(): void;
|
|
20
21
|
private createFilterFromColumns;
|
|
21
22
|
onBeforeDestroy(): void;
|
|
23
|
+
private formatFormValue;
|
|
22
24
|
private applyFilter;
|
|
23
25
|
private setFilter;
|
|
24
26
|
private clearFilter;
|
|
@@ -72,6 +72,7 @@ export declare class TekGrid extends GridEditable implements ITekGrid {
|
|
|
72
72
|
filterOperationsDatasource: Datasource;
|
|
73
73
|
editNewRowsOnly: boolean;
|
|
74
74
|
protected keyShortcutKeyMapping: any;
|
|
75
|
+
showCheckboxAllFilter: boolean;
|
|
75
76
|
/**
|
|
76
77
|
* TekGrid class constructor
|
|
77
78
|
* @param props TekGrid properties
|