@zeedhi/teknisa-components-common 1.107.2 → 1.109.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.
@@ -806,6 +806,7 @@ class MultiOption {
806
806
  class GridBase {
807
807
  constructor(grid) {
808
808
  this.exportConfigButtons = [];
809
+ this.defaultToolbar = {};
809
810
  this.atoms = {
810
811
  TITLE: '_gridTitle',
811
812
  HIDE_BUTTON: '_hideButton',
@@ -827,6 +828,7 @@ class GridBase {
827
828
  };
828
829
  this.grid = grid;
829
830
  this.exportConfigButtons = this.getExportConfigButtons();
831
+ this.initializeDefaultToolbarItems();
830
832
  }
831
833
  getOption(config) {
832
834
  if (config.multiOption)
@@ -839,17 +841,17 @@ class GridBase {
839
841
  return option.buildComponent(this.grid);
840
842
  });
841
843
  }
842
- createToolbarProps() {
843
- return [
844
- {
845
- name: `${this.grid.name}_gridTitle`,
844
+ initializeDefaultToolbarItems() {
845
+ this.defaultToolbar = {
846
+ title: () => ({
847
+ name: `${this.grid.name}_title`,
846
848
  component: 'ZdText',
847
849
  cssClass: 'toolbar-title',
848
850
  tag: 'h2',
849
851
  text: this.grid.title,
850
852
  title: this.grid.title,
851
- },
852
- {
853
+ }),
854
+ hideButton: () => ({
853
855
  name: `${this.grid.name}_hideTooltip`,
854
856
  component: 'ZdTooltip',
855
857
  label: `{{GridController_${this.grid.componentId}.tooltipName}}`,
@@ -859,213 +861,260 @@ class GridBase {
859
861
  name: `${this.grid.name}_hideButton`,
860
862
  component: 'ZdIcon',
861
863
  iconName: 'mdi-chevron-right',
862
- isVisible: `{{GridController_${this.grid.componentId}.isNotEditing}}`,
864
+ isVisible: true,
863
865
  cssClass: `{{GridController_${this.grid.componentId}.toolbarStyle}}`,
864
866
  events: {
865
867
  click: this.hideButtonClick.bind(this),
866
868
  },
867
869
  },
868
870
  ],
869
- },
870
- {
871
- name: `${this.grid.name}_toolbarDiv`,
872
- component: 'ZdTag',
873
- tag: 'div',
874
- cssStyle: 'display: flex; align-items: center',
875
- isVisible: `{{GridController_${this.grid.componentId}.showToolbar}}`,
871
+ }),
872
+ addButton: () => ({
873
+ name: `${this.grid.name}_add_tooltip`,
874
+ component: 'ZdTooltip',
875
+ label: 'TEKGRID_ADD',
876
+ bottom: true,
876
877
  children: [
877
878
  {
878
- name: `${this.grid.name}_notEditingSpan`,
879
- component: 'ZdTag',
880
- tag: 'span',
881
- cssStyle: 'display: flex',
882
- isVisible: `{{GridController_${this.grid.componentId}.isNotEditing}}`,
883
- children: [
884
- {
885
- name: `${this.grid.name}_add_tooltip`,
886
- component: 'ZdTooltip',
887
- label: 'TEKGRID_ADD',
888
- bottom: true,
889
- children: [
890
- {
891
- name: `${this.grid.name}_addButton`,
892
- component: 'ZdButton',
893
- icon: true,
894
- iconName: 'add',
895
- isVisible: `{{GridController_${this.grid.componentId}.showAddButton}}`,
896
- events: {
897
- click: this.addButtonClick.bind(this),
898
- },
899
- },
900
- ],
901
- },
902
- {
903
- name: `${this.grid.name}_delete_tooltip`,
904
- component: 'ZdTooltip',
905
- label: 'TEKGRID_DELETE',
906
- bottom: true,
907
- children: [
908
- {
909
- name: `${this.grid.name}_deleteButton`,
910
- component: 'ZdButton',
911
- icon: true,
912
- iconName: 'delete',
913
- isVisible: `{{GridController_${this.grid.componentId}.showDeleteButton}}`,
914
- disabled: `{{GridController_${this.grid.componentId}.disableDeleteButton}}`,
915
- events: {
916
- click: this.deleteButtonClick.bind(this),
917
- },
918
- },
919
- ],
920
- },
921
- {
922
- name: `${this.grid.name}_divider1`,
923
- component: 'ZdDivider',
924
- cssClass: 'toolbar-divider',
925
- vertical: true,
926
- isVisible: `{{GridController_${this.grid.componentId}.showDivider1}}`,
927
- },
928
- {
929
- name: `${this.grid.name}_refresh_tooltip`,
930
- component: 'ZdTooltip',
931
- label: 'TEKGRID_REFRESH',
932
- bottom: true,
933
- children: [
934
- {
935
- name: `${this.grid.name}_refreshButton`,
936
- component: 'ZdButton',
937
- icon: true,
938
- iconName: 'refresh',
939
- isVisible: `{{GridController_${this.grid.componentId}.showReloadButton}}`,
940
- events: {
941
- click: this.reloadGrid.bind(this),
942
- },
943
- },
944
- ],
945
- },
946
- {
947
- name: `${this.grid.name}_divider2`,
948
- component: 'ZdDivider',
949
- cssClass: 'toolbar-divider',
950
- vertical: true,
951
- isVisible: `{{GridController_${this.grid.componentId}.showDivider2}}`,
952
- },
953
- {
954
- name: `${this.grid.name}_columns_button_tooltip`,
955
- component: 'ZdTooltip',
956
- label: 'TEKGRID_COLUMNS',
957
- bottom: true,
958
- children: [
959
- {
960
- name: `${this.grid.name}_columnsButton`,
961
- component: 'TekGridColumnsButton',
962
- isVisible: `{{GridController_${this.grid.componentId}.showColumnsButton}}`,
963
- iterableComponentName: this.grid.name,
964
- hideGroups: !(this.grid instanceof TekGrid),
965
- ignoreColumns: `{{GridController_${this.grid.componentId}.columnsButtonIgnore}}`,
966
- },
967
- ],
968
- },
969
- {
970
- name: `${this.grid.name}_layout_options`,
971
- component: 'TekGridLayoutOptions',
972
- isVisible: `{{GridController_${this.grid.componentId}.showLayoutOptionsButton}}`,
973
- },
974
- {
975
- name: `${this.grid.name}_dividerActions`,
976
- component: 'ZdDivider',
977
- cssClass: 'toolbar-divider',
978
- vertical: true,
979
- isVisible: `{{GridController_${this.grid.componentId}.showActionAndExportButton}}`,
980
- },
981
- {
982
- name: `${this.grid.name}_export_dropdown`,
983
- component: 'ZdDropdown',
984
- cssClass: 'tekgrid-actions-dropdown',
985
- offsetY: true,
986
- activator: {
987
- name: `${this.grid.name}_exportButton`,
988
- component: 'ZdButton',
989
- icon: true,
990
- iconName: 'fileDownload',
991
- isVisible: `{{GridController_${this.grid.componentId}.showExportButton}}`,
992
- },
993
- children: this.grid.exportActions || this.exportConfigButtons,
994
- },
995
- {
996
- name: `${this.grid.name}_actions_dropdown`,
997
- component: 'ZdDropdown',
998
- cssClass: 'tekgrid-actions-dropdown',
999
- offsetY: true,
1000
- activator: {
1001
- name: `${this.grid.name}_actionsButton`,
1002
- component: 'ZdButton',
1003
- icon: true,
1004
- iconName: 'more',
1005
- isVisible: `{{GridController_${this.grid.componentId}.showActionsButton}}`,
1006
- },
1007
- children: this.grid.actions,
1008
- },
1009
- {
1010
- name: `${this.grid.name}_divider3`,
1011
- component: 'ZdDivider',
1012
- cssClass: 'toolbar-divider',
1013
- vertical: true,
1014
- isVisible: `{{GridController_${this.grid.componentId}.showDivider3}}`,
1015
- },
1016
- ],
879
+ name: `${this.grid.name}_addButton`,
880
+ component: 'ZdButton',
881
+ icon: true,
882
+ iconName: 'add',
883
+ isVisible: `{{GridController_${this.grid.componentId}.showAddButton}}`,
884
+ events: {
885
+ click: this.addButtonClick.bind(this),
886
+ },
1017
887
  },
888
+ ],
889
+ }),
890
+ deleteButton: () => ({
891
+ name: `${this.grid.name}_delete_tooltip`,
892
+ component: 'ZdTooltip',
893
+ label: 'TEKGRID_DELETE',
894
+ bottom: true,
895
+ children: [
1018
896
  {
1019
- name: `${this.grid.name}_saveButton`,
897
+ name: `${this.grid.name}_deleteButton`,
1020
898
  component: 'ZdButton',
1021
- label: 'TEKGRID_SAVE',
1022
- isVisible: `{{GridController_${this.grid.componentId}.showEditButtons}}`,
1023
- small: true,
899
+ icon: true,
900
+ iconName: 'delete',
901
+ isVisible: `{{GridController_${this.grid.componentId}.showDeleteButton}}`,
902
+ disabled: `{{GridController_${this.grid.componentId}.disableDeleteButton}}`,
1024
903
  events: {
1025
- click: this.saveChanges.bind(this),
904
+ click: this.deleteButtonClick.bind(this),
1026
905
  },
1027
906
  },
907
+ ],
908
+ }),
909
+ divider: (index) => ({
910
+ name: `${this.grid.name}_divider${index}`,
911
+ component: 'ZdDivider',
912
+ cssClass: 'toolbar-divider',
913
+ vertical: true,
914
+ isVisible: `{{GridController_${this.grid.componentId}.showDivider}}`,
915
+ }),
916
+ refreshButton: () => ({
917
+ name: `${this.grid.name}_refresh_tooltip`,
918
+ component: 'ZdTooltip',
919
+ label: 'TEKGRID_REFRESH',
920
+ bottom: true,
921
+ children: [
1028
922
  {
1029
- name: `${this.grid.name}_cancelButton`,
923
+ name: `${this.grid.name}_refreshButton`,
1030
924
  component: 'ZdButton',
1031
- label: 'TEKGRID_CANCEL',
1032
- outline: true,
1033
- cssClass: 'zd-mx-2',
1034
- isVisible: `{{GridController_${this.grid.componentId}.showEditButtons}}`,
1035
- small: true,
925
+ icon: true,
926
+ iconName: 'refresh',
927
+ isVisible: `{{GridController_${this.grid.componentId}.showReloadButton}}`,
1036
928
  events: {
1037
- click: this.cancelChanges.bind(this),
929
+ click: this.reloadGrid.bind(this),
1038
930
  },
1039
931
  },
932
+ ],
933
+ }),
934
+ columnsButton: () => ({
935
+ name: `${this.grid.name}_columns_button_tooltip`,
936
+ component: 'ZdTooltip',
937
+ label: 'TEKGRID_COLUMNS',
938
+ bottom: true,
939
+ children: [
1040
940
  {
1041
- name: `${this.grid.name}_gridSearch`,
1042
- component: 'ZdSearch',
1043
- cssClass: 'zd-grid-search',
1044
- iterableComponentName: `${this.grid.name}`,
1045
- isVisible: `{{GridController_${this.grid.componentId}.showSearchInput}}`,
941
+ name: `${this.grid.name}_columnsButton`,
942
+ component: 'TekGridColumnsButton',
943
+ isVisible: `{{GridController_${this.grid.componentId}.showColumnsButton}}`,
944
+ iterableComponentName: this.grid.name,
945
+ hideGroups: !(this.grid instanceof TekGrid),
946
+ ignoreColumns: `{{GridController_${this.grid.componentId}.columnsButtonIgnore}}`,
1046
947
  },
948
+ ],
949
+ }),
950
+ layoutOptions: () => ({
951
+ name: `${this.grid.name}_layout_options`,
952
+ component: 'TekGridLayoutOptions',
953
+ isVisible: `{{GridController_${this.grid.componentId}.showLayoutOptionsButton}}`,
954
+ }),
955
+ exportDropdown: () => ({
956
+ name: `${this.grid.name}_export_dropdown`,
957
+ component: 'ZdDropdown',
958
+ cssClass: 'tekgrid-actions-dropdown',
959
+ offsetY: true,
960
+ activator: {
961
+ name: `${this.grid.name}_exportButton`,
962
+ component: 'ZdButton',
963
+ icon: true,
964
+ iconName: 'fileDownload',
965
+ isVisible: `{{GridController_${this.grid.componentId}.showExportButton}}`,
966
+ },
967
+ children: this.grid.exportActions || this.exportConfigButtons,
968
+ }),
969
+ actionsDropdown: () => ({
970
+ name: `${this.grid.name}_actions_dropdown`,
971
+ component: 'ZdDropdown',
972
+ cssClass: 'tekgrid-actions-dropdown',
973
+ offsetY: true,
974
+ activator: {
975
+ name: `${this.grid.name}_actionsButton`,
976
+ component: 'ZdButton',
977
+ icon: true,
978
+ iconName: 'more',
979
+ isVisible: `{{GridController_${this.grid.componentId}.showActionsButton}}`,
980
+ },
981
+ children: this.grid.actions,
982
+ }),
983
+ saveButton: () => ({
984
+ name: `${this.grid.name}_saveButton`,
985
+ component: 'ZdButton',
986
+ label: 'TEKGRID_SAVE',
987
+ isVisible: `{{GridController_${this.grid.componentId}.showEditButtons}}`,
988
+ small: true,
989
+ events: {
990
+ click: this.saveChanges.bind(this),
991
+ },
992
+ }),
993
+ cancelButton: () => ({
994
+ name: `${this.grid.name}_cancelButton`,
995
+ component: 'ZdButton',
996
+ label: 'TEKGRID_CANCEL',
997
+ outline: true,
998
+ cssClass: 'zd-mx-2',
999
+ isVisible: `{{GridController_${this.grid.componentId}.showEditButtons}}`,
1000
+ small: true,
1001
+ events: {
1002
+ click: this.cancelChanges.bind(this),
1003
+ },
1004
+ }),
1005
+ gridSearch: () => ({
1006
+ name: `${this.grid.name}_gridSearch`,
1007
+ component: 'ZdSearch',
1008
+ cssClass: 'zd-grid-search',
1009
+ iterableComponentName: `${this.grid.name}`,
1010
+ isVisible: `{{GridController_${this.grid.componentId}.showSearchInput}}`,
1011
+ }),
1012
+ filterButton: () => ({
1013
+ name: `${this.grid.name}_filter_tooltip`,
1014
+ component: 'ZdTooltip',
1015
+ label: 'TEKGRID_FILTER',
1016
+ bottom: true,
1017
+ children: [
1047
1018
  {
1048
- name: `${this.grid.name}_filter_tooltip`,
1049
- component: 'ZdTooltip',
1050
- label: 'TEKGRID_FILTER',
1051
- bottom: true,
1052
- children: [
1053
- {
1054
- name: `${this.grid.name}_filterButton`,
1055
- component: 'TekGridFilterButton',
1056
- grid: this.grid,
1057
- gridName: this.grid.name,
1058
- showCheckboxAll: this.grid.showCheckboxAllFilter,
1059
- isVisible: `{{GridController_${this.grid.componentId}.showFilterButton}}`,
1060
- events: {
1061
- onCreated: this.loadFilterButton.bind(this),
1062
- },
1063
- },
1064
- ],
1019
+ name: `${this.grid.name}_filterButton`,
1020
+ component: 'TekGridFilterButton',
1021
+ grid: this.grid,
1022
+ gridName: this.grid.name,
1023
+ showCheckboxAll: this.grid.showCheckboxAllFilter,
1024
+ isVisible: `{{GridController_${this.grid.componentId}.showFilterButton}}`,
1025
+ events: {
1026
+ onCreated: this.loadFilterButton.bind(this),
1027
+ },
1065
1028
  },
1066
1029
  ],
1067
- },
1030
+ }),
1031
+ };
1032
+ }
1033
+ processUserToolbarItems(toolbarDivChildren) {
1034
+ this.grid.toolbarConfig.forEach((item, index) => {
1035
+ if (typeof item === 'object' && item.component) {
1036
+ toolbarDivChildren.push(item);
1037
+ }
1038
+ else if (typeof item === 'string') {
1039
+ const toolbarToPropertyMap = {
1040
+ addButton: 'addButton',
1041
+ deleteButton: 'deleteButton',
1042
+ refreshButton: 'refreshButton',
1043
+ columnsButton: 'columnsButton',
1044
+ layoutOptions: 'layoutButton',
1045
+ exportDropdown: 'exportButton',
1046
+ actionsDropdown: 'actionsButton',
1047
+ gridSearch: 'searchInput',
1048
+ filterButton: 'filterButton',
1049
+ };
1050
+ const gridProperty = toolbarToPropertyMap[item];
1051
+ if (gridProperty && !this.grid[gridProperty]) {
1052
+ this.grid[gridProperty] = true;
1053
+ }
1054
+ const itemFactory = this.defaultToolbar[item];
1055
+ if (itemFactory) {
1056
+ const predefinedItem = itemFactory(index);
1057
+ if (predefinedItem) {
1058
+ toolbarDivChildren.push(predefinedItem);
1059
+ }
1060
+ }
1061
+ else {
1062
+ console.warn(`Predefined toolbar item "${item}" not found.`);
1063
+ }
1064
+ }
1065
+ else {
1066
+ console.warn('Invalid item in toolbarConfig:', item);
1067
+ }
1068
+ });
1069
+ }
1070
+ /**
1071
+ * Adiciona os itens padrão da toolbar quando nenhuma configuração é fornecida.
1072
+ * @param toolbarDivChildren Array para adicionar os componentes da toolbar.
1073
+ */
1074
+ addDefaultToolbarItems(toolbarDivChildren) {
1075
+ const defaultItems = [
1076
+ 'addButton', 'deleteButton', 'divider', 'refreshButton', 'divider',
1077
+ 'columnsButton', 'layoutOptions', 'exportDropdown', 'divider', 'actionsDropdown',
1078
+ 'saveButton', 'cancelButton', 'divider', 'gridSearch', 'filterButton',
1068
1079
  ];
1080
+ defaultItems.forEach((itemName, index) => {
1081
+ const itemFactory = this.defaultToolbar[itemName];
1082
+ if (itemFactory) {
1083
+ const predefinedItem = itemFactory(index);
1084
+ if (predefinedItem) {
1085
+ toolbarDivChildren.push(predefinedItem);
1086
+ }
1087
+ }
1088
+ });
1089
+ }
1090
+ /**
1091
+ * Cria os componentes que serão renderizados na toolbar do grid.
1092
+ */
1093
+ createToolbarProps() {
1094
+ var _a, _b, _c, _d;
1095
+ const toolbarItems = [];
1096
+ const toolbarDivChildren = [];
1097
+ const title = (_b = (_a = this.defaultToolbar).title) === null || _b === void 0 ? void 0 : _b.call(_a);
1098
+ const hideButton = (_d = (_c = this.defaultToolbar).hideButton) === null || _d === void 0 ? void 0 : _d.call(_c);
1099
+ if (title)
1100
+ toolbarItems.push(title);
1101
+ if (hideButton)
1102
+ toolbarItems.push(hideButton);
1103
+ if (this.grid.toolbarConfig && this.grid.toolbarConfig.length > 0) {
1104
+ this.processUserToolbarItems(toolbarDivChildren);
1105
+ }
1106
+ else {
1107
+ this.addDefaultToolbarItems(toolbarDivChildren);
1108
+ }
1109
+ toolbarItems.push({
1110
+ name: `${this.grid.name}_toolbarDiv`,
1111
+ component: 'ZdTag',
1112
+ tag: 'div',
1113
+ cssStyle: 'display: flex; align-items: center',
1114
+ isVisible: `{{GridController_${this.grid.componentId}.showToolbar}}`,
1115
+ children: toolbarDivChildren,
1116
+ });
1117
+ return toolbarItems;
1069
1118
  }
1070
1119
  loadFilterButton({ component }) {
1071
1120
  this.filterButton = component;
@@ -1254,7 +1303,6 @@ Messages.add({
1254
1303
  TEKGRID_HELPERVALUE_CURRENT_YEAR: 'Ano Atual',
1255
1304
  TEKGRID_WITH_GROUPS: '(Com grupos)',
1256
1305
  TEKGRID_GRID_MIRROR: '(Espelho do grid)',
1257
- TEKGRID_NO_DATA: 'Não há dados para gerar o relatório',
1258
1306
  },
1259
1307
  },
1260
1308
  'en-US': {
@@ -1327,7 +1375,6 @@ Messages.add({
1327
1375
  TEKGRID_HELPERVALUE_CURRENT_YEAR: 'Current Year',
1328
1376
  TEKGRID_WITH_GROUPS: '(With groups)',
1329
1377
  TEKGRID_GRID_MIRROR: '(Grid mirror)',
1330
- TEKGRID_NO_DATA: 'There is no data to generate the report',
1331
1378
  },
1332
1379
  },
1333
1380
  'es-CL': {
@@ -1400,7 +1447,6 @@ Messages.add({
1400
1447
  TEKGRID_HELPERVALUE_CURRENT_YEAR: 'Año actual',
1401
1448
  TEKGRID_WITH_GROUPS: '(Con grupos)',
1402
1449
  TEKGRID_GRID_MIRROR: '(Espejo de grid)',
1403
- TEKGRID_NO_DATA: 'No hay datos para generar el reporte',
1404
1450
  },
1405
1451
  },
1406
1452
  });
@@ -1415,19 +1461,19 @@ class GridController {
1415
1461
  return this.grid.title;
1416
1462
  }
1417
1463
  get showAddButton() {
1418
- return this.grid.addButton;
1464
+ return this.grid.addButton && !this.isEditing && this.openToolbar;
1419
1465
  }
1420
1466
  get showDeleteButton() {
1421
- return this.grid.deleteButton !== 'none';
1467
+ return this.grid.deleteButton !== 'none' && !this.isEditing && this.openToolbar;
1422
1468
  }
1423
1469
  get showFilterButton() {
1424
- return this.grid.filterButton;
1470
+ return this.grid.filterButton && this.openToolbar;
1425
1471
  }
1426
1472
  get showModalFilterProps() {
1427
1473
  return this.grid.modalFilterProps;
1428
1474
  }
1429
1475
  get showSearchInput() {
1430
- return this.grid.showSearch;
1476
+ return this.grid.showSearch && this.openToolbar;
1431
1477
  }
1432
1478
  get showToolbar() {
1433
1479
  return this.openToolbar;
@@ -1442,46 +1488,29 @@ class GridController {
1442
1488
  return !this.openToolbar ? 'TEKGRID_SHOW' : 'TEKGRID_HIDE';
1443
1489
  }
1444
1490
  get showReloadButton() {
1445
- return this.grid.showReload;
1446
- }
1447
- get showDivider2() {
1448
- return (this.showReloadButton
1449
- && (this.showLayoutOptionsButton
1450
- || this.showColumnsButton
1451
- || this.showActionsButton
1452
- || this.showExportButton
1453
- || this.showSearchInput));
1491
+ return this.grid.showReload && !this.isEditing && this.openToolbar;
1454
1492
  }
1455
1493
  get showColumnsButton() {
1456
- return this.grid.columnsButton;
1494
+ return this.grid.columnsButton && !this.isEditing && this.openToolbar;
1457
1495
  }
1458
1496
  get columnsButtonIgnore() {
1459
1497
  return this.grid.columnsButtonIgnore;
1460
1498
  }
1461
1499
  get showLayoutOptionsButton() {
1462
- return this.grid.showLayoutOptions;
1500
+ return this.grid.showLayoutOptions && !this.isEditing && this.openToolbar;
1463
1501
  }
1464
- get showDivider1() {
1465
- return ((this.showAddButton || this.showDeleteButton)
1466
- && (this.showReloadButton
1467
- || this.showLayoutOptionsButton
1468
- || this.showColumnsButton
1469
- || this.showActionsButton
1470
- || this.showExportButton
1471
- || this.showSearchInput));
1502
+ get showDivider() {
1503
+ return !this.isEditing && this.openToolbar;
1472
1504
  }
1473
1505
  get showActionsButton() {
1474
- return this.grid.actions.length > 0;
1506
+ return this.grid.actions.length > 0 && !this.isEditing && this.openToolbar;
1475
1507
  }
1476
1508
  get showExportButton() {
1477
- return this.grid.showExport;
1509
+ return this.grid.showExport && !this.isEditing && this.openToolbar;
1478
1510
  }
1479
1511
  get showActionAndExportButton() {
1480
1512
  return ((this.showLayoutOptionsButton || this.showColumnsButton)
1481
- && (this.showActionsButton || this.showExportButton || this.showSearchInput));
1482
- }
1483
- get showDivider3() {
1484
- return ((this.showActionsButton || this.showExportButton) && this.showSearchInput);
1513
+ && (this.showActionsButton || this.showExportButton || this.showSearchInput)) && !this.isEditing && this.openToolbar;
1485
1514
  }
1486
1515
  get isEditing() {
1487
1516
  return this.grid.editing;
@@ -2243,6 +2272,10 @@ class TekGrid extends GridEditable {
2243
2272
  * @public
2244
2273
  */
2245
2274
  this.dragColumns = true;
2275
+ /**
2276
+ * Components that will be rendered on toolbar slot
2277
+ */
2278
+ this.toolbarConfig = [];
2246
2279
  /**
2247
2280
  * Enables column resizing
2248
2281
  * @public
@@ -2324,8 +2357,8 @@ class TekGrid extends GridEditable {
2324
2357
  this.groupColumnNames = [];
2325
2358
  this.summaryColumns = [];
2326
2359
  this.groupColumns = [];
2327
- this.groupedData = [];
2328
2360
  this.toolbarSlotProps = false;
2361
+ this.groupedData = [];
2329
2362
  this.editNewRowsOnly = false;
2330
2363
  this.showCheckboxAllFilter = Config.gridShowCheckboxAllFilter || false;
2331
2364
  this.defaultFilter = {};
@@ -2364,6 +2397,7 @@ class TekGrid extends GridEditable {
2364
2397
  this.showSummaryTotal = this.getInitValue('showSummaryTotal', props.showSummaryTotal, this.showSummaryTotal);
2365
2398
  this.showCheckboxAllFilter = this.getInitValue('showCheckboxAllFilter', props.showCheckboxAllFilter, this.showCheckboxAllFilter);
2366
2399
  this.defaultFilter = this.getInitValue('defaultFilter', props.defaultFilter, this.defaultFilter);
2400
+ this.toolbarConfig = this.getInitValue('toolbarConfig', props.toolbarConfig, this.toolbarConfig);
2367
2401
  this.toolbarOpened = this.getInitValue('toolbarOpened', props.toolbarOpened, this.toolbarOpened);
2368
2402
  this.editNewRowsOnly = this.getInitValue('editNewRowsOnly', props.editNewRowsOnly, this.editNewRowsOnly);
2369
2403
  this.mainGrid = this.getInitValue('mainGrid', props.mainGrid, this.mainGrid);
@@ -2661,8 +2695,9 @@ class TekGrid extends GridEditable {
2661
2695
  });
2662
2696
  if (this.groupedData.length > 0) {
2663
2697
  this.addGroupFooters(0);
2664
- if (this.showSummaryTotal) {
2665
- this.addSummary();
2698
+ if (this.showSummaryTotal && this.summaryColumns.length > 0) {
2699
+ const summaryRow = this.getSummary();
2700
+ this.groupedData.push(summaryRow);
2666
2701
  }
2667
2702
  }
2668
2703
  }
@@ -2714,14 +2749,79 @@ class TekGrid extends GridEditable {
2714
2749
  for (let i = this.groups.length - 1; i >= groupIndex; i -= 1) {
2715
2750
  if (!this.groups[i].initialized)
2716
2751
  return;
2717
- const groupFooterRow = Object.assign({ groupFooter: true, groupIndex: i, groupHeaders: [], groupLabel: this.groups[i].lastGroupHeaderRow.groupLabel, groupValue: this.groups[i].lastGroupHeaderRow.groupValue }, this.summaryData(this.groups[i].footer));
2718
- // add header for outer groups
2719
- for (let g = 0; g < i; g += 1) {
2720
- groupFooterRow.groupHeaders.push(this.groups[g].lastGroupHeaderRow);
2721
- }
2752
+ const groupFooterRow = this.getGroupFooter(this.groups[i], i);
2753
+ groupFooterRow.groupHeaders = this.getGroupHeaders(groupIndex);
2722
2754
  this.groupedData.push(groupFooterRow);
2723
2755
  }
2724
2756
  }
2757
+ /**
2758
+ * Creates a group footer, calculating its summary data
2759
+ * @param group Group to which this footer is related
2760
+ * @param groupIndex Index of the group
2761
+ * @returns new group footer
2762
+ */
2763
+ getGroupFooter(group, groupIndex) {
2764
+ const groupFooterRow = Object.assign({ groupIndex, groupFooter: true, groupHeaders: [], groupLabel: group.lastGroupHeaderRow.groupLabel, groupValue: group.lastGroupHeaderRow.groupValue }, this.getSummaryData(group.footer));
2765
+ return groupFooterRow;
2766
+ }
2767
+ /**
2768
+ * Gets all of the group headers that belong to the group at the specified index
2769
+ * This method should be called only during the groups creation process because it depends on the
2770
+ * group creation order (because it accesses lastGroupHeaderRow that changes during the creation process)
2771
+ * @param groupIndex
2772
+ * @returns
2773
+ */
2774
+ getGroupHeaders(groupIndex) {
2775
+ const groupHeaders = [];
2776
+ for (let i = 0; i <= groupIndex; i += 1) {
2777
+ groupHeaders.push(this.groups[i].lastGroupHeaderRow);
2778
+ }
2779
+ return groupHeaders;
2780
+ }
2781
+ /**
2782
+ * Updates all footers summary data and the summary total
2783
+ */
2784
+ updateSummary() {
2785
+ this.summary = {};
2786
+ this.groups.forEach((group) => {
2787
+ this.resetFooterVariables(group);
2788
+ });
2789
+ this.groupedData.forEach((row) => {
2790
+ if (this.isGroupHeader(row))
2791
+ return;
2792
+ if (this.isGroupFooter(row)) {
2793
+ this.updateGroupFooterSummary(row);
2794
+ this.resetFooterVariables(this.groups[row.groupIndex]);
2795
+ return;
2796
+ }
2797
+ if (this.isGroupSummary(row)) {
2798
+ this.updateSummaryTotal(row);
2799
+ return;
2800
+ }
2801
+ this.calcSummary(row);
2802
+ });
2803
+ }
2804
+ /**
2805
+ * Takes a group footer and updates its summary data
2806
+ */
2807
+ updateGroupFooterSummary(groupFooter) {
2808
+ const group = this.groups[groupFooter.groupIndex];
2809
+ const summary = this.getSummaryData(group.footer);
2810
+ Object.keys(summary).forEach((key) => {
2811
+ // change properties one by one to avoid changing the object reference
2812
+ groupFooter[key] = summary[key];
2813
+ });
2814
+ }
2815
+ /**
2816
+ * Updates the total summary data
2817
+ */
2818
+ updateSummaryTotal(summaryTotal) {
2819
+ const summary = this.getSummaryData(this.summary);
2820
+ Object.keys(summary).forEach((key) => {
2821
+ // change properties one by one to avoid changing the object reference
2822
+ summaryTotal[key] = summary[key];
2823
+ });
2824
+ }
2725
2825
  resetFooterVariables(group) {
2726
2826
  this.summaryColumns.forEach((column) => {
2727
2827
  group.footer[column.name] = {
@@ -2758,33 +2858,31 @@ class TekGrid extends GridEditable {
2758
2858
  }
2759
2859
  }
2760
2860
  calcSummary(row) {
2761
- if (this.summaryColumns.length > 0) {
2762
- this.summaryColumns.forEach((column) => {
2763
- const columnName = column.name;
2764
- const rowValue = row[columnName];
2765
- if (this.isUndefined(this.summary[columnName])) {
2766
- this.summary[columnName] = {
2767
- count: 0,
2768
- sum: undefined,
2769
- avg: undefined,
2770
- min: undefined,
2771
- max: undefined,
2772
- };
2773
- }
2774
- this.calcSummaryValues(columnName, this.summary[columnName], rowValue);
2775
- this.groups.forEach((group) => {
2776
- this.calcSummaryValues(columnName, group.footer[columnName], rowValue);
2777
- });
2778
- });
2779
- }
2780
- }
2781
- addSummary() {
2782
2861
  if (this.summaryColumns.length === 0)
2783
2862
  return;
2784
- const summaryRow = Object.assign({ groupFooter: true, groupSummary: true }, this.summaryData(this.summary));
2785
- this.groupedData.push(summaryRow);
2863
+ this.summaryColumns.forEach((column) => {
2864
+ const columnName = column.name;
2865
+ const rowValue = this.getVisibleValue(row, column);
2866
+ if (this.isUndefined(this.summary[columnName])) {
2867
+ this.summary[columnName] = {
2868
+ count: 0,
2869
+ sum: undefined,
2870
+ avg: undefined,
2871
+ min: undefined,
2872
+ max: undefined,
2873
+ };
2874
+ }
2875
+ this.calcSummaryValues(columnName, this.summary[columnName], rowValue);
2876
+ this.groups.forEach((group) => {
2877
+ this.calcSummaryValues(columnName, group.footer[columnName], rowValue);
2878
+ });
2879
+ });
2786
2880
  }
2787
- summaryData(group) {
2881
+ getSummary() {
2882
+ const summaryRow = Object.assign({ groupFooter: true, groupSummary: true }, this.getSummaryData(this.summary));
2883
+ return summaryRow;
2884
+ }
2885
+ getSummaryData(group) {
2788
2886
  const summaryData = {};
2789
2887
  this.summaryColumns.forEach((column) => {
2790
2888
  const { aggregation } = column;
@@ -3177,12 +3275,32 @@ class TekGrid extends GridEditable {
3177
3275
  isGroupHeader(row) {
3178
3276
  return row.groupHeader;
3179
3277
  }
3278
+ /**
3279
+ * Checks if a row is a group footer, adding typescript type-checking
3280
+ */
3281
+ isGroupFooter(row) {
3282
+ return row.groupFooter && !row.groupSummary;
3283
+ }
3284
+ /**
3285
+ * Checks if a row is a summary, adding typescript type-checking
3286
+ */
3287
+ isGroupSummary(row) {
3288
+ return row.groupSummary;
3289
+ }
3180
3290
  /**
3181
3291
  * Checks if a row is the last grouping of the grid (the most internal grouping)
3182
3292
  */
3183
3293
  isLastGrouping(group) {
3184
3294
  return group.groupColumnName === this.groupColumns[this.groupColumns.length - 1].name;
3185
3295
  }
3296
+ /**
3297
+ * change event of editable components
3298
+ * - override to call updateSummary on change
3299
+ */
3300
+ changeEditableComponent(column, row, value, component) {
3301
+ super.changeEditableComponent(column, row, value, component);
3302
+ this.updateSummary();
3303
+ }
3186
3304
  }
3187
3305
 
3188
3306
  class TekGridColumnsButtonController extends IterableColumnsButtonController {
@@ -3825,6 +3943,10 @@ class TekTreeGrid extends TreeGridEditable {
3825
3943
  this.title = '';
3826
3944
  /* Show Add button */
3827
3945
  this.addButton = false;
3946
+ /**
3947
+ * Components that will be rendered on toolbar slot
3948
+ */
3949
+ this.toolbarConfig = [];
3828
3950
  /* Show edit buttons */
3829
3951
  this.showEditButtons = true;
3830
3952
  /* Show Delete button */
@@ -3943,6 +4065,7 @@ class TekTreeGrid extends TreeGridEditable {
3943
4065
  this.exportConfig = this.getInitValue('exportConfig', props.exportConfig, this.exportConfig);
3944
4066
  this.showCheckboxAllFilter = this.getInitValue('showCheckboxAllFilter', props.showCheckboxAllFilter, this.showCheckboxAllFilter);
3945
4067
  this.defaultFilter = this.getInitValue('defaultFilter', props.defaultFilter, this.defaultFilter);
4068
+ this.toolbarConfig = this.getInitValue('toolbarConfig', props.toolbarConfig, this.toolbarConfig);
3946
4069
  this.toolbarOpened = this.getInitValue('toolbarOpened', props.toolbarOpened, this.toolbarOpened);
3947
4070
  this.exportActions = props.exportActions || this.exportActions;
3948
4071
  this.reportTitle = this.getInitValue('reportTitle', props.reportTitle, this.reportTitle);