@sankhyalabs/sankhyablocks 8.16.0-dev.5 → 8.16.0-dev.7

Sign up to get free protection for your applications and to get access to all the features.
Files changed (72) hide show
  1. package/dist/cjs/{ConfigStorage-942ce74b.js → ConfigStorage-a343e418.js} +1 -0
  2. package/dist/cjs/{SnkFormConfigManager-26dfc762.js → SnkFormConfigManager-166cbd1f.js} +1 -1
  3. package/dist/cjs/loader.cjs.js +1 -1
  4. package/dist/cjs/sankhyablocks.cjs.js +1 -1
  5. package/dist/cjs/snk-actions-button_4.cjs.entry.js +1 -1
  6. package/dist/cjs/snk-application.cjs.entry.js +1 -1
  7. package/dist/cjs/snk-crud.cjs.entry.js +2 -0
  8. package/dist/cjs/snk-data-exporter.cjs.entry.js +1 -1
  9. package/dist/cjs/{snk-data-unit-685272e7.js → snk-data-unit-04df81bf.js} +15 -5
  10. package/dist/cjs/snk-data-unit.cjs.entry.js +1 -1
  11. package/dist/cjs/snk-detail-view.cjs.entry.js +3 -3
  12. package/dist/cjs/snk-filter-bar.cjs.entry.js +1 -1
  13. package/dist/cjs/snk-filter-modal-item.cjs.entry.js +1 -1
  14. package/dist/cjs/snk-form.cjs.entry.js +2 -2
  15. package/dist/cjs/snk-grid.cjs.entry.js +1 -1
  16. package/dist/cjs/{snk-guides-viewer-28122419.js → snk-guides-viewer-bdc41281.js} +1 -1
  17. package/dist/cjs/snk-guides-viewer.cjs.entry.js +3 -3
  18. package/dist/cjs/snk-personalized-filter.cjs.entry.js +1 -1
  19. package/dist/cjs/snk-simple-crud.cjs.entry.js +5 -3
  20. package/dist/collection/components/snk-crud/snk-crud.js +19 -0
  21. package/dist/collection/components/snk-data-unit/snk-data-unit.js +32 -5
  22. package/dist/collection/components/snk-simple-crud/snk-simple-crud.js +38 -1
  23. package/dist/collection/lib/configs/ConfigStorage.js +1 -0
  24. package/dist/components/ConfigStorage.js +1 -0
  25. package/dist/components/snk-crud.js +3 -0
  26. package/dist/components/snk-data-unit2.js +16 -5
  27. package/dist/components/snk-simple-crud2.js +4 -1
  28. package/dist/esm/{ConfigStorage-86187da3.js → ConfigStorage-3806514e.js} +1 -0
  29. package/dist/esm/{SnkFormConfigManager-5782d6cf.js → SnkFormConfigManager-31b24066.js} +1 -1
  30. package/dist/esm/loader.js +1 -1
  31. package/dist/esm/sankhyablocks.js +1 -1
  32. package/dist/esm/snk-actions-button_4.entry.js +1 -1
  33. package/dist/esm/snk-application.entry.js +1 -1
  34. package/dist/esm/snk-crud.entry.js +2 -0
  35. package/dist/esm/snk-data-exporter.entry.js +1 -1
  36. package/dist/esm/{snk-data-unit-63f83504.js → snk-data-unit-8eec78bd.js} +15 -5
  37. package/dist/esm/snk-data-unit.entry.js +1 -1
  38. package/dist/esm/snk-detail-view.entry.js +3 -3
  39. package/dist/esm/snk-filter-bar.entry.js +1 -1
  40. package/dist/esm/snk-filter-modal-item.entry.js +1 -1
  41. package/dist/esm/snk-form.entry.js +2 -2
  42. package/dist/esm/snk-grid.entry.js +1 -1
  43. package/dist/esm/{snk-guides-viewer-7460fe10.js → snk-guides-viewer-dda0fede.js} +1 -1
  44. package/dist/esm/snk-guides-viewer.entry.js +3 -3
  45. package/dist/esm/snk-personalized-filter.entry.js +1 -1
  46. package/dist/esm/snk-simple-crud.entry.js +5 -3
  47. package/dist/sankhyablocks/{p-82a0bfb0.entry.js → p-045eae4d.entry.js} +1 -1
  48. package/dist/sankhyablocks/{p-f4d7fa81.js → p-2a408684.js} +1 -1
  49. package/dist/sankhyablocks/{p-eae7a817.entry.js → p-2c68b3ae.entry.js} +1 -1
  50. package/dist/sankhyablocks/p-46d38387.entry.js +1 -0
  51. package/dist/sankhyablocks/{p-a1d72395.entry.js → p-47db7e88.entry.js} +1 -1
  52. package/dist/sankhyablocks/{p-bad55caa.entry.js → p-4e5e1313.entry.js} +1 -1
  53. package/dist/sankhyablocks/{p-aff76a53.js → p-52920496.js} +1 -1
  54. package/dist/sankhyablocks/{p-941bf3ef.entry.js → p-547eeac8.entry.js} +1 -1
  55. package/dist/sankhyablocks/{p-b8d06bb3.entry.js → p-62ba211a.entry.js} +1 -1
  56. package/dist/sankhyablocks/{p-f1b31208.entry.js → p-75e674ed.entry.js} +1 -1
  57. package/dist/sankhyablocks/{p-3a216b81.entry.js → p-7a85fd49.entry.js} +1 -1
  58. package/dist/sankhyablocks/{p-c5268346.entry.js → p-7b08d0f8.entry.js} +1 -1
  59. package/dist/sankhyablocks/p-b05d8893.entry.js +1 -0
  60. package/dist/sankhyablocks/{p-17359530.entry.js → p-c1d57831.entry.js} +1 -1
  61. package/dist/sankhyablocks/{p-47b60deb.entry.js → p-d6e26ea8.entry.js} +1 -1
  62. package/dist/sankhyablocks/p-e549f7d1.js +1 -0
  63. package/dist/sankhyablocks/{p-f51acb38.js → p-fa4d8cb4.js} +1 -1
  64. package/dist/sankhyablocks/sankhyablocks.esm.js +1 -1
  65. package/dist/types/components/snk-crud/snk-crud.d.ts +4 -0
  66. package/dist/types/components/snk-data-unit/snk-data-unit.d.ts +5 -0
  67. package/dist/types/components/snk-simple-crud/snk-simple-crud.d.ts +8 -0
  68. package/dist/types/components.d.ts +24 -0
  69. package/package.json +1 -1
  70. package/dist/sankhyablocks/p-75f83d1d.entry.js +0 -1
  71. package/dist/sankhyablocks/p-c640163b.entry.js +0 -1
  72. package/dist/sankhyablocks/p-fcac4dfc.js +0 -1
@@ -59,6 +59,7 @@ const SnkDataUnit = class {
59
59
  this.ignoreSaveMessage = undefined;
60
60
  this.configName = undefined;
61
61
  this.resourceID = undefined;
62
+ this.domainMessagesBuilder = undefined;
62
63
  }
63
64
  observePageSize() {
64
65
  if (this.dataUnit) {
@@ -475,7 +476,8 @@ const SnkDataUnit = class {
475
476
  if (this.ignoreSaveMessage) {
476
477
  return;
477
478
  }
478
- const msg = this.getMessage("snkDataUnit.saveInfo", action.payload.records[0]);
479
+ const saveOperation = action.payload.changes[0]._operation.toLowerCase();
480
+ const msg = this.getMessage("snkDataUnit.saveInfo", action.payload.records[0], saveOperation);
479
481
  if (msg != undefined) {
480
482
  this.showSuccessMessage(msg);
481
483
  }
@@ -506,10 +508,13 @@ const SnkDataUnit = class {
506
508
  * - Criar um arquivo no seguinte caminho: /messages/appmessages.msg.js.
507
509
  * Para conhecer os detalhes do módulo, vide o arquivo neste projeto "/src/lib/message/resources/snk-data-unit.msg.ts"
508
510
  */
509
- getMessage(key, params = undefined) {
511
+ getMessage(key, params = undefined, customOperation) {
510
512
  if (!params) {
511
513
  params = this.getMessageParams();
512
514
  }
515
+ if (customOperation) {
516
+ this.messagesBuilder.currentOperation = customOperation;
517
+ }
513
518
  return this.messagesBuilder.getMessage(key, params);
514
519
  }
515
520
  getMessageParams() {
@@ -616,6 +621,13 @@ const SnkDataUnit = class {
616
621
  parent = parent.parentElement;
617
622
  }
618
623
  }
624
+ instanceMessagesBuilder() {
625
+ var _a, _b;
626
+ if (this.messagesBuilder) {
627
+ return;
628
+ }
629
+ this.messagesBuilder = new SnkMessageBuilder((_b = (_a = this.domainMessagesBuilder) !== null && _a !== void 0 ? _a : this.entityName) !== null && _b !== void 0 ? _b : 'InMemoryDomain');
630
+ }
619
631
  //---------------------------------------------
620
632
  // Lifecycle web component
621
633
  //---------------------------------------------
@@ -623,9 +635,7 @@ const SnkDataUnit = class {
623
635
  this._application = ApplicationContext.getContextValue("__SNK__APPLICATION__");
624
636
  this._application.getAllAccess(this.resourceID).then(access => this._permissions = access);
625
637
  this._parentSnkDataUnit = this.getParentSnkDataUnit();
626
- if (this.messagesBuilder == undefined) {
627
- this.messagesBuilder = new SnkMessageBuilder(this.entityName);
628
- }
638
+ this.instanceMessagesBuilder();
629
639
  }
630
640
  disconnectedCallback() {
631
641
  if (this.dataUnit) {
@@ -1,4 +1,4 @@
1
- export { S as snk_data_unit } from './snk-data-unit-63f83504.js';
1
+ export { S as snk_data_unit } from './snk-data-unit-8eec78bd.js';
2
2
  import './index-a7d3d3f1.js';
3
3
  import '@sankhyalabs/core';
4
4
  import '@sankhyalabs/ezui/dist/collection/utils';
@@ -1,6 +1,6 @@
1
1
  import { r as registerInstance, c as createEvent, f as forceUpdate, h, H as Host } from './index-a7d3d3f1.js';
2
2
  import { Action } from '@sankhyalabs/core';
3
- import { S as SnkFormConfigManager } from './SnkFormConfigManager-5782d6cf.js';
3
+ import { S as SnkFormConfigManager } from './SnkFormConfigManager-31b24066.js';
4
4
  import { FormMetadata, buildFormMetadata } from '@sankhyalabs/ezui/dist/collection/utils/form';
5
5
  import './DataFetcher-c1baf61d.js';
6
6
  import './pesquisa-fetcher-03c8f919.js';
@@ -13,9 +13,9 @@ import './filter-item-type.enum-d45e026f.js';
13
13
  import './form-config-fetcher-30fb808f.js';
14
14
  import { T as TaskbarElement } from './taskbar-elements-d59867f1.js';
15
15
  import { d as VIEW_MODE } from './constants-8457af36.js';
16
- import { S as SnkGuidesViewer } from './snk-guides-viewer-7460fe10.js';
16
+ import { S as SnkGuidesViewer } from './snk-guides-viewer-dda0fede.js';
17
17
  import { S as SnkMessageBuilder } from './SnkMessageBuilder-89925609.js';
18
- import './ConfigStorage-86187da3.js';
18
+ import './ConfigStorage-3806514e.js';
19
19
  import './PrintUtils-3e4ff0f5.js';
20
20
  import '@sankhyalabs/ezui/dist/collection/components/ez-grid/utils';
21
21
  import '@sankhyalabs/core/dist/utils/SortingUtils';
@@ -1,7 +1,7 @@
1
1
  import { r as registerInstance, c as createEvent, h, H as Host, g as getElement } from './index-a7d3d3f1.js';
2
2
  import { DataType, StringUtils, ObjectUtils, ElementIDUtils, ErrorException, ApplicationContext } from '@sankhyalabs/core';
3
3
  import { EzScrollDirection } from '@sankhyalabs/ezui/dist/collection/components/ez-scroller/EzScrollDirection';
4
- import { C as ConfigStorage } from './ConfigStorage-86187da3.js';
4
+ import { C as ConfigStorage } from './ConfigStorage-3806514e.js';
5
5
  import { toString } from '@sankhyalabs/core/dist/dataunit/metadata/DataType';
6
6
  import { F as FilterItemType } from './filter-item-type.enum-d45e026f.js';
7
7
  import { F as FilterOperand } from './index-ae591a44.js';
@@ -2,7 +2,7 @@ import { r as registerInstance, c as createEvent, h, H as Host, g as getElement
2
2
  import { ElementIDUtils, ObjectUtils } from '@sankhyalabs/core';
3
3
  import { F as FilterItemType } from './filter-item-type.enum-d45e026f.js';
4
4
  import { E as EPresentationMode } from './presentationMode-783bbf9d.js';
5
- import { C as ConfigStorage } from './ConfigStorage-86187da3.js';
5
+ import { C as ConfigStorage } from './ConfigStorage-3806514e.js';
6
6
  import { F as FilterType } from './filter-type.enum-a80c1b6b.js';
7
7
  import './form-config-fetcher-30fb808f.js';
8
8
  import './DataFetcher-c1baf61d.js';
@@ -1,8 +1,8 @@
1
1
  import { r as registerInstance, c as createEvent, h, g as getElement } from './index-a7d3d3f1.js';
2
2
  import { ElementIDUtils } from '@sankhyalabs/core';
3
- import { S as SnkFormConfigManager } from './SnkFormConfigManager-5782d6cf.js';
3
+ import { S as SnkFormConfigManager } from './SnkFormConfigManager-31b24066.js';
4
4
  import { R as ResourceIDUtils } from './ResourceIDUtils-a114189a.js';
5
- import './ConfigStorage-86187da3.js';
5
+ import './ConfigStorage-3806514e.js';
6
6
  import './form-config-fetcher-30fb808f.js';
7
7
  import './DataFetcher-c1baf61d.js';
8
8
  import './PrintUtils-3e4ff0f5.js';
@@ -1,7 +1,7 @@
1
1
  import { r as registerInstance, c as createEvent, h, F as Fragment, g as getElement } from './index-a7d3d3f1.js';
2
2
  import { Action, ElementIDUtils, ApplicationContext, StringUtils } from '@sankhyalabs/core';
3
3
  import { T as TaskbarElement } from './taskbar-elements-d59867f1.js';
4
- import { C as ConfigStorage } from './ConfigStorage-86187da3.js';
4
+ import { C as ConfigStorage } from './ConfigStorage-3806514e.js';
5
5
  import { P as PresentationMode } from './index-3aa4977a.js';
6
6
  import { T as TaskbarProcessor, o as openFieldSearch, b as buildFieldSearch } from './field-search-efbe307f.js';
7
7
  import { s as store } from './index-bdf75557.js';
@@ -1,6 +1,6 @@
1
1
  import { r as registerInstance, c as createEvent, h, F as Fragment } from './index-a7d3d3f1.js';
2
2
  import { Action, ElementIDUtils } from '@sankhyalabs/core';
3
- import { S as SnkFormConfigManager } from './SnkFormConfigManager-5782d6cf.js';
3
+ import { S as SnkFormConfigManager } from './SnkFormConfigManager-31b24066.js';
4
4
  import { buildFormMetadata, FormMetadata } from '@sankhyalabs/ezui/dist/collection/utils/form';
5
5
  import { o as openFieldSearch, T as TaskbarProcessor, b as buildFieldSearch } from './field-search-efbe307f.js';
6
6
  import { T as TaskbarElement } from './taskbar-elements-d59867f1.js';
@@ -1,8 +1,8 @@
1
- export { S as snk_guides_viewer } from './snk-guides-viewer-7460fe10.js';
1
+ export { S as snk_guides_viewer } from './snk-guides-viewer-dda0fede.js';
2
2
  import './index-a7d3d3f1.js';
3
3
  import '@sankhyalabs/core';
4
- import './SnkFormConfigManager-5782d6cf.js';
5
- import './ConfigStorage-86187da3.js';
4
+ import './SnkFormConfigManager-31b24066.js';
5
+ import './ConfigStorage-3806514e.js';
6
6
  import './form-config-fetcher-30fb808f.js';
7
7
  import './DataFetcher-c1baf61d.js';
8
8
  import './PrintUtils-3e4ff0f5.js';
@@ -1,7 +1,7 @@
1
1
  import { r as registerInstance, c as createEvent, h, F as Fragment, H as Host } from './index-a7d3d3f1.js';
2
2
  import { StringUtils, ObjectUtils, ApplicationContext, ElementIDUtils } from '@sankhyalabs/core';
3
3
  import { P as PersonalizedFilterUtils } from './PersonalizedFilterUtils-e2b38ef7.js';
4
- import { P as PersonalizedFilterFetcher, C as ConfigStorage } from './ConfigStorage-86187da3.js';
4
+ import { P as PersonalizedFilterFetcher, C as ConfigStorage } from './ConfigStorage-3806514e.js';
5
5
  import { ApplicationUtils } from '@sankhyalabs/ezui/dist/collection/utils';
6
6
  import { a as FilterGroupCondition } from './index-ae591a44.js';
7
7
  import { s as store } from './index-bdf75557.js';
@@ -14,8 +14,8 @@ import { I as InMemoryLoader } from './dataunit-fetcher-264191b2.js';
14
14
  import './filter-item-type.enum-d45e026f.js';
15
15
  import { F as FormConfigFetcher } from './form-config-fetcher-30fb808f.js';
16
16
  import { T as TaskbarProcessor, b as buildFieldSearch, o as openFieldSearch } from './field-search-efbe307f.js';
17
- import { C as ConfigStorage } from './ConfigStorage-86187da3.js';
18
- import { S as SnkFormConfigManager } from './SnkFormConfigManager-5782d6cf.js';
17
+ import { C as ConfigStorage } from './ConfigStorage-3806514e.js';
18
+ import { S as SnkFormConfigManager } from './SnkFormConfigManager-31b24066.js';
19
19
  import { g as getSelectedIDs } from './RecordIDUtils-87d02110.js';
20
20
  import { s as store } from './index-bdf75557.js';
21
21
  import './PrintUtils-3e4ff0f5.js';
@@ -133,6 +133,8 @@ const SnkSimpleCrud = class {
133
133
  this.formLegacyConfigName = undefined;
134
134
  this.ignoreReadOnlyFormFields = false;
135
135
  this.autoFocus = true;
136
+ this.domainMessagesBuilder = undefined;
137
+ this.domainMessagesBuilder = 'InMemoryDomain';
136
138
  this.autoLoad = undefined;
137
139
  }
138
140
  /**
@@ -769,7 +771,7 @@ const SnkSimpleCrud = class {
769
771
  if (this.dataUnit == undefined) {
770
772
  return;
771
773
  }
772
- return (h("snk-data-unit", { ref: ref => this._snkDataUnit = ref, class: "simple-crud__container", dataUnit: this.dataUnit, useCancelConfirm: this.useCancelConfirm, onDataStateChange: evt => this.onDataStateChange(evt), onCancelEdition: this.handleCancelEdit.bind(this), pageSize: this.getPageSize(), onInsertionMode: () => this.goToView(VIEW_MODE.FORM), onDataUnitReady: (evt) => this.dataUnitReady.emit(evt.detail), ignoreSaveMessage: this._currentViewMode === VIEW_MODE.GRID, onMessagesBuilderUpdated: evt => this.messagesBuilder = evt.detail, onDataUnitFieldsHidded: this.updateFormConfig.bind(this) }, h("header", null, h("slot", { name: "snkSimpleCrudHeader" })), h("section", { class: "ez-box ez-box--shadow simple-crud__container-section" }, h("snk-taskbar", { class: "ez-box ez-box--shadow ez-padding--medium", dataUnit: this.dataUnit, primaryButton: ((_a = this.dataState) === null || _a === void 0 ? void 0 : _a.isDirty) ? "SAVE" : "INSERT", "data-element-id": "grid_left", messagesBuilder: this.messagesBuilder, buttons: this._taskbarProcessor.buttons, actionsList: this.getActionsList(), disabledButtons: this._taskbarProcessor.disabledButtons, customButtons: this._taskbarProcessor.customButtons, "data-exporter-store-key": this.getDataExporterStoreKey(), slot: "leftButtons", presentationMode: PresentationMode.SECONDARY }, h("slot", { name: "TASKBAR_CUSTOM_ELEMENTS" })), h("ez-view-stack", { ref: (ref) => this._viewStack = ref, "data-element-id": "simple-crud" }, h("stack-item", null, h("ez-grid", { class: "ez-margin-bottom--large", ref: ref => this._grid = ref, dataUnit: this.dataUnit, config: this.gridConfig, "no-header": true, multipleSelection: this.multipleSelection, onEzDoubleClick: () => this.goToView(VIEW_MODE.FORM), onConfigChange: evt => this.gridConfigChangeHandler(evt), columnfilterDataSource: this.dataUnit.name && this.dataUnit.name.includes(InMemoryLoader.IN_MEMORY_DATA_UNIT_NAME)
774
+ return (h("snk-data-unit", { ref: ref => this._snkDataUnit = ref, class: "simple-crud__container", dataUnit: this.dataUnit, useCancelConfirm: this.useCancelConfirm, onDataStateChange: evt => this.onDataStateChange(evt), onCancelEdition: this.handleCancelEdit.bind(this), pageSize: this.getPageSize(), onInsertionMode: () => this.goToView(VIEW_MODE.FORM), onDataUnitReady: (evt) => this.dataUnitReady.emit(evt.detail), ignoreSaveMessage: this._currentViewMode === VIEW_MODE.GRID, onMessagesBuilderUpdated: evt => this.messagesBuilder = evt.detail, onDataUnitFieldsHidded: this.updateFormConfig.bind(this), domainMessagesBuilder: this.domainMessagesBuilder }, h("header", null, h("slot", { name: "snkSimpleCrudHeader" })), h("section", { class: "ez-box ez-box--shadow simple-crud__container-section" }, h("snk-taskbar", { class: "ez-box ez-box--shadow ez-padding--medium", dataUnit: this.dataUnit, primaryButton: ((_a = this.dataState) === null || _a === void 0 ? void 0 : _a.isDirty) ? "SAVE" : "INSERT", "data-element-id": "grid_left", messagesBuilder: this.messagesBuilder, buttons: this._taskbarProcessor.buttons, actionsList: this.getActionsList(), disabledButtons: this._taskbarProcessor.disabledButtons, customButtons: this._taskbarProcessor.customButtons, "data-exporter-store-key": this.getDataExporterStoreKey(), slot: "leftButtons", presentationMode: PresentationMode.SECONDARY }, h("slot", { name: "TASKBAR_CUSTOM_ELEMENTS" })), h("ez-view-stack", { ref: (ref) => this._viewStack = ref, "data-element-id": "simple-crud" }, h("stack-item", null, h("ez-grid", { class: "ez-margin-bottom--large", ref: ref => this._grid = ref, dataUnit: this.dataUnit, config: this.gridConfig, "no-header": true, multipleSelection: this.multipleSelection, onEzDoubleClick: () => this.goToView(VIEW_MODE.FORM), onConfigChange: evt => this.gridConfigChangeHandler(evt), columnfilterDataSource: this.dataUnit.name && this.dataUnit.name.includes(InMemoryLoader.IN_MEMORY_DATA_UNIT_NAME)
773
775
  ? undefined
774
776
  : this._multiSelectionListDataSource, useEnterLikeTab: this.useEnterLikeTab, autoFocus: this.autoFocus }, h("div", { slot: "footer" }, h("slot", { name: "snkSimpleCrudFooter" })))), h("stack-item", null, h("ez-form", { ref: (ref) => this._form = ref, class: `ez-margin-top--large ${this.handleShowFormConfig() ? "simple-crud__form--hidden" : ""}`, dataUnit: this.dataUnit, config: this.getFormConfig(), fieldToFocus: this._fieldToGetFocus, onEzFormSetFields: (evt) => this.handleFormSetFields(evt.detail), onEzFormRequestClearFieldToFocus: this.clearFieldToFocusHandler.bind(this) }), this.handleShowFormConfig() && h("snk-form-config", { messagesBuilder: this.messagesBuilder, dataUnit: this.dataUnit, configManager: this._formConfigManager, onConfigClose: () => this.closeFormConfig() })), this.messagesBuilder && h("snk-configurator", { ref: (ref) => this._snkConfigurator = ref, viewMode: this._currentViewMode, messagesBuilder: this.messagesBuilder, onConfigSelected: (evt) => this.goToView(evt.detail), onOpenConfig: (evt) => this.openConfig(evt.detail), showActionButtons: this.showConfiguratorButtons, onSave: evt => this.handleConfiguratorEvent(evt, 'SAVE'), onCancel: evt => this.handleConfiguratorEvent(evt, 'CANCEL'), resourceID: this.resolveResourceID(), customContainerId: this._customContainerId })), h("div", { id: `${this._customContainerId}` }, h("slot", { name: "SnkConfigContainerSlot" }))), h("ez-modal", { modalSize: "small", closeEsc: false, closeOutsideClick: false, opened: this._showPopUpGridConfig, 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.resolveResourceID() }))));
775
777
  }
@@ -1,4 +1,4 @@
1
- import{r as t,c as s,h as e,g as i}from"./p-d2d301a6.js";import{DateUtils as n,StringUtils as r,ObjectUtils as o,WaitingChangeException as a,WarningException as c,ErrorException as h,KeyboardManager as l,OnboardingUtils as u,DependencyType as p,ArrayUtils as d,SearchUtils as w,ElementIDUtils as m,ApplicationContext as f,DataType as y,ErrorTracking as P}from"@sankhyalabs/core";import{ApplicationUtils as v}from"@sankhyalabs/ezui/dist/collection/utils";import{C as g}from"./p-aff76a53.js";import{d as _,D as A,U as I}from"./p-dc7c9047.js";import{A as S,a as C}from"./p-913a9979.js";import{D as N}from"./p-fe79f83a.js";import{P as b}from"./p-af8efd95.js";import{S as L}from"./p-7a337364.js";import"./p-df5451c7.js";import"./p-ff1990ad.js";import"./p-8d884fab.js";import"@sankhyalabs/core/dist/dataunit/metadata/UnitMetadata";import"@sankhyalabs/ezui/dist/collection/utils/constants";import"@sankhyalabs/ezui/dist/collection/components/ez-grid/utils";import"@sankhyalabs/core/dist/utils/SortingUtils";import"./p-688dcb4c.js";class D{static webConnectionCaller(t,s,e){var i;null===(i=window.AppletCaller)||void 0===i||i.webConnectionCaller(t,s,e)}}const T=k;function k(t,s){const e=E();return(k=function(t){return e[t-=378]})(t,s)}function E(){const t=["true","863GKWjmo","parse","56355fjjjAm","isSup","putAccess","4324480sjuCdS","hasOwnProperty","239748okvJLB","name","6055770tXeRaU","actions","forEach","7RPRvzn","1042CHxkUw","2988126NIwRMm","20MTNzmH","authorizationSf","item","string","hasAccess","isArray","Objeto não pode ser indefinido.","3071943fWslZp","parseFromJSON"];return(E=function(){return t})()}!function(){const t=k,s=E();for(;;)try{if(281287==parseInt(t(399))/1*(-parseInt(t(387))/2)+-parseInt(t(401))/3+parseInt(t(381))/4*(-parseInt(t(389))/5)+parseInt(t(388))/6*(-parseInt(t(386))/7)+parseInt(t(379))/8+parseInt(t(396))/9+parseInt(t(383))/10)break;s.push(s.shift())}catch(t){s.push(s.shift())}}();class O{[T(397)](t){const s=T;if(typeof(t=utxt(t[s(390)]))==s(392)&&(t=JSON[s(400)](t)),null==t)throw Error(s(395));const e=new U("S"===t[s(402)]||!0===t[s(402)]);return Array[s(394)](t[s(391)])&&t[s(391)][s(385)]((t=>e.putAccess(t[s(382)],String(t.status)==s(398)))),e}}class U{constructor(t){const s=T;this.isSup=t,this[s(384)]={}}[T(378)](t,s){this[T(384)][t]=s}[T(393)](t){const s=T;if(this[s(402)])return!0;let e=!0;return this[s(384)][s(380)](t)&&(e=this.actions[t]),e}isUserSup(){return this.isSup}}class j{constructor(){this._embeddedParams=new Map,this.templateByQuery=new Map;try{if(null!=window.MGE_PARAMS){atob(window.MGE_PARAMS).split("__;__").forEach((t=>{const[s,e]=t.split("__=__");this._embeddedParams.set(s,e)}))}}catch(t){console.error("Problemas ao obter parâmetros embarcados"),console.error(t)}this.buldTemplates()}buldTemplates(){this.templateByQuery.set("fetchParam",_.gql`query($name: String!) {
1
+ import{r as t,c as s,h as e,g as i}from"./p-d2d301a6.js";import{DateUtils as n,StringUtils as r,ObjectUtils as o,WaitingChangeException as a,WarningException as c,ErrorException as h,KeyboardManager as l,OnboardingUtils as u,DependencyType as p,ArrayUtils as d,SearchUtils as w,ElementIDUtils as m,ApplicationContext as f,DataType as y,ErrorTracking as P}from"@sankhyalabs/core";import{ApplicationUtils as v}from"@sankhyalabs/ezui/dist/collection/utils";import{C as g}from"./p-52920496.js";import{d as _,D as A,U as I}from"./p-dc7c9047.js";import{A as S,a as C}from"./p-913a9979.js";import{D as N}from"./p-fe79f83a.js";import{P as b}from"./p-af8efd95.js";import{S as L}from"./p-7a337364.js";import"./p-df5451c7.js";import"./p-ff1990ad.js";import"./p-8d884fab.js";import"@sankhyalabs/core/dist/dataunit/metadata/UnitMetadata";import"@sankhyalabs/ezui/dist/collection/utils/constants";import"@sankhyalabs/ezui/dist/collection/components/ez-grid/utils";import"@sankhyalabs/core/dist/utils/SortingUtils";import"./p-688dcb4c.js";class D{static webConnectionCaller(t,s,e){var i;null===(i=window.AppletCaller)||void 0===i||i.webConnectionCaller(t,s,e)}}const T=k;function k(t,s){const e=E();return(k=function(t){return e[t-=378]})(t,s)}function E(){const t=["true","863GKWjmo","parse","56355fjjjAm","isSup","putAccess","4324480sjuCdS","hasOwnProperty","239748okvJLB","name","6055770tXeRaU","actions","forEach","7RPRvzn","1042CHxkUw","2988126NIwRMm","20MTNzmH","authorizationSf","item","string","hasAccess","isArray","Objeto não pode ser indefinido.","3071943fWslZp","parseFromJSON"];return(E=function(){return t})()}!function(){const t=k,s=E();for(;;)try{if(281287==parseInt(t(399))/1*(-parseInt(t(387))/2)+-parseInt(t(401))/3+parseInt(t(381))/4*(-parseInt(t(389))/5)+parseInt(t(388))/6*(-parseInt(t(386))/7)+parseInt(t(379))/8+parseInt(t(396))/9+parseInt(t(383))/10)break;s.push(s.shift())}catch(t){s.push(s.shift())}}();class O{[T(397)](t){const s=T;if(typeof(t=utxt(t[s(390)]))==s(392)&&(t=JSON[s(400)](t)),null==t)throw Error(s(395));const e=new U("S"===t[s(402)]||!0===t[s(402)]);return Array[s(394)](t[s(391)])&&t[s(391)][s(385)]((t=>e.putAccess(t[s(382)],String(t.status)==s(398)))),e}}class U{constructor(t){const s=T;this.isSup=t,this[s(384)]={}}[T(378)](t,s){this[T(384)][t]=s}[T(393)](t){const s=T;if(this[s(402)])return!0;let e=!0;return this[s(384)][s(380)](t)&&(e=this.actions[t]),e}isUserSup(){return this.isSup}}class j{constructor(){this._embeddedParams=new Map,this.templateByQuery=new Map;try{if(null!=window.MGE_PARAMS){atob(window.MGE_PARAMS).split("__;__").forEach((t=>{const[s,e]=t.split("__=__");this._embeddedParams.set(s,e)}))}}catch(t){console.error("Problemas ao obter parâmetros embarcados"),console.error(t)}this.buldTemplates()}buldTemplates(){this.templateByQuery.set("fetchParam",_.gql`query($name: String!) {
2
2
  $queryAlias$: fetchResource(name: $name){
3
3
  name
4
4
  resource
@@ -1 +1 @@
1
- import{C as t}from"./p-aff76a53.js";import{ObjectUtils as e,StringUtils as i}from"@sankhyalabs/core";import{F as s}from"./p-df5451c7.js";class r{constructor(t,e,i){this._resourceID=e,this._configName=t,this._onConfigChange=i}addFormLegacyConfig(e){this._configName&&t.addFormLegacyConfig(this._configName,e)}async loadConfig(){return new Promise((e=>{t.loadFormConfig(this._configName,this._resourceID).then((t=>{this.setConfig(t),e(t)})).catch((t=>{console.warn(t)}))}))}saveConfig(i){const s=e.copy(i);return new Promise((e=>{t.saveFormConfig(i,this._configName,this._resourceID).then((t=>{this.setConfig(Object.assign(Object.assign({},s),t)),e(Object.assign(Object.assign({},s),t))}))}))}saveCardState(e,i,s){return new Promise((r=>{var n;const l=(null===(n=this._config)||void 0===n?void 0:n.cardsState)||new Map,a=l.get(e);l.set(e,"fixed"===s?this.updateFixSequence(Object.assign(Object.assign({},a),{fixed:i.fixed}),l):Object.assign(Object.assign({},a),{[s]:i[s]})),t.saveCardState(l,this._configName,this._resourceID).then((t=>{this._config=Object.assign(Object.assign({},this._config),{cardsState:l}),r(t)}))}))}updateFixSequence(t,e){let i=-1;return Array.from(e.values()).forEach((e=>{e.fixed||delete t.fixSequence,null!=e.fixSequence&&(i=Math.max(i,e.fixSequence))})),t.fixed?t.fixSequence=i+1:delete t.fixSequence,t}getFieldsList(t,e){var i;const s=null===(i=this._config)||void 0===i?void 0:i.fields;return null!=s&&s.length>0?s.map((({label:e,name:i,readOnly:s,visible:r,required:n})=>{if(null==e){const e=t.getField(i);return Object.assign(Object.assign({},e),{name:null!=i?i:e.name,readOnly:null!=s?s:e.readOnly,visible:null!=r?r:e.visible,required:null!=n?n:e.required})}return{name:i,label:e,readOnly:s,visible:r,required:n}})).filter((t=>this.isFieldVisible(t,e))):null!=t?t.metadata.fields.filter((t=>this.isFieldVisible(t,e))).map((({label:t,name:e,readOnly:i})=>({label:t,name:e,readOnly:i}))):[]}isFieldVisible(t,e){if(!1===t.visible)return!1;if(null==e)return!0;const s=i.replaceAccentuatedCharsLower((t.label||t.name).toLocaleLowerCase()),r=i.replaceAccentuatedCharsLower(e.toLocaleLowerCase());return s.includes(r)}getFormConfig(t,e){let i=this.getFieldsList(t);return e&&(i=i.filter((e=>{if(t){const i=t.getField(e.name);if(i&&i.readOnly)return!1}return!e.readOnly}))),Object.assign(Object.assign({},this._config),{fields:i})}setConfig(t){this.isLoaded=!0;const{cardsState:e,summary:i,defaultVars:s}=this._config||{};this._config=Object.assign({},t),e&&(this._config.cardsState=e),i&&(this._config.summary=i),s&&(this._config.defaultVars=s),this._onConfigChange&&this._onConfigChange(Object.assign({},this._config))}getConfig(t,e){return this.getFormConfig(t,null==e||e)}getFormConfigFetcher(){return null==this._formConfigFetcher&&(this._formConfigFetcher=new s),this._formConfigFetcher}async fetchUserAvailableConfigs(){return null!=this._configName?Promise.resolve(void 0):this.getFormConfigFetcher().fetchUserAvailableConfigs(this._configName,this._resourceID)}async fetchLegacyConfig(){return this.getFormConfigFetcher().fetchLegacyConfig(this._configName,this._resourceID)}async fetchDefaultConfig(){return this.getFormConfigFetcher().fetchDefaultConfig(this._configName,this._resourceID)}}export{r as S}
1
+ import{C as t}from"./p-52920496.js";import{ObjectUtils as e,StringUtils as i}from"@sankhyalabs/core";import{F as s}from"./p-df5451c7.js";class r{constructor(t,e,i){this._resourceID=e,this._configName=t,this._onConfigChange=i}addFormLegacyConfig(e){this._configName&&t.addFormLegacyConfig(this._configName,e)}async loadConfig(){return new Promise((e=>{t.loadFormConfig(this._configName,this._resourceID).then((t=>{this.setConfig(t),e(t)})).catch((t=>{console.warn(t)}))}))}saveConfig(i){const s=e.copy(i);return new Promise((e=>{t.saveFormConfig(i,this._configName,this._resourceID).then((t=>{this.setConfig(Object.assign(Object.assign({},s),t)),e(Object.assign(Object.assign({},s),t))}))}))}saveCardState(e,i,s){return new Promise((r=>{var n;const l=(null===(n=this._config)||void 0===n?void 0:n.cardsState)||new Map,h=l.get(e);l.set(e,"fixed"===s?this.updateFixSequence(Object.assign(Object.assign({},h),{fixed:i.fixed}),l):Object.assign(Object.assign({},h),{[s]:i[s]})),t.saveCardState(l,this._configName,this._resourceID).then((t=>{this._config=Object.assign(Object.assign({},this._config),{cardsState:l}),r(t)}))}))}updateFixSequence(t,e){let i=-1;return Array.from(e.values()).forEach((e=>{e.fixed||delete t.fixSequence,null!=e.fixSequence&&(i=Math.max(i,e.fixSequence))})),t.fixed?t.fixSequence=i+1:delete t.fixSequence,t}getFieldsList(t,e){var i;const s=null===(i=this._config)||void 0===i?void 0:i.fields;return null!=s&&s.length>0?s.map((({label:e,name:i,readOnly:s,visible:r,required:n})=>{if(null==e){const e=t.getField(i);return Object.assign(Object.assign({},e),{name:null!=i?i:e.name,readOnly:null!=s?s:e.readOnly,visible:null!=r?r:e.visible,required:null!=n?n:e.required})}return{name:i,label:e,readOnly:s,visible:r,required:n}})).filter((t=>this.isFieldVisible(t,e))):null!=t?t.metadata.fields.filter((t=>this.isFieldVisible(t,e))).map((({label:t,name:e,readOnly:i})=>({label:t,name:e,readOnly:i}))):[]}isFieldVisible(t,e){if(!1===t.visible)return!1;if(null==e)return!0;const s=i.replaceAccentuatedCharsLower((t.label||t.name).toLocaleLowerCase()),r=i.replaceAccentuatedCharsLower(e.toLocaleLowerCase());return s.includes(r)}getFormConfig(t,e){let i=this.getFieldsList(t);return e&&(i=i.filter((e=>{if(t){const i=t.getField(e.name);if(i&&i.readOnly)return!1}return!e.readOnly}))),Object.assign(Object.assign({},this._config),{fields:i})}setConfig(t){this.isLoaded=!0;const{cardsState:e,summary:i,defaultVars:s}=this._config||{};this._config=Object.assign({},t),e&&(this._config.cardsState=e),i&&(this._config.summary=i),s&&(this._config.defaultVars=s),this._onConfigChange&&this._onConfigChange(Object.assign({},this._config))}getConfig(t,e){return this.getFormConfig(t,null==e||e)}getFormConfigFetcher(){return null==this._formConfigFetcher&&(this._formConfigFetcher=new s),this._formConfigFetcher}async fetchUserAvailableConfigs(){return null!=this._configName?Promise.resolve(void 0):this.getFormConfigFetcher().fetchUserAvailableConfigs(this._configName,this._resourceID)}async fetchLegacyConfig(){return this.getFormConfigFetcher().fetchLegacyConfig(this._configName,this._resourceID)}async fetchDefaultConfig(){return this.getFormConfigFetcher().fetchDefaultConfig(this._configName,this._resourceID)}}export{r as S}
@@ -1 +1 @@
1
- import{r as i,c as e,h as s,F as t,H as n}from"./p-d2d301a6.js";import{StringUtils as l,ObjectUtils as a,ApplicationContext as r,ElementIDUtils as o}from"@sankhyalabs/core";import{P as h}from"./p-057fad05.js";import{P as d,C as c}from"./p-aff76a53.js";import{ApplicationUtils as f}from"@sankhyalabs/ezui/dist/collection/utils";import{a as p}from"./p-933c0c0b.js";import{s as z}from"./p-6dc031de.js";import"./p-ff1990ad.js";import"./p-df5451c7.js";import"./p-dc7c9047.js";import"./p-8d884fab.js";import"@sankhyalabs/core/dist/dataunit/metadata/UnitMetadata";const m=class{constructor(s){i(this,s),this.ezCancel=e(this,"ezCancel",7),this.ezSave=e(this,"ezSave",7),this.ezAfterSave=e(this,"ezAfterSave",7),this._personalizedFilterFetcher=new d,this._filterMetadataStorage=new Map,this._dataSourceFetcher={fetchData:async i=>{let e=null==i?void 0:i.uri;if(l.isEmpty(e)&&(e=this.entityUri),!this._filterMetadataStorage.has(e)){const i=await this._personalizedFilterFetcher.loadFields(e);this._filterMetadataStorage.set(e,i)}return this._filterMetadataStorage.get(e)}},this._filterAssistentMode=!0,this._filterAssistent=void 0,this.messagesBuilder=void 0,this.entityUri=void 0,this.filterId=void 0,this.configName=void 0,this.resourceID=void 0}async createPersonalizedFilter(){const i={name:"",active:!0,expression:"",parameters:[],assistent:{id:l.generateUUID(),items:[{id:l.generateUUID(),entityName:"",fieldName:"",description:"",fieldLabel:"Valor",type:void 0,expression:void 0,operand:void 0,paramVariable:!1,value:void 0,systemConfig:null,userConfig:null}],childrenGroups:[],operand:p.AND}};this._originalFilterAssistent=a.copy(i),this._filterAssistent=a.copy(i)}loadFilter(i,e){null!=i&&e!=i&&null!=this.resourceID&&c.loadPersonalizedFilter(i,this.resourceID,this.configName).then((i=>{const e=this.applyDefaultValues(i);this._filterAssistent=e,this._originalFilterAssistent=a.copy(e),this._filterAssistentMode=this._filterAssistent.hasOwnProperty("assistent")&&null!=this._filterAssistent.assistent}))}componentWillLoad(){var i;null==z.get(`filterFieldsDataSource.${this.entityUri}`)&&z.set(`filterFieldsDataSource.${this.entityUri}`,this._dataSourceFetcher),this.messagesBuilder||(this._application=r.getContextValue("__SNK__APPLICATION__"),this.messagesBuilder=null===(i=this._application)||void 0===i?void 0:i.messagesBuilder),this.loadFilter(this.filterId,void 0)}componentDidRender(){var i;null===(i=this._viewStackRef)||void 0===i||i.show(this._filterAssistentMode?0:1),this._elButtonMode&&this._elButtonMode.setAttribute(o.DATA_ELEMENT_ID_ATTRIBUTE_NAME,o.getInternalIDInfo(this._filterAssistentMode?"advancedMode_ezButton":"assistentMode_ezButton"))}getMessage(i,e){return this._application.messagesBuilder.getMessage(i,e)}saveFilter(){c.savePersonalizedFilter(this._filterAssistent,this.resourceID,this.configName).then((i=>{this._elButtonSave.enabled=!1,f.info(this.getMessage(`snkPersonalizedFilter.${this._filterAssistent.id?"confirmEdit":"confirmSave"}.title`),{iconName:"check"});const e=Object.assign(Object.assign({},i),this._filterAssistent);e.parameters=h.buildVariableParameters(this._filterAssistent.assistent),this._originalFilterAssistent=a.copy(e),this._filterAssistent=a.copy(e),this.ezAfterSave.emit()}))}removeFilter(){c.removePersonalizedFilter(this._filterAssistent,this.resourceID,this.configName)}hasChangesToSave(){return JSON.stringify(this._filterAssistent)===JSON.stringify(this._originalFilterAssistent)}async handleSave(){if(this._filterAssistentMode){if(!h.validateFields(this._filterAssistent.assistent)||!this._filterAssistent.name)return this._application.error(this.getMessage("snkPersonalizedFilter.error.title"),this.getMessage("snkPersonalizedFilter.error.description"));this.saveAssistentMode()}else{if(!this._filterAssistent.expression||!this._filterAssistent.name)return this._application.error(this.getMessage("snkPersonalizedFilter.error.title"),this.getMessage("snkPersonalizedFilter.error.description"));if(!await this.validateExpressionBeforeSaving())return;this.saveAdvancedMode()}}saveAssistentMode(){const{assistent:i,expression:e}=this._filterAssistent,s=i?h.buildGroupExpression(i):e;this._filterAssistent.expression=s,this.ezSave.emit(s),this.saveFilter()}saveAdvancedMode(){this._originalFilterAssistent.expression!==this._filterAssistent.expression&&this._filterAssistent.assistent?f.confirm(this.getMessage("snkPersonalizedFilter.confirmSaveModeAdvanced.title"),this.getMessage("snkPersonalizedFilter.confirmSaveModeAdvanced.description")).then((i=>{i&&this.saveAndTransformToAdvancedMode()})):this._filterAssistent.assistent?this.saveAssistentMode():this.saveAndTransformToAdvancedMode()}saveAndTransformToAdvancedMode(){this._filterAssistent.assistent=void 0,this.ezSave.emit(this._filterAssistent.expression),this.saveFilter()}async validateExpressionBeforeSaving(){const{valid:i,message:e=""}=await this._personalizedFilterFetcher.validatePersonalizedFilter(this.entityUri,this._filterAssistent.expression);return i||this._application.error(this.getMessage("snkPersonalizedFilter.errorValidation.title"),e.replace(/.*Exception: /,"")),i}handleCancel(){if(this.hasChangesToSave())return this.ezCancel.emit();f.confirm(this.getMessage("snkPersonalizedFilter.confirmCancel.title"),this.getMessage("snkPersonalizedFilter.confirmCancel.description")).then((i=>{var e;i&&(this._filterAssistent=a.copy(null!==(e=this._originalFilterAssistent)&&void 0!==e?e:{}),this.ezCancel.emit(),this._elButtonSave.enabled=!1)}))}handleTitleChange(i){this._filterAssistent=Object.assign(Object.assign({},this._filterAssistent),{name:i}),this._elButtonSave.enabled=!this.hasChangesToSave()}applyDefaultValues(i){return this.addLabelToItems(i),this.addFilterGroupCondition(i),i}addFilterGroupCondition(i){i.assistent&&!i.assistent.operand&&(i.assistent.operand=p.AND)}addLabelToItems(i){i.assistent&&i.assistent.items&&i.assistent.items.length>0&&i.assistent.items.forEach((e=>{if(null==e.fieldLabel){const s=(i.parameters||[]).find((i=>i.fieldName===e.fieldName));s&&(e.fieldLabel=s.label)}}))}handleExpressionChangeAdvancedMode(i){this._filterAssistent=Object.assign(Object.assign({},this._filterAssistent),{expression:i}),this._elButtonSave.enabled=!this.hasChangesToSave()}handleChangeFilterAssistentMode(i){this._elButtonSave.enabled=!this.hasChangesToSave(),this._filterAssistent=Object.assign({},i)}selectField(i){if(!("name"in i))return;const e=this.buildExpression(i.entityName,i.name,i.entityPath);this._elAdvancedMode.querySelector("ez-text-area").appendTextToSelection(e)}buildExpression(i,e,s){return s.length>0&&s.shift(),s.length>0?`${s.join("->")}->${e}`:`${i}.${e}`}onAddField(i){this._elAdvancedMode.querySelector("ez-text-area").setFocus(),i.setBlur(),this._elFilterFieldSearch&&this._elFilterFieldSearch.show(i,{horizontalGap:0,verticalGap:12,fromRight:!0})}renderButtonAddField(){if(!this._filterAssistentMode)return s(t,null,s("ez-button",{class:"snk-personalized-filter__button-mode",label:this.getMessage("snkPersonalizedFilter.info.addField"),enabled:!0,onClick:i=>this.onAddField(i.target)},s("ez-icon",{class:"ez-padding-right--small",slot:"leftIcon",iconName:"plus"})),s("snk-filter-field-search",{class:"ez-padding-left--medium",ref:i=>this._elFilterFieldSearch=i,onEzSelectFilterItem:i=>this.selectField(i.detail),fieldsDataSource:this._dataSourceFetcher}))}buildContainerPersonalizedFilter(){return s("ez-view-stack",{ref:i=>this._viewStackRef=i},s("stack-item",null,this._filterAssistentMode&&s("snk-filter-assistent-mode",{filterAssistent:this._filterAssistent,messagesBuilder:this.messagesBuilder,filterId:this.filterId,entityUri:this.entityUri,application:this._application,onEzChangeFilter:i=>this.handleChangeFilterAssistentMode(i.detail)})),s("stack-item",null,s("snk-filter-advanced-mode",{ref:i=>this._elAdvancedMode=i,filterAssistent:this._filterAssistent,application:this._application,onEzExpressionChange:i=>this.handleExpressionChangeAdvancedMode(i.detail)})))}handleModeChange(){var i,e;if(this._filterAssistentMode)f.confirm(this.getMessage("snkPersonalizedFilter.confirmChangeModeAssistent.title"),this.getMessage("snkPersonalizedFilter.confirmChangeModeAssistent.description")).then((i=>{if(i&&(this._filterAssistentMode=!this._filterAssistentMode,!this.hasChangesToSave())){const i=h.buildGroupExpression(this._filterAssistent.assistent);this._filterAssistent.expression=i,this._elButtonSave.enabled=!this.hasChangesToSave()}}));else if((null===(i=this._filterAssistent)||void 0===i?void 0:i.expression)===(null===(e=this._originalFilterAssistent)||void 0===e?void 0:e.expression))this._filterAssistentMode=!this._filterAssistentMode;else{const i=this._filterAssistent.expression,e=h.buildGroupExpression(this._filterAssistent.assistent);i!==e?f.confirm(this.getMessage("snkPersonalizedFilter.confirmChangeModeAdvanced.title"),this.getMessage("snkPersonalizedFilter.confirmChangeModeAdvanced.description")).then((i=>{i&&(this._filterAssistent=Object.assign(Object.assign({},this._filterAssistent),{expression:e}),this._filterAssistentMode=!this._filterAssistentMode)})):this._filterAssistentMode=!this._filterAssistentMode}}render(){var i,e,t,l;if((null===(i=this._filterAssistent)||void 0===i?void 0:i.assistent)||!this._filterAssistentMode)return s(n,null,s("div",{class:"snk-personalized-filter"},s("div",null,s("snk-simple-bar",{label:this.getMessage(this.filterId?"snkPersonalizedFilter.info.titleEdit":"snkPersonalizedFilter.info.titleAdd"),onExit:()=>this.handleCancel()},s("div",{class:"snk-personalized-filter__header-actions",slot:"rightSlot"},s("ez-button",{size:"small",label:this.getMessage("snkPersonalizedFilter.info.labelCancel"),onClick:()=>this.handleCancel()}),s("ez-button",{size:"small",ref:i=>this._elButtonSave=i,enabled:!1,class:"ez-button--primary",label:this.getMessage("snkPersonalizedFilter.info.labelSave"),onClick:this.handleSave.bind(this)})))),s("div",{class:"ez-box ez-margin-bottom--medium ez-box__main"},s("div",{class:"ez-box__container"},s("div",{class:"ez-flex ez-flex--column ez-size-width--full"},s("div",{class:"ez-flex"},s("ez-text-input",{class:"ez-padding-right--medium",label:this.getMessage("snkPersonalizedFilter.info.labelNameFilter"),value:null===(e=this._filterAssistent)||void 0===e?void 0:e.name,onEzChange:i=>this.handleTitleChange(i.detail)}),this.renderButtonAddField(),s("ez-button",{ref:i=>this._elButtonMode=i,class:"snk-personalized-filter__button-mode",label:this.getMessage(this._filterAssistentMode?"snkPersonalizedFilter.info.activeModeAdvanced":"snkPersonalizedFilter.info.activeModeAssistent"),onClick:()=>this.handleModeChange(),"data-tooltip":this._filterAssistentMode||(null===(t=this._filterAssistent)||void 0===t?void 0:t.assistent)?void 0:this.getMessage("snkPersonalizedFilter.info.tooltipDisabledAssistentMode"),"data-flow":"bottom",enabled:!this._filterAssistent.name||Boolean(this._filterAssistentMode||(null===(l=this._filterAssistent)||void 0===l?void 0:l.assistent))})),this.buildContainerPersonalizedFilter())))))}static get watchers(){return{filterId:["loadFilter"]}}};m.style=".sc-snk-personalized-filter-h{display:flex;height:100%;padding:var(--space--large, 24px);--snk-personalized-filter--width:100%;--snk-personalized-filter--height:100%;--snk-personalized-filter--background-color-line:var(--color--disable-secondary);--snk-personalized-filter--margin-line:var(--border--radius-medium, 12px)}.snk-personalized-filter.sc-snk-personalized-filter{height:var(--snk-personalized-filter--width);width:var(--snk-personalized-filter--height)}.snk-personalized-filter__header-actions.sc-snk-personalized-filter{display:flex;gap:var(--space--medium)}.snk-personalized-filter__group.sc-snk-personalized-filter{flex:1}.snk-personalized-filter__expression-input--line.sc-snk-personalized-filter{width:100%;height:2px;background-color:var(--snk-personalized-filter--background-color-line);margin-top:var(--snk-personalized-filter--margin-line);margin-bottom:var(--snk-personalized-filter--margin-line)}.ez-box__main.sc-snk-personalized-filter{height:90%}.snk-personalized-filter__button-mode.sc-snk-personalized-filter{height:35px}";export{m as snk_personalized_filter}
1
+ import{r as i,c as e,h as s,F as t,H as n}from"./p-d2d301a6.js";import{StringUtils as l,ObjectUtils as r,ApplicationContext as a,ElementIDUtils as o}from"@sankhyalabs/core";import{P as h}from"./p-057fad05.js";import{P as d,C as c}from"./p-52920496.js";import{ApplicationUtils as f}from"@sankhyalabs/ezui/dist/collection/utils";import{a as p}from"./p-933c0c0b.js";import{s as z}from"./p-6dc031de.js";import"./p-ff1990ad.js";import"./p-df5451c7.js";import"./p-dc7c9047.js";import"./p-8d884fab.js";import"@sankhyalabs/core/dist/dataunit/metadata/UnitMetadata";const m=class{constructor(s){i(this,s),this.ezCancel=e(this,"ezCancel",7),this.ezSave=e(this,"ezSave",7),this.ezAfterSave=e(this,"ezAfterSave",7),this._personalizedFilterFetcher=new d,this._filterMetadataStorage=new Map,this._dataSourceFetcher={fetchData:async i=>{let e=null==i?void 0:i.uri;if(l.isEmpty(e)&&(e=this.entityUri),!this._filterMetadataStorage.has(e)){const i=await this._personalizedFilterFetcher.loadFields(e);this._filterMetadataStorage.set(e,i)}return this._filterMetadataStorage.get(e)}},this._filterAssistentMode=!0,this._filterAssistent=void 0,this.messagesBuilder=void 0,this.entityUri=void 0,this.filterId=void 0,this.configName=void 0,this.resourceID=void 0}async createPersonalizedFilter(){const i={name:"",active:!0,expression:"",parameters:[],assistent:{id:l.generateUUID(),items:[{id:l.generateUUID(),entityName:"",fieldName:"",description:"",fieldLabel:"Valor",type:void 0,expression:void 0,operand:void 0,paramVariable:!1,value:void 0,systemConfig:null,userConfig:null}],childrenGroups:[],operand:p.AND}};this._originalFilterAssistent=r.copy(i),this._filterAssistent=r.copy(i)}loadFilter(i,e){null!=i&&e!=i&&null!=this.resourceID&&c.loadPersonalizedFilter(i,this.resourceID,this.configName).then((i=>{const e=this.applyDefaultValues(i);this._filterAssistent=e,this._originalFilterAssistent=r.copy(e),this._filterAssistentMode=this._filterAssistent.hasOwnProperty("assistent")&&null!=this._filterAssistent.assistent}))}componentWillLoad(){var i;null==z.get(`filterFieldsDataSource.${this.entityUri}`)&&z.set(`filterFieldsDataSource.${this.entityUri}`,this._dataSourceFetcher),this.messagesBuilder||(this._application=a.getContextValue("__SNK__APPLICATION__"),this.messagesBuilder=null===(i=this._application)||void 0===i?void 0:i.messagesBuilder),this.loadFilter(this.filterId,void 0)}componentDidRender(){var i;null===(i=this._viewStackRef)||void 0===i||i.show(this._filterAssistentMode?0:1),this._elButtonMode&&this._elButtonMode.setAttribute(o.DATA_ELEMENT_ID_ATTRIBUTE_NAME,o.getInternalIDInfo(this._filterAssistentMode?"advancedMode_ezButton":"assistentMode_ezButton"))}getMessage(i,e){return this._application.messagesBuilder.getMessage(i,e)}saveFilter(){c.savePersonalizedFilter(this._filterAssistent,this.resourceID,this.configName).then((i=>{this._elButtonSave.enabled=!1,f.info(this.getMessage(`snkPersonalizedFilter.${this._filterAssistent.id?"confirmEdit":"confirmSave"}.title`),{iconName:"check"});const e=Object.assign(Object.assign({},i),this._filterAssistent);e.parameters=h.buildVariableParameters(this._filterAssistent.assistent),this._originalFilterAssistent=r.copy(e),this._filterAssistent=r.copy(e),this.ezAfterSave.emit()}))}removeFilter(){c.removePersonalizedFilter(this._filterAssistent,this.resourceID,this.configName)}hasChangesToSave(){return JSON.stringify(this._filterAssistent)===JSON.stringify(this._originalFilterAssistent)}async handleSave(){if(this._filterAssistentMode){if(!h.validateFields(this._filterAssistent.assistent)||!this._filterAssistent.name)return this._application.error(this.getMessage("snkPersonalizedFilter.error.title"),this.getMessage("snkPersonalizedFilter.error.description"));this.saveAssistentMode()}else{if(!this._filterAssistent.expression||!this._filterAssistent.name)return this._application.error(this.getMessage("snkPersonalizedFilter.error.title"),this.getMessage("snkPersonalizedFilter.error.description"));if(!await this.validateExpressionBeforeSaving())return;this.saveAdvancedMode()}}saveAssistentMode(){const{assistent:i,expression:e}=this._filterAssistent,s=i?h.buildGroupExpression(i):e;this._filterAssistent.expression=s,this.ezSave.emit(s),this.saveFilter()}saveAdvancedMode(){this._originalFilterAssistent.expression!==this._filterAssistent.expression&&this._filterAssistent.assistent?f.confirm(this.getMessage("snkPersonalizedFilter.confirmSaveModeAdvanced.title"),this.getMessage("snkPersonalizedFilter.confirmSaveModeAdvanced.description")).then((i=>{i&&this.saveAndTransformToAdvancedMode()})):this._filterAssistent.assistent?this.saveAssistentMode():this.saveAndTransformToAdvancedMode()}saveAndTransformToAdvancedMode(){this._filterAssistent.assistent=void 0,this.ezSave.emit(this._filterAssistent.expression),this.saveFilter()}async validateExpressionBeforeSaving(){const{valid:i,message:e=""}=await this._personalizedFilterFetcher.validatePersonalizedFilter(this.entityUri,this._filterAssistent.expression);return i||this._application.error(this.getMessage("snkPersonalizedFilter.errorValidation.title"),e.replace(/.*Exception: /,"")),i}handleCancel(){if(this.hasChangesToSave())return this.ezCancel.emit();f.confirm(this.getMessage("snkPersonalizedFilter.confirmCancel.title"),this.getMessage("snkPersonalizedFilter.confirmCancel.description")).then((i=>{var e;i&&(this._filterAssistent=r.copy(null!==(e=this._originalFilterAssistent)&&void 0!==e?e:{}),this.ezCancel.emit(),this._elButtonSave.enabled=!1)}))}handleTitleChange(i){this._filterAssistent=Object.assign(Object.assign({},this._filterAssistent),{name:i}),this._elButtonSave.enabled=!this.hasChangesToSave()}applyDefaultValues(i){return this.addLabelToItems(i),this.addFilterGroupCondition(i),i}addFilterGroupCondition(i){i.assistent&&!i.assistent.operand&&(i.assistent.operand=p.AND)}addLabelToItems(i){i.assistent&&i.assistent.items&&i.assistent.items.length>0&&i.assistent.items.forEach((e=>{if(null==e.fieldLabel){const s=(i.parameters||[]).find((i=>i.fieldName===e.fieldName));s&&(e.fieldLabel=s.label)}}))}handleExpressionChangeAdvancedMode(i){this._filterAssistent=Object.assign(Object.assign({},this._filterAssistent),{expression:i}),this._elButtonSave.enabled=!this.hasChangesToSave()}handleChangeFilterAssistentMode(i){this._elButtonSave.enabled=!this.hasChangesToSave(),this._filterAssistent=Object.assign({},i)}selectField(i){if(!("name"in i))return;const e=this.buildExpression(i.entityName,i.name,i.entityPath);this._elAdvancedMode.querySelector("ez-text-area").appendTextToSelection(e)}buildExpression(i,e,s){return s.length>0&&s.shift(),s.length>0?`${s.join("->")}->${e}`:`${i}.${e}`}onAddField(i){this._elAdvancedMode.querySelector("ez-text-area").setFocus(),i.setBlur(),this._elFilterFieldSearch&&this._elFilterFieldSearch.show(i,{horizontalGap:0,verticalGap:12,fromRight:!0})}renderButtonAddField(){if(!this._filterAssistentMode)return s(t,null,s("ez-button",{class:"snk-personalized-filter__button-mode",label:this.getMessage("snkPersonalizedFilter.info.addField"),enabled:!0,onClick:i=>this.onAddField(i.target)},s("ez-icon",{class:"ez-padding-right--small",slot:"leftIcon",iconName:"plus"})),s("snk-filter-field-search",{class:"ez-padding-left--medium",ref:i=>this._elFilterFieldSearch=i,onEzSelectFilterItem:i=>this.selectField(i.detail),fieldsDataSource:this._dataSourceFetcher}))}buildContainerPersonalizedFilter(){return s("ez-view-stack",{ref:i=>this._viewStackRef=i},s("stack-item",null,this._filterAssistentMode&&s("snk-filter-assistent-mode",{filterAssistent:this._filterAssistent,messagesBuilder:this.messagesBuilder,filterId:this.filterId,entityUri:this.entityUri,application:this._application,onEzChangeFilter:i=>this.handleChangeFilterAssistentMode(i.detail)})),s("stack-item",null,s("snk-filter-advanced-mode",{ref:i=>this._elAdvancedMode=i,filterAssistent:this._filterAssistent,application:this._application,onEzExpressionChange:i=>this.handleExpressionChangeAdvancedMode(i.detail)})))}handleModeChange(){var i,e;if(this._filterAssistentMode)f.confirm(this.getMessage("snkPersonalizedFilter.confirmChangeModeAssistent.title"),this.getMessage("snkPersonalizedFilter.confirmChangeModeAssistent.description")).then((i=>{if(i&&(this._filterAssistentMode=!this._filterAssistentMode,!this.hasChangesToSave())){const i=h.buildGroupExpression(this._filterAssistent.assistent);this._filterAssistent.expression=i,this._elButtonSave.enabled=!this.hasChangesToSave()}}));else if((null===(i=this._filterAssistent)||void 0===i?void 0:i.expression)===(null===(e=this._originalFilterAssistent)||void 0===e?void 0:e.expression))this._filterAssistentMode=!this._filterAssistentMode;else{const i=this._filterAssistent.expression,e=h.buildGroupExpression(this._filterAssistent.assistent);i!==e?f.confirm(this.getMessage("snkPersonalizedFilter.confirmChangeModeAdvanced.title"),this.getMessage("snkPersonalizedFilter.confirmChangeModeAdvanced.description")).then((i=>{i&&(this._filterAssistent=Object.assign(Object.assign({},this._filterAssistent),{expression:e}),this._filterAssistentMode=!this._filterAssistentMode)})):this._filterAssistentMode=!this._filterAssistentMode}}render(){var i,e,t,l;if((null===(i=this._filterAssistent)||void 0===i?void 0:i.assistent)||!this._filterAssistentMode)return s(n,null,s("div",{class:"snk-personalized-filter"},s("div",null,s("snk-simple-bar",{label:this.getMessage(this.filterId?"snkPersonalizedFilter.info.titleEdit":"snkPersonalizedFilter.info.titleAdd"),onExit:()=>this.handleCancel()},s("div",{class:"snk-personalized-filter__header-actions",slot:"rightSlot"},s("ez-button",{size:"small",label:this.getMessage("snkPersonalizedFilter.info.labelCancel"),onClick:()=>this.handleCancel()}),s("ez-button",{size:"small",ref:i=>this._elButtonSave=i,enabled:!1,class:"ez-button--primary",label:this.getMessage("snkPersonalizedFilter.info.labelSave"),onClick:this.handleSave.bind(this)})))),s("div",{class:"ez-box ez-margin-bottom--medium ez-box__main"},s("div",{class:"ez-box__container"},s("div",{class:"ez-flex ez-flex--column ez-size-width--full"},s("div",{class:"ez-flex"},s("ez-text-input",{class:"ez-padding-right--medium",label:this.getMessage("snkPersonalizedFilter.info.labelNameFilter"),value:null===(e=this._filterAssistent)||void 0===e?void 0:e.name,onEzChange:i=>this.handleTitleChange(i.detail)}),this.renderButtonAddField(),s("ez-button",{ref:i=>this._elButtonMode=i,class:"snk-personalized-filter__button-mode",label:this.getMessage(this._filterAssistentMode?"snkPersonalizedFilter.info.activeModeAdvanced":"snkPersonalizedFilter.info.activeModeAssistent"),onClick:()=>this.handleModeChange(),"data-tooltip":this._filterAssistentMode||(null===(t=this._filterAssistent)||void 0===t?void 0:t.assistent)?void 0:this.getMessage("snkPersonalizedFilter.info.tooltipDisabledAssistentMode"),"data-flow":"bottom",enabled:!this._filterAssistent.name||Boolean(this._filterAssistentMode||(null===(l=this._filterAssistent)||void 0===l?void 0:l.assistent))})),this.buildContainerPersonalizedFilter())))))}static get watchers(){return{filterId:["loadFilter"]}}};m.style=".sc-snk-personalized-filter-h{display:flex;height:100%;padding:var(--space--large, 24px);--snk-personalized-filter--width:100%;--snk-personalized-filter--height:100%;--snk-personalized-filter--background-color-line:var(--color--disable-secondary);--snk-personalized-filter--margin-line:var(--border--radius-medium, 12px)}.snk-personalized-filter.sc-snk-personalized-filter{height:var(--snk-personalized-filter--width);width:var(--snk-personalized-filter--height)}.snk-personalized-filter__header-actions.sc-snk-personalized-filter{display:flex;gap:var(--space--medium)}.snk-personalized-filter__group.sc-snk-personalized-filter{flex:1}.snk-personalized-filter__expression-input--line.sc-snk-personalized-filter{width:100%;height:2px;background-color:var(--snk-personalized-filter--background-color-line);margin-top:var(--snk-personalized-filter--margin-line);margin-bottom:var(--snk-personalized-filter--margin-line)}.ez-box__main.sc-snk-personalized-filter{height:90%}.snk-personalized-filter__button-mode.sc-snk-personalized-filter{height:35px}";export{m as snk_personalized_filter}
@@ -0,0 +1 @@
1
+ import{r as i,c as t,h as s,g as e}from"./p-d2d301a6.js";import{UserInterface as o,StringUtils as n,ApplicationContext as h,ObjectUtils as a,DataType as r,JSUtils as d,FloatingManager as l,ElementIDUtils as u}from"@sankhyalabs/core";import{CSSVarsUtils as c}from"@sankhyalabs/ezui/dist/collection/utils";import{d as m,S as v}from"./p-b0ef4383.js";import{T as f}from"./p-7e7a7473.js";import"./p-dc7c9047.js";import"./p-af8efd95.js";import{C as p,S as g,R as C,a as S}from"./p-3a212712.js";import{D as k,P as b}from"./p-30cf616e.js";import"./p-21749402.js";import"@sankhyalabs/ezui/dist/collection/utils/constants";import"@sankhyalabs/core/dist/dataunit/metadata/UnitMetadata";import{I as y}from"./p-fe79f83a.js";import"./p-ff1990ad.js";import{F as w}from"./p-df5451c7.js";import{T as E,b as _,o as I}from"./p-c2495304.js";import{C as T}from"./p-52920496.js";import{S as F}from"./p-2a408684.js";import{g as R}from"./p-9863d682.js";import{s as D}from"./p-6dc031de.js";import"./p-8d884fab.js";import"@sankhyalabs/ezui/dist/collection/components/ez-grid/utils/InMemoryFilterColumnDataSource";import"@sankhyalabs/ezui/dist/collection/components/ez-grid/utils";import"@sankhyalabs/core/dist/utils/SortingUtils";import"./p-688dcb4c.js";const z=["INSERT","REFRESH","PREVIOUS","NEXT","DIVIDER","MORE_OPTIONS"],M=["INSERT","REFRESH","PREVIOUS","NEXT","DIVIDER","CLONE","REMOVE","DIVIDER","MORE_OPTIONS"];class O extends p{getSelectedNumber(){return this.dataUnit.getSelectionInfo().length}getTotalRecords(){var i,t,s;const{total:e}=(null===(i=this.dataUnit)||void 0===i?void 0:i.getPaginationInfo())||{};return null!=e?e:null===(s=null===(t=this.dataUnit)||void 0===t?void 0:t.records)||void 0===s?void 0:s.length}getSelectedIDs(){return R(this.dataUnit)}getRecordID(){var i,t,s;return null===(s=null===(t=null===(i=this.dataUnit)||void 0===i?void 0:i.records)||void 0===t?void 0:t[0])||void 0===s?void 0:s.__record__id__}async getRecords(){if(0===this.dataUnit.records.length)return Promise.resolve([]);const i=this.dataUnit.getSelectionInfo(),t=i.isEmpty()||i.isAllRecords()?await i.getAllRecords():i.records;return Promise.resolve(null==t?[]:t)}getHiddenOptions(){return[k.EXPORT_BY_EMAIL,k.EXPORT_PDF_TO_EMAIL,k.EXPORT_XLS_TO_EMAIL,k.EXPORT_PAGE_TO_PDF,k.EXPORT_PAGE_TO_XLS]}formatValue(i,t){const{id:s,descriptionFrom:e}=t,n=i[e||s];if(null==n)return"";if(null!=e)return n.label;if(this.dataUnit.getField(s).userInterface===o.SEARCH)return n.value;if(t.customFormatter){const s=this.getColumnsState().find((i=>t.id===i.name));return t.customFormatter.format(n,s,i.__record__id__)}return this.dataUnit.getFormattedValue(s,n)}}const P=class{constructor(s){i(this,s),this.dataStateChange=t(this,"dataStateChange",3),this.dataUnitReady=t(this,"dataUnitReady",3),this.actionClick=t(this,"actionClick",7),this.formItemsReady=t(this,"formItemsReady",7),this.configuratorSave=t(this,"configuratorSave",7),this.configuratorCancel=t(this,"configuratorCancel",7),this._multiSelectionListDataSource=new g,this._keyDownHandler=i=>this.keyDownListener(i),this._formConfigFetcher=new w,this._customEditors=new Map,this._customRenders=new Map,this._taskbarProcessor=new E({"snkSimpleCrudTaskbar.form_regular":this.getButtons(!1,[f.GRID_MODE]),"snkSimpleCrudTaskbar.grid_regular":this.getButtons(!1,[f.DATA_EXPORTER,f.FORM_MODE]),"snkSimpleCrudTaskbar.form_selected":this.getButtons(!0,[f.GRID_MODE]),"snkSimpleCrudTaskbar.grid_selected":this.getButtons(!0,[f.DATA_EXPORTER,f.FORM_MODE]),"snkSimpleCrudTaskbar.finish_edition":["CANCEL","SAVE"]}),this._showPopUpGridConfig=!1,this._showFormConfig=!1,this._currentViewMode=m.GRID,this._config=void 0,this._fieldToGetFocus=void 0,this._customContainerId=`SNK-SIMPLE-CRUD-CUSTOM-CONTAINER-${n.generateUUID()}`,this.dataState=void 0,this.dataUnit=void 0,this.entityName=void 0,this.mode=v.SERVER,this.gridConfig=void 0,this.formConfig=void 0,this._formFields=[],this._fieldsProps=new Map,this.multipleSelection=void 0,this.useCancelConfirm=!0,this.pageSize=150,this.resourceID=void 0,this.taskbarManager=void 0,this.messagesBuilder=void 0,this.useEnterLikeTab=!1,this.actionsList=void 0,this.configName=void 0,this.showConfiguratorButtons=void 0,this.gridLegacyConfigName=void 0,this.formLegacyConfigName=void 0,this.ignoreReadOnlyFormFields=!1,this.autoFocus=!0,this.domainMessagesBuilder=void 0,this.domainMessagesBuilder="InMemoryDomain",this.autoLoad=void 0}async addCustomEditor(i,t){if(this._grid&&this._form)return this._grid.addCustomEditor(i,t),void this._form.addCustomEditor(i,t);const s=new Map(this._customEditors);s.set(i,t),this._customEditors=s}async addGridCustomRender(i,t){if(this._grid)return void this._grid.addGridCustomRender(i,t);const s=new Map(this._customRenders);s.set(i,t),this._customRenders=s}handleResourceIDChanged(i,t){n.isEmpty(i)||i!==t&&(this.loadFormConfig(!0),this.loadGridConfig(!0))}async addCustomValueFormatter(i,t){this._grid.addCustomValueFormatter(i,t)}async removeCustomValueFormatter(i){this._grid.removeCustomValueFormatter(i)}async setFieldProp(i,t,s){const e=new Map(this._fieldsProps),o=this._fieldsProps.get(i);e.set(i,Object.assign(Object.assign({},o),{[t]:s})),this._fieldsProps=e}getButtons(i,t){return this.addConfigButton(this.resolveInMemoryBtns(i?M:z).concat(t))}addConfigButton(i){return void 0===this.configName?i:i.concat(f.CONFIGURATOR)}get application(){return h.getContextValue("__SNK__APPLICATION__")}resolveInMemoryBtns(i){const t=[...i];return this.mode===v.IN_MEMORY&&t.splice(1,1),t}async goToView(i){this._currentViewMode=i,this._viewStack&&this._viewStack.show(i)}actionClickListener(i){const t=i.detail;t===f.CONFIGURATOR?this._snkConfigurator.open():t===f.GRID_MODE?this.goToView(m.GRID):t===f.FORM_MODE&&this.goToView(m.FORM),i.stopPropagation()}async onChangeEntityName(i){if(this.dataUnit)return;const t=h.getContextValue("__SNK__APPLICATION__");this.dataUnit=await t.getDataUnit(i,null,null,this.configName)}onModeChange(){this.mode==v.IN_MEMORY&&this.initInMemoryDataUnit()}observeDataState(i,t){this.handleDataStateChange(i,t)}async observeFormLegacy(i,t){await this.handleUpdateFormLegacyConfig(i,t)}async observeGridLegacy(i,t){await this.handleUpdateGridLegacyConfig(i,t)}async handleDataStateChange(i,t){a.objectToString(t)!=a.objectToString(i)&&this.dataStateChange.emit(i),await this.processRmPrecision()}async processRmPrecision(){var i,t;const s=await this._snkDataUnit.getFieldsWithRmPrecision();for(const e of s||[]){if(!e)continue;const s=null===(t=null===(i=this.dataState)||void 0===i?void 0:i.rowMetadata)||void 0===t?void 0:t.getProp("rm_precision",e);(s||0===s)&&(await this.setFieldProp(e,"precision",s),await this.setFieldProp(e,"prettyPrecision",s))}this._rmPrecisionCustomValueFormatter.setDataState(this.dataState)}async handleUpdateGridLegacyConfig(i,t){null!=i&&i!=t&&this._gridConfigAlreadyLoaded&&await this.loadGridConfig(!0)}async handleUpdateFormLegacyConfig(i,t){null!=i&&i!=t&&this._formConfigAlreadyLoaded&&this.loadFormConfig(!0)}openConfig(i){this._snkConfigurator.close(),i===m.GRID?this.openGridConfig():i===m.FORM&&this.openFormConfig()}openGridConfig(){this._grid.getColumnsState().then((i=>{this._snkGridConfig.columns=i.filter((i=>i.name)),this._snkGridConfig.selectedIndex=0,this._showPopUpGridConfig=!0}))}async openFormConfig(){var i,t;if(this.formLegacyConfigName){const s=null===(i=this.messagesBuilder)||void 0===i?void 0:i.getMessage("snkSimpleCrud.formConfigUnavaliable.title",void 0),e=null===(t=this.messagesBuilder)||void 0===t?void 0:t.getMessage("snkSimpleCrud.formConfigUnavaliable.message",void 0);await this.application.alert(s,e)}else this._showFormConfig=!0}addGridLegacyConfigName(){this.gridLegacyConfigName&&this.configName&&T.addGridLegacyConfig(this.configName,this.gridLegacyConfigName)}loadGridConfig(i){if(void 0!==this.configName&&(null==this.gridConfig&&!this._gridConfigAlreadyLoaded||i))return this.addGridLegacyConfigName(),this._gridConfigAlreadyLoaded=!0,new Promise(((i,t)=>{T.loadGridConfig(this.configName,this.resolveResourceID()).then((t=>{this.setGridConfig(t),i()})).catch((i=>{t(i)}))}))}formConfigIsLoaded(){return null!=this.formConfig||this._formConfigAlreadyLoaded}async loadFormConfig(i=!1){if(void 0===this.configName)return;if(null==this._formConfigManager&&(this._formConfigManager=new F(this.configName,this.resolveResourceID()),this._formConfigManager.setConfig(this.formConfig)),this.formConfigIsLoaded()&&!i)return;this._formConfigAlreadyLoaded=!0;let t=await this._formConfigFetcher.fetchLegacyConfigurableForm(this.formLegacyConfigName);if(null!=t)return this._formConfigManager.setConfig(t),void this.setFormConfig(t);this.setFormConfig(await this._formConfigManager.loadConfig())}async componentWillRender(){this._resourceID=await this.application.getResourceID(),this.dataExporterProviderStore(),this._taskbarProcessor.process(this.getTaskBarId(),this.taskbarManager,this.dataState,this.getTaskBarDisabledButtons()),void 0!==this.configName&&(null!=this.gridConfig||this._gridConfigAlreadyLoaded||(await this.addGridLegacyConfigName(),this.loadGridConfig(),this.loadFormConfig()))}componentDidRender(){this._rmPrecisionCustomValueFormatter.setGrid(this._grid),this.addGridCustomValueFormattters(),this.setFieldsProps(),this.setCustomRenders(),this.setCustomEditors()}componentWillLoad(){this.processMetadata(),this.onModeChange(),this.configDatasource(),this._rmPrecisionCustomValueFormatter=new C}componentDidLoad(){c.applyVarsGrid(this._element,this._grid)}setCustomRenders(){if(this._grid)for(const[i,t]of this._customRenders)this._grid.addGridCustomRender(i,t),this._customRenders.delete(i)}setCustomEditors(){if(this._grid&&this._form)for(const[i,t]of this._customEditors)this._grid.addCustomEditor(i,t),this._form.addCustomEditor(i,t),this._customEditors.delete(i)}configDatasource(){this._multiSelectionListDataSource.setApplication(this.application),this._multiSelectionListDataSource.setDataUnit(this.dataUnit)}setFieldsProps(){if(this._form)for(const[i,t]of this._fieldsProps){for(const s in t)this._form.setFieldProp(i,s,t[s]);this._fieldsProps.delete(i)}}getTaskBarId(){var i,t;return(null===(i=this.dataState)||void 0===i?void 0:i.isDirty)?"snkSimpleCrudTaskbar.finish_edition":(null===(t=this.dataState)||void 0===t?void 0:t.selectionInfo)&&!this.dataState.selectionInfo.isAllRecords()&&this.dataState.selectionInfo.length>0?this._currentViewMode===m.GRID?"snkSimpleCrudTaskbar.grid_selected":"snkSimpleCrudTaskbar.form_selected":this._currentViewMode===m.GRID?"snkSimpleCrudTaskbar.grid_regular":"snkSimpleCrudTaskbar.form_regular"}initInMemoryDataUnit(){this._inMemoryLoader=new y(this._metadata,void 0,{autoLoad:this.autoLoad}),this.dataUnit=this._inMemoryLoader.dataUnit,this.dataUnitReady.emit(this.dataUnit)}setMetadata(i){return this._inMemoryLoader?this._inMemoryLoader.metadata=i:this.dataUnit&&(this.dataUnit.metadata=i),Promise.resolve()}setRecords(i){return this._inMemoryLoader?this._inMemoryLoader.records=i:this.dataUnit&&(this.dataUnit.records=i),Promise.resolve()}getRecords(){return Promise.resolve(this.dataUnit.records)}async openConfigurator(){var i;null===(i=this._snkConfigurator)||void 0===i||i.open()}async closeConfigurator(){var i;null===(i=this._snkConfigurator)||void 0===i||i.close()}async updateConfig(){null==this._formConfigManager&&(this._formConfigManager=new F(this.configName,this.resolveResourceID())),this._formConfigManager.setConfig(this.formConfig)}processMetadata(){const i=this._element.querySelectorAll("snk-field-metadata"),t=[],s={fields:[],emptyConfig:!1};i.forEach((i=>{const e={name:i.getAttribute("name")||i.getAttribute("label"),label:i.getAttribute("label"),dataType:r[i.getAttribute("dataType")]||r.TEXT,userInterface:o[i.getAttribute("userInterface")]||o.SHORTTEXT,readOnly:"true"==i.getAttribute("readOnly"),required:"true"==i.getAttribute("required"),tab:i.getAttribute("tab")||void 0,visible:"false"!=i.getAttribute("visible")};s.fields.push({name:e.name,tab:e.tab,visible:e.visible}),t.push(e)})),t.length>0&&(this.formConfig||(this.formConfig=s),this._metadata={name:"SimpleCrud",label:"SimpleCrud",fields:t})}addGridCustomValueFormattters(){var i,t,s;const e=(null===(i=this._metadata)||void 0===i?void 0:i.fields)||(null===(s=null===(t=this.dataUnit)||void 0===t?void 0:t.metadata)||void 0===s?void 0:s.fields);if(!e)return;const o=[];e.forEach((i=>{var t;(null===(t=i.properties)||void 0===t?void 0:t.rm_precision)&&!o.includes(i.name)&&o.push(i.name)})),o.forEach((i=>{this.addCustomValueFormatter(i,this._rmPrecisionCustomValueFormatter)}))}onDataStateChange(i){this.dataState=Object.assign({},i.detail)}getTaskBarDisabledButtons(){var i,t,s,e,o,n;const h=[];return(null===(i=this.dataState)||void 0===i?void 0:i.hasNext)||h.push(f.NEXT),(null===(t=this.dataState)||void 0===t?void 0:t.hasPrevious)||h.push(f.PREVIOUS),(null===(e=null===(s=this.dataState)||void 0===s?void 0:s.selectionInfo)||void 0===e?void 0:e.isEmpty())&&h.push(f.FORM_MODE),(null===(n=null===(o=this.dataState)||void 0===o?void 0:o.selectionInfo)||void 0===n?void 0:n.length)>1&&h.push(f.CLONE),h}handleCancelEdit(){var i;(null===(i=this.dataState)||void 0===i?void 0:i.recordsIsEmpty)&&(this.goToView(m.GRID),this.dataUnit.clearSelection())}handleConfiguratorEvent(i,t){i.stopImmediatePropagation(),"SAVE"!==t?this.configuratorCancel.emit():this.configuratorSave.emit()}getColumnSearch(i,t){return null!=this._columnSearch||(this._moreOptions=i,this._columnSearch=_(t,(({argument:i})=>new Promise((t=>{this._grid.filterColumns(i).then((i=>{t(i.filter((i=>!i.hidden)).map((i=>({label:i.label,value:i.name}))))}))}))),(t=>{var s;null!=t&&(this._grid.locateColumn(t.value),null===(s=i.hideActions)||void 0===s||s.call(i))}))),this._columnSearch}onSelectField(i,t){null!=i&&(this._fieldToGetFocus=i.value,t.hideActions())}getFieldSearch(i,t){return null!=this._fieldSearch||(this._moreOptions=i,i.addEventListener("ezPopoverOpen",(()=>this.findField())),this._fieldSearch=_(t,(({argument:i})=>this.fieldsOptionLoader(i)),(t=>this.onSelectField(t,i)))),this._fieldSearch}getFormFields(){var i,t;return null!==(t=null===(i=this.formConfig)||void 0===i?void 0:i.fields)&&void 0!==t?t:this._formFields}handleFormSetFields(i){a.equals(this._formFields,i)||(this._formFields=null!=i?i:[])}fieldsOptionLoader(i){const t=null==i?void 0:i.toLowerCase(),s=this.getFormFields().map((i=>{var t;return null===(t=this.dataUnit)||void 0===t?void 0:t.getField(i.name)})).filter((i=>{var s,e;return(null===(s=i.name)||void 0===s?void 0:s.toLowerCase().includes(t))||(null===(e=i.label)||void 0===e?void 0:e.toLowerCase().includes(t))})).map((i=>({value:i.name,label:i.label})));return Promise.resolve(s)}getActionsList(){var i,t;const s=[{value:n.generateUUID(),label:null!==(t=null===(i=this.messagesBuilder)||void 0===i?void 0:i.getMessage("snkSimpleCrud.findColumn",void 0))&&void 0!==t?t:"Buscar",disableCloseOnSelect:!0,eagerInitialize:!0,itemBuilder:(i,t)=>this._currentViewMode===m.GRID?this.getColumnSearch(i,t):this.getFieldSearch(i,t)}];if(null!=this.taskbarManager&&null!=this.taskbarManager.getMoreOptions){const i=this.getTopTaskBarId();return s.concat(this.taskbarManager.getMoreOptions(i,this.configName,this.dataState,this.actionsList))}return s.concat(this.actionsList)}getTopTaskBarId(){var i;return(null===(i=this.dataState)||void 0===i?void 0:i.isDirty)?`snkGridTopTaskbar.finish_edition${b.PRIMARY}`:`snkGridTopTaskbar.regular${b.PRIMARY}`}async keyDownListener(i){i.ctrlKey&&null!=i.key&&"F"===i.key.toUpperCase()&&null!=this._element&&(d.isHiddenElement(this._element)||(l.closeAll(),this._currentViewMode===m.GRID?await this.findColumn():await this.findField(),i.preventDefault()))}async findField(){await this.openSeach(this._fieldSearch)}async findColumn(){await this.openSeach(this._columnSearch)}async openSeach(i){await I(this._moreOptions,i)}clearFieldToFocusHandler(){this._fieldToGetFocus=void 0}connectedCallback(){window.addEventListener("keydown",this._keyDownHandler,{capture:!0})}disconnectedCallback(){window.removeEventListener("keydown",this._keyDownHandler)}gridConfigChangeHandler(i){T.saveGridConfig(i.detail,this.configName,this.resolveResourceID()),i.stopPropagation()}modalConfigChangeHandler(i){const t=i.detail;this._grid.setColumnsState(t.columns).then((()=>{this.setGridConfig(t),this.closeGridConfig(),this.dataExporterProviderStore()})),i.stopPropagation()}async dataExporterProviderStore(){if(null==this.dataUnit)return;if(null==this._grid)return;const i=new O(this.dataUnit,this._grid);D.set("exporterProviders",Object.assign(Object.assign({},D.get("exporterProviders")),{[this.getDataExporterStoreKey()]:i}))}getDataExporterStoreKey(){return`SnkSimpleCrudDataExporter:${null==this.configName?this.dataUnit.name:this.configName}`}setGridConfig(i){this.gridConfig=i,S.assertDefaultSorting(this.gridConfig,this.dataUnit)}setFormConfig(i,t){this.formConfig&&!t||(this.formConfig=i)}closeGridConfig(){this._showPopUpGridConfig=!1}closeFormConfig(){this._showFormConfig=!1}getPageSize(){return this.mode===v.IN_MEMORY?0:null==this.pageSize?150:this.pageSize}handleShowFormConfig(){return this._showFormConfig&&!this.formLegacyConfigName}resolveResourceID(){return n.isEmpty(this.resourceID)?this._resourceID:this.resourceID}getFormConfig(){var i;const t=null===(i=this._formConfigManager)||void 0===i?void 0:i.getConfig(this.dataUnit,this.ignoreReadOnlyFormFields);return this.configName||t?t:this.formConfig}updateFormConfig(){const i=Object.assign(Object.assign({},this.formConfig),{fields:this.dataUnit.metadata.fields});this.setFormConfig(i,!0),null==this._formConfigManager&&(this._formConfigManager=new F(this.configName,this.resolveResourceID())),this._formConfigManager.setConfig(this.formConfig)}render(){var i;if(null!=this.dataUnit)return s("snk-data-unit",{ref:i=>this._snkDataUnit=i,class:"simple-crud__container",dataUnit:this.dataUnit,useCancelConfirm:this.useCancelConfirm,onDataStateChange:i=>this.onDataStateChange(i),onCancelEdition:this.handleCancelEdit.bind(this),pageSize:this.getPageSize(),onInsertionMode:()=>this.goToView(m.FORM),onDataUnitReady:i=>this.dataUnitReady.emit(i.detail),ignoreSaveMessage:this._currentViewMode===m.GRID,onMessagesBuilderUpdated:i=>this.messagesBuilder=i.detail,onDataUnitFieldsHidded:this.updateFormConfig.bind(this),domainMessagesBuilder:this.domainMessagesBuilder},s("header",null,s("slot",{name:"snkSimpleCrudHeader"})),s("section",{class:"ez-box ez-box--shadow simple-crud__container-section"},s("snk-taskbar",{class:"ez-box ez-box--shadow ez-padding--medium",dataUnit:this.dataUnit,primaryButton:(null===(i=this.dataState)||void 0===i?void 0:i.isDirty)?"SAVE":"INSERT","data-element-id":"grid_left",messagesBuilder:this.messagesBuilder,buttons:this._taskbarProcessor.buttons,actionsList:this.getActionsList(),disabledButtons:this._taskbarProcessor.disabledButtons,customButtons:this._taskbarProcessor.customButtons,"data-exporter-store-key":this.getDataExporterStoreKey(),slot:"leftButtons",presentationMode:b.SECONDARY},s("slot",{name:"TASKBAR_CUSTOM_ELEMENTS"})),s("ez-view-stack",{ref:i=>this._viewStack=i,"data-element-id":"simple-crud"},s("stack-item",null,s("ez-grid",{class:"ez-margin-bottom--large",ref:i=>this._grid=i,dataUnit:this.dataUnit,config:this.gridConfig,"no-header":!0,multipleSelection:this.multipleSelection,onEzDoubleClick:()=>this.goToView(m.FORM),onConfigChange:i=>this.gridConfigChangeHandler(i),columnfilterDataSource:this.dataUnit.name&&this.dataUnit.name.includes(y.IN_MEMORY_DATA_UNIT_NAME)?void 0:this._multiSelectionListDataSource,useEnterLikeTab:this.useEnterLikeTab,autoFocus:this.autoFocus},s("div",{slot:"footer"},s("slot",{name:"snkSimpleCrudFooter"})))),s("stack-item",null,s("ez-form",{ref:i=>this._form=i,class:"ez-margin-top--large "+(this.handleShowFormConfig()?"simple-crud__form--hidden":""),dataUnit:this.dataUnit,config:this.getFormConfig(),fieldToFocus:this._fieldToGetFocus,onEzFormSetFields:i=>this.handleFormSetFields(i.detail),onEzFormRequestClearFieldToFocus:this.clearFieldToFocusHandler.bind(this)}),this.handleShowFormConfig()&&s("snk-form-config",{messagesBuilder:this.messagesBuilder,dataUnit:this.dataUnit,configManager:this._formConfigManager,onConfigClose:()=>this.closeFormConfig()})),this.messagesBuilder&&s("snk-configurator",{ref:i=>this._snkConfigurator=i,viewMode:this._currentViewMode,messagesBuilder:this.messagesBuilder,onConfigSelected:i=>this.goToView(i.detail),onOpenConfig:i=>this.openConfig(i.detail),showActionButtons:this.showConfiguratorButtons,onSave:i=>this.handleConfiguratorEvent(i,"SAVE"),onCancel:i=>this.handleConfiguratorEvent(i,"CANCEL"),resourceID:this.resolveResourceID(),customContainerId:this._customContainerId})),s("div",{id:`${this._customContainerId}`},s("slot",{name:"SnkConfigContainerSlot"}))),s("ez-modal",{modalSize:"small",closeEsc:!1,closeOutsideClick:!1,opened:this._showPopUpGridConfig,onEzCloseModal:()=>this.closeGridConfig()},s("snk-grid-config",{ref:i=>this._snkGridConfig=i,config:this.gridConfig,"data-element-id":this._element.getAttribute(u.DATA_ELEMENT_ID_ATTRIBUTE_NAME),selectedIndex:0,configName:this.configName,onConfigChange:i=>this.modalConfigChangeHandler(i),onConfigCancel:()=>this.closeGridConfig(),resourceID:this.resolveResourceID()})))}get _element(){return e(this)}static get watchers(){return{resourceID:["handleResourceIDChanged"],entityName:["onChangeEntityName"],mode:["onModeChange"],dataState:["observeDataState"],formLegacyConfigName:["observeFormLegacy"],gridLegacyConfigName:["observeGridLegacy"]}}};P.style=".sc-snk-simple-crud-h{display:flex;height:100%;width:100%;--snk-simple-crud-grid--min-height:300px}.simple-crud__container.sc-snk-simple-crud{display:grid;grid-template-rows:auto 1fr;row-gap:12px;height:100%;width:100%}.simple-crud__container-section.sc-snk-simple-crud{flex-wrap:unset;flex-direction:column}.simple-crud__form--hidden.sc-snk-simple-crud{display:none}ez-grid.sc-snk-simple-crud{--ez-grid__container--shadow:none;--ez-grid--min-height:var(--snk-simple-crud-grid--min-height)}ez-form.sc-snk-simple-crud{min-height:300px}";export{P as snk_simple_crud}
@@ -1 +1 @@
1
- import{r as t,c as i,h as e,H as s,g as r}from"./p-d2d301a6.js";import{ElementIDUtils as o,ObjectUtils as l}from"@sankhyalabs/core";import{F as a}from"./p-ff1990ad.js";import{E as n}from"./p-1a68fb59.js";import{C as d}from"./p-aff76a53.js";import{F as h}from"./p-d9804798.js";import"./p-df5451c7.js";import"./p-dc7c9047.js";import"./p-8d884fab.js";import"@sankhyalabs/core/dist/dataunit/metadata/UnitMetadata";const c=class{constructor(e){t(this,e),this.filterChange=i(this,"filterChange",7),this.editPersonalizedFilter=i(this,"editPersonalizedFilter",7),this.addPersonalizedFilter=i(this,"addPersonalizedFilter",7),this.filterItem=void 0,this.configName=void 0,this.resourceID=void 0}observeFilterItem(t){var i,e;this._editor&&(this._editor.config=t),null===(e=null===(i=this._editor)||void 0===i?void 0:i.reloadList)||void 0===e||e.call(i),this.filterChange.emit(t)}getContentEditorConfig(){const t={presentationMode:n.MODAL};switch(this.filterItem.type){case a.BINARY_SELECT:return{tag:"snk-filter-binary-select",props:t};case a.MULTI_SELECT:return{tag:"snk-filter-multi-select"};case a.PERIOD:return{tag:"snk-filter-period",props:t};case a.SEARCH:return{tag:"snk-filter-search"};case a.NUMBER:return{tag:"snk-filter-number",props:t};case a.PERSONALIZED:return this.buildSnkFilterPersonalizedProps();case a.CHECK_BOX_LIST:return{tag:"snk-filter-checkbox-list",props:t};case a.MULTI_LIST:return{tag:"snk-entity-list",props:{maxHeightList:"640px",rightListSlotBuilder:t=>this.buildRightSlot(t)}}}return{tag:"snk-filter-text"}}buildSnkFilterPersonalizedProps(){return{tag:"snk-personalized-filter-editor",props:{onEditFilter:t=>this.editPersonalizedFilter.emit(t.detail),onAddFilter:()=>this.addPersonalizedFilter.emit()}}}isVisible(t){return!!this.filterItem.visible||void 0!==t}updateFilterValue(t){const i=void 0!==(null==t?void 0:t.value)?t.value:t;this.filterItem=Object.assign(Object.assign({},this.filterItem),null!=this.filterItem.groupedItems?{visible:i>0,value:i,groupedItems:t.items}:{value:this.filterItem.type===(a.SEARCH||a.CHECK_BOX_LIST)?t:i,visible:this.isVisible(i)})}handleDeleteFilter(t,i){i===a.PERSONALIZED&&d.removePersonalizedFilter(t,this.resourceID,this.configName)}componentDidLoad(){if(this._element){o.addIDInfo(this._element);const t=this._element.getAttribute(o.DATA_ELEMENT_ID_ATTRIBUTE_NAME);this._idContentEditor=`${t}_${this.filterItem.id}`}}buildRightSlot(t){return e("ez-icon",{iconName:"delete",onClick:()=>this.removeValueFromConfig(t)})}removeValueFromConfig(t){var i,e,s;const r=null===(e=null===(i=this.filterItem)||void 0===i?void 0:i.value)||void 0===e?void 0:e.findIndex((({id:i})=>i===t.id)),o=l.copy(this.filterItem);null===(s=null==o?void 0:o.value)||void 0===s||s.splice(r,1),this.updateFilterValue(o.value)}canShowDetailModal(){const{CUSTOM_FILTER:t,OTHER_FILTERS:i}=h;return![t,i].includes(this.filterItem.filterType)&&this.filterItem.type!==a.BINARY_SELECT}render(){const{tag:t,props:i}=this.getContentEditorConfig();return e(s,null,e("div",{class:"ez-flex ez-flex--column grow"},this.canShowDetailModal()&&e("div",{class:"col ez-col--sd-12 ez-align--right ez-padding-medium ez-flex--align-items-center"},e("div",{class:"ez-title ez-title--small ez-title--primary grow"},this.filterItem.detailModal)),e(t,Object.assign({ref:t=>this._editor=t,config:this.filterItem,value:this.filterItem.value,onValueChanged:t=>this.updateFilterValue(t.detail),"data-element-id":this._idContentEditor},i))))}get _element(){return r(this)}static get watchers(){return{filterItem:["observeFilterItem"]}}};c.style=".grow{flex-grow:1}.gap{gap:4px}";export{c as snk_filter_modal_item}
1
+ import{r as t,c as i,h as e,H as s,g as r}from"./p-d2d301a6.js";import{ElementIDUtils as o,ObjectUtils as l}from"@sankhyalabs/core";import{F as a}from"./p-ff1990ad.js";import{E as n}from"./p-1a68fb59.js";import{C as d}from"./p-52920496.js";import{F as h}from"./p-d9804798.js";import"./p-df5451c7.js";import"./p-dc7c9047.js";import"./p-8d884fab.js";import"@sankhyalabs/core/dist/dataunit/metadata/UnitMetadata";const c=class{constructor(e){t(this,e),this.filterChange=i(this,"filterChange",7),this.editPersonalizedFilter=i(this,"editPersonalizedFilter",7),this.addPersonalizedFilter=i(this,"addPersonalizedFilter",7),this.filterItem=void 0,this.configName=void 0,this.resourceID=void 0}observeFilterItem(t){var i,e;this._editor&&(this._editor.config=t),null===(e=null===(i=this._editor)||void 0===i?void 0:i.reloadList)||void 0===e||e.call(i),this.filterChange.emit(t)}getContentEditorConfig(){const t={presentationMode:n.MODAL};switch(this.filterItem.type){case a.BINARY_SELECT:return{tag:"snk-filter-binary-select",props:t};case a.MULTI_SELECT:return{tag:"snk-filter-multi-select"};case a.PERIOD:return{tag:"snk-filter-period",props:t};case a.SEARCH:return{tag:"snk-filter-search"};case a.NUMBER:return{tag:"snk-filter-number",props:t};case a.PERSONALIZED:return this.buildSnkFilterPersonalizedProps();case a.CHECK_BOX_LIST:return{tag:"snk-filter-checkbox-list",props:t};case a.MULTI_LIST:return{tag:"snk-entity-list",props:{maxHeightList:"640px",rightListSlotBuilder:t=>this.buildRightSlot(t)}}}return{tag:"snk-filter-text"}}buildSnkFilterPersonalizedProps(){return{tag:"snk-personalized-filter-editor",props:{onEditFilter:t=>this.editPersonalizedFilter.emit(t.detail),onAddFilter:()=>this.addPersonalizedFilter.emit()}}}isVisible(t){return!!this.filterItem.visible||void 0!==t}updateFilterValue(t){const i=void 0!==(null==t?void 0:t.value)?t.value:t;this.filterItem=Object.assign(Object.assign({},this.filterItem),null!=this.filterItem.groupedItems?{visible:i>0,value:i,groupedItems:t.items}:{value:this.filterItem.type===(a.SEARCH||a.CHECK_BOX_LIST)?t:i,visible:this.isVisible(i)})}handleDeleteFilter(t,i){i===a.PERSONALIZED&&d.removePersonalizedFilter(t,this.resourceID,this.configName)}componentDidLoad(){if(this._element){o.addIDInfo(this._element);const t=this._element.getAttribute(o.DATA_ELEMENT_ID_ATTRIBUTE_NAME);this._idContentEditor=`${t}_${this.filterItem.id}`}}buildRightSlot(t){return e("ez-icon",{iconName:"delete",onClick:()=>this.removeValueFromConfig(t)})}removeValueFromConfig(t){var i,e,s;const r=null===(e=null===(i=this.filterItem)||void 0===i?void 0:i.value)||void 0===e?void 0:e.findIndex((({id:i})=>i===t.id)),o=l.copy(this.filterItem);null===(s=null==o?void 0:o.value)||void 0===s||s.splice(r,1),this.updateFilterValue(o.value)}canShowDetailModal(){const{CUSTOM_FILTER:t,OTHER_FILTERS:i}=h;return![t,i].includes(this.filterItem.filterType)&&this.filterItem.type!==a.BINARY_SELECT}render(){const{tag:t,props:i}=this.getContentEditorConfig();return e(s,null,e("div",{class:"ez-flex ez-flex--column grow"},this.canShowDetailModal()&&e("div",{class:"col ez-col--sd-12 ez-align--right ez-padding-medium ez-flex--align-items-center"},e("div",{class:"ez-title ez-title--small ez-title--primary grow"},this.filterItem.detailModal)),e(t,Object.assign({ref:t=>this._editor=t,config:this.filterItem,value:this.filterItem.value,onValueChanged:t=>this.updateFilterValue(t.detail),"data-element-id":this._idContentEditor},i))))}get _element(){return r(this)}static get watchers(){return{filterItem:["observeFilterItem"]}}};c.style=".grow{flex-grow:1}.gap{gap:4px}";export{c as snk_filter_modal_item}
@@ -1 +1 @@
1
- import{r as t,h as i,H as s,g as e,c as n}from"./p-d2d301a6.js";import{ApplicationContext as o,StringUtils as r,ErrorException as a,WarningException as l,ObjectUtils as c,DateUtils as d,ArrayUtils as h,ElementIDUtils as u}from"@sankhyalabs/core";import{D as g}from"./p-dc7c9047.js";import{P as f}from"./p-eaad0aa8.js";import"./p-af8efd95.js";import"./p-30cf616e.js";import"./p-21749402.js";import"@sankhyalabs/ezui/dist/collection/utils/constants";import"@sankhyalabs/core/dist/dataunit/metadata/UnitMetadata";import"./p-fe79f83a.js";import"./p-ff1990ad.js";import"./p-df5451c7.js";import{R as m}from"./p-688dcb4c.js";import{ApplicationUtils as p,DialogType as v}from"@sankhyalabs/ezui/dist/collection/utils";import{CheckMode as b}from"@sankhyalabs/ezui/dist/collection/components/ez-check/CheckMode";import{C as k}from"./p-aff76a53.js";import{O as _}from"./p-b0ef4383.js";import"./p-8d884fab.js";import"@sankhyalabs/ezui/dist/collection/components/ez-grid/utils";import"@sankhyalabs/core/dist/utils/SortingUtils";class w{execute(t){var i;const s={actionID:t.actionID,refreshType:null===(i=t.actionConfig.javaCall)||void 0===i?void 0:i.refreshType};return new Promise((t=>{t({execSource:s,callback:this.callExecJava})}))}async callExecJava(t){const i={requestBody:{javaCall:t}};await g.get().callServiceBroker("ActionButtonsSP.executeJava",JSON.stringify(i))}}class C{execute(t){var i;const s={actionID:t.actionID,refreshType:null===(i=t.actionConfig.runScript)||void 0===i?void 0:i.refreshType};return new Promise((t=>{t({execSource:s,callback:this.callExecScript})}))}async callExecScript(t){const i={runScript:t};await g.get().callServiceBroker("ActionButtonsSP.executeScript",i)}}class y{constructor(){this._application=o.getContextValue("__SNK__APPLICATION__")}async execute(t,i){const s=t.resourceID;if(!s)return;let e=await this.buildLaunchObject(t,i);return this._application.openApp(s,e),null}buildLaunchObject(t,i){return new Promise((s=>{let e=t.actionConfig.params.param;if(e&&e.length>0){let n={},o=[];e.forEach((s=>{const e=s.localField;let l=i.getFieldValue(e);if(!l){let s=i.getField(e).label;throw s=r.isEmpty(i.getField(e).label)?e:s,new a(this._application.messagesBuilder.getMessage("snkActionsButton.title.error",void 0),this._application.messagesBuilder.getMessage("snkActionsButton.launchScreen.emptyField",{description:t.description,localFieldLabel:s}))}l=r.isEmpty(l.toString())?void 0:l.toString(),n[s.targetField]=l,o.push({fieldName:s.targetField,value:l})})),n.ACTION_PARAMETERS=o,n.call_time=Date.now(),s(n)}s(null)}))}}class x{execute(t){var i,s,e;const n=null===(i=t.actionConfig.dbCall)||void 0===i?void 0:i.name,o=null===(s=t.actionConfig.dbCall)||void 0===s?void 0:s.rootEntity,r={actionID:t.actionID,refreshType:null===(e=t.actionConfig.dbCall)||void 0===e?void 0:e.refreshType,procName:n,rootEntity:o};return new Promise((t=>{t({execSource:r,callback:this.callExecProcedure})}))}async callExecProcedure(t){const i={requestBody:{stpCall:t}};await g.get().callServiceBroker("ActionButtonsSP.executeSTP",JSON.stringify(i))}}var S,z;!function(t){t.LAUNCH_SCREEN="LC",t.JAVASCRIPT="SC",t.JAVA="RJ",t.PROCEDURE="SP",t.EMBEDDED="EB"}(S||(S={}));class A{constructor(t){this.actionType=t,this._application=o.getContextValue("__SNK__APPLICATION__")}get executor(){switch(this.actionType){case S.LAUNCH_SCREEN:return new y;case S.JAVASCRIPT:return new C;case S.JAVA:return new w;case S.PROCEDURE:return new x;default:throw new a(this._application.messagesBuilder.getMessage("snkActionsButton.title.error",void 0),this._application.messagesBuilder.getMessage("snkActionsButton.action.nonExistentType",{actionType:this.actionType}))}}}!function(t){t.NONE="NONE",t.PARENT="PARENT",t.MASTER="MASTER",t.ALL="ALL"}(z||(z={}));const O="__MASTER_ROW__";class N{constructor(t,i,s){var e;this._lastValuesCache={},this._actionsExecuteInterface=t,this._dataUnit=i,this._selectedRows=(null===(e=null==i?void 0:i.getSelectionInfo())||void 0===e?void 0:e.isAllRecords())?[]:null==i?void 0:i.getSelectionInfo().records,this._application=o.getContextValue("__SNK__APPLICATION__"),this._appResourceId=s}apply(t,i){this._application.closePopUp(),this._actionsExecuteInterface.execute(t,this._dataUnit).then((({execSource:s,callback:e})=>{this.resolvePromptParams(t,s,i).then((()=>{this.actionExecute(s,e)}))}))}async execute(t){var i;if(!t.actionConfig)throw new l(this._application.messagesBuilder.getMessage("snkActionsButton.title.warning",void 0),this._application.messagesBuilder.getMessage("snkActionsButton.action.incorrectAction",{description:t.description}));if(null===(i=t.actionConfig.params)||void 0===i?void 0:i.promptParam){const i=t.actionConfig.params.promptParam;let s=!1;for(let t=0;t<i.length;t++)if(!s&&"true"===i[t].saveLast){s=!0;break}s&&(t.actionConfig.params.promptParam=await this.loadSavedValuesIntoParams(t));const e=document.createElement("snk-actions-form");window.document.body.appendChild(e),e.action=c.copy(t),e.applyParameters=t=>{this.apply(t,s)},e.openPopup()}else t.type!=S.LAUNCH_SCREEN?this._actionsExecuteInterface.execute(t,this._dataUnit).then((({execSource:t,callback:i})=>{this.actionExecute(t,i)})):this._actionsExecuteInterface.execute(t,this._dataUnit)}loadSavedValuesIntoParams(t){return this.loadLastValues(t).then((i=>{let s=t.actionConfig.params.promptParam;return i&&i.param.forEach((t=>{s=s.map((i=>i.name!==t.paramName?i:Object.assign(Object.assign({},i),"B"===i.paramType?{value:"S"===t.$}:{value:t.$})))})),s}))}actionExecute(t,i){t.virtualPage=this.buildVirtualPage(),this.prepareAndExecute(t,i),this.recordsReloader(t.refreshType)}resolvePromptParams(t,i,s){return new Promise((e=>{let n=[];t.actionConfig.params.promptParam.forEach((t=>{n.push(this.buildPromptParam(t))})),this.putParamsOnExecSource(n,i),s&&this.saveLastValues(t,n),e()}))}buildPromptParam(t){let i,s,e=t.paramType,n=!1,o=t.value;switch(e){case f.DATE:e="D";break;case f.DATETIME:e="H";break;case f.DECIMAL:e="F",i={"sk-precision":Number(t.precision)};break;case f.BOOLEAN:e="S",n=!0,o=t.value?"S":"N";break;case f.ENTITY:i={"sk-entity-name":t.entityName,"sk-allow-show-hierarchical-mode":t.hierarchyEntity,"sk-data-type":"S"},t.hierarchyEntity&&t.entityPK&&(s=t.entityPK),o=t.value?Number(t.value):null;break;case f.OPTIONS:e="O";let r=t.options.split(";").map((function(t,i){let s,e;if(t.indexOf("=")>-1){let i=t.split("=");s=i[0],e=i[1]}else s=i+1,e=t;return{data:s,value:e}}));i={"sk-options":r}}return{description:t.label,required:"true"==t.required,fieldName:t.name,fieldNameOri:t.name,entityPK:s,paramType:t.paramType,type:e,isCheckbox:n,saveLast:t.saveLast,fieldProp:i,value:o,isGeneratedName:t.isGeneratedName}}putParamsOnExecSource(t,i){i.params={param:[]},t.forEach((t=>{if(t.isGeneratedName&&t.value)throw new a(this._application.messagesBuilder.getMessage("snkActionsButton.title.error",void 0),this._application.messagesBuilder.getMessage("snkActionsButton.action.emptyParamName",void 0));r.isEmpty(t.value)||i.params.param.push({type:this.getParamDataType(t.paramType),paramName:t.fieldName,$:this.getParamValue(t)})}))}getParamDataType(t){let i;switch(t){case"D":i="F";break;case"DT":case"DH":i="D";break;case"B":case"ENTITY":case"SO":i="S";break;default:i=t}return i}getParamValue(t){let i=t.value;return i?("DT"==t.paramType?i=d.formatDate(i):"DH"==t.paramType&&(i=d.formatDateTime(i)),i):i}async loadLastValues(t){const i=await this.buildResourceId(t.actionID);return new Promise(((t,s)=>{if(this._lastValuesCache[i])t(this._lastValuesCache[i]);else{const e={config:{chave:i,tipo:"T"}};g.get().callServiceBroker("SystemUtilsSP.getConf",e).then((s=>{var e,n;let o;(null===(n=null===(e=s.config)||void 0===e?void 0:e.data)||void 0===n?void 0:n.params)&&(o=s.config.data.params,Array.isArray(o.param)||(o.param=[o.param])),this._lastValuesCache[i]=o,t(o)})).catch((t=>{s(t)}))}}))}async saveLastValues(t,i){if(this._application){let s={params:{param:[]}};i.forEach((t=>{"true"==t.saveLast&&s.params.param.push({paramName:t.fieldName,$:t.value})}));const e=await this.buildResourceId(t.actionID);this._lastValuesCache[e]=s.params,this._application.saveConfig(e,s)}}async buildResourceId(t){return this._appResourceId+".actionconfig."+t}prepareAndExecute(t,i){this.addRows(t),i(t)}addRows(t){const i={row:[]},s=this._selectedRows;for(const t in s){const e=s[t],n={};e.hasOwnProperty(O)&&(n.master="S",n.entityName=e.__ENTITY_NAME__,delete e[O],delete e.__ENTITY_NAME__);for(const t in e)"NUFIN"===t&&(n.field||(n.field=[]),n.field.push({fieldName:t,$:e[t]}));i.row.push(n)}i.row.length>0&&(t.rows=i)}recordsReloader(t){switch(t){case z.NONE:break;case z.PARENT:case z.MASTER:case z.ALL:this._dataUnit.loadData();break;default:this._dataUnit.reloadCurrentRecord()}}buildVirtualPage(){var t,i,s,e;if(null===(i=null===(t=this._dataUnit)||void 0===t?void 0:t.getSelectionInfo())||void 0===i?void 0:i.isAllRecords())return{filters:{filters:null===(s=this._dataUnit)||void 0===s?void 0:s.getAppliedFilters()},orders:{orders:null===(e=this._dataUnit)||void 0===e?void 0:e.getSort()}}}}class P{async clientConfirm(t,i){return new Promise((s=>{const e=o.getContextValue("__SNK__APPLICATION__");let n="";t.content.event.hasOwnProperty("stpCall")?(i.requestBody=t.content.event.stpCall,n=S.PROCEDURE):t.content.event.hasOwnProperty("runScript")?(i.requestBody=t.content.event.runScript,n=S.JAVASCRIPT):t.content.event.hasOwnProperty("javaCall")&&(i.requestBody=t.content.event.javaCall,n=S.JAVA);let r={type:"S",sequence:t.content.event.sequence};i.requestBody.params?Array.isArray(i.requestBody.params.param)||(i.requestBody.params.param=[i.requestBody.params.param]):i.requestBody.params={param:[]},i.requestBody.params.param.push(r);const a=t.content.event.title.$,l=t.content.event.message.$;let c;switch(n){case S.JAVASCRIPT:c={runScript:i.requestBody};break;case S.PROCEDURE:c={requestBody:{stpCall:i.requestBody}};break;case S.JAVA:c={requestBody:{javaCall:i.requestBody}}}if("S"==t.content.event.showNoOption){r.paramName="__ESCOLHA_SIMNAO__";const t=document.createElement("snk-client-confirm");window.document.body.appendChild(t),t.titleMessage=a,t.message=l,t.accept=async()=>{r.$="S",await i.reCall(c),s()},t.cancel=async()=>{r.$="N",await i.reCall(c),s()},t.openPopup()}else e.confirm(a,l,null,"warn",{labelCancel:"Cancelar",labelConfirm:"Sim"}).then((async t=>{t&&(r.paramName="__CONFIRMACAO__",r.$="S",await i.reCall(c),s())}))}))}}const D=class{constructor(i){t(this,i),this.CLIENT_EVENT_CONFIRM_NAME="br.com.sankhya.actionbutton.clientconfirm",this.handleClick=t=>{const i=this._actions.find((i=>i.actionID==t.detail.id)),s=new A(i.type).executor;new N(s,this._dataUnit,this._resourceID).execute(Object.assign({},i)),this._showDropdown=!1},this._items=[],this._showDropdown=!1,this._actions=[],this._isOrderActions=!1}async getActions(){let t={param:{entityName:this._entityName,resourceID:this._resourceID}};return g.get().callServiceBroker("ActionButtonsSP.getActions",t).then((t=>{var i;(null===(i=t.actions)||void 0===i?void 0:i.action)&&(this._actions=this._isOrderActions?h.sortAlphabetically(t.actions.action,"description"):t.actions.action)}))}controlDropdown(){this._showDropdown=!this._showDropdown}canShowDropdown(){var t;return this._showDropdown&&(null===(t=this._items)||void 0===t?void 0:t.length)>0}positionDropdown(){var t;const i=null===(t=this._ezButton)||void 0===t?void 0:t.getBoundingClientRect();i&&this._dropdownParent&&(this._dropdownParent.style.top=i.y+i.height+5+"px",this._dropdownParent.style.left=i.x+"px")}closeDropdown(t){const i=null==t?void 0:t.target;i&&(i.closest(".snk-actions-button")||(this._showDropdown=!1))}setEvents(){document.removeEventListener("click",this.closeDropdown.bind(this)),document.addEventListener("click",this.closeDropdown.bind(this)),document.removeEventListener("scroll",this.positionDropdown.bind(this)),document.addEventListener("scroll",this.positionDropdown.bind(this))}async componentWillLoad(){this._application=o.getContextValue("__SNK__APPLICATION__"),this._isOrderActions=await this._application.getBooleanParam("global.ordenar.acoes.personalizadas");const t=this._element.parentElement;this._dataUnit=null==t?void 0:t.dataUnit,this._resourceID=null==t?void 0:t.resourceID,this._entityName=this._dataUnit.name.split("/")[2],null==this._resourceID&&(this._resourceID=await m.getResourceID()),this.setEvents(),this.getActions().then((()=>{this.loadItems()}))}async componentDidLoad(){if(this._element&&(u.addIDInfo(this._element),this.positionDropdown(),!await this._application.hasClientEvent(this.CLIENT_EVENT_CONFIRM_NAME))){const t=new P;this._application.addClientEvent(this.CLIENT_EVENT_CONFIRM_NAME,t.clientConfirm)}}componentDidUpdate(){this.positionDropdown()}loadItems(){this._actions&&0!=this._actions.length&&this._actions.forEach((t=>{this._items.push({id:t.actionID,label:t.description})}))}getElementID(t){return{[u.DATA_ELEMENT_ID_ATTRIBUTE_NAME]:u.getInternalIDInfo(t)}}render(){return i(s,null,this._actions&&this._actions.length>0&&i("div",{class:`ez-padding-left--medium snk-actions-button\n ${this.canShowDropdown()?" ez-elevation--16":""}\n `},i("ez-button",Object.assign({ref:t=>this._ezButton=t,iconName:"acao",size:"small",mode:"icon",title:this._application.messagesBuilder.getMessage("snkActionsButton.title.actions",void 0),onClick:()=>this.controlDropdown()},this.getElementID("button"))),i("div",Object.assign({ref:t=>this._dropdownParent=t,class:(this.canShowDropdown()?"snk-actions-button__dropdown--show":"snk-actions-button__dropdown")+"\n "},this.getElementID("dropdown")),this.canShowDropdown()&&i("ez-dropdown",Object.assign({items:this._items,onEzClick:t=>this.handleClick(t)},this.getElementID("dropdown"))))),this.canShowDropdown()&&i("div",Object.assign({class:"ez-scrim ez-scrim--light"},this.getElementID("ezScrim"))))}get _element(){return e(this)}};D.style=".sc-snk-actions-button-h{display:flex;width:fit-content;height:fit-content}.snk-actions-button.sc-snk-actions-button{display:flex;width:fit-content;height:fit-content}.snk-actions-button__dropdown--show.sc-snk-actions-button{display:flex;flex-direction:column;position:fixed}.snk-actions-button__dropdown.sc-snk-actions-button>ez-dropdown.sc-snk-actions-button{position:relative}.snk-actions-button__dropdown.sc-snk-actions-button{display:none}";const I=class{constructor(i){t(this,i),this.configChange=n(this,"configChange",7),this.configCancel=n(this,"configCancel",7),this._orderListItems=[],this._orderPriorityList=[],this._columListItems=[],this._selectedIndex=-1,this._dataChanged=!1,this._componenteInternalKey=Date.now(),this.selectedIndex=0,this.columns=void 0,this.config=void 0,this.configName=void 0,this.resourceID=void 0}getMessage(t,i){return o.getContextValue("__SNK__APPLICATION__").messagesBuilder.getMessage(t,i)}getSortableColumns(){let t=[];return this.columns.filter((t=>{var i;return r.getBooleanValue(null===(i=null==t?void 0:t.props)||void 0===i?void 0:i.get("sortable"),!0)})).forEach((i=>{var s;let e=null===(s=this.config)||void 0===s?void 0:s.columns.find((t=>t.name===i.name)),n={name:i.name,label:i.label};e&&(n.orderIndex=e.orderIndex,n.ascending=e.ascending),i.hidden||t.push(n)})),t}createOrderList(){let t=this.getSortableColumns();t.sort(((t,i)=>0!=t.orderIndex||0!=i.orderIndex||null==t.ascending&&null==i.ascending?null!=t.ascending&&null!=i.ascending?t.orderIndex-i.orderIndex:null!=t.ascending||null!=i.ascending?null!=t.ascending?-1:null!=i.ascending?1:0:t.orderIndex-i.orderIndex:null!=t.ascending?-1:null!=i.ascending?1:0)),this._orderListItems=t}createColumnList(){let t={group:this.getMessage("snkGridConfig.group.visible"),items:[]},i={group:this.getMessage("snkGridConfig.group.hidden"),items:[],sort:_.asc.value};this.columns.forEach((s=>{let e={label:s.label};s.hidden?i.items.push(e):t.items.push(e)})),this._columListItems=[t,i]}createColumnListSlotDataElementId(t){return`configItem_${r.replaceAccentuatedChars(r.toCamelCase(t.label))}`}buildColumnListSlot(t,s){const e=this.createColumnListSlotDataElementId(t);return i("div",null,i("ez-check",{mode:b.SWITCH,id:b.SWITCH+((null==t?void 0:t.label)||"")+((null==s?void 0:s.group)||""),value:s.group===this.getMessage("snkGridConfig.group.visible"),"data-element-id":e,onEzChange:i=>{this.switchColumnGroup(i,t)}}))}createOrderListSlotDataElementId(t){return`${this._element.getAttribute(u.DATA_ELEMENT_ID_ATTRIBUTE_NAME)}_configItem_${r.toCamelCase(t.label)}`}buildOrderListSlot(t){const s=this.createOrderListSlotDataElementId(t);let e=_.none.value;return null!=(null==t?void 0:t.ascending)&&(e=1==t.ascending?_.asc.value:_.desc.value),i("div",null,i("snk-select-box",{selectedOption:e,key:"snk-select-box-"+this._componenteInternalKey+"-"+t,"data-element-id":s,onEzChange:i=>{i.stopPropagation(),this.updateOrder(i.detail,t.label)}}))}updateOrder(t,i){var s;this._dataChanged=!0;let e,n=[...this.columns],o=n.find((t=>t.label===i));o&&(o.sort=t.value===_.none.value?void 0:t.value),(null===(s=this._orderPriorityList)||void 0===s?void 0:s.length)>0?(this._orderPriorityList.find((t=>t.label===o.label)).sort=t,this._orderPriorityList.filter((t=>t.sort)).forEach(((t,i)=>{t.label===o.label&&(o.sortIndex=i)}))):(e=n.filter((t=>t.sort&&!0!==t.hidden)).map(((t,i)=>({label:t.label,orderIndex:i}))),e.forEach((t=>{n.find((i=>i.label===t.label)).sortIndex=t.orderIndex}))),this.columns=n}switchColumnGroup(t,i){t.stopPropagation();let s=[...this._columListItems];if(this._dataChanged=!0,!0===t.detail){let t=s.find((t=>t.group===this.getMessage("snkGridConfig.group.hidden"))),e=t.items.findIndex((t=>t.label===i.label));e>=0&&t.items.splice(e,1),s.find((t=>t.group===this.getMessage("snkGridConfig.group.visible"))).items.push(i),this._columListItems=s,this.createOrderList()}else if(!1===t.detail){let t=s.find((t=>t.group===this.getMessage("snkGridConfig.group.visible"))),e=t.items.findIndex((t=>t.label===i.label));e>=0&&t.items.splice(e,1),s.find((t=>t.group===this.getMessage("snkGridConfig.group.hidden"))).items.push(i),this._columListItems=s,this.createOrderList()}}finish(){if(!this._dataChanged)return void this.closeConfig();let t=[];this._columListItems.forEach((i=>{i.items.forEach((s=>{const e=this.columns.find((t=>t.label===s.label));let n=Object.assign({},e);n.hidden=i.group===this.getMessage("snkGridConfig.group.hidden"),t.push(n)}))})),this.columns=t,this._dataChanged=!1,this.closeConfig(),this.save()}saveGridConfigOnStorage(t){k.saveGridConfig(t,this.configName,this.resourceID).then((t=>{this.configChange.emit(t),this._orderList.clearHistory(),p.info(this.getMessage("snkGridConfig.info.successfullyConfigSaved"),{iconName:"check"})}))}reOrderPriorityColumns(t,i){let s=[];s=t.filter((t=>t.sort&&!0!==t.hidden)).map((t=>({label:t.label,orderIndex:0})));let e=0,n=[];return i.forEach((t=>{let i=s.find((i=>i.label===t.label));i&&(i.orderIndex=e,n.push(i),e++)})),n.length>0&&(s=n),s}save(){var t;let i;i=this.config?this.config:this.createConfigFromState(this.columns);let s,e=[];(null===(t=this._orderPriorityList)||void 0===t?void 0:t.length)>0&&(s=this.reOrderPriorityColumns(this.columns,this._orderPriorityList)),this.columns.forEach((t=>{let n=i.columns.find((i=>t.name===i.name));!0===t.hidden&&n||(n?n.width=t.width:!1===t.hidden&&(n={name:t.name,width:t.width,orderIndex:0}),n&&(t.sort?(n.ascending=t.sort.toUpperCase()===_.asc.value,s?function(t,i){if(s){let e=s.find((i=>i.label===t.label));e&&(i.orderIndex=e.orderIndex)}}(t,n):n.orderIndex=t.sortIndex):(delete n.ascending,n.orderIndex=0),e.push(n)))})),i.columns=e,this.saveGridConfigOnStorage(i)}createConfigFromState(t){let i={columns:[]};return t.forEach((t=>{if(!t.hidden){let s={name:t.name};t.width&&(s.width=t.width),t.sort?(s.ascending=t.sort.toUpperCase()===_.asc.value,s.orderIndex=t.sortIndex):s.orderIndex=0,s&&i.columns.push(s)}})),i}async locateColumn(t,i){var s;const e="Enter"===t.key;if(!(i=i||(null===(s=t.currentTarget)||void 0===s?void 0:s.value)))return void this.removeSelection();const n=await this.getMatchedIndexes(i),o=this.getNewSelectedIndex(n,e);this._selectedIndex=o,1===this.selectedIndex?this.updateOrderListSelection(o):this.updateColumnListSelection(o)}async getMatchedIndexes(t){const i=[];return 1===this.selectedIndex?(await this._orderList.getList()).forEach(((s,e)=>{this.compareWords(s,t)&&i.push(e)})):this.columns.forEach(((s,e)=>{this.compareWords(s,t)&&i.push(e)})),i}getNewSelectedIndex(t,i){if(0===t.length)return-1;if(i)for(const i of t)if(i>this._selectedIndex)return i;return t[0]}updateOrderListSelection(t){-1!==t?this._orderList.getList().then((i=>{const s=i[t];s?this._orderList.setSelection(s,!0):this._orderList.removeSelection()})):this._orderList.removeSelection()}updateColumnListSelection(t){if(-1===t)return void this._columnList.removeSelection();const i=this.columns[t];if(i){const t=this._columListItems.map((t=>t.items)).flat().find((t=>t.label===i.label));t?this._columnList.setSelection(t,!0):this._columnList.removeSelection()}else this._columnList.removeSelection()}removeSelection(){1===this.selectedIndex?this._orderList.removeSelection():this._columnList.removeSelection()}compareWords(t,i){var s,e;const n=null===(s=r.replaceAccentuatedChars(null==t?void 0:t.label))||void 0===s?void 0:s.toUpperCase(),o=null===(e=r.replaceAccentuatedChars(i))||void 0===e?void 0:e.toUpperCase();return!r.isEmpty(n)&&!r.isEmpty(o)&&n.includes(o)}getColumnNames(){const t=[];return t.push(this.getMessage("snkGridConfig.tab.columns")),t.push(this.getMessage("snkGridConfig.tab.lineOrdering")),t.join(",")}closeConfig(){if(this._orderList.scrollToTop(),this._columnList.scrollToTop(),this._searchElement.value="",this._dataChanged){let t={canClose:!1,labelCancel:this.getMessage("snkGridConfig.confirm.cancel"),labelConfirm:this.getMessage("snkGridConfig.confirm.save"),btnConfirmDanger:!1};p.confirm(this.getMessage("snkGridConfig.confirm.alert"),this.getMessage("snkGridConfig.confirm.msgCancel"),null,v.WARN,t).then((t=>{t?this.finish():(this._dataChanged=!1,this.configCancel.emit(),this._orderList.clearHistory(),this._componenteInternalKey=Date.now())}))}else this.configCancel.emit(),this._orderList.clearHistory()}handleTabChange(t){null!=(null==t?void 0:t.index)&&(this.selectedIndex!==t.index&&(0===t.index?this._orderList.scrollToTop():1===t.index&&this._columnList.scrollToTop(),this._searchElement.value=""),1===t.index&&this.createOrderList(),this.selectedIndex=t.index)}handleColumnListChange(t){var i;if(t.detail){let s=null===(i=t.detail.find((t=>t.group===this.getMessage("snkGridConfig.group.visible"))))||void 0===i?void 0:i.items;s&&(this._dataChanged=!0,this._orderListItems=s)}}handleOrderListChange(t){if(t.detail){let i=t.detail;i&&(this._dataChanged=!0,this._orderPriorityList=i)}}componentWillRender(){var t;(null===(t=this.columns)||void 0===t?void 0:t.length)>0&&this.createColumnList()}componentDidRender(){var t;(null===(t=this.columns)||void 0===t?void 0:t.length)>0&&this.locateColumn(new KeyboardEvent("arrow-right",{key:"ArrowRight"}),this._searchElement.value)}componentDidLoad(){u.addIDInfo(this._element)}render(){return i(s,null,i("div",{class:"grid-config__header"},i("div",{class:"title-container"},i("div",{class:""},i("label",{class:"title"},this.getMessage("snkGridConfig.gridConfiguration")),i("label",{class:"subtitle"},this.getMessage("snkGridConfig.columnVisibilityOrder"))),i("div",{class:"button-close"},i("ez-button",{mode:"icon",iconName:"close",size:"medium",onClick:()=>this.closeConfig()}))),i("div",{class:"tabselector-container"},i("ez-tabselector",{selectedIndex:this.selectedIndex,onEzChange:t=>{this.handleTabChange(t.detail)},tabs:this.getColumnNames()})),i("div",null,i("ez-text-input",{"data-element-id":"searchColums",ref:t=>this._searchElement=t,label:this.getMessage("snkGridConfig.findColumn"),onKeyUp:t=>this.locateColumn(t)},i("ez-icon",{slot:"leftIcon",size:"medium",iconName:"search"})))),i("div",{class:"grid-config__main"},i("ez-list",{ref:t=>this._columnList=t,class:0===this.selectedIndex?"":"hidden",dataSource:this._columListItems,onEzChange:t=>this.handleColumnListChange(t),ezDraggable:!0,ezSelectable:!0,itemSlotBuilder:(t,i)=>this.buildColumnListSlot(t,i),useGroups:!0,"data-element-id":"configCols"}),i("div",{class:1===this.selectedIndex?"group-name":"hidden"},this.getMessage("snkGridConfig.info.sortingSequence")),i("ez-list",{ref:t=>this._orderList=t,class:1===this.selectedIndex?"height-calc":"hidden",dataSource:this._orderListItems,ezSelectable:!0,onEzChange:t=>this.handleOrderListChange(t),ezDraggable:!0,itemSlotBuilder:t=>this.buildOrderListSlot(t),"data-element-id":"configDataOrder"})),i("div",{class:"grid-config__footer"},i("ez-button",{class:"padding-right--medium",label:this.getMessage("snkGridConfig.cancel"),onClick:()=>this.closeConfig()}),i("ez-button",{label:this.getMessage("snkGridConfig.complete"),class:"ez-button--primary",onClick:()=>this.finish()})))}static get assetsDirs(){return["../assets"]}get _element(){return e(this)}};I.style='.sc-snk-grid-config-h{--snk-grid-config__footer--padding-top:var(--space--medium, 12px);--snk-grid-config__main--padding-right:var(--space--medium, 12px);--snk-grid-config__tabselector-container--padding:var(--space--medium, 12px);--snk-grid-config__button-close--padding-left:var(--space--medium, 12px);--snk-grid-config__title--color:var(--title--primary, #2B3A54);--snk-grid-config__title--font-family:var(--font-pattern, "Roboto");--snk-grid-config__title--font-size:var(--title--large, 20px);--snk-grid-config__title--font-weight:var(--text-weight--extra-large, 700);--snk-grid-config__subtitle--font-family:var(--font-pattern, "Roboto");--snk-grid-config__subtitle--font-size:var(--text--medium, 14px);--snk-grid-config__group--font-family:var(--font-pattern, "Roboto");--snk-grid-config__group--font-size:var(--text--medium, 14px);--snk-grid-config__group--font-weight:var(--text-weight--large, 600);--snk-grid-config__group--padding-bottom:var(--space-small, 6px);--snk-grid-config__scrollbar--color-default:var(--scrollbar--default, #626e82);--snk-grid-config__scrollbar--color-background:var(--scrollbar--background, #E5EAF0);--snk-grid-config__scrollbar--color-hover:var(--scrollbar--hover, #2B3A54);--snk-grid-config__scrollbar--color-clicked:var(--scrollbar--clicked, #a2abb9);--snk-grid-config__scrollbar--border-radius:var(--border--radius-small, 6px);--snk-grid-config__scrollbar--width:var(--space--medium, 12px);display:grid;grid-template-rows:auto 1fr auto;max-height:100%;width:100%}@media screen and (min-width: 480px){.sc-snk-grid-config-h{width:359px;max-width:359px}}.padding-right--medium.sc-snk-grid-config{padding-right:var(--space--medium)}ez-list.sc-snk-grid-config{height:100%}.height-calc.sc-snk-grid-config{max-height:calc(100% - 24px)}.grid-config__footer.sc-snk-grid-config{display:flex;justify-content:flex-end;width:100%;padding-top:var(--snk-grid-config__footer--padding-top)}.hidden.sc-snk-grid-config{display:none}.tabselector-container.sc-snk-grid-config{padding:var(--snk-grid-config__tabselector-container--padding) 0}.button-close.sc-snk-grid-config{padding-left:var(--snk-grid-config__button-close--padding-left)}.title-container.sc-snk-grid-config{display:flex;justify-content:space-between;align-items:center;width:100%}.title.sc-snk-grid-config{display:flex;margin:0;line-height:normal;letter-spacing:0em;text-align:left;color:var(--snk-grid-config__title--color);font-size:var(--snk-grid-config__title--font-size);font-family:var(--snk-grid-config__title--font-family);font-weight:var(--snk-grid-config__title--font-weight)}.subtitle.sc-snk-grid-config{color:var(--text--primary);font-size:var(--snk-grid-config__subtitle--font-size);font-family:var(--snk-grid-config__subtitle--font-family)}.grid-config__main.sc-snk-grid-config{overflow-y:auto;scrollbar-width:thin;scrollbar-color:var(--snk-grid-config__scrollbar--color-clicked) var(--snk-grid-config__scrollbar--color-background);padding-right:var(--snk-grid-config__main--padding-right)}.grid-config__main.sc-snk-grid-config::-webkit-scrollbar{width:var(--snk-grid-config__scrollbar--width);max-width:var(--snk-grid-config__scrollbar--width);min-width:var(--snk-grid-config__scrollbar--width);background-color:var(--snk-grid-config__scrollbar--color-background)}.grid-config__main.sc-snk-grid-config::-webkit-scrollbar-track{background-color:var(--snk-grid-config__scrollbar--color-background);border-radius:var(--snk-grid-config__scrollbar--border-radius)}.grid-config__main.sc-snk-grid-config::-webkit-scrollbar-thumb{background-color:var(--snk-grid-config__scrollbar--color-default);border-radius:var(--snk-grid-config__scrollbar--border-radius)}.grid-config__main.sc-snk-grid-config::-webkit-scrollbar-thumb:vertical:hover,.grid-config__main.sc-snk-grid-config::-webkit-scrollbar-thumb:horizontal:hover{background-color:var(--snk-grid-config__scrollbar--color-hover)}.grid-config__main.sc-snk-grid-config::-webkit-scrollbar-thumb:vertical:active,.grid-config__main.sc-snk-grid-config::-webkit-scrollbar-thumb:horizontal:active{background-color:var(--snk-grid-config__scrollbar--color-clicked)}.group-name.sc-snk-grid-config{font-family:var(--snk-grid-config__group--font-family);font-size:var(--snk-grid-config__group--font-size);font-weight:var(--snk-grid-config__group--font-weight);padding-bottom:var(--snk-grid-config__group--padding-bottom)}';const E=class{constructor(i){t(this,i),this.ezChange=n(this,"ezChange",7),this.selectedOption=_.none}render(){return i("ez-combo-box",{class:"grid-config-combo ez-input--inverted",label:"",suppressSearch:!0,value:this.selectedOption,enabled:!0,canShowError:!1,suppressEmptyOption:!0},Object.keys(_).map((t=>i("option",{value:_[t].value},_[t].label))))}static get assetsDirs(){return["../assets"]}};E.style="ez-combo-box{width:100px}.grid-config-combo{--ez-text-input--height:28px;--ez-text-input__input--background-color:#fff;--ez-text-input__input--border-color:#dce0e8}";const j=class{constructor(i){t(this,i),this.taskbarActionSelected=n(this,"taskbarActionSelected",7),this.taskbarActionsOpened=n(this,"taskbarActionsOpened",7),this.taskbarActionsButtonDisconnected=n(this,"taskbarActionsButtonDisconnected",7),this._showDropdown=!1,this.title=void 0,this.enabled=void 0,this.actions=void 0}async handleKeyDown(t){"Escape"!==t.key&&"Esc"!==t.key||await this.hideActions()}async handleClose(){await this.hideActions()}async showActions(){this._showDropdown=!0,requestAnimationFrame((()=>{this._element.scrollIntoView({behavior:"smooth",block:"nearest",inline:"nearest"})}))}async hideActions(){this._showDropdown=!1}async isOpened(){return this._showDropdown}controlDropdown(){this._showDropdown=!this._showDropdown}loadItems(){return this.actions.filter((t=>void 0!==t)).map((t=>{var i;return{id:t.value,label:t.label,value:t.value,type:null!==(i=t.type)&&void 0!==i?i:"item",children:t.children,iconName:t.iconName,subAction:t.subAction,group:t.group,disableCloseOnSelect:t.disableCloseOnSelect}}))}canShowDropdown(){var t;return this._showDropdown&&(null===(t=this.actions)||void 0===t?void 0:t.length)>0}onSelectAction(t){const i=this.actions.map((t=>Object.assign(Object.assign({},t),{id:t.value}))),s=this.getSelectedAction(t.id,i);this.taskbarActionSelected.emit(s),s.disableCloseOnSelect||(this._showDropdown=!1)}getSelectedAction(t,i){let s=null;for(const e of i){if(e.id===t){s=e;break}if((null==e?void 0:e.children)&&(s=this.getSelectedAction(t,e.children),s))break}return s}dropdownItemBuilder(t,s){const e=this.actions.find((i=>i.value===t.id));if(!e||!e.itemBuilder)return;const n=e.itemBuilder(this._element,e);return"string"==typeof n?i("div",{innerHTML:n}):n}initializeEagerItems(){var t;null===(t=this.actions)||void 0===t||t.forEach((t=>{var i;t&&t.eagerInitialize&&t.itemBuilder&&(null===(i=t.itemBuilder)||void 0===i||i.call(t,this._element,t))}))}componentDidLoad(){this.initializeEagerItems()}componentDidRender(){this._showDropdown&&this.taskbarActionsOpened.emit(this._element)}disconnectedCallback(){this.taskbarActionsButtonDisconnected.emit()}render(){return i(s,null,i("div",{class:this.canShowDropdown()?" ez-elevation--16":""},i("ez-button",{title:this.title,mode:"icon",iconName:"dots-vertical",size:"small",enabled:this.enabled,onClick:()=>this.controlDropdown()}),this.canShowDropdown()&&i("ez-dropdown",{items:this.loadItems(),onEzClick:t=>this.onSelectAction(t.detail),onEzOutsideClick:()=>this._showDropdown=!1,itemBuilder:(t,i)=>this.dropdownItemBuilder(t,i)})))}get _element(){return e(this)}};j.style=".sc-taskbar-actions-button-h{display:flex;width:fit-content;height:fit-content}";export{D as snk_actions_button,I as snk_grid_config,E as snk_select_box,j as taskbar_actions_button}
1
+ import{r as t,h as i,H as s,g as e,c as n}from"./p-d2d301a6.js";import{ApplicationContext as o,StringUtils as r,ErrorException as a,WarningException as l,ObjectUtils as c,DateUtils as d,ArrayUtils as h,ElementIDUtils as u}from"@sankhyalabs/core";import{D as g}from"./p-dc7c9047.js";import{P as f}from"./p-eaad0aa8.js";import"./p-af8efd95.js";import"./p-30cf616e.js";import"./p-21749402.js";import"@sankhyalabs/ezui/dist/collection/utils/constants";import"@sankhyalabs/core/dist/dataunit/metadata/UnitMetadata";import"./p-fe79f83a.js";import"./p-ff1990ad.js";import"./p-df5451c7.js";import{R as m}from"./p-688dcb4c.js";import{ApplicationUtils as p,DialogType as v}from"@sankhyalabs/ezui/dist/collection/utils";import{CheckMode as b}from"@sankhyalabs/ezui/dist/collection/components/ez-check/CheckMode";import{C as k}from"./p-52920496.js";import{O as _}from"./p-b0ef4383.js";import"./p-8d884fab.js";import"@sankhyalabs/ezui/dist/collection/components/ez-grid/utils";import"@sankhyalabs/core/dist/utils/SortingUtils";class w{execute(t){var i;const s={actionID:t.actionID,refreshType:null===(i=t.actionConfig.javaCall)||void 0===i?void 0:i.refreshType};return new Promise((t=>{t({execSource:s,callback:this.callExecJava})}))}async callExecJava(t){const i={requestBody:{javaCall:t}};await g.get().callServiceBroker("ActionButtonsSP.executeJava",JSON.stringify(i))}}class C{execute(t){var i;const s={actionID:t.actionID,refreshType:null===(i=t.actionConfig.runScript)||void 0===i?void 0:i.refreshType};return new Promise((t=>{t({execSource:s,callback:this.callExecScript})}))}async callExecScript(t){const i={runScript:t};await g.get().callServiceBroker("ActionButtonsSP.executeScript",i)}}class y{constructor(){this._application=o.getContextValue("__SNK__APPLICATION__")}async execute(t,i){const s=t.resourceID;if(!s)return;let e=await this.buildLaunchObject(t,i);return this._application.openApp(s,e),null}buildLaunchObject(t,i){return new Promise((s=>{let e=t.actionConfig.params.param;if(e&&e.length>0){let n={},o=[];e.forEach((s=>{const e=s.localField;let l=i.getFieldValue(e);if(!l){let s=i.getField(e).label;throw s=r.isEmpty(i.getField(e).label)?e:s,new a(this._application.messagesBuilder.getMessage("snkActionsButton.title.error",void 0),this._application.messagesBuilder.getMessage("snkActionsButton.launchScreen.emptyField",{description:t.description,localFieldLabel:s}))}l=r.isEmpty(l.toString())?void 0:l.toString(),n[s.targetField]=l,o.push({fieldName:s.targetField,value:l})})),n.ACTION_PARAMETERS=o,n.call_time=Date.now(),s(n)}s(null)}))}}class x{execute(t){var i,s,e;const n=null===(i=t.actionConfig.dbCall)||void 0===i?void 0:i.name,o=null===(s=t.actionConfig.dbCall)||void 0===s?void 0:s.rootEntity,r={actionID:t.actionID,refreshType:null===(e=t.actionConfig.dbCall)||void 0===e?void 0:e.refreshType,procName:n,rootEntity:o};return new Promise((t=>{t({execSource:r,callback:this.callExecProcedure})}))}async callExecProcedure(t){const i={requestBody:{stpCall:t}};await g.get().callServiceBroker("ActionButtonsSP.executeSTP",JSON.stringify(i))}}var S,z;!function(t){t.LAUNCH_SCREEN="LC",t.JAVASCRIPT="SC",t.JAVA="RJ",t.PROCEDURE="SP",t.EMBEDDED="EB"}(S||(S={}));class A{constructor(t){this.actionType=t,this._application=o.getContextValue("__SNK__APPLICATION__")}get executor(){switch(this.actionType){case S.LAUNCH_SCREEN:return new y;case S.JAVASCRIPT:return new C;case S.JAVA:return new w;case S.PROCEDURE:return new x;default:throw new a(this._application.messagesBuilder.getMessage("snkActionsButton.title.error",void 0),this._application.messagesBuilder.getMessage("snkActionsButton.action.nonExistentType",{actionType:this.actionType}))}}}!function(t){t.NONE="NONE",t.PARENT="PARENT",t.MASTER="MASTER",t.ALL="ALL"}(z||(z={}));const O="__MASTER_ROW__";class N{constructor(t,i,s){var e;this._lastValuesCache={},this._actionsExecuteInterface=t,this._dataUnit=i,this._selectedRows=(null===(e=null==i?void 0:i.getSelectionInfo())||void 0===e?void 0:e.isAllRecords())?[]:null==i?void 0:i.getSelectionInfo().records,this._application=o.getContextValue("__SNK__APPLICATION__"),this._appResourceId=s}apply(t,i){this._application.closePopUp(),this._actionsExecuteInterface.execute(t,this._dataUnit).then((({execSource:s,callback:e})=>{this.resolvePromptParams(t,s,i).then((()=>{this.actionExecute(s,e)}))}))}async execute(t){var i;if(!t.actionConfig)throw new l(this._application.messagesBuilder.getMessage("snkActionsButton.title.warning",void 0),this._application.messagesBuilder.getMessage("snkActionsButton.action.incorrectAction",{description:t.description}));if(null===(i=t.actionConfig.params)||void 0===i?void 0:i.promptParam){const i=t.actionConfig.params.promptParam;let s=!1;for(let t=0;t<i.length;t++)if(!s&&"true"===i[t].saveLast){s=!0;break}s&&(t.actionConfig.params.promptParam=await this.loadSavedValuesIntoParams(t));const e=document.createElement("snk-actions-form");window.document.body.appendChild(e),e.action=c.copy(t),e.applyParameters=t=>{this.apply(t,s)},e.openPopup()}else t.type!=S.LAUNCH_SCREEN?this._actionsExecuteInterface.execute(t,this._dataUnit).then((({execSource:t,callback:i})=>{this.actionExecute(t,i)})):this._actionsExecuteInterface.execute(t,this._dataUnit)}loadSavedValuesIntoParams(t){return this.loadLastValues(t).then((i=>{let s=t.actionConfig.params.promptParam;return i&&i.param.forEach((t=>{s=s.map((i=>i.name!==t.paramName?i:Object.assign(Object.assign({},i),"B"===i.paramType?{value:"S"===t.$}:{value:t.$})))})),s}))}actionExecute(t,i){t.virtualPage=this.buildVirtualPage(),this.prepareAndExecute(t,i),this.recordsReloader(t.refreshType)}resolvePromptParams(t,i,s){return new Promise((e=>{let n=[];t.actionConfig.params.promptParam.forEach((t=>{n.push(this.buildPromptParam(t))})),this.putParamsOnExecSource(n,i),s&&this.saveLastValues(t,n),e()}))}buildPromptParam(t){let i,s,e=t.paramType,n=!1,o=t.value;switch(e){case f.DATE:e="D";break;case f.DATETIME:e="H";break;case f.DECIMAL:e="F",i={"sk-precision":Number(t.precision)};break;case f.BOOLEAN:e="S",n=!0,o=t.value?"S":"N";break;case f.ENTITY:i={"sk-entity-name":t.entityName,"sk-allow-show-hierarchical-mode":t.hierarchyEntity,"sk-data-type":"S"},t.hierarchyEntity&&t.entityPK&&(s=t.entityPK),o=t.value?Number(t.value):null;break;case f.OPTIONS:e="O";let r=t.options.split(";").map((function(t,i){let s,e;if(t.indexOf("=")>-1){let i=t.split("=");s=i[0],e=i[1]}else s=i+1,e=t;return{data:s,value:e}}));i={"sk-options":r}}return{description:t.label,required:"true"==t.required,fieldName:t.name,fieldNameOri:t.name,entityPK:s,paramType:t.paramType,type:e,isCheckbox:n,saveLast:t.saveLast,fieldProp:i,value:o,isGeneratedName:t.isGeneratedName}}putParamsOnExecSource(t,i){i.params={param:[]},t.forEach((t=>{if(t.isGeneratedName&&t.value)throw new a(this._application.messagesBuilder.getMessage("snkActionsButton.title.error",void 0),this._application.messagesBuilder.getMessage("snkActionsButton.action.emptyParamName",void 0));r.isEmpty(t.value)||i.params.param.push({type:this.getParamDataType(t.paramType),paramName:t.fieldName,$:this.getParamValue(t)})}))}getParamDataType(t){let i;switch(t){case"D":i="F";break;case"DT":case"DH":i="D";break;case"B":case"ENTITY":case"SO":i="S";break;default:i=t}return i}getParamValue(t){let i=t.value;return i?("DT"==t.paramType?i=d.formatDate(i):"DH"==t.paramType&&(i=d.formatDateTime(i)),i):i}async loadLastValues(t){const i=await this.buildResourceId(t.actionID);return new Promise(((t,s)=>{if(this._lastValuesCache[i])t(this._lastValuesCache[i]);else{const e={config:{chave:i,tipo:"T"}};g.get().callServiceBroker("SystemUtilsSP.getConf",e).then((s=>{var e,n;let o;(null===(n=null===(e=s.config)||void 0===e?void 0:e.data)||void 0===n?void 0:n.params)&&(o=s.config.data.params,Array.isArray(o.param)||(o.param=[o.param])),this._lastValuesCache[i]=o,t(o)})).catch((t=>{s(t)}))}}))}async saveLastValues(t,i){if(this._application){let s={params:{param:[]}};i.forEach((t=>{"true"==t.saveLast&&s.params.param.push({paramName:t.fieldName,$:t.value})}));const e=await this.buildResourceId(t.actionID);this._lastValuesCache[e]=s.params,this._application.saveConfig(e,s)}}async buildResourceId(t){return this._appResourceId+".actionconfig."+t}prepareAndExecute(t,i){this.addRows(t),i(t)}addRows(t){const i={row:[]},s=this._selectedRows;for(const t in s){const e=s[t],n={};e.hasOwnProperty(O)&&(n.master="S",n.entityName=e.__ENTITY_NAME__,delete e[O],delete e.__ENTITY_NAME__);for(const t in e)"NUFIN"===t&&(n.field||(n.field=[]),n.field.push({fieldName:t,$:e[t]}));i.row.push(n)}i.row.length>0&&(t.rows=i)}recordsReloader(t){switch(t){case z.NONE:break;case z.PARENT:case z.MASTER:case z.ALL:this._dataUnit.loadData();break;default:this._dataUnit.reloadCurrentRecord()}}buildVirtualPage(){var t,i,s,e;if(null===(i=null===(t=this._dataUnit)||void 0===t?void 0:t.getSelectionInfo())||void 0===i?void 0:i.isAllRecords())return{filters:{filters:null===(s=this._dataUnit)||void 0===s?void 0:s.getAppliedFilters()},orders:{orders:null===(e=this._dataUnit)||void 0===e?void 0:e.getSort()}}}}class P{async clientConfirm(t,i){return new Promise((s=>{const e=o.getContextValue("__SNK__APPLICATION__");let n="";t.content.event.hasOwnProperty("stpCall")?(i.requestBody=t.content.event.stpCall,n=S.PROCEDURE):t.content.event.hasOwnProperty("runScript")?(i.requestBody=t.content.event.runScript,n=S.JAVASCRIPT):t.content.event.hasOwnProperty("javaCall")&&(i.requestBody=t.content.event.javaCall,n=S.JAVA);let r={type:"S",sequence:t.content.event.sequence};i.requestBody.params?Array.isArray(i.requestBody.params.param)||(i.requestBody.params.param=[i.requestBody.params.param]):i.requestBody.params={param:[]},i.requestBody.params.param.push(r);const a=t.content.event.title.$,l=t.content.event.message.$;let c;switch(n){case S.JAVASCRIPT:c={runScript:i.requestBody};break;case S.PROCEDURE:c={requestBody:{stpCall:i.requestBody}};break;case S.JAVA:c={requestBody:{javaCall:i.requestBody}}}if("S"==t.content.event.showNoOption){r.paramName="__ESCOLHA_SIMNAO__";const t=document.createElement("snk-client-confirm");window.document.body.appendChild(t),t.titleMessage=a,t.message=l,t.accept=async()=>{r.$="S",await i.reCall(c),s()},t.cancel=async()=>{r.$="N",await i.reCall(c),s()},t.openPopup()}else e.confirm(a,l,null,"warn",{labelCancel:"Cancelar",labelConfirm:"Sim"}).then((async t=>{t&&(r.paramName="__CONFIRMACAO__",r.$="S",await i.reCall(c),s())}))}))}}const D=class{constructor(i){t(this,i),this.CLIENT_EVENT_CONFIRM_NAME="br.com.sankhya.actionbutton.clientconfirm",this.handleClick=t=>{const i=this._actions.find((i=>i.actionID==t.detail.id)),s=new A(i.type).executor;new N(s,this._dataUnit,this._resourceID).execute(Object.assign({},i)),this._showDropdown=!1},this._items=[],this._showDropdown=!1,this._actions=[],this._isOrderActions=!1}async getActions(){let t={param:{entityName:this._entityName,resourceID:this._resourceID}};return g.get().callServiceBroker("ActionButtonsSP.getActions",t).then((t=>{var i;(null===(i=t.actions)||void 0===i?void 0:i.action)&&(this._actions=this._isOrderActions?h.sortAlphabetically(t.actions.action,"description"):t.actions.action)}))}controlDropdown(){this._showDropdown=!this._showDropdown}canShowDropdown(){var t;return this._showDropdown&&(null===(t=this._items)||void 0===t?void 0:t.length)>0}positionDropdown(){var t;const i=null===(t=this._ezButton)||void 0===t?void 0:t.getBoundingClientRect();i&&this._dropdownParent&&(this._dropdownParent.style.top=i.y+i.height+5+"px",this._dropdownParent.style.left=i.x+"px")}closeDropdown(t){const i=null==t?void 0:t.target;i&&(i.closest(".snk-actions-button")||(this._showDropdown=!1))}setEvents(){document.removeEventListener("click",this.closeDropdown.bind(this)),document.addEventListener("click",this.closeDropdown.bind(this)),document.removeEventListener("scroll",this.positionDropdown.bind(this)),document.addEventListener("scroll",this.positionDropdown.bind(this))}async componentWillLoad(){this._application=o.getContextValue("__SNK__APPLICATION__"),this._isOrderActions=await this._application.getBooleanParam("global.ordenar.acoes.personalizadas");const t=this._element.parentElement;this._dataUnit=null==t?void 0:t.dataUnit,this._resourceID=null==t?void 0:t.resourceID,this._entityName=this._dataUnit.name.split("/")[2],null==this._resourceID&&(this._resourceID=await m.getResourceID()),this.setEvents(),this.getActions().then((()=>{this.loadItems()}))}async componentDidLoad(){if(this._element&&(u.addIDInfo(this._element),this.positionDropdown(),!await this._application.hasClientEvent(this.CLIENT_EVENT_CONFIRM_NAME))){const t=new P;this._application.addClientEvent(this.CLIENT_EVENT_CONFIRM_NAME,t.clientConfirm)}}componentDidUpdate(){this.positionDropdown()}loadItems(){this._actions&&0!=this._actions.length&&this._actions.forEach((t=>{this._items.push({id:t.actionID,label:t.description})}))}getElementID(t){return{[u.DATA_ELEMENT_ID_ATTRIBUTE_NAME]:u.getInternalIDInfo(t)}}render(){return i(s,null,this._actions&&this._actions.length>0&&i("div",{class:`ez-padding-left--medium snk-actions-button\n ${this.canShowDropdown()?" ez-elevation--16":""}\n `},i("ez-button",Object.assign({ref:t=>this._ezButton=t,iconName:"acao",size:"small",mode:"icon",title:this._application.messagesBuilder.getMessage("snkActionsButton.title.actions",void 0),onClick:()=>this.controlDropdown()},this.getElementID("button"))),i("div",Object.assign({ref:t=>this._dropdownParent=t,class:(this.canShowDropdown()?"snk-actions-button__dropdown--show":"snk-actions-button__dropdown")+"\n "},this.getElementID("dropdown")),this.canShowDropdown()&&i("ez-dropdown",Object.assign({items:this._items,onEzClick:t=>this.handleClick(t)},this.getElementID("dropdown"))))),this.canShowDropdown()&&i("div",Object.assign({class:"ez-scrim ez-scrim--light"},this.getElementID("ezScrim"))))}get _element(){return e(this)}};D.style=".sc-snk-actions-button-h{display:flex;width:fit-content;height:fit-content}.snk-actions-button.sc-snk-actions-button{display:flex;width:fit-content;height:fit-content}.snk-actions-button__dropdown--show.sc-snk-actions-button{display:flex;flex-direction:column;position:fixed}.snk-actions-button__dropdown.sc-snk-actions-button>ez-dropdown.sc-snk-actions-button{position:relative}.snk-actions-button__dropdown.sc-snk-actions-button{display:none}";const I=class{constructor(i){t(this,i),this.configChange=n(this,"configChange",7),this.configCancel=n(this,"configCancel",7),this._orderListItems=[],this._orderPriorityList=[],this._columListItems=[],this._selectedIndex=-1,this._dataChanged=!1,this._componenteInternalKey=Date.now(),this.selectedIndex=0,this.columns=void 0,this.config=void 0,this.configName=void 0,this.resourceID=void 0}getMessage(t,i){return o.getContextValue("__SNK__APPLICATION__").messagesBuilder.getMessage(t,i)}getSortableColumns(){let t=[];return this.columns.filter((t=>{var i;return r.getBooleanValue(null===(i=null==t?void 0:t.props)||void 0===i?void 0:i.get("sortable"),!0)})).forEach((i=>{var s;let e=null===(s=this.config)||void 0===s?void 0:s.columns.find((t=>t.name===i.name)),n={name:i.name,label:i.label};e&&(n.orderIndex=e.orderIndex,n.ascending=e.ascending),i.hidden||t.push(n)})),t}createOrderList(){let t=this.getSortableColumns();t.sort(((t,i)=>0!=t.orderIndex||0!=i.orderIndex||null==t.ascending&&null==i.ascending?null!=t.ascending&&null!=i.ascending?t.orderIndex-i.orderIndex:null!=t.ascending||null!=i.ascending?null!=t.ascending?-1:null!=i.ascending?1:0:t.orderIndex-i.orderIndex:null!=t.ascending?-1:null!=i.ascending?1:0)),this._orderListItems=t}createColumnList(){let t={group:this.getMessage("snkGridConfig.group.visible"),items:[]},i={group:this.getMessage("snkGridConfig.group.hidden"),items:[],sort:_.asc.value};this.columns.forEach((s=>{let e={label:s.label};s.hidden?i.items.push(e):t.items.push(e)})),this._columListItems=[t,i]}createColumnListSlotDataElementId(t){return`configItem_${r.replaceAccentuatedChars(r.toCamelCase(t.label))}`}buildColumnListSlot(t,s){const e=this.createColumnListSlotDataElementId(t);return i("div",null,i("ez-check",{mode:b.SWITCH,id:b.SWITCH+((null==t?void 0:t.label)||"")+((null==s?void 0:s.group)||""),value:s.group===this.getMessage("snkGridConfig.group.visible"),"data-element-id":e,onEzChange:i=>{this.switchColumnGroup(i,t)}}))}createOrderListSlotDataElementId(t){return`${this._element.getAttribute(u.DATA_ELEMENT_ID_ATTRIBUTE_NAME)}_configItem_${r.toCamelCase(t.label)}`}buildOrderListSlot(t){const s=this.createOrderListSlotDataElementId(t);let e=_.none.value;return null!=(null==t?void 0:t.ascending)&&(e=1==t.ascending?_.asc.value:_.desc.value),i("div",null,i("snk-select-box",{selectedOption:e,key:"snk-select-box-"+this._componenteInternalKey+"-"+t,"data-element-id":s,onEzChange:i=>{i.stopPropagation(),this.updateOrder(i.detail,t.label)}}))}updateOrder(t,i){var s;this._dataChanged=!0;let e,n=[...this.columns],o=n.find((t=>t.label===i));o&&(o.sort=t.value===_.none.value?void 0:t.value),(null===(s=this._orderPriorityList)||void 0===s?void 0:s.length)>0?(this._orderPriorityList.find((t=>t.label===o.label)).sort=t,this._orderPriorityList.filter((t=>t.sort)).forEach(((t,i)=>{t.label===o.label&&(o.sortIndex=i)}))):(e=n.filter((t=>t.sort&&!0!==t.hidden)).map(((t,i)=>({label:t.label,orderIndex:i}))),e.forEach((t=>{n.find((i=>i.label===t.label)).sortIndex=t.orderIndex}))),this.columns=n}switchColumnGroup(t,i){t.stopPropagation();let s=[...this._columListItems];if(this._dataChanged=!0,!0===t.detail){let t=s.find((t=>t.group===this.getMessage("snkGridConfig.group.hidden"))),e=t.items.findIndex((t=>t.label===i.label));e>=0&&t.items.splice(e,1),s.find((t=>t.group===this.getMessage("snkGridConfig.group.visible"))).items.push(i),this._columListItems=s,this.createOrderList()}else if(!1===t.detail){let t=s.find((t=>t.group===this.getMessage("snkGridConfig.group.visible"))),e=t.items.findIndex((t=>t.label===i.label));e>=0&&t.items.splice(e,1),s.find((t=>t.group===this.getMessage("snkGridConfig.group.hidden"))).items.push(i),this._columListItems=s,this.createOrderList()}}finish(){if(!this._dataChanged)return void this.closeConfig();let t=[];this._columListItems.forEach((i=>{i.items.forEach((s=>{const e=this.columns.find((t=>t.label===s.label));let n=Object.assign({},e);n.hidden=i.group===this.getMessage("snkGridConfig.group.hidden"),t.push(n)}))})),this.columns=t,this._dataChanged=!1,this.closeConfig(),this.save()}saveGridConfigOnStorage(t){k.saveGridConfig(t,this.configName,this.resourceID).then((t=>{this.configChange.emit(t),this._orderList.clearHistory(),p.info(this.getMessage("snkGridConfig.info.successfullyConfigSaved"),{iconName:"check"})}))}reOrderPriorityColumns(t,i){let s=[];s=t.filter((t=>t.sort&&!0!==t.hidden)).map((t=>({label:t.label,orderIndex:0})));let e=0,n=[];return i.forEach((t=>{let i=s.find((i=>i.label===t.label));i&&(i.orderIndex=e,n.push(i),e++)})),n.length>0&&(s=n),s}save(){var t;let i;i=this.config?this.config:this.createConfigFromState(this.columns);let s,e=[];(null===(t=this._orderPriorityList)||void 0===t?void 0:t.length)>0&&(s=this.reOrderPriorityColumns(this.columns,this._orderPriorityList)),this.columns.forEach((t=>{let n=i.columns.find((i=>t.name===i.name));!0===t.hidden&&n||(n?n.width=t.width:!1===t.hidden&&(n={name:t.name,width:t.width,orderIndex:0}),n&&(t.sort?(n.ascending=t.sort.toUpperCase()===_.asc.value,s?function(t,i){if(s){let e=s.find((i=>i.label===t.label));e&&(i.orderIndex=e.orderIndex)}}(t,n):n.orderIndex=t.sortIndex):(delete n.ascending,n.orderIndex=0),e.push(n)))})),i.columns=e,this.saveGridConfigOnStorage(i)}createConfigFromState(t){let i={columns:[]};return t.forEach((t=>{if(!t.hidden){let s={name:t.name};t.width&&(s.width=t.width),t.sort?(s.ascending=t.sort.toUpperCase()===_.asc.value,s.orderIndex=t.sortIndex):s.orderIndex=0,s&&i.columns.push(s)}})),i}async locateColumn(t,i){var s;const e="Enter"===t.key;if(!(i=i||(null===(s=t.currentTarget)||void 0===s?void 0:s.value)))return void this.removeSelection();const n=await this.getMatchedIndexes(i),o=this.getNewSelectedIndex(n,e);this._selectedIndex=o,1===this.selectedIndex?this.updateOrderListSelection(o):this.updateColumnListSelection(o)}async getMatchedIndexes(t){const i=[];return 1===this.selectedIndex?(await this._orderList.getList()).forEach(((s,e)=>{this.compareWords(s,t)&&i.push(e)})):this.columns.forEach(((s,e)=>{this.compareWords(s,t)&&i.push(e)})),i}getNewSelectedIndex(t,i){if(0===t.length)return-1;if(i)for(const i of t)if(i>this._selectedIndex)return i;return t[0]}updateOrderListSelection(t){-1!==t?this._orderList.getList().then((i=>{const s=i[t];s?this._orderList.setSelection(s,!0):this._orderList.removeSelection()})):this._orderList.removeSelection()}updateColumnListSelection(t){if(-1===t)return void this._columnList.removeSelection();const i=this.columns[t];if(i){const t=this._columListItems.map((t=>t.items)).flat().find((t=>t.label===i.label));t?this._columnList.setSelection(t,!0):this._columnList.removeSelection()}else this._columnList.removeSelection()}removeSelection(){1===this.selectedIndex?this._orderList.removeSelection():this._columnList.removeSelection()}compareWords(t,i){var s,e;const n=null===(s=r.replaceAccentuatedChars(null==t?void 0:t.label))||void 0===s?void 0:s.toUpperCase(),o=null===(e=r.replaceAccentuatedChars(i))||void 0===e?void 0:e.toUpperCase();return!r.isEmpty(n)&&!r.isEmpty(o)&&n.includes(o)}getColumnNames(){const t=[];return t.push(this.getMessage("snkGridConfig.tab.columns")),t.push(this.getMessage("snkGridConfig.tab.lineOrdering")),t.join(",")}closeConfig(){if(this._orderList.scrollToTop(),this._columnList.scrollToTop(),this._searchElement.value="",this._dataChanged){let t={canClose:!1,labelCancel:this.getMessage("snkGridConfig.confirm.cancel"),labelConfirm:this.getMessage("snkGridConfig.confirm.save"),btnConfirmDanger:!1};p.confirm(this.getMessage("snkGridConfig.confirm.alert"),this.getMessage("snkGridConfig.confirm.msgCancel"),null,v.WARN,t).then((t=>{t?this.finish():(this._dataChanged=!1,this.configCancel.emit(),this._orderList.clearHistory(),this._componenteInternalKey=Date.now())}))}else this.configCancel.emit(),this._orderList.clearHistory()}handleTabChange(t){null!=(null==t?void 0:t.index)&&(this.selectedIndex!==t.index&&(0===t.index?this._orderList.scrollToTop():1===t.index&&this._columnList.scrollToTop(),this._searchElement.value=""),1===t.index&&this.createOrderList(),this.selectedIndex=t.index)}handleColumnListChange(t){var i;if(t.detail){let s=null===(i=t.detail.find((t=>t.group===this.getMessage("snkGridConfig.group.visible"))))||void 0===i?void 0:i.items;s&&(this._dataChanged=!0,this._orderListItems=s)}}handleOrderListChange(t){if(t.detail){let i=t.detail;i&&(this._dataChanged=!0,this._orderPriorityList=i)}}componentWillRender(){var t;(null===(t=this.columns)||void 0===t?void 0:t.length)>0&&this.createColumnList()}componentDidRender(){var t;(null===(t=this.columns)||void 0===t?void 0:t.length)>0&&this.locateColumn(new KeyboardEvent("arrow-right",{key:"ArrowRight"}),this._searchElement.value)}componentDidLoad(){u.addIDInfo(this._element)}render(){return i(s,null,i("div",{class:"grid-config__header"},i("div",{class:"title-container"},i("div",{class:""},i("label",{class:"title"},this.getMessage("snkGridConfig.gridConfiguration")),i("label",{class:"subtitle"},this.getMessage("snkGridConfig.columnVisibilityOrder"))),i("div",{class:"button-close"},i("ez-button",{mode:"icon",iconName:"close",size:"medium",onClick:()=>this.closeConfig()}))),i("div",{class:"tabselector-container"},i("ez-tabselector",{selectedIndex:this.selectedIndex,onEzChange:t=>{this.handleTabChange(t.detail)},tabs:this.getColumnNames()})),i("div",null,i("ez-text-input",{"data-element-id":"searchColums",ref:t=>this._searchElement=t,label:this.getMessage("snkGridConfig.findColumn"),onKeyUp:t=>this.locateColumn(t)},i("ez-icon",{slot:"leftIcon",size:"medium",iconName:"search"})))),i("div",{class:"grid-config__main"},i("ez-list",{ref:t=>this._columnList=t,class:0===this.selectedIndex?"":"hidden",dataSource:this._columListItems,onEzChange:t=>this.handleColumnListChange(t),ezDraggable:!0,ezSelectable:!0,itemSlotBuilder:(t,i)=>this.buildColumnListSlot(t,i),useGroups:!0,"data-element-id":"configCols"}),i("div",{class:1===this.selectedIndex?"group-name":"hidden"},this.getMessage("snkGridConfig.info.sortingSequence")),i("ez-list",{ref:t=>this._orderList=t,class:1===this.selectedIndex?"height-calc":"hidden",dataSource:this._orderListItems,ezSelectable:!0,onEzChange:t=>this.handleOrderListChange(t),ezDraggable:!0,itemSlotBuilder:t=>this.buildOrderListSlot(t),"data-element-id":"configDataOrder"})),i("div",{class:"grid-config__footer"},i("ez-button",{class:"padding-right--medium",label:this.getMessage("snkGridConfig.cancel"),onClick:()=>this.closeConfig()}),i("ez-button",{label:this.getMessage("snkGridConfig.complete"),class:"ez-button--primary",onClick:()=>this.finish()})))}static get assetsDirs(){return["../assets"]}get _element(){return e(this)}};I.style='.sc-snk-grid-config-h{--snk-grid-config__footer--padding-top:var(--space--medium, 12px);--snk-grid-config__main--padding-right:var(--space--medium, 12px);--snk-grid-config__tabselector-container--padding:var(--space--medium, 12px);--snk-grid-config__button-close--padding-left:var(--space--medium, 12px);--snk-grid-config__title--color:var(--title--primary, #2B3A54);--snk-grid-config__title--font-family:var(--font-pattern, "Roboto");--snk-grid-config__title--font-size:var(--title--large, 20px);--snk-grid-config__title--font-weight:var(--text-weight--extra-large, 700);--snk-grid-config__subtitle--font-family:var(--font-pattern, "Roboto");--snk-grid-config__subtitle--font-size:var(--text--medium, 14px);--snk-grid-config__group--font-family:var(--font-pattern, "Roboto");--snk-grid-config__group--font-size:var(--text--medium, 14px);--snk-grid-config__group--font-weight:var(--text-weight--large, 600);--snk-grid-config__group--padding-bottom:var(--space-small, 6px);--snk-grid-config__scrollbar--color-default:var(--scrollbar--default, #626e82);--snk-grid-config__scrollbar--color-background:var(--scrollbar--background, #E5EAF0);--snk-grid-config__scrollbar--color-hover:var(--scrollbar--hover, #2B3A54);--snk-grid-config__scrollbar--color-clicked:var(--scrollbar--clicked, #a2abb9);--snk-grid-config__scrollbar--border-radius:var(--border--radius-small, 6px);--snk-grid-config__scrollbar--width:var(--space--medium, 12px);display:grid;grid-template-rows:auto 1fr auto;max-height:100%;width:100%}@media screen and (min-width: 480px){.sc-snk-grid-config-h{width:359px;max-width:359px}}.padding-right--medium.sc-snk-grid-config{padding-right:var(--space--medium)}ez-list.sc-snk-grid-config{height:100%}.height-calc.sc-snk-grid-config{max-height:calc(100% - 24px)}.grid-config__footer.sc-snk-grid-config{display:flex;justify-content:flex-end;width:100%;padding-top:var(--snk-grid-config__footer--padding-top)}.hidden.sc-snk-grid-config{display:none}.tabselector-container.sc-snk-grid-config{padding:var(--snk-grid-config__tabselector-container--padding) 0}.button-close.sc-snk-grid-config{padding-left:var(--snk-grid-config__button-close--padding-left)}.title-container.sc-snk-grid-config{display:flex;justify-content:space-between;align-items:center;width:100%}.title.sc-snk-grid-config{display:flex;margin:0;line-height:normal;letter-spacing:0em;text-align:left;color:var(--snk-grid-config__title--color);font-size:var(--snk-grid-config__title--font-size);font-family:var(--snk-grid-config__title--font-family);font-weight:var(--snk-grid-config__title--font-weight)}.subtitle.sc-snk-grid-config{color:var(--text--primary);font-size:var(--snk-grid-config__subtitle--font-size);font-family:var(--snk-grid-config__subtitle--font-family)}.grid-config__main.sc-snk-grid-config{overflow-y:auto;scrollbar-width:thin;scrollbar-color:var(--snk-grid-config__scrollbar--color-clicked) var(--snk-grid-config__scrollbar--color-background);padding-right:var(--snk-grid-config__main--padding-right)}.grid-config__main.sc-snk-grid-config::-webkit-scrollbar{width:var(--snk-grid-config__scrollbar--width);max-width:var(--snk-grid-config__scrollbar--width);min-width:var(--snk-grid-config__scrollbar--width);background-color:var(--snk-grid-config__scrollbar--color-background)}.grid-config__main.sc-snk-grid-config::-webkit-scrollbar-track{background-color:var(--snk-grid-config__scrollbar--color-background);border-radius:var(--snk-grid-config__scrollbar--border-radius)}.grid-config__main.sc-snk-grid-config::-webkit-scrollbar-thumb{background-color:var(--snk-grid-config__scrollbar--color-default);border-radius:var(--snk-grid-config__scrollbar--border-radius)}.grid-config__main.sc-snk-grid-config::-webkit-scrollbar-thumb:vertical:hover,.grid-config__main.sc-snk-grid-config::-webkit-scrollbar-thumb:horizontal:hover{background-color:var(--snk-grid-config__scrollbar--color-hover)}.grid-config__main.sc-snk-grid-config::-webkit-scrollbar-thumb:vertical:active,.grid-config__main.sc-snk-grid-config::-webkit-scrollbar-thumb:horizontal:active{background-color:var(--snk-grid-config__scrollbar--color-clicked)}.group-name.sc-snk-grid-config{font-family:var(--snk-grid-config__group--font-family);font-size:var(--snk-grid-config__group--font-size);font-weight:var(--snk-grid-config__group--font-weight);padding-bottom:var(--snk-grid-config__group--padding-bottom)}';const E=class{constructor(i){t(this,i),this.ezChange=n(this,"ezChange",7),this.selectedOption=_.none}render(){return i("ez-combo-box",{class:"grid-config-combo ez-input--inverted",label:"",suppressSearch:!0,value:this.selectedOption,enabled:!0,canShowError:!1,suppressEmptyOption:!0},Object.keys(_).map((t=>i("option",{value:_[t].value},_[t].label))))}static get assetsDirs(){return["../assets"]}};E.style="ez-combo-box{width:100px}.grid-config-combo{--ez-text-input--height:28px;--ez-text-input__input--background-color:#fff;--ez-text-input__input--border-color:#dce0e8}";const j=class{constructor(i){t(this,i),this.taskbarActionSelected=n(this,"taskbarActionSelected",7),this.taskbarActionsOpened=n(this,"taskbarActionsOpened",7),this.taskbarActionsButtonDisconnected=n(this,"taskbarActionsButtonDisconnected",7),this._showDropdown=!1,this.title=void 0,this.enabled=void 0,this.actions=void 0}async handleKeyDown(t){"Escape"!==t.key&&"Esc"!==t.key||await this.hideActions()}async handleClose(){await this.hideActions()}async showActions(){this._showDropdown=!0,requestAnimationFrame((()=>{this._element.scrollIntoView({behavior:"smooth",block:"nearest",inline:"nearest"})}))}async hideActions(){this._showDropdown=!1}async isOpened(){return this._showDropdown}controlDropdown(){this._showDropdown=!this._showDropdown}loadItems(){return this.actions.filter((t=>void 0!==t)).map((t=>{var i;return{id:t.value,label:t.label,value:t.value,type:null!==(i=t.type)&&void 0!==i?i:"item",children:t.children,iconName:t.iconName,subAction:t.subAction,group:t.group,disableCloseOnSelect:t.disableCloseOnSelect}}))}canShowDropdown(){var t;return this._showDropdown&&(null===(t=this.actions)||void 0===t?void 0:t.length)>0}onSelectAction(t){const i=this.actions.map((t=>Object.assign(Object.assign({},t),{id:t.value}))),s=this.getSelectedAction(t.id,i);this.taskbarActionSelected.emit(s),s.disableCloseOnSelect||(this._showDropdown=!1)}getSelectedAction(t,i){let s=null;for(const e of i){if(e.id===t){s=e;break}if((null==e?void 0:e.children)&&(s=this.getSelectedAction(t,e.children),s))break}return s}dropdownItemBuilder(t,s){const e=this.actions.find((i=>i.value===t.id));if(!e||!e.itemBuilder)return;const n=e.itemBuilder(this._element,e);return"string"==typeof n?i("div",{innerHTML:n}):n}initializeEagerItems(){var t;null===(t=this.actions)||void 0===t||t.forEach((t=>{var i;t&&t.eagerInitialize&&t.itemBuilder&&(null===(i=t.itemBuilder)||void 0===i||i.call(t,this._element,t))}))}componentDidLoad(){this.initializeEagerItems()}componentDidRender(){this._showDropdown&&this.taskbarActionsOpened.emit(this._element)}disconnectedCallback(){this.taskbarActionsButtonDisconnected.emit()}render(){return i(s,null,i("div",{class:this.canShowDropdown()?" ez-elevation--16":""},i("ez-button",{title:this.title,mode:"icon",iconName:"dots-vertical",size:"small",enabled:this.enabled,onClick:()=>this.controlDropdown()}),this.canShowDropdown()&&i("ez-dropdown",{items:this.loadItems(),onEzClick:t=>this.onSelectAction(t.detail),onEzOutsideClick:()=>this._showDropdown=!1,itemBuilder:(t,i)=>this.dropdownItemBuilder(t,i)})))}get _element(){return e(this)}};j.style=".sc-taskbar-actions-button-h{display:flex;width:fit-content;height:fit-content}";export{D as snk_actions_button,I as snk_grid_config,E as snk_select_box,j as taskbar_actions_button}