@zeedhi/teknisa-components-common 1.96.3 → 1.97.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/tek-components-common.esm.js +30 -11
- package/dist/tek-components-common.umd.js +29 -10
- package/package.json +3 -3
- package/tests/unit/components/tek-grid/grid.spec.ts +25 -0
- package/types/components/tek-grid/grid.d.ts +6 -1
- package/types/components/tek-grid/interfaces.d.ts +1 -0
- package/types/components/tek-tree-grid/interfaces.d.ts +2 -0
- package/types/components/tek-tree-grid/tree-grid.d.ts +1 -0
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { KeyMap, I18n, FormatterParserProvider, Messages, DatasourceFactory, Metadata, MemoryDatasource, URL, Utils, RestDatasource, Config, Loader, DateHelper, Http, Singleton, VersionService } from '@zeedhi/core';
|
|
1
|
+
import { KeyMap, I18n, FormatterParserProvider, Messages, DatasourceFactory, Metadata, MemoryDatasource, URL, Utils, RestDatasource, Config, Accessor, Loader, DateHelper, Http, Singleton, VersionService } from '@zeedhi/core';
|
|
2
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';
|
|
@@ -2108,8 +2108,7 @@ class TekGrid extends GridEditable {
|
|
|
2108
2108
|
* @param props TekGrid properties
|
|
2109
2109
|
*/
|
|
2110
2110
|
constructor(props) {
|
|
2111
|
-
|
|
2112
|
-
super(Object.assign(Object.assign({}, props), { datasource: Object.assign(Object.assign({}, props.datasource), { lazyLoad: true }) }));
|
|
2111
|
+
super(props);
|
|
2113
2112
|
/* Grid Title */
|
|
2114
2113
|
this.title = '';
|
|
2115
2114
|
/* Show Add button */
|
|
@@ -2222,6 +2221,7 @@ class TekGrid extends GridEditable {
|
|
|
2222
2221
|
this.toolbarSlotProps = false;
|
|
2223
2222
|
this.editNewRowsOnly = false;
|
|
2224
2223
|
this.showCheckboxAllFilter = Config.gridShowCheckboxAllFilter || false;
|
|
2224
|
+
this.defaultFilter = {};
|
|
2225
2225
|
this.defaultLazy = false;
|
|
2226
2226
|
this.groups = [];
|
|
2227
2227
|
this.summary = {};
|
|
@@ -2253,6 +2253,7 @@ class TekGrid extends GridEditable {
|
|
|
2253
2253
|
this.groupsOpened = this.getInitValue('groupsOpened', props.groupsOpened, this.groupsOpened);
|
|
2254
2254
|
this.showSummaryTotal = this.getInitValue('showSummaryTotal', props.showSummaryTotal, this.showSummaryTotal);
|
|
2255
2255
|
this.showCheckboxAllFilter = this.getInitValue('showCheckboxAllFilter', props.showCheckboxAllFilter, this.showCheckboxAllFilter);
|
|
2256
|
+
this.defaultFilter = this.getInitValue('defaultFilter', props.defaultFilter, this.defaultFilter);
|
|
2256
2257
|
this.editNewRowsOnly = this.getInitValue('editNewRowsOnly', props.editNewRowsOnly, this.editNewRowsOnly);
|
|
2257
2258
|
this.mainGrid = this.getInitValue('mainGrid', props.mainGrid, this.mainGrid);
|
|
2258
2259
|
this.actions = props.actions || this.actions;
|
|
@@ -2290,10 +2291,24 @@ class TekGrid extends GridEditable {
|
|
|
2290
2291
|
},
|
|
2291
2292
|
};
|
|
2292
2293
|
this.createAccessors();
|
|
2294
|
+
this.defaultLazy = this.getDefaultLazy(props);
|
|
2293
2295
|
this.gridBase = new GridBase(this);
|
|
2294
2296
|
this.filterOperationsDatasource = this.gridBase.getFilterOperationsDatasource();
|
|
2295
2297
|
this.filterRelationsDatasource = this.gridBase.getFilterRelationsDatasource();
|
|
2296
|
-
|
|
2298
|
+
}
|
|
2299
|
+
getDatasourceDefaults() {
|
|
2300
|
+
return { lazyLoad: true };
|
|
2301
|
+
}
|
|
2302
|
+
getDefaultLazy(props) {
|
|
2303
|
+
if (typeof props.datasource === 'object') {
|
|
2304
|
+
return props.datasource.lazyLoad;
|
|
2305
|
+
}
|
|
2306
|
+
if (typeof props.datasource === 'string' && Accessor.isAccessorDefinition(props.datasource)) {
|
|
2307
|
+
const [controller, accessor] = Accessor.getAccessor(props.datasource);
|
|
2308
|
+
const instance = Loader.getInstance(controller);
|
|
2309
|
+
return instance[accessor].lazyLoad || false;
|
|
2310
|
+
}
|
|
2311
|
+
return false;
|
|
2297
2312
|
}
|
|
2298
2313
|
onCreated() {
|
|
2299
2314
|
super.onCreated();
|
|
@@ -2342,7 +2357,7 @@ class TekGrid extends GridEditable {
|
|
|
2342
2357
|
const dynamicFilter = this.datasource.dynamicFilter[column.name];
|
|
2343
2358
|
return dynamicFilter && dynamicFilter.length > 0;
|
|
2344
2359
|
}
|
|
2345
|
-
return this.datasource.filter[column.name];
|
|
2360
|
+
return this.datasource.filter[column.name] && this.datasource.filter[column.name].length > 0;
|
|
2346
2361
|
}
|
|
2347
2362
|
buildReportGroups() {
|
|
2348
2363
|
return this.columns
|
|
@@ -2956,9 +2971,10 @@ class TekGridFilterButton extends Button {
|
|
|
2956
2971
|
const { datasource } = this.grid;
|
|
2957
2972
|
if (datasource instanceof TekRestDatasource || datasource instanceof TekMemoryDatasource) {
|
|
2958
2973
|
const { dynamicFilter } = datasource;
|
|
2959
|
-
Object.
|
|
2960
|
-
|
|
2961
|
-
|
|
2974
|
+
const newDynamicFilter = Object.assign(Object.assign({}, this.grid.defaultFilter), dynamicFilter);
|
|
2975
|
+
Object.keys(newDynamicFilter).forEach((column) => {
|
|
2976
|
+
if (newDynamicFilter[column] && newDynamicFilter[column].length > 0) {
|
|
2977
|
+
newDynamicFilter[column].forEach((filterItem, index) => {
|
|
2962
2978
|
const relation = filterItem.relation || 'AND';
|
|
2963
2979
|
const operation = filterItem.operation || 'CONTAINS';
|
|
2964
2980
|
const compName = `${this.grid.name}-filter-${relation}-${operation}-${column}-${index}`;
|
|
@@ -2989,11 +3005,12 @@ class TekGridFilterButton extends Button {
|
|
|
2989
3005
|
}
|
|
2990
3006
|
else {
|
|
2991
3007
|
const { filter } = datasource;
|
|
2992
|
-
Object.
|
|
2993
|
-
|
|
3008
|
+
const newFilter = Object.assign(Object.assign({}, this.grid.defaultFilter), filter);
|
|
3009
|
+
Object.keys(newFilter).forEach((item) => {
|
|
3010
|
+
if (newFilter[item]) {
|
|
2994
3011
|
const compName = `${this.grid.name}-filter-AND-CONTAINS-${item}-0`;
|
|
2995
3012
|
changedCompNames.push(compName);
|
|
2996
|
-
component.value[compName] =
|
|
3013
|
+
component.value[compName] = newFilter[item];
|
|
2997
3014
|
}
|
|
2998
3015
|
});
|
|
2999
3016
|
}
|
|
@@ -3585,6 +3602,7 @@ class TekTreeGrid extends TreeGridEditable {
|
|
|
3585
3602
|
];
|
|
3586
3603
|
this.toolbarSlotProps = false;
|
|
3587
3604
|
this.showCheckboxAllFilter = false;
|
|
3605
|
+
this.defaultFilter = {};
|
|
3588
3606
|
this.title = this.getInitValue('title', props.title, this.title);
|
|
3589
3607
|
this.addButton = this.getInitValue('addButton', props.addButton, this.addButton);
|
|
3590
3608
|
this.deleteButton = this.getInitValue('deleteButton', props.deleteButton, this.deleteButton);
|
|
@@ -3601,6 +3619,7 @@ class TekTreeGrid extends TreeGridEditable {
|
|
|
3601
3619
|
this.showReload = this.getInitValue('showReload', props.showReload, this.showReload);
|
|
3602
3620
|
this.exportConfig = this.getInitValue('exportConfig', props.exportConfig, this.exportConfig);
|
|
3603
3621
|
this.showCheckboxAllFilter = this.getInitValue('showCheckboxAllFilter', props.showCheckboxAllFilter, this.showCheckboxAllFilter);
|
|
3622
|
+
this.defaultFilter = this.getInitValue('defaultFilter', props.defaultFilter, this.defaultFilter);
|
|
3604
3623
|
this.exportActions = props.exportActions || this.exportActions;
|
|
3605
3624
|
this.actions = props.actions || this.actions;
|
|
3606
3625
|
this.toolbarSlotProps = props.toolbarSlot !== undefined;
|
|
@@ -2112,8 +2112,7 @@
|
|
|
2112
2112
|
* @param props TekGrid properties
|
|
2113
2113
|
*/
|
|
2114
2114
|
constructor(props) {
|
|
2115
|
-
|
|
2116
|
-
super(Object.assign(Object.assign({}, props), { datasource: Object.assign(Object.assign({}, props.datasource), { lazyLoad: true }) }));
|
|
2115
|
+
super(props);
|
|
2117
2116
|
/* Grid Title */
|
|
2118
2117
|
this.title = '';
|
|
2119
2118
|
/* Show Add button */
|
|
@@ -2226,6 +2225,7 @@
|
|
|
2226
2225
|
this.toolbarSlotProps = false;
|
|
2227
2226
|
this.editNewRowsOnly = false;
|
|
2228
2227
|
this.showCheckboxAllFilter = core.Config.gridShowCheckboxAllFilter || false;
|
|
2228
|
+
this.defaultFilter = {};
|
|
2229
2229
|
this.defaultLazy = false;
|
|
2230
2230
|
this.groups = [];
|
|
2231
2231
|
this.summary = {};
|
|
@@ -2257,6 +2257,7 @@
|
|
|
2257
2257
|
this.groupsOpened = this.getInitValue('groupsOpened', props.groupsOpened, this.groupsOpened);
|
|
2258
2258
|
this.showSummaryTotal = this.getInitValue('showSummaryTotal', props.showSummaryTotal, this.showSummaryTotal);
|
|
2259
2259
|
this.showCheckboxAllFilter = this.getInitValue('showCheckboxAllFilter', props.showCheckboxAllFilter, this.showCheckboxAllFilter);
|
|
2260
|
+
this.defaultFilter = this.getInitValue('defaultFilter', props.defaultFilter, this.defaultFilter);
|
|
2260
2261
|
this.editNewRowsOnly = this.getInitValue('editNewRowsOnly', props.editNewRowsOnly, this.editNewRowsOnly);
|
|
2261
2262
|
this.mainGrid = this.getInitValue('mainGrid', props.mainGrid, this.mainGrid);
|
|
2262
2263
|
this.actions = props.actions || this.actions;
|
|
@@ -2294,10 +2295,24 @@
|
|
|
2294
2295
|
},
|
|
2295
2296
|
};
|
|
2296
2297
|
this.createAccessors();
|
|
2298
|
+
this.defaultLazy = this.getDefaultLazy(props);
|
|
2297
2299
|
this.gridBase = new GridBase(this);
|
|
2298
2300
|
this.filterOperationsDatasource = this.gridBase.getFilterOperationsDatasource();
|
|
2299
2301
|
this.filterRelationsDatasource = this.gridBase.getFilterRelationsDatasource();
|
|
2300
|
-
|
|
2302
|
+
}
|
|
2303
|
+
getDatasourceDefaults() {
|
|
2304
|
+
return { lazyLoad: true };
|
|
2305
|
+
}
|
|
2306
|
+
getDefaultLazy(props) {
|
|
2307
|
+
if (typeof props.datasource === 'object') {
|
|
2308
|
+
return props.datasource.lazyLoad;
|
|
2309
|
+
}
|
|
2310
|
+
if (typeof props.datasource === 'string' && core.Accessor.isAccessorDefinition(props.datasource)) {
|
|
2311
|
+
const [controller, accessor] = core.Accessor.getAccessor(props.datasource);
|
|
2312
|
+
const instance = core.Loader.getInstance(controller);
|
|
2313
|
+
return instance[accessor].lazyLoad || false;
|
|
2314
|
+
}
|
|
2315
|
+
return false;
|
|
2301
2316
|
}
|
|
2302
2317
|
onCreated() {
|
|
2303
2318
|
super.onCreated();
|
|
@@ -2346,7 +2361,7 @@
|
|
|
2346
2361
|
const dynamicFilter = this.datasource.dynamicFilter[column.name];
|
|
2347
2362
|
return dynamicFilter && dynamicFilter.length > 0;
|
|
2348
2363
|
}
|
|
2349
|
-
return this.datasource.filter[column.name];
|
|
2364
|
+
return this.datasource.filter[column.name] && this.datasource.filter[column.name].length > 0;
|
|
2350
2365
|
}
|
|
2351
2366
|
buildReportGroups() {
|
|
2352
2367
|
return this.columns
|
|
@@ -2960,9 +2975,10 @@
|
|
|
2960
2975
|
const { datasource } = this.grid;
|
|
2961
2976
|
if (datasource instanceof TekRestDatasource || datasource instanceof TekMemoryDatasource) {
|
|
2962
2977
|
const { dynamicFilter } = datasource;
|
|
2963
|
-
Object.
|
|
2964
|
-
|
|
2965
|
-
|
|
2978
|
+
const newDynamicFilter = Object.assign(Object.assign({}, this.grid.defaultFilter), dynamicFilter);
|
|
2979
|
+
Object.keys(newDynamicFilter).forEach((column) => {
|
|
2980
|
+
if (newDynamicFilter[column] && newDynamicFilter[column].length > 0) {
|
|
2981
|
+
newDynamicFilter[column].forEach((filterItem, index) => {
|
|
2966
2982
|
const relation = filterItem.relation || 'AND';
|
|
2967
2983
|
const operation = filterItem.operation || 'CONTAINS';
|
|
2968
2984
|
const compName = `${this.grid.name}-filter-${relation}-${operation}-${column}-${index}`;
|
|
@@ -2993,11 +3009,12 @@
|
|
|
2993
3009
|
}
|
|
2994
3010
|
else {
|
|
2995
3011
|
const { filter } = datasource;
|
|
2996
|
-
Object.
|
|
2997
|
-
|
|
3012
|
+
const newFilter = Object.assign(Object.assign({}, this.grid.defaultFilter), filter);
|
|
3013
|
+
Object.keys(newFilter).forEach((item) => {
|
|
3014
|
+
if (newFilter[item]) {
|
|
2998
3015
|
const compName = `${this.grid.name}-filter-AND-CONTAINS-${item}-0`;
|
|
2999
3016
|
changedCompNames.push(compName);
|
|
3000
|
-
component.value[compName] =
|
|
3017
|
+
component.value[compName] = newFilter[item];
|
|
3001
3018
|
}
|
|
3002
3019
|
});
|
|
3003
3020
|
}
|
|
@@ -3589,6 +3606,7 @@
|
|
|
3589
3606
|
];
|
|
3590
3607
|
this.toolbarSlotProps = false;
|
|
3591
3608
|
this.showCheckboxAllFilter = false;
|
|
3609
|
+
this.defaultFilter = {};
|
|
3592
3610
|
this.title = this.getInitValue('title', props.title, this.title);
|
|
3593
3611
|
this.addButton = this.getInitValue('addButton', props.addButton, this.addButton);
|
|
3594
3612
|
this.deleteButton = this.getInitValue('deleteButton', props.deleteButton, this.deleteButton);
|
|
@@ -3605,6 +3623,7 @@
|
|
|
3605
3623
|
this.showReload = this.getInitValue('showReload', props.showReload, this.showReload);
|
|
3606
3624
|
this.exportConfig = this.getInitValue('exportConfig', props.exportConfig, this.exportConfig);
|
|
3607
3625
|
this.showCheckboxAllFilter = this.getInitValue('showCheckboxAllFilter', props.showCheckboxAllFilter, this.showCheckboxAllFilter);
|
|
3626
|
+
this.defaultFilter = this.getInitValue('defaultFilter', props.defaultFilter, this.defaultFilter);
|
|
3608
3627
|
this.exportActions = props.exportActions || this.exportActions;
|
|
3609
3628
|
this.actions = props.actions || this.actions;
|
|
3610
3629
|
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.97.1",
|
|
4
4
|
"description": "Teknisa Components Common",
|
|
5
5
|
"author": "Zeedhi <zeedhi@teknisa.com>",
|
|
6
6
|
"license": "ISC",
|
|
@@ -30,7 +30,7 @@
|
|
|
30
30
|
"@types/lodash.merge": "4.6.*"
|
|
31
31
|
},
|
|
32
32
|
"peerDependencies": {
|
|
33
|
-
"@zeedhi/core": "
|
|
33
|
+
"@zeedhi/core": "~1.97.0"
|
|
34
34
|
},
|
|
35
|
-
"gitHead": "
|
|
35
|
+
"gitHead": "ff6f76c07441863c96758cecfb84300f914a15d3"
|
|
36
36
|
}
|
|
@@ -5,6 +5,8 @@ import {
|
|
|
5
5
|
} from '@zeedhi/common';
|
|
6
6
|
import {
|
|
7
7
|
KeyMap, Http, Metadata, IDictionary, IEventParam,
|
|
8
|
+
Datasource,
|
|
9
|
+
init,
|
|
8
10
|
} from '@zeedhi/core';
|
|
9
11
|
import {
|
|
10
12
|
ITekGrid,
|
|
@@ -19,6 +21,13 @@ jest.mock('lodash.debounce', () => jest.fn((fn) => fn));
|
|
|
19
21
|
|
|
20
22
|
jest.useFakeTimers();
|
|
21
23
|
|
|
24
|
+
class AppController {
|
|
25
|
+
public datasource = {
|
|
26
|
+
uniqueKey: 'id',
|
|
27
|
+
data: [{ id: '1' }],
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
|
|
22
31
|
const clickOnFilterButton = (grid: TekGrid, event?: any) => {
|
|
23
32
|
const buttonProps = getChild<ITekGridFilterButton>(grid.toolbarSlot, `${grid.name}_filterButton`);
|
|
24
33
|
const filterButton = new TekGridFilterButton(buttonProps);
|
|
@@ -177,6 +186,22 @@ describe('TekGrid', () => {
|
|
|
177
186
|
expect((instance as any).gridBase.exportConfigButtons[0].flat).toBeTruthy();
|
|
178
187
|
expect((instance as any).gridBase.exportConfigButtons[0].events).toBeDefined();
|
|
179
188
|
});
|
|
189
|
+
|
|
190
|
+
it('should create new TekGrid with accessor datasource', () => {
|
|
191
|
+
init({
|
|
192
|
+
controllers: {
|
|
193
|
+
AppController,
|
|
194
|
+
},
|
|
195
|
+
});
|
|
196
|
+
const instance = new TekGrid({
|
|
197
|
+
name: 'grid',
|
|
198
|
+
component: 'TekGrid',
|
|
199
|
+
datasource: '{{AppController.datasource}}' as any,
|
|
200
|
+
});
|
|
201
|
+
|
|
202
|
+
expect(instance.datasource).toBeInstanceOf(Datasource);
|
|
203
|
+
expect(instance.datasource.data).toEqual([{ id: '1' }]);
|
|
204
|
+
});
|
|
180
205
|
});
|
|
181
206
|
|
|
182
207
|
describe('getReport()', () => {
|
|
@@ -73,12 +73,17 @@ export declare class TekGrid extends GridEditable implements ITekGrid {
|
|
|
73
73
|
editNewRowsOnly: boolean;
|
|
74
74
|
protected keyShortcutKeyMapping: any;
|
|
75
75
|
showCheckboxAllFilter: boolean;
|
|
76
|
+
defaultFilter: IDictionary;
|
|
76
77
|
/**
|
|
77
78
|
* TekGrid class constructor
|
|
78
79
|
* @param props TekGrid properties
|
|
79
80
|
*/
|
|
80
81
|
constructor(props: ITekGrid);
|
|
82
|
+
protected getDatasourceDefaults(): {
|
|
83
|
+
lazyLoad: boolean;
|
|
84
|
+
};
|
|
81
85
|
private defaultLazy;
|
|
86
|
+
private getDefaultLazy;
|
|
82
87
|
onCreated(): void;
|
|
83
88
|
onMounted(element: HTMLElement): void;
|
|
84
89
|
onBeforeDestroy(): void;
|
|
@@ -89,7 +94,7 @@ export declare class TekGrid extends GridEditable implements ITekGrid {
|
|
|
89
94
|
* @param columns Grid columns parameter
|
|
90
95
|
*/
|
|
91
96
|
protected getColumns(columns: ITekGridColumn[]): TekGridColumn[];
|
|
92
|
-
columnHasFilterData(column: TekGridColumn):
|
|
97
|
+
columnHasFilterData(column: TekGridColumn): boolean;
|
|
93
98
|
private buildReportGroups;
|
|
94
99
|
private buildReportAggregations;
|
|
95
100
|
getReport(type: string, portrait?: boolean, rowObj?: any): Promise<Window | null>;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { IComponentRender, ITreeGridEditable } from '@zeedhi/common';
|
|
2
|
+
import { IDictionary } from '@zeedhi/core';
|
|
2
3
|
import { ITekGridColumn, ITekGridEvents, ITekGridExportConfig, TekGridLayoutOptions, IModalFilterProps } from '..';
|
|
3
4
|
export interface ITekTreeGrid extends ITreeGridEditable {
|
|
4
5
|
actions?: IComponentRender[];
|
|
@@ -22,4 +23,5 @@ export interface ITekTreeGrid extends ITreeGridEditable {
|
|
|
22
23
|
exportActions?: IComponentRender[];
|
|
23
24
|
layoutOptions?: TekGridLayoutOptions;
|
|
24
25
|
showCheckboxAllFilter?: boolean;
|
|
26
|
+
defaultFilter?: IDictionary;
|
|
25
27
|
}
|
|
@@ -63,6 +63,7 @@ export declare class TekTreeGrid extends TreeGridEditable implements ITekTreeGri
|
|
|
63
63
|
filterRelationsDatasource: Datasource;
|
|
64
64
|
filterOperationsDatasource: Datasource;
|
|
65
65
|
showCheckboxAllFilter: boolean;
|
|
66
|
+
defaultFilter: IDictionary;
|
|
66
67
|
/**
|
|
67
68
|
* TekTreeGrid class constructor
|
|
68
69
|
* @param props TekTreeGrid properties
|