@sankhyalabs/sankhyablocks 10.1.0-dev.57 → 10.1.0-dev.59

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (150) hide show
  1. package/dist/cjs/{ConfigStorage-a28eceb2.js → ConfigStorage-156bfcac.js} +2 -2
  2. package/dist/cjs/{DataFetcher-98d95e8f.js → DataFetcher-d13b4637.js} +12 -0
  3. package/dist/cjs/{ISave-a9815bb3.js → ISave-55d9dcc3.js} +1 -1
  4. package/dist/cjs/{SnkFormConfigManager-af47ba2f.js → SnkFormConfigManager-5cb9a39c.js} +2 -2
  5. package/dist/cjs/{SnkMultiSelectionListDataSource-13774e5f.js → SnkMultiSelectionListDataSource-5c5badfc.js} +5 -5
  6. package/dist/cjs/{auth-fetcher-9c257a1f.js → auth-fetcher-d1715459.js} +1 -1
  7. package/dist/cjs/{dataunit-fetcher-afc246d8.js → dataunit-fetcher-fae710c5.js} +1 -1
  8. package/dist/cjs/{form-config-fetcher-1ce4125c.js → form-config-fetcher-bbebdcb8.js} +1 -1
  9. package/dist/cjs/{index-e3e39724.js → index-bc950921.js} +6 -0
  10. package/dist/cjs/loader.cjs.js +1 -1
  11. package/dist/cjs/pesquisa-grid_2.cjs.entry.js +5 -5
  12. package/dist/cjs/sankhyablocks.cjs.js +1 -1
  13. package/dist/cjs/snk-actions-button_9.cjs.entry.js +9 -9
  14. package/dist/cjs/snk-application.cjs.entry.js +7 -7
  15. package/dist/cjs/snk-attach_11.cjs.entry.js +14 -12
  16. package/dist/cjs/snk-crud.cjs.entry.js +14 -10
  17. package/dist/cjs/snk-data-exporter.cjs.entry.js +59 -14
  18. package/dist/cjs/{snk-data-unit-ab570f87.js → snk-data-unit-32237a2d.js} +2 -2
  19. package/dist/cjs/snk-data-unit.cjs.entry.js +3 -3
  20. package/dist/cjs/snk-detail-view.cjs.entry.js +9 -9
  21. package/dist/cjs/snk-dynaform-detail-view_2.cjs.entry.js +33 -10
  22. package/dist/cjs/{snk-dynaform-guides-view-30ce5a8c.js → snk-dynaform-guides-view-2c7c6ce4.js} +389 -42
  23. package/dist/cjs/snk-dynaform-guides-view.cjs.entry.js +6 -6
  24. package/dist/cjs/snk-dynaform.cjs.entry.js +14 -10
  25. package/dist/cjs/snk-filter-bar_4.cjs.entry.js +4 -4
  26. package/dist/cjs/snk-form_2.cjs.entry.js +4 -4
  27. package/dist/cjs/snk-grid.cjs.entry.js +8 -8
  28. package/dist/cjs/{snk-guides-viewer-2a55fa3a.js → snk-guides-viewer-67b9cca9.js} +2 -2
  29. package/dist/cjs/snk-guides-viewer.cjs.entry.js +7 -7
  30. package/dist/cjs/snk-layout-form-config.cjs.entry.js +5 -5
  31. package/dist/cjs/snk-pesquisa.cjs.entry.js +5 -5
  32. package/dist/cjs/snk-taskbar.cjs.entry.js +2 -2
  33. package/dist/cjs/{taskbar-elements-80eddec8.js → taskbar-elements-25f800b3.js} +1 -1
  34. package/dist/cjs/{taskbarUtils-4ca4235e.js → taskbarUtils-99aaa01f.js} +11 -6
  35. package/dist/collection/components/snk-actions-button/snk-actions-button.js +3 -3
  36. package/dist/collection/components/snk-crud/snk-crud.css +9 -4
  37. package/dist/collection/components/snk-crud/snk-crud.js +5 -1
  38. package/dist/collection/components/snk-crud/utils/taskbarUtils.js +5 -0
  39. package/dist/collection/components/snk-data-exporter/exporter-strategy/ClientSideExporterStrategy.js +2 -2
  40. package/dist/collection/components/snk-data-exporter/snk-data-exporter.js +8 -4
  41. package/dist/collection/components/snk-data-exporter/structure/ItemBuilder.js +43 -2
  42. package/dist/collection/components/snk-dynaform/snk-dynaform.css +9 -4
  43. package/dist/collection/components/snk-dynaform/snk-dynaform.js +5 -1
  44. package/dist/collection/components/snk-dynaform/subcomponents/snk-dynaform-detail-view/snk-dynaform-detail-view.css +71 -1
  45. package/dist/collection/components/snk-dynaform/subcomponents/snk-dynaform-detail-view/snk-dynaform-detail-view.js +23 -0
  46. package/dist/collection/components/snk-dynaform/subcomponents/snk-dynaform-form-view/snk-dynaform-form-view.css +35 -1
  47. package/dist/collection/components/snk-dynaform/subcomponents/snk-dynaform-form-view/snk-dynaform-form-view.js +3 -1
  48. package/dist/collection/components/snk-dynaform/subcomponents/snk-dynaform-guides-view/snk-dynaform-guides-view.css +229 -6
  49. package/dist/collection/components/snk-dynaform/subcomponents/snk-dynaform-guides-view/snk-dynaform-guides-view.js +458 -38
  50. package/dist/collection/components/snk-dynaform-form-config/SnkFormConfigManager.js +8 -1
  51. package/dist/collection/components/snk-filter-bar/snk-filter-bar.js +1 -1
  52. package/dist/collection/lib/@types/index.js +6 -0
  53. package/dist/collection/lib/message/resources/en-us/snk-crud.msg.js +4 -0
  54. package/dist/collection/lib/message/resources/es-es/snk-crud.msg.js +4 -0
  55. package/dist/collection/lib/message/resources/pt-br/snk-crud.msg.js +4 -0
  56. package/dist/components/ISave.js +6 -0
  57. package/dist/components/SnkMessageBuilder.js +12 -0
  58. package/dist/components/snk-actions-button2.js +3 -3
  59. package/dist/components/snk-crud.js +6 -2
  60. package/dist/components/snk-data-exporter2.js +53 -8
  61. package/dist/components/snk-dynaform-detail-view2.js +419 -41
  62. package/dist/components/snk-dynaform-form-view2.js +4 -2
  63. package/dist/components/snk-dynaform.js +6 -2
  64. package/dist/components/snk-filter-bar2.js +1 -1
  65. package/dist/components/taskbarUtils.js +5 -0
  66. package/dist/esm/{ConfigStorage-346d781d.js → ConfigStorage-0d1c0695.js} +2 -2
  67. package/dist/esm/{DataFetcher-7d8df5a2.js → DataFetcher-70de9419.js} +12 -0
  68. package/dist/esm/{ISave-2117075a.js → ISave-f5704813.js} +1 -1
  69. package/dist/esm/{SnkFormConfigManager-066d370b.js → SnkFormConfigManager-e7f05f79.js} +2 -2
  70. package/dist/esm/{SnkMultiSelectionListDataSource-7c5ffcd4.js → SnkMultiSelectionListDataSource-6ac291a9.js} +5 -5
  71. package/dist/esm/{auth-fetcher-5891e22c.js → auth-fetcher-e34880e5.js} +1 -1
  72. package/dist/esm/{dataunit-fetcher-5dcb0e89.js → dataunit-fetcher-d26e4a08.js} +1 -1
  73. package/dist/esm/{form-config-fetcher-8e2082f3.js → form-config-fetcher-98c42169.js} +1 -1
  74. package/dist/esm/{index-b40568ff.js → index-c6721886.js} +6 -0
  75. package/dist/esm/loader.js +1 -1
  76. package/dist/esm/pesquisa-grid_2.entry.js +5 -5
  77. package/dist/esm/sankhyablocks.js +1 -1
  78. package/dist/esm/snk-actions-button_9.entry.js +9 -9
  79. package/dist/esm/snk-application.entry.js +7 -7
  80. package/dist/esm/snk-attach_11.entry.js +14 -12
  81. package/dist/esm/snk-crud.entry.js +14 -10
  82. package/dist/esm/snk-data-exporter.entry.js +59 -14
  83. package/dist/esm/{snk-data-unit-f697345b.js → snk-data-unit-ff57ac90.js} +2 -2
  84. package/dist/esm/snk-data-unit.entry.js +3 -3
  85. package/dist/esm/snk-detail-view.entry.js +9 -9
  86. package/dist/esm/snk-dynaform-detail-view_2.entry.js +33 -10
  87. package/dist/esm/{snk-dynaform-guides-view-6aae38f7.js → snk-dynaform-guides-view-0dfbefc1.js} +390 -43
  88. package/dist/esm/snk-dynaform-guides-view.entry.js +6 -6
  89. package/dist/esm/snk-dynaform.entry.js +14 -10
  90. package/dist/esm/snk-filter-bar_4.entry.js +4 -4
  91. package/dist/esm/snk-form_2.entry.js +4 -4
  92. package/dist/esm/snk-grid.entry.js +8 -8
  93. package/dist/esm/{snk-guides-viewer-3ea7e312.js → snk-guides-viewer-31a0a23d.js} +2 -2
  94. package/dist/esm/snk-guides-viewer.entry.js +7 -7
  95. package/dist/esm/snk-layout-form-config.entry.js +5 -5
  96. package/dist/esm/snk-pesquisa.entry.js +5 -5
  97. package/dist/esm/snk-taskbar.entry.js +2 -2
  98. package/dist/esm/{taskbar-elements-63651ca7.js → taskbar-elements-ba9d6889.js} +1 -1
  99. package/dist/esm/{taskbarUtils-a43e4bba.js → taskbarUtils-cb9db0d9.js} +11 -6
  100. package/dist/sankhyablocks/{p-3190ac29.js → p-097d75b3.js} +2 -2
  101. package/dist/sankhyablocks/{p-aa9d61fa.entry.js → p-12579574.entry.js} +1 -1
  102. package/dist/sankhyablocks/{p-741f1ad0.entry.js → p-1d31aec3.entry.js} +1 -1
  103. package/dist/sankhyablocks/{p-6f2de911.entry.js → p-250b273e.entry.js} +1 -1
  104. package/dist/sankhyablocks/p-2a83f20e.entry.js +1 -0
  105. package/dist/sankhyablocks/p-2c4f7fdd.entry.js +1 -0
  106. package/dist/sankhyablocks/{p-3072136e.js → p-2ec98523.js} +1 -1
  107. package/dist/sankhyablocks/{p-10d883b0.js → p-4dd574d6.js} +1 -1
  108. package/dist/sankhyablocks/{p-7827871d.entry.js → p-541c72ec.entry.js} +1 -1
  109. package/dist/sankhyablocks/p-5aeae67f.js +1 -0
  110. package/dist/sankhyablocks/p-5ef0e9a8.entry.js +1 -0
  111. package/dist/sankhyablocks/{p-9e97fabb.entry.js → p-6d3bcabf.entry.js} +1 -1
  112. package/dist/sankhyablocks/p-6f60df43.js +1 -0
  113. package/dist/sankhyablocks/{p-58e0f14b.entry.js → p-846d8f79.entry.js} +1 -1
  114. package/dist/sankhyablocks/{p-77f608bc.entry.js → p-885262ce.entry.js} +1 -1
  115. package/dist/sankhyablocks/{p-c1e168a2.js → p-8d1ef77a.js} +1 -1
  116. package/dist/sankhyablocks/{p-13f91e7e.js → p-8d81c8d3.js} +1 -1
  117. package/dist/sankhyablocks/{p-ee192f06.entry.js → p-8f5dd87d.entry.js} +1 -1
  118. package/dist/sankhyablocks/{p-c5889dae.js → p-90037547.js} +1 -1
  119. package/dist/sankhyablocks/p-9e02a785.js +1 -0
  120. package/dist/sankhyablocks/{p-5a8390f9.entry.js → p-a25ab2ff.entry.js} +1 -1
  121. package/dist/sankhyablocks/p-a696bbcd.entry.js +1 -0
  122. package/dist/sankhyablocks/{p-b3762105.entry.js → p-a9012341.entry.js} +1 -1
  123. package/dist/sankhyablocks/p-abcb646d.js +1 -0
  124. package/dist/sankhyablocks/{p-733eba69.js → p-bd2a845c.js} +1 -1
  125. package/dist/sankhyablocks/p-bfce617e.entry.js +1 -0
  126. package/dist/sankhyablocks/{p-3630a5ae.entry.js → p-c4b34e2b.entry.js} +1 -1
  127. package/dist/sankhyablocks/{p-8d513b64.js → p-c9440c8a.js} +1 -1
  128. package/dist/sankhyablocks/p-cd153f71.entry.js +1 -0
  129. package/dist/sankhyablocks/{p-e91bd00e.js → p-eac48627.js} +1 -1
  130. package/dist/sankhyablocks/{p-d7657667.js → p-ec7c87bb.js} +1 -1
  131. package/dist/sankhyablocks/p-fb6e3c65.entry.js +1 -0
  132. package/dist/sankhyablocks/sankhyablocks.esm.js +1 -1
  133. package/dist/types/components/snk-data-exporter/structure/ItemBuilder.d.ts +16 -0
  134. package/dist/types/components/snk-dynaform/subcomponents/snk-dynaform-detail-view/snk-dynaform-detail-view.d.ts +11 -0
  135. package/dist/types/components/snk-dynaform/subcomponents/snk-dynaform-form-view/snk-dynaform-form-view.d.ts +1 -0
  136. package/dist/types/components.d.ts +32 -0
  137. package/dist/types/lib/@types/index.d.ts +6 -0
  138. package/dist/types/lib/http/data-fetcher/fetchers/fetchDataExporter/interfaces/IFetchDataExporterParams.d.ts +2 -0
  139. package/package.json +1 -1
  140. package/dist/sankhyablocks/p-0f3698af.js +0 -1
  141. package/dist/sankhyablocks/p-1bc6849e.js +0 -1
  142. package/dist/sankhyablocks/p-2c65dc01.entry.js +0 -1
  143. package/dist/sankhyablocks/p-3cc67d50.entry.js +0 -1
  144. package/dist/sankhyablocks/p-4a53fbeb.entry.js +0 -1
  145. package/dist/sankhyablocks/p-7e63af25.entry.js +0 -1
  146. package/dist/sankhyablocks/p-a8a93568.entry.js +0 -1
  147. package/dist/sankhyablocks/p-acd3adf9.entry.js +0 -1
  148. package/dist/sankhyablocks/p-c3bc693a.js +0 -1
  149. package/dist/sankhyablocks/p-c6b6567f.entry.js +0 -1
  150. package/dist/sankhyablocks/p-ed1b1b14.js +0 -1
@@ -1 +1 @@
1
- import{r as i,e as t,h as s,f as e,g as n}from"./p-2c9d0870.js";import{Action as o,DataUnitAction as a,StringUtils as h,ElementIDUtils as r,ApplicationContext as d,KeyboardManager as l}from"@sankhyalabs/core";import{buildFieldSearch as u}from"@sankhyalabs/ezui/dist/collection/utils";import"./p-10d883b0.js";import"./p-3190ac29.js";import{P as c,E as v}from"./p-0f3698af.js";import"@sankhyalabs/ezui/dist/collection/utils/constants";import"@sankhyalabs/core/dist/dataunit/metadata/UnitMetadata";import"./p-c1e168a2.js";import"./p-ff1990ad.js";import"./p-d7657667.js";import{V as m}from"./p-9019a32f.js";import{A as f}from"./p-c3bc693a.js";import{C as g}from"./p-e5a3711f.js";import{S as p,D as k,C as y,b as C,g as b,a as w}from"./p-1bc6849e.js";import{v as S}from"./p-76e66fd9.js";import{S as E}from"./p-cad964b5.js";import{T as _}from"./p-3072136e.js";import"./p-8d884fab.js";import"@sankhyalabs/ezui/dist/collection/components/ez-grid/utils";import"@sankhyalabs/core/dist/utils/SortingUtils";import"./p-688dcb4c.js";import"./p-a73b6b00.js";const T=class{constructor(s){i(this,s),this.snkShowGuide=t(this,"snkShowGuide",7),this.actionClick=t(this,"actionClick",7),this.configuratorSave=t(this,"configuratorSave",7),this.configuratorCancel=t(this,"configuratorCancel",7),this.formItemsReady=t(this,"formItemsReady",7),this.viewModeChanged=t(this,"viewModeChanged",7),this.numberingConfigChanged=t(this,"numberingConfigChanged",7),this._viewHistory=[],this._customEditors=new Map,this._customRenders=new Map,this._taskbarProcessor=new p(k),this._taskbarCustomProcessor=new p([]),this.dataUnitInterceptor={interceptAction:async i=>{var t;switch(i.type){case o.DATA_SAVED:return this.interceptDataSaved(i);case o.LOADING_DATA:return null!==(t=await this.interceptLoadData(i))&&void 0!==t?t:new a(o.INVALIDATE_CLEAN);default:return i}}},this._dataUnit=void 0,this._dataState=void 0,this.attachmentRegisterKey=void 0,this._currentViewMode=m.GRID,this._canEdit=void 0,this._resourceID=void 0,this.customContainerId=`SNK-CRUD-CUSTOM-CONTAINER-${h.generateUUID()}`,this.numberingConfig=void 0,this._filterMode="regular",this._enableContinuousInsert=!1,this._headerVisible=!0,this.enableLockManagerLoadingComp=!1,this.enableLockManagerTaskbarClick=!1,this.configName=void 0,this.filterBarTitle=void 0,this.selectionToastConfig=void 0,this.showActionButtons=!0,this.actionsList=void 0,this.taskbarManager=void 0,this.recordsValidator=void 0,this.statusResolver=void 0,this.multipleSelection=!0,this.presentationMode=c.PRIMARY,this.messagesBuilder=void 0,this.useEnterLikeTab=!1,this.gridLegacyConfigName=void 0,this.filterBarLegacyConfigName=void 0,this.formLegacyConfigName=void 0,this.disablePersonalizedFilter=void 0,this.autoLoad=void 0,this.autoFocus=!0,this.enableGridInsert=!1,this.domainMessagesBuilder=void 0,this.ignoreReadOnlyFormFields=void 0,this.setCustomFormTitle=void 0,this.strategyExporter=v.SERVER_SIDE,this.layoutFormConfig=!0,this.multipleEditionEnabled=!0,this.paginationCounterMode="auto",this.customGuidesConfig=[],this.showEntitySearch=!0,this.disableNumberingConfig=!1}handleActionClick(i){this.executeAction(i.detail)}async goToView(i){this.executeAction(i)}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 reloadFilterBar(){var i;null===(i=this._snkGrid)||void 0===i||i.reloadFilterBar()}async getFilterBar(){var i;return await(null===(i=this._snkGrid)||void 0===i?void 0:i.getFilterBar())}async addCustomEditor(i,t){if(this._guidesViewer&&this._snkGrid)return this._guidesViewer.addCustomEditor(i,t),void this._snkGrid.addCustomEditor(i,t);const s=new Map(this._customEditors);s.set(i,t),this._customEditors=s}async addGridCustomRender(i,t){if(this._snkGrid)return void this._snkGrid.addGridCustomRender(i,t);const s=new Map(this._customRenders);s.set(i,t),this._customRenders=s}async addCustomValueFormatter(i,t){var s;null===(s=this._snkGrid)||void 0===s||s.addCustomValueFormatter(i,t)}async removeCustomValueFormatter(i){var t;null===(t=this._snkGrid)||void 0===t||t.removeCustomValueFormatter(i)}async setFieldProp(i,t,s){var e;await(null===(e=this._guidesViewer)||void 0===e?void 0:e.setFieldProp(i,t,s))}async getNumberingConfig(){return this.numberingConfig}async updateNumberingConfig(i){this.numberingConfig=i,this.applyNumberingConfigToFields()}currentViewModeWatcher(i){this._viewHistory=[...this._viewHistory.slice(-1),i]}async gridToForm(i=!1){var t;this._backToGrid=!i&&await(null===(t=this._viewStack)||void 0===t?void 0:t.getSelectedIndex())===m.GRID,this.setViewMode(m.FORM)}async executeAction(i){var t,s,e;switch(i){case _.GRID_MODE:return this.setViewMode(m.GRID);case _.FORM_MODE:case _.UPDATE:return this.gridToForm(i!==_.UPDATE);case _.UPDATE_MULTIPLE:return this._dataUnit&&(this._dataUnit.isMultipleEdition=!0),this.setViewMode(m.FORM);case _.CONFIGURATOR:return null===(t=this._snkConfigurator)||void 0===t?void 0:t.open();case _.ATTACH:return null===(s=this._snkAttach)||void 0===s?void 0:s.open();case y.FILTER:return null===(e=this._snkFilterBar)||void 0===e?void 0:e.showFilterModal();case y.ENTITY_SEARCH:return this.openSearchPopover()}}setViewMode(i){var t,s,e,n,o;null===(t=this._viewStack)||void 0===t||t.show(i),this._currentViewMode=i,i===m.GRID?(this._dataUnit&&(this._dataUnit.isMultipleEdition=!1),null===(s=this._snkGrid)||void 0===s||s.setFocus()):i===m.FORM&&(null===(n=null===(e=this._guidesViewer)||void 0===e?void 0:e.setFocus)||void 0===n||n.call(e)),null===(o=this.viewModeChanged)||void 0===o||o.emit(i)}openConfig(i){var t,s,e,n,o,a;null===(s=null===(t=this._snkConfigurator)||void 0===t?void 0:t.close)||void 0===s||s.call(t),i===m.GRID?null===(n=(e=this._snkGrid).showConfig)||void 0===n||n.call(e):i===m.FORM&&(null===(a=(o=this._guidesViewer).showFormConfig)||void 0===a||a.call(o))}addDataElementID(){this._element&&r.addIDInfo(this._element,void 0,{dataUnit:this._dataUnit})}insertionModeHandler(){this.enableGridInsert||this.gridToForm()}cancelHandler(){this._backToGrid&&this.setViewMode(m.GRID)}async getAttachmentRegisterKey(){if(this._snkDataUnit)return(await this._snkDataUnit.getSelectedRecordsIDsInfo()).map((({value:i})=>i)).join("_")}setCustomRenders(){if(this._snkGrid)for(const[i,t]of this._customRenders)this._snkGrid.addGridCustomRender(i,t),this._customRenders.delete(i)}setCustomEditors(){if(this._snkGrid&&this._guidesViewer)for(const[i,t]of this._customEditors)this._guidesViewer.addCustomEditor(i,t),this._snkGrid.addCustomEditor(i,t),this._customEditors.delete(i)}initializeTaskbarProcessor(){if(!this._dataState)return;const i=C(this._currentViewMode,this.taskbarManager,this.messagesBuilder),t=b(this._dataState,this.presentationMode);this._taskbarProcessor.process(t,i,this._dataState,void 0,[]);const s=w(this._dataState,this.presentationMode);this._taskbarCustomProcessor.process(s,this.taskbarManager,this._dataState,void 0,[])}componentWillRender(){this.initializeTaskbarProcessor()}componentDidRender(){this.setCustomRenders(),this.setCustomEditors()}componentWillLoad(){var i,t,s,e,n;this._application=d.getContextValue("__SNK__APPLICATION__");let o=null===(i=this._element)||void 0===i?void 0:i.parentElement;for(null===(t=this._application)||void 0===t||t.hasAccess(f.UPDATE,this._resourceID).then((i=>this._canEdit=i));o;){if("SNK-DATA-UNIT"===o.tagName.toUpperCase()){this._snkDataUnit=o,this._snkDataUnit.addEventListener("insertionMode",(()=>this.insertionModeHandler())),this._snkDataUnit.addEventListener("cancelEdition",(()=>this.cancelHandler())),this._snkDataUnit&&this.domainMessagesBuilder&&(this._snkDataUnit.domainMessagesBuilder=this.domainMessagesBuilder),this._dataUnit=this._snkDataUnit.dataUnit,this._dataState=this._snkDataUnit.dataState,this._dataUnit?this.initDataUnit():null===(s=this._snkDataUnit)||void 0===s||s.addEventListener("dataUnitReady",(i=>{this._dataUnit=i.detail,this.initDataUnit()})),null===(e=this._snkDataUnit)||void 0===e||e.addEventListener("dataStateChange",(i=>this.handleDataStateChange(i)));break}o=o.parentElement}this.configName||(this.configName=null===(n=this._application)||void 0===n?void 0:n.configName),this.initContinuousInsertUtils()}componentDidLoad(){this.initKeyboardManager()}disconnectedCallback(){var i;this.removeShortcuts(),null===(i=this._dataUnit)||void 0===i||i.removeInterceptor(this.dataUnitInterceptor)}async handleDataStateChange(i){var t,s,e;this._dataState=i.detail,void 0!==this._dataState.selectedRecord&&(this.attachmentRegisterKey=null!==(t=await this.getAttachmentRegisterKey())&&void 0!==t?t:void 0);const n=await(null===(s=this._snkDataUnit)||void 0===s?void 0:s.getFieldsWithRmPrecision());for(const i of n||[]){if(!i)continue;const t=null===(e=this._dataState.rowMetadata)||void 0===e?void 0:e.getProp("rm_precision",i);(t||0===t)&&(await this.setFieldProp(i,"precision",t),await this.setFieldProp(i,"prettyPrecision",t))}}async initKeyboardManager(){var i,t,s,e,n,o,a,h,r,d;this._keyboardManager=new l({propagate:!1,element:this._element});const u=this._dataUnit||await(null===(i=this._snkDataUnit)||void 0===i?void 0:i.getDataUnit());async function c(){const i=document.activeElement,t=i==document.body;t||i.blur(),await(null==u?void 0:u.saveData()),t||null==i.setFocus?t||i.focus():i.setFocus()}this._keyboardManager&&this._keyboardManager.bind("F6",this.toggleView.bind(this),{description:null!==(t=this.getMessage("snkCrud.shortcuts.toggleView"))&&void 0!==t?t:"",element:this._element}).bind("F7",c.bind(this),{description:null!==(s=this.getMessage("snkCrud.shortcuts.saveData"))&&void 0!==s?s:"",element:this._element}).bind("ctrl + \\",c.bind(this),{description:null!==(e=this.getMessage("snkCrud.shortcuts.addRecord"))&&void 0!==e?e:"",element:this._element}).bind("F8",async function(){(null==u?void 0:u.hasNewRecord())||null==u||u.addRecord()}.bind(this),{description:null!==(n=this.getMessage("snkCrud.shortcuts.addRecord"))&&void 0!==n?n:"",element:this._element}).bind("F9",u?null===(o=u.removeSelectedRecords)||void 0===o?void 0:o.bind(u):()=>{},{description:null!==(a=this.getMessage("snkCrud.shortcuts.removeRecord"))&&void 0!==a?a:"",element:this._element}).bind("ctrl + F9",u?u.removeSelectedRecords.bind(u):()=>{},{description:null!==(h=this.getMessage("snkCrud.shortcuts.removeRecord"))&&void 0!==h?h:"",element:this._element}).bind("F5",(async()=>{var i;const t=await(null===(i=this._viewStack)||void 0===i?void 0:i.getSelectedIndex());m.GRID===t&&(null==u||u.loadData())}),{description:null!==(r=this.getMessage("snkCrud.shortcuts.refreshData"))&&void 0!==r?r:"",element:this._element}).bind("Escape",(()=>{(null==u?void 0:u.isDirty())&&(null==u||u.cancelEdition())}),{debounceTime:1e3,description:null!==(d=this.getMessage("snkCrud.shortcuts.cancelAction"))&&void 0!==d?d:"",element:this._element})}getMessage(i,t){if(this.messagesBuilder)return this.messagesBuilder.getMessage(i,t)}async removeShortcuts(){var i;null===(i=this._keyboardManager)||void 0===i||i.unbindAllShortcutKeys()}async toggleView(){var i;const t=await(null===(i=this._viewStack)||void 0===i?void 0:i.getSelectedIndex());this.setViewMode(m.GRID===t?m.FORM:m.GRID)}getLastRecordSaved(i){var t;return(null===(t=i.payload)||void 0===t?void 0:t.records.length)?i.payload.records[i.payload.records.length-1]:null}async saveNumberingConfig(){if(!this._snkDataUnit||!this.numberingConfig||!this._servicesNumberingConfig)return;const i={entityName:this._snkDataUnit.entityName,isAutoNum:this.numberingConfig.isAutoNumbering,numInicial:this.numberingConfig.initialNumber};await this._servicesNumberingConfig.saveConfig(i)}updateNumberingConfigAfterInsert(i){var t,s,e;if(!(null===(t=i.payload)||void 0===t?void 0:t.changes.length)||this.disableNumberingConfig||!(null===(s=this.numberingConfig)||void 0===s?void 0:s.isAutoNumbering)||!this._fieldAutoNum)return i;if(!i.payload.changes.some((i=>"INSERT"===i.operation||"COPY"===i.operation)))return i;const n=this.getLastRecordSaved(i);if(n&&n.hasOwnProperty(this._fieldAutoNum)){const i=Number(n[this._fieldAutoNum]);this.numberingConfig.initialNumber=i,this.saveNumberingConfig()}else this.numberingConfig.initialNumber=this.numberingConfig.initialNumber+1;return null===(e=this.numberingConfigChanged)||void 0===e||e.emit(this.numberingConfig),i}interceptDataSaved(i){return this.updateNumberingConfigAfterInsert(i),i}async interceptLoadData(i){var t,s,e,n,o,a,h;if(S(null!==(s=null===(t=this._snkFilterBar)||void 0===t?void 0:t.filterConfig)&&void 0!==s?s:[]))return i;{const i=null!==(n=null===(e=this.messagesBuilder)||void 0===e?void 0:e.getMessage("snkGrid.requiredFiltersNotFilled.title",{}))&&void 0!==n?n:"",t=null!==(a=null===(o=this.messagesBuilder)||void 0===o?void 0:o.getMessage("snkGrid.requiredFiltersNotFilled.message",{}))&&void 0!==a?a:"";await(null===(h=this._application)||void 0===h?void 0:h.error(i,t))}}onDataUnitReady(){var i;null===(i=this._dataUnit)||void 0===i||i.addInterceptor(this.dataUnitInterceptor),this.loadNumberingConfig()}async initDataUnit(){var i,t,s;this.addDataElementID(),this.messagesBuilder||(this.messagesBuilder=null===(i=this._snkDataUnit)||void 0===i?void 0:i.messagesBuilder),null==this._resourceID&&(this._resourceID=null===(t=this._snkDataUnit)||void 0===t?void 0:t.resourceID,null==this._resourceID&&(this._resourceID=await(null===(s=this._application)||void 0===s?void 0:s.getResourceID()))),this.onDataUnitReady()}initContinuousInsertUtils(){this._application&&this._resourceID&&(this._continuousInsertUtils=new g(this._application,this._resourceID,this.configName),this.enableGridInsert&&this._continuousInsertUtils.getConfig().then((i=>this._enableContinuousInsert=i)))}async loadNumberingConfig(){if(!this.numberingConfig&&this._snkDataUnit&&this._snkDataUnit.entityName&&!this.disableNumberingConfig&&this._application){this._servicesNumberingConfig||(this._servicesNumberingConfig=new E(this._application,this._resourceID));try{this.numberingConfig=await this._servicesNumberingConfig.getConfig(this._snkDataUnit.entityName),this.getFieldAutoNum(),this.applyNumberingConfigToFields()}catch(i){console.error("Error loading numbering config in snk-crud:",i),this.numberingConfig={isAutoNumbering:!1,initialNumber:NaN}}}}getFieldAutoNum(){var i;if(this._fieldAutoNum)return;const t=null===(i=this._dataUnit)||void 0===i?void 0:i.metadata.fields.find((i=>{var t;return"true"===(null===(t=i.properties)||void 0===t?void 0:t.isAutoNumField)}));this._fieldAutoNum=(null==t?void 0:t.name)||null}async applyNumberingConfigToFields(){var i;if(!this.numberingConfig||!this._snkDataUnit||!this._fieldAutoNum)return;const t=null===(i=this._dataUnit)||void 0===i?void 0:i.getField(this._fieldAutoNum);t&&(t.readOnly=this.numberingConfig.isAutoNumbering,t.required=!this.numberingConfig.isAutoNumbering)}handleConfiguratorEvent(i,t){var s,e,n;if(i.stopImmediatePropagation(),"SAVE"===t)return null===(s=this._guidesViewer)||void 0===s||s.reloadGuides(),void(null===(e=this.configuratorSave)||void 0===e||e.emit());null===(n=this.configuratorCancel)||void 0===n||n.emit()}renderCustomGuideSlots(){if(this.customGuidesConfig)return this.customGuidesConfig.map((i=>s("slot",{name:i.id})))}getColumnSearch(i){return null!=this._columnSearch||(this._columnSearch=u(i,(({argument:i})=>new Promise((t=>{var s;null===(s=this._snkGrid)||void 0===s||s.filterColumns(i).then((i=>{t(i.filter((i=>!i.hidden)).map((i=>({label:i.label,value:i.name}))))}))}))),(i=>{var t;null!=i&&(null===(t=this._snkGrid)||void 0===t||t.locateColumn(i.value))}))),this._columnSearch}buildTaskbarCustomActionsList(){return[this.buildSearchColumnTaskbarAction()]}buildSearchColumnTaskbarAction(){var i,t;return{value:h.generateUUID(),label:null!==(t=null===(i=this.messagesBuilder)||void 0===i?void 0:i.getMessage("snkGrid.findColumn",{}))&&void 0!==t?t:"",disableCloseOnSelect:!0,eagerInitialize:!0,itemBuilder:(i,t)=>{var s;return null!==(s=this.getColumnSearch(t))&&void 0!==s?s:document.createElement("div")}}}isGridInsertActive(){var i;return this.enableGridInsert&&(null===(i=this._dataUnit)||void 0===i?void 0:i.hasNewRecord())}getActionsList(){var i,t;const s=[];if(this.enableGridInsert&&this._continuousInsertUtils&&s.push(this._continuousInsertUtils.actionContinuousInsert(this._enableContinuousInsert,(()=>{var i;this._enableContinuousInsert=!this._enableContinuousInsert,null===(i=this._continuousInsertUtils)||void 0===i||i.handleSaveConfig(this._enableContinuousInsert)}))),this.isGridInsertActive())return s;if(this._dataState&&this.actionsList&&null!=this.taskbarManager&&null!=this.taskbarManager.getMoreOptions){const t=b(this._dataState,this.presentationMode);return s.concat(this.taskbarManager.getMoreOptions(t,null!==(i=this.configName)&&void 0!==i?i:"",this._dataState,this.actionsList))}return s.concat(null!==(t=this.actionsList)&&void 0!==t?t:[])}async openSearchPopover(){var i;if(!this._popoverSearchEntity)return;const t=null===(i=this._element)||void 0===i?void 0:i.querySelector(`[data-taskbar-element="${y.ENTITY_SEARCH}"]`);await this._popoverSearchEntity.showUnder(t)}handleLoadedSearch(i){var t;1===i.detail.length&&(null===(t=this._dataUnit)||void 0===t||t.selectFirst(),this.gridToForm(!0))}renderDynamicSearch(){var i;if(this.showEntitySearch)return s("snk-entity-search",{ref:i=>this._popoverSearchEntity=i,dataUnit:this._dataUnit,entityName:null===(i=this._snkDataUnit)||void 0===i?void 0:i.entityName,messagesBuilder:this.messagesBuilder,onLoaded:i=>this.handleLoadedSearch(i)})}handleFilterConfigUpdated(i){i.length&&(1!==i.length||"PERSONALIZED_FILTER_GROUP"!==i[0].id||(this._filterMode=i[0].groupedItems.length>0?"regular":"button"))}render(){var i,t,n,o,a;if(null!=this._resourceID)return this._snkDataUnit&&(this._snkDataUnit.ignoreSaveMessage=this._currentViewMode===m.GRID&&!this.enableGridInsert),s(e,null,s("header",{class:{"snk-crud--hidden":!this._headerVisible,"snk-crud__header":!0}},s("div",{class:"snk-crud__header-top"},s("snk-taskbar",{"data-element-id":"grid_top",key:"snkGridTopTaskbar",configName:this.configName,dataUnit:this._dataUnit,messagesBuilder:this.messagesBuilder,buttons:this._taskbarProcessor.buttons,disabledButtons:this._taskbarProcessor.disabledButtons,customButtons:this._taskbarProcessor.customButtons,resourceID:this._resourceID,primaryButton:"INSERT",overflowStrategy:"hiddenItems",alignRigth:!0,actionsList:this.getActionsList(),customActionsList:this.buildTaskbarCustomActionsList(),sizeButtons:"medium"})),s("snk-filter-bar",{ref:i=>this._snkFilterBar=i,title:this.filterBarTitle,dataUnit:this._dataUnit,"data-element-id":"gridFilter",class:"snk-grid__filter-bar ez-align--top",configName:this.configName,messagesBuilder:this.messagesBuilder,resourceID:this._resourceID,onConfigUpdated:i=>this.handleFilterConfigUpdated(i.detail),disablePersonalizedFilter:this.disablePersonalizedFilter,filterBarLegacyConfigName:this.filterBarLegacyConfigName,autoLoad:this.autoLoad,enableLockManagerLoadingComp:this.enableLockManagerLoadingComp,mode:this._filterMode,hideFilterButton:!0,sizeChips:"default"})),s("ez-view-stack",{ref:i=>this._viewStack=i,"data-element-id":"crud"},s("stack-item",{class:"snk-crud__grid-stack-item"},s("snk-grid",{ref:i=>this._snkGrid=i,class:"ez-flex ez-flex--column ez-size-height--full ez-size-width--full",filterBarTitle:this.filterBarTitle,"data-element-id":"crud_grid",configName:this.configName,onGridDoubleClick:()=>this.gridToForm(!0),taskbarManager:this.taskbarManager,onActionClick:i=>this.executeAction(i.detail),messagesBuilder:this.messagesBuilder,actionsList:this.actionsList,statusResolver:this.statusResolver,multipleSelection:this.multipleSelection,presentationMode:this.presentationMode,recordsValidator:this.recordsValidator,selectionToastConfig:this.selectionToastConfig,useEnterLikeTab:this.useEnterLikeTab,canEdit:this._canEdit,resourceID:this._resourceID,disablePersonalizedFilter:this.disablePersonalizedFilter,gridLegacyConfigName:this.gridLegacyConfigName,filterBarLegacyConfigName:this.filterBarLegacyConfigName,autoLoad:this.autoLoad,autoFocus:this.autoFocus,enableGridInsert:this.enableGridInsert,enableLockManagerTaskbarClick:this.enableLockManagerTaskbarClick,enableLockManagerLoadingComp:this.enableLockManagerLoadingComp,strategyExporter:this.strategyExporter,multipleEditionEnabled:this.multipleEditionEnabled,paginationCounterMode:this.paginationCounterMode,hideHeader:!0,hideGridTaskbar:!0},s("slot",{name:"GRID_TASKBAR_CUSTOM_ELEMENTS"}),s("slot",{name:"GRID_HEADER_CUSTOM_ELEMENTS"}),s("slot",{name:"SnkGridHeader"}),s("slot",{name:"SnkGridFooter"}),s("slot",{name:"SnkGridTaskBar"}))),s("stack-item",null,s("snk-dynaform-guides-view",{ref:i=>this._guidesViewer=i,customGuidesConfig:this.customGuidesConfig,entityPath:null===(i=this._snkDataUnit)||void 0===i?void 0:i.entityName,messagesBuilder:this.messagesBuilder,onExit:()=>this.setViewMode(m.GRID),dataState:this._dataState,dataUnit:this._dataUnit,actionsList:this.actionsList,taskbarManager:this.taskbarManager,configName:this.configName,onActionClick:i=>this.executeAction(i.detail),presentationMode:this.presentationMode,"data-element-id":"crud_form",canEdit:this._canEdit,recordsValidator:this.recordsValidator,resourceID:this._resourceID,detailTaskbarCustomContainerId:this.customContainerId,formLegacyConfigName:this.formLegacyConfigName,enableGridInsert:this.enableGridInsert,getCustomTitle:this.setCustomFormTitle,ignoreReadOnlyFormFields:this.ignoreReadOnlyFormFields,onFormConfigVisibilityChanged:i=>this._headerVisible=!i.detail},s("slot",{name:"GUIDES_VIEWER_TASKBAR_CUSTOM_ELEMENTS"}),this.renderCustomGuideSlots(),s("slot",{name:"SnkFormTaskBar"})))),s("snk-attach",{ref:i=>this._snkAttach=i,registerKey:null!==(t=this.attachmentRegisterKey)&&void 0!==t?t:"",messagesBuilder:this.messagesBuilder,entityName:null!==(o=null===(n=this._snkDataUnit)||void 0===n?void 0:n.entityName)&&void 0!==o?o:""}),s("snk-configurator",{ref:i=>this._snkConfigurator=i,entityName:null===(a=this._snkDataUnit)||void 0===a?void 0:a.entityName,viewMode:this._currentViewMode,messagesBuilder:this.messagesBuilder,onConfigSelected:i=>this.setViewMode(i.detail),onOpenConfig:i=>this.openConfig(i.detail),showActionButtons:this.showActionButtons,onSave:i=>this.handleConfiguratorEvent(i,"SAVE"),onCancel:i=>this.handleConfiguratorEvent(i,"CANCEL"),resourceID:this._resourceID,customContainerId:this.customContainerId,layoutFormConfig:this.layoutFormConfig}),this.renderDynamicSearch(),s("div",{id:`${this.customContainerId}`},s("slot",{name:"SnkConfigContainerSlot"}),s("slot",{name:"DETAIL_GRID_HEADER_CUSTOM_ELEMENTS"}),s("slot",{name:"DETAIL_GRID_TASKBAR_CUSTOM_ELEMENTS"}),s("slot",{name:"DETAIL_TASKBAR_CUSTOM_ELEMENTS"})))}get _element(){return n(this)}static get watchers(){return{_currentViewMode:["currentViewModeWatcher"]}}};T.style=".sc-snk-dynaform-h{display:flex;flex-direction:column;height:100%;width:100%;overflow:hidden;scrollbar-gutter:stable both-edges}snk-grid.sc-snk-dynaform{--snk-grid-padding:0 var(--space--6, 6px) var(--space--6, 6px) var(--space--6, 6px)}ez-view-stack.sc-snk-dynaform{flex:1;min-height:0;display:flex;flex-direction:column;overflow:hidden}stack-item.sc-snk-dynaform.sc-snk-dynaform{display:flex;flex-direction:column;flex:1;min-height:0;overflow:hidden}stack-item.sc-snk-dynaform.sc-snk-dynaform>snk-dynaform-guides-view.sc-snk-dynaform{flex:1;min-height:0;display:flex;flex-direction:column;overflow:hidden}.snk-crud__header.sc-snk-dynaform{margin-bottom:var(--space--10, 10px)}.snk-crud__grid-stack-item.sc-snk-dynaform{display:flex;flex-direction:column;height:100%;width:100%;padding:0 var(--space--2, 2px)}.snk-crud__header-top.sc-snk-dynaform{display:flex;justify-content:space-between;align-items:center;padding:var(--space--8, 8px);padding-top:var(--space--12, 12px)}.snk-crud--hidden.sc-snk-dynaform{display:none !important}ez-record-navigation.sc-snk-dynaform,ez-grid-pagination.sc-snk-dynaform{margin-bottom:var(--space--8, 8px)}";export{T as snk_dynaform}
1
+ import{r as i,e as t,h as s,f as e,g as n}from"./p-2c9d0870.js";import{Action as o,DataUnitAction as a,StringUtils as h,ElementIDUtils as r,ApplicationContext as d,KeyboardManager as l}from"@sankhyalabs/core";import{buildFieldSearch as u}from"@sankhyalabs/ezui/dist/collection/utils";import"./p-4dd574d6.js";import"./p-097d75b3.js";import{P as c,E as v}from"./p-abcb646d.js";import"@sankhyalabs/ezui/dist/collection/utils/constants";import"@sankhyalabs/core/dist/dataunit/metadata/UnitMetadata";import"./p-8d1ef77a.js";import"./p-ff1990ad.js";import"./p-ec7c87bb.js";import{V as m}from"./p-9019a32f.js";import{A as f}from"./p-9e02a785.js";import{C as g}from"./p-e5a3711f.js";import{S as p,D as k,C as y,b as C,g as b,a as w}from"./p-6f60df43.js";import{v as S}from"./p-76e66fd9.js";import{S as _}from"./p-cad964b5.js";import{T as E}from"./p-2ec98523.js";import"./p-8d884fab.js";import"@sankhyalabs/ezui/dist/collection/components/ez-grid/utils";import"@sankhyalabs/core/dist/utils/SortingUtils";import"./p-688dcb4c.js";import"./p-a73b6b00.js";const T=class{constructor(s){i(this,s),this.snkShowGuide=t(this,"snkShowGuide",7),this.actionClick=t(this,"actionClick",7),this.configuratorSave=t(this,"configuratorSave",7),this.configuratorCancel=t(this,"configuratorCancel",7),this.formItemsReady=t(this,"formItemsReady",7),this.viewModeChanged=t(this,"viewModeChanged",7),this.numberingConfigChanged=t(this,"numberingConfigChanged",7),this._viewHistory=[],this._customEditors=new Map,this._customRenders=new Map,this._taskbarProcessor=new p(k),this._taskbarCustomProcessor=new p([]),this.dataUnitInterceptor={interceptAction:async i=>{var t;switch(i.type){case o.DATA_SAVED:return this.interceptDataSaved(i);case o.LOADING_DATA:return null!==(t=await this.interceptLoadData(i))&&void 0!==t?t:new a(o.INVALIDATE_CLEAN);default:return i}}},this._dataUnit=void 0,this._dataState=void 0,this.attachmentRegisterKey=void 0,this._currentViewMode=m.GRID,this._canEdit=void 0,this._resourceID=void 0,this.customContainerId=`SNK-CRUD-CUSTOM-CONTAINER-${h.generateUUID()}`,this.numberingConfig=void 0,this._filterMode="regular",this._enableContinuousInsert=!1,this._headerVisible=!0,this.enableLockManagerLoadingComp=!1,this.enableLockManagerTaskbarClick=!1,this.configName=void 0,this.filterBarTitle=void 0,this.selectionToastConfig=void 0,this.showActionButtons=!0,this.actionsList=void 0,this.taskbarManager=void 0,this.recordsValidator=void 0,this.statusResolver=void 0,this.multipleSelection=!0,this.presentationMode=c.PRIMARY,this.messagesBuilder=void 0,this.useEnterLikeTab=!1,this.gridLegacyConfigName=void 0,this.filterBarLegacyConfigName=void 0,this.formLegacyConfigName=void 0,this.disablePersonalizedFilter=void 0,this.autoLoad=void 0,this.autoFocus=!0,this.enableGridInsert=!1,this.domainMessagesBuilder=void 0,this.ignoreReadOnlyFormFields=void 0,this.setCustomFormTitle=void 0,this.strategyExporter=v.SERVER_SIDE,this.layoutFormConfig=!0,this.multipleEditionEnabled=!0,this.paginationCounterMode="auto",this.customGuidesConfig=[],this.showEntitySearch=!0,this.disableNumberingConfig=!1}handleActionClick(i){this.executeAction(i.detail)}async goToView(i){this.executeAction(i)}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 reloadFilterBar(){var i;null===(i=this._snkGrid)||void 0===i||i.reloadFilterBar()}async getFilterBar(){var i;return await(null===(i=this._snkGrid)||void 0===i?void 0:i.getFilterBar())}async addCustomEditor(i,t){if(this._guidesViewer&&this._snkGrid)return this._guidesViewer.addCustomEditor(i,t),void this._snkGrid.addCustomEditor(i,t);const s=new Map(this._customEditors);s.set(i,t),this._customEditors=s}async addGridCustomRender(i,t){if(this._snkGrid)return void this._snkGrid.addGridCustomRender(i,t);const s=new Map(this._customRenders);s.set(i,t),this._customRenders=s}async addCustomValueFormatter(i,t){var s;null===(s=this._snkGrid)||void 0===s||s.addCustomValueFormatter(i,t)}async removeCustomValueFormatter(i){var t;null===(t=this._snkGrid)||void 0===t||t.removeCustomValueFormatter(i)}async setFieldProp(i,t,s){var e;await(null===(e=this._guidesViewer)||void 0===e?void 0:e.setFieldProp(i,t,s))}async getNumberingConfig(){return this.numberingConfig}async updateNumberingConfig(i){this.numberingConfig=i,this.applyNumberingConfigToFields()}currentViewModeWatcher(i){this._viewHistory=[...this._viewHistory.slice(-1),i]}async gridToForm(i=!1){var t;this._backToGrid=!i&&await(null===(t=this._viewStack)||void 0===t?void 0:t.getSelectedIndex())===m.GRID,this.setViewMode(m.FORM)}async executeAction(i){var t,s,e;switch(i){case E.GRID_MODE:return this.setViewMode(m.GRID);case E.FORM_MODE:case E.UPDATE:return this.gridToForm(i!==E.UPDATE);case E.UPDATE_MULTIPLE:return this._dataUnit&&(this._dataUnit.isMultipleEdition=!0),this.setViewMode(m.FORM);case E.CONFIGURATOR:return null===(t=this._snkConfigurator)||void 0===t?void 0:t.open();case E.ATTACH:return null===(s=this._snkAttach)||void 0===s?void 0:s.open();case y.FILTER:return null===(e=this._snkFilterBar)||void 0===e?void 0:e.showFilterModal();case y.ENTITY_SEARCH:return this.openSearchPopover()}}setViewMode(i){var t,s,e,n,o;null===(t=this._viewStack)||void 0===t||t.show(i),this._currentViewMode=i,i===m.GRID?(this._dataUnit&&(this._dataUnit.isMultipleEdition=!1),null===(s=this._snkGrid)||void 0===s||s.setFocus()):i===m.FORM&&(null===(n=null===(e=this._guidesViewer)||void 0===e?void 0:e.setFocus)||void 0===n||n.call(e)),null===(o=this.viewModeChanged)||void 0===o||o.emit(i)}openConfig(i){var t,s,e,n,o,a;null===(s=null===(t=this._snkConfigurator)||void 0===t?void 0:t.close)||void 0===s||s.call(t),i===m.GRID?null===(n=(e=this._snkGrid).showConfig)||void 0===n||n.call(e):i===m.FORM&&(null===(a=(o=this._guidesViewer).showFormConfig)||void 0===a||a.call(o))}addDataElementID(){this._element&&r.addIDInfo(this._element,void 0,{dataUnit:this._dataUnit})}insertionModeHandler(){this.enableGridInsert||this.gridToForm()}cancelHandler(){this._backToGrid&&this.setViewMode(m.GRID)}async getAttachmentRegisterKey(){if(this._snkDataUnit)return(await this._snkDataUnit.getSelectedRecordsIDsInfo()).map((({value:i})=>i)).join("_")}setCustomRenders(){if(this._snkGrid)for(const[i,t]of this._customRenders)this._snkGrid.addGridCustomRender(i,t),this._customRenders.delete(i)}setCustomEditors(){if(this._snkGrid&&this._guidesViewer)for(const[i,t]of this._customEditors)this._guidesViewer.addCustomEditor(i,t),this._snkGrid.addCustomEditor(i,t),this._customEditors.delete(i)}initializeTaskbarProcessor(){if(!this._dataState)return;const i=C(this._currentViewMode,this.taskbarManager,this.messagesBuilder),t=b(this._dataState,this.presentationMode);this._taskbarProcessor.process(t,i,this._dataState,void 0,[]);const s=w(this._dataState,this.presentationMode);this._taskbarCustomProcessor.process(s,this.taskbarManager,this._dataState,void 0,[])}componentWillRender(){this.initializeTaskbarProcessor()}componentDidRender(){this.setCustomRenders(),this.setCustomEditors()}componentWillLoad(){var i,t,s,e,n;this._application=d.getContextValue("__SNK__APPLICATION__");let o=null===(i=this._element)||void 0===i?void 0:i.parentElement;for(null===(t=this._application)||void 0===t||t.hasAccess(f.UPDATE,this._resourceID).then((i=>this._canEdit=i));o;){if("SNK-DATA-UNIT"===o.tagName.toUpperCase()){this._snkDataUnit=o,this._snkDataUnit.addEventListener("insertionMode",(()=>this.insertionModeHandler())),this._snkDataUnit.addEventListener("cancelEdition",(()=>this.cancelHandler())),this._snkDataUnit&&this.domainMessagesBuilder&&(this._snkDataUnit.domainMessagesBuilder=this.domainMessagesBuilder),this._dataUnit=this._snkDataUnit.dataUnit,this._dataState=this._snkDataUnit.dataState,this._dataUnit?this.initDataUnit():null===(s=this._snkDataUnit)||void 0===s||s.addEventListener("dataUnitReady",(i=>{this._dataUnit=i.detail,this.initDataUnit()})),null===(e=this._snkDataUnit)||void 0===e||e.addEventListener("dataStateChange",(i=>this.handleDataStateChange(i)));break}o=o.parentElement}this.configName||(this.configName=null===(n=this._application)||void 0===n?void 0:n.configName),this.initContinuousInsertUtils()}componentDidLoad(){this.initKeyboardManager()}disconnectedCallback(){var i;this.removeShortcuts(),null===(i=this._dataUnit)||void 0===i||i.removeInterceptor(this.dataUnitInterceptor)}async handleDataStateChange(i){var t,s,e;this._dataState=i.detail,void 0!==this._dataState.selectedRecord&&(this.attachmentRegisterKey=null!==(t=await this.getAttachmentRegisterKey())&&void 0!==t?t:void 0);const n=await(null===(s=this._snkDataUnit)||void 0===s?void 0:s.getFieldsWithRmPrecision());for(const i of n||[]){if(!i)continue;const t=null===(e=this._dataState.rowMetadata)||void 0===e?void 0:e.getProp("rm_precision",i);(t||0===t)&&(await this.setFieldProp(i,"precision",t),await this.setFieldProp(i,"prettyPrecision",t))}}async initKeyboardManager(){var i,t,s,e,n,o,a,h,r,d;this._keyboardManager=new l({propagate:!1,element:this._element});const u=this._dataUnit||await(null===(i=this._snkDataUnit)||void 0===i?void 0:i.getDataUnit());async function c(){const i=document.activeElement,t=i==document.body;t||i.blur(),await(null==u?void 0:u.saveData()),t||null==i.setFocus?t||i.focus():i.setFocus()}this._keyboardManager&&this._keyboardManager.bind("F6",this.toggleView.bind(this),{description:null!==(t=this.getMessage("snkCrud.shortcuts.toggleView"))&&void 0!==t?t:"",element:this._element}).bind("F7",c.bind(this),{description:null!==(s=this.getMessage("snkCrud.shortcuts.saveData"))&&void 0!==s?s:"",element:this._element}).bind("ctrl + \\",c.bind(this),{description:null!==(e=this.getMessage("snkCrud.shortcuts.addRecord"))&&void 0!==e?e:"",element:this._element}).bind("F8",async function(){(null==u?void 0:u.hasNewRecord())||null==u||u.addRecord()}.bind(this),{description:null!==(n=this.getMessage("snkCrud.shortcuts.addRecord"))&&void 0!==n?n:"",element:this._element}).bind("F9",u?null===(o=u.removeSelectedRecords)||void 0===o?void 0:o.bind(u):()=>{},{description:null!==(a=this.getMessage("snkCrud.shortcuts.removeRecord"))&&void 0!==a?a:"",element:this._element}).bind("ctrl + F9",u?u.removeSelectedRecords.bind(u):()=>{},{description:null!==(h=this.getMessage("snkCrud.shortcuts.removeRecord"))&&void 0!==h?h:"",element:this._element}).bind("F5",(async()=>{var i;const t=await(null===(i=this._viewStack)||void 0===i?void 0:i.getSelectedIndex());m.GRID===t&&(null==u||u.loadData())}),{description:null!==(r=this.getMessage("snkCrud.shortcuts.refreshData"))&&void 0!==r?r:"",element:this._element}).bind("Escape",(()=>{(null==u?void 0:u.isDirty())&&(null==u||u.cancelEdition())}),{debounceTime:1e3,description:null!==(d=this.getMessage("snkCrud.shortcuts.cancelAction"))&&void 0!==d?d:"",element:this._element})}getMessage(i,t){if(this.messagesBuilder)return this.messagesBuilder.getMessage(i,t)}async removeShortcuts(){var i;null===(i=this._keyboardManager)||void 0===i||i.unbindAllShortcutKeys()}async toggleView(){var i;const t=await(null===(i=this._viewStack)||void 0===i?void 0:i.getSelectedIndex());this.setViewMode(m.GRID===t?m.FORM:m.GRID)}getLastRecordSaved(i){var t;return(null===(t=i.payload)||void 0===t?void 0:t.records.length)?i.payload.records[i.payload.records.length-1]:null}async saveNumberingConfig(){if(!this._snkDataUnit||!this.numberingConfig||!this._servicesNumberingConfig)return;const i={entityName:this._snkDataUnit.entityName,isAutoNum:this.numberingConfig.isAutoNumbering,numInicial:this.numberingConfig.initialNumber};await this._servicesNumberingConfig.saveConfig(i)}updateNumberingConfigAfterInsert(i){var t,s,e;if(!(null===(t=i.payload)||void 0===t?void 0:t.changes.length)||this.disableNumberingConfig||!(null===(s=this.numberingConfig)||void 0===s?void 0:s.isAutoNumbering)||!this._fieldAutoNum)return i;if(!i.payload.changes.some((i=>"INSERT"===i.operation||"COPY"===i.operation)))return i;const n=this.getLastRecordSaved(i);if(n&&n.hasOwnProperty(this._fieldAutoNum)){const i=Number(n[this._fieldAutoNum]);this.numberingConfig.initialNumber=i,this.saveNumberingConfig()}else this.numberingConfig.initialNumber=this.numberingConfig.initialNumber+1;return null===(e=this.numberingConfigChanged)||void 0===e||e.emit(this.numberingConfig),i}interceptDataSaved(i){return this.updateNumberingConfigAfterInsert(i),i}async interceptLoadData(i){var t,s,e,n,o,a,h;if(S(null!==(s=null===(t=this._snkFilterBar)||void 0===t?void 0:t.filterConfig)&&void 0!==s?s:[]))return i;{const i=null!==(n=null===(e=this.messagesBuilder)||void 0===e?void 0:e.getMessage("snkGrid.requiredFiltersNotFilled.title",{}))&&void 0!==n?n:"",t=null!==(a=null===(o=this.messagesBuilder)||void 0===o?void 0:o.getMessage("snkGrid.requiredFiltersNotFilled.message",{}))&&void 0!==a?a:"";await(null===(h=this._application)||void 0===h?void 0:h.error(i,t))}}onDataUnitReady(){var i;null===(i=this._dataUnit)||void 0===i||i.addInterceptor(this.dataUnitInterceptor),this.loadNumberingConfig()}async initDataUnit(){var i,t,s;this.addDataElementID(),this.messagesBuilder||(this.messagesBuilder=null===(i=this._snkDataUnit)||void 0===i?void 0:i.messagesBuilder),null==this._resourceID&&(this._resourceID=null===(t=this._snkDataUnit)||void 0===t?void 0:t.resourceID,null==this._resourceID&&(this._resourceID=await(null===(s=this._application)||void 0===s?void 0:s.getResourceID()))),this.onDataUnitReady()}initContinuousInsertUtils(){this._application&&this._resourceID&&(this._continuousInsertUtils=new g(this._application,this._resourceID,this.configName),this.enableGridInsert&&this._continuousInsertUtils.getConfig().then((i=>this._enableContinuousInsert=i)))}async loadNumberingConfig(){if(!this.numberingConfig&&this._snkDataUnit&&this._snkDataUnit.entityName&&!this.disableNumberingConfig&&this._application){this._servicesNumberingConfig||(this._servicesNumberingConfig=new _(this._application,this._resourceID));try{this.numberingConfig=await this._servicesNumberingConfig.getConfig(this._snkDataUnit.entityName),this.getFieldAutoNum(),this.applyNumberingConfigToFields()}catch(i){console.error("Error loading numbering config in snk-crud:",i),this.numberingConfig={isAutoNumbering:!1,initialNumber:NaN}}}}getFieldAutoNum(){var i;if(this._fieldAutoNum)return;const t=null===(i=this._dataUnit)||void 0===i?void 0:i.metadata.fields.find((i=>{var t;return"true"===(null===(t=i.properties)||void 0===t?void 0:t.isAutoNumField)}));this._fieldAutoNum=(null==t?void 0:t.name)||null}async applyNumberingConfigToFields(){var i;if(!this.numberingConfig||!this._snkDataUnit||!this._fieldAutoNum)return;const t=null===(i=this._dataUnit)||void 0===i?void 0:i.getField(this._fieldAutoNum);t&&(t.readOnly=this.numberingConfig.isAutoNumbering,t.required=!this.numberingConfig.isAutoNumbering)}handleConfiguratorEvent(i,t){var s,e,n;if(i.stopImmediatePropagation(),"SAVE"===t)return null===(s=this._guidesViewer)||void 0===s||s.reloadGuides(),void(null===(e=this.configuratorSave)||void 0===e||e.emit());null===(n=this.configuratorCancel)||void 0===n||n.emit()}renderCustomGuideSlots(){if(this.customGuidesConfig)return this.customGuidesConfig.map((i=>s("slot",{name:i.id})))}getColumnSearch(i){return null!=this._columnSearch||(this._columnSearch=u(i,(({argument:i})=>new Promise((t=>{var s;null===(s=this._snkGrid)||void 0===s||s.filterColumns(i).then((i=>{t(i.filter((i=>!i.hidden)).map((i=>({label:i.label,value:i.name}))))}))}))),(i=>{var t;null!=i&&(null===(t=this._snkGrid)||void 0===t||t.locateColumn(i.value))}))),this._columnSearch}buildTaskbarCustomActionsList(){return[this.buildSearchColumnTaskbarAction()]}buildSearchColumnTaskbarAction(){var i,t;return{value:h.generateUUID(),label:null!==(t=null===(i=this.messagesBuilder)||void 0===i?void 0:i.getMessage("snkGrid.findColumn",{}))&&void 0!==t?t:"",disableCloseOnSelect:!0,eagerInitialize:!0,itemBuilder:(i,t)=>{var s;return null!==(s=this.getColumnSearch(t))&&void 0!==s?s:document.createElement("div")}}}isGridInsertActive(){var i;return this.enableGridInsert&&(null===(i=this._dataUnit)||void 0===i?void 0:i.hasNewRecord())}getActionsList(){var i,t;const s=[];if(this.enableGridInsert&&this._continuousInsertUtils&&s.push(this._continuousInsertUtils.actionContinuousInsert(this._enableContinuousInsert,(()=>{var i;this._enableContinuousInsert=!this._enableContinuousInsert,null===(i=this._continuousInsertUtils)||void 0===i||i.handleSaveConfig(this._enableContinuousInsert)}))),this.isGridInsertActive())return s;if(this._dataState&&this.actionsList&&null!=this.taskbarManager&&null!=this.taskbarManager.getMoreOptions){const t=b(this._dataState,this.presentationMode);return s.concat(this.taskbarManager.getMoreOptions(t,null!==(i=this.configName)&&void 0!==i?i:"",this._dataState,this.actionsList))}return s.concat(null!==(t=this.actionsList)&&void 0!==t?t:[])}async openSearchPopover(){var i;if(!this._popoverSearchEntity)return;const t=null===(i=this._element)||void 0===i?void 0:i.querySelector(`[data-taskbar-element="${y.ENTITY_SEARCH}"]`);await this._popoverSearchEntity.showUnder(t)}handleLoadedSearch(i){var t;1===i.detail.length&&(null===(t=this._dataUnit)||void 0===t||t.selectFirst(),this.gridToForm(!0))}renderDynamicSearch(){var i;if(this.showEntitySearch)return s("snk-entity-search",{ref:i=>this._popoverSearchEntity=i,dataUnit:this._dataUnit,entityName:null===(i=this._snkDataUnit)||void 0===i?void 0:i.entityName,messagesBuilder:this.messagesBuilder,onLoaded:i=>this.handleLoadedSearch(i)})}handleFilterConfigUpdated(i){i.length&&(1!==i.length||"PERSONALIZED_FILTER_GROUP"!==i[0].id||(this._filterMode=i[0].groupedItems.length>0?"regular":"button"))}render(){var i,t,n,o,a;if(null!=this._resourceID)return this._snkDataUnit&&(this._snkDataUnit.ignoreSaveMessage=this._currentViewMode===m.GRID&&!this.enableGridInsert),s(e,null,s("header",{class:{"snk-crud--hidden":!this._headerVisible,"snk-crud__header":!0}},s("div",{class:"snk-crud__header-top"},s("snk-taskbar",{"data-element-id":"grid_top",key:"snkGridTopTaskbar",configName:this.configName,dataUnit:this._dataUnit,messagesBuilder:this.messagesBuilder,buttons:this._taskbarProcessor.buttons,disabledButtons:this._taskbarProcessor.disabledButtons,customButtons:this._taskbarProcessor.customButtons,resourceID:this._resourceID,primaryButton:"INSERT",overflowStrategy:"hiddenItems",alignRigth:!0,actionsList:this.getActionsList(),customActionsList:this.buildTaskbarCustomActionsList(),sizeButtons:"medium"})),s("snk-filter-bar",{ref:i=>this._snkFilterBar=i,title:this.filterBarTitle,dataUnit:this._dataUnit,"data-element-id":"gridFilter",class:{"snk-grid__filter-bar":!0,"ez-align--top":!0,"snk-crud__filter-bar--hidden":this._currentViewMode!==m.GRID},configName:this.configName,messagesBuilder:this.messagesBuilder,resourceID:this._resourceID,onConfigUpdated:i=>this.handleFilterConfigUpdated(i.detail),disablePersonalizedFilter:this.disablePersonalizedFilter,filterBarLegacyConfigName:this.filterBarLegacyConfigName,autoLoad:this.autoLoad,enableLockManagerLoadingComp:this.enableLockManagerLoadingComp,mode:this._filterMode,hideFilterButton:!0,sizeChips:"default"})),s("ez-view-stack",{ref:i=>this._viewStack=i,"data-element-id":"crud"},s("stack-item",{class:"snk-crud__grid-stack-item"},s("snk-grid",{ref:i=>this._snkGrid=i,class:"ez-flex ez-flex--column ez-size-height--full ez-size-width--full",filterBarTitle:this.filterBarTitle,"data-element-id":"crud_grid",configName:this.configName,onGridDoubleClick:()=>this.gridToForm(!0),taskbarManager:this.taskbarManager,onActionClick:i=>this.executeAction(i.detail),messagesBuilder:this.messagesBuilder,actionsList:this.actionsList,statusResolver:this.statusResolver,multipleSelection:this.multipleSelection,presentationMode:this.presentationMode,recordsValidator:this.recordsValidator,selectionToastConfig:this.selectionToastConfig,useEnterLikeTab:this.useEnterLikeTab,canEdit:this._canEdit,resourceID:this._resourceID,disablePersonalizedFilter:this.disablePersonalizedFilter,gridLegacyConfigName:this.gridLegacyConfigName,filterBarLegacyConfigName:this.filterBarLegacyConfigName,autoLoad:this.autoLoad,autoFocus:this.autoFocus,enableGridInsert:this.enableGridInsert,enableLockManagerTaskbarClick:this.enableLockManagerTaskbarClick,enableLockManagerLoadingComp:this.enableLockManagerLoadingComp,strategyExporter:this.strategyExporter,multipleEditionEnabled:this.multipleEditionEnabled,paginationCounterMode:this.paginationCounterMode,hideHeader:!0,hideGridTaskbar:!0},s("slot",{name:"GRID_TASKBAR_CUSTOM_ELEMENTS"}),s("slot",{name:"GRID_HEADER_CUSTOM_ELEMENTS"}),s("slot",{name:"SnkGridHeader"}),s("slot",{name:"SnkGridFooter"}),s("slot",{name:"SnkGridTaskBar"}))),s("stack-item",null,s("snk-dynaform-guides-view",{ref:i=>this._guidesViewer=i,customGuidesConfig:this.customGuidesConfig,entityPath:null===(i=this._snkDataUnit)||void 0===i?void 0:i.entityName,messagesBuilder:this.messagesBuilder,onExit:()=>this.setViewMode(m.GRID),dataState:this._dataState,dataUnit:this._dataUnit,actionsList:this.actionsList,taskbarManager:this.taskbarManager,configName:this.configName,onActionClick:i=>this.executeAction(i.detail),presentationMode:this.presentationMode,"data-element-id":"crud_form",canEdit:this._canEdit,recordsValidator:this.recordsValidator,resourceID:this._resourceID,detailTaskbarCustomContainerId:this.customContainerId,formLegacyConfigName:this.formLegacyConfigName,enableGridInsert:this.enableGridInsert,getCustomTitle:this.setCustomFormTitle,ignoreReadOnlyFormFields:this.ignoreReadOnlyFormFields,onFormConfigVisibilityChanged:i=>this._headerVisible=!i.detail},s("slot",{name:"GUIDES_VIEWER_TASKBAR_CUSTOM_ELEMENTS"}),this.renderCustomGuideSlots(),s("slot",{name:"SnkFormTaskBar"})))),s("snk-attach",{ref:i=>this._snkAttach=i,registerKey:null!==(t=this.attachmentRegisterKey)&&void 0!==t?t:"",messagesBuilder:this.messagesBuilder,entityName:null!==(o=null===(n=this._snkDataUnit)||void 0===n?void 0:n.entityName)&&void 0!==o?o:""}),s("snk-configurator",{ref:i=>this._snkConfigurator=i,entityName:null===(a=this._snkDataUnit)||void 0===a?void 0:a.entityName,viewMode:this._currentViewMode,messagesBuilder:this.messagesBuilder,onConfigSelected:i=>this.setViewMode(i.detail),onOpenConfig:i=>this.openConfig(i.detail),showActionButtons:this.showActionButtons,onSave:i=>this.handleConfiguratorEvent(i,"SAVE"),onCancel:i=>this.handleConfiguratorEvent(i,"CANCEL"),resourceID:this._resourceID,customContainerId:this.customContainerId,layoutFormConfig:this.layoutFormConfig}),this.renderDynamicSearch(),s("div",{id:`${this.customContainerId}`},s("slot",{name:"SnkConfigContainerSlot"}),s("slot",{name:"DETAIL_GRID_HEADER_CUSTOM_ELEMENTS"}),s("slot",{name:"DETAIL_GRID_TASKBAR_CUSTOM_ELEMENTS"}),s("slot",{name:"DETAIL_TASKBAR_CUSTOM_ELEMENTS"})))}get _element(){return n(this)}static get watchers(){return{_currentViewMode:["currentViewModeWatcher"]}}};T.style=".sc-snk-dynaform-h{display:flex;flex-direction:column;height:100%;width:100%;overflow:hidden;scrollbar-gutter:stable both-edges}snk-grid.sc-snk-dynaform{--snk-grid-padding:0 var(--space--6, 6px) var(--space--6, 6px) var(--space--6, 6px)}ez-view-stack.sc-snk-dynaform{flex:1;min-height:0;display:flex;flex-direction:column;overflow:hidden}stack-item.sc-snk-dynaform.sc-snk-dynaform{display:flex;flex-direction:column;flex:1;min-height:0;overflow:hidden}stack-item.sc-snk-dynaform.sc-snk-dynaform>snk-dynaform-guides-view.sc-snk-dynaform{flex:1;min-height:0;display:flex;flex-direction:column;overflow:hidden}.snk-crud__grid-stack-item.sc-snk-dynaform{display:flex;flex-direction:column;height:100%;width:100%;padding:0 var(--space--2, 2px)}.snk-crud__header-top.sc-snk-dynaform{display:flex;justify-content:space-between;align-items:center;padding:var(--space--8, 8px);padding-top:var(--space--12, 12px)}.snk-crud--hidden.sc-snk-dynaform{display:none !important}.snk-crud__filter-bar--hidden.sc-snk-dynaform{display:none !important}snk-filter-bar.sc-snk-dynaform{padding-inline:var(--space--4, 4px)}ez-record-navigation.sc-snk-dynaform,ez-grid-pagination.sc-snk-dynaform{margin-bottom:var(--space--8, 8px)}";export{T as snk_dynaform}
@@ -1 +1 @@
1
- import{r as i,e,h as s,F as t,g as r}from"./p-2c9d0870.js";import{ObjectUtils as n,Action as a,KeyboardManager as d}from"@sankhyalabs/core";import{buildFieldSearch as o,SHORTCUT_SEARCH_FIELD as h}from"@sankhyalabs/ezui/dist/collection/utils";import{buildFormMetadata as l,FormMetadata as u}from"@sankhyalabs/ezui/dist/collection/utils/form";import{V as v}from"./p-9019a32f.js";import{S as c}from"./p-8d513b64.js";import{T as g}from"./p-3072136e.js";const m="__FORM:",f=class{constructor(s){i(this,s),this.snkShowGuide=e(this,"snkShowGuide",7),this.snkMasterFormConfigChange=e(this,"snkMasterFormConfigChange",7),this.formConfigVisibilityChanged=e(this,"formConfigVisibilityChanged",7),this.exit=e(this,"exit",7),this.actionClick=e(this,"actionClick",7),this.formItemsReady=e(this,"formItemsReady",7),this._guideBuilders=new Map,this.dataUnit=void 0,this.dataState=void 0,this.configName=void 0,this.entityPath=void 0,this.actionsList=void 0,this.recordsValidator=void 0,this.masterFormConfig=void 0,this.selectedGuide=void 0,this.taskbarManager=void 0,this.messagesBuilder=void 0,this.canEdit=!0,this.presentationMode=void 0,this.resourceID=void 0,this.detailTaskbarCustomContainerId=void 0,this.formLegacyConfigName=void 0,this.enableGridInsert=!1,this.ignoreReadOnlyFormFields=void 0,this.getCustomTitle=void 0,this.customGuidesConfig=[],this._hasToCreateFieldSearch=!0,this._breadcrumbItems=[],this._guides=void 0,this._formEditorConfigManager=void 0,this._formEditorDataUnit=void 0,this._fieldToGetFocus=void 0,this._customEditors=void 0,this._customRenders=void 0,this._fieldsProps={},this._mainForm=void 0}observeDataUnit(){this.loadGuides(!0)}async observeFormConfigManager(i){const e=!!i;await this._viewStack.show(e?k.CONFIG:k.GUIDES),this.formConfigVisibilityChanged.emit(e)}observeDataState(i,e){var s,t,r,a,d,o;const h=null!==(t=null===(s=null==i?void 0:i.selectionInfo)||void 0===s?void 0:s.recordIds)&&void 0!==t?t:null===(r=null==i?void 0:i.selectedRecord)||void 0===r?void 0:r.__record__id__,l=null!==(d=null===(a=null==e?void 0:e.selectionInfo)||void 0===a?void 0:a.recordIds)&&void 0!==d?d:null===(o=null==e?void 0:e.selectedRecord)||void 0===o?void 0:o.__record__id__;n.equals(h,l)||this.loadGuides((null==e?void 0:e.insertionMode)!=(null==i?void 0:i.insertionMode))}observeMasterFormConfig(){this.loadGuides(this.noGuideSelected()),this.snkMasterFormConfigChange.emit(this.masterFormConfig)}async showFormConfig(i=!1){const e=!i||null==this._currentDetail;this._formEditorConfigManager=e?this._configManager:this._currentDetail.formConfigManager,this._formEditorDataUnit=e?this.dataUnit:this._currentDetail.dataUnit}async addCustomEditor(i,e){this._customEditors=Object.assign(Object.assign({},this._customEditors),{[i]:e})}async addGridCustomRender(i,e){this._customRenders=Object.assign(Object.assign({},this._customRenders),{[i]:e})}async setFieldProp(i,e,s){const t={[i]:Object.assign(Object.assign({},this._fieldsProps[i]),{[e]:s})};this._fieldsProps=Object.assign(Object.assign({},this._fieldsProps),t)}async setFocus(){var i;null===(i=this._container)||void 0===i||i.focus({preventScroll:!0})}async reloadGuides(){this.loadGuides(!1)}exitViewer(){!this.enableGridInsert&&this.dataUnit.isDirty()?this.dataUnit.cancelEdition({after:()=>this.exit.emit()}):this.exit.emit()}onActionClick(i){i.detail===g.CONFIGURATOR&&"master"!=i.target.dataset.taskbarOwner&&(this._snkConfigurator.open(),i.stopImmediatePropagation(),i.stopPropagation())}onContentCardChanged(i){f.updateContentCard(i.detail.formName,i.detail.cardConfig,i.detail.propertyChanged,this._configManager).then((()=>this.masterFormConfig=this._configManager.getConfig(this.dataUnit)))}getMessage(i){var e,s;if(this.dataUnit.isMultipleEdition){const i=null!==(s=null===(e=this.dataUnit.getSelectionInfo())||void 0===e?void 0:e.records)&&void 0!==s?s:[];return this.messagesBuilder.getMessage("snkCrud.multipleEdition.editing",{COUNT:i.length})}return this.messagesBuilder.getMessage(i,this.dataUnit.getSelectedRecord())}loadGuides(i){if(!this.dataUnit)return;if(!this._configManager.isLoaded)return;this._masterFormMetadata=l(this.masterFormConfig,this.dataUnit,!0,this.customGuidesConfig);const e=this._masterFormMetadata.getAllSheets(),s=this.dataUnit.getSelectedRecord(),t=this.hasToDisableDetails(s),r=[];Array.from(e.values()).forEach((i=>{const e={id:i.name,label:i.label};this.isDetail(i.name)&&t&&(e.tooltip=this.getMessage("snkCrud.detail.tooltip.needSingleSelection"),e.disabled=!0),i.isCustom&&i.ctxProps&&Object.entries(i.ctxProps).forEach((([i,s])=>{void 0!==s&&(e[i]=s)})),r.push(e)})),this._guides=r,this._guideNavigator&&this._guideNavigator.updateItem(this._guides),i&&(this.selectedGuide=this._guides.length>0?this._guides[0]:void 0)}hasToDisableDetails(i){return!i||this.dataUnit.isNewRecord(i.__record__id__)||this.dataUnit.isMultipleEdition}isDetail(i){return null!=u.getDetailName(i)}updateGuide(i){this._guideBuilders.set(i.id,i);const e=i.buildGuideItem(this._guideBuilders);this._guideNavigator&&(this._guideNavigator.updateItem(e).then((()=>{this._guideNavigator.getCurrentPath().then((i=>{this._breadcrumbItems=i}))})),this._guides=this._guides.map((i=>i.id===e.id?Object.assign(Object.assign(Object.assign({},i),e),void 0!==e.children?{}:{children:void 0}):i)))}static updateContentCard(i,e,s,t){return t.saveCardState(i,e,s)}static buildFixedForms(i){var e;const r=null===(e=i.formConfig)||void 0===e?void 0:e.cardsState;if(null!=r)return s(t,null,Array.from(r.entries()).filter((([e,s])=>(null==s?void 0:s.fixed)&&e!=i.selectedForm)).sort((([,i],[,e])=>((null==i?void 0:i.fixSequence)||0)-((null==e?void 0:e.fixSequence)||0))).map((([e,t])=>{var r,n;const a=i.formMetadata.getSheet(e);if(null!=a)return s("snk-form-view",{levelPath:i.levelPath,label:a.label,name:e,fields:a.fields,formMetadata:i.formMetadata,dataUnit:i.dataUnit,recordsValidator:i.recordsValidator,contracted:"CONTRACTED"===(null==t?void 0:t.presentation),fixed:null==t?void 0:t.fixed,summaryFields:null===(n=null===(r=i.formConfig)||void 0===r?void 0:r.summary)||void 0===n?void 0:n.get(e),fieldToFocus:i.fieldToFocus,key:e,onSnkRequestClearFieldToFocus:()=>{var e;return null===(e=i.onRequestClearFieldToFocus)||void 0===e?void 0:e.call(i)},customEditors:i.propsCustomEditor,fieldsProps:i.fieldsProps,entityPath:i.entityPath})})))}wrapDetail(i,e){if(0===i.length)return e;const t=i.pop(),r=u.getDetailName(t);return r?this.wrapDetail(i,s("snk-data-unit",{dataUnitName:`${this.getDataUnitName(i,r)}`,entityName:r},e)):void 0}getDataUnitName(i,e){if(i.length>0){const s=i.map((i=>u.getDetailName(i)));return`${this.entityPath}/${s.join("/")}/${e}`}return`${this.entityPath}/${e}`}getContent(){if(!this.selectedGuide)return void this.snkShowGuide.emit(void 0);const i=this.selectedGuide.id;if(this.snkShowGuide.emit(i),this.isCustomGuide(i))return s("slot",{name:i});const e=i.split("::"),t=e.pop(),r=u.getDetailName(t);let n=i;return this.isDetailGuide(r,e)?this.buildDetailGuideContent(i,n,e,r):this.buildFormViewGuideContent(i)}buildFormViewGuideContent(i){var e,t,r,n;const a=this._masterFormMetadata.getSheet(i);if(!a)return;const d=null===(t=null===(e=this.masterFormConfig)||void 0===e?void 0:e.cardsState)||void 0===t?void 0:t.get(i);return s("snk-form-view",{ref:i=>this._mainForm=i,fixed:null==d?void 0:d.fixed,summaryFields:null===(n=null===(r=this.masterFormConfig)||void 0===r?void 0:r.summary)||void 0===n?void 0:n.get(i),name:i,label:a.label,fields:a.fields,dataUnit:this.dataUnit,formMetadata:this._masterFormMetadata,recordsValidator:this.recordsValidator,fieldToFocus:this._fieldToGetFocus,key:i,onSnkRequestClearFieldToFocus:()=>this.clearFieldToFocusHandler(),customEditors:this._customEditors,fieldsProps:this._fieldsProps,fieldSearch:this._fieldSearch,entityPath:this.entityPath})}isDetailGuide(i,e){return i||e.length>0}buildDetailGuideContent(i,e,t,r){var n;let a,d;if(i.includes(m)){[e,a]=i.split(m);const s=(null===(n=this._breadcrumbItems)||void 0===n?void 0:n.length)||0;d=s>1?this._breadcrumbItems[s-2]:this.selectedGuide}else d=this.selectedGuide;return this.wrapDetail(t,s("snk-detail-view",{ref:i=>this._currentDetail=i,dataUnitName:this.getDataUnitName(t,r),onSnkDetailGuidesChange:i=>this.updateGuide(i.detail),entityName:r,selectedForm:a,branchGuide:d,guideItemPath:this._breadcrumbItems,key:`detail${e}`,canEdit:this.canEdit,onSnkSwitchGuide:i=>this._guideNavigator.selectGuide(i.detail),resourceID:this.resourceID,taskbarCustomContainerId:this.detailTaskbarCustomContainerId,customEditors:this._customEditors,customRenders:this._customRenders,presentationMode:this.presentationMode}))}isCustomGuide(i){var e;return null===(e=this.customGuidesConfig)||void 0===e?void 0:e.map((i=>i.id)).includes(i)}updateSelectedGuideHandler(i){this._guideHasChanged=this.selectedGuide!=i,this.selectedGuide=i,this._guideNavigator.getCurrentPath().then((i=>{this._breadcrumbItems=i})),this.resetGuideBadge(i)}clearFieldToFocusHandler(){this._fieldToGetFocus=void 0}resetGuideBadge(i){var e;i&&(this._guides=[...null===(e=this._guides)||void 0===e?void 0:e.map((e=>this.canClearGuideBadge(e,i.id)?Object.assign(Object.assign({},e),{badge:null}):e))])}canClearGuideBadge(i,e){return i.id===e||this.isIncludedInChildrenList(i,e)}isIncludedInChildrenList(i,e){return this.hasChildren(i)&&this.getChildrenIdList(i).includes(e)}hasChildren(i){return i.children&&Array.isArray(i.children)}getChildrenIdList(i){return i.children.map((i=>i.id))}getConfigViewMode(){return v.GRID}changeConfigViewMode(i){this._currentDetail&&this._currentDetail.changeViewMode(i)}openConfig(i){this._snkConfigurator.close(),this._currentDetail&&(i===v.FORM?this.showFormConfig(!0):this._currentDetail.configGrid())}noGuideSelected(){var i;return void 0===this.selectedGuide||"__main"===(null===(i=this.selectedGuide)||void 0===i?void 0:i.id)}addFormLegacyConfigName(){this.formLegacyConfigName&&this._configManager.addFormLegacyConfig(this.formLegacyConfigName)}setMasterFormConfig(i){this.masterFormConfig=i}componentWillLoad(){if(null==this.resourceID)throw new Error(this.getMessage("snkCrud.errors.resourceIDNotProvided"));this._configManager=new c(this.configName,this.resourceID,this.setMasterFormConfig.bind(this),this.dataUnit),this.addFormLegacyConfigName(),this._configManager.loadConfig()}componentDidRender(){this._guideHasChanged&&(window.scrollTo(0,0),this._guideHasChanged=!1)}async dataUnitActionHandler(i){var e;switch(i.type){case a.EDITION_CANCELED:case a.DATA_SAVED:this.dataUnit.isMultipleEdition&&(this.exitViewer(),this.dataUnit.isMultipleEdition=!1);break;case a.FIELD_INVALIDATED:const s=this.getGuideName(null===(e=i.payload)||void 0===e?void 0:e.fieldName);await this.addErrorBadgeToGuide(s),await this.openGuideNavigator(s);break;case a.METADATA_LOADED:case a.MULTIPLE_EDITION_CHANGED:this.loadGuides(this.noGuideSelected())}}async addErrorBadgeToGuide(i){var e;this._guides=[...null===(e=this._guides)||void 0===e?void 0:e.map((e=>Object.assign(Object.assign({},e),{badge:this.getBadge(e,i)})))]}async openGuideNavigator(i){this.selectedGuide.id!==i&&await this._guideNavigator.openGuideNavidator()}getBadge(i,e){var s;return this.selectedGuide.id===e?null:e===i.id?"error":null!==(s=i.badge)&&void 0!==s?s:null}getGuideName(i){var e;for(const s of this._masterFormMetadata.getAllSheets()){const t=null===(e=s[1])||void 0===e?void 0:e.fields;for(const e of t)if(e.name===i)return s[0]}return""}getCustomGuidesConfig(){return this._currentDetail?[]:this.customGuidesConfig}getFieldsSearch(){if(null==this._fieldSearch||this._hasToCreateFieldSearch){this._hasToCreateFieldSearch=!1;const i={label:this.getMessage("snkSimpleCrud.findFields"),value:"findFields"};this._fieldSearch=o(i,(({argument:i})=>this.fieldsOptionLoader(i)),(i=>this.onSelectField(i)))}return this._fieldSearch}fieldsOptionLoader(i){return Promise.resolve(this._configManager.getFieldsList(i).map((i=>({value:i.name,label:i.label}))))}changeGuideHandler(i){var e;null===(e=this._guideNavigator)||void 0===e||e.selectGuide(i)}onSelectField(i){if(null==i)return;this._fieldToGetFocus=i.value;const e=this.getGuideName(i.value);e!==this.selectedGuide.id&&this.changeGuideHandler(e)}componentDidLoad(){this.dataUnit.subscribe(this.dataUnitActionHandler.bind(this)),this.initKeyboardManager(),this.getFieldsSearch()}disconnectedCallback(){var i;null===(i=this._keyboardManager)||void 0===i||i.unbindAllShortcutKeys()}async initKeyboardManager(){this._keyboardManager=new d({propagate:!1,element:this._element}),this._keyboardManager.bind(h,(async()=>{this._mainForm&&await this._mainForm.showSearchField()}),{description:this.getMessage("snkSimpleCrud.findFields"),element:this._element})}renderFormConfig(){if(null!=this._formEditorConfigManager)return s("snk-form-config",{ref:i=>this._container=i,tabindex:-1,dataUnit:this._formEditorDataUnit,messagesBuilder:this.messagesBuilder,configManager:this._formEditorConfigManager,onConfigClose:()=>this._formEditorConfigManager=null,customGuidesConfig:this.getCustomGuidesConfig()})}renderGuidesNavigator(i){var e;return s("section",{class:"snk-guides-viewer",ref:i=>this._container=i,tabIndex:-1},s("div",{class:"snk-guides-viewer__container"},i?s("ez-guide-navigator",{ref:i=>this._guideNavigator=i,class:"snk-guides-viewer__guide-navigator",items:this._guides,selectedId:this.selectedGuide?this.selectedGuide.id:void 0,onEzSelectionChange:i=>this.updateSelectedGuideHandler(i.detail)}):s("div",null),s("div",{class:"snk-guides-viewer__detail-container"},f.buildFixedForms({formConfig:this.masterFormConfig,formMetadata:this._masterFormMetadata,selectedForm:null===(e=this.selectedGuide)||void 0===e?void 0:e.id,dataUnit:this.dataUnit,recordsValidator:this.recordsValidator,fieldToFocus:this._fieldToGetFocus,onRequestClearFieldToFocus:this.clearFieldToFocusHandler.bind(this),propsCustomEditor:this._customEditors,fieldsProps:this._fieldsProps,entityPath:this.entityPath}),this.getContent())),s("snk-configurator",{ref:i=>this._snkConfigurator=i,viewMode:this.getConfigViewMode(),onConfigSelected:i=>this.changeConfigViewMode(i.detail),messagesBuilder:this.messagesBuilder,onOpenConfig:i=>this.openConfig(i.detail),resourceID:this.resourceID,layoutFormConfig:!1,disableNumberingConfig:!0}))}render(){if(this.dataUnit&&this._configManager.isLoaded)return s("ez-view-stack",{ref:i=>this._viewStack=i,"data-element-id":"guides-viewer-stack"},s("stack-item",null,this.renderGuidesNavigator(this._guides&&this._guides.length>1)),s("stack-item",null,this.renderFormConfig()))}get _element(){return r(this)}static get watchers(){return{dataUnit:["observeDataUnit"],_formEditorConfigManager:["observeFormConfigManager"],dataState:["observeDataState"],masterFormConfig:["observeMasterFormConfig"]}}};var k;!function(i){i[i.GUIDES=0]="GUIDES",i[i.CONFIG=1]="CONFIG"}(k||(k={})),f.style=".sc-snk-guides-viewer-h{--snk-guides-viewer--space-large:var(--space--large, 24px);--snk-guides-viewer--space-small:var(--space--2xs, 8px);--snk-guides-viewer__header--min-height:132px;--snk-guides-viewer__header--z-index:var(--more-visible, 2);--snk-guides-viewer__header--background-color:var(--background--body, #fafcff);--snk-guides-viewer__guide-navigator--width:340px;--snk-workspace--header-height:40px;display:block;outline:none}ez-guide-navigator.sc-snk-guides-viewer{--ez-guide-navigator--border-radius:var(--space--12, 12px)}snk-form-view.sc-snk-guides-viewer{width:100%}stack-item.snk-guides-viewer.sc-snk-guides-viewer{display:grid}stack-item.sc-snk-guides-viewer.sc-snk-guides-viewer{display:grid;min-height:100%}.snk-guides-viewer.sc-snk-guides-viewer{position:relative;padding:0 var(--snk-guides-viewer--space-small);padding-bottom:var(--snk-guides-viewer--space-small)}.snk-guides-viewer__detail-container.sc-snk-guides-viewer{display:flex;row-gap:24px;flex-direction:column;max-height:calc(100vh - var(--snk-guides-viewer__header--min-height));overflow-y:auto}.snk-guides-viewer__header.sc-snk-guides-viewer{position:sticky;align-items:center;top:0;z-index:var(--snk-guides-viewer__header--z-index);background-color:var(--snk-guides-viewer__header--background-color);min-height:var(--snk-guides-viewer__header--min-height);width:calc(100% + (var(--snk-guides-viewer--space-large) * 2));padding-left:var(--snk-guides-viewer--space-large);padding-right:var(--snk-guides-viewer--space-large);padding-top:var(--snk-guides-viewer--space-large);padding-bottom:var(--snk-guides-viewer--space-small);margin-left:calc(var(--snk-guides-viewer--space-large) * -1);margin-right:calc(var(--snk-guides-viewer--space-large) * -1);margin-bottom:var(--snk-guides-viewer--space-small)}.snk-guides-viewer__header-breadcrumb.sc-snk-guides-viewer{width:25%;display:flex}.snk-guides-viewer__header-taskbar.sc-snk-guides-viewer{width:75%}.snk-guides-viewer__container.sc-snk-guides-viewer{display:grid;grid-template-columns:minmax(0, auto) minmax(0, 100%);height:100%;column-gap:var(--snk-guides-viewer--space-small)}.snk-guides-viewer__guide-navigator.sc-snk-guides-viewer{position:sticky;top:var(--snk-guides-viewer--space-small);height:calc(100vh - var(--snk-guides-viewer__header--min-height))}.snk-guides-viewer__guide-navigator[open].sc-snk-guides-viewer{width:var(--snk-guides-viewer__guide-navigator--width);max-width:var(--snk-guides-viewer__guide-navigator--width);min-width:var(--snk-guides-viewer__guide-navigator--width)}.snk-guides-viewer__detail-content.sc-snk-guides-viewer{min-height:100%;align-items:flex-start;align-content:flex-start}";export{f as S}
1
+ import{r as i,e,h as s,F as t,g as r}from"./p-2c9d0870.js";import{ObjectUtils as n,Action as a,KeyboardManager as d}from"@sankhyalabs/core";import{buildFieldSearch as o,SHORTCUT_SEARCH_FIELD as h}from"@sankhyalabs/ezui/dist/collection/utils";import{buildFormMetadata as l,FormMetadata as u}from"@sankhyalabs/ezui/dist/collection/utils/form";import{V as v}from"./p-9019a32f.js";import{S as c}from"./p-c9440c8a.js";import{T as g}from"./p-2ec98523.js";const m="__FORM:",f=class{constructor(s){i(this,s),this.snkShowGuide=e(this,"snkShowGuide",7),this.snkMasterFormConfigChange=e(this,"snkMasterFormConfigChange",7),this.formConfigVisibilityChanged=e(this,"formConfigVisibilityChanged",7),this.exit=e(this,"exit",7),this.actionClick=e(this,"actionClick",7),this.formItemsReady=e(this,"formItemsReady",7),this._guideBuilders=new Map,this.dataUnit=void 0,this.dataState=void 0,this.configName=void 0,this.entityPath=void 0,this.actionsList=void 0,this.recordsValidator=void 0,this.masterFormConfig=void 0,this.selectedGuide=void 0,this.taskbarManager=void 0,this.messagesBuilder=void 0,this.canEdit=!0,this.presentationMode=void 0,this.resourceID=void 0,this.detailTaskbarCustomContainerId=void 0,this.formLegacyConfigName=void 0,this.enableGridInsert=!1,this.ignoreReadOnlyFormFields=void 0,this.getCustomTitle=void 0,this.customGuidesConfig=[],this._hasToCreateFieldSearch=!0,this._breadcrumbItems=[],this._guides=void 0,this._formEditorConfigManager=void 0,this._formEditorDataUnit=void 0,this._fieldToGetFocus=void 0,this._customEditors=void 0,this._customRenders=void 0,this._fieldsProps={},this._mainForm=void 0}observeDataUnit(){this.loadGuides(!0)}async observeFormConfigManager(i){const e=!!i;await this._viewStack.show(e?k.CONFIG:k.GUIDES),this.formConfigVisibilityChanged.emit(e)}observeDataState(i,e){var s,t,r,a,d,o;const h=null!==(t=null===(s=null==i?void 0:i.selectionInfo)||void 0===s?void 0:s.recordIds)&&void 0!==t?t:null===(r=null==i?void 0:i.selectedRecord)||void 0===r?void 0:r.__record__id__,l=null!==(d=null===(a=null==e?void 0:e.selectionInfo)||void 0===a?void 0:a.recordIds)&&void 0!==d?d:null===(o=null==e?void 0:e.selectedRecord)||void 0===o?void 0:o.__record__id__;n.equals(h,l)||this.loadGuides((null==e?void 0:e.insertionMode)!=(null==i?void 0:i.insertionMode))}observeMasterFormConfig(){this.loadGuides(this.noGuideSelected()),this.snkMasterFormConfigChange.emit(this.masterFormConfig)}async showFormConfig(i=!1){const e=!i||null==this._currentDetail;this._formEditorConfigManager=e?this._configManager:this._currentDetail.formConfigManager,this._formEditorDataUnit=e?this.dataUnit:this._currentDetail.dataUnit}async addCustomEditor(i,e){this._customEditors=Object.assign(Object.assign({},this._customEditors),{[i]:e})}async addGridCustomRender(i,e){this._customRenders=Object.assign(Object.assign({},this._customRenders),{[i]:e})}async setFieldProp(i,e,s){const t={[i]:Object.assign(Object.assign({},this._fieldsProps[i]),{[e]:s})};this._fieldsProps=Object.assign(Object.assign({},this._fieldsProps),t)}async setFocus(){var i;null===(i=this._container)||void 0===i||i.focus({preventScroll:!0})}async reloadGuides(){this.loadGuides(!1)}exitViewer(){!this.enableGridInsert&&this.dataUnit.isDirty()?this.dataUnit.cancelEdition({after:()=>this.exit.emit()}):this.exit.emit()}onActionClick(i){i.detail===g.CONFIGURATOR&&"master"!=i.target.dataset.taskbarOwner&&(this._snkConfigurator.open(),i.stopImmediatePropagation(),i.stopPropagation())}onContentCardChanged(i){f.updateContentCard(i.detail.formName,i.detail.cardConfig,i.detail.propertyChanged,this._configManager).then((()=>this.masterFormConfig=this._configManager.getConfig(this.dataUnit)))}getMessage(i){var e,s;if(this.dataUnit.isMultipleEdition){const i=null!==(s=null===(e=this.dataUnit.getSelectionInfo())||void 0===e?void 0:e.records)&&void 0!==s?s:[];return this.messagesBuilder.getMessage("snkCrud.multipleEdition.editing",{COUNT:i.length})}return this.messagesBuilder.getMessage(i,this.dataUnit.getSelectedRecord())}loadGuides(i){if(!this.dataUnit)return;if(!this._configManager.isLoaded)return;this._masterFormMetadata=l(this.masterFormConfig,this.dataUnit,!0,this.customGuidesConfig);const e=this._masterFormMetadata.getAllSheets(),s=this.dataUnit.getSelectedRecord(),t=this.hasToDisableDetails(s),r=[];Array.from(e.values()).forEach((i=>{const e={id:i.name,label:i.label};this.isDetail(i.name)&&t&&(e.tooltip=this.getMessage("snkCrud.detail.tooltip.needSingleSelection"),e.disabled=!0),i.isCustom&&i.ctxProps&&Object.entries(i.ctxProps).forEach((([i,s])=>{void 0!==s&&(e[i]=s)})),r.push(e)})),this._guides=r,this._guideNavigator&&this._guideNavigator.updateItem(this._guides),i&&(this.selectedGuide=this._guides.length>0?this._guides[0]:void 0)}hasToDisableDetails(i){return!i||this.dataUnit.isNewRecord(i.__record__id__)||this.dataUnit.isMultipleEdition}isDetail(i){return null!=u.getDetailName(i)}updateGuide(i){this._guideBuilders.set(i.id,i);const e=i.buildGuideItem(this._guideBuilders);this._guideNavigator&&(this._guideNavigator.updateItem(e).then((()=>{this._guideNavigator.getCurrentPath().then((i=>{this._breadcrumbItems=i}))})),this._guides=this._guides.map((i=>i.id===e.id?Object.assign(Object.assign(Object.assign({},i),e),void 0!==e.children?{}:{children:void 0}):i)))}static updateContentCard(i,e,s,t){return t.saveCardState(i,e,s)}static buildFixedForms(i){var e;const r=null===(e=i.formConfig)||void 0===e?void 0:e.cardsState;if(null!=r)return s(t,null,Array.from(r.entries()).filter((([e,s])=>(null==s?void 0:s.fixed)&&e!=i.selectedForm)).sort((([,i],[,e])=>((null==i?void 0:i.fixSequence)||0)-((null==e?void 0:e.fixSequence)||0))).map((([e,t])=>{var r,n;const a=i.formMetadata.getSheet(e);if(null!=a)return s("snk-form-view",{levelPath:i.levelPath,label:a.label,name:e,fields:a.fields,formMetadata:i.formMetadata,dataUnit:i.dataUnit,recordsValidator:i.recordsValidator,contracted:"CONTRACTED"===(null==t?void 0:t.presentation),fixed:null==t?void 0:t.fixed,summaryFields:null===(n=null===(r=i.formConfig)||void 0===r?void 0:r.summary)||void 0===n?void 0:n.get(e),fieldToFocus:i.fieldToFocus,key:e,onSnkRequestClearFieldToFocus:()=>{var e;return null===(e=i.onRequestClearFieldToFocus)||void 0===e?void 0:e.call(i)},customEditors:i.propsCustomEditor,fieldsProps:i.fieldsProps,entityPath:i.entityPath})})))}wrapDetail(i,e){if(0===i.length)return e;const t=i.pop(),r=u.getDetailName(t);return r?this.wrapDetail(i,s("snk-data-unit",{dataUnitName:`${this.getDataUnitName(i,r)}`,entityName:r},e)):void 0}getDataUnitName(i,e){if(i.length>0){const s=i.map((i=>u.getDetailName(i)));return`${this.entityPath}/${s.join("/")}/${e}`}return`${this.entityPath}/${e}`}getContent(){if(!this.selectedGuide)return void this.snkShowGuide.emit(void 0);const i=this.selectedGuide.id;if(this.snkShowGuide.emit(i),this.isCustomGuide(i))return s("slot",{name:i});const e=i.split("::"),t=e.pop(),r=u.getDetailName(t);let n=i;return this.isDetailGuide(r,e)?this.buildDetailGuideContent(i,n,e,r):this.buildFormViewGuideContent(i)}buildFormViewGuideContent(i){var e,t,r,n;const a=this._masterFormMetadata.getSheet(i);if(!a)return;const d=null===(t=null===(e=this.masterFormConfig)||void 0===e?void 0:e.cardsState)||void 0===t?void 0:t.get(i);return s("snk-form-view",{ref:i=>this._mainForm=i,fixed:null==d?void 0:d.fixed,summaryFields:null===(n=null===(r=this.masterFormConfig)||void 0===r?void 0:r.summary)||void 0===n?void 0:n.get(i),name:i,label:a.label,fields:a.fields,dataUnit:this.dataUnit,formMetadata:this._masterFormMetadata,recordsValidator:this.recordsValidator,fieldToFocus:this._fieldToGetFocus,key:i,onSnkRequestClearFieldToFocus:()=>this.clearFieldToFocusHandler(),customEditors:this._customEditors,fieldsProps:this._fieldsProps,fieldSearch:this._fieldSearch,entityPath:this.entityPath})}isDetailGuide(i,e){return i||e.length>0}buildDetailGuideContent(i,e,t,r){var n;let a,d;if(i.includes(m)){[e,a]=i.split(m);const s=(null===(n=this._breadcrumbItems)||void 0===n?void 0:n.length)||0;d=s>1?this._breadcrumbItems[s-2]:this.selectedGuide}else d=this.selectedGuide;return this.wrapDetail(t,s("snk-detail-view",{ref:i=>this._currentDetail=i,dataUnitName:this.getDataUnitName(t,r),onSnkDetailGuidesChange:i=>this.updateGuide(i.detail),entityName:r,selectedForm:a,branchGuide:d,guideItemPath:this._breadcrumbItems,key:`detail${e}`,canEdit:this.canEdit,onSnkSwitchGuide:i=>this._guideNavigator.selectGuide(i.detail),resourceID:this.resourceID,taskbarCustomContainerId:this.detailTaskbarCustomContainerId,customEditors:this._customEditors,customRenders:this._customRenders,presentationMode:this.presentationMode}))}isCustomGuide(i){var e;return null===(e=this.customGuidesConfig)||void 0===e?void 0:e.map((i=>i.id)).includes(i)}updateSelectedGuideHandler(i){this._guideHasChanged=this.selectedGuide!=i,this.selectedGuide=i,this._guideNavigator.getCurrentPath().then((i=>{this._breadcrumbItems=i})),this.resetGuideBadge(i)}clearFieldToFocusHandler(){this._fieldToGetFocus=void 0}resetGuideBadge(i){var e;i&&(this._guides=[...null===(e=this._guides)||void 0===e?void 0:e.map((e=>this.canClearGuideBadge(e,i.id)?Object.assign(Object.assign({},e),{badge:null}):e))])}canClearGuideBadge(i,e){return i.id===e||this.isIncludedInChildrenList(i,e)}isIncludedInChildrenList(i,e){return this.hasChildren(i)&&this.getChildrenIdList(i).includes(e)}hasChildren(i){return i.children&&Array.isArray(i.children)}getChildrenIdList(i){return i.children.map((i=>i.id))}getConfigViewMode(){return v.GRID}changeConfigViewMode(i){this._currentDetail&&this._currentDetail.changeViewMode(i)}openConfig(i){this._snkConfigurator.close(),this._currentDetail&&(i===v.FORM?this.showFormConfig(!0):this._currentDetail.configGrid())}noGuideSelected(){var i;return void 0===this.selectedGuide||"__main"===(null===(i=this.selectedGuide)||void 0===i?void 0:i.id)}addFormLegacyConfigName(){this.formLegacyConfigName&&this._configManager.addFormLegacyConfig(this.formLegacyConfigName)}setMasterFormConfig(i){this.masterFormConfig=i}componentWillLoad(){if(null==this.resourceID)throw new Error(this.getMessage("snkCrud.errors.resourceIDNotProvided"));this._configManager=new c(this.configName,this.resourceID,this.setMasterFormConfig.bind(this),this.dataUnit),this.addFormLegacyConfigName(),this._configManager.loadConfig()}componentDidRender(){this._guideHasChanged&&(window.scrollTo(0,0),this._guideHasChanged=!1)}async dataUnitActionHandler(i){var e;switch(i.type){case a.EDITION_CANCELED:case a.DATA_SAVED:this.dataUnit.isMultipleEdition&&(this.exitViewer(),this.dataUnit.isMultipleEdition=!1);break;case a.FIELD_INVALIDATED:const s=this.getGuideName(null===(e=i.payload)||void 0===e?void 0:e.fieldName);await this.addErrorBadgeToGuide(s),await this.openGuideNavigator(s);break;case a.METADATA_LOADED:case a.MULTIPLE_EDITION_CHANGED:this.loadGuides(this.noGuideSelected())}}async addErrorBadgeToGuide(i){var e;this._guides=[...null===(e=this._guides)||void 0===e?void 0:e.map((e=>Object.assign(Object.assign({},e),{badge:this.getBadge(e,i)})))]}async openGuideNavigator(i){this.selectedGuide.id!==i&&await this._guideNavigator.openGuideNavidator()}getBadge(i,e){var s;return this.selectedGuide.id===e?null:e===i.id?"error":null!==(s=i.badge)&&void 0!==s?s:null}getGuideName(i){var e;for(const s of this._masterFormMetadata.getAllSheets()){const t=null===(e=s[1])||void 0===e?void 0:e.fields;for(const e of t)if(e.name===i)return s[0]}return""}getCustomGuidesConfig(){return this._currentDetail?[]:this.customGuidesConfig}getFieldsSearch(){if(null==this._fieldSearch||this._hasToCreateFieldSearch){this._hasToCreateFieldSearch=!1;const i={label:this.getMessage("snkSimpleCrud.findFields"),value:"findFields"};this._fieldSearch=o(i,(({argument:i})=>this.fieldsOptionLoader(i)),(i=>this.onSelectField(i)))}return this._fieldSearch}fieldsOptionLoader(i){return Promise.resolve(this._configManager.getFieldsList(i).map((i=>({value:i.name,label:i.label}))))}changeGuideHandler(i){var e;null===(e=this._guideNavigator)||void 0===e||e.selectGuide(i)}onSelectField(i){if(null==i)return;this._fieldToGetFocus=i.value;const e=this.getGuideName(i.value);e!==this.selectedGuide.id&&this.changeGuideHandler(e)}componentDidLoad(){this.dataUnit.subscribe(this.dataUnitActionHandler.bind(this)),this.initKeyboardManager(),this.getFieldsSearch()}disconnectedCallback(){var i;null===(i=this._keyboardManager)||void 0===i||i.unbindAllShortcutKeys()}async initKeyboardManager(){this._keyboardManager=new d({propagate:!1,element:this._element}),this._keyboardManager.bind(h,(async()=>{this._mainForm&&await this._mainForm.showSearchField()}),{description:this.getMessage("snkSimpleCrud.findFields"),element:this._element})}renderFormConfig(){if(null!=this._formEditorConfigManager)return s("snk-form-config",{ref:i=>this._container=i,tabindex:-1,dataUnit:this._formEditorDataUnit,messagesBuilder:this.messagesBuilder,configManager:this._formEditorConfigManager,onConfigClose:()=>this._formEditorConfigManager=null,customGuidesConfig:this.getCustomGuidesConfig()})}renderGuidesNavigator(i){var e;return s("section",{class:"snk-guides-viewer",ref:i=>this._container=i,tabIndex:-1},s("div",{class:"snk-guides-viewer__container"},i?s("ez-guide-navigator",{ref:i=>this._guideNavigator=i,class:"snk-guides-viewer__guide-navigator",items:this._guides,selectedId:this.selectedGuide?this.selectedGuide.id:void 0,onEzSelectionChange:i=>this.updateSelectedGuideHandler(i.detail)}):s("div",null),s("div",{class:"snk-guides-viewer__detail-container"},f.buildFixedForms({formConfig:this.masterFormConfig,formMetadata:this._masterFormMetadata,selectedForm:null===(e=this.selectedGuide)||void 0===e?void 0:e.id,dataUnit:this.dataUnit,recordsValidator:this.recordsValidator,fieldToFocus:this._fieldToGetFocus,onRequestClearFieldToFocus:this.clearFieldToFocusHandler.bind(this),propsCustomEditor:this._customEditors,fieldsProps:this._fieldsProps,entityPath:this.entityPath}),this.getContent())),s("snk-configurator",{ref:i=>this._snkConfigurator=i,viewMode:this.getConfigViewMode(),onConfigSelected:i=>this.changeConfigViewMode(i.detail),messagesBuilder:this.messagesBuilder,onOpenConfig:i=>this.openConfig(i.detail),resourceID:this.resourceID,layoutFormConfig:!1,disableNumberingConfig:!0}))}render(){if(this.dataUnit&&this._configManager.isLoaded)return s("ez-view-stack",{ref:i=>this._viewStack=i,"data-element-id":"guides-viewer-stack"},s("stack-item",null,this.renderGuidesNavigator(this._guides&&this._guides.length>1)),s("stack-item",null,this.renderFormConfig()))}get _element(){return r(this)}static get watchers(){return{dataUnit:["observeDataUnit"],_formEditorConfigManager:["observeFormConfigManager"],dataState:["observeDataState"],masterFormConfig:["observeMasterFormConfig"]}}};var k;!function(i){i[i.GUIDES=0]="GUIDES",i[i.CONFIG=1]="CONFIG"}(k||(k={})),f.style=".sc-snk-guides-viewer-h{--snk-guides-viewer--space-large:var(--space--large, 24px);--snk-guides-viewer--space-small:var(--space--2xs, 8px);--snk-guides-viewer__header--min-height:132px;--snk-guides-viewer__header--z-index:var(--more-visible, 2);--snk-guides-viewer__header--background-color:var(--background--body, #fafcff);--snk-guides-viewer__guide-navigator--width:340px;--snk-workspace--header-height:40px;display:block;outline:none}ez-guide-navigator.sc-snk-guides-viewer{--ez-guide-navigator--border-radius:var(--space--12, 12px)}snk-form-view.sc-snk-guides-viewer{width:100%}stack-item.snk-guides-viewer.sc-snk-guides-viewer{display:grid}stack-item.sc-snk-guides-viewer.sc-snk-guides-viewer{display:grid;min-height:100%}.snk-guides-viewer.sc-snk-guides-viewer{position:relative;padding:0 var(--snk-guides-viewer--space-small);padding-bottom:var(--snk-guides-viewer--space-small)}.snk-guides-viewer__detail-container.sc-snk-guides-viewer{display:flex;row-gap:24px;flex-direction:column;max-height:calc(100vh - var(--snk-guides-viewer__header--min-height));overflow-y:auto}.snk-guides-viewer__header.sc-snk-guides-viewer{position:sticky;align-items:center;top:0;z-index:var(--snk-guides-viewer__header--z-index);background-color:var(--snk-guides-viewer__header--background-color);min-height:var(--snk-guides-viewer__header--min-height);width:calc(100% + (var(--snk-guides-viewer--space-large) * 2));padding-left:var(--snk-guides-viewer--space-large);padding-right:var(--snk-guides-viewer--space-large);padding-top:var(--snk-guides-viewer--space-large);padding-bottom:var(--snk-guides-viewer--space-small);margin-left:calc(var(--snk-guides-viewer--space-large) * -1);margin-right:calc(var(--snk-guides-viewer--space-large) * -1);margin-bottom:var(--snk-guides-viewer--space-small)}.snk-guides-viewer__header-breadcrumb.sc-snk-guides-viewer{width:25%;display:flex}.snk-guides-viewer__header-taskbar.sc-snk-guides-viewer{width:75%}.snk-guides-viewer__container.sc-snk-guides-viewer{display:grid;grid-template-columns:minmax(0, auto) minmax(0, 100%);height:100%;column-gap:var(--snk-guides-viewer--space-small)}.snk-guides-viewer__guide-navigator.sc-snk-guides-viewer{position:sticky;top:var(--snk-guides-viewer--space-small);height:calc(100vh - var(--snk-guides-viewer__header--min-height))}.snk-guides-viewer__guide-navigator[open].sc-snk-guides-viewer{width:var(--snk-guides-viewer__guide-navigator--width);max-width:var(--snk-guides-viewer__guide-navigator--width);min-width:var(--snk-guides-viewer__guide-navigator--width)}.snk-guides-viewer__detail-content.sc-snk-guides-viewer{min-height:100%;align-items:flex-start;align-content:flex-start}";export{f as S}
@@ -0,0 +1 @@
1
+ import{ObjectUtils as t}from"@sankhyalabs/core";import{R as a}from"./p-ec7c87bb.js";class e extends a{getData(a){const e=`cfg://auth/${a}`;return new Promise(((a,s)=>{this.loadResource(e).then((e=>{let s=t.stringToObject(e);s&&"object"==typeof s&&a(s)})).catch((t=>{s(t)}))}))}}var s;!function(t){t.INSERT="I",t.UPDATE="A",t.REMOVE="E",t.SHOW="C",t.CONFIG="F",t.CONFIG_NUMBER="N",t.CLONE="D",t.CONFIG_GRID="G"}(s||(s={}));export{s as A,e as a}
@@ -1 +1 @@
1
- import{r as t,e as i,i as s,h as e,f as a,g as o}from"./p-2c9d0870.js";import{Action as h,StringUtils as n,KeyboardManager as d}from"@sankhyalabs/core";import{S as r}from"./p-8d513b64.js";import{FormMetadata as l,buildFormMetadata as c}from"@sankhyalabs/ezui/dist/collection/utils/form";import{S as u}from"./p-10d883b0.js";import"./p-3190ac29.js";import{P as m}from"./p-0f3698af.js";import"@sankhyalabs/ezui/dist/collection/utils/constants";import"@sankhyalabs/core/dist/dataunit/metadata/UnitMetadata";import"./p-c1e168a2.js";import"./p-ff1990ad.js";import"./p-d7657667.js";import{V as v}from"./p-9019a32f.js";import{T as p}from"./p-3072136e.js";import{S as g}from"./p-c5889dae.js";import{buildFieldSearch as f,SHORTCUT_SEARCH_FIELD as b}from"@sankhyalabs/ezui/dist/collection/utils";import"./p-13f91e7e.js";import"./p-8d884fab.js";import"@sankhyalabs/ezui/dist/collection/components/ez-grid/utils";import"@sankhyalabs/core/dist/utils/SortingUtils";import"./p-688dcb4c.js";import"./p-a73b6b00.js";class k{constructor(t,i,s,e){this._parentGuide=t,this._formMetadata=i,this._dataUnit=s,this._messageBuilder=e,this._messageBuilder||(this._messageBuilder=new u)}get id(){return this._parentGuide.id}getMessage(t,i){return this._messageBuilder.getMessage(t,i)}buildGuideItem(t){const i=Object.assign({},this._parentGuide);delete i.expanded,delete i.children;const s=this._dataUnit.getSelectedRecord();if(!s)return i;const e=this._dataUnit.isNewRecord(s.__record__id__),a=Array.from(this._formMetadata.getAllSheets().values()).map((i=>{const{name:s,label:a}=i,o=null!=l.getDetailName(s.split("::").pop()),h=o&&e,n=this._parentGuide.id,d=o?`${n}::${s}`:`${n}__FORM:${s}`;return o&&t.has(d)&&!h?t.get(d).buildGuideItem(t):{id:d,label:a,disabled:h,tooltip:h?this.getMessage("snkCrud.guide.tooltip.disabledDetail"):void 0}})),o=a.shift();return o.label=e?this.getMessage("snkCrud.newRecord"):s.__record__label__,o.children=a,i.children=[o],i}}const w=class{constructor(s){t(this,s),this.snkDetailGuidesChange=i(this,"snkDetailGuidesChange",7),this.snkSwitchGuide=i(this,"snkSwitchGuide",7),this.formItemsReady=i(this,"formItemsReady",7),this._disabledButtons=void 0,this._currentView=void 0,this.attachmentRegisterKey=void 0,this._fieldToGetFocus=void 0,this._hasToCreateFieldSearch=!0,this.formConfigManager=void 0,this.dataUnitName=void 0,this.resourceID=void 0,this.guideItemPath=void 0,this.entityName=void 0,this.label=void 0,this.dataUnit=void 0,this.selectedForm=void 0,this.dataState=void 0,this.messagesBuilder=void 0,this.branchGuide=void 0,this.canEdit=!0,this.taskbarCustomContainerId=void 0,this.customEditors=void 0,this.customRenders=void 0,this.presentationMode=m.SECONDARY}observeDataUnit(t,i){null==t||t.subscribe(this.dataUnitActionHandler.bind(this)),null==i||i.unsubscribe(this.dataUnitActionHandler)}observerDataState(t,i){const s=!(null==i?void 0:i.insertionMode)&&(null==t?void 0:t.insertionMode),e=(null==i?void 0:i.insertionMode)&&!(null==t?void 0:t.insertionMode);if((s||e)&&this.loadMetadata(),null==this._formMetadata)return;const a=null==t?void 0:t.selectedRecord,o=null==i?void 0:i.selectedRecord;(null==a?void 0:a.__record__id__)!==(null==o?void 0:o.__record__id__)&&this.snkDetailGuidesChange.emit(new k(this.branchGuide,this._formMetadata,this.dataUnit,this.messagesBuilder)),s&&setTimeout((()=>{this.changeViewMode(v.FORM)}),0),e&&this.changeViewMode(v.GRID);const h=[];this.dataState.hasPrevious||h.push(p.PREVIOUS),this.dataState.hasNext||h.push(p.NEXT),this.dataState.insertionMode&&h.push(p.INSERT),this._disabledButtons=h}async changeViewMode(t){this.emitSwitchEvent(t)}async configGrid(){this._snkGrid&&this._snkGrid.showConfig()}async showUp(){this._snkFormView&&this._snkFormView.showUp(),this._snkGrid&&this._snkGrid.scrollIntoView({behavior:"smooth",block:"start"})}async addCustomEditor(t,i){var s;const e=this.normalizeBranchGuideId(null===(s=this.branchGuide)||void 0===s?void 0:s.id);this._snkGrid.addCustomEditor(t,i,e),this._snkFormView.addCustomEditor(t,i,e)}async observerPropsCustomEditor(t){for(const i in t)await this.addCustomEditor(i,t[i])}async addGridCustomRender(t,i){var s;const e=this.normalizeBranchGuideId(null===(s=this.branchGuide)||void 0===s?void 0:s.id);await this._snkGrid.addGridCustomRender(t,i,e)}onContentCardChanged(t){g.updateContentCard(t.detail.formName,t.detail.cardConfig,t.detail.propertyChanged,this.formConfigManager).then((()=>s(this))),t.stopPropagation()}async observeCustomRenders(t){for(const i in t){const s=t[i];await this.addGridCustomRender(i,s)}}updateLabel(){const t=this.guideItemPath?this.guideItemPath.length:0;if(t>0){const i=t>0?this.guideItemPath.map((t=>t.label)):void 0;this.label=i.pop(),this._levelPath=i.length>0?i.join(" / "):void 0}else this.label="",this._levelPath=void 0}getFormGuideId(t){var i;if(!t){if(null==(null===(i=this.dataState)||void 0===i?void 0:i.selectedRecord))return;const s=Array.from(this._formMetadata.getAllSheets().keys());if(!s||0==s.length)return;t=s[0]}return`${this.stripFormPattern(this.branchGuide.id)}__FORM:${t}`}stripFormPattern(t){return t.replace(w.REGEX_FORM_ID,"")}loadMetadata(){if(!this.dataUnit)return;if(!this.formConfigManager.isLoaded)return;const t=this.formConfigManager.getConfig(this.dataUnit);this._formMetadata=c(null==t||0===t.fields.length?void 0:t,this.dataUnit,!0)}dataUnitReadyHandler(t){this.dataUnit=t.detail,this.loadMetadata()}updateViewStack(t){var i,s;this._viewStack=t,this._currentView=this.selectedForm?1:0,null===(s=null===(i=this._viewStack)||void 0===i?void 0:i.show)||void 0===s||s.call(i,this._currentView)}getFormFields(){return this.selectedForm&&this._formMetadata?this._formMetadata.getSheet(this.selectedForm).fields:[]}emitSwitchEvent(t){t===v.GRID&&(this.dataUnit.isMultipleEdition=!1);const i=t===v.GRID?this.stripFormPattern(this.branchGuide.id):this.getFormGuideId();i&&this.snkSwitchGuide.emit(i)}executeActionHandler(t){t.detail===p.GRID_MODE&&(this.emitSwitchEvent(v.GRID),t.stopPropagation()),t.detail===p.UPDATE_MULTIPLE&&(this.dataUnit.isMultipleEdition=!0,this.emitSwitchEvent(v.FORM),t.stopPropagation()),t.detail!==p.FORM_MODE&&t.detail!==p.UPDATE||(this.emitSwitchEvent(v.FORM),t.stopPropagation()),t.detail===p.ATTACH&&(this._snkAttach.open(),t.stopPropagation())}async getAttachmentRegisterKey(){if(this._snkDataUnit)return(await this._snkDataUnit.getSelectedRecordsIDsInfo()).map((({value:t})=>t)).join("_")}async handleDataStateChange({detail:t}){this.dataState=t,void 0!==t.selectedRecord&&this._snkDataUnit&&(this.attachmentRegisterKey=await this.getAttachmentRegisterKey())}componentWillLoad(){this._configName=`dynaform.${this.entityName}`,this.formConfigManager=new r(this._configName,this.resourceID,(()=>this.loadMetadata()),this.dataUnit),this.formConfigManager.loadConfig(),null==this.messagesBuilder&&(this.messagesBuilder=new u(this.entityName))}async componentDidLoad(){await this.observerPropsCustomEditor(this.customEditors),await this.observeCustomRenders(this.customRenders),this.initKeyboardManager()}disconnectedCallback(){var t;null===(t=this._keyboardManager)||void 0===t||t.unbindAllShortcutKeys()}async dataUnitActionHandler(t){t.type===h.FIELD_INVALIDATED?this.addErrorBadgeToBranchGuide():t.type===h.DATA_LOADED&&this.handleDataLoaded()}handleDataLoaded(){var t;(null===(t=this.dataUnit)||void 0===t?void 0:t.getSelectedRecord())||this.dataUnit.selectFirst()}addErrorBadgeToBranchGuide(){this.branchGuide=Object.assign(Object.assign({},this.branchGuide),{badge:"error"}),this.snkDetailGuidesChange.emit(new k(this.branchGuide,this._formMetadata,this.dataUnit,this.messagesBuilder))}normalizeBranchGuideId(t){return null==t?void 0:t.replace(/child\[(.*?)\]/g,"$1").replace(/::/g,">")}getSettingsListForm(){return[{value:n.generateUUID(),label:this.messagesBuilder.getMessage("snkCrud.findColumn",void 0),disableCloseOnSelect:!0,eagerInitialize:!0,itemBuilder:(t,i)=>this.getFieldsSearch(i)}]}getFieldsSearch(t){return(null==this._fieldSearch||this._hasToCreateFieldSearch)&&(this._hasToCreateFieldSearch=!1,this._fieldSearch=f(t,(({argument:t})=>this.fieldsOptionLoader(t)),(t=>this.onSelectField(t)))),this._fieldSearch}fieldsOptionLoader(t){const i=null==t?void 0:t.toLowerCase(),s=this.getFormFields().map((t=>{var i;return null===(i=this.dataUnit)||void 0===i?void 0:i.getField(t.name)})).filter((t=>{var s,e;return(null===(s=t.name)||void 0===s?void 0:s.toLowerCase().includes(i))||(null===(e=t.label)||void 0===e?void 0:e.toLowerCase().includes(i))})).map((t=>({value:t.name,label:t.label})));return Promise.resolve(s)}onSelectField(t){null!=t&&(this._fieldToGetFocus=t.value)}clearFieldToFocusHandler(){this._fieldToGetFocus=void 0}async initKeyboardManager(){this._keyboardManager=new d({propagate:!1,element:this._element}),this._keyboardManager.bind(b,(async()=>{await this._snkFormView.showSearchField()}),{description:this.messagesBuilder.getMessage("snkSimpleCrud.findFields"),element:this._element})}render(){return this.updateLabel(),e(a,null,e("snk-data-unit",{ref:t=>this._snkDataUnit=t,dataUnitName:`${this.dataUnitName}`,onDataUnitReady:t=>this.dataUnitReadyHandler(t),entityName:this.entityName,onDataStateChange:this.handleDataStateChange.bind(this),ignoreSaveMessage:this._currentView===v.GRID,messagesBuilder:this.messagesBuilder,configName:this._configName},e("ez-view-stack",{ref:t=>this.updateViewStack(t)},e("stack-item",null,e("div",{class:"ez-box ez-box--shadow grid-container"},e("div",{class:"ez-title--primary ez-size-width--full ez-padding--large detail-header"},e("div",{class:"ez-flex ez-text ez-text--bold ez-flex--justify-start ez-flex--align-items-center"},this._levelPath?e("span",{class:"level-path"},this._levelPath+" /"):void 0,this.label)),e("snk-grid",{class:"ez-size-width--full",ref:t=>this._snkGrid=t,configName:this._configName,messagesBuilder:this.messagesBuilder,onGridDoubleClick:()=>this.emitSwitchEvent(v.FORM),onActionClick:t=>this.executeActionHandler(t),presentationMode:this.presentationMode,canEdit:this.canEdit,isDetail:!0,taskbarCustomContainerId:this.taskbarCustomContainerId,gridHeaderCustomSlotId:"DETAIL_GRID_HEADER_CUSTOM_ELEMENTS",topTaskbarCustomSlotId:"DETAIL_GRID_TASKBAR_CUSTOM_ELEMENTS",outlineMode:!1,enableGridInsert:!0,autoLoad:!0,multipleEditionEnabled:!0,multipleSelection:!0}))),e("stack-item",null,e("snk-form-view",{ref:t=>this._snkFormView=t,canExpand:!1,canFix:!1,name:this.selectedForm,formMetadata:this._formMetadata,dataUnit:this.dataUnit,fields:this.getFormFields(),fieldToFocus:this._fieldToGetFocus,label:this.label,levelPath:this._levelPath,onFormItemsReady:({detail:t})=>this.formItemsReady.emit(t),onSnkRequestClearFieldToFocus:this.clearFieldToFocusHandler.bind(this),fieldSearch:this._fieldSearch,entityPath:this.entityName},e("snk-taskbar",{key:"guideViewerTaskbar",class:"form-taskbar","data-element-id":"guideViewer",configName:this._configName,messagesBuilder:this.messagesBuilder,disabledButtons:this._disabledButtons,buttons:"INSERT,PREVIOUS,NEXT,DIVIDER,CLONE,REMOVE,MORE_OPTIONS,ACTIONS_BUTTON,DIVIDER,GRID_MODE,CONFIGURATOR",primaryButton:"INSERT",presentationMode:this.presentationMode,onActionClick:t=>this.executeActionHandler(t),dataUnit:this.dataUnit,resourceID:this.resourceID,customContainerId:this.taskbarCustomContainerId,customSlotId:"DETAIL_TASKBAR_CUSTOM_ELEMENTS",actionsSettingsList:this.getSettingsListForm()},e("slot",{name:"DETAIL_TASKBAR_CUSTOM_ELEMENTS"}))))),e("snk-attach",{ref:t=>this._snkAttach=t,registerKey:this.attachmentRegisterKey,messagesBuilder:this.messagesBuilder,entityName:this.entityName})))}get _element(){return o(this)}static get watchers(){return{dataUnit:["observeDataUnit"],dataState:["observerDataState"],customEditors:["observerPropsCustomEditor"],customRenders:["observeCustomRenders"]}}};w.REGEX_FORM_ID=/__FORM:[^:]+/g,w.style=".sc-snk-detail-view-h{display:flex;row-gap:24px;flex-direction:column;width:100%;height:100%}.level-path.sc-snk-detail-view{color:var(--color--title-primary, #2B3A54);font-weight:var(--text-weight--medium, 400);padding-right:3px}.form-taskbar.sc-snk-detail-view{padding-bottom:var(--space--medium)}.grid-container.sc-snk-detail-view{background-color:#FFF;min-height:100px;height:100%}.detail-header.sc-snk-detail-view{padding-bottom:0}snk-data-unit.sc-snk-detail-view{flex:1}snk-grid.sc-snk-detail-view{height:calc(100% - 56px);--snk-grid__header-padding:var(--space--4, 4px);--snk-grid-padding:var(--space--8, 8px);--snk-grid-box-shadow:unset}";export{w as snk_detail_view}
1
+ import{r as t,e as i,i as s,h as e,f as a,g as o}from"./p-2c9d0870.js";import{Action as h,StringUtils as n,KeyboardManager as d}from"@sankhyalabs/core";import{S as r}from"./p-c9440c8a.js";import{FormMetadata as l,buildFormMetadata as c}from"@sankhyalabs/ezui/dist/collection/utils/form";import{S as u}from"./p-4dd574d6.js";import"./p-097d75b3.js";import{P as m}from"./p-abcb646d.js";import"@sankhyalabs/ezui/dist/collection/utils/constants";import"@sankhyalabs/core/dist/dataunit/metadata/UnitMetadata";import"./p-8d1ef77a.js";import"./p-ff1990ad.js";import"./p-ec7c87bb.js";import{V as v}from"./p-9019a32f.js";import{T as p}from"./p-2ec98523.js";import{S as g}from"./p-90037547.js";import{buildFieldSearch as b,SHORTCUT_SEARCH_FIELD as f}from"@sankhyalabs/ezui/dist/collection/utils";import"./p-8d81c8d3.js";import"./p-8d884fab.js";import"@sankhyalabs/ezui/dist/collection/components/ez-grid/utils";import"@sankhyalabs/core/dist/utils/SortingUtils";import"./p-688dcb4c.js";import"./p-a73b6b00.js";class k{constructor(t,i,s,e){this._parentGuide=t,this._formMetadata=i,this._dataUnit=s,this._messageBuilder=e,this._messageBuilder||(this._messageBuilder=new u)}get id(){return this._parentGuide.id}getMessage(t,i){return this._messageBuilder.getMessage(t,i)}buildGuideItem(t){const i=Object.assign({},this._parentGuide);delete i.expanded,delete i.children;const s=this._dataUnit.getSelectedRecord();if(!s)return i;const e=this._dataUnit.isNewRecord(s.__record__id__),a=Array.from(this._formMetadata.getAllSheets().values()).map((i=>{const{name:s,label:a}=i,o=null!=l.getDetailName(s.split("::").pop()),h=o&&e,n=this._parentGuide.id,d=o?`${n}::${s}`:`${n}__FORM:${s}`;return o&&t.has(d)&&!h?t.get(d).buildGuideItem(t):{id:d,label:a,disabled:h,tooltip:h?this.getMessage("snkCrud.guide.tooltip.disabledDetail"):void 0}})),o=a.shift();return o.label=e?this.getMessage("snkCrud.newRecord"):s.__record__label__,o.children=a,i.children=[o],i}}const w=class{constructor(s){t(this,s),this.snkDetailGuidesChange=i(this,"snkDetailGuidesChange",7),this.snkSwitchGuide=i(this,"snkSwitchGuide",7),this.formItemsReady=i(this,"formItemsReady",7),this._disabledButtons=void 0,this._currentView=void 0,this.attachmentRegisterKey=void 0,this._fieldToGetFocus=void 0,this._hasToCreateFieldSearch=!0,this.formConfigManager=void 0,this.dataUnitName=void 0,this.resourceID=void 0,this.guideItemPath=void 0,this.entityName=void 0,this.label=void 0,this.dataUnit=void 0,this.selectedForm=void 0,this.dataState=void 0,this.messagesBuilder=void 0,this.branchGuide=void 0,this.canEdit=!0,this.taskbarCustomContainerId=void 0,this.customEditors=void 0,this.customRenders=void 0,this.presentationMode=m.SECONDARY}observeDataUnit(t,i){null==t||t.subscribe(this.dataUnitActionHandler.bind(this)),null==i||i.unsubscribe(this.dataUnitActionHandler)}observerDataState(t,i){const s=!(null==i?void 0:i.insertionMode)&&(null==t?void 0:t.insertionMode),e=(null==i?void 0:i.insertionMode)&&!(null==t?void 0:t.insertionMode);if((s||e)&&this.loadMetadata(),null==this._formMetadata)return;const a=null==t?void 0:t.selectedRecord,o=null==i?void 0:i.selectedRecord;(null==a?void 0:a.__record__id__)!==(null==o?void 0:o.__record__id__)&&this.snkDetailGuidesChange.emit(new k(this.branchGuide,this._formMetadata,this.dataUnit,this.messagesBuilder)),s&&setTimeout((()=>{this.changeViewMode(v.FORM)}),0),e&&this.changeViewMode(v.GRID);const h=[];this.dataState.hasPrevious||h.push(p.PREVIOUS),this.dataState.hasNext||h.push(p.NEXT),this.dataState.insertionMode&&h.push(p.INSERT),this._disabledButtons=h}async changeViewMode(t){this.emitSwitchEvent(t)}async configGrid(){this._snkGrid&&this._snkGrid.showConfig()}async showUp(){this._snkFormView&&this._snkFormView.showUp(),this._snkGrid&&this._snkGrid.scrollIntoView({behavior:"smooth",block:"start"})}async addCustomEditor(t,i){var s;const e=this.normalizeBranchGuideId(null===(s=this.branchGuide)||void 0===s?void 0:s.id);this._snkGrid.addCustomEditor(t,i,e),this._snkFormView.addCustomEditor(t,i,e)}async observerPropsCustomEditor(t){for(const i in t)await this.addCustomEditor(i,t[i])}async addGridCustomRender(t,i){var s;const e=this.normalizeBranchGuideId(null===(s=this.branchGuide)||void 0===s?void 0:s.id);await this._snkGrid.addGridCustomRender(t,i,e)}onContentCardChanged(t){g.updateContentCard(t.detail.formName,t.detail.cardConfig,t.detail.propertyChanged,this.formConfigManager).then((()=>s(this))),t.stopPropagation()}async observeCustomRenders(t){for(const i in t){const s=t[i];await this.addGridCustomRender(i,s)}}updateLabel(){const t=this.guideItemPath?this.guideItemPath.length:0;if(t>0){const i=t>0?this.guideItemPath.map((t=>t.label)):void 0;this.label=i.pop(),this._levelPath=i.length>0?i.join(" / "):void 0}else this.label="",this._levelPath=void 0}getFormGuideId(t){var i;if(!t){if(null==(null===(i=this.dataState)||void 0===i?void 0:i.selectedRecord))return;const s=Array.from(this._formMetadata.getAllSheets().keys());if(!s||0==s.length)return;t=s[0]}return`${this.stripFormPattern(this.branchGuide.id)}__FORM:${t}`}stripFormPattern(t){return t.replace(w.REGEX_FORM_ID,"")}loadMetadata(){if(!this.dataUnit)return;if(!this.formConfigManager.isLoaded)return;const t=this.formConfigManager.getConfig(this.dataUnit);this._formMetadata=c(null==t||0===t.fields.length?void 0:t,this.dataUnit,!0)}dataUnitReadyHandler(t){this.dataUnit=t.detail,this.loadMetadata()}updateViewStack(t){var i,s;this._viewStack=t,this._currentView=this.selectedForm?1:0,null===(s=null===(i=this._viewStack)||void 0===i?void 0:i.show)||void 0===s||s.call(i,this._currentView)}getFormFields(){return this.selectedForm&&this._formMetadata?this._formMetadata.getSheet(this.selectedForm).fields:[]}emitSwitchEvent(t){t===v.GRID&&(this.dataUnit.isMultipleEdition=!1);const i=t===v.GRID?this.stripFormPattern(this.branchGuide.id):this.getFormGuideId();i&&this.snkSwitchGuide.emit(i)}executeActionHandler(t){t.detail===p.GRID_MODE&&(this.emitSwitchEvent(v.GRID),t.stopPropagation()),t.detail===p.UPDATE_MULTIPLE&&(this.dataUnit.isMultipleEdition=!0,this.emitSwitchEvent(v.FORM),t.stopPropagation()),t.detail!==p.FORM_MODE&&t.detail!==p.UPDATE||(this.emitSwitchEvent(v.FORM),t.stopPropagation()),t.detail===p.ATTACH&&(this._snkAttach.open(),t.stopPropagation())}async getAttachmentRegisterKey(){if(this._snkDataUnit)return(await this._snkDataUnit.getSelectedRecordsIDsInfo()).map((({value:t})=>t)).join("_")}async handleDataStateChange({detail:t}){this.dataState=t,void 0!==t.selectedRecord&&this._snkDataUnit&&(this.attachmentRegisterKey=await this.getAttachmentRegisterKey())}componentWillLoad(){this._configName=`dynaform.${this.entityName}`,this.formConfigManager=new r(this._configName,this.resourceID,(()=>this.loadMetadata()),this.dataUnit),this.formConfigManager.loadConfig(),null==this.messagesBuilder&&(this.messagesBuilder=new u(this.entityName))}async componentDidLoad(){await this.observerPropsCustomEditor(this.customEditors),await this.observeCustomRenders(this.customRenders),this.initKeyboardManager()}disconnectedCallback(){var t;null===(t=this._keyboardManager)||void 0===t||t.unbindAllShortcutKeys()}async dataUnitActionHandler(t){t.type===h.FIELD_INVALIDATED?this.addErrorBadgeToBranchGuide():t.type===h.DATA_LOADED&&this.handleDataLoaded()}handleDataLoaded(){var t;(null===(t=this.dataUnit)||void 0===t?void 0:t.getSelectedRecord())||this.dataUnit.selectFirst()}addErrorBadgeToBranchGuide(){this.branchGuide=Object.assign(Object.assign({},this.branchGuide),{badge:"error"}),this.snkDetailGuidesChange.emit(new k(this.branchGuide,this._formMetadata,this.dataUnit,this.messagesBuilder))}normalizeBranchGuideId(t){return null==t?void 0:t.replace(/child\[(.*?)\]/g,"$1").replace(/::/g,">")}getSettingsListForm(){return[{value:n.generateUUID(),label:this.messagesBuilder.getMessage("snkCrud.findColumn",void 0),disableCloseOnSelect:!0,eagerInitialize:!0,itemBuilder:(t,i)=>this.getFieldsSearch(i)}]}getFieldsSearch(t){return(null==this._fieldSearch||this._hasToCreateFieldSearch)&&(this._hasToCreateFieldSearch=!1,this._fieldSearch=b(t,(({argument:t})=>this.fieldsOptionLoader(t)),(t=>this.onSelectField(t)))),this._fieldSearch}fieldsOptionLoader(t){const i=null==t?void 0:t.toLowerCase(),s=this.getFormFields().map((t=>{var i;return null===(i=this.dataUnit)||void 0===i?void 0:i.getField(t.name)})).filter((t=>{var s,e;return(null===(s=t.name)||void 0===s?void 0:s.toLowerCase().includes(i))||(null===(e=t.label)||void 0===e?void 0:e.toLowerCase().includes(i))})).map((t=>({value:t.name,label:t.label})));return Promise.resolve(s)}onSelectField(t){null!=t&&(this._fieldToGetFocus=t.value)}clearFieldToFocusHandler(){this._fieldToGetFocus=void 0}async initKeyboardManager(){this._keyboardManager=new d({propagate:!1,element:this._element}),this._keyboardManager.bind(f,(async()=>{await this._snkFormView.showSearchField()}),{description:this.messagesBuilder.getMessage("snkSimpleCrud.findFields"),element:this._element})}render(){return this.updateLabel(),e(a,null,e("snk-data-unit",{ref:t=>this._snkDataUnit=t,dataUnitName:`${this.dataUnitName}`,onDataUnitReady:t=>this.dataUnitReadyHandler(t),entityName:this.entityName,onDataStateChange:this.handleDataStateChange.bind(this),ignoreSaveMessage:this._currentView===v.GRID,messagesBuilder:this.messagesBuilder,configName:this._configName},e("ez-view-stack",{ref:t=>this.updateViewStack(t)},e("stack-item",null,e("div",{class:"ez-box ez-box--shadow grid-container"},e("div",{class:"ez-title--primary ez-size-width--full ez-padding--large detail-header"},e("div",{class:"ez-flex ez-text ez-text--bold ez-flex--justify-start ez-flex--align-items-center"},this._levelPath?e("span",{class:"level-path"},this._levelPath+" /"):void 0,this.label)),e("snk-grid",{class:"ez-size-width--full",ref:t=>this._snkGrid=t,configName:this._configName,messagesBuilder:this.messagesBuilder,onGridDoubleClick:()=>this.emitSwitchEvent(v.FORM),onActionClick:t=>this.executeActionHandler(t),presentationMode:this.presentationMode,canEdit:this.canEdit,isDetail:!0,taskbarCustomContainerId:this.taskbarCustomContainerId,gridHeaderCustomSlotId:"DETAIL_GRID_HEADER_CUSTOM_ELEMENTS",topTaskbarCustomSlotId:"DETAIL_GRID_TASKBAR_CUSTOM_ELEMENTS",outlineMode:!1,enableGridInsert:!0,autoLoad:!0,multipleEditionEnabled:!0,multipleSelection:!0}))),e("stack-item",null,e("snk-form-view",{ref:t=>this._snkFormView=t,canExpand:!1,canFix:!1,name:this.selectedForm,formMetadata:this._formMetadata,dataUnit:this.dataUnit,fields:this.getFormFields(),fieldToFocus:this._fieldToGetFocus,label:this.label,levelPath:this._levelPath,onFormItemsReady:({detail:t})=>this.formItemsReady.emit(t),onSnkRequestClearFieldToFocus:this.clearFieldToFocusHandler.bind(this),fieldSearch:this._fieldSearch,entityPath:this.entityName},e("snk-taskbar",{key:"guideViewerTaskbar",class:"form-taskbar","data-element-id":"guideViewer",configName:this._configName,messagesBuilder:this.messagesBuilder,disabledButtons:this._disabledButtons,buttons:"INSERT,PREVIOUS,NEXT,DIVIDER,CLONE,REMOVE,MORE_OPTIONS,ACTIONS_BUTTON,DIVIDER,GRID_MODE,CONFIGURATOR",primaryButton:"INSERT",presentationMode:this.presentationMode,onActionClick:t=>this.executeActionHandler(t),dataUnit:this.dataUnit,resourceID:this.resourceID,customContainerId:this.taskbarCustomContainerId,customSlotId:"DETAIL_TASKBAR_CUSTOM_ELEMENTS",actionsSettingsList:this.getSettingsListForm()},e("slot",{name:"DETAIL_TASKBAR_CUSTOM_ELEMENTS"}))))),e("snk-attach",{ref:t=>this._snkAttach=t,registerKey:this.attachmentRegisterKey,messagesBuilder:this.messagesBuilder,entityName:this.entityName})))}get _element(){return o(this)}static get watchers(){return{dataUnit:["observeDataUnit"],dataState:["observerDataState"],customEditors:["observerPropsCustomEditor"],customRenders:["observeCustomRenders"]}}};w.REGEX_FORM_ID=/__FORM:[^:]+/g,w.style=".sc-snk-detail-view-h{display:flex;row-gap:24px;flex-direction:column;width:100%;height:100%}.level-path.sc-snk-detail-view{color:var(--color--title-primary, #2B3A54);font-weight:var(--text-weight--medium, 400);padding-right:3px}.form-taskbar.sc-snk-detail-view{padding-bottom:var(--space--medium)}.grid-container.sc-snk-detail-view{background-color:#FFF;min-height:100px;height:100%}.detail-header.sc-snk-detail-view{padding-bottom:0}snk-data-unit.sc-snk-detail-view{flex:1}snk-grid.sc-snk-detail-view{height:calc(100% - 56px);--snk-grid__header-padding:var(--space--4, 4px);--snk-grid-padding:var(--space--8, 8px);--snk-grid-box-shadow:unset}";export{w as snk_detail_view}
@@ -0,0 +1 @@
1
+ import{r as t,h as e,f as i,g as s}from"./p-2c9d0870.js";import{ApplicationContext as o,ObjectUtils as r,UserInterface as n,DataType as l,ElementIDUtils as a}from"@sankhyalabs/core";import{ApplicationUtils as d,DialogType as h}from"@sankhyalabs/ezui/dist/collection/utils";import{I as c}from"./p-8f3f2306.js";import{D as u,a as p,b as m}from"./p-abcb646d.js";import{R as v}from"./p-9019a32f.js";import{D as x}from"./p-4dd574d6.js";import{S as g}from"./p-eac48627.js";import"./p-097d75b3.js";import"@sankhyalabs/ezui/dist/collection/utils/constants";import"@sankhyalabs/core/dist/dataunit/metadata/UnitMetadata";import"./p-8d1ef77a.js";import"./p-ff1990ad.js";import"./p-ec7c87bb.js";import"./p-8d884fab.js";import"@sankhyalabs/core/dist/dataunit/metadata/DataType";import"./p-7dd49d15.js";import"@sankhyalabs/ezui/dist/collection/components/ez-grid/utils";import"@sankhyalabs/core/dist/utils/SortingUtils";import"./p-688dcb4c.js";class f{constructor(t,e){this._selectedNumber=0,this._getMessage=t,this._selectedNumber=e}setExportOption(t,e){const i=this.getExportGroupName();t===u.EXPORT_TO_PDF&&e.push(this.getExportToPDF(i)),t===u.EXPORT_TO_XLS&&e.push(this.getExportToXLS(i)),t===u.EXPORT_TO_XLSX&&e.push(this.getExportToXLSX(i)),this.setExportCurrentPage(t,e),this._selectedNumber>0&&this.setExportAllRecords(t,e),this.setExportByEmail(t,e)}setExportCurrentPage(t,e){var i;const s=[u.EXPORT_PAGE_TO_PDF,u.EXPORT_PAGE_TO_XLS,u.EXPORT_PAGE_TO_XLSX];if(t===u.EXPORT_CURRENT_PAGE&&e.push(this.getCurrentPage()),s.includes(t)){let s=e.find((t=>t.id===u.EXPORT_CURRENT_PAGE));null==s&&(e.push(this.getCurrentPage()),s=e.find((t=>t.id===u.EXPORT_CURRENT_PAGE))),(null===(i=null==s?void 0:s.children)||void 0===i?void 0:i.length)||(s.children=[]),t===u.EXPORT_PAGE_TO_PDF&&s.children.push(this.getExportPageToPDF()),t===u.EXPORT_PAGE_TO_XLS&&s.children.push(this.getExportPageToXLS()),t===u.EXPORT_PAGE_TO_XLSX&&s.children.push(this.getExportPageToXLSX())}}setExportAllRecords(t,e){var i;const s=[u.EXPORT_ALL_RECORDS_TO_PDF,u.EXPORT_ALL_RECORDS_TO_XLS,u.EXPORT_ALL_RECORDS_TO_XLSX];if(t===u.EXPORT_ALL_RECORDS&&e.push(this.getAllRecords()),s.includes(t)){let s=e.find((t=>t.id===u.EXPORT_ALL_RECORDS));null==s&&(e.push(this.getAllRecords()),s=e.find((t=>t.id===u.EXPORT_ALL_RECORDS))),(null===(i=s.children)||void 0===i?void 0:i.length)||(s.children=[]),t===u.EXPORT_ALL_RECORDS_TO_PDF&&s.children.push(this.getExportAllRecordsToPDF()),t===u.EXPORT_ALL_RECORDS_TO_XLS&&s.children.push(this.getExportAllRecordsToXLS()),t===u.EXPORT_ALL_RECORDS_TO_XLSX&&s.children.push(this.getExportAllRecordsToXLSX())}}setExportByEmail(t,e){t===u.EXPORT_BY_EMAIL&&e.push(this.getExportByEmail())}getExportToPDF(t){return{id:u.EXPORT_TO_PDF,label:"PDF (.pdf)",group:t}}getExportToXLS(t){return{id:u.EXPORT_TO_XLS,label:`${this._getMessage("snkDataExporter.label.spreadsheet")} (.xls)`,group:t}}getExportToXLSX(t){return{id:u.EXPORT_TO_XLSX,label:`${this._getMessage("snkDataExporter.label.spreadsheet")} (.xlsx)`,group:t}}getCurrentPage(){return{id:u.EXPORT_CURRENT_PAGE,label:this._getMessage("snkDataExporter.label.currentPage"),group:this._getMessage("snkDataExporter.group.custom")}}getAllRecords(){return{id:u.EXPORT_ALL_RECORDS,label:this._getMessage("snkDataExporter.label.allRecords"),group:this._getMessage("snkDataExporter.group.custom")}}getExportPageToPDF(){return{id:u.EXPORT_PAGE_TO_PDF,label:"PDF (.pdf)"}}getExportPageToXLS(){return{id:u.EXPORT_PAGE_TO_XLS,label:`${this._getMessage("snkDataExporter.label.spreadsheet")} (.xls)`}}getExportPageToXLSX(){return{id:u.EXPORT_PAGE_TO_XLSX,label:`${this._getMessage("snkDataExporter.label.spreadsheet")} (.xlsx)`}}getExportAllRecordsToPDF(){return{id:u.EXPORT_ALL_RECORDS_TO_PDF,label:"PDF (.pdf)"}}getExportAllRecordsToXLS(){return{id:u.EXPORT_ALL_RECORDS_TO_XLS,label:`${this._getMessage("snkDataExporter.label.spreadsheet")} (.xls)`}}getExportAllRecordsToXLSX(){return{id:u.EXPORT_ALL_RECORDS_TO_XLSX,label:`${this._getMessage("snkDataExporter.label.spreadsheet")} (.xlsx)`}}getExportByEmail(){return{id:u.EXPORT_BY_EMAIL,label:`${this._getMessage("snkDataExporter.label.sendByEmail")}...`}}getExportGroupName(){return 1===this._selectedNumber?this._getMessage("snkDataExporter.group.export.selectedLine"):this._selectedNumber>1?this._getMessage("snkDataExporter.group.export.multiSelected").replace("{0}",this._selectedNumber.toString()):this._getMessage("snkDataExporter.group.export.default")}}function b(t){const e=[];let i=0;for(const s of t){if(i+=s.width,i>=860)break;e.push(s)}return e}function E(t){return Object.keys(u).find((e=>u[e]===t))}class D{constructor(t){this._provider=t}async getParsedColumns(){return b(await this._provider.getColumnsMetadata())}async getColumns(t){var e;return(null===(e=E(null==t?void 0:t.exportOption))||void 0===e?void 0:e.includes("PDF"))?await this.getParsedColumns():await this._provider.getColumnsMetadata()}async getParams(t){var e,i,s,o,r,n;const l=null===(i=(e=this._provider).getFilters)||void 0===i?void 0:i.call(e),a=await this.getColumns(t),d=null===(o=(s=this._provider).getOrders)||void 0===o?void 0:o.call(s),h=null===(n=(r=this._provider).getResourceURI)||void 0===n?void 0:n.call(r),c=this._provider.getSelectedIDs(),p=t.exportOption,m=[u.EXPORT_PAGE_TO_PDF,u.EXPORT_PAGE_TO_XLS];delete t.exportOption;let v=Object.assign({filters:l,columns:a,sort:d,resourceURI:h,selectedIDs:c.slice(0,this._provider.getExportLimit())},t);if(m.includes(p)||"page"==t.type){const t=this._provider.getOffset(),e=this._provider.getPageSize();v=Object.assign(Object.assign({},v),{offset:t,limit:e,selectedIDs:[]})}else"all"==t.type&&(v=Object.assign(Object.assign({},v),{offset:0,limit:this._provider.getExportLimit(),selectedIDs:[]}));return Promise.resolve(v)}async executeExport(t){const e=await this.getParams(t),{methodName:i}=e,s=function(t,e){var i={};for(var s in t)Object.prototype.hasOwnProperty.call(t,s)&&e.indexOf(s)<0&&(i[s]=t[s]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(s=Object.getOwnPropertySymbols(t);o<s.length;o++)e.indexOf(s[o])<0&&Object.prototype.propertyIsEnumerable.call(t,s[o])&&(i[s[o]]=t[s[o]])}return i}(e,["methodName"]),n=`${o.getContextValue("__SNK__APPLICATION__").getModuleName()}@DataExporterSPBean.${i}`,l={serviceName:n,requestBody:s};return new Promise(((t,e)=>{x.get().callServiceBroker(n,r.objectToString(l)).then((e=>t(this.getFormatResponse(e)))).catch((t=>e(t)))}))}getFormatResponse(t){var e;const i=null===(e=null==t?void 0:t.json)||void 0===e?void 0:e.$;if(null!=i)return r.stringToObject(i)}}class k{constructor(t){this._provider=t}async getParsedColumns(){return b(await this._provider.getColumnsMetadata())}async executeExport(t){var e,i;const{methodName:s,gridTitle:o}=t,r=await this._provider.getRecords(t.type),n=(null===(e=E(null==t?void 0:t.exportOption))||void 0===e?void 0:e.includes("PDF"))?await this.getParsedColumns():await this._provider.getColumnsMetadata(),[l,a]=this.getExecutor(s),d={serviceName:l,requestBody:{grid:{gridTitle:o,columns:this.buildColumnsObject(n),rows:this.buildRowsObject(n,r),customOptions:{xlsxExtension:null!==(i=null==t?void 0:t.xlsxExtension)&&void 0!==i&&i}}}};return new Promise(((t,e)=>{x.get().callServiceBroker(l,d).then((e=>t(a(e)))).catch((t=>e(t)))}))}getExecutor(t){return"exportToPDF"===t?["GridPDFBuilderSP.buildPDFFromJson",t=>({fileSessionKey:t.chavePDF.valor,canPrint:"S"===t.permiteImprimir.valor,canExport:"S"===t.permiteExportar.valor,canSendEmail:"S"===t.canSendEmail.valor,useAppPrint:!0})]:["GridXLSBuilderSP.buildXLSFromJson",t=>({fileSessionKey:t.chaveXLS.valor,canPrint:!0,canExport:!0,canSendEmail:!0,useAppPrint:!1})]}buildColumnsObject(t){return{column:t.map(((t,e)=>{const{label:i,id:s,width:o,userInterface:r}=t;return Object.assign({index:e+1,id:s,label:i,width:o,presentationType:"P"},w[r]||{type:"S",align:"left"})}))}}buildRowsObject(t,e){return{row:e.map((e=>{const i={};return t.forEach(((t,s)=>i["c"+(s+1)]={$:this.formatValue(e,t)})),i}))}}formatValue(t,e){return null!=this._provider.formatValue?this._provider.formatValue(t,e):t[e.id]||""}}const w={[n.DATE]:{type:"D",align:"center"},[n.DATETIME]:{type:"H",align:"center"},[n.TIME]:{type:"I",align:"right"},[n.ELAPSEDTIME]:{type:"I",align:"right"},[n.DECIMALNUMBER]:{type:"F",align:"right"},[n.INTEGERNUMBER]:{type:"I",align:"right"},[n.SEARCH]:{type:"S",align:"right"}},y=class{constructor(e){t(this,e),this._selectedNumber=0,this._customPrefix="$custom$",this._releasedToExport=[u.EXPORT_TO_PDF,u.EXPORT_TO_XLS,u.EXPORT_TO_XLSX,u.EXPORT_BY_EMAIL,u.EXPORT_PDF_TO_EMAIL,u.EXPORT_XLS_TO_EMAIL,u.EXPORT_PAGE_TO_PDF,u.EXPORT_PAGE_TO_XLS,u.EXPORT_PAGE_TO_XLSX,u.EXPORT_ALL_RECORDS_TO_PDF,u.EXPORT_ALL_RECORDS_TO_XLS,u.EXPORT_ALL_RECORDS_TO_XLSX],this._items=[],this._showDropdown=!1,this.provider=null,this.messagesBuilder=void 0,this.size="medium"}async exportByEmail(){const t=this._selectedNumber;this._snkEmailSender.open({type:t>0?"selection":"all",selectedRows:t,email:{attachments:[{name:this._appLabel}]},resolver:({type:t,format:e,email:{to:i,subject:s,message:o}})=>{var r;const n=null!==(r=m[null==e?void 0:e.toUpperCase()])&&void 0!==r?r:m.PDF;this.resolveExporter({type:t,methodName:n,to:i,subject:s,message:o,fileName:this._appLabel,gridTitle:this._appLabel},(()=>{this._snkEmailSender.close(),d.info(this.getMessage("snkDataExporter.message.emailSuccess"),{iconName:"check"})}))}})}getMessage(t,e){if(null==this.messagesBuilder){const t=g.getNearestInstance(this._element);t&&(this.messagesBuilder=t.messagesBuilder)}return this.messagesBuilder.getMessage(t,e)}positionDropdown(){var t;const e=null===(t=this._ezButton)||void 0===t?void 0:t.getBoundingClientRect();null!=e&&null!=this._dropdownParent&&(this._dropdownParent.style.top=e.y+e.height+5+"px",this._dropdownParent.style.left=e.x+"px")}closeDropdown(t){const e=null==t?void 0:t.target;null!=e&&(e.closest(".snk-data-exporter")||(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))}controlDropdown(){this._showDropdown=!this._showDropdown}async resolveExporter(t,e){null!=this.provider&&null!=t&&null!=e&&this.getExporterStrategy().executeExport(t).then((t=>e(t))).catch((t=>{console.error(t);let{title:e,message:i,statusMessage:s}=t||{};d.error(e||this.getMessage("snkDataExporter.message.exportError"),s||i||this.getMessage("snkDataExporter.message.unknownFailure"))}))}getExporterStrategy(){return null==this.provider.getRecords?new D(this.provider):new k(this.provider)}getOptionKey(t){return Object.keys(u).find((e=>u[e]===t))}getExportType(t){return t===u.EXPORT_ALL_RECORDS_TO_PDF||t===u.EXPORT_ALL_RECORDS_TO_XLS||t===u.EXPORT_ALL_RECORDS_TO_XLSX?c.ALL:t===u.EXPORT_PAGE_TO_PDF||t===u.EXPORT_PAGE_TO_XLS||t===u.EXPORT_PAGE_TO_XLSX?c.PAGE:c.SELECTION}async dispatchExporter(t){var e,i,s,r;const n=this.getOptionKey(t),l=null!==(e=p[n])&&void 0!==e?e:p.EXPORT_TO_PDF,a={methodName:u[`EXPORT_TO_${l}`],fileName:this._appLabel,gridTitle:this._appLabel,exportOption:t,limit:null===(s=null===(i=this.provider)||void 0===i?void 0:i.getExportLimit)||void 0===s?void 0:s.call(i),type:this.getExportType(t),xlsxExtension:null!==(r=null==n?void 0:n.includes("XLSX"))&&void 0!==r&&r};await this.resolveExporter(a,(t=>{t.canExport||l===p.EXPORT_TO_PDF?function({fileSessionKey:t,isDownload:e}){const i=o.getContextValue("__SNK__APPLICATION__");window.open(`${window.location.protocol}//${window.location.hostname}:${window.location.port}/mge/visualizadorArquivos.mge?chaveArquivo=${t}${e?"&download=S":""}`),d.info(function(t){var e;return null===(e=null==t?void 0:t.messagesBuilder)||void 0===e?void 0:e.getMessage("fileViewer.message.exportSuccess",void 0)}(i),{iconName:"check"})}(Object.assign(Object.assign({},t),{fileType:l})):d.error(this.getMessage("snkDataExporter.title.permission"),this.getMessage("snkDataExporter.message.exportPermission"))}))}async processExporter(t){var e,i,s,o,r,n,l;const a=null==t?void 0:t.detail,c=[u.EXPORT_PAGE_TO_PDF,u.EXPORT_PAGE_TO_XLS,u.EXPORT_PAGE_TO_XLSX],p=null===(e=null==a?void 0:a.id)||void 0===e?void 0:e.includes(this._customPrefix);if((null==a?void 0:a.id)===u.EXPORT_CURRENT_PAGE)return;const m=null===(i=this.provider)||void 0===i?void 0:i.getSelectedIDs(),v=null===(s=this.provider)||void 0===s?void 0:s.getTotalRecords(),x=null===(r=null===(o=this.provider)||void 0===o?void 0:o.getPageSize)||void 0===r?void 0:r.call(o),g=null===(l=null===(n=this.provider)||void 0===n?void 0:n.getExportLimit)||void 0===l?void 0:l.call(n);let f=!1;if(c.includes(null==a?void 0:a.id)&&x<=g||p?f=!1:(null==m?void 0:m.length)?f=m.length>g:v>g&&(f=!0),f){const t=g.toLocaleString("pt-BR",{minimumFractionDigits:0}),e={title:this.getMessage("snkDataExporter.limitExceeded.title"),description:`\n ${this.getMessage("snkDataExporter.limitExceeded.description",{limit:t})}\n <br/><br/>\n <b>\n ${this.getMessage("snkDataExporter.limitExceeded.subdescription")}\n </b>\n `,cancel:this.getMessage("snkDataExporter.limitExceeded.cancel"),confirm:this.getMessage("snkDataExporter.limitExceeded.continue")};if(!await d.confirm(e.title,e.description,null,h.WARN,{labelCancel:e.cancel,labelConfirm:e.confirm}))return}if(p)return this.openPersonalizedReports(a.id),void(this._showDropdown=!1);this.getFilteredReleasedToExport().includes(null==a?void 0:a.id)&&(a.id===u.EXPORT_BY_EMAIL?this.exportByEmail():this.dispatchExporter(a.id),this._showDropdown=!1)}getFilteredReleasedToExport(){var t,e;if(null==this.provider)return this._releasedToExport;const i=null===(e=(t=this.provider).getHiddenOptions)||void 0===e?void 0:e.call(t);return null==i?this._releasedToExport:this._releasedToExport.filter((t=>!i.includes(t)))}loadItems(){const t=[];this.getFilteredReleasedToExport().forEach((e=>{var i;null===(i=this._itemBuilder)||void 0===i||i.setExportOption(e,t)})),this.loadPersonalizedItems(t)}async loadPersonalizedItems(t){var e,i;const s=null===(i=null===(e=this.provider)||void 0===e?void 0:e.getRecordID)||void 0===i?void 0:i.call(e);if(null==s)return void(this._items=t);const n=await function(t){const e=`${o.getContextValue("__SNK__APPLICATION__").getModuleName()}@DataExporterSPBean.getPersonalizedReports`,i={serviceName:e,requestBody:t};return new Promise(((t,s)=>x.get().callServiceBroker(e,r.objectToString(i)).then((e=>t(function(t){var e;const i=null===(e=null==t?void 0:t.json)||void 0===e?void 0:e.$;if(null!=i)return r.stringToObject(i)}(e)))).catch((t=>s(t)))))}({recordID:s});null==n||n.forEach((e=>{t.push({id:`${this._customPrefix}_${e.ID}`,label:e.label,group:this.getMessage("snkDataExporter.group.custom")})})),this._items=t}openPersonalizedReports(t){var e,i;const s=[],o=(null==t?void 0:t.replace(this._customPrefix,""))||"";null===(i=null===(e=this.provider)||void 0===e?void 0:e.getSelectedIDs)||void 0===i||i.call(e).forEach((({name:t,type:e,value:i},o)=>{const r={fields:[]};0===o&&(s[`PK_${t}`]={type:this.parseDataType(e),value:i},s.pks=[]);const n={nome:`PK_${t}`,tipo:this.parseDataType(e),valor:i};r.fields.push(n),s.pks.push(r)})),this._application.openApp(`${v}${o}`,s)}parseDataType(t){switch(t){case l.NUMBER:return"I";case l.DATE:return"D";default:return"S"}}loadDropdown(){var t;this._selectedNumber=(null===(t=this.provider)||void 0===t?void 0:t.getSelectedNumber())||0,this._itemBuilder=new f(this.getMessage.bind(this),this._selectedNumber),this.loadItems()}getElementID(t){return{[a.DATA_ELEMENT_ID_ATTRIBUTE_NAME]:a.getInternalIDInfo(t)}}canShowDropdown(){var t;return this._showDropdown&&(null===(t=this._items)||void 0===t?void 0:t.length)>0}componentWillLoad(){var t;this._application=o.getContextValue("__SNK__APPLICATION__"),null===(t=this._application)||void 0===t||t.getAppLabel().then((t=>this._appLabel=t)),this.setEvents()}componentDidLoad(){null!=this._element&&(a.addIDInfo(this._element),this.positionDropdown())}componentWillUpdate(){var t;this._showDropdown&&!(null===(t=this._items)||void 0===t?void 0:t.length)&&this.loadDropdown()}componentDidUpdate(){var t;this._showDropdown?this.positionDropdown():(null===(t=this._items)||void 0===t?void 0:t.length)>0&&(this._items=[])}render(){return e(i,null,e("div",{class:`snk-data-exporter\n ${this.canShowDropdown()?" ez-elevation--16":""}\n `},e("ez-tooltip",{message:this.getMessage("snkDataExporter.group.export.title")},e("ez-button",Object.assign({ref:t=>this._ezButton=t,iconName:"file-download",mode:"icon",onClick:()=>this.controlDropdown(),size:this.size},this.getElementID("button")))),e("div",Object.assign({ref:t=>this._dropdownParent=t,class:`snk-data-exporter__dropdown\n ${this.canShowDropdown()?"snk-data-exporter__dropdown--show":""}\n `},this.getElementID("dropdown")),this.canShowDropdown()&&e("ez-dropdown",Object.assign({items:this._items,onEzClick:t=>this.processExporter(t)},this.getElementID("dropdown"))))),this.canShowDropdown()&&e("div",Object.assign({class:"ez-scrim ez-scrim--light"},this.getElementID("ezScrim"))),e("snk-exporter-email-sender",Object.assign({ref:t=>this._snkEmailSender=t,getMessage:(t,e)=>this.getMessage(t,e)},this.getElementID("snkExporterEmailSender"))))}get _element(){return s(this)}};y.style=".sc-snk-data-exporter-h{display:flex;width:fit-content;height:fit-content}.snk-data-exporter.sc-snk-data-exporter{display:flex;width:fit-content;height:fit-content}.snk-data-exporter__dropdown.sc-snk-data-exporter{display:none}.snk-data-exporter__dropdown--show.sc-snk-data-exporter{display:flex;flex-direction:column;position:fixed}.snk-data-exporter__dropdown.sc-snk-data-exporter>ez-dropdown.sc-snk-data-exporter{position:relative}";export{y as snk_data_exporter}
@@ -1,4 +1,4 @@
1
- import{r as t,e,h as i,f as s,g as n}from"./p-2c9d0870.js";import{DateUtils as r,StringUtils as a,ObjectUtils as o,WaitingChangeException as h,SilentException as l,WarningException as c,ErrorException as d,ElementIDUtils as u,SearchUtils as p,ArrayUtils as m,KeyboardManager as g,OnboardingUtils as w,DependencyType as y,DataType as v,ApplicationContext as f,ErrorTracking as P,UserAgentUtils as k,LockManager as z,LockManagerOperation as _}from"@sankhyalabs/core";import{ApplicationUtils as x}from"@sankhyalabs/ezui/dist/collection/utils";import{C as A}from"./p-13f91e7e.js";import{d as S,D as b,U as I,S as T}from"./p-10d883b0.js";import{A as O,a as L}from"./p-c3bc693a.js";import{P as N,D as E}from"./p-c1e168a2.js";import{P as C}from"./p-3190ac29.js";import{T as D}from"./p-9019a32f.js";import"./p-0f3698af.js";import"./p-ff1990ad.js";import{F as R}from"./p-d7657667.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 F{static webConnectionCaller(t,e,i){var s;null===(s=window.AppletCaller)||void 0===s||s.webConnectionCaller(t,e,i)}}const M=U;function U(t,e){const i=j();return(U=function(t){return i[t-=378]})(t,e)}function j(){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(j=function(){return t})()}!function(){const t=U,e=j();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;e.push(e.shift())}catch(t){e.push(e.shift())}}();class ${[M(397)](t){const e=M;if(typeof(t=utxt(t[e(390)]))==e(392)&&(t=JSON[e(400)](t)),null==t)throw Error(e(395));const i=new H("S"===t[e(402)]||!0===t[e(402)]);return Array[e(394)](t[e(391)])&&t[e(391)][e(385)]((t=>i.putAccess(t[e(382)],String(t.status)==e(398)))),i}}class H{constructor(t){const e=M;this.isSup=t,this[e(384)]={}}[M(378)](t,e){this[M(384)][t]=e}[M(393)](t){const e=M;if(this[e(402)])return!0;let i=!0;return this[e(384)][e(380)](t)&&(i=this.actions[t]),i}isUserSup(){return this.isSup}}class B{constructor(){this._embeddedParams=new Map,this._cachedParams=new Map,this.templateByQuery=new Map;try{if(null!=window.MGE_PARAMS){atob(window.MGE_PARAMS).split("__;__").forEach((t=>{const[e,i]=t.split("__=__");this._embeddedParams.set(e,i)}))}}catch(t){console.error("Problemas ao obter parâmetros embarcados"),console.error(t)}this.buldTemplates()}buldTemplates(){this.templateByQuery.set("fetchParam",S.gql`query($name: String!) {
1
+ import{r as t,e,h as i,f as s,g as n}from"./p-2c9d0870.js";import{DateUtils as r,StringUtils as a,ObjectUtils as o,WaitingChangeException as h,SilentException as l,WarningException as c,ErrorException as d,ElementIDUtils as u,SearchUtils as p,ArrayUtils as m,KeyboardManager as g,OnboardingUtils as w,DependencyType as y,DataType as v,ApplicationContext as f,ErrorTracking as P,UserAgentUtils as k,LockManager as z,LockManagerOperation as _}from"@sankhyalabs/core";import{ApplicationUtils as x}from"@sankhyalabs/ezui/dist/collection/utils";import{C as A}from"./p-8d81c8d3.js";import{d as S,D as b,U as I,S as T}from"./p-4dd574d6.js";import{A as O,a as L}from"./p-9e02a785.js";import{P as N,D as E}from"./p-8d1ef77a.js";import{P as C}from"./p-097d75b3.js";import{T as D}from"./p-9019a32f.js";import"./p-abcb646d.js";import"./p-ff1990ad.js";import{F as R}from"./p-ec7c87bb.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 F{static webConnectionCaller(t,e,i){var s;null===(s=window.AppletCaller)||void 0===s||s.webConnectionCaller(t,e,i)}}const M=U;function U(t,e){const i=j();return(U=function(t){return i[t-=378]})(t,e)}function j(){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(j=function(){return t})()}!function(){const t=U,e=j();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;e.push(e.shift())}catch(t){e.push(e.shift())}}();class ${[M(397)](t){const e=M;if(typeof(t=utxt(t[e(390)]))==e(392)&&(t=JSON[e(400)](t)),null==t)throw Error(e(395));const i=new H("S"===t[e(402)]||!0===t[e(402)]);return Array[e(394)](t[e(391)])&&t[e(391)][e(385)]((t=>i.putAccess(t[e(382)],String(t.status)==e(398)))),i}}class H{constructor(t){const e=M;this.isSup=t,this[e(384)]={}}[M(378)](t,e){this[M(384)][t]=e}[M(393)](t){const e=M;if(this[e(402)])return!0;let i=!0;return this[e(384)][e(380)](t)&&(i=this.actions[t]),i}isUserSup(){return this.isSup}}class B{constructor(){this._embeddedParams=new Map,this._cachedParams=new Map,this.templateByQuery=new Map;try{if(null!=window.MGE_PARAMS){atob(window.MGE_PARAMS).split("__;__").forEach((t=>{const[e,i]=t.split("__=__");this._embeddedParams.set(e,i)}))}}catch(t){console.error("Problemas ao obter parâmetros embarcados"),console.error(t)}this.buldTemplates()}buldTemplates(){this.templateByQuery.set("fetchParam",S.gql`query($name: String!) {
2
2
  $queryAlias$: fetchResource(name: $name){
3
3
  name
4
4
  resource
@@ -0,0 +1 @@
1
+ var o,e,r,t,a;!function(o){o.PRIMARY="primary",o.SECONDARY="secondary",o.SINGLE_TASKBAR="singleTaskbar"}(o||(o={})),function(o){o.EXPORT_TO_PDF="exportToPDF",o.EXPORT_TO_XLS="exportToXLS",o.EXPORT_TO_XLSX="exportToXLSX",o.EXPORT_CURRENT_PAGE="exportCurrentPage",o.EXPORT_ALL_RECORDS="exportAllRecords",o.EXPORT_PAGE_TO_PDF="exportPageToPDF",o.EXPORT_PAGE_TO_XLS="exportPageToXLS",o.EXPORT_PAGE_TO_XLSX="exportPageToXLSX",o.EXPORT_ALL_RECORDS_TO_PDF="exportAllRecordsToPDF",o.EXPORT_ALL_RECORDS_TO_XLS="exportAllRecordsToXLS",o.EXPORT_ALL_RECORDS_TO_XLSX="exportAllRecordsToXLSX",o.EXPORT_BY_EMAIL="exportToEmail",o.EXPORT_PDF_TO_EMAIL="exportPDFToEmail",o.EXPORT_XLS_TO_EMAIL="exportXLSToEmail"}(e||(e={})),function(o){o.PDF="exportPDFToEmail",o.XLS="exportXLSToEmail",o.XLSX="exportXLSToEmail"}(r||(r={})),function(o){o.EXPORT_TO_PDF="PDF",o.EXPORT_TO_XLS="XLS",o.EXPORT_TO_XLSX="XLS",o.EXPORT_PAGE_TO_PDF="PDF",o.EXPORT_PAGE_TO_XLS="XLS",o.EXPORT_PAGE_TO_XLSX="XLS",o.EXPORT_ALL_RECORDS_TO_PDF="PDF",o.EXPORT_ALL_RECORDS_TO_XLS="XLS",o.EXPORT_ALL_RECORDS_TO_XLSX="XLS",o.EXPORT_PDF_TO_EMAIL="PDF",o.EXPORT_XLS_TO_EMAIL="XLS"}(t||(t={})),function(o){o.SERVER_SIDE="ServerSideExporterStrategy",o.CLIENT_SIDE="ClientSideExporterStrategy"}(a||(a={}));export{e as D,a as E,o as P,t as a,r as b}
@@ -1 +1 @@
1
- import{D as t}from"./p-10d883b0.js";import"./p-3190ac29.js";import{SortMode as i,ApplicationContext as s,ObjectUtils as e,StringUtils as r,NumberUtils as n,DataType as o,UserInterface as l,DateUtils as a}from"@sankhyalabs/core";import{D as u}from"./p-0f3698af.js";import"@sankhyalabs/ezui/dist/collection/utils/constants";import{UserInterface as d}from"@sankhyalabs/core/dist/dataunit/metadata/UnitMetadata";import{P as c}from"./p-c1e168a2.js";import"./p-ff1990ad.js";import"./p-d7657667.js";import"./p-9019a32f.js";import{g as h}from"./p-7dd49d15.js";import{I as f}from"./p-8f3f2306.js";import v from"@sankhyalabs/ezui/dist/collection/components/ez-grid/utils/InMemoryFilterColumnDataSource";class m{static assertDefaultSorting(t,s){t&&s&&(s.defaultSorting=t.columns.filter((t=>null!=t.ascending)).sort(((t,i)=>t.orderIndex-i.orderIndex)).reduce(((t,{name:e,ascending:r})=>{const n=s.getField(e);return n&&t.push({field:e,dataType:n.dataType,mode:r?i.ASC:i.DESC}),t}),[]))}static parseCrudResults(t,i){Array.isArray(t)||(t=[t]);const s=[];for(const e of t){let t={fields:new Map};for(let s in e){let r=e[s];if(r.hasOwnProperty("$")&&t.fields.set(s,r.$),i)break}s.push(t)}return s.length>1?s:s[0]}static find(i,e,r,n=!0,o,l){let a=[],u=[],d={},c=s.getContextValue("__SNK__APPLICATION__");if(e){if(!Array.isArray(e))throw new Error(c.messagesBuilder.getMessage("crudUtils.errorArray",null));e.forEach((t=>{a.push({name:t})}))}if(r)for(const t in r)r.hasOwnProperty(t)&&u.push({nome:t,valor:r[t]});o&&(d={expression:{$:o}});let h={requestBody:{entity:{name:i,criterio:u,fields:{field:a},literalCriteria:d,orderby:l}}};return new Promise((i=>{t.get().callServiceBroker("mge@crud.find",JSON.stringify(h)).then((t=>{var s;let e=null===(s=t.entidades)||void 0===s?void 0:s.entidade;e||i(null);const r=this.parseCrudResults(e,n);i(r)}))}))}}class p{setGrid(t){this._grid||(this._grid=t,this.refreshSelectedRows())}setDataState(t){this._dataState&&e.equals(null==t?void 0:t.metadataByRow,this._dataState.metadataByRow)||(this._dataState=t,this.refreshSelectedRows())}format(t,i,s){var e;if(r.isEmpty(t))return t;const o=null===(e=this._dataState)||void 0===e?void 0:e.metadataByRow.get(s),l=null==o?void 0:o.getProp("rm_precision",i.name);if(l||0===l)return n.format(t,l,l);if(null==i?void 0:i.props){const s=null==i?void 0:i.props.get("precision"),e=null==i?void 0:i.props.get("prettyPrecision");if(void 0!==s&&void 0!==e)return n.format(t,s,e)}return t}refreshSelectedRows(){var t;null===(t=this._grid)||void 0===t||t.refreshSelectedRows()}}class b{constructor(t,i){this.MAX_WIDTH_COD=60,this.MIN_WIDTH_COD=10,this.DEFAULT_FONT_SIZE=13,this.dataUnit=t,this.grid=i}async getColumnsMetadata(){var t;return this.columnsState=await(null===(t=this.grid)||void 0===t?void 0:t.getColumnsState())||[],await this.buildColumnsMetadata(this.columnsState)}getColumnsState(){return this.columnsState}async buildColumnsMetadata(t){var i;const s=[],e=this.collectSearchPlusDescriptionIds(t),r=new Map(t.map((t=>[t.name,t])));for(const n of t){if(this.isHiddenColumn(n))continue;if(e.has(n.name))continue;const t=null===(i=this.dataUnit)||void 0===i?void 0:i.getField(n.name),o=await this.grid.getCustomValueFormatter(n.name),l=this.isSearchUserInterface(t),a=l?"Cód. ":n.label;let u={id:n.name,label:a,width:l?a.length*this.DEFAULT_FONT_SIZE:n.width,type:null==t?void 0:t.dataType,userInterface:null==t?void 0:t.userInterface,customFormatter:o},d=l?this.buildDescriptionColumn(t,n):void 0;if(d){const t=r.get(d.id);if(null==t?void 0:t.width)u=Object.assign(Object.assign({},u),{width:Math.min(u.width,this.MAX_WIDTH_COD)}),d=Object.assign(Object.assign({},d),{width:t.width,label:(null==d?void 0:d.label)||(null==n?void 0:n.label)});else{const t=this.getWidthByMetaData(null==n?void 0:n.width,null==u?void 0:u.width,null==d?void 0:d.width);u=Object.assign(Object.assign({},u),{width:null==t?void 0:t.codWidth}),d=Object.assign(Object.assign({},d),{width:null==t?void 0:t.descWidth,label:(null==d?void 0:d.label)||(null==n?void 0:n.label)})}}s.push(u),d&&s.push(d)}return s||[]}collectSearchPlusDescriptionIds(t){var i;const s=new Set;for(const e of t){if(this.isHiddenColumn(e))continue;const t=null===(i=this.dataUnit)||void 0===i?void 0:i.getField(e.name);if(!this.isSearchUserInterface(t))continue;const r=this.buildDescriptionColumnId(t);r&&s.add(r)}return s}isHiddenColumn(t){return t.hidden&&"RECDESP"!==t.name}isSearchUserInterface(t){return(null==t?void 0:t.userInterface)===d.SEARCH||(null==t?void 0:t.userInterface)===d.SEARCHPLUS}buildDescriptionColumnId(t){const i=null==t?void 0:t.properties;if(null==(null==i?void 0:i.DESCRIPTIONFIELD))return;const s=`${i.ENTITYNAME}.${i.DESCRIPTIONFIELD}`;return i.mergedFrom?`${i.mergedFrom}.${s}`:s}buildDescriptionColumn(t,i){var s;const e=this.buildDescriptionColumnId(t);if(!e)return;const r=null===(s=null==t?void 0:t.properties)||void 0===s?void 0:s.DESCRIPTIONENTITY;return{id:e,label:r,width:r?r.length*this.DEFAULT_FONT_SIZE-60:i.width,type:o.TEXT,userInterface:d.LONGTEXT,descriptionFrom:t.name}}getWidthByMetaData(t,i,s){const e=i+s,r=s/e;let n=Math.round(t*(i/e)),o=Math.round(t*r);return n>this.MAX_WIDTH_COD?(n=this.MAX_WIDTH_COD,o=t-this.MAX_WIDTH_COD):n<this.MIN_WIDTH_COD&&(n=this.MIN_WIDTH_COD,o=t-this.MIN_WIDTH_COD),{codWidth:n,descWidth:o}}}class y extends b{getSelectedNumber(){return this.dataUnit.getSelectionInfo().length}getTotalRecords(){var t,i,s;const{total:e}=(null===(t=this.dataUnit)||void 0===t?void 0:t.getPaginationInfo())||{};return null!=e?e:null===(s=null===(i=this.dataUnit)||void 0===i?void 0:i.records)||void 0===s?void 0:s.length}getSelectedIDs(){return h(this.dataUnit)}getRecordID(){var t,i,s;return null===(s=null===(i=null===(t=this.dataUnit)||void 0===t?void 0:t.records)||void 0===i?void 0:i[0])||void 0===s?void 0:s.__record__id__}async getRecords(t){if(0===this.dataUnit.records.length)return[];switch(t){case f.ALL:return this.dataUnit.getSelectionInfo().getAllRecords();case f.SELECTION:return this.resolveRecordsFromSelection();case f.PAGE:return this.dataUnit.records;default:return this.resolveRecordsFromSelection()}}resolveRecordsFromSelection(){const t=this.dataUnit.getSelectionInfo();if(t.isEmpty())return this.dataUnit.records;const i=t.isAllRecords()?t.getAllRecords():t.records;return i.length?i:this.dataUnit.records}getHiddenOptions(){return[u.EXPORT_BY_EMAIL,u.EXPORT_PDF_TO_EMAIL,u.EXPORT_XLS_TO_EMAIL,u.EXPORT_PAGE_TO_PDF,u.EXPORT_PAGE_TO_XLS]}formatValue(t,i){const{id:s,descriptionFrom:e}=i,r=t[e||s];if(null==r)return"";if(null!=e)return r.label;if(this.dataUnit.getField(s).userInterface===l.SEARCH)return r.value;if(i.customFormatter){const s=this.getColumnsState().find((t=>i.id===t.name));return i.customFormatter.format(r,s,t.__record__id__)}return this.dataUnit.getFormattedValue(s,r)}}class w{constructor(t){this._defaultButtons=t}process(t,i,s,e=[],r=[]){var n;this.customButtons=new Map,this.buttons="",this.disabledButtons=[].concat(e),null===(n=this.getButtonsArray(t,i,s))||void 0===n||n.forEach((n=>{let o;if("string"==typeof n)o=n;else{const t=n;this.customButtons.set(t.name,t),o=t.name}r.includes(o)||(this.isEnabled(t,i,o,s,e)||this.disabledButtons.push(o),this.buttons.length>0&&(this.buttons+=","),this.buttons+=o)}))}getButtonsArray(t,i,s){const e=this.getButtonsFromKey(t);return i?i.getButtons(t,s,[...e]):e}getButtonsFromKey(t){const i=this._defaultButtons[t];return"function"==typeof i?i():i}isEnabled(t,i,s,e,r){const n=!r.includes(s);return i&&i.isEnabled?i.isEnabled(t,e,s,n):n}}class g{setDataUnit(t){this._dataUnit=t}setApplication(t){this._application=t}formatLabel(t,i){const{userInterface:s}=this._dataUnit.getField(t);return s===l.DATETIME?a.formatDate(this._dataUnit.valueFromString(t,i)):String(this._dataUnit.getFormattedValue(t,i))}async getStaticOptions(t,i){return Promise.resolve(null==t?void 0:await c.getDistinct(this._dataUnit,t,null==i?void 0:i.onlyLabel))}fetchData(t,i){return new Promise((s=>{this._application.executeSelectDistinct(this._dataUnit,i,t).then((t=>{s(t.map((t=>this._dataUnit.getField(i).userInterface===l.SEARCH?Object.assign(Object.assign({},JSON.parse(t)),{check:!0}):{value:t,label:this.formatLabel(i,t),check:!0})))}))}))}sortItems(t,i){return v.defaultSorterMultSelectionOption(this._dataUnit,t,i)}}export{b as C,p as R,g as S,w as T,m as a,y as b}
1
+ import{D as t}from"./p-4dd574d6.js";import"./p-097d75b3.js";import{SortMode as i,ApplicationContext as s,ObjectUtils as e,StringUtils as r,NumberUtils as n,DataType as o,UserInterface as l,DateUtils as a}from"@sankhyalabs/core";import{D as u}from"./p-abcb646d.js";import"@sankhyalabs/ezui/dist/collection/utils/constants";import{UserInterface as d}from"@sankhyalabs/core/dist/dataunit/metadata/UnitMetadata";import{P as c}from"./p-8d1ef77a.js";import"./p-ff1990ad.js";import"./p-ec7c87bb.js";import"./p-9019a32f.js";import{g as h}from"./p-7dd49d15.js";import{I as f}from"./p-8f3f2306.js";import v from"@sankhyalabs/ezui/dist/collection/components/ez-grid/utils/InMemoryFilterColumnDataSource";class m{static assertDefaultSorting(t,s){t&&s&&(s.defaultSorting=t.columns.filter((t=>null!=t.ascending)).sort(((t,i)=>t.orderIndex-i.orderIndex)).reduce(((t,{name:e,ascending:r})=>{const n=s.getField(e);return n&&t.push({field:e,dataType:n.dataType,mode:r?i.ASC:i.DESC}),t}),[]))}static parseCrudResults(t,i){Array.isArray(t)||(t=[t]);const s=[];for(const e of t){let t={fields:new Map};for(let s in e){let r=e[s];if(r.hasOwnProperty("$")&&t.fields.set(s,r.$),i)break}s.push(t)}return s.length>1?s:s[0]}static find(i,e,r,n=!0,o,l){let a=[],u=[],d={},c=s.getContextValue("__SNK__APPLICATION__");if(e){if(!Array.isArray(e))throw new Error(c.messagesBuilder.getMessage("crudUtils.errorArray",null));e.forEach((t=>{a.push({name:t})}))}if(r)for(const t in r)r.hasOwnProperty(t)&&u.push({nome:t,valor:r[t]});o&&(d={expression:{$:o}});let h={requestBody:{entity:{name:i,criterio:u,fields:{field:a},literalCriteria:d,orderby:l}}};return new Promise((i=>{t.get().callServiceBroker("mge@crud.find",JSON.stringify(h)).then((t=>{var s;let e=null===(s=t.entidades)||void 0===s?void 0:s.entidade;e||i(null);const r=this.parseCrudResults(e,n);i(r)}))}))}}class p{setGrid(t){this._grid||(this._grid=t,this.refreshSelectedRows())}setDataState(t){this._dataState&&e.equals(null==t?void 0:t.metadataByRow,this._dataState.metadataByRow)||(this._dataState=t,this.refreshSelectedRows())}format(t,i,s){var e;if(r.isEmpty(t))return t;const o=null===(e=this._dataState)||void 0===e?void 0:e.metadataByRow.get(s),l=null==o?void 0:o.getProp("rm_precision",i.name);if(l||0===l)return n.format(t,l,l);if(null==i?void 0:i.props){const s=null==i?void 0:i.props.get("precision"),e=null==i?void 0:i.props.get("prettyPrecision");if(void 0!==s&&void 0!==e)return n.format(t,s,e)}return t}refreshSelectedRows(){var t;null===(t=this._grid)||void 0===t||t.refreshSelectedRows()}}class b{constructor(t,i){this.MAX_WIDTH_COD=60,this.MIN_WIDTH_COD=10,this.DEFAULT_FONT_SIZE=13,this.dataUnit=t,this.grid=i}async getColumnsMetadata(){var t;return this.columnsState=await(null===(t=this.grid)||void 0===t?void 0:t.getColumnsState())||[],await this.buildColumnsMetadata(this.columnsState)}getColumnsState(){return this.columnsState}async buildColumnsMetadata(t){var i;const s=[],e=this.collectSearchPlusDescriptionIds(t),r=new Map(t.map((t=>[t.name,t])));for(const n of t){if(this.isHiddenColumn(n))continue;if(e.has(n.name))continue;const t=null===(i=this.dataUnit)||void 0===i?void 0:i.getField(n.name),o=await this.grid.getCustomValueFormatter(n.name),l=this.isSearchUserInterface(t),a=l?"Cód. ":n.label;let u={id:n.name,label:a,width:l?a.length*this.DEFAULT_FONT_SIZE:n.width,type:null==t?void 0:t.dataType,userInterface:null==t?void 0:t.userInterface,customFormatter:o},d=l?this.buildDescriptionColumn(t,n):void 0;if(d){const t=r.get(d.id);if(null==t?void 0:t.width)u=Object.assign(Object.assign({},u),{width:Math.min(u.width,this.MAX_WIDTH_COD)}),d=Object.assign(Object.assign({},d),{width:t.width,label:(null==d?void 0:d.label)||(null==n?void 0:n.label)});else{const t=this.getWidthByMetaData(null==n?void 0:n.width,null==u?void 0:u.width,null==d?void 0:d.width);u=Object.assign(Object.assign({},u),{width:null==t?void 0:t.codWidth}),d=Object.assign(Object.assign({},d),{width:null==t?void 0:t.descWidth,label:(null==d?void 0:d.label)||(null==n?void 0:n.label)})}}s.push(u),d&&s.push(d)}return s||[]}collectSearchPlusDescriptionIds(t){var i;const s=new Set;for(const e of t){if(this.isHiddenColumn(e))continue;const t=null===(i=this.dataUnit)||void 0===i?void 0:i.getField(e.name);if(!this.isSearchUserInterface(t))continue;const r=this.buildDescriptionColumnId(t);r&&s.add(r)}return s}isHiddenColumn(t){return t.hidden&&"RECDESP"!==t.name}isSearchUserInterface(t){return(null==t?void 0:t.userInterface)===d.SEARCH||(null==t?void 0:t.userInterface)===d.SEARCHPLUS}buildDescriptionColumnId(t){const i=null==t?void 0:t.properties;if(null==(null==i?void 0:i.DESCRIPTIONFIELD))return;const s=`${i.ENTITYNAME}.${i.DESCRIPTIONFIELD}`;return i.mergedFrom?`${i.mergedFrom}.${s}`:s}buildDescriptionColumn(t,i){var s;const e=this.buildDescriptionColumnId(t);if(!e)return;const r=null===(s=null==t?void 0:t.properties)||void 0===s?void 0:s.DESCRIPTIONENTITY;return{id:e,label:r,width:r?r.length*this.DEFAULT_FONT_SIZE-60:i.width,type:o.TEXT,userInterface:d.LONGTEXT,descriptionFrom:t.name}}getWidthByMetaData(t,i,s){const e=i+s,r=s/e;let n=Math.round(t*(i/e)),o=Math.round(t*r);return n>this.MAX_WIDTH_COD?(n=this.MAX_WIDTH_COD,o=t-this.MAX_WIDTH_COD):n<this.MIN_WIDTH_COD&&(n=this.MIN_WIDTH_COD,o=t-this.MIN_WIDTH_COD),{codWidth:n,descWidth:o}}}class y extends b{getSelectedNumber(){return this.dataUnit.getSelectionInfo().length}getTotalRecords(){var t,i,s;const{total:e}=(null===(t=this.dataUnit)||void 0===t?void 0:t.getPaginationInfo())||{};return null!=e?e:null===(s=null===(i=this.dataUnit)||void 0===i?void 0:i.records)||void 0===s?void 0:s.length}getSelectedIDs(){return h(this.dataUnit)}getRecordID(){var t,i,s;return null===(s=null===(i=null===(t=this.dataUnit)||void 0===t?void 0:t.records)||void 0===i?void 0:i[0])||void 0===s?void 0:s.__record__id__}async getRecords(t){if(0===this.dataUnit.records.length)return[];switch(t){case f.ALL:return this.dataUnit.getSelectionInfo().getAllRecords();case f.SELECTION:return this.resolveRecordsFromSelection();case f.PAGE:return this.dataUnit.records;default:return this.resolveRecordsFromSelection()}}resolveRecordsFromSelection(){const t=this.dataUnit.getSelectionInfo();if(t.isEmpty())return this.dataUnit.records;const i=t.isAllRecords()?t.getAllRecords():t.records;return i.length?i:this.dataUnit.records}getHiddenOptions(){return[u.EXPORT_BY_EMAIL,u.EXPORT_PDF_TO_EMAIL,u.EXPORT_XLS_TO_EMAIL,u.EXPORT_PAGE_TO_PDF,u.EXPORT_PAGE_TO_XLS]}formatValue(t,i){const{id:s,descriptionFrom:e}=i,r=t[e||s];if(null==r)return"";if(null!=e)return r.label;if(this.dataUnit.getField(s).userInterface===l.SEARCH)return r.value;if(i.customFormatter){const s=this.getColumnsState().find((t=>i.id===t.name));return i.customFormatter.format(r,s,t.__record__id__)}return this.dataUnit.getFormattedValue(s,r)}}class w{constructor(t){this._defaultButtons=t}process(t,i,s,e=[],r=[]){var n;this.customButtons=new Map,this.buttons="",this.disabledButtons=[].concat(e),null===(n=this.getButtonsArray(t,i,s))||void 0===n||n.forEach((n=>{let o;if("string"==typeof n)o=n;else{const t=n;this.customButtons.set(t.name,t),o=t.name}r.includes(o)||(this.isEnabled(t,i,o,s,e)||this.disabledButtons.push(o),this.buttons.length>0&&(this.buttons+=","),this.buttons+=o)}))}getButtonsArray(t,i,s){const e=this.getButtonsFromKey(t);return i?i.getButtons(t,s,[...e]):e}getButtonsFromKey(t){const i=this._defaultButtons[t];return"function"==typeof i?i():i}isEnabled(t,i,s,e,r){const n=!r.includes(s);return i&&i.isEnabled?i.isEnabled(t,e,s,n):n}}class g{setDataUnit(t){this._dataUnit=t}setApplication(t){this._application=t}formatLabel(t,i){const{userInterface:s}=this._dataUnit.getField(t);return s===l.DATETIME?a.formatDate(this._dataUnit.valueFromString(t,i)):String(this._dataUnit.getFormattedValue(t,i))}async getStaticOptions(t,i){return Promise.resolve(null==t?void 0:await c.getDistinct(this._dataUnit,t,null==i?void 0:i.onlyLabel))}fetchData(t,i){return new Promise((s=>{this._application.executeSelectDistinct(this._dataUnit,i,t).then((t=>{s(t.map((t=>this._dataUnit.getField(i).userInterface===l.SEARCH?Object.assign(Object.assign({},JSON.parse(t)),{check:!0}):{value:t,label:this.formatLabel(i,t),check:!0})))}))}))}sortItems(t,i){return v.defaultSorterMultSelectionOption(this._dataUnit,t,i)}}export{b as C,p as R,g as S,w as T,m as a,y as b}