@zeedhi/teknisa-components-common 1.131.0 → 1.132.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 +443 -390
- package/coverage/coverage-final.json +49 -48
- package/coverage/lcov-report/index.html +13 -13
- package/coverage/lcov-report/tests/__helpers__/component-event-helper.ts.html +1 -1
- package/coverage/lcov-report/tests/__helpers__/flush-promises-helper.ts.html +1 -1
- package/coverage/lcov-report/tests/__helpers__/get-child-helper.ts.html +1 -1
- 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 +696 -580
- package/dist/tek-components-common.esm.js +116 -33
- package/dist/tek-components-common.umd.js +116 -33
- package/package.json +2 -2
- package/tests/unit/components/tek-grid/grid.spec.ts +40 -0
- package/tests/unit/components/tek-grid/layout_options.spec.ts +516 -27
- package/tests/unit/utils/object-comparison.spec.ts +89 -0
- package/types/components/tek-grid/layout-options.d.ts +9 -0
- package/types/utils/index.d.ts +1 -0
- package/types/utils/object-comparison.d.ts +3 -0
- package/.package.json +0 -39
- package/types/components/tek-ag-grid/default-icons.d.ts +0 -53
- package/types/components/tek-ag-grid/interfaces.d.ts +0 -9
- package/types/components/tek-ag-grid/tek-ag-grid.d.ts +0 -35
- package/types/components/tek-datasource/datasource.d.ts +0 -94
- package/types/components/tek-grid/default-icons.d.ts +0 -53
- package/types/components/tek-grid/filter-dynamic-values.d.ts +0 -9
- package/types/components/tek-grid/grid-controller.d.ts +0 -19
- package/types/components/tek-grid/grid_column.d.ts +0 -14
- package/types/components/tek-grid/grid_controller.d.ts +0 -15
- package/types/components/tek-grid/tek-grid.d.ts +0 -35
- package/types/components/tek-login/interfaces.d.ts +0 -3
- package/types/components/tek-login/login-children.d.ts +0 -3
- package/types/components/tek-login/login.d.ts +0 -58
- package/types/components/tek-login/login_children.d.ts +0 -3
|
@@ -8,6 +8,7 @@ import {
|
|
|
8
8
|
ITekGridLayoutInfo,
|
|
9
9
|
TekGrid,
|
|
10
10
|
TekGridLayoutOptions,
|
|
11
|
+
TekRestDatasource,
|
|
11
12
|
} from '../../../../src';
|
|
12
13
|
import { setClick } from '../../../__helpers__';
|
|
13
14
|
|
|
@@ -153,7 +154,7 @@ describe('LayoutOptions', () => {
|
|
|
153
154
|
expect(instance.originalColumnProps.map((column) => column.name)).toEqual(['id', 'name']);
|
|
154
155
|
});
|
|
155
156
|
|
|
156
|
-
it('should mark layout as edited when named grid layout
|
|
157
|
+
it('should not mark layout as edited when named grid layout change does not change layout state', async () => {
|
|
157
158
|
const grid = new TekGrid({
|
|
158
159
|
name: 'layout_options_change_layout_grid',
|
|
159
160
|
component: 'TekGrid',
|
|
@@ -172,7 +173,152 @@ describe('LayoutOptions', () => {
|
|
|
172
173
|
|
|
173
174
|
grid.changeLayout();
|
|
174
175
|
|
|
176
|
+
expect(instance.layoutEdited).toBe(false);
|
|
177
|
+
});
|
|
178
|
+
|
|
179
|
+
it('should mark layout as edited only when column width changes explicitly', async () => {
|
|
180
|
+
const grid = new TekGrid({
|
|
181
|
+
name: 'layout_options_column_width_grid',
|
|
182
|
+
component: 'TekGrid',
|
|
183
|
+
columns: [{ name: 'id' }],
|
|
184
|
+
});
|
|
185
|
+
grid.onCreated();
|
|
186
|
+
|
|
187
|
+
const instance = new TekGridLayoutOptions({
|
|
188
|
+
name: 'layout_options_column_width',
|
|
189
|
+
component: 'TekGridLayoutOptions',
|
|
190
|
+
gridName: 'layout_options_column_width_grid',
|
|
191
|
+
});
|
|
192
|
+
|
|
193
|
+
await instance.onMounted({} as HTMLElement);
|
|
194
|
+
expect(instance.layoutEdited).toBe(false);
|
|
195
|
+
|
|
196
|
+
grid.changeLayout();
|
|
197
|
+
|
|
198
|
+
expect(instance.layoutEdited).toBe(false);
|
|
199
|
+
|
|
200
|
+
grid.columns[0].width = '120px';
|
|
201
|
+
grid.changeLayout();
|
|
202
|
+
|
|
203
|
+
expect(instance.layoutEdited).toBe(true);
|
|
204
|
+
|
|
205
|
+
grid.columns[0].width = undefined;
|
|
206
|
+
grid.changeLayout();
|
|
207
|
+
|
|
208
|
+
expect(instance.layoutEdited).toBe(false);
|
|
209
|
+
});
|
|
210
|
+
|
|
211
|
+
it('should compare current grid layout with selected named layout', async () => {
|
|
212
|
+
const grid = new TekGrid({
|
|
213
|
+
name: 'layout_options_named_baseline_grid',
|
|
214
|
+
component: 'TekGrid',
|
|
215
|
+
columns: [{ name: 'id' }],
|
|
216
|
+
});
|
|
217
|
+
grid.onCreated();
|
|
218
|
+
|
|
219
|
+
const instance = new TekGridLayoutOptions({
|
|
220
|
+
name: 'layout_options_named_baseline',
|
|
221
|
+
component: 'TekGridLayoutOptions',
|
|
222
|
+
gridName: 'layout_options_named_baseline_grid',
|
|
223
|
+
});
|
|
224
|
+
|
|
225
|
+
await instance.onMounted({} as HTMLElement);
|
|
226
|
+
|
|
227
|
+
const selectedLayout = instance.getCurrentLayout();
|
|
228
|
+
selectedLayout.name = 'Name first';
|
|
229
|
+
instance.layouts = {
|
|
230
|
+
'Name first': selectedLayout,
|
|
231
|
+
};
|
|
232
|
+
instance.currentLayoutName = 'Name first';
|
|
233
|
+
|
|
234
|
+
expect(instance.hasLayoutChanges()).toBe(false);
|
|
235
|
+
|
|
236
|
+
grid.columns[0].width = '120px';
|
|
237
|
+
|
|
238
|
+
expect(instance.hasLayoutChanges()).toBe(true);
|
|
239
|
+
});
|
|
240
|
+
|
|
241
|
+
it('should not detect layout changes when there is no baseline layout', async () => {
|
|
242
|
+
const grid = new TekGrid({
|
|
243
|
+
name: 'layout_options_without_baseline_grid',
|
|
244
|
+
component: 'TekGrid',
|
|
245
|
+
columns: [{ name: 'id' }],
|
|
246
|
+
});
|
|
247
|
+
grid.onCreated();
|
|
248
|
+
|
|
249
|
+
const instance = new TekGridLayoutOptions({
|
|
250
|
+
name: 'layout_options_without_baseline',
|
|
251
|
+
component: 'TekGridLayoutOptions',
|
|
252
|
+
gridName: 'layout_options_without_baseline_grid',
|
|
253
|
+
});
|
|
254
|
+
|
|
255
|
+
await instance.onMounted({} as HTMLElement);
|
|
256
|
+
instance.currentLayoutName = 'Missing layout';
|
|
257
|
+
|
|
258
|
+
expect(instance.hasLayoutChanges()).toBe(false);
|
|
259
|
+
});
|
|
260
|
+
|
|
261
|
+
it('should mark layout as edited when filter changes and clear when filter is restored', async () => {
|
|
262
|
+
const grid = new TekGrid({
|
|
263
|
+
name: 'layout_options_filter_undo_grid',
|
|
264
|
+
component: 'TekGrid',
|
|
265
|
+
columns: [{ name: 'id' }],
|
|
266
|
+
});
|
|
267
|
+
grid.onCreated();
|
|
268
|
+
|
|
269
|
+
const instance = new TekGridLayoutOptions({
|
|
270
|
+
name: 'layout_options_filter_undo',
|
|
271
|
+
component: 'TekGridLayoutOptions',
|
|
272
|
+
gridName: 'layout_options_filter_undo_grid',
|
|
273
|
+
});
|
|
274
|
+
|
|
275
|
+
await instance.onMounted({} as HTMLElement);
|
|
276
|
+
expect(instance.layoutEdited).toBe(false);
|
|
277
|
+
|
|
278
|
+
grid.datasource.filter = { id: '10' };
|
|
279
|
+
grid.changeLayout();
|
|
280
|
+
|
|
175
281
|
expect(instance.layoutEdited).toBe(true);
|
|
282
|
+
|
|
283
|
+
grid.datasource.filter = {};
|
|
284
|
+
grid.changeLayout();
|
|
285
|
+
|
|
286
|
+
expect(instance.layoutEdited).toBe(false);
|
|
287
|
+
});
|
|
288
|
+
|
|
289
|
+
it('should mark layout as edited when dynamic filter changes and clear when dynamic filter is restored', async () => {
|
|
290
|
+
const grid = new TekGrid({
|
|
291
|
+
name: 'layout_options_dynamic_filter_undo_grid',
|
|
292
|
+
component: 'TekGrid',
|
|
293
|
+
datasource: {
|
|
294
|
+
type: 'tek-rest',
|
|
295
|
+
lazyLoad: true,
|
|
296
|
+
dynamicFilter: {
|
|
297
|
+
id: [{ relation: 'AND', operation: 'EQUALS', value: '10' }],
|
|
298
|
+
},
|
|
299
|
+
},
|
|
300
|
+
columns: [{ name: 'id' }],
|
|
301
|
+
});
|
|
302
|
+
grid.onCreated();
|
|
303
|
+
|
|
304
|
+
const instance = new TekGridLayoutOptions({
|
|
305
|
+
name: 'layout_options_dynamic_filter_undo',
|
|
306
|
+
component: 'TekGridLayoutOptions',
|
|
307
|
+
gridName: 'layout_options_dynamic_filter_undo_grid',
|
|
308
|
+
});
|
|
309
|
+
|
|
310
|
+
await instance.onMounted({} as HTMLElement);
|
|
311
|
+
expect(instance.layoutEdited).toBe(false);
|
|
312
|
+
|
|
313
|
+
(grid.datasource as TekRestDatasource).dynamicFilter.id[0].value = '20';
|
|
314
|
+
grid.changeLayout();
|
|
315
|
+
|
|
316
|
+
expect(instance.layoutEdited).toBe(true);
|
|
317
|
+
|
|
318
|
+
(grid.datasource as TekRestDatasource).dynamicFilter.id[0].value = '10';
|
|
319
|
+
grid.changeLayout();
|
|
320
|
+
|
|
321
|
+
expect(instance.layoutEdited).toBe(false);
|
|
176
322
|
});
|
|
177
323
|
|
|
178
324
|
it('should preserve existing changeLayout event handlers', async () => {
|
|
@@ -199,7 +345,7 @@ describe('LayoutOptions', () => {
|
|
|
199
345
|
grid.changeLayout();
|
|
200
346
|
|
|
201
347
|
expect(changeLayoutCalled).toBe(true);
|
|
202
|
-
expect(instance.layoutEdited).toBe(
|
|
348
|
+
expect(instance.layoutEdited).toBe(false);
|
|
203
349
|
});
|
|
204
350
|
|
|
205
351
|
it('should mark layout as edited when parent grid layout changes', async () => {
|
|
@@ -215,6 +361,7 @@ describe('LayoutOptions', () => {
|
|
|
215
361
|
instance.parent = grid;
|
|
216
362
|
|
|
217
363
|
await instance.onMounted({} as HTMLElement);
|
|
364
|
+
grid.datasource.filter = { id: '10' };
|
|
218
365
|
grid.changeLayout();
|
|
219
366
|
|
|
220
367
|
expect(instance.layoutEdited).toBe(true);
|
|
@@ -269,11 +416,11 @@ describe('LayoutOptions', () => {
|
|
|
269
416
|
isVisible: true,
|
|
270
417
|
fixed: false,
|
|
271
418
|
grouped: false,
|
|
272
|
-
minWidth:
|
|
273
|
-
maxWidth:
|
|
419
|
+
minWidth: '',
|
|
420
|
+
maxWidth: '',
|
|
274
421
|
aggregation: undefined,
|
|
275
422
|
align: 'left',
|
|
276
|
-
groupOpened:
|
|
423
|
+
groupOpened: false,
|
|
277
424
|
label: '',
|
|
278
425
|
filterHelperValue: [],
|
|
279
426
|
},
|
|
@@ -282,11 +429,11 @@ describe('LayoutOptions', () => {
|
|
|
282
429
|
isVisible: true,
|
|
283
430
|
fixed: false,
|
|
284
431
|
grouped: false,
|
|
285
|
-
minWidth:
|
|
286
|
-
maxWidth:
|
|
432
|
+
minWidth: '',
|
|
433
|
+
maxWidth: '',
|
|
287
434
|
aggregation: undefined,
|
|
288
435
|
align: 'left',
|
|
289
|
-
groupOpened:
|
|
436
|
+
groupOpened: false,
|
|
290
437
|
label: '',
|
|
291
438
|
filterHelperValue: [],
|
|
292
439
|
},
|
|
@@ -295,11 +442,11 @@ describe('LayoutOptions', () => {
|
|
|
295
442
|
isVisible: true,
|
|
296
443
|
fixed: false,
|
|
297
444
|
grouped: false,
|
|
298
|
-
minWidth:
|
|
299
|
-
maxWidth:
|
|
445
|
+
minWidth: '',
|
|
446
|
+
maxWidth: '',
|
|
300
447
|
aggregation: undefined,
|
|
301
448
|
align: 'left',
|
|
302
|
-
groupOpened:
|
|
449
|
+
groupOpened: false,
|
|
303
450
|
label: '',
|
|
304
451
|
filterHelperValue: [],
|
|
305
452
|
},
|
|
@@ -308,11 +455,11 @@ describe('LayoutOptions', () => {
|
|
|
308
455
|
isVisible: true,
|
|
309
456
|
fixed: false,
|
|
310
457
|
grouped: false,
|
|
311
|
-
minWidth:
|
|
312
|
-
maxWidth:
|
|
458
|
+
minWidth: '',
|
|
459
|
+
maxWidth: '',
|
|
313
460
|
aggregation: undefined,
|
|
314
461
|
align: 'left',
|
|
315
|
-
groupOpened:
|
|
462
|
+
groupOpened: false,
|
|
316
463
|
label: '',
|
|
317
464
|
filterHelperValue: 'TODAY',
|
|
318
465
|
},
|
|
@@ -321,11 +468,11 @@ describe('LayoutOptions', () => {
|
|
|
321
468
|
isVisible: true,
|
|
322
469
|
fixed: false,
|
|
323
470
|
grouped: false,
|
|
324
|
-
minWidth:
|
|
325
|
-
maxWidth:
|
|
471
|
+
minWidth: '',
|
|
472
|
+
maxWidth: '',
|
|
326
473
|
aggregation: undefined,
|
|
327
474
|
align: 'left',
|
|
328
|
-
groupOpened:
|
|
475
|
+
groupOpened: false,
|
|
329
476
|
label: '',
|
|
330
477
|
filterHelperValue: ['TODAY', 'TOMORROW'],
|
|
331
478
|
},
|
|
@@ -355,37 +502,37 @@ describe('LayoutOptions', () => {
|
|
|
355
502
|
minWidth: '100px',
|
|
356
503
|
aggregation: undefined,
|
|
357
504
|
align: 'left',
|
|
358
|
-
groupOpened:
|
|
505
|
+
groupOpened: false,
|
|
359
506
|
label: '',
|
|
360
507
|
filterHelperValue: '',
|
|
361
508
|
fixed: false,
|
|
362
|
-
grouped:
|
|
509
|
+
grouped: false,
|
|
363
510
|
},
|
|
364
511
|
{
|
|
365
512
|
name: 'name',
|
|
366
513
|
isVisible: true,
|
|
367
|
-
minWidth:
|
|
368
|
-
maxWidth:
|
|
514
|
+
minWidth: '',
|
|
515
|
+
maxWidth: '',
|
|
369
516
|
aggregation: undefined,
|
|
370
517
|
align: 'left',
|
|
371
|
-
groupOpened:
|
|
518
|
+
groupOpened: false,
|
|
372
519
|
label: '',
|
|
373
520
|
filterHelperValue: '',
|
|
374
521
|
fixed: false,
|
|
375
|
-
grouped:
|
|
522
|
+
grouped: false,
|
|
376
523
|
},
|
|
377
524
|
{
|
|
378
525
|
name: 'salary',
|
|
379
526
|
isVisible: true,
|
|
380
|
-
minWidth:
|
|
381
|
-
maxWidth:
|
|
527
|
+
minWidth: '',
|
|
528
|
+
maxWidth: '',
|
|
382
529
|
aggregation: undefined,
|
|
383
530
|
align: 'left',
|
|
384
|
-
groupOpened:
|
|
531
|
+
groupOpened: false,
|
|
385
532
|
label: '',
|
|
386
533
|
filterHelperValue: '',
|
|
387
534
|
fixed: false,
|
|
388
|
-
grouped:
|
|
535
|
+
grouped: false,
|
|
389
536
|
},
|
|
390
537
|
]);
|
|
391
538
|
});
|
|
@@ -769,6 +916,41 @@ describe('LayoutOptions', () => {
|
|
|
769
916
|
expect(instance.currentLayoutName).toBe('Name first');
|
|
770
917
|
expect(instance.layouts['Name last'].gridWidth).toBe('740px');
|
|
771
918
|
});
|
|
919
|
+
|
|
920
|
+
it('should call beforeApplyLayout with default layout', async () => {
|
|
921
|
+
let appliedLayout: ITekGridApplyLayoutEventParams['layout'];
|
|
922
|
+
const tag = new Tag({
|
|
923
|
+
name: 'toolbar',
|
|
924
|
+
component: 'ZdTag',
|
|
925
|
+
tag: 'span',
|
|
926
|
+
});
|
|
927
|
+
const grid = new TekGrid({
|
|
928
|
+
name: 'grid_apply_default_layout',
|
|
929
|
+
component: 'TekGrid',
|
|
930
|
+
columns: [
|
|
931
|
+
{ name: 'id' },
|
|
932
|
+
{ name: 'name' },
|
|
933
|
+
{ name: 'salary' },
|
|
934
|
+
],
|
|
935
|
+
events: {
|
|
936
|
+
beforeApplyLayout: ({ layout }: ITekGridApplyLayoutEventParams) => {
|
|
937
|
+
appliedLayout = layout;
|
|
938
|
+
return true;
|
|
939
|
+
},
|
|
940
|
+
},
|
|
941
|
+
});
|
|
942
|
+
const instance = new TekGridLayoutOptions({ name: 'layout_apply_default', component: 'TekGridLayoutOptions' });
|
|
943
|
+
instance.parent = tag;
|
|
944
|
+
tag.parent = grid;
|
|
945
|
+
|
|
946
|
+
await instance.onMounted({} as HTMLElement);
|
|
947
|
+
|
|
948
|
+
instance.applyLayout('');
|
|
949
|
+
|
|
950
|
+
expect(appliedLayout).toEqual(instance.getLayout(''));
|
|
951
|
+
expect(appliedLayout!.name).toBe('');
|
|
952
|
+
expect(instance.currentLayoutName).toBe('');
|
|
953
|
+
});
|
|
772
954
|
});
|
|
773
955
|
|
|
774
956
|
describe('deleteLayout()', () => {
|
|
@@ -830,6 +1012,209 @@ describe('LayoutOptions', () => {
|
|
|
830
1012
|
});
|
|
831
1013
|
});
|
|
832
1014
|
|
|
1015
|
+
describe('getCurrentLayout()', () => {
|
|
1016
|
+
it('should return layout from view bridge when available', () => {
|
|
1017
|
+
const instance = new TekGridLayoutOptions({
|
|
1018
|
+
name: 'layout_current_from_view',
|
|
1019
|
+
component: 'TekGridLayoutOptions',
|
|
1020
|
+
});
|
|
1021
|
+
const layout = {
|
|
1022
|
+
name: '',
|
|
1023
|
+
gridWidth: 'auto',
|
|
1024
|
+
order: [],
|
|
1025
|
+
filter: {},
|
|
1026
|
+
dynamicFilter: {},
|
|
1027
|
+
columns: [],
|
|
1028
|
+
};
|
|
1029
|
+
instance.viewGetCurrentLayout = jest.fn(() => layout);
|
|
1030
|
+
|
|
1031
|
+
expect(instance.getCurrentLayout()).toBe(layout);
|
|
1032
|
+
expect(instance.viewGetCurrentLayout).toBeCalledWith('');
|
|
1033
|
+
});
|
|
1034
|
+
|
|
1035
|
+
it('should return current grid layout', async () => {
|
|
1036
|
+
const tag = new Tag({
|
|
1037
|
+
name: 'toolbar',
|
|
1038
|
+
component: 'ZdTag',
|
|
1039
|
+
tag: 'span',
|
|
1040
|
+
});
|
|
1041
|
+
const grid = new TekGrid({
|
|
1042
|
+
name: 'grid_current_layout',
|
|
1043
|
+
component: 'TekGrid',
|
|
1044
|
+
columns: [
|
|
1045
|
+
{ name: 'id' },
|
|
1046
|
+
{ name: 'name' },
|
|
1047
|
+
{ name: 'salary' },
|
|
1048
|
+
],
|
|
1049
|
+
});
|
|
1050
|
+
const instance = new TekGridLayoutOptions({ name: 'layout_current', component: 'TekGridLayoutOptions' });
|
|
1051
|
+
instance.parent = tag;
|
|
1052
|
+
tag.parent = grid;
|
|
1053
|
+
|
|
1054
|
+
await instance.onMounted({} as HTMLElement);
|
|
1055
|
+
|
|
1056
|
+
grid.datasource.order = ['name.asc'];
|
|
1057
|
+
grid.datasource.filter = { name: 'a' };
|
|
1058
|
+
(grid.datasource as any).dynamicFilter = {
|
|
1059
|
+
name: [
|
|
1060
|
+
{
|
|
1061
|
+
operation: 'CONTAINS',
|
|
1062
|
+
relation: 'AND',
|
|
1063
|
+
value: 'a',
|
|
1064
|
+
},
|
|
1065
|
+
],
|
|
1066
|
+
};
|
|
1067
|
+
grid.columns[1].isVisible = false;
|
|
1068
|
+
grid.columns[1].width = '120px';
|
|
1069
|
+
|
|
1070
|
+
expect(instance.getCurrentLayout()).toEqual({
|
|
1071
|
+
name: '',
|
|
1072
|
+
gridWidth: 'auto',
|
|
1073
|
+
order: ['name.asc'],
|
|
1074
|
+
filter: { name: 'a' },
|
|
1075
|
+
dynamicFilter: {
|
|
1076
|
+
name: [
|
|
1077
|
+
{
|
|
1078
|
+
operation: 'CONTAINS',
|
|
1079
|
+
relation: 'AND',
|
|
1080
|
+
value: 'a',
|
|
1081
|
+
},
|
|
1082
|
+
],
|
|
1083
|
+
},
|
|
1084
|
+
columns: [
|
|
1085
|
+
{
|
|
1086
|
+
name: 'id',
|
|
1087
|
+
label: '',
|
|
1088
|
+
align: 'left',
|
|
1089
|
+
isVisible: true,
|
|
1090
|
+
minWidth: '',
|
|
1091
|
+
maxWidth: '',
|
|
1092
|
+
width: undefined,
|
|
1093
|
+
fixed: false,
|
|
1094
|
+
grouped: false,
|
|
1095
|
+
groupOpened: false,
|
|
1096
|
+
aggregation: undefined,
|
|
1097
|
+
filterHelperValue: [],
|
|
1098
|
+
},
|
|
1099
|
+
{
|
|
1100
|
+
name: 'name',
|
|
1101
|
+
label: '',
|
|
1102
|
+
align: 'left',
|
|
1103
|
+
isVisible: false,
|
|
1104
|
+
minWidth: '',
|
|
1105
|
+
maxWidth: '',
|
|
1106
|
+
width: '120px',
|
|
1107
|
+
fixed: false,
|
|
1108
|
+
grouped: false,
|
|
1109
|
+
groupOpened: false,
|
|
1110
|
+
aggregation: undefined,
|
|
1111
|
+
filterHelperValue: [],
|
|
1112
|
+
},
|
|
1113
|
+
{
|
|
1114
|
+
name: 'salary',
|
|
1115
|
+
label: '',
|
|
1116
|
+
align: 'left',
|
|
1117
|
+
isVisible: true,
|
|
1118
|
+
minWidth: '',
|
|
1119
|
+
maxWidth: '',
|
|
1120
|
+
width: undefined,
|
|
1121
|
+
fixed: false,
|
|
1122
|
+
grouped: false,
|
|
1123
|
+
groupOpened: false,
|
|
1124
|
+
aggregation: undefined,
|
|
1125
|
+
filterHelperValue: [],
|
|
1126
|
+
},
|
|
1127
|
+
],
|
|
1128
|
+
});
|
|
1129
|
+
});
|
|
1130
|
+
});
|
|
1131
|
+
|
|
1132
|
+
describe('getLayout()', () => {
|
|
1133
|
+
it('should return undefined when named layout does not exist', () => {
|
|
1134
|
+
const instance = new TekGridLayoutOptions({
|
|
1135
|
+
name: 'layout_get_missing',
|
|
1136
|
+
component: 'TekGridLayoutOptions',
|
|
1137
|
+
});
|
|
1138
|
+
|
|
1139
|
+
expect(instance.getLayout('Missing layout')).toBeUndefined();
|
|
1140
|
+
});
|
|
1141
|
+
|
|
1142
|
+
it('should return current layout when called without parameters', () => {
|
|
1143
|
+
const instance = new TekGridLayoutOptions({
|
|
1144
|
+
name: 'layout_get_without_parameters',
|
|
1145
|
+
component: 'TekGridLayoutOptions',
|
|
1146
|
+
});
|
|
1147
|
+
instance.layouts = testLayouts.layouts!;
|
|
1148
|
+
instance.currentLayoutName = 'Name first';
|
|
1149
|
+
|
|
1150
|
+
const layout = instance.getLayout();
|
|
1151
|
+
|
|
1152
|
+
expect(layout).toEqual(testLayouts.layouts!['Name first']);
|
|
1153
|
+
|
|
1154
|
+
layout!.gridWidth = '999px';
|
|
1155
|
+
expect(instance.layouts['Name first'].gridWidth).toBe('544px');
|
|
1156
|
+
});
|
|
1157
|
+
|
|
1158
|
+
it('should return a named layout clone', async () => {
|
|
1159
|
+
const tag = new Tag({
|
|
1160
|
+
name: 'toolbar',
|
|
1161
|
+
component: 'ZdTag',
|
|
1162
|
+
tag: 'span',
|
|
1163
|
+
});
|
|
1164
|
+
const grid = new TekGrid({
|
|
1165
|
+
name: 'grid_get_layout',
|
|
1166
|
+
component: 'TekGrid',
|
|
1167
|
+
columns: [
|
|
1168
|
+
{ name: 'id' },
|
|
1169
|
+
{ name: 'name' },
|
|
1170
|
+
{ name: 'salary' },
|
|
1171
|
+
],
|
|
1172
|
+
});
|
|
1173
|
+
const instance = new TekGridLayoutOptions({ name: 'layout_get', component: 'TekGridLayoutOptions' });
|
|
1174
|
+
instance.parent = tag;
|
|
1175
|
+
tag.parent = grid;
|
|
1176
|
+
|
|
1177
|
+
await instance.onMounted({} as HTMLElement);
|
|
1178
|
+
|
|
1179
|
+
const layout = instance.getLayout('Name first');
|
|
1180
|
+
expect(layout).toEqual(instance.layouts['Name first']);
|
|
1181
|
+
|
|
1182
|
+
layout!.gridWidth = '999px';
|
|
1183
|
+
expect(instance.layouts['Name first'].gridWidth).toBe('544px');
|
|
1184
|
+
});
|
|
1185
|
+
|
|
1186
|
+
it('should return default layout when name is empty', async () => {
|
|
1187
|
+
const tag = new Tag({
|
|
1188
|
+
name: 'toolbar',
|
|
1189
|
+
component: 'ZdTag',
|
|
1190
|
+
tag: 'span',
|
|
1191
|
+
});
|
|
1192
|
+
const grid = new TekGrid({
|
|
1193
|
+
name: 'grid_get_default_layout',
|
|
1194
|
+
component: 'TekGrid',
|
|
1195
|
+
columns: [
|
|
1196
|
+
{ name: 'id' },
|
|
1197
|
+
{ name: 'name' },
|
|
1198
|
+
{ name: 'salary' },
|
|
1199
|
+
],
|
|
1200
|
+
});
|
|
1201
|
+
const instance = new TekGridLayoutOptions({ name: 'layout_get_default', component: 'TekGridLayoutOptions' });
|
|
1202
|
+
instance.parent = tag;
|
|
1203
|
+
tag.parent = grid;
|
|
1204
|
+
|
|
1205
|
+
await instance.onMounted({} as HTMLElement);
|
|
1206
|
+
|
|
1207
|
+
expect(instance.getLayout('')).toEqual({
|
|
1208
|
+
name: '',
|
|
1209
|
+
gridWidth: 'auto',
|
|
1210
|
+
order: [],
|
|
1211
|
+
filter: {},
|
|
1212
|
+
dynamicFilter: {},
|
|
1213
|
+
columns: instance.originalColumnProps,
|
|
1214
|
+
});
|
|
1215
|
+
});
|
|
1216
|
+
});
|
|
1217
|
+
|
|
833
1218
|
describe('updateLayout()', () => {
|
|
834
1219
|
it('should update layout and save', async () => {
|
|
835
1220
|
const tag = new Tag({
|
|
@@ -891,6 +1276,110 @@ describe('LayoutOptions', () => {
|
|
|
891
1276
|
},
|
|
892
1277
|
});
|
|
893
1278
|
});
|
|
1279
|
+
|
|
1280
|
+
it('should update named layout using current grid configuration', async () => {
|
|
1281
|
+
let eventSavedLayouts: ITekGridLayoutInfo = {};
|
|
1282
|
+
const tag = new Tag({
|
|
1283
|
+
name: 'toolbar',
|
|
1284
|
+
component: 'ZdTag',
|
|
1285
|
+
tag: 'span',
|
|
1286
|
+
});
|
|
1287
|
+
const grid = new TekGrid({
|
|
1288
|
+
name: 'grid_update_current_layout',
|
|
1289
|
+
component: 'TekGrid',
|
|
1290
|
+
columns: [
|
|
1291
|
+
{ name: 'id' },
|
|
1292
|
+
{ name: 'name' },
|
|
1293
|
+
{ name: 'salary' },
|
|
1294
|
+
],
|
|
1295
|
+
events: {
|
|
1296
|
+
saveLayouts: ({ layouts }) => { eventSavedLayouts = layouts; },
|
|
1297
|
+
},
|
|
1298
|
+
});
|
|
1299
|
+
const instance = new TekGridLayoutOptions({ name: 'layout_update_current', component: 'TekGridLayoutOptions' });
|
|
1300
|
+
instance.parent = tag;
|
|
1301
|
+
tag.parent = grid;
|
|
1302
|
+
|
|
1303
|
+
await instance.onMounted({} as HTMLElement);
|
|
1304
|
+
|
|
1305
|
+
grid.datasource.order = ['salary.desc'];
|
|
1306
|
+
grid.datasource.filter = { salary: 100 };
|
|
1307
|
+
grid.columns[2].width = '160px';
|
|
1308
|
+
|
|
1309
|
+
instance.updateLayout('Custom layout');
|
|
1310
|
+
|
|
1311
|
+
expect(instance.currentLayoutName).toBe('Custom layout');
|
|
1312
|
+
expect(instance.layouts['Custom layout'].name).toBe('Custom layout');
|
|
1313
|
+
expect(instance.layouts['Custom layout'].gridWidth).toBe('auto');
|
|
1314
|
+
expect(instance.layouts['Custom layout'].order).toEqual(['salary.desc']);
|
|
1315
|
+
expect(instance.layouts['Custom layout'].filter).toEqual({ salary: 100 });
|
|
1316
|
+
expect(instance.layouts['Custom layout'].columns![2].width).toBe('160px');
|
|
1317
|
+
expect(eventSavedLayouts.currentLayoutName).toBe('Custom layout');
|
|
1318
|
+
expect(eventSavedLayouts.layouts!['Custom layout'].filter).toEqual({ salary: 100 });
|
|
1319
|
+
});
|
|
1320
|
+
|
|
1321
|
+
it('should update current selected layout when name is unset', async () => {
|
|
1322
|
+
const tag = new Tag({
|
|
1323
|
+
name: 'toolbar',
|
|
1324
|
+
component: 'ZdTag',
|
|
1325
|
+
tag: 'span',
|
|
1326
|
+
});
|
|
1327
|
+
const grid = new TekGrid({
|
|
1328
|
+
name: 'grid_update_selected_layout',
|
|
1329
|
+
component: 'TekGrid',
|
|
1330
|
+
columns: [
|
|
1331
|
+
{ name: 'id' },
|
|
1332
|
+
{ name: 'name' },
|
|
1333
|
+
{ name: 'salary' },
|
|
1334
|
+
],
|
|
1335
|
+
});
|
|
1336
|
+
const instance = new TekGridLayoutOptions({ name: 'layout_update_selected', component: 'TekGridLayoutOptions' });
|
|
1337
|
+
instance.parent = tag;
|
|
1338
|
+
tag.parent = grid;
|
|
1339
|
+
|
|
1340
|
+
await instance.onMounted({} as HTMLElement);
|
|
1341
|
+
|
|
1342
|
+
instance.currentLayoutName = 'Name first';
|
|
1343
|
+
grid.datasource.filter = { name: 'selected' };
|
|
1344
|
+
|
|
1345
|
+
instance.updateLayout();
|
|
1346
|
+
|
|
1347
|
+
expect(instance.currentLayoutName).toBe('Name first');
|
|
1348
|
+
expect(instance.layouts['Name first'].filter).toEqual({ name: 'selected' });
|
|
1349
|
+
});
|
|
1350
|
+
|
|
1351
|
+
it('should update default layout when name is empty', async () => {
|
|
1352
|
+
const tag = new Tag({
|
|
1353
|
+
name: 'toolbar',
|
|
1354
|
+
component: 'ZdTag',
|
|
1355
|
+
tag: 'span',
|
|
1356
|
+
});
|
|
1357
|
+
const grid = new TekGrid({
|
|
1358
|
+
name: 'grid_update_default_layout',
|
|
1359
|
+
component: 'TekGrid',
|
|
1360
|
+
columns: [
|
|
1361
|
+
{ name: 'id' },
|
|
1362
|
+
{ name: 'name' },
|
|
1363
|
+
{ name: 'salary' },
|
|
1364
|
+
],
|
|
1365
|
+
});
|
|
1366
|
+
const instance = new TekGridLayoutOptions({ name: 'layout_update_default', component: 'TekGridLayoutOptions' });
|
|
1367
|
+
instance.parent = tag;
|
|
1368
|
+
tag.parent = grid;
|
|
1369
|
+
|
|
1370
|
+
await instance.onMounted({} as HTMLElement);
|
|
1371
|
+
|
|
1372
|
+
grid.datasource.order = ['id.desc'];
|
|
1373
|
+
grid.datasource.filter = { id: 1 };
|
|
1374
|
+
instance.layoutEdited = true;
|
|
1375
|
+
|
|
1376
|
+
instance.updateLayout('');
|
|
1377
|
+
|
|
1378
|
+
expect(instance.layouts['']).toBeUndefined();
|
|
1379
|
+
expect(instance.originalDatasourceOrder).toEqual(['id.desc']);
|
|
1380
|
+
expect(instance.originalDatasourceFilter).toEqual({ id: 1 });
|
|
1381
|
+
expect(instance.layoutEdited).toBeFalsy();
|
|
1382
|
+
});
|
|
894
1383
|
});
|
|
895
1384
|
|
|
896
1385
|
describe('discardChanges()', () => {
|