@zeedhi/teknisa-components-common 1.130.0 → 1.131.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.
Files changed (44) hide show
  1. package/.package.json +39 -0
  2. package/coverage/clover.xml +1204 -1142
  3. package/coverage/coverage-final.json +48 -47
  4. package/coverage/lcov-report/index.html +18 -18
  5. package/coverage/lcov-report/tests/__helpers__/component-event-helper.ts.html +3 -3
  6. package/coverage/lcov-report/tests/__helpers__/flush-promises-helper.ts.html +1 -1
  7. package/coverage/lcov-report/tests/__helpers__/get-child-helper.ts.html +11 -11
  8. package/coverage/lcov-report/tests/__helpers__/index.html +1 -1
  9. package/coverage/lcov-report/tests/__helpers__/index.ts.html +4 -4
  10. package/coverage/lcov-report/tests/__helpers__/mock-created-helper.ts.html +3 -3
  11. package/coverage/lcov.info +2082 -1961
  12. package/dist/tek-components-common.esm.js +278 -163
  13. package/dist/tek-components-common.umd.js +278 -162
  14. package/package.json +2 -2
  15. package/tests/unit/components/tek-grid/grid-columns-button.spec.ts +123 -2
  16. package/tests/unit/components/tek-grid/grid-export-button.spec.ts +403 -0
  17. package/tests/unit/components/tek-grid/grid-filter-button.spec.ts +147 -4
  18. package/tests/unit/components/tek-grid/grid.spec.ts +142 -9
  19. package/tests/unit/components/tek-grid/layout_options.spec.ts +166 -0
  20. package/types/components/index.d.ts +1 -0
  21. package/types/components/tek-ag-grid/default-icons.d.ts +53 -0
  22. package/types/components/tek-ag-grid/interfaces.d.ts +9 -0
  23. package/types/components/tek-ag-grid/tek-ag-grid.d.ts +35 -0
  24. package/types/components/tek-datasource/datasource.d.ts +94 -0
  25. package/types/components/tek-grid/default-icons.d.ts +53 -0
  26. package/types/components/tek-grid/filter-dynamic-values.d.ts +9 -0
  27. package/types/components/tek-grid/grid-columns-button.d.ts +2 -1
  28. package/types/components/tek-grid/grid-controller.d.ts +19 -0
  29. package/types/components/tek-grid/grid-export-button.d.ts +19 -0
  30. package/types/components/tek-grid/grid-filter-button.d.ts +1 -0
  31. package/types/components/tek-grid/grid.d.ts +4 -0
  32. package/types/components/tek-grid/grid_column.d.ts +14 -0
  33. package/types/components/tek-grid/grid_controller.d.ts +15 -0
  34. package/types/components/tek-grid/interfaces.d.ts +8 -0
  35. package/types/components/tek-grid/layout-options.d.ts +6 -0
  36. package/types/components/tek-grid/tek-grid.d.ts +35 -0
  37. package/types/components/tek-login/interfaces.d.ts +3 -0
  38. package/types/components/tek-login/login-children.d.ts +3 -0
  39. package/types/components/tek-login/login.d.ts +58 -0
  40. package/types/components/tek-login/login_children.d.ts +3 -0
  41. package/types/components/tek-tree-grid/tree-grid.d.ts +2 -0
  42. package/types/utils/grid-base/export-options/button-option.d.ts +3 -1
  43. package/types/utils/grid-base/export-options/multi-option.d.ts +3 -1
  44. package/types/utils/grid-base/grid-base.d.ts +1 -3
@@ -639,6 +639,18 @@
639
639
  PERFORMANCE OF THIS SOFTWARE.
640
640
  ***************************************************************************** */
641
641
 
642
+ function __rest(s, e) {
643
+ var t = {};
644
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
645
+ t[p] = s[p];
646
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
647
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
648
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
649
+ t[p[i]] = s[p[i]];
650
+ }
651
+ return t;
652
+ }
653
+
642
654
  function __decorate(decorators, target, key, desc) {
643
655
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
644
656
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
@@ -715,98 +727,8 @@
715
727
  }
716
728
  }
717
729
 
718
- class ButtonOption {
719
- constructor(config) {
720
- this.config = config;
721
- }
722
- buildComponent(grid) {
723
- const { type, label, portrait = true, iconName, } = this.config;
724
- const orientation = portrait ? 'portrait' : 'landscape';
725
- return {
726
- label,
727
- iconName,
728
- name: `${grid.name}_export_${type}_${orientation}`,
729
- component: 'ZdButton',
730
- flat: true,
731
- events: {
732
- click: () => grid.getReport(type, portrait),
733
- },
734
- };
735
- }
736
- }
737
-
738
- class MultiOption {
739
- constructor(config) {
740
- this.config = config;
741
- }
742
- formatName(id, type, grid) {
743
- return `${grid.name}_export_${type}_${id}`;
744
- }
745
- buildTooltip(option, type, grid) {
746
- const { label } = option;
747
- return {
748
- name: this.formatName(`tooltip_${label}`, type, grid),
749
- component: 'ZdTooltip',
750
- bottom: true,
751
- label,
752
- children: [],
753
- };
754
- }
755
- buildButton(option, type, grid) {
756
- const { cssClass, label, iconName, reportParams, } = option;
757
- const { portrait: optionPortrait, rowObj } = reportParams || {};
758
- return {
759
- name: this.formatName(`button_${label}`, type, grid),
760
- component: 'ZdButton',
761
- cssClass,
762
- icon: true,
763
- iconName,
764
- events: {
765
- click: () => grid.getReport(type, optionPortrait, rowObj),
766
- },
767
- };
768
- }
769
- buildDivider(option, type, grid) {
770
- const { label } = option;
771
- return {
772
- name: this.formatName(`divider_${label}`, type, grid),
773
- component: 'ZdDivider',
774
- cssClass: 'zd-my-1',
775
- vertical: true,
776
- };
777
- }
778
- buildComponent(grid) {
779
- const { type, label, multiOption, } = this.config;
780
- const optionComponents = multiOption.map((option) => ([
781
- Object.assign(Object.assign({}, this.buildTooltip(option, type, grid)), { children: [
782
- this.buildButton(option, type, grid),
783
- ] }),
784
- this.buildDivider(option, type, grid),
785
- ]))
786
- .flat();
787
- optionComponents.pop();
788
- const text = {
789
- name: this.formatName('text', type, grid),
790
- component: 'ZdText',
791
- cssClass: 'zd-display-flex zd-align-center zd-flex-grow-1 tek-grid-export-multioption-text',
792
- events: {
793
- click: ({ event }) => event === null || event === void 0 ? void 0 : event.stopPropagation(),
794
- },
795
- text: label || '',
796
- };
797
- const result = {
798
- name: this.formatName('row', type, grid),
799
- component: 'ZdRow',
800
- cssClass: 'zd-display-flex zd-ma-0 zd-py-0 zd-gap-x-1 tek-grid-export-multioption-row',
801
- children: [text, ...optionComponents],
802
- };
803
- return result;
804
- }
805
- }
806
-
807
730
  class GridBase {
808
731
  constructor(grid) {
809
- this.exportConfigButtons = [];
810
732
  this.defaultToolbar = {};
811
733
  this.atoms = {
812
734
  TITLE: '_gridTitle',
@@ -828,20 +750,8 @@
828
750
  ACTIONS_DROPDOWN: '_actions_dropdown',
829
751
  };
830
752
  this.grid = grid;
831
- this.exportConfigButtons = this.getExportConfigButtons();
832
753
  this.initializeDefaultToolbarItems();
833
754
  }
834
- getOption(config) {
835
- if (config.multiOption)
836
- return new MultiOption(config);
837
- return new ButtonOption(config);
838
- }
839
- getExportConfigButtons() {
840
- return this.grid.exportConfig.map((config) => {
841
- const option = this.getOption(config);
842
- return option.buildComponent(this.grid);
843
- });
844
- }
845
755
  initializeDefaultToolbarItems() {
846
756
  this.defaultToolbar = {
847
757
  title: () => ({
@@ -949,7 +859,7 @@
949
859
  name: `${this.grid.name}_columnsButton`,
950
860
  component: 'TekGridColumnsButton',
951
861
  isVisible: `{{GridController_${this.grid.componentId}.showColumnsButton}}`,
952
- iterableComponentName: this.grid.name,
862
+ gridName: this.grid.name,
953
863
  hideGroups: !(this.grid instanceof TekGrid),
954
864
  ignoreColumns: `{{GridController_${this.grid.componentId}.columnsButtonIgnore}}`,
955
865
  },
@@ -958,21 +868,15 @@
958
868
  layoutOptions: () => ({
959
869
  name: `${this.grid.name}_layout_options`,
960
870
  component: 'TekGridLayoutOptions',
871
+ gridName: this.grid.name,
961
872
  isVisible: `{{GridController_${this.grid.componentId}.showLayoutOptionsButton}}`,
962
873
  }),
963
874
  exportDropdown: () => ({
964
875
  name: `${this.grid.name}_export_dropdown`,
965
- component: 'ZdDropdown',
966
- cssClass: 'tekgrid-actions-dropdown',
967
- offsetY: true,
968
- activator: {
969
- name: `${this.grid.name}_exportButton`,
970
- component: 'ZdButton',
971
- icon: true,
972
- iconName: 'fileDownload',
973
- isVisible: `{{GridController_${this.grid.componentId}.showExportButton}}`,
974
- },
975
- children: this.grid.exportActions || this.exportConfigButtons,
876
+ component: 'TekGridExportButton',
877
+ grid: this.grid,
878
+ gridName: this.grid.name,
879
+ isVisible: `{{GridController_${this.grid.componentId}.showExportButton}}`,
976
880
  }),
977
881
  actionsDivider: (index) => ({
978
882
  name: `${this.grid.name}_actions_divider${index}`,
@@ -1141,7 +1045,10 @@
1141
1045
  return toolbarItems;
1142
1046
  }
1143
1047
  loadFilterButton({ component }) {
1144
- this.filterButton = component;
1048
+ this.registerFilterButton(component);
1049
+ }
1050
+ registerFilterButton(filterButton) {
1051
+ this.filterButton = filterButton;
1145
1052
  }
1146
1053
  hideButtonClick({ event }) {
1147
1054
  if (!event.defaultPrevented) {
@@ -1243,7 +1150,14 @@
1243
1150
  return __awaiter(this, void 0, void 0, function* () {
1244
1151
  const { datasource } = this.grid;
1245
1152
  if (datasource instanceof TekRestDatasource || datasource instanceof TekMemoryDatasource) {
1246
- const lookupColumns = this.grid.columns.filter((column) => !!column.componentProps.datasource && !column.skipLookupSearch);
1153
+ const searchIn = datasource.searchIn || [];
1154
+ const lookupColumns = this.grid.columns.filter((column) => {
1155
+ if (!column.componentProps.datasource || column.skipLookupSearch)
1156
+ return false;
1157
+ if (searchIn.length > 0)
1158
+ return searchIn.indexOf(column.name) !== -1;
1159
+ return true;
1160
+ });
1247
1161
  const searchJoin = {};
1248
1162
  if (search) {
1249
1163
  const promises = lookupColumns.map((column) => __awaiter(this, void 0, void 0, function* () {
@@ -1581,6 +1495,95 @@
1581
1495
  }
1582
1496
  }
1583
1497
 
1498
+ class ButtonOption {
1499
+ constructor(config) {
1500
+ this.config = config;
1501
+ }
1502
+ buildComponent(grid) {
1503
+ const { type, label, portrait = true, iconName, } = this.config;
1504
+ const orientation = portrait ? 'portrait' : 'landscape';
1505
+ return {
1506
+ label,
1507
+ iconName,
1508
+ name: `${grid.name}_export_${type}_${orientation}`,
1509
+ component: 'ZdButton',
1510
+ flat: true,
1511
+ events: {
1512
+ click: () => grid.getReport(type, portrait),
1513
+ },
1514
+ };
1515
+ }
1516
+ }
1517
+
1518
+ class MultiOption {
1519
+ constructor(config) {
1520
+ this.config = config;
1521
+ }
1522
+ formatName(id, type, grid) {
1523
+ return `${grid.name}_export_${type}_${id}`;
1524
+ }
1525
+ buildTooltip(option, type, grid) {
1526
+ const { label } = option;
1527
+ return {
1528
+ name: this.formatName(`tooltip_${label}`, type, grid),
1529
+ component: 'ZdTooltip',
1530
+ bottom: true,
1531
+ label,
1532
+ children: [],
1533
+ };
1534
+ }
1535
+ buildButton(option, type, grid) {
1536
+ const { cssClass, label, iconName, reportParams, } = option;
1537
+ const { portrait: optionPortrait, rowObj } = reportParams || {};
1538
+ return {
1539
+ name: this.formatName(`button_${label}`, type, grid),
1540
+ component: 'ZdButton',
1541
+ cssClass,
1542
+ icon: true,
1543
+ iconName,
1544
+ events: {
1545
+ click: () => grid.getReport(type, optionPortrait, rowObj),
1546
+ },
1547
+ };
1548
+ }
1549
+ buildDivider(option, type, grid) {
1550
+ const { label } = option;
1551
+ return {
1552
+ name: this.formatName(`divider_${label}`, type, grid),
1553
+ component: 'ZdDivider',
1554
+ cssClass: 'zd-my-1',
1555
+ vertical: true,
1556
+ };
1557
+ }
1558
+ buildComponent(grid) {
1559
+ const { type, label, multiOption, } = this.config;
1560
+ const optionComponents = multiOption.map((option) => ([
1561
+ Object.assign(Object.assign({}, this.buildTooltip(option, type, grid)), { children: [
1562
+ this.buildButton(option, type, grid),
1563
+ ] }),
1564
+ this.buildDivider(option, type, grid),
1565
+ ]))
1566
+ .flat();
1567
+ optionComponents.pop();
1568
+ const text = {
1569
+ name: this.formatName('text', type, grid),
1570
+ component: 'ZdText',
1571
+ cssClass: 'zd-display-flex zd-align-center zd-flex-grow-1 tek-grid-export-multioption-text',
1572
+ events: {
1573
+ click: ({ event }) => event === null || event === void 0 ? void 0 : event.stopPropagation(),
1574
+ },
1575
+ text: label || '',
1576
+ };
1577
+ const result = {
1578
+ name: this.formatName('row', type, grid),
1579
+ component: 'ZdRow',
1580
+ cssClass: 'zd-display-flex zd-ma-0 zd-py-0 zd-gap-x-1 tek-grid-export-multioption-row',
1581
+ children: [text, ...optionComponents],
1582
+ };
1583
+ return result;
1584
+ }
1585
+ }
1586
+
1584
1587
  /**
1585
1588
  * Extracts properties from an object based on a list of properties
1586
1589
  * @param obj object whose properties will be extracted
@@ -3000,44 +3003,38 @@
3000
3003
  super.navigateDown();
3001
3004
  return;
3002
3005
  }
3003
- if (this.cellSelection && this.viewNavigate) {
3006
+ if (this.viewNavigate) {
3004
3007
  this.viewNavigate('down');
3005
3008
  return;
3006
3009
  }
3007
- const { index } = params;
3008
- if (!this.groupedData.length || index === this.groupedData.length)
3009
- return;
3010
- const { uniqueKey, currentRow } = this.datasource;
3011
- const rowIndex = index !== undefined
3012
- ? index
3013
- : this.groupedData.findIndex((row) => {
3014
- if (currentRow.group) {
3015
- return row.group && row.groupValue === currentRow.groupValue;
3016
- }
3017
- return row[uniqueKey] && row[uniqueKey] === currentRow[uniqueKey];
3018
- });
3019
- const newRow = this.groupedData[rowIndex + 1];
3020
- if (!newRow || !this.isItemVisible(newRow) || newRow.groupFooter) {
3021
- this.navigateDown({ index: rowIndex + 1 });
3022
- return;
3023
- }
3024
- this.datasource.currentRow = newRow;
3010
+ this.navigateGroupedDatasource(false, params);
3025
3011
  }
3026
3012
  navigateUp(params) {
3027
3013
  if (!this.isGrouped()) {
3028
3014
  super.navigateUp();
3029
3015
  return;
3030
3016
  }
3031
- if (this.cellSelection && this.viewNavigate) {
3017
+ if (this.viewNavigate) {
3032
3018
  this.viewNavigate('up');
3033
3019
  return;
3034
3020
  }
3021
+ this.navigateGroupedDatasource(true, params);
3022
+ }
3023
+ navigateDatasource(up) {
3024
+ if (!this.isGrouped()) {
3025
+ super.navigateDatasource(up);
3026
+ return;
3027
+ }
3028
+ this.navigateGroupedDatasource(up);
3029
+ }
3030
+ navigateGroupedDatasource(up, params = {}) {
3035
3031
  const { index } = params;
3036
- if (!this.groupedData.length || index === -1)
3032
+ if (!this.groupedData.length
3033
+ || (!up && index === this.groupedData.length)
3034
+ || (up && index === -1))
3037
3035
  return;
3038
3036
  const { uniqueKey, currentRow } = this.datasource;
3039
- let rowIndex;
3040
- rowIndex = index !== undefined
3037
+ let rowIndex = index !== undefined
3041
3038
  ? index
3042
3039
  : this.groupedData.findIndex((row) => {
3043
3040
  if (currentRow.group) {
@@ -3045,11 +3042,12 @@
3045
3042
  }
3046
3043
  return row[uniqueKey] && row[uniqueKey] === currentRow[uniqueKey];
3047
3044
  });
3048
- if (rowIndex === -1)
3045
+ if (up && rowIndex === -1)
3049
3046
  rowIndex = this.groupedData.length;
3050
- const newRow = this.groupedData[rowIndex - 1];
3047
+ const nextIndex = rowIndex + (up ? -1 : 1);
3048
+ const newRow = this.groupedData[nextIndex];
3051
3049
  if (!newRow || !this.isItemVisible(newRow) || newRow.groupFooter) {
3052
- this.navigateUp({ index: rowIndex - 1 });
3050
+ this.navigateGroupedDatasource(up, { index: nextIndex });
3053
3051
  return;
3054
3052
  }
3055
3053
  this.datasource.currentRow = newRow;
@@ -3172,6 +3170,9 @@
3172
3170
  getFilterInputs(columnName) {
3173
3171
  return this.gridBase.getFilterInputs(columnName);
3174
3172
  }
3173
+ registerFilterButton(filterButton) {
3174
+ this.gridBase.registerFilterButton(filterButton);
3175
+ }
3175
3176
  isColumnSearchable(column) {
3176
3177
  return column.searchable && (!this.searchVisibleOnly || column.isVisible || column.grouped);
3177
3178
  }
@@ -3380,16 +3381,14 @@
3380
3381
  */
3381
3382
  class TekGridColumnsButton extends common.IterableColumnsButton {
3382
3383
  constructor(props) {
3383
- super(props);
3384
+ super(Object.assign(Object.assign({}, props), { iterableComponentName: props.gridName || props.iterableComponentName }));
3384
3385
  this.hideGroups = false;
3385
3386
  this.aggregationDataSet = [];
3386
3387
  this.hideGroups = this.getInitValue('hideGroups', props.hideGroups, this.hideGroups);
3387
3388
  this.createAccessors();
3388
3389
  }
3389
- onCreated() {
3390
- super.onCreated();
3391
- this.controller = new TekGridColumnsButtonController(this.iterableComponent);
3392
- core.Loader.addController(`IterableColumnsButtonController_${this.componentId}`, this.controller);
3390
+ createController() {
3391
+ return new TekGridColumnsButtonController(this.iterableComponent);
3393
3392
  }
3394
3393
  getAggregationSelectData() {
3395
3394
  if (!this.aggregationDataSet.length) {
@@ -3402,6 +3401,67 @@
3402
3401
  }
3403
3402
  }
3404
3403
 
3404
+ /**
3405
+ * Base class for TekGrid export button/dropdown component.
3406
+ */
3407
+ class TekGridExportButton extends common.ComponentRender {
3408
+ constructor(props) {
3409
+ super(props);
3410
+ this.gridName = this.getInitValue('gridName', props.gridName, this.gridName);
3411
+ this.grid = this.getInitValue('grid', props.grid, this.grid);
3412
+ this.exportConfig = this.getInitValue('exportConfig', props.exportConfig, this.exportConfig);
3413
+ this.exportActions = this.getInitValue('exportActions', props.exportActions, this.exportActions);
3414
+ this.children = this.getInitValue('children', props.children, []);
3415
+ this.cssClass = this.getInitValue('cssClass', props.cssClass, this.cssClass);
3416
+ this.createAccessors();
3417
+ this.loadGrid();
3418
+ }
3419
+ getOption(config) {
3420
+ if (config.multiOption)
3421
+ return new MultiOption(config);
3422
+ return new ButtonOption(config);
3423
+ }
3424
+ getExportConfigButtons() {
3425
+ if (!this.grid)
3426
+ return [];
3427
+ const exportConfig = this.exportConfig || this.grid.exportConfig;
3428
+ return exportConfig.map((config) => {
3429
+ const option = this.getOption(config);
3430
+ return option.buildComponent(this.grid);
3431
+ });
3432
+ }
3433
+ loadChildren() {
3434
+ if (!this.grid)
3435
+ return;
3436
+ if (this.exportActions) {
3437
+ this.children = this.exportActions;
3438
+ return;
3439
+ }
3440
+ if (this.exportConfig) {
3441
+ this.children = this.getExportConfigButtons();
3442
+ return;
3443
+ }
3444
+ this.children = this.grid.exportActions || this.getExportConfigButtons();
3445
+ }
3446
+ loadGrid(gridName) {
3447
+ if (gridName)
3448
+ this.gridName = gridName;
3449
+ if (!this.grid && this.gridName) {
3450
+ const grid = core.Metadata.getInstances(this.gridName)[0];
3451
+ if (grid)
3452
+ this.grid = grid;
3453
+ }
3454
+ if (this.grid) {
3455
+ this.gridName = this.grid.name;
3456
+ this.loadChildren();
3457
+ }
3458
+ }
3459
+ onCreated() {
3460
+ super.onCreated();
3461
+ this.loadGrid();
3462
+ }
3463
+ }
3464
+
3405
3465
  class TekFilterHelper {
3406
3466
  static getLabel(name) {
3407
3467
  return core.DateHelper.getLabel(name);
@@ -3429,23 +3489,35 @@
3429
3489
  this.grid = this.getInitValue('grid', props.grid, undefined);
3430
3490
  this.showCheckboxAll = this.getInitValue('showCheckboxAll', props.showCheckboxAll, this.showCheckboxAll);
3431
3491
  this.createAccessors();
3432
- if (!this.grid)
3433
- this.loadGrid();
3492
+ this.loadGrid();
3434
3493
  }
3435
3494
  loadGrid(gridName) {
3436
3495
  if (gridName)
3437
3496
  this.gridName = gridName;
3438
- if (!this.gridName)
3439
- return;
3440
- this.grid = core.Metadata.getInstances(this.gridName)[0];
3497
+ if (!this.grid && this.gridName) {
3498
+ const grid = core.Metadata.getInstances(this.gridName)[0];
3499
+ if (grid)
3500
+ this.grid = grid;
3501
+ }
3502
+ if (this.grid) {
3503
+ this.gridName = this.grid.name;
3504
+ this.grid.registerFilterButton(this);
3505
+ }
3441
3506
  }
3442
3507
  click(event) {
3443
3508
  this.callEvent('click', { component: this, event });
3509
+ this.loadGrid();
3510
+ if (!this.grid)
3511
+ return;
3444
3512
  this.grid.callEvent('filterClick', { component: this.grid, event });
3445
3513
  if (!(event === null || event === void 0 ? void 0 : event.defaultPrevented)) {
3446
3514
  this.createFilterFromColumns.call(this);
3447
3515
  }
3448
3516
  }
3517
+ onCreated() {
3518
+ super.onCreated();
3519
+ this.loadGrid();
3520
+ }
3449
3521
  loadFilterValues({ component }) {
3450
3522
  const changedCompNames = [];
3451
3523
  const { datasource } = this.grid;
@@ -3501,7 +3573,8 @@
3501
3573
  });
3502
3574
  }
3503
3575
  hideFilterModal() {
3504
- this.filterModal.hide();
3576
+ if (this.filterModal)
3577
+ this.filterModal.hide();
3505
3578
  }
3506
3579
  destroyFilterModal() {
3507
3580
  if (this.filterModal)
@@ -3547,9 +3620,14 @@
3547
3620
  },
3548
3621
  {
3549
3622
  name: `${this.grid.name}-filter-close-button`,
3550
- component: 'ZdModalCloseButton',
3623
+ component: 'ZdButton',
3624
+ icon: true,
3625
+ iconName: 'close',
3626
+ flat: true,
3551
3627
  small: true,
3552
- modalName: `${this.grid.name}-filter-modal`,
3628
+ events: {
3629
+ click: this.hideFilterModal.bind(this),
3630
+ },
3553
3631
  },
3554
3632
  ],
3555
3633
  },
@@ -3695,15 +3773,20 @@
3695
3773
  this.setFilter(filter, event, datasource.setBaseFilter.bind(datasource));
3696
3774
  }
3697
3775
  else {
3776
+ const structuredFilter = {};
3698
3777
  Object.keys(formValue).forEach((item) => {
3699
3778
  let columnName = item.split(`${this.grid.name}-filter-AND-CONTAINS-`)[1];
3700
3779
  columnName = columnName.split('-').slice(0, -1).join('-'); // remove index
3701
- if (formValue[item]) {
3702
- filter[columnName] = formValue[item];
3780
+ const itemValue = formValue[item];
3781
+ if (itemValue && !(Array.isArray(itemValue) && !itemValue.length)) {
3782
+ filter[columnName] = itemValue;
3783
+ if (!structuredFilter[columnName])
3784
+ structuredFilter[columnName] = [];
3785
+ structuredFilter[columnName].push({ relation: 'AND', operation: 'CONTAINS', value: itemValue });
3703
3786
  }
3704
3787
  });
3705
3788
  datasource.filter = filter;
3706
- this.setFilter(filter, event, datasource.setBaseFilter.bind(datasource));
3789
+ this.setFilter(structuredFilter, event, datasource.setBaseFilter.bind(datasource));
3707
3790
  }
3708
3791
  this.grid.changeLayout(event);
3709
3792
  }
@@ -3753,7 +3836,8 @@
3753
3836
  columnComponentName = `${this.grid.name}-filter-AND-CONTAINS-${column.name}-${index}`;
3754
3837
  }
3755
3838
  this.filterFormInputs[column.name].push(columnComponentName);
3756
- const newColumnComponent = Object.assign(Object.assign(Object.assign({ label: column.label }, column.componentProps), filterItem), { name: columnComponentName });
3839
+ const _b = column.componentProps || {}, componentProps = __rest(_b, ["dataValueOut"]);
3840
+ const newColumnComponent = Object.assign(Object.assign(Object.assign({ label: column.label }, componentProps), filterItem), { name: columnComponentName });
3757
3841
  if (filterItem.helperOptions) {
3758
3842
  if (!newColumnComponent.events)
3759
3843
  newColumnComponent.events = {};
@@ -3787,8 +3871,8 @@
3787
3871
  }
3788
3872
 
3789
3873
  class TekGridLayoutOptions extends common.ComponentRender {
3790
- constructor() {
3791
- super(...arguments);
3874
+ constructor(props) {
3875
+ super(props);
3792
3876
  this.currentLayoutName = '';
3793
3877
  this.layoutEdited = false;
3794
3878
  this.layouts = {};
@@ -3797,6 +3881,8 @@
3797
3881
  this.originalDatasourceOrder = [];
3798
3882
  this.originalDatasourceDynamicFilter = {};
3799
3883
  this.originalDatasourceFilter = {};
3884
+ this.gridName = this.getInitValue('gridName', props.gridName, this.gridName);
3885
+ this.createAccessors();
3800
3886
  }
3801
3887
  getParentGrid() {
3802
3888
  let { parent } = this;
@@ -3807,13 +3893,39 @@
3807
3893
  }
3808
3894
  return parent;
3809
3895
  }
3896
+ loadGrid(gridName) {
3897
+ if (gridName)
3898
+ this.gridName = gridName;
3899
+ if (this.gridName) {
3900
+ const grid = core.Metadata.getInstances(this.gridName)[0];
3901
+ if (grid)
3902
+ this.grid = grid;
3903
+ }
3904
+ else {
3905
+ this.grid = this.getParentGrid();
3906
+ }
3907
+ if (this.grid) {
3908
+ this.gridName = this.grid.name;
3909
+ }
3910
+ return this.grid;
3911
+ }
3912
+ onGridChangeLayout() {
3913
+ this.layoutEdited = true;
3914
+ }
3915
+ registerChangeLayoutEvent() {
3916
+ if (!this.grid || this.changeLayoutEventGrid === this.grid)
3917
+ return;
3918
+ this.grid.addEvent('changeLayout', this.onGridChangeLayout.bind(this));
3919
+ this.changeLayoutEventGrid = this.grid;
3920
+ }
3810
3921
  onMounted(element) {
3811
3922
  const _super = Object.create(null, {
3812
3923
  onMounted: { get: () => super.onMounted }
3813
3924
  });
3814
3925
  return __awaiter(this, void 0, void 0, function* () {
3815
3926
  _super.onMounted.call(this, element);
3816
- this.grid = this.getParentGrid();
3927
+ this.loadGrid();
3928
+ this.registerChangeLayoutEvent();
3817
3929
  this.originalDatasourceOrder = [...this.grid.datasource.order];
3818
3930
  this.originalDatasourceDynamicFilter = Object.assign({}, this.grid.datasource.dynamicFilter);
3819
3931
  this.originalDatasourceFilter = Object.assign({}, this.grid.datasource.filter);
@@ -4350,6 +4462,9 @@
4350
4462
  getFilterInputs(columnName) {
4351
4463
  return this.gridBase.getFilterInputs(columnName);
4352
4464
  }
4465
+ registerFilterButton(filterButton) {
4466
+ this.gridBase.registerFilterButton(filterButton);
4467
+ }
4353
4468
  getColumn(name) {
4354
4469
  return super.getColumn(name);
4355
4470
  }
@@ -4958,6 +5073,7 @@
4958
5073
  exports.TekGridColumn = TekGridColumn;
4959
5074
  exports.TekGridColumnsButton = TekGridColumnsButton;
4960
5075
  exports.TekGridColumnsButtonController = TekGridColumnsButtonController;
5076
+ exports.TekGridExportButton = TekGridExportButton;
4961
5077
  exports.TekGridFilterButton = TekGridFilterButton;
4962
5078
  exports.TekGridLayoutOptions = TekGridLayoutOptions;
4963
5079
  exports.TekMemoryDatasource = TekMemoryDatasource;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zeedhi/teknisa-components-common",
3
- "version": "1.130.0",
3
+ "version": "1.131.0",
4
4
  "description": "Teknisa Components Common",
5
5
  "author": "Zeedhi <zeedhi@teknisa.com>",
6
6
  "license": "ISC",
@@ -32,5 +32,5 @@
32
32
  "peerDependencies": {
33
33
  "@zeedhi/core": "^1.97.0"
34
34
  },
35
- "gitHead": "51f17ecdb5684968a784c9717b48adee73ea1e03"
35
+ "gitHead": "d69433a80af7e19465bcdc279415daf367743b0c"
36
36
  }