@zeedhi/teknisa-components-common 3.0.0 → 3.0.2
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/.package.json +5 -2
- package/dist/teknisa-components-common.js +3722 -32
- package/dist/teknisa-components-common.min.js +3722 -32
- package/dist/types/components/index.d.ts +5 -0
- package/dist/types/components/tek-datasource/index.d.ts +3 -0
- package/dist/types/components/tek-datasource/interfaces.d.ts +16 -0
- package/dist/types/components/tek-datasource/tek-memory-datasource.d.ts +93 -0
- package/dist/types/components/tek-datasource/tek-rest-datasource.d.ts +95 -0
- package/dist/types/components/tek-grid/columns-searcher.d.ts +5 -0
- package/dist/types/components/tek-grid/dynamic-filter-datasource-factory.d.ts +6 -0
- package/dist/types/components/tek-grid/filter-helper.d.ts +7 -0
- package/dist/types/components/tek-grid/grid-filter-button.d.ts +29 -0
- package/dist/types/components/tek-grid/grouped-data-manager.d.ts +82 -0
- package/dist/types/components/tek-grid/grouped-data-selector.d.ts +7 -0
- package/dist/types/components/tek-grid/grouped-view-navigator.d.ts +14 -0
- package/dist/types/components/tek-grid/index.d.ts +18 -0
- package/dist/types/components/tek-grid/interfaces.d.ts +259 -0
- package/dist/types/components/tek-grid/keymap-grouped.d.ts +6 -0
- package/dist/types/components/tek-grid/layout-options.d.ts +39 -0
- package/dist/types/components/tek-grid/tek-grid-column.d.ts +42 -0
- package/dist/types/components/tek-grid/tek-grid-columns-button/tek-grid-columns-button-controller.d.ts +8 -0
- package/dist/types/components/tek-grid/tek-grid-columns-button/tek-grid-columns-button.d.ts +13 -0
- package/dist/types/components/tek-grid/tek-grid-controller.d.ts +31 -0
- package/dist/types/components/tek-grid/tek-grid-events.d.ts +31 -0
- package/dist/types/components/tek-grid/tek-grid-toolbar-provider/export-options/button-option.d.ts +17 -0
- package/dist/types/components/tek-grid/tek-grid-toolbar-provider/export-options/index.d.ts +3 -0
- package/dist/types/components/tek-grid/tek-grid-toolbar-provider/export-options/interfaces.d.ts +5 -0
- package/dist/types/components/tek-grid/tek-grid-toolbar-provider/export-options/multi-option.d.ts +12 -0
- package/dist/types/components/tek-grid/tek-grid-toolbar-provider/index.d.ts +2 -0
- package/dist/types/components/tek-grid/tek-grid-toolbar-provider/tek-grid-toolbar-provider.d.ts +22 -0
- package/dist/types/components/tek-grid/tek-grid.d.ts +216 -0
- package/dist/types/components/tek-user-info/TekUserInfoController.d.ts +22 -0
- package/dist/types/components/tek-user-info/interfaces.d.ts +27 -0
- package/dist/types/components/tek-user-info/tek-user-info-list.d.ts +32 -0
- package/dist/types/components/tek-user-info/tek-user-info.d.ts +37 -0
- package/dist/types/error/tek-grid-delete-rows-error.d.ts +7 -0
- package/dist/types/error/teknisa-common-error.d.ts +6 -0
- package/dist/types/index.d.ts +1 -0
- package/dist/types/utils/config/config.d.ts +7 -0
- package/dist/types/utils/index.d.ts +3 -0
- package/dist/types/utils/is-filled-object/is-filled-object.d.ts +2 -0
- package/dist/types/utils/is-nil.d.ts +1 -0
- package/package.json +2 -2
- package/src/components/index.ts +5 -12
- package/src/components/tek-datasource/index.ts +3 -0
- package/src/components/tek-datasource/interfaces.ts +36 -0
- package/src/components/tek-datasource/tek-memory-datasource.ts +314 -0
- package/src/components/tek-datasource/tek-rest-datasource.ts +224 -0
- package/src/components/tek-grid/columns-searcher.ts +22 -0
- package/src/components/tek-grid/dynamic-filter-datasource-factory.ts +20 -0
- package/src/components/tek-grid/filter-helper.ts +20 -0
- package/src/components/tek-grid/grid-filter-button.ts +419 -0
- package/src/components/tek-grid/grouped-data-manager.ts +448 -0
- package/src/components/tek-grid/grouped-data-selector.ts +40 -0
- package/src/components/tek-grid/grouped-view-navigator.ts +84 -0
- package/src/components/tek-grid/index.ts +18 -0
- package/src/components/tek-grid/interfaces.ts +329 -0
- package/src/components/tek-grid/keymap-grouped.ts +20 -0
- package/src/components/tek-grid/layout-options.ts +248 -0
- package/src/components/tek-grid/tek-grid-column.ts +193 -0
- package/src/components/tek-grid/tek-grid-columns-button/tek-grid-columns-button-controller.ts +28 -0
- package/src/components/tek-grid/tek-grid-columns-button/tek-grid-columns-button.ts +38 -0
- package/src/components/tek-grid/tek-grid-controller.ts +140 -0
- package/src/components/tek-grid/tek-grid-events.ts +105 -0
- package/src/components/tek-grid/tek-grid-toolbar-provider/export-options/button-option.ts +26 -0
- package/src/components/tek-grid/tek-grid-toolbar-provider/export-options/index.ts +3 -0
- package/src/components/tek-grid/tek-grid-toolbar-provider/export-options/interfaces.ts +6 -0
- package/src/components/tek-grid/tek-grid-toolbar-provider/export-options/multi-option.ts +85 -0
- package/src/components/tek-grid/tek-grid-toolbar-provider/index.ts +2 -0
- package/src/components/tek-grid/tek-grid-toolbar-provider/tek-grid-toolbar-provider.ts +365 -0
- package/src/components/tek-grid/tek-grid.ts +1118 -0
- package/src/components/tek-user-info/TekUserInfoController.ts +87 -0
- package/src/components/tek-user-info/interfaces.ts +21 -0
- package/src/components/tek-user-info/tek-user-info-list.ts +64 -0
- package/src/components/tek-user-info/tek-user-info.ts +337 -0
- package/src/error/tek-grid-delete-rows-error.ts +15 -0
- package/src/error/teknisa-common-error.ts +8 -0
- package/src/index.ts +1 -0
- package/src/utils/config/config.ts +8 -0
- package/src/utils/index.ts +3 -0
- package/src/utils/is-filled-object/is-filled-object.ts +5 -0
- package/src/utils/is-nil.ts +3 -0
- package/tests/unit/components/tek-grid/button-option.spec.ts +49 -0
- package/tests/unit/components/tek-grid/columns-searcher.spec.ts +112 -0
- package/tests/unit/components/tek-grid/dynamic-filter-datasource-factory.spec.ts +90 -0
- package/tests/unit/components/tek-grid/filter-helper.spec.ts +34 -130
- package/tests/unit/components/tek-grid/grid-filter-button.spec.ts +110 -241
- package/tests/unit/components/tek-grid/grouped-data-manager.spec.ts +593 -0
- package/tests/unit/components/tek-grid/grouped-data-selector.spec.ts +136 -0
- package/tests/unit/components/tek-grid/grouped-view-navigator.spec.ts +244 -0
- package/tests/unit/components/tek-grid/keymap-grouped.spec.ts +20 -0
- package/tests/unit/components/tek-grid/{layout_options.spec.ts → layout-options.spec.ts} +77 -35
- package/tests/unit/components/tek-grid/multi-option.spec.ts +139 -0
- package/tests/unit/components/tek-grid/{grid-column.spec.ts → tek-grid-column.spec.ts} +48 -6
- package/tests/unit/components/tek-grid/{grid-columns-button.spec.ts → tek-grid-columns-button.spec.ts} +42 -9
- package/tests/unit/components/tek-grid/tek-grid-controller.spec.ts +253 -0
- package/tests/unit/components/tek-grid/tek-grid-events.spec.ts +186 -0
- package/tests/unit/components/tek-grid/tek-grid-toolbar-provider.spec.ts +34 -0
- package/tests/unit/components/tek-grid/tek-grid.spec.ts +895 -0
- package/tests/unit/components/tek-grid/tek-memory-datasource.spec.ts +482 -0
- package/tests/unit/components/tek-grid/tek-rest-datasource.spec.ts +422 -0
- package/dist/types/error/delete-rows-error.d.ts +0 -6
- package/src/error/delete-rows-error.ts +0 -11
- package/tests/unit/components/tek-grid/grid.spec.ts +0 -2701
|
@@ -1,13 +1,15 @@
|
|
|
1
1
|
import { Grid, Tag } from '@zeedhi/common';
|
|
2
|
-
import { Config, Http } from '@zeedhi/core';
|
|
2
|
+
import { Config, Http, Loader, SimpleControllerBuilder } from '@zeedhi/core';
|
|
3
3
|
import {
|
|
4
|
-
|
|
5
|
-
|
|
4
|
+
ITekConfig,
|
|
5
|
+
ITekGridLayoutInfo,
|
|
6
6
|
TekGrid,
|
|
7
7
|
TekGridLayoutOptions,
|
|
8
|
+
ITekGridProps,
|
|
8
9
|
} from '../../../../src';
|
|
10
|
+
import { flushPromises } from '../../__helpers__';
|
|
9
11
|
|
|
10
|
-
let savedLayouts = '';
|
|
12
|
+
let savedLayouts: string = '';
|
|
11
13
|
const testLayouts: ITekGridLayoutInfo = {
|
|
12
14
|
layouts: {
|
|
13
15
|
'Name first': {
|
|
@@ -37,7 +39,42 @@ const testLayouts: ITekGridLayoutInfo = {
|
|
|
37
39
|
},
|
|
38
40
|
};
|
|
39
41
|
|
|
42
|
+
const setupInstance = (props: Partial<ITekGridProps> = {}) => {
|
|
43
|
+
const instance = new TekGrid({
|
|
44
|
+
name: 'Grid',
|
|
45
|
+
component: 'TekGrid',
|
|
46
|
+
columns: [
|
|
47
|
+
{ name: 'first' },
|
|
48
|
+
{ name: 'second' },
|
|
49
|
+
{ name: 'third' },
|
|
50
|
+
],
|
|
51
|
+
datasource: {
|
|
52
|
+
limit: 2,
|
|
53
|
+
page: 1,
|
|
54
|
+
data: [
|
|
55
|
+
{ id: 1 },
|
|
56
|
+
{ id: 2 },
|
|
57
|
+
{ id: 3 },
|
|
58
|
+
{ id: 4 },
|
|
59
|
+
{ id: 5 },
|
|
60
|
+
{ id: 6 },
|
|
61
|
+
{ id: 7 },
|
|
62
|
+
],
|
|
63
|
+
},
|
|
64
|
+
...props,
|
|
65
|
+
});
|
|
66
|
+
const elem = document.createElement('DIV');
|
|
67
|
+
instance.onCreated();
|
|
68
|
+
instance.onMounted(elem);
|
|
69
|
+
|
|
70
|
+
return instance;
|
|
71
|
+
};
|
|
72
|
+
|
|
40
73
|
describe('LayoutOptions', () => {
|
|
74
|
+
beforeAll(() => {
|
|
75
|
+
Loader.setBuilder(new SimpleControllerBuilder());
|
|
76
|
+
});
|
|
77
|
+
|
|
41
78
|
describe('constructor()', () => {
|
|
42
79
|
it('should create layout options object', () => {
|
|
43
80
|
const instance = new TekGridLayoutOptions({ name: 'layout', component: 'TekGridLayoutOptions' });
|
|
@@ -56,7 +93,7 @@ describe('LayoutOptions', () => {
|
|
|
56
93
|
component: 'ZdTag',
|
|
57
94
|
tag: 'span',
|
|
58
95
|
});
|
|
59
|
-
const grid =
|
|
96
|
+
const grid = setupInstance({
|
|
60
97
|
name: 'grid',
|
|
61
98
|
component: 'TekGrid',
|
|
62
99
|
columns: [
|
|
@@ -103,9 +140,10 @@ describe('LayoutOptions', () => {
|
|
|
103
140
|
maxWidth: undefined,
|
|
104
141
|
aggregation: undefined,
|
|
105
142
|
align: 'left',
|
|
106
|
-
groupOpened:
|
|
143
|
+
groupOpened: false,
|
|
107
144
|
label: '',
|
|
108
145
|
filterHelperValue: [],
|
|
146
|
+
width: undefined,
|
|
109
147
|
},
|
|
110
148
|
{
|
|
111
149
|
name: 'name',
|
|
@@ -116,9 +154,10 @@ describe('LayoutOptions', () => {
|
|
|
116
154
|
maxWidth: undefined,
|
|
117
155
|
aggregation: undefined,
|
|
118
156
|
align: 'left',
|
|
119
|
-
groupOpened:
|
|
157
|
+
groupOpened: false,
|
|
120
158
|
label: '',
|
|
121
159
|
filterHelperValue: [],
|
|
160
|
+
width: undefined,
|
|
122
161
|
},
|
|
123
162
|
{
|
|
124
163
|
name: 'salary',
|
|
@@ -129,9 +168,10 @@ describe('LayoutOptions', () => {
|
|
|
129
168
|
maxWidth: undefined,
|
|
130
169
|
aggregation: undefined,
|
|
131
170
|
align: 'left',
|
|
132
|
-
groupOpened:
|
|
171
|
+
groupOpened: false,
|
|
133
172
|
label: '',
|
|
134
173
|
filterHelperValue: [],
|
|
174
|
+
width: undefined,
|
|
135
175
|
},
|
|
136
176
|
{
|
|
137
177
|
name: 'date1',
|
|
@@ -142,9 +182,10 @@ describe('LayoutOptions', () => {
|
|
|
142
182
|
maxWidth: undefined,
|
|
143
183
|
aggregation: undefined,
|
|
144
184
|
align: 'left',
|
|
145
|
-
groupOpened:
|
|
185
|
+
groupOpened: false,
|
|
146
186
|
label: '',
|
|
147
187
|
filterHelperValue: 'TODAY',
|
|
188
|
+
width: undefined
|
|
148
189
|
},
|
|
149
190
|
{
|
|
150
191
|
name: 'date2',
|
|
@@ -155,9 +196,10 @@ describe('LayoutOptions', () => {
|
|
|
155
196
|
maxWidth: undefined,
|
|
156
197
|
aggregation: undefined,
|
|
157
198
|
align: 'left',
|
|
158
|
-
groupOpened:
|
|
199
|
+
groupOpened: false,
|
|
159
200
|
label: '',
|
|
160
201
|
filterHelperValue: ['TODAY', 'TOMORROW'],
|
|
202
|
+
width: undefined,
|
|
161
203
|
},
|
|
162
204
|
]);
|
|
163
205
|
});
|
|
@@ -172,6 +214,7 @@ describe('LayoutOptions', () => {
|
|
|
172
214
|
{ name: 'salary' },
|
|
173
215
|
],
|
|
174
216
|
});
|
|
217
|
+
grid.onCreated();
|
|
175
218
|
const instance = new TekGridLayoutOptions({ name: 'layout', component: 'TekGridLayoutOptions' });
|
|
176
219
|
instance.parent = grid;
|
|
177
220
|
|
|
@@ -258,7 +301,7 @@ describe('LayoutOptions', () => {
|
|
|
258
301
|
component: 'ZdTag',
|
|
259
302
|
tag: 'span',
|
|
260
303
|
});
|
|
261
|
-
const grid =
|
|
304
|
+
const grid = setupInstance({
|
|
262
305
|
name: 'grid',
|
|
263
306
|
component: 'TekGrid',
|
|
264
307
|
columns: [
|
|
@@ -287,7 +330,7 @@ describe('LayoutOptions', () => {
|
|
|
287
330
|
component: 'ZdTag',
|
|
288
331
|
tag: 'span',
|
|
289
332
|
});
|
|
290
|
-
const grid =
|
|
333
|
+
const grid = setupInstance({
|
|
291
334
|
name: 'grid',
|
|
292
335
|
component: 'TekGrid',
|
|
293
336
|
columns: [
|
|
@@ -300,14 +343,16 @@ describe('LayoutOptions', () => {
|
|
|
300
343
|
instance.parent = tag;
|
|
301
344
|
tag.parent = grid;
|
|
302
345
|
|
|
303
|
-
const localStorageMock = ((
|
|
346
|
+
const localStorageMock = (function () { // eslint-disable-line func-names
|
|
347
|
+
return {
|
|
304
348
|
getItem(): string {
|
|
305
349
|
return JSON.stringify(testLayouts);
|
|
306
350
|
},
|
|
307
351
|
setItem(_name: string, value: string) {
|
|
308
352
|
savedLayouts = value;
|
|
309
353
|
},
|
|
310
|
-
}
|
|
354
|
+
};
|
|
355
|
+
}());
|
|
311
356
|
|
|
312
357
|
Object.defineProperty(window, 'localStorage', {
|
|
313
358
|
value: localStorageMock,
|
|
@@ -352,7 +397,7 @@ describe('LayoutOptions', () => {
|
|
|
352
397
|
component: 'ZdTag',
|
|
353
398
|
tag: 'span',
|
|
354
399
|
});
|
|
355
|
-
const grid =
|
|
400
|
+
const grid = setupInstance({
|
|
356
401
|
name: 'grid',
|
|
357
402
|
component: 'TekGrid',
|
|
358
403
|
columns: [
|
|
@@ -410,7 +455,7 @@ describe('LayoutOptions', () => {
|
|
|
410
455
|
component: 'ZdTag',
|
|
411
456
|
tag: 'span',
|
|
412
457
|
});
|
|
413
|
-
const grid =
|
|
458
|
+
const grid = setupInstance({
|
|
414
459
|
name: 'grid',
|
|
415
460
|
component: 'TekGrid',
|
|
416
461
|
columns: [
|
|
@@ -445,7 +490,7 @@ describe('LayoutOptions', () => {
|
|
|
445
490
|
component: 'ZdTag',
|
|
446
491
|
tag: 'span',
|
|
447
492
|
});
|
|
448
|
-
const grid =
|
|
493
|
+
const grid = setupInstance({
|
|
449
494
|
name: 'grid',
|
|
450
495
|
component: 'TekGrid',
|
|
451
496
|
columns: [
|
|
@@ -474,7 +519,7 @@ describe('LayoutOptions', () => {
|
|
|
474
519
|
component: 'ZdTag',
|
|
475
520
|
tag: 'span',
|
|
476
521
|
});
|
|
477
|
-
const grid =
|
|
522
|
+
const grid = setupInstance({
|
|
478
523
|
name: 'grid',
|
|
479
524
|
component: 'TekGrid',
|
|
480
525
|
columns: [
|
|
@@ -506,7 +551,7 @@ describe('LayoutOptions', () => {
|
|
|
506
551
|
component: 'ZdTag',
|
|
507
552
|
tag: 'span',
|
|
508
553
|
});
|
|
509
|
-
const grid =
|
|
554
|
+
const grid = setupInstance({
|
|
510
555
|
name: 'grid',
|
|
511
556
|
component: 'TekGrid',
|
|
512
557
|
columns: [
|
|
@@ -535,7 +580,7 @@ describe('LayoutOptions', () => {
|
|
|
535
580
|
component: 'ZdTag',
|
|
536
581
|
tag: 'span',
|
|
537
582
|
});
|
|
538
|
-
const grid =
|
|
583
|
+
const grid = setupInstance({
|
|
539
584
|
name: 'grid',
|
|
540
585
|
component: 'TekGrid',
|
|
541
586
|
columns: [
|
|
@@ -565,7 +610,7 @@ describe('LayoutOptions', () => {
|
|
|
565
610
|
component: 'ZdTag',
|
|
566
611
|
tag: 'span',
|
|
567
612
|
});
|
|
568
|
-
const grid =
|
|
613
|
+
const grid = setupInstance({
|
|
569
614
|
name: 'grid',
|
|
570
615
|
component: 'TekGrid',
|
|
571
616
|
columns: [
|
|
@@ -660,7 +705,7 @@ describe('LayoutOptions', () => {
|
|
|
660
705
|
component: 'ZdTag',
|
|
661
706
|
tag: 'span',
|
|
662
707
|
});
|
|
663
|
-
const grid =
|
|
708
|
+
const grid = setupInstance({
|
|
664
709
|
name: 'grid',
|
|
665
710
|
component: 'TekGrid',
|
|
666
711
|
columns: [
|
|
@@ -697,7 +742,7 @@ describe('LayoutOptions', () => {
|
|
|
697
742
|
component: 'ZdTag',
|
|
698
743
|
tag: 'span',
|
|
699
744
|
});
|
|
700
|
-
const grid =
|
|
745
|
+
const grid = setupInstance({
|
|
701
746
|
name: 'grid',
|
|
702
747
|
component: 'TekGrid',
|
|
703
748
|
columns: [
|
|
@@ -753,7 +798,7 @@ describe('LayoutOptions', () => {
|
|
|
753
798
|
component: 'ZdTag',
|
|
754
799
|
tag: 'span',
|
|
755
800
|
});
|
|
756
|
-
const grid =
|
|
801
|
+
const grid = setupInstance({
|
|
757
802
|
name: 'grid',
|
|
758
803
|
component: 'TekGrid',
|
|
759
804
|
columns: [
|
|
@@ -794,7 +839,7 @@ describe('LayoutOptions', () => {
|
|
|
794
839
|
component: 'ZdTag',
|
|
795
840
|
tag: 'span',
|
|
796
841
|
});
|
|
797
|
-
const grid =
|
|
842
|
+
const grid = setupInstance({
|
|
798
843
|
name: 'grid',
|
|
799
844
|
component: 'TekGrid',
|
|
800
845
|
columns: [
|
|
@@ -804,7 +849,6 @@ describe('LayoutOptions', () => {
|
|
|
804
849
|
],
|
|
805
850
|
});
|
|
806
851
|
const instance = new TekGridLayoutOptions({ name: 'layout', component: 'TekGridLayoutOptions' });
|
|
807
|
-
const flushPromises = () => new Promise(setImmediate);
|
|
808
852
|
instance.parent = tag;
|
|
809
853
|
tag.parent = grid;
|
|
810
854
|
|
|
@@ -830,7 +874,7 @@ describe('LayoutOptions', () => {
|
|
|
830
874
|
await grid.onMounted({} as HTMLElement);
|
|
831
875
|
|
|
832
876
|
await flushPromises();
|
|
833
|
-
expect(spy).
|
|
877
|
+
expect(spy).toHaveBeenCalled();
|
|
834
878
|
expect(instance.layouts).toEqual({
|
|
835
879
|
'layout-test': {
|
|
836
880
|
name: 'layout-test',
|
|
@@ -854,7 +898,7 @@ describe('LayoutOptions', () => {
|
|
|
854
898
|
component: 'ZdTag',
|
|
855
899
|
tag: 'span',
|
|
856
900
|
});
|
|
857
|
-
const grid =
|
|
901
|
+
const grid = setupInstance({
|
|
858
902
|
name: 'grid',
|
|
859
903
|
component: 'TekGrid',
|
|
860
904
|
columns: [
|
|
@@ -864,7 +908,6 @@ describe('LayoutOptions', () => {
|
|
|
864
908
|
],
|
|
865
909
|
});
|
|
866
910
|
const instance = new TekGridLayoutOptions({ name: 'layout', component: 'TekGridLayoutOptions' });
|
|
867
|
-
const flushPromises = () => new Promise(setImmediate);
|
|
868
911
|
instance.parent = tag;
|
|
869
912
|
tag.parent = grid;
|
|
870
913
|
|
|
@@ -890,7 +933,7 @@ describe('LayoutOptions', () => {
|
|
|
890
933
|
await grid.onMounted({} as HTMLElement);
|
|
891
934
|
|
|
892
935
|
await flushPromises();
|
|
893
|
-
expect(spy).
|
|
936
|
+
expect(spy).toHaveBeenCalled();
|
|
894
937
|
expect(instance.layouts).toEqual({
|
|
895
938
|
'layout-test': {
|
|
896
939
|
name: 'layout-test',
|
|
@@ -914,7 +957,7 @@ describe('LayoutOptions', () => {
|
|
|
914
957
|
component: 'ZdTag',
|
|
915
958
|
tag: 'span',
|
|
916
959
|
});
|
|
917
|
-
const grid =
|
|
960
|
+
const grid = setupInstance({
|
|
918
961
|
name: 'grid',
|
|
919
962
|
component: 'TekGrid',
|
|
920
963
|
columns: [
|
|
@@ -924,17 +967,16 @@ describe('LayoutOptions', () => {
|
|
|
924
967
|
],
|
|
925
968
|
});
|
|
926
969
|
const instance = new TekGridLayoutOptions({ name: 'layout', component: 'TekGridLayoutOptions' });
|
|
927
|
-
const flushPromises = () => new Promise(setImmediate);
|
|
928
970
|
instance.parent = tag;
|
|
929
971
|
tag.parent = grid;
|
|
930
972
|
|
|
931
973
|
const spy = jest.spyOn(Http, 'get').mockImplementation(() => Promise.resolve({ data: { data: '' } }));
|
|
932
974
|
|
|
933
975
|
await instance.onMounted({} as HTMLElement);
|
|
934
|
-
|
|
976
|
+
grid.onMounted({} as HTMLElement);
|
|
935
977
|
|
|
936
978
|
await flushPromises();
|
|
937
|
-
expect(spy).
|
|
979
|
+
expect(spy).toHaveBeenCalled();
|
|
938
980
|
expect(instance.layouts).toEqual({});
|
|
939
981
|
spy.mockReset();
|
|
940
982
|
(Config as ITekConfig).loadGridLayoutsEndPoint = '';
|
|
@@ -947,7 +989,7 @@ describe('LayoutOptions', () => {
|
|
|
947
989
|
component: 'ZdTag',
|
|
948
990
|
tag: 'span',
|
|
949
991
|
});
|
|
950
|
-
const grid =
|
|
992
|
+
const grid = setupInstance({
|
|
951
993
|
name: 'grid',
|
|
952
994
|
component: 'TekGrid',
|
|
953
995
|
columns: [
|
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
import { Button, IText, Text } from '@zeedhi/common';
|
|
2
|
+
import { ITekGridExportConfig, TekGrid, MultiOption } from '../../../../src';
|
|
3
|
+
import { Loader, SimpleControllerBuilder } from '@zeedhi/core';
|
|
4
|
+
|
|
5
|
+
describe('MultiOption', () => {
|
|
6
|
+
beforeAll(() => {
|
|
7
|
+
Loader.setBuilder(new SimpleControllerBuilder());
|
|
8
|
+
});
|
|
9
|
+
|
|
10
|
+
describe('buildComponent()', () => {
|
|
11
|
+
it('when called, should build a row with multiple buttons', () => {
|
|
12
|
+
const grid = new TekGrid({ name: 'Grid', component: 'TekGrid' });
|
|
13
|
+
const config: ITekGridExportConfig = {
|
|
14
|
+
type: 'pdf',
|
|
15
|
+
label: 'Exportar PDF',
|
|
16
|
+
multiOption: [
|
|
17
|
+
{ label: 'portrait', iconName: 'icon-portrait' },
|
|
18
|
+
{ label: 'landscape', iconName: 'icon-landscape' },
|
|
19
|
+
],
|
|
20
|
+
};
|
|
21
|
+
const option = new MultiOption(config);
|
|
22
|
+
|
|
23
|
+
const component = option.buildComponent(grid);
|
|
24
|
+
|
|
25
|
+
expect(component).toEqual({
|
|
26
|
+
name: 'Grid_export_pdf_row',
|
|
27
|
+
component: 'ZdRow',
|
|
28
|
+
cssClass: 'zd-display-flex zd-ma-0 zd-py-0 zd-gap-x-1 tek-grid-export-multioption-row',
|
|
29
|
+
children: [
|
|
30
|
+
expect.objectContaining({
|
|
31
|
+
name: 'Grid_export_pdf_text',
|
|
32
|
+
component: 'ZdText',
|
|
33
|
+
text: 'Exportar PDF',
|
|
34
|
+
cssClass: 'zd-display-flex zd-align-center zd-flex-grow-1 tek-grid-export-multioption-text',
|
|
35
|
+
}),
|
|
36
|
+
{
|
|
37
|
+
name: 'Grid_export_pdf_tooltip_portrait',
|
|
38
|
+
component: 'ZdTooltip',
|
|
39
|
+
bottom: true,
|
|
40
|
+
label: 'portrait',
|
|
41
|
+
children: [
|
|
42
|
+
expect.objectContaining({
|
|
43
|
+
name: 'Grid_export_pdf_button_portrait',
|
|
44
|
+
component: 'ZdButton',
|
|
45
|
+
icon: true,
|
|
46
|
+
iconName: 'icon-portrait',
|
|
47
|
+
}),
|
|
48
|
+
],
|
|
49
|
+
},
|
|
50
|
+
expect.objectContaining({
|
|
51
|
+
name: 'Grid_export_pdf_divider_portrait',
|
|
52
|
+
component: 'ZdDivider',
|
|
53
|
+
cssClass: 'zd-my-1',
|
|
54
|
+
vertical: true,
|
|
55
|
+
}),
|
|
56
|
+
{
|
|
57
|
+
name: 'Grid_export_pdf_tooltip_landscape',
|
|
58
|
+
component: 'ZdTooltip',
|
|
59
|
+
bottom: true,
|
|
60
|
+
label: 'landscape',
|
|
61
|
+
children: [
|
|
62
|
+
expect.objectContaining({
|
|
63
|
+
name: 'Grid_export_pdf_button_landscape',
|
|
64
|
+
component: 'ZdButton',
|
|
65
|
+
icon: true,
|
|
66
|
+
iconName: 'icon-landscape',
|
|
67
|
+
}),
|
|
68
|
+
],
|
|
69
|
+
},
|
|
70
|
+
],
|
|
71
|
+
});
|
|
72
|
+
});
|
|
73
|
+
|
|
74
|
+
it('the generated text component should call stopPropagation on click', () => {
|
|
75
|
+
const grid = new TekGrid({ name: 'Grid', component: 'TekGrid' });
|
|
76
|
+
const config: ITekGridExportConfig = {
|
|
77
|
+
type: 'pdf',
|
|
78
|
+
label: 'Exportar PDF',
|
|
79
|
+
multiOption: [
|
|
80
|
+
{ label: 'portrait', iconName: 'icon-portrait' },
|
|
81
|
+
{ label: 'landscape', iconName: 'icon-landscape' },
|
|
82
|
+
],
|
|
83
|
+
};
|
|
84
|
+
const option = new MultiOption(config);
|
|
85
|
+
|
|
86
|
+
const component = option.buildComponent(grid);
|
|
87
|
+
|
|
88
|
+
const instance = new Text(component.children![0] as IText);
|
|
89
|
+
const spy = jest.fn();
|
|
90
|
+
const event = { stopPropagation: spy } as unknown as Event;
|
|
91
|
+
instance.click(event);
|
|
92
|
+
|
|
93
|
+
expect(spy).toHaveBeenCalled();
|
|
94
|
+
});
|
|
95
|
+
|
|
96
|
+
it('the generated text component should not throw if event is undefined', () => {
|
|
97
|
+
const grid = new TekGrid({ name: 'Grid', component: 'TekGrid' });
|
|
98
|
+
const config: ITekGridExportConfig = {
|
|
99
|
+
type: 'pdf',
|
|
100
|
+
label: 'Exportar PDF',
|
|
101
|
+
multiOption: [
|
|
102
|
+
{ label: 'portrait', iconName: 'icon-portrait' },
|
|
103
|
+
{ label: 'landscape', iconName: 'icon-landscape' },
|
|
104
|
+
],
|
|
105
|
+
};
|
|
106
|
+
const option = new MultiOption(config);
|
|
107
|
+
|
|
108
|
+
const component = option.buildComponent(grid);
|
|
109
|
+
|
|
110
|
+
const instance = new Text(component.children![0] as IText);
|
|
111
|
+
|
|
112
|
+
expect(() => instance.callEvent('click', { event: undefined })).not.toThrow();
|
|
113
|
+
});
|
|
114
|
+
|
|
115
|
+
it('the generated button components should call grid.getReport on click', () => {
|
|
116
|
+
const grid = new TekGrid({ name: 'Grid', component: 'TekGrid' });
|
|
117
|
+
const spy = jest.fn();
|
|
118
|
+
grid.getReport = spy;
|
|
119
|
+
const config: ITekGridExportConfig = {
|
|
120
|
+
type: 'pdf',
|
|
121
|
+
multiOption: [
|
|
122
|
+
{ label: 'portrait', iconName: 'icon-portrait' },
|
|
123
|
+
{ label: 'landscape', iconName: 'icon-landscape' },
|
|
124
|
+
],
|
|
125
|
+
};
|
|
126
|
+
const option = new MultiOption(config);
|
|
127
|
+
|
|
128
|
+
const component = option.buildComponent(grid);
|
|
129
|
+
|
|
130
|
+
const instance = new Button(component.children![1].children![0]);
|
|
131
|
+
instance.click();
|
|
132
|
+
|
|
133
|
+
const instance2 = new Button(component.children![3].children![0]);
|
|
134
|
+
instance2.click();
|
|
135
|
+
|
|
136
|
+
expect(spy).toHaveBeenCalledTimes(2);
|
|
137
|
+
});
|
|
138
|
+
});
|
|
139
|
+
});
|
|
@@ -1,20 +1,24 @@
|
|
|
1
|
-
import { Http } from '@zeedhi/core';
|
|
1
|
+
import { Http, Loader, SimpleControllerBuilder } from '@zeedhi/core';
|
|
2
2
|
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
3
|
+
IFilterOperation,
|
|
4
|
+
IFilterPropsComponent,
|
|
5
|
+
IFilterRelation,
|
|
6
|
+
ITekGridColumn,
|
|
7
7
|
TekGrid,
|
|
8
8
|
TekGridColumn,
|
|
9
9
|
} from '../../../../src';
|
|
10
|
+
import { flushPromises } from '../../__helpers__';
|
|
10
11
|
|
|
11
12
|
jest.mock('lodash.debounce', () => jest.fn((fn) => fn));
|
|
12
|
-
const flushPromises = () => new Promise(setImmediate);
|
|
13
13
|
|
|
14
14
|
describe('TekGridColumn', () => {
|
|
15
15
|
let baseProps: ITekGridColumn;
|
|
16
16
|
let httpSpy: jest.SpyInstance;
|
|
17
17
|
|
|
18
|
+
beforeAll(() => {
|
|
19
|
+
Loader.setBuilder(new SimpleControllerBuilder());
|
|
20
|
+
});
|
|
21
|
+
|
|
18
22
|
beforeEach(() => {
|
|
19
23
|
httpSpy = jest.spyOn(Http, 'get').mockImplementation((url: string) => {
|
|
20
24
|
if (url === '/zeedhi') {
|
|
@@ -120,6 +124,7 @@ describe('TekGridColumn', () => {
|
|
|
120
124
|
it('should get lookup data', async () => {
|
|
121
125
|
const grid = new TekGrid({ name: 'grid', component: 'TekGrid' });
|
|
122
126
|
const column = new TekGridColumn(baseProps, grid);
|
|
127
|
+
column.initialize();
|
|
123
128
|
|
|
124
129
|
let data = column.getLookupData('name', 'employee 1');
|
|
125
130
|
expect(data).toEqual({});
|
|
@@ -153,6 +158,7 @@ describe('TekGridColumn', () => {
|
|
|
153
158
|
const grid = new TekGrid({ name: 'grid', component: 'TekGrid' });
|
|
154
159
|
baseProps.storeData = false;
|
|
155
160
|
const column = new TekGridColumn(baseProps, grid);
|
|
161
|
+
column.initialize();
|
|
156
162
|
|
|
157
163
|
let data = column.getLookupData('name', 'employee 1');
|
|
158
164
|
expect(data).toEqual({});
|
|
@@ -267,4 +273,40 @@ describe('TekGridColumn', () => {
|
|
|
267
273
|
await expect(column.memorySearch('')).rejects.toThrow();
|
|
268
274
|
});
|
|
269
275
|
});
|
|
276
|
+
|
|
277
|
+
describe('change grouping', () => {
|
|
278
|
+
beforeEach(() => {
|
|
279
|
+
jest.useFakeTimers();
|
|
280
|
+
});
|
|
281
|
+
|
|
282
|
+
it('when grouped property changes, should call grid updateGrouping', () => {
|
|
283
|
+
const grid = { updateGrouping: jest.fn() } as any as TekGrid;
|
|
284
|
+
const column = new TekGridColumn(baseProps, grid);
|
|
285
|
+
column.grouped = true;
|
|
286
|
+
|
|
287
|
+
jest.runAllTimers();
|
|
288
|
+
|
|
289
|
+
expect(grid.updateGrouping).toHaveBeenCalled();
|
|
290
|
+
});
|
|
291
|
+
|
|
292
|
+
it('when aggregation property changes, should call grid updateGrouping', () => {
|
|
293
|
+
const grid = { updateGrouping: jest.fn() } as any as TekGrid;
|
|
294
|
+
const column = new TekGridColumn(baseProps, grid);
|
|
295
|
+
column.aggregation = 'COUNT';
|
|
296
|
+
|
|
297
|
+
jest.runAllTimers();
|
|
298
|
+
|
|
299
|
+
expect(grid.updateGrouping).toHaveBeenCalled();
|
|
300
|
+
});
|
|
301
|
+
|
|
302
|
+
it('when groupOpened property changes, should call grid updateGrouping', () => {
|
|
303
|
+
const grid = { updateGrouping: jest.fn() } as any as TekGrid;
|
|
304
|
+
const column = new TekGridColumn(baseProps, grid);
|
|
305
|
+
column.groupOpened = true;
|
|
306
|
+
|
|
307
|
+
jest.runAllTimers();
|
|
308
|
+
|
|
309
|
+
expect(grid.updateGrouping).toHaveBeenCalled();
|
|
310
|
+
});
|
|
311
|
+
});
|
|
270
312
|
});
|
|
@@ -1,9 +1,42 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
import { I18n, Loader, SimpleControllerBuilder } from '@zeedhi/core';
|
|
2
|
+
import { TekGrid, TekGridColumnsButton, TekGridColumnsButtonController, Grid, Checkbox, ITekGridProps } from '../../../../src';
|
|
3
|
+
|
|
4
|
+
const setupInstance = (props: Partial<ITekGridProps> = {}) => {
|
|
5
|
+
const instance = new TekGrid({
|
|
6
|
+
name: 'Grid',
|
|
7
|
+
component: 'TekGrid',
|
|
8
|
+
columns: [
|
|
9
|
+
{ name: 'first' },
|
|
10
|
+
{ name: 'second' },
|
|
11
|
+
{ name: 'third' },
|
|
12
|
+
],
|
|
13
|
+
datasource: {
|
|
14
|
+
limit: 2,
|
|
15
|
+
page: 1,
|
|
16
|
+
data: [
|
|
17
|
+
{ id: 1 },
|
|
18
|
+
{ id: 2 },
|
|
19
|
+
{ id: 3 },
|
|
20
|
+
{ id: 4 },
|
|
21
|
+
{ id: 5 },
|
|
22
|
+
{ id: 6 },
|
|
23
|
+
{ id: 7 },
|
|
24
|
+
],
|
|
25
|
+
},
|
|
26
|
+
...props,
|
|
27
|
+
});
|
|
28
|
+
const elem = document.createElement('DIV');
|
|
29
|
+
instance.onCreated();
|
|
30
|
+
instance.onMounted(elem);
|
|
31
|
+
|
|
32
|
+
return instance;
|
|
33
|
+
};
|
|
5
34
|
|
|
6
35
|
describe('TekGridColumnsButton', () => {
|
|
36
|
+
beforeAll(() => {
|
|
37
|
+
Loader.setBuilder(new SimpleControllerBuilder());
|
|
38
|
+
});
|
|
39
|
+
|
|
7
40
|
describe('getAggregationSelectData', () => {
|
|
8
41
|
it('should get aggregation data', () => {
|
|
9
42
|
let I18Called = false;
|
|
@@ -12,7 +45,7 @@ describe('TekGridColumnsButton', () => {
|
|
|
12
45
|
if (Array.isArray(code)) return code[0];
|
|
13
46
|
return code;
|
|
14
47
|
});
|
|
15
|
-
const grid =
|
|
48
|
+
const grid = setupInstance({
|
|
16
49
|
name: 'grid-1',
|
|
17
50
|
component: 'TekGrid',
|
|
18
51
|
});
|
|
@@ -45,7 +78,7 @@ describe('TekGridColumnsButton', () => {
|
|
|
45
78
|
component: 'ZdCheckbox',
|
|
46
79
|
value: false,
|
|
47
80
|
});
|
|
48
|
-
const iterable = new
|
|
81
|
+
const iterable = new Grid({
|
|
49
82
|
name: 'iterable',
|
|
50
83
|
component: 'ZdIterable',
|
|
51
84
|
columns: [
|
|
@@ -55,7 +88,7 @@ describe('TekGridColumnsButton', () => {
|
|
|
55
88
|
},
|
|
56
89
|
],
|
|
57
90
|
});
|
|
58
|
-
const grid =
|
|
91
|
+
const grid = setupInstance({
|
|
59
92
|
name: 'grid-1',
|
|
60
93
|
component: 'TekGrid',
|
|
61
94
|
parent: iterable,
|
|
@@ -78,7 +111,7 @@ describe('TekGridColumnsButton', () => {
|
|
|
78
111
|
});
|
|
79
112
|
|
|
80
113
|
it('changeGroupedColumn', () => {
|
|
81
|
-
const grid =
|
|
114
|
+
const grid = setupInstance({
|
|
82
115
|
name: 'grid-2',
|
|
83
116
|
component: 'TekGrid',
|
|
84
117
|
columns: [
|
|
@@ -130,7 +163,7 @@ describe('TekGridColumnsButton', () => {
|
|
|
130
163
|
});
|
|
131
164
|
|
|
132
165
|
it('changeAggregationColumn', () => {
|
|
133
|
-
const grid =
|
|
166
|
+
const grid = setupInstance({
|
|
134
167
|
name: 'grid-2',
|
|
135
168
|
component: 'TekGrid',
|
|
136
169
|
columns: [
|