@sankhyalabs/sankhyablocks 8.15.0-dev.30 → 8.15.0-dev.31

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 (123) hide show
  1. package/dist/cjs/SnkMultiSelectionListDataSource-5213120b.js +140 -0
  2. package/dist/cjs/index-f9e81701.js +2 -10
  3. package/dist/cjs/loader.cjs.js +1 -1
  4. package/dist/cjs/{pesquisa-fetcher-c416a6b7.js → pesquisa-fetcher-94f6b316.js} +231 -20
  5. package/dist/cjs/sankhyablocks.cjs.js +1 -1
  6. package/dist/cjs/{snk-actions-button_2.cjs.entry.js → snk-actions-button_4.cjs.entry.js} +517 -2
  7. package/dist/cjs/snk-application.cjs.entry.js +1 -2
  8. package/dist/cjs/snk-attach.cjs.entry.js +3 -4
  9. package/dist/cjs/snk-crud.cjs.entry.js +2 -3
  10. package/dist/cjs/snk-detail-view.cjs.entry.js +4 -5
  11. package/dist/cjs/snk-form-config.cjs.entry.js +6 -0
  12. package/dist/cjs/snk-form.cjs.entry.js +1 -1
  13. package/dist/cjs/snk-grid.cjs.entry.js +10 -19
  14. package/dist/cjs/{snk-guides-viewer-bd69fce4.js → snk-guides-viewer-c7293cfa.js} +2 -3
  15. package/dist/cjs/snk-guides-viewer.cjs.entry.js +3 -4
  16. package/dist/cjs/snk-personalized-filter-editor.cjs.entry.js +3 -1
  17. package/dist/cjs/snk-simple-crud.cjs.entry.js +147 -16
  18. package/dist/collection/collection-manifest.json +6 -6
  19. package/dist/collection/components/snk-crud/subcomponents/snk-detail-view/snk-detail-view.js +2 -2
  20. package/dist/collection/components/snk-crud/subcomponents/snk-guides-viewer.js +1 -1
  21. package/dist/collection/components/snk-filter-bar/filter-item/editors/snk-personalized-filter-editor/snk-personalized-filter-editor.js +3 -1
  22. package/dist/collection/components/snk-form/snk-form.js +1 -1
  23. package/dist/collection/components/{snk-form/subcomponents/snk-form-config → snk-form-config}/snk-form-config.js +11 -5
  24. package/dist/collection/components/snk-grid/snk-grid.js +5 -16
  25. package/dist/collection/components/{snk-grid/subcomponents/snk-grid-config → snk-grid-config}/snk-grid-config.js +130 -123
  26. package/dist/collection/components/{snk-grid/subcomponents → snk-grid-config}/snk-select-box/snk-select-box.js +1 -1
  27. package/dist/collection/components/snk-simple-crud/snk-simple-crud.css +5 -0
  28. package/dist/collection/components/snk-simple-crud/snk-simple-crud.js +226 -14
  29. package/dist/collection/lib/http/data-fetcher/fetchers/pesquisa-fetcher.js +1 -8
  30. package/dist/collection/lib/utils/CrudUtils.js +13 -1
  31. package/dist/components/dataunit-fetcher.js +1 -8
  32. package/dist/components/field-search.js +93 -3
  33. package/dist/components/index.d.ts +6 -6
  34. package/dist/components/snk-attach2.js +54 -12
  35. package/dist/components/snk-detail-view2.js +29 -4
  36. package/dist/components/snk-form-config2.js +7 -1
  37. package/dist/components/snk-grid-config2.js +128 -102
  38. package/dist/components/snk-grid2.js +10 -17
  39. package/dist/components/snk-personalized-filter-editor.js +3 -1
  40. package/dist/components/snk-simple-crud2.js +204 -24
  41. package/dist/esm/SnkMultiSelectionListDataSource-7e7eada5.js +133 -0
  42. package/dist/esm/index-a7d3d3f1.js +2 -10
  43. package/dist/esm/loader.js +1 -1
  44. package/dist/esm/{pesquisa-fetcher-ab16a2e8.js → pesquisa-fetcher-f05a12ca.js} +222 -12
  45. package/dist/esm/sankhyablocks.js +1 -1
  46. package/dist/esm/{snk-actions-button_2.entry.js → snk-actions-button_4.entry.js} +516 -3
  47. package/dist/esm/snk-application.entry.js +1 -2
  48. package/dist/esm/snk-attach.entry.js +2 -3
  49. package/dist/esm/snk-crud.entry.js +2 -3
  50. package/dist/esm/snk-detail-view.entry.js +4 -5
  51. package/dist/esm/snk-form-config.entry.js +7 -1
  52. package/dist/esm/snk-form.entry.js +1 -1
  53. package/dist/esm/snk-grid.entry.js +11 -20
  54. package/dist/esm/{snk-guides-viewer-fde82cc1.js → snk-guides-viewer-47443f7c.js} +2 -3
  55. package/dist/esm/snk-guides-viewer.entry.js +3 -4
  56. package/dist/esm/snk-personalized-filter-editor.entry.js +3 -1
  57. package/dist/esm/snk-simple-crud.entry.js +148 -17
  58. package/dist/sankhyablocks/p-2897fb8c.js +1 -0
  59. package/dist/sankhyablocks/p-30735d1e.entry.js +1 -0
  60. package/dist/sankhyablocks/p-3c5b7cfc.entry.js +1 -0
  61. package/dist/sankhyablocks/p-6ae58da0.js +1 -0
  62. package/dist/sankhyablocks/{p-fcdcb0e2.entry.js → p-746fc99e.entry.js} +1 -1
  63. package/dist/sankhyablocks/p-99b1926b.entry.js +1 -0
  64. package/dist/sankhyablocks/p-9fb97691.entry.js +1 -0
  65. package/dist/sankhyablocks/p-b11aa1e0.entry.js +1 -0
  66. package/dist/sankhyablocks/p-b281e9e9.entry.js +1 -0
  67. package/dist/sankhyablocks/p-d78d4062.js +65 -0
  68. package/dist/sankhyablocks/{p-fd0a8d68.entry.js → p-ec18c04e.entry.js} +3 -3
  69. package/dist/sankhyablocks/p-eefe9954.entry.js +1 -0
  70. package/dist/sankhyablocks/p-fca66dda.entry.js +1 -0
  71. package/dist/sankhyablocks/p-fe741404.entry.js +1 -0
  72. package/dist/sankhyablocks/sankhyablocks.esm.js +1 -1
  73. package/dist/types/components/snk-crud/subcomponents/snk-detail-view/snk-detail-view.d.ts +1 -1
  74. package/dist/types/components/snk-crud/subcomponents/snk-guides-viewer.d.ts +1 -1
  75. package/dist/types/components/snk-form/snk-form.d.ts +1 -1
  76. package/dist/types/components/{snk-form/subcomponents/snk-form-config → snk-form-config}/snk-form-config.d.ts +4 -3
  77. package/dist/types/components/snk-grid/snk-grid.d.ts +0 -1
  78. package/dist/types/components/{snk-grid/subcomponents/snk-grid-config → snk-grid-config}/snk-grid-config.d.ts +11 -6
  79. package/dist/types/components/{snk-grid/subcomponents → snk-grid-config}/snk-select-box/snk-select-box.d.ts +1 -1
  80. package/dist/types/components/snk-simple-crud/snk-simple-crud.d.ts +46 -1
  81. package/dist/types/components.d.ts +26 -10
  82. package/dist/types/lib/utils/CrudUtils.d.ts +3 -0
  83. package/package.json +1 -1
  84. package/dist/cjs/PreloadManager-84466da6.js +0 -224
  85. package/dist/cjs/SnkMultiSelectionListDataSource-ba5838c2.js +0 -49
  86. package/dist/cjs/snk-grid-config.cjs.entry.js +0 -483
  87. package/dist/cjs/snk-select-box.cjs.entry.js +0 -25
  88. package/dist/esm/PreloadManager-c1c2f2b4.js +0 -222
  89. package/dist/esm/SnkMultiSelectionListDataSource-44494b0e.js +0 -43
  90. package/dist/esm/snk-grid-config.entry.js +0 -479
  91. package/dist/esm/snk-select-box.entry.js +0 -21
  92. package/dist/sankhyablocks/p-094c30cb.js +0 -1
  93. package/dist/sankhyablocks/p-0b0b36ac.entry.js +0 -1
  94. package/dist/sankhyablocks/p-11ad137d.entry.js +0 -1
  95. package/dist/sankhyablocks/p-57212bb5.js +0 -1
  96. package/dist/sankhyablocks/p-5f5b58b6.entry.js +0 -1
  97. package/dist/sankhyablocks/p-84bb8f47.entry.js +0 -1
  98. package/dist/sankhyablocks/p-91b7f78a.entry.js +0 -1
  99. package/dist/sankhyablocks/p-98674137.entry.js +0 -1
  100. package/dist/sankhyablocks/p-b7004423.entry.js +0 -1
  101. package/dist/sankhyablocks/p-c22c1d8e.js +0 -1
  102. package/dist/sankhyablocks/p-c6247955.js +0 -65
  103. package/dist/sankhyablocks/p-c758265f.entry.js +0 -1
  104. package/dist/sankhyablocks/p-d4802f81.entry.js +0 -1
  105. package/dist/sankhyablocks/p-e3bd000e.entry.js +0 -1
  106. package/dist/sankhyablocks/p-fb842329.entry.js +0 -1
  107. /package/dist/cjs/{SnkFormConfigManager-3621bfc4.js → SnkFormConfigManager-0ffd098d.js} +0 -0
  108. /package/dist/collection/components/{snk-form → snk-form-config}/SnkFormConfigManager.js +0 -0
  109. /package/dist/collection/components/{snk-form/subcomponents/snk-form-config → snk-form-config}/snk-form-config.css +0 -0
  110. /package/dist/collection/components/{snk-form → snk-form-config}/subcomponents/snk-config-options/snk-config-options.css +0 -0
  111. /package/dist/collection/components/{snk-form → snk-form-config}/subcomponents/snk-config-options/snk-config-options.js +0 -0
  112. /package/dist/collection/components/{snk-form → snk-form-config}/subcomponents/snk-field-config/snk-field-config.css +0 -0
  113. /package/dist/collection/components/{snk-form → snk-form-config}/subcomponents/snk-field-config/snk-field-config.js +0 -0
  114. /package/dist/collection/components/{snk-form → snk-form-config}/subcomponents/snk-tab-config/snk-tab-config.css +0 -0
  115. /package/dist/collection/components/{snk-form → snk-form-config}/subcomponents/snk-tab-config/snk-tab-config.js +0 -0
  116. /package/dist/collection/components/{snk-grid/subcomponents/snk-grid-config → snk-grid-config}/snk-grid-config.css +0 -0
  117. /package/dist/collection/components/{snk-grid/subcomponents → snk-grid-config}/snk-select-box/snk-select-box.css +0 -0
  118. /package/dist/esm/{SnkFormConfigManager-692e20c7.js → SnkFormConfigManager-dd450734.js} +0 -0
  119. /package/dist/sankhyablocks/{p-725d04ba.js → p-9ea14b61.js} +0 -0
  120. /package/dist/types/components/{snk-form → snk-form-config}/SnkFormConfigManager.d.ts +0 -0
  121. /package/dist/types/components/{snk-form → snk-form-config}/subcomponents/snk-config-options/snk-config-options.d.ts +0 -0
  122. /package/dist/types/components/{snk-form → snk-form-config}/subcomponents/snk-field-config/snk-field-config.d.ts +0 -0
  123. /package/dist/types/components/{snk-form → snk-form-config}/subcomponents/snk-tab-config/snk-tab-config.d.ts +0 -0
@@ -1,9 +1,9 @@
1
1
  import { h, Host } from "@stencil/core";
2
2
  import { Sortable } from '@shopify/draggable';
3
- import { ObjectUtils, ArrayUtils, ElementIDUtils } from '@sankhyalabs/core';
3
+ import { ObjectUtils, ArrayUtils, ElementIDUtils, ApplicationContext } from '@sankhyalabs/core';
4
4
  import { ApplicationUtils, DialogType } from "@sankhyalabs/ezui/dist/collection/utils";
5
- import { ACTION_CONFIG, CONFIG_EVENTS, CONFIG_SORTABLE_EVENTS, DEFAULT_TYPE, TAB_NAMES } from "../../../../lib/utils/constants";
6
- import { UserConfigType } from "../../../../lib/http/data-fetcher/fetchers/form-config-fetcher";
5
+ import { ACTION_CONFIG, CONFIG_EVENTS, CONFIG_SORTABLE_EVENTS, DEFAULT_TYPE, TAB_NAMES } from "../../lib/utils/constants";
6
+ import { UserConfigType } from "../../lib/http/data-fetcher/fetchers/form-config-fetcher";
7
7
  import { buildFormConfigFromDataUnit } from "@sankhyalabs/ezui/dist/collection/utils/form";
8
8
  const CONTAINER_ID = {
9
9
  collapsibleBox: "EZ-COLLAPSIBLE-BOX",
@@ -932,6 +932,12 @@ export class SnkFormConfig {
932
932
  this.controlSortableField();
933
933
  this.controlSortableGroup();
934
934
  }
935
+ async componentWillRender() {
936
+ if (this.messagesBuilder == undefined) {
937
+ const application = ApplicationContext.getContextValue("__SNK__APPLICATION__");
938
+ this.messagesBuilder = application.messagesBuilder;
939
+ }
940
+ }
935
941
  componentWillLoad() {
936
942
  this.loadConfig();
937
943
  }
@@ -1005,7 +1011,7 @@ export class SnkFormConfig {
1005
1011
  "references": {
1006
1012
  "SnkFormConfigManager": {
1007
1013
  "location": "import",
1008
- "path": "../../SnkFormConfigManager"
1014
+ "path": "./SnkFormConfigManager"
1009
1015
  }
1010
1016
  }
1011
1017
  },
@@ -1025,7 +1031,7 @@ export class SnkFormConfig {
1025
1031
  "references": {
1026
1032
  "SnkMessageBuilder": {
1027
1033
  "location": "import",
1028
- "path": "../../../../lib/message/SnkMessageBuilder"
1034
+ "path": "../../lib/message/SnkMessageBuilder"
1029
1035
  }
1030
1036
  }
1031
1037
  },
@@ -1,6 +1,6 @@
1
1
  import { h, Fragment } from '@stencil/core';
2
2
  import { ApplicationContext, DataType, ElementIDUtils, StringUtils } from '@sankhyalabs/core';
3
- import { SortMode, UserInterface } from '@sankhyalabs/core/dist/dataunit/metadata/UnitMetadata';
3
+ import { UserInterface } from '@sankhyalabs/core/dist/dataunit/metadata/UnitMetadata';
4
4
  import { TaskbarElement } from '../snk-taskbar/elements/taskbar-elements';
5
5
  import { ConfigStorage } from '../../lib/configs/ConfigStorage';
6
6
  import { PresentationMode } from '../../lib/@types';
@@ -9,6 +9,7 @@ import store from "../../lib/store";
9
9
  import SnkMultiSelectionListDataSource from './filtercolumn/SnkMultiSelectionListDataSource';
10
10
  import { SelectionMode } from '@sankhyalabs/core/dist/dataunit/DataUnit';
11
11
  import { buildFieldSearch, openFieldSearch } from '../snk-taskbar/subcomponents/field-search';
12
+ import { CrudUtils } from '../../lib';
12
13
  export class SnkGrid {
13
14
  constructor() {
14
15
  this._topTaskbarProcessor = new TaskbarProcessor({
@@ -111,19 +112,7 @@ export class SnkGrid {
111
112
  }
112
113
  setGridConfig(config) {
113
114
  this._gridConfig = config;
114
- this.assertDefaultSorting();
115
- }
116
- assertDefaultSorting() {
117
- if (this._gridConfig && this._dataUnit) {
118
- this._dataUnit.defaultSorting = this._gridConfig
119
- .columns
120
- .filter(col => col.ascending != undefined)
121
- .sort((colA, colB) => colA.orderIndex - colB.orderIndex)
122
- .map(({ name: field, ascending }) => {
123
- const { dataType } = this._dataUnit.getField(field);
124
- return { field, dataType, mode: ascending ? SortMode.ASC : SortMode.DESC };
125
- });
126
- }
115
+ CrudUtils.assertDefaultSorting(this._gridConfig, this._dataUnit);
127
116
  }
128
117
  loadConfig() {
129
118
  ConfigStorage.loadGridConfig(this.configName, this.resourceID)
@@ -249,7 +238,7 @@ export class SnkGrid {
249
238
  ElementIDUtils.addIDInfo(this._element, null, dataInfo);
250
239
  }
251
240
  finshLoading() {
252
- this.assertDefaultSorting();
241
+ CrudUtils.assertDefaultSorting(this._gridConfig, this._dataUnit);
253
242
  this.addElementID();
254
243
  if (this.columnFilterDataSource != undefined) {
255
244
  this.columnFilterDataSource.setApplication(this._application);
@@ -401,7 +390,7 @@ export class SnkGrid {
401
390
  return undefined;
402
391
  }
403
392
  return (h("div", { class: "snk-grid__container ez-flex ez-flex--column ez-flex-item--auto ez-padding--large" }, h("div", { class: "snk-grid__header ez-margin-bottom--medium" }, this._showSnkFilterBar &&
404
- h(Fragment, null, h("snk-filter-bar", { ref: (ref) => this._snkFilterBar = ref, title: this.filterBarTitle, dataUnit: this._dataUnit, "data-element-id": "gridFilter", class: "snk-grid__filter-bar ez-align--top", configName: this.configName, messagesBuilder: this.messagesBuilder, resourceID: this.resourceID, onConfigUpdated: evt => this.handleFilterConfigUpdated(evt.detail), disablePersonalizedFilter: this.disablePersonalizedFilter }), h("hr", { class: "ez-divider-vertical ez-divider--dark ez-margin-left--medium snk-grid__header-divider" })), h("snk-taskbar", { class: "ez-padding-left--medium", "data-element-id": "grid_top", key: "topTaskbar", configName: this.configName, dataUnit: this._dataUnit, messagesBuilder: this.messagesBuilder, buttons: this._topTaskbarProcessor.buttons, disabledButtons: this._topTaskbarProcessor.disabledButtons, customButtons: this._topTaskbarProcessor.customButtons, primaryButton: this.getPrimaryButton(), resourceID: this.resourceID, customContainerId: this.taskbarCustomContainerId, customSlotId: this.topTaskbarCustomSlotId, overflowStrategy: 'none' }, h("slot", { name: this.topTaskbarCustomSlotId }))), h("ez-grid", { ref: ref => this._grid = ref, class: (this.presentationMode === PresentationMode.SECONDARY ? "snk-grid-container__without-shadow " : "") + "snk-grid__table", "data-element-id": "embedded", dataUnit: this._dataUnit, key: "grid-" + this._snkDataUnit.entityName, config: this._gridConfig, onConfigChange: (evt) => { this.gridConfigChangeHandler(evt); }, onEzDoubleClick: (evt) => this.gridDoubleClick.emit(evt.detail), statusResolver: this.statusResolver, multipleSelection: this.multipleSelection, columnfilterDataSource: this.columnFilterDataSource, selectionToastConfig: this.selectionToastConfig, useEnterLikeTab: this.useEnterLikeTab, recordsValidator: this.recordsValidator, canEdit: this.canEdit }, h("snk-taskbar", { id: 'teste', dataUnit: this._dataUnit, configName: this.configName, messagesBuilder: this.messagesBuilder, "data-element-id": "grid_left", buttons: this._headerTaskbarProcessor.buttons, presentationMode: this.presentationMode, disabledButtons: this._headerTaskbarProcessor.disabledButtons, customButtons: this._headerTaskbarProcessor.customButtons, slot: "leftButtons", actionsList: this.getActionsList(), primaryButton: this.getPrimaryButton(), resourceID: this.resourceID, customContainerId: this.taskbarCustomContainerId, customSlotId: this.gridHeaderCustomSlotId }, h("slot", { name: this.gridHeaderCustomSlotId }))), h("div", { class: "ez-col ez-col--sd-12" }, h("slot", { name: "SnkGridFooter" })), h("ez-modal", { modalSize: "small", closeEsc: false, closeOutsideClick: false, opened: this._popUpGridConfig, onEzCloseModal: () => this.closeGridConfig() }, h("snk-grid-config", { ref: ref => this._snkGridConfig = ref, config: this._gridConfig, "data-element-id": this._element.getAttribute(ElementIDUtils.DATA_ELEMENT_ID_ATTRIBUTE_NAME), application: this._application, selectedIndex: 0, configName: this.configName, onConfigChange: (evt) => this.modalConfigChangeHandler(evt), onConfigCancel: () => this.closeGridConfig(), resourceID: this.resourceID }))));
393
+ h(Fragment, null, h("snk-filter-bar", { ref: (ref) => this._snkFilterBar = ref, title: this.filterBarTitle, dataUnit: this._dataUnit, "data-element-id": "gridFilter", class: "snk-grid__filter-bar ez-align--top", configName: this.configName, messagesBuilder: this.messagesBuilder, resourceID: this.resourceID, onConfigUpdated: evt => this.handleFilterConfigUpdated(evt.detail), disablePersonalizedFilter: this.disablePersonalizedFilter }), h("hr", { class: "ez-divider-vertical ez-divider--dark ez-margin-left--medium snk-grid__header-divider" })), h("snk-taskbar", { class: "ez-padding-left--medium", "data-element-id": "grid_top", key: "topTaskbar", configName: this.configName, dataUnit: this._dataUnit, messagesBuilder: this.messagesBuilder, buttons: this._topTaskbarProcessor.buttons, disabledButtons: this._topTaskbarProcessor.disabledButtons, customButtons: this._topTaskbarProcessor.customButtons, primaryButton: this.getPrimaryButton(), resourceID: this.resourceID, customContainerId: this.taskbarCustomContainerId, customSlotId: this.topTaskbarCustomSlotId, overflowStrategy: 'none' }, h("slot", { name: this.topTaskbarCustomSlotId }))), h("ez-grid", { ref: ref => this._grid = ref, class: (this.presentationMode === PresentationMode.SECONDARY ? "snk-grid-container__without-shadow " : "") + "snk-grid__table", "data-element-id": "embedded", dataUnit: this._dataUnit, key: "grid-" + this._snkDataUnit.entityName, config: this._gridConfig, onConfigChange: (evt) => { this.gridConfigChangeHandler(evt); }, onEzDoubleClick: (evt) => this.gridDoubleClick.emit(evt.detail), statusResolver: this.statusResolver, multipleSelection: this.multipleSelection, columnfilterDataSource: this.columnFilterDataSource, selectionToastConfig: this.selectionToastConfig, useEnterLikeTab: this.useEnterLikeTab, recordsValidator: this.recordsValidator, canEdit: this.canEdit }, h("snk-taskbar", { id: 'teste', dataUnit: this._dataUnit, configName: this.configName, messagesBuilder: this.messagesBuilder, "data-element-id": "grid_left", buttons: this._headerTaskbarProcessor.buttons, presentationMode: this.presentationMode, disabledButtons: this._headerTaskbarProcessor.disabledButtons, customButtons: this._headerTaskbarProcessor.customButtons, slot: "leftButtons", actionsList: this.getActionsList(), primaryButton: this.getPrimaryButton(), resourceID: this.resourceID, customContainerId: this.taskbarCustomContainerId, customSlotId: this.gridHeaderCustomSlotId }, h("slot", { name: this.gridHeaderCustomSlotId }))), h("div", { class: "ez-col ez-col--sd-12" }, h("slot", { name: "SnkGridFooter" })), h("ez-modal", { modalSize: "small", closeEsc: false, closeOutsideClick: false, opened: this._popUpGridConfig, onEzCloseModal: () => this.closeGridConfig() }, h("snk-grid-config", { ref: ref => this._snkGridConfig = ref, config: this._gridConfig, "data-element-id": this._element.getAttribute(ElementIDUtils.DATA_ELEMENT_ID_ATTRIBUTE_NAME), selectedIndex: 0, configName: this.configName, onConfigChange: (evt) => this.modalConfigChangeHandler(evt), onConfigCancel: () => this.closeGridConfig(), resourceID: this.resourceID }))));
405
394
  }
406
395
  static get is() { return "snk-grid"; }
407
396
  static get encapsulation() { return "scoped"; }
@@ -1,9 +1,9 @@
1
- import { StringUtils, ElementIDUtils } from '@sankhyalabs/core';
1
+ import { StringUtils, ElementIDUtils, ApplicationContext } from '@sankhyalabs/core';
2
2
  import { ApplicationUtils, DialogType } from '@sankhyalabs/ezui/dist/collection/utils';
3
3
  import { CheckMode } from '@sankhyalabs/ezui/dist/collection/components/ez-check/CheckMode';
4
4
  import { h, Host } from '@stencil/core';
5
- import { ConfigStorage } from '../../../../lib/configs/ConfigStorage';
6
- import { ORDER_VALUES } from '../../../../lib/utils/constants';
5
+ import { ConfigStorage } from '../../lib/configs/ConfigStorage';
6
+ import { ORDER_VALUES } from '../../lib/utils/constants';
7
7
  export class SnkGridConfig {
8
8
  constructor() {
9
9
  this._orderListItems = [];
@@ -13,7 +13,6 @@ export class SnkGridConfig {
13
13
  this._dataChanged = false;
14
14
  this._componenteInternalKey = Date.now();
15
15
  this.selectedIndex = 0;
16
- this.application = undefined;
17
16
  this.columns = undefined;
18
17
  this.config = undefined;
19
18
  this.configName = undefined;
@@ -27,9 +26,10 @@ export class SnkGridConfig {
27
26
  * Para conhecer os detalhes do módulo, vide o arquivo neste projeto "/src/lib/message/resources/snk-grid.msg.ts"
28
27
  */
29
28
  getMessage(key, params) {
30
- return this.application.messagesBuilder.getMessage(key, params);
29
+ const application = ApplicationContext.getContextValue("__SNK__APPLICATION__");
30
+ return application.messagesBuilder.getMessage(key, params);
31
31
  }
32
- createOrderList() {
32
+ getSortableColumns() {
33
33
  let newList = [];
34
34
  this.columns.filter(col => { var _a; return StringUtils.getBooleanValue((_a = col === null || col === void 0 ? void 0 : col.props) === null || _a === void 0 ? void 0 : _a.get("sortable"), true); }).forEach((column) => {
35
35
  var _a;
@@ -43,7 +43,11 @@ export class SnkGridConfig {
43
43
  newList.push(item);
44
44
  }
45
45
  });
46
- newList.sort((a, b) => {
46
+ return newList;
47
+ }
48
+ createOrderList() {
49
+ let newSortableList = this.getSortableColumns();
50
+ newSortableList.sort((a, b) => {
47
51
  //OS dois tem order index 0 e pelo menos um deles tem orientação de ordenação.
48
52
  if (a.orderIndex == 0 && b.orderIndex == 0 && (a.ascending != undefined || b.ascending != undefined)) {
49
53
  if (a.ascending != undefined)
@@ -66,7 +70,7 @@ export class SnkGridConfig {
66
70
  }
67
71
  return (a.orderIndex - b.orderIndex);
68
72
  });
69
- this._orderListItems = newList;
73
+ this._orderListItems = newSortableList;
70
74
  }
71
75
  createColumnList() {
72
76
  let visibleGroup = {
@@ -89,12 +93,18 @@ export class SnkGridConfig {
89
93
  });
90
94
  this._columListItems = [visibleGroup, hiddenGroup];
91
95
  }
96
+ createColumnListSlotDataElementId(item) {
97
+ return `configItem_${StringUtils.replaceAccentuatedChars(StringUtils.toCamelCase(item.label))}`;
98
+ }
92
99
  buildColumnListSlot(item, group) {
93
- const dataElementId = `configItem_${StringUtils.replaceAccentuatedChars(StringUtils.toCamelCase(item.label))}`;
100
+ const dataElementId = this.createColumnListSlotDataElementId(item);
94
101
  return (h("div", null, h("ez-check", { mode: CheckMode.SWITCH, id: CheckMode.SWITCH + ((item === null || item === void 0 ? void 0 : item.label) || '') + ((group === null || group === void 0 ? void 0 : group.group) || ''), value: group.group === this.getMessage("snkGridConfig.group.visible"), "data-element-id": dataElementId, onEzChange: (evt) => { this.switchColumnGroup(evt, item); } })));
95
102
  }
103
+ createOrderListSlotDataElementId(item) {
104
+ return `${this._element.getAttribute(ElementIDUtils.DATA_ELEMENT_ID_ATTRIBUTE_NAME)}_configItem_${StringUtils.toCamelCase(item.label)}`;
105
+ }
96
106
  buildOrderListSlot(item) {
97
- const dataElementId = `${this._element.getAttribute(ElementIDUtils.DATA_ELEMENT_ID_ATTRIBUTE_NAME)}_configItem_${StringUtils.toCamelCase(item.label)}`;
107
+ const dataElementId = this.createOrderListSlotDataElementId(item);
98
108
  let selectedOption = ORDER_VALUES.none.value;
99
109
  if ((item === null || item === void 0 ? void 0 : item.ascending) != undefined) {
100
110
  selectedOption = item.ascending == true ? ORDER_VALUES.asc.value : ORDER_VALUES.desc.value;
@@ -112,7 +122,7 @@ export class SnkGridConfig {
112
122
  let orderArray;
113
123
  if (((_a = this._orderPriorityList) === null || _a === void 0 ? void 0 : _a.length) > 0) {
114
124
  this._orderPriorityList.find((item) => item.label === newItem.label).sort = sortOrder;
115
- this._orderPriorityList.filter((item) => item.sort).map((item, index) => {
125
+ this._orderPriorityList.filter((item) => item.sort).forEach((item, index) => {
116
126
  if (item.label === newItem.label) {
117
127
  newItem.sortIndex = index;
118
128
  }
@@ -181,6 +191,35 @@ export class SnkGridConfig {
181
191
  this.closeConfig();
182
192
  this.save();
183
193
  }
194
+ saveGridConfigOnStorage(_newConfig) {
195
+ ConfigStorage.saveGridConfig(_newConfig, this.configName, this.resourceID)
196
+ .then((savedConfig) => {
197
+ this.configChange.emit(savedConfig);
198
+ this._orderList.clearHistory();
199
+ ApplicationUtils.info(this.getMessage("snkGridConfig.info.successfullyConfigSaved"), { iconName: "check" });
200
+ });
201
+ }
202
+ reOrderPriorityColumns(columns, orderPriorityList) {
203
+ let orderArray = [];
204
+ orderArray = columns.filter((item) => item.sort && item.hidden !== true)
205
+ .map((item) => {
206
+ return { label: item.label, orderIndex: 0 };
207
+ });
208
+ let indexCount = 0;
209
+ let newOrderArray = [];
210
+ orderPriorityList.forEach((orderPriorityItem) => {
211
+ let item = orderArray.find((column) => column.label === orderPriorityItem.label);
212
+ if (item) {
213
+ item.orderIndex = indexCount;
214
+ newOrderArray.push(item);
215
+ indexCount++;
216
+ }
217
+ });
218
+ if (newOrderArray.length > 0) {
219
+ orderArray = newOrderArray;
220
+ }
221
+ return orderArray;
222
+ }
184
223
  save() {
185
224
  var _a;
186
225
  let _newConfig;
@@ -193,30 +232,12 @@ export class SnkGridConfig {
193
232
  let _newColumnConfigList = [];
194
233
  let orderArray;
195
234
  if (((_a = this._orderPriorityList) === null || _a === void 0 ? void 0 : _a.length) > 0) {
196
- orderArray = this.columns.filter((item) => item.sort && item.hidden !== true)
197
- .map((item) => {
198
- return { label: item.label, orderIndex: 0 };
199
- });
200
- let indexCount = 0;
201
- let newOrderArray = [];
202
- this._orderPriorityList.forEach((orderPriorityItem) => {
203
- let item = orderArray.find((column) => column.label === orderPriorityItem.label);
204
- if (item) {
205
- item.orderIndex = indexCount;
206
- newOrderArray.push(item);
207
- indexCount++;
208
- }
209
- });
210
- if (newOrderArray.length > 0) {
211
- orderArray = newOrderArray;
212
- }
235
+ orderArray = this.reOrderPriorityColumns(this.columns, this._orderPriorityList);
213
236
  }
214
- for (let i = 0; i < this.columns.length; i++) {
215
- const column = this.columns[i];
237
+ this.columns.forEach((column) => {
216
238
  let _newColumnConfig = _newConfig.columns.find((_newColumnConfig) => column.name === _newColumnConfig.name);
217
- if (column.hidden === true && _newColumnConfig) {
218
- continue;
219
- }
239
+ if (column.hidden === true && _newColumnConfig)
240
+ return;
220
241
  if (_newColumnConfig) {
221
242
  _newColumnConfig.width = column.width;
222
243
  }
@@ -239,14 +260,9 @@ export class SnkGridConfig {
239
260
  }
240
261
  _newColumnConfigList.push(_newColumnConfig);
241
262
  }
242
- }
243
- _newConfig.columns = _newColumnConfigList;
244
- ConfigStorage.saveGridConfig(_newConfig, this.configName, this.resourceID)
245
- .then((savedConfig) => {
246
- this.configChange.emit(savedConfig);
247
- this._orderList.clearHistory();
248
- ApplicationUtils.info(this.getMessage("snkGridConfig.info.successfullyConfigSaved"), { iconName: "check" });
249
263
  });
264
+ _newConfig.columns = _newColumnConfigList;
265
+ this.saveGridConfigOnStorage(_newConfig);
250
266
  function adjustPriorityOrder(column, _newColumnConfig) {
251
267
  if (orderArray) {
252
268
  let orderItem = orderArray.find((item) => item.label === column.label);
@@ -281,85 +297,96 @@ export class SnkGridConfig {
281
297
  async locateColumn(evt, searchingText) {
282
298
  var _a;
283
299
  const hitEnter = evt.key === "Enter";
300
+ searchingText = searchingText || ((_a = evt.currentTarget) === null || _a === void 0 ? void 0 : _a.value);
284
301
  if (!searchingText) {
285
- searchingText = (_a = evt.currentTarget) === null || _a === void 0 ? void 0 : _a.value;
302
+ this.removeSelection();
303
+ return;
286
304
  }
287
- let newSelected = -1;
305
+ const matchedIndexes = await this.getMatchedIndexes(searchingText);
306
+ const newSelected = this.getNewSelectedIndex(matchedIndexes, hitEnter);
307
+ this._selectedIndex = newSelected;
288
308
  if (this.selectedIndex === 1) {
289
- if (searchingText) {
290
- const matchedIndexes = [];
291
- let orderListDatasource;
292
- await this._orderList.getList().then((listGroup) => {
293
- orderListDatasource = listGroup;
294
- orderListDatasource.forEach((column, index) => {
295
- if (this.compareWords(column, searchingText)) {
296
- matchedIndexes.push(index);
297
- }
298
- });
299
- });
300
- if (matchedIndexes.length > 0) {
301
- if (hitEnter) {
302
- for (let j = 0; j < matchedIndexes.length; j++) {
303
- if (matchedIndexes[j] > this._selectedIndex) {
304
- newSelected = matchedIndexes[j];
305
- break;
306
- }
307
- }
308
- }
309
- if (newSelected === -1) {
310
- newSelected = matchedIndexes[0];
311
- }
309
+ this.updateOrderListSelection(newSelected);
310
+ }
311
+ else {
312
+ this.updateColumnListSelection(newSelected);
313
+ }
314
+ }
315
+ async getMatchedIndexes(searchingText) {
316
+ const matchedIndexes = [];
317
+ if (this.selectedIndex === 1) {
318
+ const orderListDatasource = await this._orderList.getList();
319
+ orderListDatasource.forEach((column, index) => {
320
+ if (this.compareWords(column, searchingText)) {
321
+ matchedIndexes.push(index);
312
322
  }
313
- this._selectedIndex = newSelected;
314
- let selectedColumn;
315
- selectedColumn = orderListDatasource[newSelected];
316
- if (selectedColumn) {
317
- this._orderList.setSelection(selectedColumn, true);
323
+ });
324
+ }
325
+ else {
326
+ this.columns.forEach((column, index) => {
327
+ if (this.compareWords(column, searchingText)) {
328
+ matchedIndexes.push(index);
318
329
  }
319
- else {
320
- this._orderList.removeSelection();
330
+ });
331
+ }
332
+ return matchedIndexes;
333
+ }
334
+ getNewSelectedIndex(matchedIndexes, hitEnter) {
335
+ if (matchedIndexes.length === 0)
336
+ return -1;
337
+ if (hitEnter) {
338
+ for (const index of matchedIndexes) {
339
+ if (index > this._selectedIndex) {
340
+ return index;
321
341
  }
322
342
  }
343
+ }
344
+ return matchedIndexes[0];
345
+ }
346
+ updateOrderListSelection(newSelected) {
347
+ if (newSelected === -1) {
348
+ this._orderList.removeSelection();
349
+ return;
350
+ }
351
+ this._orderList.getList().then((orderListDatasource) => {
352
+ const selectedColumn = orderListDatasource[newSelected];
353
+ if (selectedColumn) {
354
+ this._orderList.setSelection(selectedColumn, true);
355
+ }
323
356
  else {
324
357
  this._orderList.removeSelection();
325
358
  }
359
+ });
360
+ }
361
+ updateColumnListSelection(newSelected) {
362
+ if (newSelected === -1) {
363
+ this._columnList.removeSelection();
364
+ return;
326
365
  }
327
- else {
328
- if (searchingText) {
329
- const matchedIndexes = [];
330
- this.columns.forEach((column, index) => {
331
- if (this.compareWords(column, searchingText)) {
332
- matchedIndexes.push(index);
333
- }
334
- });
335
- if (matchedIndexes.length > 0) {
336
- if (hitEnter) {
337
- for (let j = 0; j < matchedIndexes.length; j++) {
338
- if (matchedIndexes[j] > this._selectedIndex) {
339
- newSelected = matchedIndexes[j];
340
- break;
341
- }
342
- }
343
- }
344
- if (newSelected === -1) {
345
- newSelected = matchedIndexes[0];
346
- }
347
- }
348
- this._selectedIndex = newSelected;
349
- let selectedColumn = this.columns[newSelected];
350
- if (selectedColumn) {
351
- const listItem = this._columListItems.map(group => group.items).flat().find(item => item.label === selectedColumn.label);
352
- if (listItem)
353
- this._columnList.setSelection(listItem, true);
354
- }
355
- else {
356
- this._columnList.removeSelection();
357
- }
366
+ const selectedColumn = this.columns[newSelected];
367
+ if (selectedColumn) {
368
+ const listItem = this._columListItems
369
+ .map(group => group.items)
370
+ .flat()
371
+ .find(item => item.label === selectedColumn.label);
372
+ if (listItem) {
373
+ this._columnList.setSelection(listItem, true);
358
374
  }
359
375
  else {
360
376
  this._columnList.removeSelection();
361
377
  }
362
378
  }
379
+ else {
380
+ this._columnList.removeSelection();
381
+ }
382
+ }
383
+ removeSelection() {
384
+ if (this.selectedIndex === 1) {
385
+ this._orderList.removeSelection();
386
+ }
387
+ else {
388
+ this._columnList.removeSelection();
389
+ }
363
390
  }
364
391
  compareWords(column, searchingText) {
365
392
  var _a, _b;
@@ -493,26 +520,6 @@ export class SnkGridConfig {
493
520
  "reflect": false,
494
521
  "defaultValue": "0"
495
522
  },
496
- "application": {
497
- "type": "unknown",
498
- "mutable": false,
499
- "complexType": {
500
- "original": "SnkApplication",
501
- "resolved": "SnkApplication",
502
- "references": {
503
- "SnkApplication": {
504
- "location": "import",
505
- "path": "../../../snk-application/snk-application"
506
- }
507
- }
508
- },
509
- "required": false,
510
- "optional": false,
511
- "docs": {
512
- "tags": [],
513
- "text": "Refer\u00EAncia para o SnkApplication"
514
- }
515
- },
516
523
  "columns": {
517
524
  "type": "unknown",
518
525
  "mutable": true,
@@ -1,5 +1,5 @@
1
1
  import { h } from '@stencil/core';
2
- import { ORDER_VALUES } from '../../../../lib/utils/constants';
2
+ import { ORDER_VALUES } from '../../../lib/utils/constants';
3
3
  export class SelectBox {
4
4
  constructor() {
5
5
  this.selectedOption = ORDER_VALUES.none;
@@ -16,6 +16,11 @@
16
16
  flex-wrap: unset;
17
17
  flex-direction: column;
18
18
  }
19
+
20
+ .simple-crud__form--hidden {
21
+ display: none;
22
+ }
23
+
19
24
  ez-grid {
20
25
  --ez-grid__container--shadow: none;
21
26
  min-height: 300px;