@zeedhi/teknisa-components-common 1.95.0 → 1.96.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/coverage/clover.xml +640 -619
- package/coverage/coverage-final.json +11 -11
- package/coverage/lcov-report/index.html +11 -11
- 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 +1165 -1125
- package/dist/tek-components-common.esm.js +70 -42
- package/dist/tek-components-common.umd.js +68 -40
- package/package.json +2 -2
- package/tests/__mocks__/@zeedhi/core/i18n.js +1 -1
- package/tests/unit/components/tek-grid/grid-filter-button.spec.ts +129 -2
- package/tests/unit/components/tek-grid/grid.spec.ts +22 -3
- package/types/components/tek-grid/grid-filter-button.d.ts +2 -0
- package/types/components/tek-grid/grid.d.ts +5 -4
- package/types/components/tek-grid/interfaces.d.ts +4 -1
- 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,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',
|
|
@@ -706,13 +706,13 @@ describe('TekGrid', () => {
|
|
|
706
706
|
(KeyMap as any).isElementActive = () => true;
|
|
707
707
|
instance.onCreated();
|
|
708
708
|
instance.onMounted(elem);
|
|
709
|
-
|
|
709
|
+
instance.navigateDatasource(false);
|
|
710
710
|
expect(instance.datasource.currentRow).toEqual(instance.datasource.data[0]);
|
|
711
711
|
|
|
712
|
-
|
|
712
|
+
instance.navigateDatasource(false);
|
|
713
713
|
expect(instance.datasource.currentRow).toEqual(instance.datasource.data[1]);
|
|
714
714
|
|
|
715
|
-
|
|
715
|
+
instance.navigateDatasource(true);
|
|
716
716
|
expect(instance.datasource.currentRow).toEqual(instance.datasource.data[0]);
|
|
717
717
|
|
|
718
718
|
dispatchEvent('arrowright', {}); // arrow right
|
|
@@ -2278,4 +2278,23 @@ describe('TekGrid', () => {
|
|
|
2278
2278
|
spyModalService.mockReset();
|
|
2279
2279
|
});
|
|
2280
2280
|
});
|
|
2281
|
+
|
|
2282
|
+
describe('loadAfterTasks', () => {
|
|
2283
|
+
it('should call request even if tasks fail', async () => {
|
|
2284
|
+
const instance = new TekGrid({
|
|
2285
|
+
name: 'grid',
|
|
2286
|
+
component: 'TekGrid',
|
|
2287
|
+
});
|
|
2288
|
+
const spy = jest.spyOn(instance.datasource, 'get');
|
|
2289
|
+
|
|
2290
|
+
const errorFn = async () => {
|
|
2291
|
+
throw new Error();
|
|
2292
|
+
};
|
|
2293
|
+
instance.registerTask(errorFn());
|
|
2294
|
+
|
|
2295
|
+
await instance.loadAfterTasks();
|
|
2296
|
+
|
|
2297
|
+
expect(spy).toHaveBeenCalledTimes(1);
|
|
2298
|
+
});
|
|
2299
|
+
});
|
|
2281
2300
|
});
|
|
@@ -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;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { GridEditable, IComponentRender } from '@zeedhi/common';
|
|
2
|
-
import { Datasource, IDictionary } from '@zeedhi/core';
|
|
2
|
+
import { Datasource, IDictionary, IEventParam } from '@zeedhi/core';
|
|
3
3
|
import { ITekGridAtoms } from '../../utils';
|
|
4
4
|
import { TekGridColumn } from './grid-column';
|
|
5
5
|
import { IModalFilterProps, ITekGrid, ITekGridColumn, ITekGridEvents, ITekGridExportConfig } from './interfaces';
|
|
@@ -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
|
|
@@ -105,7 +106,7 @@ export declare class TekGrid extends GridEditable implements ITekGrid {
|
|
|
105
106
|
/**
|
|
106
107
|
* Loads grid data after resolving all tasks
|
|
107
108
|
*/
|
|
108
|
-
loadAfterTasks(): Promise<void>;
|
|
109
|
+
loadAfterTasks(): Promise<void | undefined>;
|
|
109
110
|
private initGrouping;
|
|
110
111
|
private buildGetFunction;
|
|
111
112
|
updateGrouping: (lazyLoad?: boolean) => void;
|
|
@@ -135,8 +136,8 @@ export declare class TekGrid extends GridEditable implements ITekGrid {
|
|
|
135
136
|
isGrouped(): number | false;
|
|
136
137
|
navigateDown(params?: any): void;
|
|
137
138
|
navigateUp(params?: any): void;
|
|
138
|
-
directionalLeft(): void;
|
|
139
|
-
directionalRight(): void;
|
|
139
|
+
directionalLeft(params: IEventParam<any>): void;
|
|
140
|
+
directionalRight(params: IEventParam<any>): void;
|
|
140
141
|
/**
|
|
141
142
|
* Dispatches row click event
|
|
142
143
|
* @param row Grid row
|
|
@@ -59,6 +59,7 @@ export interface ITekGrid extends IGridEditable {
|
|
|
59
59
|
showSummaryTotal?: boolean;
|
|
60
60
|
layoutOptions?: TekGridLayoutOptions;
|
|
61
61
|
mainGrid?: boolean;
|
|
62
|
+
showCheckboxAllFilter?: boolean;
|
|
62
63
|
}
|
|
63
64
|
export declare type MultiOptionParams = {
|
|
64
65
|
iconName: string;
|
|
@@ -131,6 +132,7 @@ export interface ITekGridColumnsButton extends IIterableColumnsButton {
|
|
|
131
132
|
export interface ITekGridFilterButton extends IButton {
|
|
132
133
|
gridName?: string;
|
|
133
134
|
grid?: TekGrid | TekTreeGrid;
|
|
135
|
+
showCheckboxAll?: boolean;
|
|
134
136
|
}
|
|
135
137
|
export interface ITekGridGroup {
|
|
136
138
|
column: ITekGridColumn;
|
|
@@ -168,5 +170,6 @@ export interface ITekFilterHelperValue extends IDateHelperValue {
|
|
|
168
170
|
export interface ITekFilterHelperValues extends IDateHelperValues {
|
|
169
171
|
}
|
|
170
172
|
export interface IModalFilterProps extends IModal {
|
|
171
|
-
height
|
|
173
|
+
height?: string;
|
|
174
|
+
maxHeight?: string;
|
|
172
175
|
}
|
|
@@ -62,6 +62,7 @@ export declare class TekTreeGrid extends TreeGridEditable implements ITekTreeGri
|
|
|
62
62
|
private gridBase;
|
|
63
63
|
filterRelationsDatasource: Datasource;
|
|
64
64
|
filterOperationsDatasource: Datasource;
|
|
65
|
+
showCheckboxAllFilter: boolean;
|
|
65
66
|
/**
|
|
66
67
|
* TekTreeGrid class constructor
|
|
67
68
|
* @param props TekTreeGrid properties
|