@zeedhi/teknisa-components-common 1.97.4 → 1.97.6

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.
Files changed (92) hide show
  1. package/coverage/clover.xml +820 -688
  2. package/coverage/coverage-final.json +47 -45
  3. package/coverage/lcov-report/index.html +23 -23
  4. package/coverage/lcov-report/tests/__helpers__/component-event-helper.ts.html +2 -2
  5. package/coverage/lcov-report/tests/__helpers__/flush-promises-helper.ts.html +2 -2
  6. package/coverage/lcov-report/tests/__helpers__/get-child-helper.ts.html +9 -9
  7. package/coverage/lcov-report/tests/__helpers__/index.html +1 -1
  8. package/coverage/lcov-report/tests/__helpers__/index.ts.html +1 -1
  9. package/coverage/lcov-report/tests/__helpers__/mock-created-helper.ts.html +1 -1
  10. package/coverage/lcov.info +1411 -1175
  11. package/dist/tek-components-common.esm.js +192 -10
  12. package/dist/tek-components-common.umd.js +192 -10
  13. package/package.json +2 -2
  14. package/tests/unit/components/tek-grid/grid.spec.ts +404 -2
  15. package/types/components/tek-ag-grid/default-icons.d.ts +53 -0
  16. package/types/components/tek-ag-grid/interfaces.d.ts +9 -0
  17. package/types/components/tek-ag-grid/tek-ag-grid.d.ts +35 -0
  18. package/types/components/tek-datasource/datasource.d.ts +94 -0
  19. package/types/components/tek-grid/default-icons.d.ts +53 -0
  20. package/types/components/tek-grid/filter-dynamic-values.d.ts +9 -0
  21. package/types/components/tek-grid/grid-controller.d.ts +19 -0
  22. package/types/components/tek-grid/grid.d.ts +45 -2
  23. package/types/components/tek-grid/grid_column.d.ts +14 -0
  24. package/types/components/tek-grid/grid_controller.d.ts +15 -0
  25. package/types/components/tek-grid/interfaces.d.ts +19 -0
  26. package/types/components/tek-grid/tek-grid.d.ts +35 -0
  27. package/types/components/tek-login/interfaces.d.ts +3 -0
  28. package/types/components/tek-login/login-children.d.ts +3 -0
  29. package/types/components/tek-login/login.d.ts +58 -0
  30. package/types/components/tek-login/login_children.d.ts +3 -0
  31. package/types/error/incomplete-groups-error.d.ts +8 -0
  32. package/types/utils/extract-properties.d.ts +7 -0
  33. package/types/utils/index.d.ts +1 -0
  34. package/coverage/lcov-report/components/crud/crud-add-button.ts.html +0 -250
  35. package/coverage/lcov-report/components/crud/crud-button.ts.html +0 -292
  36. package/coverage/lcov-report/components/crud/crud-cancel-button.ts.html +0 -259
  37. package/coverage/lcov-report/components/crud/crud-delete-button.ts.html +0 -322
  38. package/coverage/lcov-report/components/crud/crud-form.ts.html +0 -382
  39. package/coverage/lcov-report/components/crud/crud-save-button.ts.html +0 -253
  40. package/coverage/lcov-report/components/crud/index.html +0 -191
  41. package/coverage/lcov-report/components/index.html +0 -116
  42. package/coverage/lcov-report/components/index.ts.html +0 -394
  43. package/coverage/lcov-report/components/tek-breadcrumb-header/breadcrumb-header.ts.html +0 -172
  44. package/coverage/lcov-report/components/tek-breadcrumb-header/index.html +0 -116
  45. package/coverage/lcov-report/components/tek-card-title/card-title.ts.html +0 -175
  46. package/coverage/lcov-report/components/tek-card-title/index.html +0 -116
  47. package/coverage/lcov-report/components/tek-datasource/index.html +0 -146
  48. package/coverage/lcov-report/components/tek-datasource/interfaces.ts.html +0 -193
  49. package/coverage/lcov-report/components/tek-datasource/memory-datasource.ts.html +0 -1015
  50. package/coverage/lcov-report/components/tek-datasource/rest-datasource.ts.html +0 -751
  51. package/coverage/lcov-report/components/tek-drag-grid/index.html +0 -116
  52. package/coverage/lcov-report/components/tek-drag-grid/tek-drag-grid.ts.html +0 -409
  53. package/coverage/lcov-report/components/tek-grid/filter-helper.ts.html +0 -145
  54. package/coverage/lcov-report/components/tek-grid/grid-column.ts.html +0 -775
  55. package/coverage/lcov-report/components/tek-grid/grid-columns-button-controller.ts.html +0 -169
  56. package/coverage/lcov-report/components/tek-grid/grid-columns-button.ts.html +0 -190
  57. package/coverage/lcov-report/components/tek-grid/grid-filter-button.ts.html +0 -1282
  58. package/coverage/lcov-report/components/tek-grid/grid.ts.html +0 -3157
  59. package/coverage/lcov-report/components/tek-grid/index.html +0 -221
  60. package/coverage/lcov-report/components/tek-grid/interfaces.ts.html +0 -733
  61. package/coverage/lcov-report/components/tek-grid/layout-options.ts.html +0 -826
  62. package/coverage/lcov-report/components/tek-image/image.ts.html +0 -313
  63. package/coverage/lcov-report/components/tek-image/index.html +0 -116
  64. package/coverage/lcov-report/components/tek-iterable-carousel/index.html +0 -116
  65. package/coverage/lcov-report/components/tek-iterable-carousel/iterable-carousel.ts.html +0 -175
  66. package/coverage/lcov-report/components/tek-iterable-component-render/index.html +0 -116
  67. package/coverage/lcov-report/components/tek-iterable-component-render/iterable-component-render.ts.html +0 -118
  68. package/coverage/lcov-report/components/tek-loading/index.html +0 -116
  69. package/coverage/lcov-report/components/tek-loading/loading.ts.html +0 -196
  70. package/coverage/lcov-report/components/tek-notifications/index.html +0 -116
  71. package/coverage/lcov-report/components/tek-notifications/notifications.ts.html +0 -271
  72. package/coverage/lcov-report/components/tek-product-card/index.html +0 -116
  73. package/coverage/lcov-report/components/tek-product-card/product-card.ts.html +0 -391
  74. package/coverage/lcov-report/components/tek-tree-grid/index.html +0 -116
  75. package/coverage/lcov-report/components/tek-tree-grid/tree-grid.ts.html +0 -1255
  76. package/coverage/lcov-report/components/tek-user-info/TekUserInfoController.ts.html +0 -367
  77. package/coverage/lcov-report/components/tek-user-info/index.html +0 -146
  78. package/coverage/lcov-report/components/tek-user-info/tek-user-info-list.ts.html +0 -268
  79. package/coverage/lcov-report/components/tek-user-info/tek-user-info.ts.html +0 -1096
  80. package/coverage/lcov-report/error/delete-rows-error.ts.html +0 -118
  81. package/coverage/lcov-report/error/index.html +0 -116
  82. package/coverage/lcov-report/utils/grid-base/export-options/button-option.ts.html +0 -166
  83. package/coverage/lcov-report/utils/grid-base/export-options/index.html +0 -146
  84. package/coverage/lcov-report/utils/grid-base/export-options/index.ts.html +0 -94
  85. package/coverage/lcov-report/utils/grid-base/export-options/multi-option.ts.html +0 -355
  86. package/coverage/lcov-report/utils/grid-base/grid-base.ts.html +0 -1960
  87. package/coverage/lcov-report/utils/grid-base/grid-controller.ts.html +0 -457
  88. package/coverage/lcov-report/utils/grid-base/index.html +0 -131
  89. package/coverage/lcov-report/utils/index.html +0 -116
  90. package/coverage/lcov-report/utils/index.ts.html +0 -100
  91. package/coverage/lcov-report/utils/report-filter/index.html +0 -116
  92. package/coverage/lcov-report/utils/report-filter/report-filter.ts.html +0 -256
@@ -42,6 +42,43 @@ const createAndMount = (props: ITekGrid) => {
42
42
  return instance;
43
43
  };
44
44
 
45
+ const createGroupedGrid = async (props: Partial<ITekGrid> = {}) => {
46
+ const grid = createAndMount({
47
+ name: 'grid',
48
+ component: 'TekGrid',
49
+ columns: [
50
+ { name: 'id' },
51
+ { name: 'name' },
52
+ { name: 'month' },
53
+ { name: 'department', grouped: true },
54
+ ],
55
+ datasource: {
56
+ uniqueKey: 'id',
57
+ data: [
58
+ {
59
+ id: '1', name: 'First', month: 11, department: 1,
60
+ },
61
+ {
62
+ id: '2', name: 'Second', month: 11, department: 1,
63
+ },
64
+ {
65
+ id: '3', name: 'Third', month: 11, department: 2,
66
+ },
67
+ {
68
+ id: '4', name: 'Fourth', month: 12, department: 1,
69
+ },
70
+ {
71
+ id: '5', name: 'Fifth', month: 12, department: 2,
72
+ },
73
+ ],
74
+ },
75
+ ...props,
76
+ });
77
+
78
+ await flushPromises();
79
+ return grid;
80
+ };
81
+
45
82
  describe('TekGrid', () => {
46
83
  beforeEach(() => {
47
84
  // clear all metadata instances before testing
@@ -2030,7 +2067,6 @@ describe('TekGrid', () => {
2030
2067
  grid.rowClick(data[0], event, element);
2031
2068
 
2032
2069
  expect(rowClick).not.toHaveBeenCalled();
2033
- expect(grid.datasource.currentRow).toEqual({});
2034
2070
  });
2035
2071
  });
2036
2072
 
@@ -2071,7 +2107,6 @@ describe('TekGrid', () => {
2071
2107
  row: grid.groupedData[0],
2072
2108
  component: grid,
2073
2109
  });
2074
- expect(grid.datasource.currentRow).toEqual({});
2075
2110
  });
2076
2111
 
2077
2112
  it('should not call events.groupRowClick if cellClick prevents it', async () => {
@@ -2322,4 +2357,371 @@ describe('TekGrid', () => {
2322
2357
  expect(spy).toHaveBeenCalledTimes(1);
2323
2358
  });
2324
2359
  });
2360
+
2361
+ describe('addNewRow', () => {
2362
+ it('when not using groups, should add a new row to the datasource', async () => {
2363
+ const instance = new TekGrid({
2364
+ name: 'Grid',
2365
+ component: 'TekGrid',
2366
+ datasource: {
2367
+ page: 1,
2368
+ data: [
2369
+ { id: 1 },
2370
+ ],
2371
+ },
2372
+ });
2373
+ const newRow1 = { id: 2 };
2374
+ await instance.addNewRow(newRow1, 'start');
2375
+ expect(instance.datasource.data[0]).toEqual({ id: 2, __added_row: true });
2376
+ expect(instance.datasource.data[1]).toEqual({ id: 1 });
2377
+ });
2378
+
2379
+ it('should add a new row to the groupedData array', async () => {
2380
+ const grid = await createGroupedGrid();
2381
+
2382
+ expect(grid.groupedData).toMatchObject([
2383
+ { groupValue: 1 },
2384
+ { id: '1', groupHeaders: [{ groupValue: 1 }] },
2385
+ { id: '2', groupHeaders: [{ groupValue: 1 }] },
2386
+ { id: '4', groupHeaders: [{ groupValue: 1 }] },
2387
+ { groupValue: 2 },
2388
+ { id: '3', groupHeaders: [{ groupValue: 2 }] },
2389
+ { id: '5', groupHeaders: [{ groupValue: 2 }] },
2390
+ ]);
2391
+ expect(grid.groupedData[0].children).toMatchObject([
2392
+ { id: '1' },
2393
+ { id: '2' },
2394
+ { id: '4' },
2395
+ ]);
2396
+
2397
+ await grid.addNewRow({ id: '999', name: 'new', department: 1 });
2398
+
2399
+ expect(grid.groupedData).toMatchObject([
2400
+ { groupValue: 1 },
2401
+ { id: '1', groupHeaders: [{ groupValue: 1 }] },
2402
+ { id: '2', groupHeaders: [{ groupValue: 1 }] },
2403
+ { id: '4', groupHeaders: [{ groupValue: 1 }] },
2404
+ { id: '999', groupHeaders: [{ groupValue: 1 }] },
2405
+ { groupValue: 2 },
2406
+ { id: '3', groupHeaders: [{ groupValue: 2 }] },
2407
+ { id: '5', groupHeaders: [{ groupValue: 2 }] },
2408
+ ]);
2409
+ expect(grid.groupedData[0].children).toMatchObject([
2410
+ { id: '1' },
2411
+ { id: '2' },
2412
+ { id: '4' },
2413
+ { id: '999' },
2414
+ ]);
2415
+ });
2416
+
2417
+ it('should add a new row to the groupedData array using nested groups', async () => {
2418
+ const grid = await createGroupedGrid({
2419
+ columns: [
2420
+ { name: 'id' },
2421
+ { name: 'name' },
2422
+ { name: 'month', grouped: true },
2423
+ { name: 'department', grouped: true },
2424
+ ],
2425
+ });
2426
+
2427
+ expect(grid.groupedData).toMatchObject([
2428
+ { groupValue: 11 },
2429
+ { groupValue: 1, groupHeaders: [{ groupValue: 11 }] },
2430
+ { id: '1', groupHeaders: [{ groupValue: 11 }, { groupValue: 1 }] },
2431
+ { id: '2', groupHeaders: [{ groupValue: 11 }, { groupValue: 1 }] },
2432
+ { groupValue: 2, groupHeaders: [{ groupValue: 11 }] },
2433
+ { id: '3', groupHeaders: [{ groupValue: 11 }, { groupValue: 2 }] },
2434
+ { groupValue: 12 },
2435
+ { groupValue: 1, groupHeaders: [{ groupValue: 12 }] },
2436
+ { id: '4', groupHeaders: [{ groupValue: 12 }, { groupValue: 1 }] },
2437
+ { groupValue: 2, groupHeaders: [{ groupValue: 12 }] },
2438
+ { id: '5', groupHeaders: [{ groupValue: 12 }, { groupValue: 2 }] },
2439
+ ]);
2440
+
2441
+ await grid.addNewRow({
2442
+ id: '999', name: 'new', month: 12, department: 1,
2443
+ }, 'start');
2444
+
2445
+ expect(grid.groupedData).toMatchObject([
2446
+ { groupValue: 11 },
2447
+ { groupValue: 1, groupHeaders: [{ groupValue: 11 }] },
2448
+ { id: '1', groupHeaders: [{ groupValue: 11 }, { groupValue: 1 }] },
2449
+ { id: '2', groupHeaders: [{ groupValue: 11 }, { groupValue: 1 }] },
2450
+ { groupValue: 2, groupHeaders: [{ groupValue: 11 }] },
2451
+ { id: '3', groupHeaders: [{ groupValue: 11 }, { groupValue: 2 }] },
2452
+ { groupValue: 12 },
2453
+ { groupValue: 1, groupHeaders: [{ groupValue: 12 }] },
2454
+ { id: '999', groupHeaders: [{ groupValue: 12 }, { groupValue: 1 }] },
2455
+ { id: '4', groupHeaders: [{ groupValue: 12 }, { groupValue: 1 }] },
2456
+ { groupValue: 2, groupHeaders: [{ groupValue: 12 }] },
2457
+ { id: '5', groupHeaders: [{ groupValue: 12 }, { groupValue: 2 }] },
2458
+ ]);
2459
+
2460
+ expect(grid.groupedData[6].children).toMatchObject([
2461
+ { id: '999' },
2462
+ { id: '4' },
2463
+ { id: '5' },
2464
+ ]);
2465
+ expect(grid.groupedData[7].children).toMatchObject([
2466
+ { id: '999' },
2467
+ { id: '4' },
2468
+ ]);
2469
+ });
2470
+
2471
+ it('should add a new row to a group that doesnt exist', async () => {
2472
+ const grid = await createGroupedGrid();
2473
+
2474
+ await grid.addNewRow({ id: '999', name: 'new', department: 999 }, 'end');
2475
+
2476
+ expect(grid.groupedData).toMatchObject([
2477
+ { groupValue: 1 },
2478
+ { id: '1', groupHeaders: [{ groupValue: 1 }] },
2479
+ { id: '2', groupHeaders: [{ groupValue: 1 }] },
2480
+ { id: '4', groupHeaders: [{ groupValue: 1 }] },
2481
+ { groupValue: 2 },
2482
+ { id: '3', groupHeaders: [{ groupValue: 2 }] },
2483
+ { id: '5', groupHeaders: [{ groupValue: 2 }] },
2484
+ { groupValue: 999 },
2485
+ { id: '999', groupHeaders: [{ groupValue: 999 }] },
2486
+ ]);
2487
+ });
2488
+
2489
+ it('should add a new row to a group that doesnt exist using nested groups', async () => {
2490
+ const grid = await createGroupedGrid({
2491
+ columns: [
2492
+ { name: 'id' },
2493
+ { name: 'name' },
2494
+ { name: 'month', grouped: true },
2495
+ { name: 'department', grouped: true },
2496
+ ],
2497
+ });
2498
+
2499
+ await grid.addNewRow({
2500
+ id: '999', name: 'new', month: 999, department: 1,
2501
+ }, 'end');
2502
+
2503
+ expect(grid.groupedData).toMatchObject([
2504
+ { groupValue: 11 },
2505
+ { groupValue: 1, groupHeaders: [{ groupValue: 11 }] },
2506
+ { id: '1', groupHeaders: [{ groupValue: 11 }, { groupValue: 1 }] },
2507
+ { id: '2', groupHeaders: [{ groupValue: 11 }, { groupValue: 1 }] },
2508
+ { groupValue: 2, groupHeaders: [{ groupValue: 11 }] },
2509
+ { id: '3', groupHeaders: [{ groupValue: 11 }, { groupValue: 2 }] },
2510
+ { groupValue: 12 },
2511
+ { groupValue: 1, groupHeaders: [{ groupValue: 12 }] },
2512
+ { id: '4', groupHeaders: [{ groupValue: 12 }, { groupValue: 1 }] },
2513
+ { groupValue: 2, groupHeaders: [{ groupValue: 12 }] },
2514
+ { id: '5', groupHeaders: [{ groupValue: 12 }, { groupValue: 2 }] },
2515
+ // new group
2516
+ { groupValue: 999 },
2517
+ { groupValue: 1, groupHeaders: [{ groupValue: 999 }] },
2518
+ { id: '999', groupHeaders: [{ groupValue: 999 }, { groupValue: 1 }] },
2519
+ ]);
2520
+ });
2521
+
2522
+ it('should add a new row to a group that doesnt inside a group that exists', async () => {
2523
+ const grid = await createGroupedGrid({
2524
+ columns: [
2525
+ { name: 'id' },
2526
+ { name: 'name' },
2527
+ { name: 'month', grouped: true },
2528
+ { name: 'department', grouped: true },
2529
+ ],
2530
+ });
2531
+
2532
+ await grid.addNewRow({
2533
+ id: '999', name: 'new', month: 11, department: 999,
2534
+ }, 'end');
2535
+
2536
+ expect(grid.groupedData).toMatchObject([
2537
+ { groupValue: 11 },
2538
+ { groupValue: 999, groupHeaders: [{ groupValue: 11 }] },
2539
+ { id: '999', groupHeaders: [{ groupValue: 11 }, { groupValue: 999 }] },
2540
+ { groupValue: 1, groupHeaders: [{ groupValue: 11 }] },
2541
+ { id: '1', groupHeaders: [{ groupValue: 11 }, { groupValue: 1 }] },
2542
+ { id: '2', groupHeaders: [{ groupValue: 11 }, { groupValue: 1 }] },
2543
+ { groupValue: 2, groupHeaders: [{ groupValue: 11 }] },
2544
+ { id: '3', groupHeaders: [{ groupValue: 11 }, { groupValue: 2 }] },
2545
+ { groupValue: 12 },
2546
+ { groupValue: 1, groupHeaders: [{ groupValue: 12 }] },
2547
+ { id: '4', groupHeaders: [{ groupValue: 12 }, { groupValue: 1 }] },
2548
+ { groupValue: 2, groupHeaders: [{ groupValue: 12 }] },
2549
+ { id: '5', groupHeaders: [{ groupValue: 12 }, { groupValue: 2 }] },
2550
+ ]);
2551
+ });
2552
+
2553
+ it('should add a new row inside nested groups that doesnt exist', async () => {
2554
+ const grid = await createGroupedGrid({
2555
+ columns: [
2556
+ { name: 'id' },
2557
+ { name: 'name' },
2558
+ { name: 'year', grouped: true },
2559
+ { name: 'month', grouped: true },
2560
+ { name: 'department', grouped: true },
2561
+ ],
2562
+ datasource: {
2563
+ uniqueKey: 'id',
2564
+ data: [
2565
+ {
2566
+ id: '1', name: 'First', year: 2000, month: 11, department: 1,
2567
+ },
2568
+ {
2569
+ id: '2', name: 'Second', year: 2000, month: 11, department: 1,
2570
+ },
2571
+ {
2572
+ id: '3', name: 'Third', year: 2000, month: 11, department: 2,
2573
+ },
2574
+ {
2575
+ id: '4', name: 'Fourth', year: 2010, month: 11, department: 1,
2576
+ },
2577
+ {
2578
+ id: '5', name: 'Fifth', year: 2010, month: 12, department: 2,
2579
+ },
2580
+ ],
2581
+ },
2582
+ });
2583
+
2584
+ await grid.addNewRow({
2585
+ id: '999', name: 'new', year: 2010, month: 999, department: 999,
2586
+ }, 'end');
2587
+ await grid.addNewRow({
2588
+ id: '998', name: 'new', year: 2010, month: 999, department: 999,
2589
+ }, 'end');
2590
+
2591
+ expect(grid.groupedData).toMatchObject([
2592
+ { groupValue: 2000 },
2593
+ { groupValue: 11, groupHeaders: [{ groupValue: 2000 }] },
2594
+ { groupValue: 1, groupHeaders: [{ groupValue: 2000 }, { groupValue: 11 }] },
2595
+ { id: '1', groupHeaders: [{ groupValue: 2000 }, { groupValue: 11 }, { groupValue: 1 }] },
2596
+ { id: '2', groupHeaders: [{ groupValue: 2000 }, { groupValue: 11 }, { groupValue: 1 }] },
2597
+ { groupValue: 2, groupHeaders: [{ groupValue: 2000 }, { groupValue: 11 }] },
2598
+ { id: '3', groupHeaders: [{ groupValue: 2000 }, { groupValue: 11 }, { groupValue: 2 }] },
2599
+ { groupValue: 2010 },
2600
+ { groupValue: 999, groupHeaders: [{ groupValue: 2010 }] },
2601
+ { groupValue: 999, groupHeaders: [{ groupValue: 2010 }, { groupValue: 999 }] },
2602
+ { id: '999', groupHeaders: [{ groupValue: 2010 }, { groupValue: 999 }, { groupValue: 999 }] },
2603
+ { id: '998', groupHeaders: [{ groupValue: 2010 }, { groupValue: 999 }, { groupValue: 999 }] },
2604
+ { groupValue: 11, groupHeaders: [{ groupValue: 2010 }] },
2605
+ { groupValue: 1, groupHeaders: [{ groupValue: 2010 }, { groupValue: 11 }] },
2606
+ { id: '4', groupHeaders: [{ groupValue: 2010 }, { groupValue: 11 }, { groupValue: 1 }] },
2607
+ { groupValue: 12, groupHeaders: [{ groupValue: 2010 }] },
2608
+ { groupValue: 2, groupHeaders: [{ groupValue: 2010 }, { groupValue: 12 }] },
2609
+ { id: '5', groupHeaders: [{ groupValue: 2010 }, { groupValue: 12 }, { groupValue: 2 }] },
2610
+ ]);
2611
+ });
2612
+
2613
+ it('should throw an error when row groups are not defined or incomplete', async () => {
2614
+ const grid = await createGroupedGrid({
2615
+ columns: [
2616
+ { name: 'id' },
2617
+ { name: 'name' },
2618
+ { name: 'month', grouped: true },
2619
+ { name: 'department', grouped: true },
2620
+ ],
2621
+ });
2622
+
2623
+ // month group is undefined, should throw
2624
+ expect(async () => grid.addNewRow({ id: '999', name: 'new', department: 1 }, 'end')).rejects.toThrow();
2625
+ });
2626
+ });
2627
+
2628
+ describe('addToSelection', () => {
2629
+ it('should add a row to the selected group', async () => {
2630
+ const grid = await createGroupedGrid();
2631
+
2632
+ [grid.datasource.currentRow] = grid.groupedData;
2633
+
2634
+ grid.addToSelection({ id: '999', name: 'new', month: 12 });
2635
+
2636
+ expect(grid.groupedData).toMatchObject([
2637
+ { groupValue: 1 },
2638
+ { id: '1', groupHeaders: [{ groupValue: 1 }] },
2639
+ { id: '2', groupHeaders: [{ groupValue: 1 }] },
2640
+ { id: '4', groupHeaders: [{ groupValue: 1 }] },
2641
+ { id: '999', groupHeaders: [{ groupValue: 1 }] },
2642
+ { groupValue: 2 },
2643
+ { id: '3', groupHeaders: [{ groupValue: 2 }] },
2644
+ { id: '5', groupHeaders: [{ groupValue: 2 }] },
2645
+ ]);
2646
+ });
2647
+
2648
+ it('should add a row to the selected group when using nested groups', async () => {
2649
+ const grid = await createGroupedGrid();
2650
+
2651
+ [grid.datasource.currentRow] = grid.groupedData;
2652
+
2653
+ grid.addToSelection({ id: '999', name: 'new', month: 12 });
2654
+
2655
+ expect(grid.groupedData).toMatchObject([
2656
+ { groupValue: 1 },
2657
+ { id: '1', groupHeaders: [{ groupValue: 1 }] },
2658
+ { id: '2', groupHeaders: [{ groupValue: 1 }] },
2659
+ { id: '4', groupHeaders: [{ groupValue: 1 }] },
2660
+ { id: '999', groupHeaders: [{ groupValue: 1 }] },
2661
+ { groupValue: 2 },
2662
+ { id: '3', groupHeaders: [{ groupValue: 2 }] },
2663
+ { id: '5', groupHeaders: [{ groupValue: 2 }] },
2664
+ ]);
2665
+ });
2666
+
2667
+ it('when selected row is not a group, should add a row to the same group as the selected row', async () => {
2668
+ const grid = await createGroupedGrid({
2669
+ columns: [
2670
+ { name: 'id' },
2671
+ { name: 'name' },
2672
+ { name: 'month', grouped: true },
2673
+ { name: 'department', grouped: true },
2674
+ ],
2675
+ });
2676
+
2677
+ grid.datasource.currentRow = grid.groupedData.find((row) => row.id === '3')!;
2678
+
2679
+ grid.addToSelection({ id: '999', name: 'new', month: 12 });
2680
+
2681
+ expect(grid.groupedData).toMatchObject([
2682
+ { groupValue: 11 },
2683
+ { groupValue: 1, groupHeaders: [{ groupValue: 11 }] },
2684
+ { id: '1', groupHeaders: [{ groupValue: 11 }, { groupValue: 1 }] },
2685
+ { id: '2', groupHeaders: [{ groupValue: 11 }, { groupValue: 1 }] },
2686
+ { groupValue: 2, groupHeaders: [{ groupValue: 11 }] },
2687
+ { id: '3', groupHeaders: [{ groupValue: 11 }, { groupValue: 2 }] },
2688
+ { id: '999', groupHeaders: [{ groupValue: 11 }, { groupValue: 2 }] },
2689
+ { groupValue: 12 },
2690
+ { groupValue: 1, groupHeaders: [{ groupValue: 12 }] },
2691
+ { id: '4', groupHeaders: [{ groupValue: 12 }, { groupValue: 1 }] },
2692
+ { groupValue: 2, groupHeaders: [{ groupValue: 12 }] },
2693
+ { id: '5', groupHeaders: [{ groupValue: 12 }, { groupValue: 2 }] },
2694
+ ]);
2695
+ });
2696
+
2697
+ it('when selected row is not the most internal group, should add a row to the first most internal group', async () => {
2698
+ const grid = await createGroupedGrid({
2699
+ columns: [
2700
+ { name: 'id' },
2701
+ { name: 'name' },
2702
+ { name: 'month', grouped: true },
2703
+ { name: 'department', grouped: true },
2704
+ ],
2705
+ });
2706
+
2707
+ [grid.datasource.currentRow] = grid.groupedData;
2708
+
2709
+ grid.addToSelection({ id: '999', name: 'new', month: 12 });
2710
+
2711
+ expect(grid.groupedData).toMatchObject([
2712
+ { groupValue: 11 },
2713
+ { groupValue: 1, groupHeaders: [{ groupValue: 11 }] },
2714
+ { id: '1', groupHeaders: [{ groupValue: 11 }, { groupValue: 1 }] },
2715
+ { id: '2', groupHeaders: [{ groupValue: 11 }, { groupValue: 1 }] },
2716
+ { id: '999', groupHeaders: [{ groupValue: 11 }, { groupValue: 1 }] },
2717
+ { groupValue: 2, groupHeaders: [{ groupValue: 11 }] },
2718
+ { id: '3', groupHeaders: [{ groupValue: 11 }, { groupValue: 2 }] },
2719
+ { groupValue: 12 },
2720
+ { groupValue: 1, groupHeaders: [{ groupValue: 12 }] },
2721
+ { id: '4', groupHeaders: [{ groupValue: 12 }, { groupValue: 1 }] },
2722
+ { groupValue: 2, groupHeaders: [{ groupValue: 12 }] },
2723
+ { id: '5', groupHeaders: [{ groupValue: 12 }, { groupValue: 2 }] },
2724
+ ]);
2725
+ });
2726
+ });
2325
2727
  });
@@ -0,0 +1,53 @@
1
+ declare const defaultIcons: {
2
+ columnGroupOpened: string;
3
+ columnGroupClosed: string;
4
+ columnSelectClosed: string;
5
+ columnSelectOpen: string;
6
+ columnSelectIndeterminate: string;
7
+ columnMovePin: string;
8
+ columnMoveHide: string;
9
+ columnMoveMove: string;
10
+ columnMoveLeft: string;
11
+ columnMoveRight: string;
12
+ columnMoveGroup: string;
13
+ columnMoveValue: string;
14
+ dropNotAllowed: string;
15
+ groupContracted: string;
16
+ groupExpanded: string;
17
+ chart: string;
18
+ close: string;
19
+ cancel: string;
20
+ check: string;
21
+ first: string;
22
+ previous: string;
23
+ next: string;
24
+ last: string;
25
+ linked: string;
26
+ unlinked: string;
27
+ colorPicker: string;
28
+ groupLoading: string;
29
+ menu: string;
30
+ filter: string;
31
+ columns: string;
32
+ maximize: string;
33
+ minimize: string;
34
+ menuPin: string;
35
+ menuValue: string;
36
+ menuAddRowGroup: string;
37
+ menuRemoveRowGroup: string;
38
+ clipboardCopy: string;
39
+ clipboardPaste: string;
40
+ rowGroupPanel: string;
41
+ valuePanel: string;
42
+ columnDrag: string;
43
+ rowDrag: string;
44
+ save: string;
45
+ smallDown: string;
46
+ smallLeft: string;
47
+ smallRight: string;
48
+ smallUp: string;
49
+ sortAscending: string;
50
+ sortDescending: string;
51
+ sortUnSort: string;
52
+ };
53
+ export default defaultIcons;
@@ -0,0 +1,9 @@
1
+ import { IIterable } from '@zeedhi/common';
2
+ import { IDictionary } from '@zeedhi/core';
3
+ export interface ITekAgGrid extends IIterable {
4
+ dense?: boolean;
5
+ frameworkComponents?: IDictionary;
6
+ gridOptions?: IDictionary;
7
+ height?: string | number;
8
+ icons?: IDictionary<string>;
9
+ }
@@ -0,0 +1,35 @@
1
+ import { Iterable } from '@zeedhi/common';
2
+ import { IDictionary } from '@zeedhi/core';
3
+ import { ITekAgGrid } from './interfaces';
4
+ /** Grid Component */
5
+ export declare class TekAgGrid extends Iterable implements ITekAgGrid {
6
+ cssClass: string;
7
+ dense: boolean;
8
+ frameworkComponents: IDictionary;
9
+ gridOptions: IDictionary;
10
+ height: string | number;
11
+ icons: IDictionary<string>;
12
+ gridComponent: any;
13
+ /**
14
+ * Creates a new AgGrid.
15
+ * @param props AgGrid properties
16
+ */
17
+ constructor(props: ITekAgGrid);
18
+ private createOptionsAccessors;
19
+ private setAccessor;
20
+ /**
21
+ * Reload dataset
22
+ */
23
+ reload(): Promise<any>;
24
+ /**
25
+ * Compares two dates
26
+ * @param date1
27
+ * @param date2
28
+ * @param format
29
+ * @returns -1 if date1 after date2
30
+ * @returns 0 if date1 equal date2
31
+ * @returns 1 if date1 before date2
32
+ */
33
+ dateComparator(date1: string | Date, date2: string | Date, format?: string): 1 | -1 | 0;
34
+ private getDateAsString;
35
+ }
@@ -0,0 +1,94 @@
1
+ import { IDatasource, IDictionary, RestDatasource } from '@zeedhi/core';
2
+ import { IDynamicFilterItem, ITekRestDatasource } from './interfaces';
3
+ export declare class TekRestDatasource extends RestDatasource implements ITekRestDatasource {
4
+ /** Dynamic filter data */
5
+ dynamicFilter: IDictionary<IDynamicFilterItem[]>;
6
+ /** Search Join data */
7
+ searchJoin: IDictionary<Array<string | number>>;
8
+ /**
9
+ * URL reserved keys
10
+ */
11
+ protected reservedKeys: IDictionary<boolean>;
12
+ /**
13
+ * Dynamic Filter Operations
14
+ */
15
+ dynamicFilterOperations: IDictionary<boolean>;
16
+ /**
17
+ * Dynamic Filter Relations
18
+ */
19
+ dynamicFilterRelations: IDictionary<boolean>;
20
+ /**
21
+ * Dynamic Filter applied flag
22
+ */
23
+ protected dynamicFilterApplied: string;
24
+ /**
25
+ * Create new datasource
26
+ * @param props Datasource properties
27
+ */
28
+ constructor(props: ITekRestDatasource);
29
+ protected updateInternalProperties(datasource?: IDatasource): void;
30
+ protected getEncodedParam(urlParam: string, datasourceParam?: IDictionary<any>): IDictionary<any>;
31
+ protected getQueryStringValues(): IDictionary<any>;
32
+ protected getUrlQueryString(): string;
33
+ /**
34
+ * Adds a new dynamic filter position or replace if exists
35
+ * @param column Dynamic Filter column name
36
+ * @param value Dynamic Filter value
37
+ * @returns Promise with data collection
38
+ */
39
+ addDynamicFilter(column: string, value: any): Promise<any>;
40
+ /**
41
+ * Removes a dynamic filter position
42
+ * @param column Dynamic Filter column name
43
+ * @returns Promise with data collection
44
+ */
45
+ removeDynamicFilter(column: string): Promise<any>;
46
+ /**
47
+ * Sets new dynamic filter value
48
+ * @param filter Dynamic Filter value
49
+ * @returns Promise with data collection
50
+ */
51
+ setDynamicFilter(filter: IDictionary<any>): Promise<any>;
52
+ /**
53
+ * Clears Dynamic filter value
54
+ * @returns Promise with data collection
55
+ */
56
+ clearDynamicFilter(): Promise<any>;
57
+ /**
58
+ * Resets page and selected rows and tries to update the url
59
+ * @returns Promise with data collection
60
+ */
61
+ protected updateDynamicFilter(): Promise<any>;
62
+ /**
63
+ * Checks if a filter value is valid
64
+ * @param value Filter value
65
+ * @returns Is valid filter value
66
+ */
67
+ protected isValidDynamicFilterValue(column: string, value?: IDictionary<any>[]): boolean | undefined;
68
+ /**
69
+ * Retrieves request params
70
+ */
71
+ protected getRequestParams(): any;
72
+ clone(): {
73
+ dynamicFilter: IDictionary<IDynamicFilterItem[]>;
74
+ searchJoin: IDictionary<(string | number)[]>;
75
+ type: string;
76
+ route?: string | undefined;
77
+ lazyLoad?: boolean | undefined;
78
+ arrayFormat?: "indices" | "brackets" | "repeat" | "comma" | undefined;
79
+ find?: IDictionary<any> | undefined;
80
+ currentRow?: IDictionary<any> | undefined;
81
+ data?: IDictionary<any>[] | undefined;
82
+ filter?: IDictionary<any> | undefined;
83
+ limit?: string | number | undefined;
84
+ loadAll?: boolean | undefined;
85
+ loading?: boolean | undefined;
86
+ order?: string[] | undefined;
87
+ page?: string | number | undefined;
88
+ search?: string | undefined;
89
+ searchIn?: string[] | undefined;
90
+ uniqueKey?: string | undefined;
91
+ watchUrl?: boolean | undefined;
92
+ events?: import("@zeedhi/core").IDatasourceEvents<import("@zeedhi/core").IEventParam<any>> | undefined;
93
+ };
94
+ }
@@ -0,0 +1,53 @@
1
+ declare const defaultIcons: {
2
+ columnGroupOpened: string;
3
+ columnGroupClosed: string;
4
+ columnSelectClosed: string;
5
+ columnSelectOpen: string;
6
+ columnSelectIndeterminate: string;
7
+ columnMovePin: string;
8
+ columnMoveHide: string;
9
+ columnMoveMove: string;
10
+ columnMoveLeft: string;
11
+ columnMoveRight: string;
12
+ columnMoveGroup: string;
13
+ columnMoveValue: string;
14
+ dropNotAllowed: string;
15
+ groupContracted: string;
16
+ groupExpanded: string;
17
+ chart: string;
18
+ close: string;
19
+ cancel: string;
20
+ check: string;
21
+ first: string;
22
+ previous: string;
23
+ next: string;
24
+ last: string;
25
+ linked: string;
26
+ unlinked: string;
27
+ colorPicker: string;
28
+ groupLoading: string;
29
+ menu: string;
30
+ filter: string;
31
+ columns: string;
32
+ maximize: string;
33
+ minimize: string;
34
+ menuPin: string;
35
+ menuValue: string;
36
+ menuAddRowGroup: string;
37
+ menuRemoveRowGroup: string;
38
+ clipboardCopy: string;
39
+ clipboardPaste: string;
40
+ rowGroupPanel: string;
41
+ valuePanel: string;
42
+ columnDrag: string;
43
+ rowDrag: string;
44
+ save: string;
45
+ smallDown: string;
46
+ smallLeft: string;
47
+ smallRight: string;
48
+ smallUp: string;
49
+ sortAscending: string;
50
+ sortDescending: string;
51
+ sortUnSort: string;
52
+ };
53
+ export default defaultIcons;
@@ -0,0 +1,9 @@
1
+ import { TekGridColumn } from '..';
2
+ export declare class TekFilterDynamicValues {
3
+ private static values;
4
+ private static formatDate;
5
+ static getLabel(name: string): string;
6
+ static getValue(name: string, column: TekGridColumn): string | string[];
7
+ static register(name: string, label: string, fn: () => Date | [Date, Date]): void;
8
+ static unregister(name: string): void;
9
+ }