@sankhyalabs/sankhyablocks 10.1.0-dev.14 → 10.1.0-dev.15
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.
- package/dist/cjs/{SnkMultiSelectionListDataSource-3f561345.js → SnkMultiSelectionListDataSource-72925620.js} +1 -1
- package/dist/cjs/config-header.cjs.entry.js +1 -1
- package/dist/cjs/configs-button.cjs.entry.js +1 -1
- package/dist/cjs/field-config_2.cjs.entry.js +1 -1
- package/dist/cjs/fields-layout.cjs.entry.js +1 -1
- package/dist/cjs/fields-selector.cjs.entry.js +1 -1
- package/dist/cjs/guides-configurator.cjs.entry.js +1 -1
- package/dist/cjs/{index-13d05f03.js → index-516250fa.js} +1 -1
- package/dist/cjs/{index-1cf293c1.js → index-dc83c596.js} +0 -17
- package/dist/cjs/loader.cjs.js +1 -1
- package/dist/cjs/pesquisa-grid_2.cjs.entry.js +1 -1
- package/dist/cjs/sankhyablocks.cjs.js +1 -1
- package/dist/cjs/snk-actions-button_9.cjs.entry.js +1 -1
- package/dist/cjs/snk-actions-form.cjs.entry.js +1 -1
- package/dist/cjs/snk-application.cjs.entry.js +1 -1
- package/dist/cjs/snk-attach.cjs.entry.js +3 -3
- package/dist/cjs/snk-client-confirm.cjs.entry.js +1 -1
- package/dist/cjs/snk-configurator.cjs.entry.js +1 -1
- package/dist/cjs/snk-crud.cjs.entry.js +3 -3
- package/dist/cjs/snk-custom-slot-elements.cjs.entry.js +1 -1
- package/dist/cjs/snk-custom-slot-guide.cjs.entry.js +1 -1
- package/dist/cjs/snk-data-exporter.cjs.entry.js +2 -2
- package/dist/cjs/{snk-data-unit-b8ea81e1.js → snk-data-unit-47f02b9e.js} +1 -1
- package/dist/cjs/snk-data-unit.cjs.entry.js +2 -2
- package/dist/cjs/snk-default-filter.cjs.entry.js +1 -1
- package/dist/cjs/snk-detail-view.cjs.entry.js +4 -4
- package/dist/cjs/snk-entity-list.cjs.entry.js +1 -1
- package/dist/cjs/snk-exporter-email-sender.cjs.entry.js +1 -1
- package/dist/cjs/snk-expression-group_2.cjs.entry.js +2 -2
- package/dist/cjs/snk-filter-advanced-mode_2.cjs.entry.js +1 -1
- package/dist/cjs/snk-filter-bar_4.cjs.entry.js +1 -1
- package/dist/cjs/snk-filter-binary-select.cjs.entry.js +1 -1
- package/dist/cjs/snk-filter-checkbox-list.cjs.entry.js +1 -1
- package/dist/cjs/snk-filter-detail.cjs.entry.js +1 -1
- package/dist/cjs/snk-filter-field-search_2.cjs.entry.js +1 -1
- package/dist/cjs/snk-filter-modal-item.cjs.entry.js +1 -1
- package/dist/cjs/snk-filter-multi-select.cjs.entry.js +1 -1
- package/dist/cjs/snk-filter-number.cjs.entry.js +1 -1
- package/dist/cjs/snk-filter-period.cjs.entry.js +1 -1
- package/dist/cjs/snk-filter-search.cjs.entry.js +1 -1
- package/dist/cjs/snk-filter-text.cjs.entry.js +1 -1
- package/dist/cjs/snk-form-summary.cjs.entry.js +1 -1
- package/dist/cjs/snk-form-view.cjs.entry.js +1 -1
- package/dist/cjs/snk-form_2.cjs.entry.js +1 -1
- package/dist/cjs/snk-grid.cjs.entry.js +15 -9
- package/dist/cjs/{snk-guides-viewer-61701970.js → snk-guides-viewer-41c22d96.js} +2 -2
- package/dist/cjs/snk-guides-viewer.cjs.entry.js +4 -4
- package/dist/cjs/snk-personalized-filter-editor.cjs.entry.js +1 -1
- package/dist/cjs/snk-personalized-filter.cjs.entry.js +2 -2
- package/dist/cjs/snk-pesquisa.cjs.entry.js +1 -1
- package/dist/cjs/snk-print-selector.cjs.entry.js +1 -1
- package/dist/cjs/snk-simple-bar.cjs.entry.js +1 -1
- package/dist/cjs/snk-simple-crud.cjs.entry.js +4 -4
- package/dist/cjs/snk-taskbar.cjs.entry.js +3 -3
- package/dist/cjs/{taskbar-elements-fb5d1e08.js → taskbar-elements-756fcbe7.js} +2 -2
- package/dist/cjs/teste-pesquisa.cjs.entry.js +1 -1
- package/dist/collection/components/snk-grid/snk-grid.js +12 -7
- package/dist/components/snk-grid2.js +12 -6
- package/dist/esm/{SnkMultiSelectionListDataSource-2d1ea0c5.js → SnkMultiSelectionListDataSource-493ae8c8.js} +1 -1
- package/dist/esm/config-header.entry.js +1 -1
- package/dist/esm/configs-button.entry.js +1 -1
- package/dist/esm/field-config_2.entry.js +1 -1
- package/dist/esm/fields-layout.entry.js +1 -1
- package/dist/esm/fields-selector.entry.js +1 -1
- package/dist/esm/guides-configurator.entry.js +1 -1
- package/dist/esm/{index-446f9341.js → index-3355bd17.js} +1 -1
- package/dist/esm/{index-479e1293.js → index-7fd74680.js} +0 -17
- package/dist/esm/loader.js +2 -2
- package/dist/esm/pesquisa-grid_2.entry.js +1 -1
- package/dist/esm/sankhyablocks.js +2 -2
- package/dist/esm/snk-actions-button_9.entry.js +1 -1
- package/dist/esm/snk-actions-form.entry.js +1 -1
- package/dist/esm/snk-application.entry.js +1 -1
- package/dist/esm/snk-attach.entry.js +3 -3
- package/dist/esm/snk-client-confirm.entry.js +1 -1
- package/dist/esm/snk-configurator.entry.js +1 -1
- package/dist/esm/snk-crud.entry.js +3 -3
- package/dist/esm/snk-custom-slot-elements.entry.js +1 -1
- package/dist/esm/snk-custom-slot-guide.entry.js +1 -1
- package/dist/esm/snk-data-exporter.entry.js +2 -2
- package/dist/esm/{snk-data-unit-6f31ec56.js → snk-data-unit-9e9d9d46.js} +1 -1
- package/dist/esm/snk-data-unit.entry.js +2 -2
- package/dist/esm/snk-default-filter.entry.js +1 -1
- package/dist/esm/snk-detail-view.entry.js +4 -4
- package/dist/esm/snk-entity-list.entry.js +1 -1
- package/dist/esm/snk-exporter-email-sender.entry.js +1 -1
- package/dist/esm/snk-expression-group_2.entry.js +2 -2
- package/dist/esm/snk-filter-advanced-mode_2.entry.js +1 -1
- package/dist/esm/snk-filter-bar_4.entry.js +1 -1
- package/dist/esm/snk-filter-binary-select.entry.js +1 -1
- package/dist/esm/snk-filter-checkbox-list.entry.js +1 -1
- package/dist/esm/snk-filter-detail.entry.js +1 -1
- package/dist/esm/snk-filter-field-search_2.entry.js +1 -1
- package/dist/esm/snk-filter-modal-item.entry.js +1 -1
- package/dist/esm/snk-filter-multi-select.entry.js +1 -1
- package/dist/esm/snk-filter-number.entry.js +1 -1
- package/dist/esm/snk-filter-period.entry.js +1 -1
- package/dist/esm/snk-filter-search.entry.js +1 -1
- package/dist/esm/snk-filter-text.entry.js +1 -1
- package/dist/esm/snk-form-summary.entry.js +1 -1
- package/dist/esm/snk-form-view.entry.js +1 -1
- package/dist/esm/snk-form_2.entry.js +1 -1
- package/dist/esm/snk-grid.entry.js +15 -9
- package/dist/esm/{snk-guides-viewer-c31259f0.js → snk-guides-viewer-31ef5fc6.js} +2 -2
- package/dist/esm/snk-guides-viewer.entry.js +4 -4
- package/dist/esm/snk-personalized-filter-editor.entry.js +1 -1
- package/dist/esm/snk-personalized-filter.entry.js +2 -2
- package/dist/esm/snk-pesquisa.entry.js +1 -1
- package/dist/esm/snk-print-selector.entry.js +1 -1
- package/dist/esm/snk-simple-bar.entry.js +1 -1
- package/dist/esm/snk-simple-crud.entry.js +4 -4
- package/dist/esm/snk-taskbar.entry.js +3 -3
- package/dist/esm/{taskbar-elements-faaf5d8f.js → taskbar-elements-bf5b73f1.js} +2 -2
- package/dist/esm/teste-pesquisa.entry.js +1 -1
- package/dist/sankhyablocks/{p-6b9833c7.entry.js → p-02cb4829.entry.js} +1 -1
- package/dist/sankhyablocks/{p-af3aface.entry.js → p-0893a694.entry.js} +1 -1
- package/dist/sankhyablocks/{p-fa8c2485.entry.js → p-0da30fd9.entry.js} +1 -1
- package/dist/sankhyablocks/{p-4b1c26ae.js → p-156c9f38.js} +1 -1
- package/dist/sankhyablocks/{p-f35f2eb3.entry.js → p-17856827.entry.js} +1 -1
- package/dist/sankhyablocks/{p-b987e15d.js → p-1be69fd4.js} +1 -1
- package/dist/sankhyablocks/{p-e679c75a.entry.js → p-1dba30c9.entry.js} +1 -1
- package/dist/sankhyablocks/{p-21107f0d.entry.js → p-1e469905.entry.js} +1 -1
- package/dist/sankhyablocks/{p-96d45943.entry.js → p-227e82b2.entry.js} +1 -1
- package/dist/sankhyablocks/{p-7af6e6b8.entry.js → p-2624dfd2.entry.js} +1 -1
- package/dist/sankhyablocks/{p-99a11017.entry.js → p-301baf9c.entry.js} +1 -1
- package/dist/sankhyablocks/{p-52c0cade.entry.js → p-357e10e0.entry.js} +1 -1
- package/dist/sankhyablocks/{p-987cd79d.entry.js → p-35a26068.entry.js} +1 -1
- package/dist/sankhyablocks/{p-180716b2.entry.js → p-3671cdd4.entry.js} +1 -1
- package/dist/sankhyablocks/{p-27482793.entry.js → p-4575c4aa.entry.js} +1 -1
- package/dist/sankhyablocks/{p-3d41f5a8.entry.js → p-497ece60.entry.js} +1 -1
- package/dist/sankhyablocks/{p-5fd4f0f6.entry.js → p-4deb7f46.entry.js} +1 -1
- package/dist/sankhyablocks/{p-bdd4f02c.entry.js → p-4e9e570c.entry.js} +1 -1
- package/dist/sankhyablocks/{p-3b167a03.entry.js → p-516411de.entry.js} +1 -1
- package/dist/sankhyablocks/{p-162bddae.entry.js → p-522d36aa.entry.js} +1 -1
- package/dist/sankhyablocks/{p-825098c1.entry.js → p-56b1b397.entry.js} +1 -1
- package/dist/sankhyablocks/{p-3f68a254.js → p-59158ba4.js} +1 -1
- package/dist/sankhyablocks/{p-c98c79c3.entry.js → p-5c9bea92.entry.js} +1 -1
- package/dist/sankhyablocks/{p-91a9abb6.entry.js → p-613eb22e.entry.js} +1 -1
- package/dist/sankhyablocks/{p-49ddc27a.entry.js → p-670b8802.entry.js} +1 -1
- package/dist/sankhyablocks/{p-60dd1d27.entry.js → p-67137d7c.entry.js} +1 -1
- package/dist/sankhyablocks/{p-a5e0a780.entry.js → p-7375bf6a.entry.js} +1 -1
- package/dist/sankhyablocks/{p-b7e891cc.entry.js → p-7961c550.entry.js} +1 -1
- package/dist/sankhyablocks/{p-75af335e.entry.js → p-82b59a45.entry.js} +1 -1
- package/dist/sankhyablocks/p-82bb3eda.js +2 -0
- package/dist/sankhyablocks/{p-55798617.js → p-8336900b.js} +1 -1
- package/dist/sankhyablocks/{p-74389ec4.entry.js → p-8488fa7e.entry.js} +1 -1
- package/dist/sankhyablocks/{p-cb4343c4.entry.js → p-8783d550.entry.js} +1 -1
- package/dist/sankhyablocks/{p-471b34f4.entry.js → p-8d76a0ca.entry.js} +1 -1
- package/dist/sankhyablocks/{p-9a63f3f7.entry.js → p-8d84d6ab.entry.js} +1 -1
- package/dist/sankhyablocks/{p-8027f732.js → p-907e96eb.js} +1 -1
- package/dist/sankhyablocks/{p-e258de96.entry.js → p-939523b3.entry.js} +1 -1
- package/dist/sankhyablocks/{p-a9b16874.entry.js → p-959fe522.entry.js} +1 -1
- package/dist/sankhyablocks/{p-7e250432.entry.js → p-98c70173.entry.js} +1 -1
- package/dist/sankhyablocks/{p-2d133b6e.entry.js → p-98e3d0a1.entry.js} +1 -1
- package/dist/sankhyablocks/{p-2fdac5e6.entry.js → p-abfc9880.entry.js} +1 -1
- package/dist/sankhyablocks/{p-728959a6.entry.js → p-b5832fa0.entry.js} +1 -1
- package/dist/sankhyablocks/{p-04bbdf6f.entry.js → p-c2bb0659.entry.js} +1 -1
- package/dist/sankhyablocks/{p-7f7fe6c4.entry.js → p-c60d864f.entry.js} +1 -1
- package/dist/sankhyablocks/{p-8ce94b62.entry.js → p-cb7c592f.entry.js} +1 -1
- package/dist/sankhyablocks/{p-f3027bc9.entry.js → p-cc68a0c1.entry.js} +1 -1
- package/dist/sankhyablocks/{p-c3dbf441.entry.js → p-ce207f2a.entry.js} +1 -1
- package/dist/sankhyablocks/{p-c4fcf1fb.entry.js → p-cfa4c183.entry.js} +1 -1
- package/dist/sankhyablocks/{p-20349480.entry.js → p-d5d7fe52.entry.js} +1 -1
- package/dist/sankhyablocks/{p-b47acee0.entry.js → p-dd89bc02.entry.js} +1 -1
- package/dist/sankhyablocks/{p-667cab42.entry.js → p-def17f0e.entry.js} +1 -1
- package/dist/sankhyablocks/p-e41c86b2.entry.js +1 -0
- package/dist/sankhyablocks/{p-4c2e2767.entry.js → p-e47d6f17.entry.js} +1 -1
- package/dist/sankhyablocks/{p-7345782c.entry.js → p-fd1a5a61.entry.js} +1 -1
- package/dist/sankhyablocks/sankhyablocks.esm.js +1 -1
- package/dist/types/components/snk-grid/snk-grid.d.ts +1 -0
- package/package.json +1 -1
- package/dist/sankhyablocks/p-0814b16c.entry.js +0 -1
- package/dist/sankhyablocks/p-d8d8169b.js +0 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as t,c as i,h as s,H as e,g as h}from"./p-d8d8169b.js";import{Action as n,StringUtils as a,ElementIDUtils as o,ApplicationContext as r,KeyboardManager as d}from"@sankhyalabs/core";import"./p-6768f176.js";import"./p-48a5c311.js";import{P as c,E as l}from"./p-0f3698af.js";import"@sankhyalabs/ezui/dist/collection/utils/constants";import"@sankhyalabs/core/dist/dataunit/metadata/UnitMetadata";import"./p-9e4555ab.js";import"./p-ff1990ad.js";import"./p-7ee6b1bf.js";import{V as u}from"./p-9019a32f.js";import{A as m}from"./p-52691b42.js";import{S as f}from"./p-cad964b5.js";import{T as p}from"./p-b987e15d.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-55798617.js";const g=class{constructor(s){t(this,s),this.snkShowGuide=i(this,"snkShowGuide",7),this.actionClick=i(this,"actionClick",7),this.configuratorSave=i(this,"configuratorSave",7),this.configuratorCancel=i(this,"configuratorCancel",7),this.formItemsReady=i(this,"formItemsReady",7),this.viewModeChanged=i(this,"viewModeChanged",7),this.numberingConfigChanged=i(this,"numberingConfigChanged",7),this._viewHistory=[],this._customEditors=new Map,this._customRenders=new Map,this.loadEntitySuggestions=async t=>{var i;const s=null!==(i=null==t?void 0:t.argument)&&void 0!==i?i:"",e=(null==t?void 0:t.mode)||"PREDICTIVE";if(!s||0===s.trim().length)return[];try{this._showMoreOnSearch=!1;const t=this._snkDataUnit.entityName;return"PREDICTIVE"===e?await this.handlePredictiveSearch(s,t):await this._application.executePreparedSearch(e,s,this.buildSearchOptions(t))}catch(t){return console.error("Erro ao carregar sugestões de entidades:",t),[]}},this.searchEntitySelect=async t=>{if(this._entityPKField&&t)try{const i=[{name:this._entityPKField,value:t.value}];await this.refreshDataUnitByPk(i)}catch(t){console.error("Erro ao selecionar entidade:",t)}},this.dataUnitInterceptor={interceptAction:t=>(t.type===n.DATA_SAVED&&(t=this.interceptDataSaved(t)),t)},this._dataUnit=void 0,this._dataState=void 0,this.attachmentRegisterKey=void 0,this._currentViewMode=u.GRID,this._canEdit=void 0,this._resourceID=void 0,this.customContainerId=`SNK-CRUD-CUSTOM-CONTAINER-${a.generateUUID()}`,this.numberingConfig=void 0,this._showMoreOnSearch=!1,this._entityPKField=void 0,this.enableLockManagerLoadingComp=!1,this.enableLockManagerTaskbarClick=!1,this.configName=void 0,this.filterBarTitle=void 0,this.selectionToastConfig=void 0,this.showActionButtons=!1,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=l.SERVER_SIDE,this.layoutFormConfig=!0,this.multipleEditionEnabled=!0,this.paginationCounterMode="auto",this.customGuidesConfig=[],this.showEntitySearch=!0,this.disableNumberingConfig=!1}async goToView(t){this.executeAction(t)}async openConfigurator(){var t;null===(t=this._snkConfigurator)||void 0===t||t.open()}async closeConfigurator(){var t;null===(t=this._snkConfigurator)||void 0===t||t.close()}async reloadFilterBar(){var t;null===(t=this._snkGrid)||void 0===t||t.reloadFilterBar()}async getFilterBar(){return await this._snkGrid.getFilterBar()}async addCustomEditor(t,i){if(this._guidesViewer&&this._snkGrid)return this._guidesViewer.addCustomEditor(t,i),void this._snkGrid.addCustomEditor(t,i);const s=new Map(this._customEditors);s.set(t,i),this._customEditors=s}async addGridCustomRender(t,i){if(this._snkGrid)return void this._snkGrid.addGridCustomRender(t,i);const s=new Map(this._customRenders);s.set(t,i),this._customRenders=s}async addCustomValueFormatter(t,i){this._snkGrid.addCustomValueFormatter(t,i)}async removeCustomValueFormatter(t){this._snkGrid.removeCustomValueFormatter(t)}async setFieldProp(t,i,s){await this._guidesViewer.setFieldProp(t,i,s)}async getNumberingConfig(){return this.numberingConfig}async updateNumberingConfig(t){this.numberingConfig=t,this.applyNumberingConfigToFields()}currentViewModeWatcher(t){this._viewHistory=[...this._viewHistory.slice(-1),t]}async gridToForm(t=!1){this._backToGrid=!t&&await this._viewStack.getSelectedIndex()===u.GRID,this.setViewMode(u.FORM)}async executeAction(t){switch(t){case p.GRID_MODE:return this.setViewMode(u.GRID);case p.FORM_MODE:case p.UPDATE:return this.gridToForm(t!==p.UPDATE);case p.UPDATE_MULTIPLE:return this._dataUnit.isMultipleEdition=!0,this.setViewMode(u.FORM);case p.CONFIGURATOR:return this._snkConfigurator.open();case p.ATTACH:return this.setViewMode(u.ATTACHMENT)}}backView(){const t=this._viewHistory.at(-2)||u.GRID;this.setViewMode(t)}setViewMode(t){this._viewStack.show(t),this._currentViewMode=t,t===u.GRID?(this._dataUnit.isMultipleEdition=!1,this._snkGrid.setFocus()):t===u.FORM&&this._guidesViewer.setFocus(),this.viewModeChanged.emit(t)}openConfig(t){this._snkConfigurator.close(),t===u.GRID?this._snkGrid.showConfig():t===u.FORM&&this._guidesViewer.showFormConfig()}addDataElementID(){o.addIDInfo(this._element,null,{dataUnit:this._dataUnit})}insertionModeHandler(){this.enableGridInsert||this.gridToForm()}cancelHandler(){this._backToGrid&&this.setViewMode(u.GRID)}async getAttachmentRegisterKey(){if(this._snkDataUnit)return(await this._snkDataUnit.getSelectedRecordsIDsInfo()).map((({value:t})=>t)).join("_")}setCustomRenders(){if(this._snkGrid)for(const[t,i]of this._customRenders)this._snkGrid.addGridCustomRender(t,i),this._customRenders.delete(t)}setCustomEditors(){if(this._snkGrid&&this._guidesViewer)for(const[t,i]of this._customEditors)this._guidesViewer.addCustomEditor(t,i),this._snkGrid.addCustomEditor(t,i),this._customEditors.delete(t)}componentDidRender(){this.setCustomRenders(),this.setCustomEditors()}componentWillLoad(){this._application=r.getContextValue("__SNK__APPLICATION__");let t=this._element.parentElement;for(this._application.hasAccess(m.UPDATE,this._resourceID).then((t=>this._canEdit=t));t;){if("SNK-DATA-UNIT"===t.tagName.toUpperCase()){this._snkDataUnit=t,this._snkDataUnit.addEventListener("insertionMode",(()=>this.insertionModeHandler())),this._snkDataUnit.addEventListener("cancelEdition",(()=>this.cancelHandler())),this._snkDataUnit.domainMessagesBuilder=this.domainMessagesBuilder,this._dataUnit=this._snkDataUnit.dataUnit,this._dataState=this._snkDataUnit.dataState,this._dataUnit?this.initDataUnit():this._snkDataUnit.addEventListener("dataUnitReady",(t=>{this._dataUnit=t.detail,this.initDataUnit()})),this._snkDataUnit.addEventListener("dataStateChange",this.handleDataStateChange.bind(this));break}t=t.parentElement}this.configName||(this.configName=this._application.configName)}componentDidLoad(){this.initKeyboardManager()}disconnectedCallback(){var t;this.removeShortcuts(),null===(t=this._dataUnit)||void 0===t||t.removeInterceptor(this.dataUnitInterceptor)}async handleDataStateChange(t){var i;this._dataState=t.detail,void 0!==this._dataState.selectedRecord&&(this.attachmentRegisterKey=await this.getAttachmentRegisterKey());const s=await this._snkDataUnit.getFieldsWithRmPrecision();for(const t of s||[]){if(!t)continue;const s=null===(i=this._dataState.rowMetadata)||void 0===i?void 0:i.getProp("rm_precision",t);(s||0===s)&&(await this.setFieldProp(t,"precision",s),await this.setFieldProp(t,"prettyPrecision",s))}}async initKeyboardManager(){this._keyboardManager=new d({propagate:!1,element:this._element});const t=this._dataUnit||await this._snkDataUnit.getDataUnit();async function i(){const i=document.activeElement,s=i==document.body;s||i.blur(),await t.saveData(),s||null==i.setFocus?s||i.focus():i.setFocus()}this._keyboardManager&&this._keyboardManager.bind("F6",this.toggleView.bind(this),{description:this.getMessage("snkCrud.shortcuts.toggleView"),element:this._element}).bind("F7",i.bind(this),{description:this.getMessage("snkCrud.shortcuts.saveData"),element:this._element}).bind("ctrl + \\",i.bind(this),{description:this.getMessage("snkCrud.shortcuts.addRecord"),element:this._element}).bind("F8",async function(){t.hasNewRecord()||t.addRecord()}.bind(this),{description:this.getMessage("snkCrud.shortcuts.addRecord"),element:this._element}).bind("F9",t.removeSelectedRecords.bind(t),{description:this.getMessage("snkCrud.shortcuts.removeRecord"),element:this._element}).bind("ctrl + F9",t.removeSelectedRecords.bind(t),{description:this.getMessage("snkCrud.shortcuts.removeRecord"),element:this._element}).bind("F5",(async()=>{const i=await this._viewStack.getSelectedIndex();u.GRID===i&&t.loadData()}),{description:this.getMessage("snkCrud.shortcuts.refreshData"),element:this._element}).bind("Escape",(()=>{t.isDirty()&&t.cancelEdition()}),{debounceTime:1e3,description:this.getMessage("snkCrud.shortcuts.cancelAction"),element:this._element})}getMessage(t,i){if(this.messagesBuilder)return this.messagesBuilder.getMessage(t,i)}async removeShortcuts(){var t;null===(t=this._keyboardManager)||void 0===t||t.unbindAllShortcutKeys()}async handlePredictiveSearch(t,i){var s,e;const h=await this._application.executePreparedSearchWithFullResponse(t,this.buildSearchOptions(i,5));return this._showMoreOnSearch=null!==(s=null==h?void 0:h.hasMore)&&void 0!==s&&s,this._entityPKField=null==h?void 0:h.pkField,null!==(e=null==h?void 0:h.data)&&void 0!==e?e:[]}async refreshDataUnitByPk(t){try{const i={term:"",filter:{name:"",params:[],expression:`(${t[0].name} = ${t[0].value})`}};await this._dataUnit.loadData(i),1===this._dataUnit.records.length&&(this._dataUnit.selectFirst(),this.gridToForm(!0))}catch(t){console.error("Erro ao atualizar dataset:",t)}}buildSearchOptions(t,i){return{entity:t,entityDescription:t,executeOnOpen:!0,searchOptions:{localEntityName:t,limit:i}}}async toggleView(){const t=await this._viewStack.getSelectedIndex();this.setViewMode(u.GRID===t?u.FORM:u.GRID)}getLastRecordSaved(t){var i;return(null===(i=t.payload)||void 0===i?void 0:i.records.length)?t.payload.records[t.payload.records.length-1]:null}async saveNumberingConfig(){const t={entityName:this._snkDataUnit.entityName,isAutoNum:this.numberingConfig.isAutoNumbering,numInicial:this.numberingConfig.initialNumber};await this._servicesNumberingConfig.saveConfig(t)}updateNumberingConfigAfterInsert(t){var i,s;if(!(null===(i=t.payload)||void 0===i?void 0:i.changes.length)||this.disableNumberingConfig||!(null===(s=this.numberingConfig)||void 0===s?void 0:s.isAutoNumbering)||!this._fieldAutoNum)return t;if(!t.payload.changes.some((t=>"INSERT"===t.operation||"COPY"===t.operation)))return t;const e=this.getLastRecordSaved(t);if(e&&e.hasOwnProperty(this._fieldAutoNum)){const t=Number(e[this._fieldAutoNum]);this.numberingConfig.initialNumber=t,this.saveNumberingConfig()}else this.numberingConfig.initialNumber=this.numberingConfig.initialNumber+1;return this.numberingConfigChanged.emit(this.numberingConfig),t}interceptDataSaved(t){return this.updateNumberingConfigAfterInsert(t),t}onDataUnitReady(){var t;null===(t=this._dataUnit)||void 0===t||t.addInterceptor(this.dataUnitInterceptor),this.loadNumberingConfig()}async initDataUnit(){this.addDataElementID(),this.messagesBuilder||(this.messagesBuilder=this._snkDataUnit.messagesBuilder),null==this._resourceID&&(this._resourceID=this._snkDataUnit.resourceID,null==this._resourceID&&(this._resourceID=await this._application.getResourceID())),this.onDataUnitReady()}async loadNumberingConfig(){if(!this.numberingConfig&&this._snkDataUnit&&this._snkDataUnit.entityName&&!this.disableNumberingConfig){this._servicesNumberingConfig||(this._servicesNumberingConfig=new f(this._application,this._resourceID));try{this.numberingConfig=await this._servicesNumberingConfig.getConfig(this._snkDataUnit.entityName),this.getFieldAutoNum(),this.applyNumberingConfigToFields()}catch(t){console.error("Error loading numbering config in snk-crud:",t),this.numberingConfig={isAutoNumbering:!1,initialNumber:null}}}}getFieldAutoNum(){if(this._fieldAutoNum)return;const t=this._dataUnit.metadata.fields.find((t=>{var i;return"true"===(null===(i=t.properties)||void 0===i?void 0:i.isAutoNumField)}));this._fieldAutoNum=(null==t?void 0:t.name)||null}async applyNumberingConfigToFields(){if(!this.numberingConfig||!this._snkDataUnit||!this._fieldAutoNum)return;const t=this._dataUnit.getField(this._fieldAutoNum);t.readOnly=this.numberingConfig.isAutoNumbering,t.required=!this.numberingConfig.isAutoNumbering}handleConfiguratorEvent(t,i){if(t.stopImmediatePropagation(),"SAVE"===i)return this._guidesViewer.reloadGuides(),void this.configuratorSave.emit();this.configuratorCancel.emit()}renderCustomGuideSlots(){if(this.customGuidesConfig)return this.customGuidesConfig.map((t=>s("slot",{name:t.id})))}renderDynamicSearch(t){var i;if(this.showEntitySearch&&!0!==(null===(i=this._dataState)||void 0===i?void 0:i.insertionMode))return s("div",{slot:t,class:"entity-search-container",style:{position:"relative",display:"inline-block",marginLeft:"10px",minWidth:"200px"}},s("ez-search",{label:"Buscar registros",optionLoader:this.loadEntitySuggestions,onEzChange:t=>this.searchEntitySelect(t.detail),mode:"slim",showMore:this._showMoreOnSearch,suppressEmptyOption:!0,suppressInputPersist:!0}))}render(){if(null!=this._resourceID)return this._snkDataUnit.ignoreSaveMessage=this._currentViewMode===u.GRID&&!this.enableGridInsert,s(e,null,s("ez-view-stack",{ref:t=>this._viewStack=t,"data-element-id":"crud"},s("stack-item",{class:"ez-flex ez-flex--column ez-size-height--full ez-size-width--full ez-padding--medium"},s("snk-grid",{ref:t=>this._snkGrid=t,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:t=>this.executeAction(t.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},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"}),this.renderDynamicSearch("GRID_HEADER_DYNAMIC_SEARCH"))),s("stack-item",null,s("snk-guides-viewer",{ref:t=>this._guidesViewer=t,customGuidesConfig:this.customGuidesConfig,entityPath:this._snkDataUnit.entityName,messagesBuilder:this.messagesBuilder,onExit:()=>this.setViewMode(u.GRID),dataState:this._dataState,dataUnit:this._dataUnit,actionsList:this.actionsList,taskbarManager:this.taskbarManager,configName:this.configName,onActionClick:t=>this.executeAction(t.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},s("slot",{name:"GUIDES_VIEWER_TASKBAR_CUSTOM_ELEMENTS"}),this.renderCustomGuideSlots(),this.renderDynamicSearch("GUIDES_VIEWER_DYNAMIC_SEARCH"),s("slot",{name:"SnkFormTaskBar"}))),s("stack-item",{tabIndex:"0"},s("snk-attach",{registerKey:this.attachmentRegisterKey,messagesBuilder:this.messagesBuilder,entityName:this._snkDataUnit.entityName,onBack:this.backView.bind(this)})),s("snk-configurator",{ref:t=>this._snkConfigurator=t,entityName:this._snkDataUnit.entityName,viewMode:this._currentViewMode,messagesBuilder:this.messagesBuilder,onConfigSelected:t=>this.setViewMode(t.detail),onOpenConfig:t=>this.openConfig(t.detail),showActionButtons:this.showActionButtons,onSave:t=>this.handleConfiguratorEvent(t,"SAVE"),onCancel:t=>this.handleConfiguratorEvent(t,"CANCEL"),resourceID:this._resourceID,customContainerId:this.customContainerId,layoutFormConfig:this.layoutFormConfig})),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 h(this)}static get watchers(){return{_currentViewMode:["currentViewModeWatcher"]}}};g.style=".sc-snk-crud-h{display:flex;flex-direction:column;height:100%;width:100%}";export{g as snk_crud}
|
|
1
|
+
import{r as t,c as i,h as s,H as e,g as h}from"./p-82bb3eda.js";import{Action as n,StringUtils as a,ElementIDUtils as o,ApplicationContext as r,KeyboardManager as d}from"@sankhyalabs/core";import"./p-6768f176.js";import"./p-48a5c311.js";import{P as c,E as l}from"./p-0f3698af.js";import"@sankhyalabs/ezui/dist/collection/utils/constants";import"@sankhyalabs/core/dist/dataunit/metadata/UnitMetadata";import"./p-9e4555ab.js";import"./p-ff1990ad.js";import"./p-7ee6b1bf.js";import{V as u}from"./p-9019a32f.js";import{A as m}from"./p-52691b42.js";import{S as f}from"./p-cad964b5.js";import{T as p}from"./p-1be69fd4.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-8336900b.js";const g=class{constructor(s){t(this,s),this.snkShowGuide=i(this,"snkShowGuide",7),this.actionClick=i(this,"actionClick",7),this.configuratorSave=i(this,"configuratorSave",7),this.configuratorCancel=i(this,"configuratorCancel",7),this.formItemsReady=i(this,"formItemsReady",7),this.viewModeChanged=i(this,"viewModeChanged",7),this.numberingConfigChanged=i(this,"numberingConfigChanged",7),this._viewHistory=[],this._customEditors=new Map,this._customRenders=new Map,this.loadEntitySuggestions=async t=>{var i;const s=null!==(i=null==t?void 0:t.argument)&&void 0!==i?i:"",e=(null==t?void 0:t.mode)||"PREDICTIVE";if(!s||0===s.trim().length)return[];try{this._showMoreOnSearch=!1;const t=this._snkDataUnit.entityName;return"PREDICTIVE"===e?await this.handlePredictiveSearch(s,t):await this._application.executePreparedSearch(e,s,this.buildSearchOptions(t))}catch(t){return console.error("Erro ao carregar sugestões de entidades:",t),[]}},this.searchEntitySelect=async t=>{if(this._entityPKField&&t)try{const i=[{name:this._entityPKField,value:t.value}];await this.refreshDataUnitByPk(i)}catch(t){console.error("Erro ao selecionar entidade:",t)}},this.dataUnitInterceptor={interceptAction:t=>(t.type===n.DATA_SAVED&&(t=this.interceptDataSaved(t)),t)},this._dataUnit=void 0,this._dataState=void 0,this.attachmentRegisterKey=void 0,this._currentViewMode=u.GRID,this._canEdit=void 0,this._resourceID=void 0,this.customContainerId=`SNK-CRUD-CUSTOM-CONTAINER-${a.generateUUID()}`,this.numberingConfig=void 0,this._showMoreOnSearch=!1,this._entityPKField=void 0,this.enableLockManagerLoadingComp=!1,this.enableLockManagerTaskbarClick=!1,this.configName=void 0,this.filterBarTitle=void 0,this.selectionToastConfig=void 0,this.showActionButtons=!1,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=l.SERVER_SIDE,this.layoutFormConfig=!0,this.multipleEditionEnabled=!0,this.paginationCounterMode="auto",this.customGuidesConfig=[],this.showEntitySearch=!0,this.disableNumberingConfig=!1}async goToView(t){this.executeAction(t)}async openConfigurator(){var t;null===(t=this._snkConfigurator)||void 0===t||t.open()}async closeConfigurator(){var t;null===(t=this._snkConfigurator)||void 0===t||t.close()}async reloadFilterBar(){var t;null===(t=this._snkGrid)||void 0===t||t.reloadFilterBar()}async getFilterBar(){return await this._snkGrid.getFilterBar()}async addCustomEditor(t,i){if(this._guidesViewer&&this._snkGrid)return this._guidesViewer.addCustomEditor(t,i),void this._snkGrid.addCustomEditor(t,i);const s=new Map(this._customEditors);s.set(t,i),this._customEditors=s}async addGridCustomRender(t,i){if(this._snkGrid)return void this._snkGrid.addGridCustomRender(t,i);const s=new Map(this._customRenders);s.set(t,i),this._customRenders=s}async addCustomValueFormatter(t,i){this._snkGrid.addCustomValueFormatter(t,i)}async removeCustomValueFormatter(t){this._snkGrid.removeCustomValueFormatter(t)}async setFieldProp(t,i,s){await this._guidesViewer.setFieldProp(t,i,s)}async getNumberingConfig(){return this.numberingConfig}async updateNumberingConfig(t){this.numberingConfig=t,this.applyNumberingConfigToFields()}currentViewModeWatcher(t){this._viewHistory=[...this._viewHistory.slice(-1),t]}async gridToForm(t=!1){this._backToGrid=!t&&await this._viewStack.getSelectedIndex()===u.GRID,this.setViewMode(u.FORM)}async executeAction(t){switch(t){case p.GRID_MODE:return this.setViewMode(u.GRID);case p.FORM_MODE:case p.UPDATE:return this.gridToForm(t!==p.UPDATE);case p.UPDATE_MULTIPLE:return this._dataUnit.isMultipleEdition=!0,this.setViewMode(u.FORM);case p.CONFIGURATOR:return this._snkConfigurator.open();case p.ATTACH:return this.setViewMode(u.ATTACHMENT)}}backView(){const t=this._viewHistory.at(-2)||u.GRID;this.setViewMode(t)}setViewMode(t){this._viewStack.show(t),this._currentViewMode=t,t===u.GRID?(this._dataUnit.isMultipleEdition=!1,this._snkGrid.setFocus()):t===u.FORM&&this._guidesViewer.setFocus(),this.viewModeChanged.emit(t)}openConfig(t){this._snkConfigurator.close(),t===u.GRID?this._snkGrid.showConfig():t===u.FORM&&this._guidesViewer.showFormConfig()}addDataElementID(){o.addIDInfo(this._element,null,{dataUnit:this._dataUnit})}insertionModeHandler(){this.enableGridInsert||this.gridToForm()}cancelHandler(){this._backToGrid&&this.setViewMode(u.GRID)}async getAttachmentRegisterKey(){if(this._snkDataUnit)return(await this._snkDataUnit.getSelectedRecordsIDsInfo()).map((({value:t})=>t)).join("_")}setCustomRenders(){if(this._snkGrid)for(const[t,i]of this._customRenders)this._snkGrid.addGridCustomRender(t,i),this._customRenders.delete(t)}setCustomEditors(){if(this._snkGrid&&this._guidesViewer)for(const[t,i]of this._customEditors)this._guidesViewer.addCustomEditor(t,i),this._snkGrid.addCustomEditor(t,i),this._customEditors.delete(t)}componentDidRender(){this.setCustomRenders(),this.setCustomEditors()}componentWillLoad(){this._application=r.getContextValue("__SNK__APPLICATION__");let t=this._element.parentElement;for(this._application.hasAccess(m.UPDATE,this._resourceID).then((t=>this._canEdit=t));t;){if("SNK-DATA-UNIT"===t.tagName.toUpperCase()){this._snkDataUnit=t,this._snkDataUnit.addEventListener("insertionMode",(()=>this.insertionModeHandler())),this._snkDataUnit.addEventListener("cancelEdition",(()=>this.cancelHandler())),this._snkDataUnit.domainMessagesBuilder=this.domainMessagesBuilder,this._dataUnit=this._snkDataUnit.dataUnit,this._dataState=this._snkDataUnit.dataState,this._dataUnit?this.initDataUnit():this._snkDataUnit.addEventListener("dataUnitReady",(t=>{this._dataUnit=t.detail,this.initDataUnit()})),this._snkDataUnit.addEventListener("dataStateChange",this.handleDataStateChange.bind(this));break}t=t.parentElement}this.configName||(this.configName=this._application.configName)}componentDidLoad(){this.initKeyboardManager()}disconnectedCallback(){var t;this.removeShortcuts(),null===(t=this._dataUnit)||void 0===t||t.removeInterceptor(this.dataUnitInterceptor)}async handleDataStateChange(t){var i;this._dataState=t.detail,void 0!==this._dataState.selectedRecord&&(this.attachmentRegisterKey=await this.getAttachmentRegisterKey());const s=await this._snkDataUnit.getFieldsWithRmPrecision();for(const t of s||[]){if(!t)continue;const s=null===(i=this._dataState.rowMetadata)||void 0===i?void 0:i.getProp("rm_precision",t);(s||0===s)&&(await this.setFieldProp(t,"precision",s),await this.setFieldProp(t,"prettyPrecision",s))}}async initKeyboardManager(){this._keyboardManager=new d({propagate:!1,element:this._element});const t=this._dataUnit||await this._snkDataUnit.getDataUnit();async function i(){const i=document.activeElement,s=i==document.body;s||i.blur(),await t.saveData(),s||null==i.setFocus?s||i.focus():i.setFocus()}this._keyboardManager&&this._keyboardManager.bind("F6",this.toggleView.bind(this),{description:this.getMessage("snkCrud.shortcuts.toggleView"),element:this._element}).bind("F7",i.bind(this),{description:this.getMessage("snkCrud.shortcuts.saveData"),element:this._element}).bind("ctrl + \\",i.bind(this),{description:this.getMessage("snkCrud.shortcuts.addRecord"),element:this._element}).bind("F8",async function(){t.hasNewRecord()||t.addRecord()}.bind(this),{description:this.getMessage("snkCrud.shortcuts.addRecord"),element:this._element}).bind("F9",t.removeSelectedRecords.bind(t),{description:this.getMessage("snkCrud.shortcuts.removeRecord"),element:this._element}).bind("ctrl + F9",t.removeSelectedRecords.bind(t),{description:this.getMessage("snkCrud.shortcuts.removeRecord"),element:this._element}).bind("F5",(async()=>{const i=await this._viewStack.getSelectedIndex();u.GRID===i&&t.loadData()}),{description:this.getMessage("snkCrud.shortcuts.refreshData"),element:this._element}).bind("Escape",(()=>{t.isDirty()&&t.cancelEdition()}),{debounceTime:1e3,description:this.getMessage("snkCrud.shortcuts.cancelAction"),element:this._element})}getMessage(t,i){if(this.messagesBuilder)return this.messagesBuilder.getMessage(t,i)}async removeShortcuts(){var t;null===(t=this._keyboardManager)||void 0===t||t.unbindAllShortcutKeys()}async handlePredictiveSearch(t,i){var s,e;const h=await this._application.executePreparedSearchWithFullResponse(t,this.buildSearchOptions(i,5));return this._showMoreOnSearch=null!==(s=null==h?void 0:h.hasMore)&&void 0!==s&&s,this._entityPKField=null==h?void 0:h.pkField,null!==(e=null==h?void 0:h.data)&&void 0!==e?e:[]}async refreshDataUnitByPk(t){try{const i={term:"",filter:{name:"",params:[],expression:`(${t[0].name} = ${t[0].value})`}};await this._dataUnit.loadData(i),1===this._dataUnit.records.length&&(this._dataUnit.selectFirst(),this.gridToForm(!0))}catch(t){console.error("Erro ao atualizar dataset:",t)}}buildSearchOptions(t,i){return{entity:t,entityDescription:t,executeOnOpen:!0,searchOptions:{localEntityName:t,limit:i}}}async toggleView(){const t=await this._viewStack.getSelectedIndex();this.setViewMode(u.GRID===t?u.FORM:u.GRID)}getLastRecordSaved(t){var i;return(null===(i=t.payload)||void 0===i?void 0:i.records.length)?t.payload.records[t.payload.records.length-1]:null}async saveNumberingConfig(){const t={entityName:this._snkDataUnit.entityName,isAutoNum:this.numberingConfig.isAutoNumbering,numInicial:this.numberingConfig.initialNumber};await this._servicesNumberingConfig.saveConfig(t)}updateNumberingConfigAfterInsert(t){var i,s;if(!(null===(i=t.payload)||void 0===i?void 0:i.changes.length)||this.disableNumberingConfig||!(null===(s=this.numberingConfig)||void 0===s?void 0:s.isAutoNumbering)||!this._fieldAutoNum)return t;if(!t.payload.changes.some((t=>"INSERT"===t.operation||"COPY"===t.operation)))return t;const e=this.getLastRecordSaved(t);if(e&&e.hasOwnProperty(this._fieldAutoNum)){const t=Number(e[this._fieldAutoNum]);this.numberingConfig.initialNumber=t,this.saveNumberingConfig()}else this.numberingConfig.initialNumber=this.numberingConfig.initialNumber+1;return this.numberingConfigChanged.emit(this.numberingConfig),t}interceptDataSaved(t){return this.updateNumberingConfigAfterInsert(t),t}onDataUnitReady(){var t;null===(t=this._dataUnit)||void 0===t||t.addInterceptor(this.dataUnitInterceptor),this.loadNumberingConfig()}async initDataUnit(){this.addDataElementID(),this.messagesBuilder||(this.messagesBuilder=this._snkDataUnit.messagesBuilder),null==this._resourceID&&(this._resourceID=this._snkDataUnit.resourceID,null==this._resourceID&&(this._resourceID=await this._application.getResourceID())),this.onDataUnitReady()}async loadNumberingConfig(){if(!this.numberingConfig&&this._snkDataUnit&&this._snkDataUnit.entityName&&!this.disableNumberingConfig){this._servicesNumberingConfig||(this._servicesNumberingConfig=new f(this._application,this._resourceID));try{this.numberingConfig=await this._servicesNumberingConfig.getConfig(this._snkDataUnit.entityName),this.getFieldAutoNum(),this.applyNumberingConfigToFields()}catch(t){console.error("Error loading numbering config in snk-crud:",t),this.numberingConfig={isAutoNumbering:!1,initialNumber:null}}}}getFieldAutoNum(){if(this._fieldAutoNum)return;const t=this._dataUnit.metadata.fields.find((t=>{var i;return"true"===(null===(i=t.properties)||void 0===i?void 0:i.isAutoNumField)}));this._fieldAutoNum=(null==t?void 0:t.name)||null}async applyNumberingConfigToFields(){if(!this.numberingConfig||!this._snkDataUnit||!this._fieldAutoNum)return;const t=this._dataUnit.getField(this._fieldAutoNum);t.readOnly=this.numberingConfig.isAutoNumbering,t.required=!this.numberingConfig.isAutoNumbering}handleConfiguratorEvent(t,i){if(t.stopImmediatePropagation(),"SAVE"===i)return this._guidesViewer.reloadGuides(),void this.configuratorSave.emit();this.configuratorCancel.emit()}renderCustomGuideSlots(){if(this.customGuidesConfig)return this.customGuidesConfig.map((t=>s("slot",{name:t.id})))}renderDynamicSearch(t){var i;if(this.showEntitySearch&&!0!==(null===(i=this._dataState)||void 0===i?void 0:i.insertionMode))return s("div",{slot:t,class:"entity-search-container",style:{position:"relative",display:"inline-block",marginLeft:"10px",minWidth:"200px"}},s("ez-search",{label:"Buscar registros",optionLoader:this.loadEntitySuggestions,onEzChange:t=>this.searchEntitySelect(t.detail),mode:"slim",showMore:this._showMoreOnSearch,suppressEmptyOption:!0,suppressInputPersist:!0}))}render(){if(null!=this._resourceID)return this._snkDataUnit.ignoreSaveMessage=this._currentViewMode===u.GRID&&!this.enableGridInsert,s(e,null,s("ez-view-stack",{ref:t=>this._viewStack=t,"data-element-id":"crud"},s("stack-item",{class:"ez-flex ez-flex--column ez-size-height--full ez-size-width--full ez-padding--medium"},s("snk-grid",{ref:t=>this._snkGrid=t,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:t=>this.executeAction(t.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},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"}),this.renderDynamicSearch("GRID_HEADER_DYNAMIC_SEARCH"))),s("stack-item",null,s("snk-guides-viewer",{ref:t=>this._guidesViewer=t,customGuidesConfig:this.customGuidesConfig,entityPath:this._snkDataUnit.entityName,messagesBuilder:this.messagesBuilder,onExit:()=>this.setViewMode(u.GRID),dataState:this._dataState,dataUnit:this._dataUnit,actionsList:this.actionsList,taskbarManager:this.taskbarManager,configName:this.configName,onActionClick:t=>this.executeAction(t.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},s("slot",{name:"GUIDES_VIEWER_TASKBAR_CUSTOM_ELEMENTS"}),this.renderCustomGuideSlots(),this.renderDynamicSearch("GUIDES_VIEWER_DYNAMIC_SEARCH"),s("slot",{name:"SnkFormTaskBar"}))),s("stack-item",{tabIndex:"0"},s("snk-attach",{registerKey:this.attachmentRegisterKey,messagesBuilder:this.messagesBuilder,entityName:this._snkDataUnit.entityName,onBack:this.backView.bind(this)})),s("snk-configurator",{ref:t=>this._snkConfigurator=t,entityName:this._snkDataUnit.entityName,viewMode:this._currentViewMode,messagesBuilder:this.messagesBuilder,onConfigSelected:t=>this.setViewMode(t.detail),onOpenConfig:t=>this.openConfig(t.detail),showActionButtons:this.showActionButtons,onSave:t=>this.handleConfiguratorEvent(t,"SAVE"),onCancel:t=>this.handleConfiguratorEvent(t,"CANCEL"),resourceID:this._resourceID,customContainerId:this.customContainerId,layoutFormConfig:this.layoutFormConfig})),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 h(this)}static get watchers(){return{_currentViewMode:["currentViewModeWatcher"]}}};g.style=".sc-snk-crud-h{display:flex;flex-direction:column;height:100%;width:100%}";export{g as snk_crud}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as t,c as s,h as i,g as e}from"./p-
|
|
1
|
+
import{r as t,c as s,h as i,g as e}from"./p-82bb3eda.js";import{ElementIDUtils as h,ApplicationContext as r}from"@sankhyalabs/core";import{F as a}from"./p-ff1990ad.js";const o=class{constructor(i){t(this,i),this.valueChanged=s(this,"valueChanged",7),this._isSearchPlus=!1,this.config=void 0,this.value=void 0,this.errorMessage=void 0}async ezChangeListener(t){this.errorMessage=void 0,this.value=this._isSearchPlus?await this._searchInput.getValueAsync():this._searchInput.value,this.valueChanged.emit(this.value)}componentDidLoad(){this._element&&h.addIDInfo(this._element,"filterContentEditor")}doSearch(t,s,i=!1){const e=r.getContextValue("__SNK__APPLICATION__"),h=i?e.executePreparedSearchPlus:e.executePreparedSearch;return new Promise(((i,r)=>{h.bind(e)(t,s,this.config.props.searchContext).then((t=>{i(t)})).catch((t=>{r(t)}))}))}async setFocus(){this._searchInput.setFocus()}async clearValue(){this.value=this.config.value,this._searchInput&&(this._searchInput.value=this.config.value)}getInputItem(){var t;return this._isSearchPlus=1==(null===(t=this.config.props)||void 0===t?void 0:t.useSearchPlus),i("ez-tooltip",{active:!1===this.config.enabled,message:this.config.disabledMessage,type:"warning"},i(this._isSearchPlus?"ez-search-plus":"ez-search",{id:this.config.id,suppressEmptyOption:!0,value:this.config.value,label:this.config.label,enabled:this.config.enabled,ref:t=>this._searchInput=t,optionLoader:({mode:t,argument:s})=>this.doSearch(t,s,this._isSearchPlus),errorMessage:this.errorMessage}))}render(){if(this.config&&this.config.type===a.SEARCH)return this.getInputItem()}get _element(){return e(this)}};export{o as snk_filter_search}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{h as i,r as e,c as t,g as s}from"./p-d8d8169b.js";import{S as l}from"./p-f4184ce7.js";import{UserInterface as a,JSUtils as n,ElementIDUtils as r,ApplicationContext as o,StringUtils as h,DataType as d}from"@sankhyalabs/core";import{ModalAction as c}from"@sankhyalabs/ezui/dist/collection/components/ez-modal-container";import{b as u,c as f,d as m}from"./p-84345e7a.js";import{P as p}from"./p-988afe78.js";import"./p-ff1990ad.js";const v={[a.SHORTTEXT]:"text",[a.LONGTEXT]:"text",[a.INTEGERNUMBER]:"number",[a.DECIMALNUMBER]:"number",[a.DATE]:"calendar",[a.DATETIME]:"calendar",[a.SWITCH]:"boolean",[a.CHECKBOX]:"check-circle-inverted",[a.OPTIONSELECTOR]:"list",[a.SEARCH]:"search",[a.HTML]:"tag_code",[a.IMAGE]:"png",[a.FILE]:"edit-file",[a.TIME]:"timer-outline",[a.ELAPSEDTIME]:"timer",[a.MASKEDTEXT]:"text",[a.PASSWORD]:"email"},b=({userInterface:e,description:t})=>i("ez-icon",{iconName:v[e],class:"ez-padding-left--small",title:t}),g="__SNK__APPLICATION__",z=/\w+:\/\/(\w+)/,k=class{constructor(i){e(this,i),this.ezSelectFilterItem=t(this,"ezSelectFilterItem",7),this._currentMetadata=null,this._filterText="",this._isLoading=!1,this.searchable=!0,this.fieldsDataSource=void 0,this.breadcrumbItems=[],this.linkItems=[],this.fieldItems=[],this.searchEmpty=!1,this.groupEmpty=!1}async show(i,e){var t;return i?null===(t=this._ezPopover)||void 0===t||t.showUnder(i,e):this._ezPopover.show(),this.loadData()}async applyFilter(i){if(this.searchable)throw new Error("This method is not available when searchable is true");this.handleFilterChange(i)}async loadData(){var i,e;this._isLoading=!0;let t=await this.fieldsDataSource.fetchData(this._currentLink);this._currentLink=t.currentLink;const{fields:s,links:l}=t||{};if(!Array.isArray(s)||!Array.isArray(l))throw new Error("Invalid metadata");this._currentMetadata=t,this.mapDataSourceToLinkItems(),this.mapDataSourceToFieldItems(),this._isLoading=!1,null===(i=this._ezFieldList)||void 0===i||i.scrollToTop(),null===(e=this._ezLinkList)||void 0===e||e.scrollToTop()}mapDataSourceToLinkItems(){var i;const{links:e}=this._currentMetadata,t=this.getMessage("snkFilterFieldSearch.linkLabel",{link:null===(i=this._currentLink)||void 0===i?void 0:i.description}),s=e.map((i=>Object.assign({label:i.description},i)));this.groupEmpty=Boolean(0===s.length),this.linkItems=[{group:t,items:s}],0===this.breadcrumbItems.length&&(this.breadcrumbItems=[Object.assign({id:n.generateUUID(),label:this._currentLink.description},this._currentLink)])}mapDataSourceToFieldItems(){var i;const e=this._currentMetadata.fields,t=this.getMessage("snkFilterFieldSearch.fieldLabel",{link:null===(i=this._currentLink)||void 0===i?void 0:i.description}),s=e.filter((i=>{if(!this._currentLink)return!0;const e=i.description.toLowerCase().includes(this._filterText.toLowerCase()),t=i.name.toLowerCase().includes(this._filterText.toLowerCase());return e||t})).map((i=>Object.assign({label:i.description},i)));this.searchEmpty=Boolean(this._filterText&&0===s.length),this.fieldItems=[{group:t,items:s}]}handleFilterChange(i){this._isLoading||(this._filterText=i,this.mapDataSourceToFieldItems())}handleSelectLink({detail:i}){if(this._isLoading)return;const e=this.breadcrumbItems.findIndex((e=>e.id===i.id));this.breadcrumbItems=e>-1?this.breadcrumbItems.slice(0,e+1):[...this.breadcrumbItems,Object.assign({id:n.generateUUID(),label:i.description},i)];const t=Object.assign(Object.assign({},i),{type:l.LINK});this._currentLink=t,this.ezSelectFilterItem.emit(t),this.loadData()}getEntityFromBreadCrumbItem(i){const e=z.exec(i.uri);if(e)return e[1]}handleSelectField({detail:i}){var e;const t=this.breadcrumbItems.map((i=>i.label)).join(">>"),s=Object.assign(Object.assign({},i),{type:l.FIELD,entityPath:this.breadcrumbItems.map((i=>this.getEntityFromBreadCrumbItem(i))).filter((i=>null!=i)),path:`${t} >> ${i.description}`});this.ezSelectFilterItem.emit(s),null===(e=this._ezPopover)||void 0===e||e.hide()}getElementID(i){return{[r.DATA_ELEMENT_ID_ATTRIBUTE_NAME]:r.getInternalIDInfo(i)}}getMessage(i,e){var t,s,l;return this._application||(this._application=o.getContextValue(g)),null===(l=null===(s=null===(t=this._application)||void 0===t?void 0:t.messagesBuilder)||void 0===s?void 0:s.getMessage)||void 0===l?void 0:l.call(s,i,e)}componentWillLoad(){this._application=o.getContextValue(g)}componentDidLoad(){r.addIDInfoIfNotExists(this._ezPopover,"popover")}disconnectedCallback(){var i;null===(i=this._ezPopover)||void 0===i||i.hide()}render(){var e;const t=this.getMessage("snkFilterFieldSearch.searchLabel");return i("ez-popover",Object.assign({ref:i=>this._ezPopover=i,role:"dialog",overlayType:"none","aria-hidden":!(null===(e=this._ezPopover)||void 0===e?void 0:e.opened)},this.getElementID("EzPopover")),i("div",{class:"snk-filter-field-search__container"},i("header",{class:"snk-filter-field-search__header"},this.searchable&&!!t&&i("ez-filter-input",Object.assign({class:"snk-filter-field-search__input",label:t,asyncSearch:!0,canShowError:!1,onEzSearching:i=>this.handleFilterChange.bind(this)(i.detail),"aria-label":t,"aria-required":"false","aria-invalid":"false"},this.getElementID("EzFilterInput"))),this.breadcrumbItems.length>0&&i("ez-breadcrumb",Object.assign({items:this.breadcrumbItems,onSelectedItem:this.handleSelectLink.bind(this),role:"navigation","aria-current":"step"},this.getElementID("EzBreadcrumb"))),i("hr",{class:"ez-divider-horizontal ez-margin-vertical--medium"})),i("section",{class:`snk-filter-field-search__section ${this.groupEmpty&&this.searchEmpty&&" ez-margin--auto"}`},this.groupEmpty?i("div",{class:"ez-margin--auto"},i("span",{class:"ez-text ez-text--secondary ez-text--medium"},this.getMessage("snkFilterFieldSearch.groupEmpty"))):i("ez-list",Object.assign({ref:i=>this._ezLinkList=i,class:"snk-filter-field-search__list",id:"filterLinkList",useGroups:!0,dataSource:this.linkItems,onEzSelectItem:this.handleSelectLink.bind(this),hoverFeedback:!0,ezSelectable:!0,itemSlotBuilder:e=>i("ez-badge",{label:e.fieldCount}),"aria-describedby":"filterLinkLabel"},this.getElementID("EzListLinks"))),this.searchEmpty?i("div",{class:"ez-margin--auto"},i("span",{class:"ez-text ez-text--secondary ez-text--medium"},this.getMessage("snkFilterFieldSearch.searchEmpty"))):i("ez-list",Object.assign({ref:i=>this._ezFieldList=i,class:"snk-filter-field-search__list",id:"filterFieldList",useGroups:!0,dataSource:this.fieldItems,onEzSelectItem:this.handleSelectField.bind(this),hoverFeedback:!0,ezSelectable:!0,itemSlotBuilder:b,"aria-describedby":"filterFieldLabel"},this.getElementID("EzListFields"))))))}};k.style=".sc-snk-filter-field-search-h{--snk-filter-field-search--container-width:468px;--snk-filter-field-search--container-height:322px}.snk-filter-field-search__container.sc-snk-filter-field-search{display:flex;flex-direction:column;padding:var(--space--medium);width:var(--snk-filter-field-search--container-width);height:var(--snk-filter-field-search--container-height)}.snk-filter-field-search__section.sc-snk-filter-field-search{display:grid;grid-template-columns:1fr 1fr;place-items:flex-start;overflow:hidden;gap:var(--space--small)}.snk-filter-field-search__input.sc-snk-filter-field-search{margin-bottom:var(--space--medium)}.snk-filter-field-search__list_container.sc-snk-filter-field-search{display:flex;flex-direction:column}.snk-filter-field-search__list.sc-snk-filter-field-search{overflow-y:auto}";const y=class{constructor(i){e(this,i),this._opened=!1,this._configType=u.SYSTEM_CONFIG,this._expressionItem=void 0,this._informedInstance=!1,this._canSave=!1,this.messagesBuilder=void 0}open(i){return this._opened=!0,this._expressionItem=i,this.loadValues(),new Promise((i=>{this._promiseResolver=i}))}close(){return this._opened=!1,new Promise((i=>{this._promiseResolver=i}))}getMessage(i,e){var t;return null===(t=this.messagesBuilder)||void 0===t?void 0:t.getMessage(i,e)}getConfigValue(i,e,t=""){var s,l,a;return(null===(l=null===(s=this._expressionItem)||void 0===s?void 0:s[i])||void 0===l?void 0:l[e])||(null===(a=this._expressionItem)||void 0===a?void 0:a[t||e])}loadValues(){var i;const e=this.getConfigValue("systemConfig","entity","entityName"),t=this.getConfigValue("systemConfig","fieldName"),s=this.getConfigValue("userConfig","description"),l=this.getConfigValue("userConfig","type");this._configType=null!=(null===(i=this._expressionItem)||void 0===i?void 0:i.userConfig)?u.USER_CONFIG:u.SYSTEM_CONFIG,h.isEmpty(e)||h.isEmpty(t)||(this._instanceElement.value={value:e,label:""},this._fieldElement.value={value:t,label:""}),h.isEmpty(s)||h.isEmpty(l)||(this._descriptionElement.value=s,this._typeElement.value=l),this.buildFilterExpression()}changeDefinitionUsed(i){if(this._configType=null!=i?i:u.SYSTEM_CONFIG,this._configType===u.SYSTEM_CONFIG){const i=this.getConfigValue("systemConfig","entity","entityName"),e=this.getConfigValue("systemConfig","fieldName");this._instanceElement.value=this._instanceElement.value||{value:i,label:""},this._fieldElement.value=this._fieldElement.value||{value:e,label:""}}else if(this._configType===u.USER_CONFIG){const i=this.getConfigValue("userConfig","description"),e=this.getConfigValue("userConfig","type");this._descriptionElement.value=this._descriptionElement.value||i,this._typeElement.value=this._typeElement.value||e}this.buildFilterExpression()}getTypeValue(){var i;const e=null===(i=this._typeElement)||void 0===i?void 0:i.value;return(null==e?void 0:e.value)||e}getExpressionValues(){var i,e,t,s,l;let a,n;return this._configType===u.SYSTEM_CONFIG?a={entity:null===(e=null===(i=this._instanceElement)||void 0===i?void 0:i.value)||void 0===e?void 0:e.value,fieldName:null===(s=null===(t=this._fieldElement)||void 0===t?void 0:t.value)||void 0===s?void 0:s.value}:this._configType===u.USER_CONFIG&&(n={description:null===(l=this._descriptionElement)||void 0===l?void 0:l.value,type:this.getTypeValue()}),Object.assign(Object.assign(Object.assign({},this._expressionItem),{systemConfig:a}),{userConfig:n})}isEnabled(i){return this._configType===i}isInformedInstance(){var i,e;return!h.isEmpty(null===(e=null===(i=this._instanceElement)||void 0===i?void 0:i.value)||void 0===e?void 0:e.value)}save(){var i;this._expressionItem=Object.assign(Object.assign({},this.getExpressionValues()),{expression:null===(i=this._expressionElement)||void 0===i?void 0:i.value}),this._promiseResolver(this._expressionItem),this._opened=!1}buildFilterExpression(){var i;this._informedInstance=this.isInformedInstance();const e=p.buildFilterExpression(this.getExpressionValues());this._expressionElement.value=e||(null===(i=this._expressionItem)||void 0===i?void 0:i.expression),this._canSave=this.getCanSave()}handleChangeInstance(){this._informedInstance=this.isInformedInstance(),null==this._fieldElement||h.isEmpty(this._fieldElement.value)||(this._fieldElement.value=null),this.buildFilterExpression()}getInstanceCriteria(){var i,e;const t=null===(e=null===(i=this._instanceElement)||void 0===i?void 0:i.value)||void 0===e?void 0:e.value;return{expression:"this.NOMETAB = (SELECT NOMETAB FROM TDDINS WHERE NOMEINSTANCIA = ?)",params:[{name:"NOMEINSTANCIA",dataType:d.TEXT,value:t}]}}onSearch({mode:i,argument:e},t){if(null==this._application||!this._opened)return;const s=t===f.FIELD,l=s?this.getInstanceCriteria():void 0,a={entity:t,entityDescription:this.getMessage("snkFilterParamConfig.label"+(s?"Field":"Instance")),criteria:l,searchOptions:{descriptionFieldName:s?"DESCRCAMPO":"DESCRINSTANCIA",codeFieldName:s?"NOMECAMPO":"NOMEINSTANCIA",showInactives:!1}};return new Promise((t=>{this._application.executePreparedSearch(i,e,a).then((i=>t(i)))}))}getElementID(i){return{[r.DATA_ELEMENT_ID_ATTRIBUTE_NAME]:r.getInternalIDInfo(i)}}getCanSave(){var i;if(this._configType===u.USER_CONFIG){const e=null===(i=this._descriptionElement)||void 0===i?void 0:i.value,t=this.getTypeValue();return!h.isEmpty(e)&&!h.isEmpty(t)}return!0}componentWillLoad(){this._application=o.getContextValue("__SNK__APPLICATION__")}render(){return r.addIDInfoIfNotExists(this._element,"snkFilterParamConfig"),i("ez-popup",Object.assign({useHeader:!1,size:"small",heightMode:"auto",opened:this._opened},this.getElementID("popup")),i("ez-modal-container",Object.assign({onEzModalAction:i=>{i.detail===c.CLOSE&&this.close()},modalTitle:this.getMessage("snkFilterParamConfig.modalTitle")},this.getElementID("modalContainer")),i("div",{class:"ez-flex"},i("div",{class:"ez-col ez-col--sd-6 ez-flex--column"},i("ez-radio-button",Object.assign({value:this._configType,onEzChange:i=>this.changeDefinitionUsed(i.detail)},this.getElementID("systemConfigOption")),i("ez-radio-button-option",{label:this.getMessage("snkFilterParamConfig.labelSystemConfig"),value:u.SYSTEM_CONFIG})),i("ez-search",Object.assign({ref:i=>this._instanceElement=i,label:this.getMessage("snkFilterParamConfig.labelInstance"),enabled:this.isEnabled(u.SYSTEM_CONFIG),suppressEmptyOption:!0,showOptionValue:!1,showSelectedValue:!1,onEzChange:()=>this.handleChangeInstance(),optionLoader:i=>this.onSearch(i,f.INSTANCE)},this.getElementID("configFindEntity"))),i("ez-search",Object.assign({ref:i=>this._fieldElement=i,label:this.getMessage("snkFilterParamConfig.labelField"),enabled:this.isEnabled(u.SYSTEM_CONFIG)&&this._informedInstance,suppressEmptyOption:!0,showOptionValue:!1,showSelectedValue:!1,onEzChange:()=>this.buildFilterExpression(),optionLoader:i=>this.onSearch(i,f.FIELD)},this.getElementID("configFindField")))),i("div",{class:"ez-flex ez-padding--medium"},i("hr",{class:"ez-divider-vertical"})),i("div",{class:"ez-col ez-col--sd-6 ez-flex--column"},i("ez-radio-button",Object.assign({value:this._configType,onEzChange:i=>this.changeDefinitionUsed(i.detail)},this.getElementID("userConfigOption")),i("ez-radio-button-option",{label:this.getMessage("snkFilterParamConfig.labelUserConfig"),value:u.USER_CONFIG})),i("ez-text-input",Object.assign({ref:i=>this._descriptionElement=i,label:this.getMessage("snkFilterParamConfig.labelDescription"),enabled:this.isEnabled(u.USER_CONFIG),onEzChange:()=>this.buildFilterExpression()},this.getElementID("configParamLabel"))),i("ez-combo-box",Object.assign({ref:i=>this._typeElement=i,label:this.getMessage("snkFilterParamConfig.labelType"),enabled:this.isEnabled(u.USER_CONFIG),suppressEmptyOption:!0,onEzChange:()=>this.buildFilterExpression()},this.getElementID("configParamType")),Object.keys(m).map((e=>i("option",{value:m[e]},this.getMessage(`snkFilterParamConfig.labelTypeValues.${e.toLowerCase()}`))))))),i("ez-text-area",Object.assign({ref:i=>this._expressionElement=i,class:"snk-filter-param-config__expression",label:this.getMessage("snkFilterParamConfig.labelExpression"),enabled:!1},this.getElementID("presentationExpression"))),i("div",{class:"ez-col ez-col--sd-12 ez-flex--justify-end ez-margin-vertical--small"},i("ez-button",Object.assign({class:"ez-padding-right--medium",label:this.getMessage("snkFilterParamConfig.labelCancel"),onClick:()=>this.close()},this.getElementID("cancelEditParam"))),i("ez-button",Object.assign({class:"ez-button--primary",label:this.getMessage("snkFilterParamConfig.labelSave"),onClick:()=>this.save(),enabled:this._canSave},this.getElementID("saveEditParam"))))))}get _element(){return s(this)}};y.style=":host{--snk-filter-param-config__expression--color:var(--title--primary, #2b3a54);display:flex;position:relative}.snk-filter-param-config__expression{--text-area__input--disabled--color:var(--snk-filter-param-config__expression--color)}";export{k as snk_filter_field_search,y as snk_filter_param_config}
|
|
1
|
+
import{h as i,r as e,c as t,g as s}from"./p-82bb3eda.js";import{S as l}from"./p-f4184ce7.js";import{UserInterface as a,JSUtils as n,ElementIDUtils as r,ApplicationContext as o,StringUtils as h,DataType as d}from"@sankhyalabs/core";import{ModalAction as c}from"@sankhyalabs/ezui/dist/collection/components/ez-modal-container";import{b as u,c as f,d as m}from"./p-84345e7a.js";import{P as p}from"./p-988afe78.js";import"./p-ff1990ad.js";const v={[a.SHORTTEXT]:"text",[a.LONGTEXT]:"text",[a.INTEGERNUMBER]:"number",[a.DECIMALNUMBER]:"number",[a.DATE]:"calendar",[a.DATETIME]:"calendar",[a.SWITCH]:"boolean",[a.CHECKBOX]:"check-circle-inverted",[a.OPTIONSELECTOR]:"list",[a.SEARCH]:"search",[a.HTML]:"tag_code",[a.IMAGE]:"png",[a.FILE]:"edit-file",[a.TIME]:"timer-outline",[a.ELAPSEDTIME]:"timer",[a.MASKEDTEXT]:"text",[a.PASSWORD]:"email"},b=({userInterface:e,description:t})=>i("ez-icon",{iconName:v[e],class:"ez-padding-left--small",title:t}),g="__SNK__APPLICATION__",z=/\w+:\/\/(\w+)/,k=class{constructor(i){e(this,i),this.ezSelectFilterItem=t(this,"ezSelectFilterItem",7),this._currentMetadata=null,this._filterText="",this._isLoading=!1,this.searchable=!0,this.fieldsDataSource=void 0,this.breadcrumbItems=[],this.linkItems=[],this.fieldItems=[],this.searchEmpty=!1,this.groupEmpty=!1}async show(i,e){var t;return i?null===(t=this._ezPopover)||void 0===t||t.showUnder(i,e):this._ezPopover.show(),this.loadData()}async applyFilter(i){if(this.searchable)throw new Error("This method is not available when searchable is true");this.handleFilterChange(i)}async loadData(){var i,e;this._isLoading=!0;let t=await this.fieldsDataSource.fetchData(this._currentLink);this._currentLink=t.currentLink;const{fields:s,links:l}=t||{};if(!Array.isArray(s)||!Array.isArray(l))throw new Error("Invalid metadata");this._currentMetadata=t,this.mapDataSourceToLinkItems(),this.mapDataSourceToFieldItems(),this._isLoading=!1,null===(i=this._ezFieldList)||void 0===i||i.scrollToTop(),null===(e=this._ezLinkList)||void 0===e||e.scrollToTop()}mapDataSourceToLinkItems(){var i;const{links:e}=this._currentMetadata,t=this.getMessage("snkFilterFieldSearch.linkLabel",{link:null===(i=this._currentLink)||void 0===i?void 0:i.description}),s=e.map((i=>Object.assign({label:i.description},i)));this.groupEmpty=Boolean(0===s.length),this.linkItems=[{group:t,items:s}],0===this.breadcrumbItems.length&&(this.breadcrumbItems=[Object.assign({id:n.generateUUID(),label:this._currentLink.description},this._currentLink)])}mapDataSourceToFieldItems(){var i;const e=this._currentMetadata.fields,t=this.getMessage("snkFilterFieldSearch.fieldLabel",{link:null===(i=this._currentLink)||void 0===i?void 0:i.description}),s=e.filter((i=>{if(!this._currentLink)return!0;const e=i.description.toLowerCase().includes(this._filterText.toLowerCase()),t=i.name.toLowerCase().includes(this._filterText.toLowerCase());return e||t})).map((i=>Object.assign({label:i.description},i)));this.searchEmpty=Boolean(this._filterText&&0===s.length),this.fieldItems=[{group:t,items:s}]}handleFilterChange(i){this._isLoading||(this._filterText=i,this.mapDataSourceToFieldItems())}handleSelectLink({detail:i}){if(this._isLoading)return;const e=this.breadcrumbItems.findIndex((e=>e.id===i.id));this.breadcrumbItems=e>-1?this.breadcrumbItems.slice(0,e+1):[...this.breadcrumbItems,Object.assign({id:n.generateUUID(),label:i.description},i)];const t=Object.assign(Object.assign({},i),{type:l.LINK});this._currentLink=t,this.ezSelectFilterItem.emit(t),this.loadData()}getEntityFromBreadCrumbItem(i){const e=z.exec(i.uri);if(e)return e[1]}handleSelectField({detail:i}){var e;const t=this.breadcrumbItems.map((i=>i.label)).join(">>"),s=Object.assign(Object.assign({},i),{type:l.FIELD,entityPath:this.breadcrumbItems.map((i=>this.getEntityFromBreadCrumbItem(i))).filter((i=>null!=i)),path:`${t} >> ${i.description}`});this.ezSelectFilterItem.emit(s),null===(e=this._ezPopover)||void 0===e||e.hide()}getElementID(i){return{[r.DATA_ELEMENT_ID_ATTRIBUTE_NAME]:r.getInternalIDInfo(i)}}getMessage(i,e){var t,s,l;return this._application||(this._application=o.getContextValue(g)),null===(l=null===(s=null===(t=this._application)||void 0===t?void 0:t.messagesBuilder)||void 0===s?void 0:s.getMessage)||void 0===l?void 0:l.call(s,i,e)}componentWillLoad(){this._application=o.getContextValue(g)}componentDidLoad(){r.addIDInfoIfNotExists(this._ezPopover,"popover")}disconnectedCallback(){var i;null===(i=this._ezPopover)||void 0===i||i.hide()}render(){var e;const t=this.getMessage("snkFilterFieldSearch.searchLabel");return i("ez-popover",Object.assign({ref:i=>this._ezPopover=i,role:"dialog",overlayType:"none","aria-hidden":!(null===(e=this._ezPopover)||void 0===e?void 0:e.opened)},this.getElementID("EzPopover")),i("div",{class:"snk-filter-field-search__container"},i("header",{class:"snk-filter-field-search__header"},this.searchable&&!!t&&i("ez-filter-input",Object.assign({class:"snk-filter-field-search__input",label:t,asyncSearch:!0,canShowError:!1,onEzSearching:i=>this.handleFilterChange.bind(this)(i.detail),"aria-label":t,"aria-required":"false","aria-invalid":"false"},this.getElementID("EzFilterInput"))),this.breadcrumbItems.length>0&&i("ez-breadcrumb",Object.assign({items:this.breadcrumbItems,onSelectedItem:this.handleSelectLink.bind(this),role:"navigation","aria-current":"step"},this.getElementID("EzBreadcrumb"))),i("hr",{class:"ez-divider-horizontal ez-margin-vertical--medium"})),i("section",{class:`snk-filter-field-search__section ${this.groupEmpty&&this.searchEmpty&&" ez-margin--auto"}`},this.groupEmpty?i("div",{class:"ez-margin--auto"},i("span",{class:"ez-text ez-text--secondary ez-text--medium"},this.getMessage("snkFilterFieldSearch.groupEmpty"))):i("ez-list",Object.assign({ref:i=>this._ezLinkList=i,class:"snk-filter-field-search__list",id:"filterLinkList",useGroups:!0,dataSource:this.linkItems,onEzSelectItem:this.handleSelectLink.bind(this),hoverFeedback:!0,ezSelectable:!0,itemSlotBuilder:e=>i("ez-badge",{label:e.fieldCount}),"aria-describedby":"filterLinkLabel"},this.getElementID("EzListLinks"))),this.searchEmpty?i("div",{class:"ez-margin--auto"},i("span",{class:"ez-text ez-text--secondary ez-text--medium"},this.getMessage("snkFilterFieldSearch.searchEmpty"))):i("ez-list",Object.assign({ref:i=>this._ezFieldList=i,class:"snk-filter-field-search__list",id:"filterFieldList",useGroups:!0,dataSource:this.fieldItems,onEzSelectItem:this.handleSelectField.bind(this),hoverFeedback:!0,ezSelectable:!0,itemSlotBuilder:b,"aria-describedby":"filterFieldLabel"},this.getElementID("EzListFields"))))))}};k.style=".sc-snk-filter-field-search-h{--snk-filter-field-search--container-width:468px;--snk-filter-field-search--container-height:322px}.snk-filter-field-search__container.sc-snk-filter-field-search{display:flex;flex-direction:column;padding:var(--space--medium);width:var(--snk-filter-field-search--container-width);height:var(--snk-filter-field-search--container-height)}.snk-filter-field-search__section.sc-snk-filter-field-search{display:grid;grid-template-columns:1fr 1fr;place-items:flex-start;overflow:hidden;gap:var(--space--small)}.snk-filter-field-search__input.sc-snk-filter-field-search{margin-bottom:var(--space--medium)}.snk-filter-field-search__list_container.sc-snk-filter-field-search{display:flex;flex-direction:column}.snk-filter-field-search__list.sc-snk-filter-field-search{overflow-y:auto}";const y=class{constructor(i){e(this,i),this._opened=!1,this._configType=u.SYSTEM_CONFIG,this._expressionItem=void 0,this._informedInstance=!1,this._canSave=!1,this.messagesBuilder=void 0}open(i){return this._opened=!0,this._expressionItem=i,this.loadValues(),new Promise((i=>{this._promiseResolver=i}))}close(){return this._opened=!1,new Promise((i=>{this._promiseResolver=i}))}getMessage(i,e){var t;return null===(t=this.messagesBuilder)||void 0===t?void 0:t.getMessage(i,e)}getConfigValue(i,e,t=""){var s,l,a;return(null===(l=null===(s=this._expressionItem)||void 0===s?void 0:s[i])||void 0===l?void 0:l[e])||(null===(a=this._expressionItem)||void 0===a?void 0:a[t||e])}loadValues(){var i;const e=this.getConfigValue("systemConfig","entity","entityName"),t=this.getConfigValue("systemConfig","fieldName"),s=this.getConfigValue("userConfig","description"),l=this.getConfigValue("userConfig","type");this._configType=null!=(null===(i=this._expressionItem)||void 0===i?void 0:i.userConfig)?u.USER_CONFIG:u.SYSTEM_CONFIG,h.isEmpty(e)||h.isEmpty(t)||(this._instanceElement.value={value:e,label:""},this._fieldElement.value={value:t,label:""}),h.isEmpty(s)||h.isEmpty(l)||(this._descriptionElement.value=s,this._typeElement.value=l),this.buildFilterExpression()}changeDefinitionUsed(i){if(this._configType=null!=i?i:u.SYSTEM_CONFIG,this._configType===u.SYSTEM_CONFIG){const i=this.getConfigValue("systemConfig","entity","entityName"),e=this.getConfigValue("systemConfig","fieldName");this._instanceElement.value=this._instanceElement.value||{value:i,label:""},this._fieldElement.value=this._fieldElement.value||{value:e,label:""}}else if(this._configType===u.USER_CONFIG){const i=this.getConfigValue("userConfig","description"),e=this.getConfigValue("userConfig","type");this._descriptionElement.value=this._descriptionElement.value||i,this._typeElement.value=this._typeElement.value||e}this.buildFilterExpression()}getTypeValue(){var i;const e=null===(i=this._typeElement)||void 0===i?void 0:i.value;return(null==e?void 0:e.value)||e}getExpressionValues(){var i,e,t,s,l;let a,n;return this._configType===u.SYSTEM_CONFIG?a={entity:null===(e=null===(i=this._instanceElement)||void 0===i?void 0:i.value)||void 0===e?void 0:e.value,fieldName:null===(s=null===(t=this._fieldElement)||void 0===t?void 0:t.value)||void 0===s?void 0:s.value}:this._configType===u.USER_CONFIG&&(n={description:null===(l=this._descriptionElement)||void 0===l?void 0:l.value,type:this.getTypeValue()}),Object.assign(Object.assign(Object.assign({},this._expressionItem),{systemConfig:a}),{userConfig:n})}isEnabled(i){return this._configType===i}isInformedInstance(){var i,e;return!h.isEmpty(null===(e=null===(i=this._instanceElement)||void 0===i?void 0:i.value)||void 0===e?void 0:e.value)}save(){var i;this._expressionItem=Object.assign(Object.assign({},this.getExpressionValues()),{expression:null===(i=this._expressionElement)||void 0===i?void 0:i.value}),this._promiseResolver(this._expressionItem),this._opened=!1}buildFilterExpression(){var i;this._informedInstance=this.isInformedInstance();const e=p.buildFilterExpression(this.getExpressionValues());this._expressionElement.value=e||(null===(i=this._expressionItem)||void 0===i?void 0:i.expression),this._canSave=this.getCanSave()}handleChangeInstance(){this._informedInstance=this.isInformedInstance(),null==this._fieldElement||h.isEmpty(this._fieldElement.value)||(this._fieldElement.value=null),this.buildFilterExpression()}getInstanceCriteria(){var i,e;const t=null===(e=null===(i=this._instanceElement)||void 0===i?void 0:i.value)||void 0===e?void 0:e.value;return{expression:"this.NOMETAB = (SELECT NOMETAB FROM TDDINS WHERE NOMEINSTANCIA = ?)",params:[{name:"NOMEINSTANCIA",dataType:d.TEXT,value:t}]}}onSearch({mode:i,argument:e},t){if(null==this._application||!this._opened)return;const s=t===f.FIELD,l=s?this.getInstanceCriteria():void 0,a={entity:t,entityDescription:this.getMessage("snkFilterParamConfig.label"+(s?"Field":"Instance")),criteria:l,searchOptions:{descriptionFieldName:s?"DESCRCAMPO":"DESCRINSTANCIA",codeFieldName:s?"NOMECAMPO":"NOMEINSTANCIA",showInactives:!1}};return new Promise((t=>{this._application.executePreparedSearch(i,e,a).then((i=>t(i)))}))}getElementID(i){return{[r.DATA_ELEMENT_ID_ATTRIBUTE_NAME]:r.getInternalIDInfo(i)}}getCanSave(){var i;if(this._configType===u.USER_CONFIG){const e=null===(i=this._descriptionElement)||void 0===i?void 0:i.value,t=this.getTypeValue();return!h.isEmpty(e)&&!h.isEmpty(t)}return!0}componentWillLoad(){this._application=o.getContextValue("__SNK__APPLICATION__")}render(){return r.addIDInfoIfNotExists(this._element,"snkFilterParamConfig"),i("ez-popup",Object.assign({useHeader:!1,size:"small",heightMode:"auto",opened:this._opened},this.getElementID("popup")),i("ez-modal-container",Object.assign({onEzModalAction:i=>{i.detail===c.CLOSE&&this.close()},modalTitle:this.getMessage("snkFilterParamConfig.modalTitle")},this.getElementID("modalContainer")),i("div",{class:"ez-flex"},i("div",{class:"ez-col ez-col--sd-6 ez-flex--column"},i("ez-radio-button",Object.assign({value:this._configType,onEzChange:i=>this.changeDefinitionUsed(i.detail)},this.getElementID("systemConfigOption")),i("ez-radio-button-option",{label:this.getMessage("snkFilterParamConfig.labelSystemConfig"),value:u.SYSTEM_CONFIG})),i("ez-search",Object.assign({ref:i=>this._instanceElement=i,label:this.getMessage("snkFilterParamConfig.labelInstance"),enabled:this.isEnabled(u.SYSTEM_CONFIG),suppressEmptyOption:!0,showOptionValue:!1,showSelectedValue:!1,onEzChange:()=>this.handleChangeInstance(),optionLoader:i=>this.onSearch(i,f.INSTANCE)},this.getElementID("configFindEntity"))),i("ez-search",Object.assign({ref:i=>this._fieldElement=i,label:this.getMessage("snkFilterParamConfig.labelField"),enabled:this.isEnabled(u.SYSTEM_CONFIG)&&this._informedInstance,suppressEmptyOption:!0,showOptionValue:!1,showSelectedValue:!1,onEzChange:()=>this.buildFilterExpression(),optionLoader:i=>this.onSearch(i,f.FIELD)},this.getElementID("configFindField")))),i("div",{class:"ez-flex ez-padding--medium"},i("hr",{class:"ez-divider-vertical"})),i("div",{class:"ez-col ez-col--sd-6 ez-flex--column"},i("ez-radio-button",Object.assign({value:this._configType,onEzChange:i=>this.changeDefinitionUsed(i.detail)},this.getElementID("userConfigOption")),i("ez-radio-button-option",{label:this.getMessage("snkFilterParamConfig.labelUserConfig"),value:u.USER_CONFIG})),i("ez-text-input",Object.assign({ref:i=>this._descriptionElement=i,label:this.getMessage("snkFilterParamConfig.labelDescription"),enabled:this.isEnabled(u.USER_CONFIG),onEzChange:()=>this.buildFilterExpression()},this.getElementID("configParamLabel"))),i("ez-combo-box",Object.assign({ref:i=>this._typeElement=i,label:this.getMessage("snkFilterParamConfig.labelType"),enabled:this.isEnabled(u.USER_CONFIG),suppressEmptyOption:!0,onEzChange:()=>this.buildFilterExpression()},this.getElementID("configParamType")),Object.keys(m).map((e=>i("option",{value:m[e]},this.getMessage(`snkFilterParamConfig.labelTypeValues.${e.toLowerCase()}`))))))),i("ez-text-area",Object.assign({ref:i=>this._expressionElement=i,class:"snk-filter-param-config__expression",label:this.getMessage("snkFilterParamConfig.labelExpression"),enabled:!1},this.getElementID("presentationExpression"))),i("div",{class:"ez-col ez-col--sd-12 ez-flex--justify-end ez-margin-vertical--small"},i("ez-button",Object.assign({class:"ez-padding-right--medium",label:this.getMessage("snkFilterParamConfig.labelCancel"),onClick:()=>this.close()},this.getElementID("cancelEditParam"))),i("ez-button",Object.assign({class:"ez-button--primary",label:this.getMessage("snkFilterParamConfig.labelSave"),onClick:()=>this.save(),enabled:this._canSave},this.getElementID("saveEditParam"))))))}get _element(){return s(this)}};y.style=":host{--snk-filter-param-config__expression--color:var(--title--primary, #2b3a54);display:flex;position:relative}.snk-filter-param-config__expression{--text-area__input--disabled--color:var(--snk-filter-param-config__expression--color)}";export{k as snk_filter_field_search,y as snk_filter_param_config}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{h as e,r as t,g as n}from"./p-
|
|
1
|
+
import{h as e,r as t,g as n}from"./p-82bb3eda.js";import{ElementIDUtils as o}from"@sankhyalabs/core";import{ModalAction as i}from"@sankhyalabs/ezui/dist/collection/components/ez-modal-container";const s=({getMessage:t,changeInfo:n,data:i})=>{const{format:s,email:l}=i||{};return e("div",null,e("ez-text-input",Object.assign({label:`${t("snkExporter.emailSenderInfoStep_sendTo")} (obrigatório) *`,value:null==l?void 0:l.to,onEzChange:e=>{var t;return n("to",null===(t=e.detail)||void 0===t?void 0:t.trim())}},{[o.DATA_ELEMENT_ID_ATTRIBUTE_NAME]:`${o.getInternalIDInfo("sendTo")}`})),e("ez-text-input",Object.assign({label:`${t("snkExporter.emailSenderInfoStep_subject")} (obrigatório) *`,value:null==l?void 0:l.subject,onEzChange:e=>{var t;return n("subject",null===(t=e.detail)||void 0===t?void 0:t.trim())}},{[o.DATA_ELEMENT_ID_ATTRIBUTE_NAME]:`${o.getInternalIDInfo("subject")}`})),e("ez-text-area",Object.assign({label:t("snkExporter.emailSenderInfoStep_message"),value:null==l?void 0:l.message,onEzChange:e=>n("message",e.detail)},{[o.DATA_ELEMENT_ID_ATTRIBUTE_NAME]:`${o.getInternalIDInfo("message")}`})),((null==l?void 0:l.attachments)||[]).map(((t,n)=>e("ez-file-item",Object.assign({class:"ez-padding-bottom--large",fileName:`${t.name}.${s}`,fileSize:t.size,canRemove:!1},{[o.DATA_ELEMENT_ID_ATTRIBUTE_NAME]:`${o.getInternalIDInfo("fileItem_")+(n+1)}`})))))},l=({getMessage:t,changeInfo:n,data:i})=>{const s=(null==i?void 0:i.selectedRows)||0,l=[{label:t("snkExporter.emailSenderOptStep_formatPDF"),value:"pdf"},{label:t("snkExporter.emailSenderOptStep_formatXLS"),value:"xls"}],a=[{label:t("snkExporter.emailSenderOptStep_allData"),value:"all"},{label:t("snkExporter.emailSenderOptStep_currentPage"),value:"page"}];if(s>0){const e=t(s>1?"snkExporter.emailSenderOptStep_someRecords":"snkExporter.emailSenderOptStep_oneRecord",{SELECTION_COUNT:s});a.push({label:e,value:"selection"})}return e("div",null,e("ez-radio-button",Object.assign({class:"ez-margin-bottom--large"},{[o.DATA_ELEMENT_ID_ATTRIBUTE_NAME]:`${o.getInternalIDInfo("formato")}`},{label:t("snkExporter.emailSenderOptStep_lblFormat"),direction:"horizontal",value:null==i?void 0:i.format,onEzChange:e=>n("format",e.detail),options:l})),e("ez-radio-button",Object.assign({class:"ez-margin-bottom--large"},{[o.DATA_ELEMENT_ID_ATTRIBUTE_NAME]:`${o.getInternalIDInfo("type")}`},{label:t("snkExporter.emailSenderOptStep_export"),value:(null==i?void 0:i.type)||"all",onEzChange:e=>n("type",e.detail),options:a})))},a=class{constructor(e){t(this,e),this._stepInfo=[{subTitle:"snkExporter.emailSenderOptStep_subtitle",firstButton:"snkExporter.emailSenderCancelButton",secondButton:"snkExporter.emailSenderNextButton",firstButtonAction:()=>this.close(),secondButtonAction:()=>this.changeStep(1)},{subTitle:"snkExporter.emailSenderInfoStep_subtitle",firstButton:"snkExporter.emailSenderBackButton",secondButton:"snkExporter.emailSenderSendButton",firstButtonAction:()=>this.changeStep(0),secondButtonAction:()=>this.send(),secondButtonEnabledTester:()=>this.isFilled(),secondButtonClass:"ez-button--primary"}],this._config=void 0,this._opened=!1,this._currentStep=0,this.getMessage=void 0}open(e){var t;return this._config=Object.assign(Object.assign({},e),{format:null!==(t=null==e?void 0:e.format)&&void 0!==t?t:"pdf"}),this._opened=!0,this.changeStep(0),new Promise((e=>{this._promiseResolver=e}))}close(){return this._opened=!1,new Promise((e=>{this._promiseResolver=e}))}getStepMessage(e){return this.getMessage((this._stepInfo[this._currentStep]||{})[e])}executeButtonAction(e){(this._stepInfo[this._currentStep]||{})[e?"firstButtonAction":"secondButtonAction"]()}checkButtonEnabled(e){const t=(this._stepInfo[this._currentStep]||{})[e?"firstButtonEnabledTester":"secondButtonEnabledTester"];return!t||t()}changeStep(e){this._currentStep=e,this._viewStack&&this._viewStack.show(this._currentStep)}send(){const{format:e,type:t,email:n,resolver:o}=this._config;o({format:e,type:t,email:n,report:void 0})}isFilled(){var e,t;return!(!(null===(e=this._config.email)||void 0===e?void 0:e.to)||!(null===(t=this._config.email)||void 0===t?void 0:t.subject))}updateEmailInfo(e,t){this._config=Object.assign(Object.assign({},this._config),{email:Object.assign(Object.assign({},this._config.email),{[e]:t})})}updateConfigInfo(e,t){this._config=Object.assign(Object.assign({},this._config),{[e]:t})}getSecondButtonClass(){return(this._stepInfo[this._currentStep]||{}).secondButtonClass||"ez-button--secondary"}render(){return o.addIDInfoIfNotExists(this._element,"snkExporterEmailSender"),e("ez-popup",{useHeader:!1,size:"x-small",heightMode:"auto",opened:this._opened},e("ez-modal-container",{onEzModalAction:e=>{e.detail===i.CLOSE&&this.close()},modalTitle:this.getMessage("snkExporter.emailSenderTitle"),modalSubTitle:this.getStepMessage("subTitle")},e("ez-view-stack",{ref:e=>this._viewStack=e},e("stack-item",null,e(l,{getMessage:this.getMessage,data:this._config,changeInfo:(e,t)=>this.updateConfigInfo(e,t)})),e("stack-item",null,e(s,{getMessage:this.getMessage,data:this._config,changeInfo:(e,t)=>this.updateEmailInfo(e,t)}))),e("div",{class:"ez-col ez-col--sd-12 ez-flex--justify-end ez-margin-vertical--small"},e("ez-button",Object.assign({class:"ez-button--tertiary ez-padding-right--medium",label:this.getStepMessage("firstButton"),onClick:()=>this.executeButtonAction(!0),enabled:this.checkButtonEnabled(!0)},{[o.DATA_ELEMENT_ID_ATTRIBUTE_NAME]:`${o.getInternalIDInfo("firstButton")}`})),e("ez-button",Object.assign({class:this.getSecondButtonClass(),label:this.getStepMessage("secondButton"),onClick:()=>this.executeButtonAction(!1),enabled:this.checkButtonEnabled(!1)},{[o.DATA_ELEMENT_ID_ATTRIBUTE_NAME]:`${o.getInternalIDInfo("secondButton")}`})))))}get _element(){return n(this)}};export{a as snk_exporter_email_sender}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as i,c as t,h as e,F as s,g as r}from"./p-d8d8169b.js";import{ObjectUtils as n,StringUtils as a,Action as d,KeyboardManager as o,ElementIDUtils as h}from"@sankhyalabs/core";import{SelectionMode as l}from"@sankhyalabs/core/dist/dataunit/DataUnit";import{buildFieldSearch as u,SHORTCUT_SEARCH_FIELD as v}from"@sankhyalabs/ezui/dist/collection/utils";import{buildFormMetadata as c,FormMetadata as g}from"@sankhyalabs/ezui/dist/collection/utils/form";import"./p-6768f176.js";import"./p-48a5c311.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-9e4555ab.js";import"./p-ff1990ad.js";import"./p-7ee6b1bf.js";import{V as k}from"./p-9019a32f.js";import{S as f}from"./p-2ac55a5d.js";import{T as p}from"./p-b987e15d.js";import{T as w}from"./p-1a0caadb.js";const b="__FORM:",_=class{constructor(e){i(this,e),this.snkShowGuide=t(this,"snkShowGuide",7),this.snkMasterFormConfigChange=t(this,"snkMasterFormConfigChange",7),this.formConfigVisibilityChanged=t(this,"formConfigVisibilityChanged",7),this.exit=t(this,"exit",7),this.actionClick=t(this,"actionClick",7),this.formItemsReady=t(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 t=!!i;await this._viewStack.show(t?y.CONFIG:y.GUIDES),this.formConfigVisibilityChanged.emit(t)}observeDataState(i,t){var e,s,r,a,d,o;const h=null!==(s=null===(e=null==i?void 0:i.selectionInfo)||void 0===e?void 0:e.recordIds)&&void 0!==s?s:null===(r=null==i?void 0:i.selectedRecord)||void 0===r?void 0:r.__record__id__,l=null!==(d=null===(a=null==t?void 0:t.selectionInfo)||void 0===a?void 0:a.recordIds)&&void 0!==d?d:null===(o=null==t?void 0:t.selectedRecord)||void 0===o?void 0:o.__record__id__;n.equals(h,l)||this.loadGuides((null==t?void 0:t.insertionMode)!=(null==i?void 0:i.insertionMode))}observeMasterFormConfig(){this.loadGuides(this.noGuideSelected()),this.snkMasterFormConfigChange.emit(this.masterFormConfig)}async showFormConfig(i=!1){const t=!i||null==this._currentDetail;this._formEditorConfigManager=t?this._configManager:this._currentDetail.formConfigManager,this._formEditorDataUnit=t?this.dataUnit:this._currentDetail.dataUnit}async addCustomEditor(i,t){this._customEditors=Object.assign(Object.assign({},this._customEditors),{[i]:t})}async addGridCustomRender(i,t){this._customRenders=Object.assign(Object.assign({},this._customRenders),{[i]:t})}async setFieldProp(i,t,e){const s={[i]:Object.assign(Object.assign({},this._fieldsProps[i]),{[t]:e})};this._fieldsProps=Object.assign(Object.assign({},this._fieldsProps),s)}async setFocus(){var i;null===(i=this._container)||void 0===i||i.focus()}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===p.CONFIGURATOR&&"master"!=i.target.dataset.taskbarOwner&&(this._snkConfigurator.open(),i.stopImmediatePropagation(),i.stopPropagation())}onContentCardChanged(i){_.updateContentCard(i.detail.formName,i.detail.cardConfig,i.detail.propertyChanged,this._configManager).then((()=>this.masterFormConfig=this._configManager.getConfig(this.dataUnit)))}getMessage(i){var t,e;if(this.dataUnit.isMultipleEdition){const i=null!==(e=null===(t=this.dataUnit.getSelectionInfo())||void 0===t?void 0:t.records)&&void 0!==e?e:[];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=c(this.masterFormConfig,this.dataUnit,!0,this.customGuidesConfig);const t=this._masterFormMetadata.getAllSheets(),e=this.dataUnit.getSelectedRecord(),s=this.hasToDisableDetails(e),r=[];Array.from(t.values()).forEach((i=>{const t={id:i.name,label:i.label};this.isDetail(i.name)&&s&&(t.tooltip=this.getMessage("snkCrud.detail.tooltip.needSingleSelection"),t.disabled=!0),i.isCustom&&i.ctxProps&&Object.entries(i.ctxProps).forEach((([i,e])=>{void 0!==e&&(t[i]=e)})),r.push(t)})),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!=g.getDetailName(i)}updateGuide(i){this._guideBuilders.set(i.id,i);const t=i.buildGuideItem(this._guideBuilders);this._guideNavigator&&(this._guideNavigator.updateItem(t).then((()=>{this._guideNavigator.getCurrentPath().then((i=>{this._breadcrumbItems=i}))})),this._guides=this._guides.map((i=>i.id===t.id?Object.assign(Object.assign(Object.assign({},i),t),void 0!==t.children?{}:{children:void 0}):i)))}getTaskBarId(){var i;return(null===(i=this.dataState)||void 0===i?void 0:i.isDirty)?C.FINISH_EDITION:this.dataUnit.isMultipleEdition?C.MUTIPLE_EDITION:C.REGULAR}loadTaskbarProcessor(){const i={};i[C.REGULAR]=this.buildBtnsRegularMode(),i[C.FINISH_EDITION]=[p.CANCEL,p.SAVE,this.handleAddGridMode()],i[C.MUTIPLE_EDITION]=[p.CANCEL],this._taskbarProcessor=new w(i),this._taskbarProcessor.process(this.getTaskBarId(),this.taskbarManager,this.dataState,this.buildDisabledButtons(),this.buildInvisibleButtons())}buildBtnsRegularMode(){var i,t;const e=[p.ATTACH,p.CLONE,p.REMOVE,p.MORE_OPTIONS,p.ACTIONS_BUTTON,p.DIVIDER,p.GRID_MODE,p.CONFIGURATOR];return(null===(t=null===(i=this.dataState)||void 0===i?void 0:i.selectionInfo)||void 0===t?void 0:t.length)<=1&&e.unshift(p.PREVIOUS,p.NEXT,p.DIVIDER),this.presentationMode==m.SECONDARY?e.unshift(p.INSERT):e.push(p.INSERT),e}buildDisabledButtons(){var i,t,e,s,r,n;const a=[];return(null===(i=this.dataState)||void 0===i?void 0:i.hasPrevious)||a.push(p.PREVIOUS),(null===(t=this.dataState)||void 0===t?void 0:t.hasNext)||a.push(p.NEXT),(null===(s=null===(e=this.dataState)||void 0===e?void 0:e.selectionInfo)||void 0===s?void 0:s.length)>1&&a.push(p.CLONE),(null===(n=null===(r=this.dataState)||void 0===r?void 0:r.selectionInfo)||void 0===n?void 0:n.isAllRecords())&&a.push(p.REMOVE),a}handleAddGridMode(){return this.enableGridInsert?p.GRID_MODE:""}buildInvisibleButtons(){const i=[];return this.dataState&&this.dataState.selectionInfo.mode===l.ALL_RECORDS&&i.push(p.ACTIONS_BUTTON),i}static updateContentCard(i,t,e,s){return s.saveCardState(i,t,e)}static buildFixedForms(i){var t;const r=null===(t=i.formConfig)||void 0===t?void 0:t.cardsState;if(null!=r)return e(s,null,Array.from(r.entries()).filter((([t,e])=>(null==e?void 0:e.fixed)&&t!=i.selectedForm)).sort((([,i],[,t])=>((null==i?void 0:i.fixSequence)||0)-((null==t?void 0:t.fixSequence)||0))).map((([t,s])=>{var r,n;const a=i.formMetadata.getSheet(t);if(null!=a)return e("snk-form-view",{levelPath:i.levelPath,label:a.label,name:t,fields:a.fields,formMetadata:i.formMetadata,dataUnit:i.dataUnit,recordsValidator:i.recordsValidator,contracted:"CONTRACTED"===(null==s?void 0:s.presentation),fixed:null==s?void 0:s.fixed,summaryFields:null===(n=null===(r=i.formConfig)||void 0===r?void 0:r.summary)||void 0===n?void 0:n.get(t),fieldToFocus:i.fieldToFocus,key:t,onSnkRequestClearFieldToFocus:()=>{var t;return null===(t=i.onRequestClearFieldToFocus)||void 0===t?void 0:t.call(i)},customEditors:i.propsCustomEditor,fieldsProps:i.fieldsProps})})))}wrapDetail(i,t){if(0===i.length)return t;const s=i.pop(),r=g.getDetailName(s);return r?this.wrapDetail(i,e("snk-data-unit",{dataUnitName:`${this.getDataUnitName(i,r)}`,entityName:r},t)):void 0}getDataUnitName(i,t){if(i.length>0){const e=i.map((i=>g.getDetailName(i)));return`${this.entityPath}/${e.join("/")}/${t}`}return`${this.entityPath}/${t}`}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 e("slot",{name:i});const t=i.split("::"),s=t.pop(),r=g.getDetailName(s);let n=i;return this.isDetailGuide(r,t)?this.buildDetailGuideContent(i,n,t,r):this.buildFormViewGuideContent(i)}buildFormViewGuideContent(i){var t,s,r,n;const a=this._masterFormMetadata.getSheet(i);if(!a)return;const d=null===(s=null===(t=this.masterFormConfig)||void 0===t?void 0:t.cardsState)||void 0===s?void 0:s.get(i);return e("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},this.presentationMode==m.SECONDARY&&this.buildTaskBar())}isDetailGuide(i,t){return i||t.length>0}buildDetailGuideContent(i,t,s,r){var n;let a,d;if(i.includes(b)){[t,a]=i.split(b);const e=(null===(n=this._breadcrumbItems)||void 0===n?void 0:n.length)||0;d=e>1?this._breadcrumbItems[e-2]:this.selectedGuide}else d=this.selectedGuide;return this.wrapDetail(s,e("snk-detail-view",{ref:i=>this._currentDetail=i,dataUnitName:this.getDataUnitName(s,r),onSnkDetailGuidesChange:i=>this.updateGuide(i.detail),entityName:r,selectedForm:a,branchGuide:d,guideItemPath:this._breadcrumbItems,key:`detail${t}`,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 t;return null===(t=this.customGuidesConfig)||void 0===t?void 0:t.map((i=>i.id)).includes(i)}onBreadcrumbClickHandler(i){null!=(null==i?void 0:i.id)&&this._guideNavigator.selectGuide(i.id)}updateSelectedGuideHandler(i){this._guideHasChanged=this.selectedGuide!=i,this.selectedGuide=i,this._guideNavigator.getCurrentPath().then((i=>{this._breadcrumbItems=i})),this.resetGuideBadge(i)}changeGuideHandler(i){var t;null===(t=this._guideNavigator)||void 0===t||t.selectGuide(i)}clearFieldToFocusHandler(){this._fieldToGetFocus=void 0}resetGuideBadge(i){var t;this._guides=[...null===(t=this._guides)||void 0===t?void 0:t.map((t=>this.canClearGuideBadge(t,i.id)?Object.assign(Object.assign({},t),{badge:null}):t))]}canClearGuideBadge(i,t){return i.id===t||this.isIncludedInChildrenList(i,t)}isIncludedInChildrenList(i,t){return this.hasChildren(i)&&this.getChildrenIdList(i).includes(t)}hasChildren(i){return i.children&&Array.isArray(i.children)}getChildrenIdList(i){return i.children.map((i=>i.id))}getConfigViewMode(){return k.GRID}changeConfigViewMode(i){this._currentDetail&&this._currentDetail.changeViewMode(i)}openConfig(i){this._snkConfigurator.close(),this._currentDetail&&(i===k.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 f(this.configName,this.resourceID,this.setMasterFormConfig.bind(this),this.dataUnit),this.addFormLegacyConfigName(),this._configManager.loadConfig()}componentDidRender(){this._guideHasChanged&&(this._currentDetail?this._currentDetail.showUp():this._mainForm&&this._mainForm.showUp(),this._guideHasChanged=!1)}getFieldsSearch(i){return(null==this._fieldSearch||this._hasToCreateFieldSearch)&&(this._hasToCreateFieldSearch=!1,this._fieldSearch=u(i,(({argument:i})=>this.fieldsOptionLoader(i)),(i=>this.onSelectField(i)))),this._fieldSearch}fieldsOptionLoader(i){return Promise.resolve(this._configManager.getFieldsList(i).map((i=>({value:i.name,label:i.label}))))}onSelectField(i){if(null==i)return;this._fieldToGetFocus=i.value;const t=this.getGuideName(i.value);t!==this.selectedGuide.id&&this.changeGuideHandler(t)}getActionsList(){var i;return[].concat(null!=this.taskbarManager&&null!=this.taskbarManager.getMoreOptions?null!==(i=this.taskbarManager.getMoreOptions(this.getTaskBarId(),this.configName,this.dataState,this.actionsList))&&void 0!==i?i:[]:this.actionsList)}getSettingsListForm(){return[{value:a.generateUUID(),label:this.getMessage("snkCrud.findColumn"),disableCloseOnSelect:!0,eagerInitialize:!0,itemBuilder:(i,t)=>this.getFieldsSearch(t)}]}buildTaskBar(){var i;return e("div",{class:"snk-guides-viewer__header-taskbar "+(this.presentationMode!=m.SECONDARY?"ez-align--right":"ez-padding-bottom--medium")},e("snk-taskbar",{key:"guideViewerTaskbar","data-element-id":"guideViewer",configName:this.configName,buttons:this._taskbarProcessor.buttons,disabledButtons:this._taskbarProcessor.disabledButtons,customButtons:this._taskbarProcessor.customButtons,actionsList:this.getActionsList(),actionsSettingsList:this.getSettingsListForm(),messagesBuilder:this.messagesBuilder,presentationMode:this.presentationMode,primaryButton:(null===(i=this.dataState)||void 0===i?void 0:i.isDirty)?p.SAVE:p.INSERT,"data-taskbar-owner":"master",dataUnit:this.dataUnit,resourceID:this.resourceID,customSlotId:"GUIDES_VIEWER_TASKBAR_CUSTOM_ELEMENTS",additionalSlotId:"GUIDES_VIEWER_DYNAMIC_SEARCH",alignRigth:!0},e("slot",{name:"GUIDES_VIEWER_TASKBAR_CUSTOM_ELEMENTS"}),e("slot",{name:"GUIDES_VIEWER_DYNAMIC_SEARCH"})))}async dataUnitActionHandler(i){var t;switch(i.type){case d.EDITION_CANCELED:case d.DATA_SAVED:this.dataUnit.isMultipleEdition&&(this.exitViewer(),this.dataUnit.isMultipleEdition=!1);break;case d.FIELD_INVALIDATED:const e=this.getGuideName(null===(t=i.payload)||void 0===t?void 0:t.fieldName);await this.addErrorBadgeToGuide(e),await this.openGuideNavigator(e);break;case d.METADATA_LOADED:case d.MULTIPLE_EDITION_CHANGED:this.loadGuides(this.noGuideSelected())}}async addErrorBadgeToGuide(i){var t;this._guides=[...null===(t=this._guides)||void 0===t?void 0:t.map((t=>Object.assign(Object.assign({},t),{badge:this.getBadge(t,i)})))]}async openGuideNavigator(i){this.selectedGuide.id!==i&&await this._guideNavigator.openGuideNavidator()}getBadge(i,t){var e;return this.selectedGuide.id===t?null:t===i.id?"error":null!==(e=i.badge)&&void 0!==e?e:null}getGuideName(i){var t;for(const e of this._masterFormMetadata.getAllSheets()){const s=null===(t=e[1])||void 0===t?void 0:t.fields;for(const t of s)if(t.name===i)return e[0]}return""}getTitle(){var i,t;return null!==(t=null===(i=this.getCustomTitle)||void 0===i?void 0:i.call(this))&&void 0!==t?t:this.getMessage("snkCrud.title")}getTitleTooltip(){if(this.dataUnit.isMultipleEdition)return this.buildRecordIdsArray()}buildRecordIdsArray(){var i,t;const e=null!==(t=null===(i=this.dataUnit.getSelectionInfo())||void 0===i?void 0:i.records)&&void 0!==t?t:[];return 0===e.length?"[]":`[${e.map((i=>this.messagesBuilder.getMessage("snkCrud.title",i))).join(", ")}]`}getCustomGuidesConfig(){return this._currentDetail?[]:this.customGuidesConfig}componentDidLoad(){this.dataUnit.subscribe(this.dataUnitActionHandler.bind(this)),this.initKeyboardManager()}disconnectedCallback(){var i;null===(i=this._keyboardManager)||void 0===i||i.unbindAllShortcutKeys()}async initKeyboardManager(){this._keyboardManager=new o({propagate:!1,element:this._element}),this._keyboardManager.bind(v,(async()=>{this._mainForm&&await this._mainForm.showSearchField()}),{description:this.getMessage("snkSimpleCrud.findFields"),element:this._element})}renderFormConfig(){if(null!=this._formEditorConfigManager)return e("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 t,s;return e("section",{class:"snk-guides-viewer",ref:i=>this._container=i,tabIndex:-1},e("div",{class:"ez-row snk-guides-viewer__header"},e("div",{class:"snk-guides-viewer__header-breadcrumb ez-flex--align-items-center ez-flex-item--align-center ez-padding-left--large",key:"header"},e("ez-button",{onClick:()=>this.exitViewer(),title:this.getMessage("snkCrud.goBackTitle"),mode:"icon",iconName:"arrow_back",class:"ez-padding-right--medium",size:"small"}),e("div",{class:"ez-flex ez-flex--column ez-flex-item--auto"},e("h1",{class:"ez-title ez-title--primary ez-title--xlarge",title:this.getTitleTooltip()},this.getTitle()),(null===(t=this._breadcrumbItems)||void 0===t?void 0:t.length)>1&&e("div",{class:"ez-margin-top--extra-small"},e("ez-breadcrumb",Object.assign({items:this._breadcrumbItems,onSelectedItem:i=>this.onBreadcrumbClickHandler(null==i?void 0:i.detail)},{[h.DATA_ELEMENT_ID_ATTRIBUTE_NAME]:`${h.getInternalIDInfo("breadcrumb")}`}))))),this.presentationMode!=m.SECONDARY&&this.buildTaskBar()),e("div",{class:"snk-guides-viewer__container"},i?e("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)}):e("div",null),e("div",{class:"snk-guides-viewer__detail-container"},_.buildFixedForms({formConfig:this.masterFormConfig,formMetadata:this._masterFormMetadata,selectedForm:null===(s=this.selectedGuide)||void 0===s?void 0:s.id,dataUnit:this.dataUnit,recordsValidator:this.recordsValidator,fieldToFocus:this._fieldToGetFocus,onRequestClearFieldToFocus:this.clearFieldToFocusHandler.bind(this),propsCustomEditor:this._customEditors,fieldsProps:this._fieldsProps}),this.getContent())),e("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}))}render(){if(this.dataUnit&&this._configManager.isLoaded)return this.loadTaskbarProcessor(),e("ez-view-stack",{ref:i=>this._viewStack=i,"data-element-id":"guides-viewer-stack"},e("stack-item",null,this.renderGuidesNavigator(this._guides&&this._guides.length>1)),e("stack-item",null,this.renderFormConfig()))}get _element(){return r(this)}static get watchers(){return{dataUnit:["observeDataUnit"],_formEditorConfigManager:["observeFormConfigManager"],dataState:["observeDataState"],masterFormConfig:["observeMasterFormConfig"]}}};var C,y;!function(i){i.FINISH_EDITION="snkGuideViewer.finish_edition",i.MUTIPLE_EDITION="snkGuideViewer.multiple_edition",i.REGULAR="snkGuideViewer.regular"}(C||(C={})),function(i){i[i.GUIDES=0]="GUIDES",i[i.CONFIG=1]="CONFIG"}(y||(y={})),_.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:68px;--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;display:block}snk-form-view.sc-snk-guides-viewer{width:100%}.snk-guides-viewer.sc-snk-guides-viewer{position:relative;padding-left:0px;padding-top:0px;padding-right:var(--snk-guides-viewer--space-large);padding-bottom:var(--snk-guides-viewer--space-large)}.snk-guides-viewer__detail-container.sc-snk-guides-viewer{display:flex;row-gap:24px;flex-direction:column}.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-large)}.snk-guides-viewer__guide-navigator.sc-snk-guides-viewer{position:sticky;top:calc(var(--snk-guides-viewer__header--min-height) + var(--snk-guides-viewer--space-small));height:calc(100vh - var(--snk-guides-viewer__header--min-height) - var(--snk-guides-viewer--space-large) - var(--snk-guides-viewer--space-small))}.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{_ as S}
|
|
1
|
+
import{r as i,c as t,h as e,F as s,g as r}from"./p-82bb3eda.js";import{ObjectUtils as n,StringUtils as a,Action as d,KeyboardManager as o,ElementIDUtils as h}from"@sankhyalabs/core";import{SelectionMode as l}from"@sankhyalabs/core/dist/dataunit/DataUnit";import{buildFieldSearch as u,SHORTCUT_SEARCH_FIELD as v}from"@sankhyalabs/ezui/dist/collection/utils";import{buildFormMetadata as c,FormMetadata as g}from"@sankhyalabs/ezui/dist/collection/utils/form";import"./p-6768f176.js";import"./p-48a5c311.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-9e4555ab.js";import"./p-ff1990ad.js";import"./p-7ee6b1bf.js";import{V as k}from"./p-9019a32f.js";import{S as f}from"./p-2ac55a5d.js";import{T as p}from"./p-1be69fd4.js";import{T as w}from"./p-1a0caadb.js";const b="__FORM:",_=class{constructor(e){i(this,e),this.snkShowGuide=t(this,"snkShowGuide",7),this.snkMasterFormConfigChange=t(this,"snkMasterFormConfigChange",7),this.formConfigVisibilityChanged=t(this,"formConfigVisibilityChanged",7),this.exit=t(this,"exit",7),this.actionClick=t(this,"actionClick",7),this.formItemsReady=t(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 t=!!i;await this._viewStack.show(t?y.CONFIG:y.GUIDES),this.formConfigVisibilityChanged.emit(t)}observeDataState(i,t){var e,s,r,a,d,o;const h=null!==(s=null===(e=null==i?void 0:i.selectionInfo)||void 0===e?void 0:e.recordIds)&&void 0!==s?s:null===(r=null==i?void 0:i.selectedRecord)||void 0===r?void 0:r.__record__id__,l=null!==(d=null===(a=null==t?void 0:t.selectionInfo)||void 0===a?void 0:a.recordIds)&&void 0!==d?d:null===(o=null==t?void 0:t.selectedRecord)||void 0===o?void 0:o.__record__id__;n.equals(h,l)||this.loadGuides((null==t?void 0:t.insertionMode)!=(null==i?void 0:i.insertionMode))}observeMasterFormConfig(){this.loadGuides(this.noGuideSelected()),this.snkMasterFormConfigChange.emit(this.masterFormConfig)}async showFormConfig(i=!1){const t=!i||null==this._currentDetail;this._formEditorConfigManager=t?this._configManager:this._currentDetail.formConfigManager,this._formEditorDataUnit=t?this.dataUnit:this._currentDetail.dataUnit}async addCustomEditor(i,t){this._customEditors=Object.assign(Object.assign({},this._customEditors),{[i]:t})}async addGridCustomRender(i,t){this._customRenders=Object.assign(Object.assign({},this._customRenders),{[i]:t})}async setFieldProp(i,t,e){const s={[i]:Object.assign(Object.assign({},this._fieldsProps[i]),{[t]:e})};this._fieldsProps=Object.assign(Object.assign({},this._fieldsProps),s)}async setFocus(){var i;null===(i=this._container)||void 0===i||i.focus()}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===p.CONFIGURATOR&&"master"!=i.target.dataset.taskbarOwner&&(this._snkConfigurator.open(),i.stopImmediatePropagation(),i.stopPropagation())}onContentCardChanged(i){_.updateContentCard(i.detail.formName,i.detail.cardConfig,i.detail.propertyChanged,this._configManager).then((()=>this.masterFormConfig=this._configManager.getConfig(this.dataUnit)))}getMessage(i){var t,e;if(this.dataUnit.isMultipleEdition){const i=null!==(e=null===(t=this.dataUnit.getSelectionInfo())||void 0===t?void 0:t.records)&&void 0!==e?e:[];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=c(this.masterFormConfig,this.dataUnit,!0,this.customGuidesConfig);const t=this._masterFormMetadata.getAllSheets(),e=this.dataUnit.getSelectedRecord(),s=this.hasToDisableDetails(e),r=[];Array.from(t.values()).forEach((i=>{const t={id:i.name,label:i.label};this.isDetail(i.name)&&s&&(t.tooltip=this.getMessage("snkCrud.detail.tooltip.needSingleSelection"),t.disabled=!0),i.isCustom&&i.ctxProps&&Object.entries(i.ctxProps).forEach((([i,e])=>{void 0!==e&&(t[i]=e)})),r.push(t)})),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!=g.getDetailName(i)}updateGuide(i){this._guideBuilders.set(i.id,i);const t=i.buildGuideItem(this._guideBuilders);this._guideNavigator&&(this._guideNavigator.updateItem(t).then((()=>{this._guideNavigator.getCurrentPath().then((i=>{this._breadcrumbItems=i}))})),this._guides=this._guides.map((i=>i.id===t.id?Object.assign(Object.assign(Object.assign({},i),t),void 0!==t.children?{}:{children:void 0}):i)))}getTaskBarId(){var i;return(null===(i=this.dataState)||void 0===i?void 0:i.isDirty)?C.FINISH_EDITION:this.dataUnit.isMultipleEdition?C.MUTIPLE_EDITION:C.REGULAR}loadTaskbarProcessor(){const i={};i[C.REGULAR]=this.buildBtnsRegularMode(),i[C.FINISH_EDITION]=[p.CANCEL,p.SAVE,this.handleAddGridMode()],i[C.MUTIPLE_EDITION]=[p.CANCEL],this._taskbarProcessor=new w(i),this._taskbarProcessor.process(this.getTaskBarId(),this.taskbarManager,this.dataState,this.buildDisabledButtons(),this.buildInvisibleButtons())}buildBtnsRegularMode(){var i,t;const e=[p.ATTACH,p.CLONE,p.REMOVE,p.MORE_OPTIONS,p.ACTIONS_BUTTON,p.DIVIDER,p.GRID_MODE,p.CONFIGURATOR];return(null===(t=null===(i=this.dataState)||void 0===i?void 0:i.selectionInfo)||void 0===t?void 0:t.length)<=1&&e.unshift(p.PREVIOUS,p.NEXT,p.DIVIDER),this.presentationMode==m.SECONDARY?e.unshift(p.INSERT):e.push(p.INSERT),e}buildDisabledButtons(){var i,t,e,s,r,n;const a=[];return(null===(i=this.dataState)||void 0===i?void 0:i.hasPrevious)||a.push(p.PREVIOUS),(null===(t=this.dataState)||void 0===t?void 0:t.hasNext)||a.push(p.NEXT),(null===(s=null===(e=this.dataState)||void 0===e?void 0:e.selectionInfo)||void 0===s?void 0:s.length)>1&&a.push(p.CLONE),(null===(n=null===(r=this.dataState)||void 0===r?void 0:r.selectionInfo)||void 0===n?void 0:n.isAllRecords())&&a.push(p.REMOVE),a}handleAddGridMode(){return this.enableGridInsert?p.GRID_MODE:""}buildInvisibleButtons(){const i=[];return this.dataState&&this.dataState.selectionInfo.mode===l.ALL_RECORDS&&i.push(p.ACTIONS_BUTTON),i}static updateContentCard(i,t,e,s){return s.saveCardState(i,t,e)}static buildFixedForms(i){var t;const r=null===(t=i.formConfig)||void 0===t?void 0:t.cardsState;if(null!=r)return e(s,null,Array.from(r.entries()).filter((([t,e])=>(null==e?void 0:e.fixed)&&t!=i.selectedForm)).sort((([,i],[,t])=>((null==i?void 0:i.fixSequence)||0)-((null==t?void 0:t.fixSequence)||0))).map((([t,s])=>{var r,n;const a=i.formMetadata.getSheet(t);if(null!=a)return e("snk-form-view",{levelPath:i.levelPath,label:a.label,name:t,fields:a.fields,formMetadata:i.formMetadata,dataUnit:i.dataUnit,recordsValidator:i.recordsValidator,contracted:"CONTRACTED"===(null==s?void 0:s.presentation),fixed:null==s?void 0:s.fixed,summaryFields:null===(n=null===(r=i.formConfig)||void 0===r?void 0:r.summary)||void 0===n?void 0:n.get(t),fieldToFocus:i.fieldToFocus,key:t,onSnkRequestClearFieldToFocus:()=>{var t;return null===(t=i.onRequestClearFieldToFocus)||void 0===t?void 0:t.call(i)},customEditors:i.propsCustomEditor,fieldsProps:i.fieldsProps})})))}wrapDetail(i,t){if(0===i.length)return t;const s=i.pop(),r=g.getDetailName(s);return r?this.wrapDetail(i,e("snk-data-unit",{dataUnitName:`${this.getDataUnitName(i,r)}`,entityName:r},t)):void 0}getDataUnitName(i,t){if(i.length>0){const e=i.map((i=>g.getDetailName(i)));return`${this.entityPath}/${e.join("/")}/${t}`}return`${this.entityPath}/${t}`}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 e("slot",{name:i});const t=i.split("::"),s=t.pop(),r=g.getDetailName(s);let n=i;return this.isDetailGuide(r,t)?this.buildDetailGuideContent(i,n,t,r):this.buildFormViewGuideContent(i)}buildFormViewGuideContent(i){var t,s,r,n;const a=this._masterFormMetadata.getSheet(i);if(!a)return;const d=null===(s=null===(t=this.masterFormConfig)||void 0===t?void 0:t.cardsState)||void 0===s?void 0:s.get(i);return e("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},this.presentationMode==m.SECONDARY&&this.buildTaskBar())}isDetailGuide(i,t){return i||t.length>0}buildDetailGuideContent(i,t,s,r){var n;let a,d;if(i.includes(b)){[t,a]=i.split(b);const e=(null===(n=this._breadcrumbItems)||void 0===n?void 0:n.length)||0;d=e>1?this._breadcrumbItems[e-2]:this.selectedGuide}else d=this.selectedGuide;return this.wrapDetail(s,e("snk-detail-view",{ref:i=>this._currentDetail=i,dataUnitName:this.getDataUnitName(s,r),onSnkDetailGuidesChange:i=>this.updateGuide(i.detail),entityName:r,selectedForm:a,branchGuide:d,guideItemPath:this._breadcrumbItems,key:`detail${t}`,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 t;return null===(t=this.customGuidesConfig)||void 0===t?void 0:t.map((i=>i.id)).includes(i)}onBreadcrumbClickHandler(i){null!=(null==i?void 0:i.id)&&this._guideNavigator.selectGuide(i.id)}updateSelectedGuideHandler(i){this._guideHasChanged=this.selectedGuide!=i,this.selectedGuide=i,this._guideNavigator.getCurrentPath().then((i=>{this._breadcrumbItems=i})),this.resetGuideBadge(i)}changeGuideHandler(i){var t;null===(t=this._guideNavigator)||void 0===t||t.selectGuide(i)}clearFieldToFocusHandler(){this._fieldToGetFocus=void 0}resetGuideBadge(i){var t;this._guides=[...null===(t=this._guides)||void 0===t?void 0:t.map((t=>this.canClearGuideBadge(t,i.id)?Object.assign(Object.assign({},t),{badge:null}):t))]}canClearGuideBadge(i,t){return i.id===t||this.isIncludedInChildrenList(i,t)}isIncludedInChildrenList(i,t){return this.hasChildren(i)&&this.getChildrenIdList(i).includes(t)}hasChildren(i){return i.children&&Array.isArray(i.children)}getChildrenIdList(i){return i.children.map((i=>i.id))}getConfigViewMode(){return k.GRID}changeConfigViewMode(i){this._currentDetail&&this._currentDetail.changeViewMode(i)}openConfig(i){this._snkConfigurator.close(),this._currentDetail&&(i===k.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 f(this.configName,this.resourceID,this.setMasterFormConfig.bind(this),this.dataUnit),this.addFormLegacyConfigName(),this._configManager.loadConfig()}componentDidRender(){this._guideHasChanged&&(this._currentDetail?this._currentDetail.showUp():this._mainForm&&this._mainForm.showUp(),this._guideHasChanged=!1)}getFieldsSearch(i){return(null==this._fieldSearch||this._hasToCreateFieldSearch)&&(this._hasToCreateFieldSearch=!1,this._fieldSearch=u(i,(({argument:i})=>this.fieldsOptionLoader(i)),(i=>this.onSelectField(i)))),this._fieldSearch}fieldsOptionLoader(i){return Promise.resolve(this._configManager.getFieldsList(i).map((i=>({value:i.name,label:i.label}))))}onSelectField(i){if(null==i)return;this._fieldToGetFocus=i.value;const t=this.getGuideName(i.value);t!==this.selectedGuide.id&&this.changeGuideHandler(t)}getActionsList(){var i;return[].concat(null!=this.taskbarManager&&null!=this.taskbarManager.getMoreOptions?null!==(i=this.taskbarManager.getMoreOptions(this.getTaskBarId(),this.configName,this.dataState,this.actionsList))&&void 0!==i?i:[]:this.actionsList)}getSettingsListForm(){return[{value:a.generateUUID(),label:this.getMessage("snkCrud.findColumn"),disableCloseOnSelect:!0,eagerInitialize:!0,itemBuilder:(i,t)=>this.getFieldsSearch(t)}]}buildTaskBar(){var i;return e("div",{class:"snk-guides-viewer__header-taskbar "+(this.presentationMode!=m.SECONDARY?"ez-align--right":"ez-padding-bottom--medium")},e("snk-taskbar",{key:"guideViewerTaskbar","data-element-id":"guideViewer",configName:this.configName,buttons:this._taskbarProcessor.buttons,disabledButtons:this._taskbarProcessor.disabledButtons,customButtons:this._taskbarProcessor.customButtons,actionsList:this.getActionsList(),actionsSettingsList:this.getSettingsListForm(),messagesBuilder:this.messagesBuilder,presentationMode:this.presentationMode,primaryButton:(null===(i=this.dataState)||void 0===i?void 0:i.isDirty)?p.SAVE:p.INSERT,"data-taskbar-owner":"master",dataUnit:this.dataUnit,resourceID:this.resourceID,customSlotId:"GUIDES_VIEWER_TASKBAR_CUSTOM_ELEMENTS",additionalSlotId:"GUIDES_VIEWER_DYNAMIC_SEARCH",alignRigth:!0},e("slot",{name:"GUIDES_VIEWER_TASKBAR_CUSTOM_ELEMENTS"}),e("slot",{name:"GUIDES_VIEWER_DYNAMIC_SEARCH"})))}async dataUnitActionHandler(i){var t;switch(i.type){case d.EDITION_CANCELED:case d.DATA_SAVED:this.dataUnit.isMultipleEdition&&(this.exitViewer(),this.dataUnit.isMultipleEdition=!1);break;case d.FIELD_INVALIDATED:const e=this.getGuideName(null===(t=i.payload)||void 0===t?void 0:t.fieldName);await this.addErrorBadgeToGuide(e),await this.openGuideNavigator(e);break;case d.METADATA_LOADED:case d.MULTIPLE_EDITION_CHANGED:this.loadGuides(this.noGuideSelected())}}async addErrorBadgeToGuide(i){var t;this._guides=[...null===(t=this._guides)||void 0===t?void 0:t.map((t=>Object.assign(Object.assign({},t),{badge:this.getBadge(t,i)})))]}async openGuideNavigator(i){this.selectedGuide.id!==i&&await this._guideNavigator.openGuideNavidator()}getBadge(i,t){var e;return this.selectedGuide.id===t?null:t===i.id?"error":null!==(e=i.badge)&&void 0!==e?e:null}getGuideName(i){var t;for(const e of this._masterFormMetadata.getAllSheets()){const s=null===(t=e[1])||void 0===t?void 0:t.fields;for(const t of s)if(t.name===i)return e[0]}return""}getTitle(){var i,t;return null!==(t=null===(i=this.getCustomTitle)||void 0===i?void 0:i.call(this))&&void 0!==t?t:this.getMessage("snkCrud.title")}getTitleTooltip(){if(this.dataUnit.isMultipleEdition)return this.buildRecordIdsArray()}buildRecordIdsArray(){var i,t;const e=null!==(t=null===(i=this.dataUnit.getSelectionInfo())||void 0===i?void 0:i.records)&&void 0!==t?t:[];return 0===e.length?"[]":`[${e.map((i=>this.messagesBuilder.getMessage("snkCrud.title",i))).join(", ")}]`}getCustomGuidesConfig(){return this._currentDetail?[]:this.customGuidesConfig}componentDidLoad(){this.dataUnit.subscribe(this.dataUnitActionHandler.bind(this)),this.initKeyboardManager()}disconnectedCallback(){var i;null===(i=this._keyboardManager)||void 0===i||i.unbindAllShortcutKeys()}async initKeyboardManager(){this._keyboardManager=new o({propagate:!1,element:this._element}),this._keyboardManager.bind(v,(async()=>{this._mainForm&&await this._mainForm.showSearchField()}),{description:this.getMessage("snkSimpleCrud.findFields"),element:this._element})}renderFormConfig(){if(null!=this._formEditorConfigManager)return e("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 t,s;return e("section",{class:"snk-guides-viewer",ref:i=>this._container=i,tabIndex:-1},e("div",{class:"ez-row snk-guides-viewer__header"},e("div",{class:"snk-guides-viewer__header-breadcrumb ez-flex--align-items-center ez-flex-item--align-center ez-padding-left--large",key:"header"},e("ez-button",{onClick:()=>this.exitViewer(),title:this.getMessage("snkCrud.goBackTitle"),mode:"icon",iconName:"arrow_back",class:"ez-padding-right--medium",size:"small"}),e("div",{class:"ez-flex ez-flex--column ez-flex-item--auto"},e("h1",{class:"ez-title ez-title--primary ez-title--xlarge",title:this.getTitleTooltip()},this.getTitle()),(null===(t=this._breadcrumbItems)||void 0===t?void 0:t.length)>1&&e("div",{class:"ez-margin-top--extra-small"},e("ez-breadcrumb",Object.assign({items:this._breadcrumbItems,onSelectedItem:i=>this.onBreadcrumbClickHandler(null==i?void 0:i.detail)},{[h.DATA_ELEMENT_ID_ATTRIBUTE_NAME]:`${h.getInternalIDInfo("breadcrumb")}`}))))),this.presentationMode!=m.SECONDARY&&this.buildTaskBar()),e("div",{class:"snk-guides-viewer__container"},i?e("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)}):e("div",null),e("div",{class:"snk-guides-viewer__detail-container"},_.buildFixedForms({formConfig:this.masterFormConfig,formMetadata:this._masterFormMetadata,selectedForm:null===(s=this.selectedGuide)||void 0===s?void 0:s.id,dataUnit:this.dataUnit,recordsValidator:this.recordsValidator,fieldToFocus:this._fieldToGetFocus,onRequestClearFieldToFocus:this.clearFieldToFocusHandler.bind(this),propsCustomEditor:this._customEditors,fieldsProps:this._fieldsProps}),this.getContent())),e("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}))}render(){if(this.dataUnit&&this._configManager.isLoaded)return this.loadTaskbarProcessor(),e("ez-view-stack",{ref:i=>this._viewStack=i,"data-element-id":"guides-viewer-stack"},e("stack-item",null,this.renderGuidesNavigator(this._guides&&this._guides.length>1)),e("stack-item",null,this.renderFormConfig()))}get _element(){return r(this)}static get watchers(){return{dataUnit:["observeDataUnit"],_formEditorConfigManager:["observeFormConfigManager"],dataState:["observeDataState"],masterFormConfig:["observeMasterFormConfig"]}}};var C,y;!function(i){i.FINISH_EDITION="snkGuideViewer.finish_edition",i.MUTIPLE_EDITION="snkGuideViewer.multiple_edition",i.REGULAR="snkGuideViewer.regular"}(C||(C={})),function(i){i[i.GUIDES=0]="GUIDES",i[i.CONFIG=1]="CONFIG"}(y||(y={})),_.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:68px;--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;display:block}snk-form-view.sc-snk-guides-viewer{width:100%}.snk-guides-viewer.sc-snk-guides-viewer{position:relative;padding-left:0px;padding-top:0px;padding-right:var(--snk-guides-viewer--space-large);padding-bottom:var(--snk-guides-viewer--space-large)}.snk-guides-viewer__detail-container.sc-snk-guides-viewer{display:flex;row-gap:24px;flex-direction:column}.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-large)}.snk-guides-viewer__guide-navigator.sc-snk-guides-viewer{position:sticky;top:calc(var(--snk-guides-viewer__header--min-height) + var(--snk-guides-viewer--space-small));height:calc(100vh - var(--snk-guides-viewer__header--min-height) - var(--snk-guides-viewer--space-large) - var(--snk-guides-viewer--space-small))}.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{_ as S}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as t,c as s,h as i,g as e}from"./p-
|
|
1
|
+
import{r as t,c as s,h as i,g as e}from"./p-82bb3eda.js";import{ElementIDUtils as h}from"@sankhyalabs/core";import{F as o}from"./p-ff1990ad.js";const a=class{constructor(i){t(this,i),this.valueChanged=s(this,"valueChanged",7),this.value=void 0,this.config=void 0,this.errorMessage=void 0}ezChangeListener(t){var s;this.errorMessage=void 0,this.value=null===(s=t.detail)||void 0===s?void 0:s.value,this.valueChanged.emit(this.value)}async setFocus(){this._comboElement.setFocus()}async clearValue(){this.value=this.config.value,this._comboElement&&(this._comboElement.value=this.config.value)}componentDidLoad(){this._element&&h.addIDInfo(this._element,"filterContentEditor")}render(){if(this.config&&this.config.type===o.MULTI_SELECT)return i("ez-tooltip",{active:!1===this.config.enabled,message:this.config.disabledMessage,type:"warning"},i("ez-combo-box",{id:this.config.id,ref:t=>this._comboElement=t,label:this.config.label,value:this.config.value,options:this.config.props.options,enabled:this.config.enabled,errorMessage:this.errorMessage,onEzVisibilityChange:t=>{t.stopPropagation()}}))}get _element(){return e(this)}};export{a as snk_filter_multi_select}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as t,c as s,h as i,g as e}from"./p-
|
|
1
|
+
import{r as t,c as s,h as i,g as e}from"./p-82bb3eda.js";import{ElementIDUtils as h}from"@sankhyalabs/core";const a=class{constructor(i){t(this,i),this.valueChanged=s(this,"valueChanged",7),this.config=void 0,this.value=void 0,this.errorMessage=void 0}ezChangeListener(t){this.errorMessage=void 0,this.value=t.detail,this.valueChanged.emit(this.value)}async setFocus(){this._textInputElement.setFocus()}async clearValue(){this.value=this.config.value,this._textInputElement&&(this._textInputElement.value=this.config.value)}componentDidLoad(){this._element&&h.addIDInfo(this._element,"filterContentEditor")}render(){var t;if(this.config)return i("ez-tooltip",{active:!1===this.config.enabled,message:this.config.disabledMessage,type:"warning"},i("ez-text-input",{id:this.config.id,label:this.config.label,ref:t=>this._textInputElement=t,value:this.config.value,mask:null===(t=this.config)||void 0===t?void 0:t.mask,enabled:this.config.enabled,cleanValueMask:!0,errorMessage:this.errorMessage}))}get _element(){return e(this)}};export{a as snk_filter_text}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as t,c as i,h as o,H as n}from"./p-
|
|
1
|
+
import{r as t,c as i,h as o,H as n}from"./p-82bb3eda.js";import{ObjectUtils as s}from"@sankhyalabs/core";import{ApplicationUtils as e}from"@sankhyalabs/ezui/dist/collection/utils";const a=class{constructor(o){t(this,o),this.formConfigOptionSelected=i(this,"formConfigOptionSelected",7),this.configOptions=[],this.selectedConfig=void 0,this.hasChanges=!1,this.messagesBuilder=void 0}getMessage(t,i){return this.messagesBuilder.getMessage(t,i)}async showShareConfigOptions(){this._refOptionsPopover&&this._refShareConfigBtn&&await this._refOptionsPopover.showUnder(this._refShareConfigBtn)}async handleSelectOption(t){if(!s.equals(t,this.selectedConfig)){if(this.hasChanges){const t=this.getMessage("snkFormConfig.confirm.title"),i=this.getMessage("snkFormConfig.confirm.cancel");if(!await e.confirm(t,i))return}this.selectedConfig=t,this.formConfigOptionSelected.emit(t),await this._refOptionsPopover.hide()}}getButtonLabel(){var t,i;return null!==(i=null===(t=this.selectedConfig)||void 0===t?void 0:t.name)&&void 0!==i?i:this.getMessage("snkFormConfig.configs.buttonLabel")}renderConfigOptions(){return this.configOptions.map((t=>o("div",{class:"main-item",onClick:async()=>await this.handleSelectOption(t)},o("span",{class:"item-label"}," ",t.name),this.renderCheckIcon(t))))}renderCheckIcon(t){if(this.selectedConfig&&this.selectedConfig.origin===t.origin)return o("ez-icon",{iconName:"check"})}render(){return o(n,null,o("ez-button",{ref:t=>this._refShareConfigBtn=t,label:this.getButtonLabel(),onClick:async()=>await this.showShareConfigOptions()},o("ez-icon",{slot:"rightIcon",iconName:"chevron-down"})),o("ez-popover-plus",{ref:t=>this._refOptionsPopover=t,autoClose:!0,overlayType:"none"},o("div",{class:"dropdown-container"},this.renderConfigOptions())))}};a.style=".dropdown-container.sc-configs-button{font-family:'Roboto';font-size:12px;font-weight:400;display:flex;flex-direction:column;color:#2b3a54;width:200px}.main-item.sc-configs-button{padding:12px;font-size:14px;cursor:pointer;transition:all .2s ease-in-out;display:flex;flex-direction:row;gap:8px;align-items:center;justify-content:start}.main-item.sc-configs-button ez-icon.sc-configs-button{--ez-icon--color:#008561}.main-item.sc-configs-button:nth-of-type(1){padding-bottom:6px}.main-item.sc-configs-button:nth-of-type(2){padding-top:6px}.main-item.sc-configs-button:hover{background-color:#FAFCFF}.item-label.sc-configs-button{display:flex}";export{a as configs_button}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as i,c as t,h as s,g as e}from"./p-d8d8169b.js";import{StringUtils as n,ApplicationContext as o,ObjectUtils as h,Action as a,DataType as r,UserInterface as d,KeyboardManager as l,ElementIDUtils as u}from"@sankhyalabs/core";import{CSSVarsUtils as c,buildFieldSearch as m}from"@sankhyalabs/ezui/dist/collection/utils";import{V as p,S as g}from"./p-9019a32f.js";import{T as v}from"./p-b987e15d.js";import"./p-6768f176.js";import"./p-48a5c311.js";import{S as f,R as C,b,a as S,c as k}from"./p-3f68a254.js";import{P as y}from"./p-0f3698af.js";import"@sankhyalabs/ezui/dist/collection/utils/constants";import"@sankhyalabs/core/dist/dataunit/metadata/UnitMetadata";import{I as w}from"./p-9e4555ab.js";import"./p-ff1990ad.js";import{F}from"./p-7ee6b1bf.js";import{T as E}from"./p-1a0caadb.js";import{C as T}from"./p-1f310bc6.js";import{S as I}from"./p-2ac55a5d.js";import{s as _}from"./p-55798617.js";import"./p-8d884fab.js";import"./p-7dd49d15.js";import"./p-8f3f2306.js";import"@sankhyalabs/ezui/dist/collection/components/ez-grid/utils/InMemoryFilterColumnDataSource";import"@sankhyalabs/ezui/dist/collection/components/ez-grid/utils";import"@sankhyalabs/core/dist/utils/SortingUtils";import"./p-688dcb4c.js";const z=["INSERT","REFRESH","PREVIOUS","NEXT","DIVIDER","MORE_OPTIONS"],R=["INSERT","REFRESH","PREVIOUS","NEXT","DIVIDER","CLONE","REMOVE","DIVIDER","MORE_OPTIONS"],M=class{constructor(s){i(this,s),this.dataStateChange=t(this,"dataStateChange",3),this.dataUnitReady=t(this,"dataUnitReady",3),this.actionClick=t(this,"actionClick",7),this.formItemsReady=t(this,"formItemsReady",7),this.configuratorSave=t(this,"configuratorSave",7),this.configuratorCancel=t(this,"configuratorCancel",7),this._multiSelectionListDataSource=new f,this._formConfigFetcher=new F,this._customEditors=new Map,this._customRenders=new Map,this._container=void 0,this._showPopUpGridConfig=!1,this._currentViewMode=p.GRID,this._config=void 0,this._fieldToGetFocus=void 0,this._customContainerId=`SNK-SIMPLE-CRUD-CUSTOM-CONTAINER-${n.generateUUID()}`,this.enableLockManagerLoadingComp=!1,this.enableLockManagerTaskbarClick=!1,this.dataState=void 0,this.dataUnit=void 0,this.entityName=void 0,this.mode=g.SERVER,this.gridConfig=void 0,this.formConfig=void 0,this._formFields=[],this._fieldsProps=new Map,this.enableContinuousInsert=!1,this.multipleSelection=void 0,this.useCancelConfirm=!0,this.pageSize=150,this.resourceID=void 0,this.enableGridInsert=!1,this.paginationCounterMode="auto",this.taskbarManager=void 0,this.messagesBuilder=void 0,this.useEnterLikeTab=!1,this.actionsList=void 0,this.configName=void 0,this.showConfiguratorButtons=!1,this.gridLegacyConfigName=void 0,this.formLegacyConfigName=void 0,this.ignoreReadOnlyFormFields=!1,this.autoFocus=!0,this.domainMessagesBuilder=void 0,this.multipleEditionEnabled=!0,this.layoutFormConfig=!0,this.autoLoad=void 0,this.outlineMode=!1}async addCustomEditor(i,t){if(this._grid&&this._form)return this._grid.addCustomEditor(i,t),void this._form.addCustomEditor(i,t);const s=new Map(this._customEditors);s.set(i,t),this._customEditors=s}async addGridCustomRender(i,t){if(this._grid)return void this._grid.addGridCustomRender(i,t);const s=new Map(this._customRenders);s.set(i,t),this._customRenders=s}async handleResourceIDChanged(i,t){n.isEmpty(i)||i!==t&&(await this.loadFormConfig(!0),await this.loadGridConfig(!0))}async addCustomValueFormatter(i,t){this._grid.addCustomValueFormatter(i,t)}async removeCustomValueFormatter(i){this._grid.removeCustomValueFormatter(i)}async setFieldProp(i,t,s){const e=new Map(this._fieldsProps),n=this._fieldsProps.get(i);e.set(i,Object.assign(Object.assign({},n),{[t]:s})),this._fieldsProps=e}loadTaskbarProcessor(){const i={};i[D.FORM_REGULAR]=this.getButtons(!1,[v.GRID_MODE],!0),i[D.GRID_REGULAR]=this.getButtons(!1,[v.DATA_EXPORTER,v.FORM_MODE]),i[D.FORM_SELECTED]=this.getButtons(!0,[v.GRID_MODE],!0),i[D.GRID_SELECTED]=this.getGridSelectedButtonsCallBack.bind(this),i[D.FINISH_EDITION]=this.getFinishEditionButtonsCallback.bind(this),i[D.MULTIPLE_EDITION]=[v.CANCEL],this._taskbarProcessor=new E(i)}getGridSelectedButtonsCallBack(){var i,t,s;return this.multipleEditionEnabled&&1!==(null===(s=null===(t=null===(i=this.dataState)||void 0===i?void 0:i.selectionInfo)||void 0===t?void 0:t.records)||void 0===s?void 0:s.length)?this.getButtons(!0,[v.UPDATE_MULTIPLE,v.DATA_EXPORTER,v.FORM_MODE]):this.getButtons(!0,[v.DATA_EXPORTER,v.FORM_MODE])}getFinishEditionButtonsCallback(){const i=[v.CANCEL,v.SAVE];return this.enableGridInsert&&this._currentViewMode!==p.ATTACHMENT&&i.push(this._currentViewMode===p.GRID?v.FORM_MODE:v.GRID_MODE),i}getButtons(i,t,s){let e=i?R:z;return(s||this.mode===g.IN_MEMORY)&&(e=e.filter((i=>i!==v.REFRESH))),this.addConfigButton(e.concat(t))}addConfigButton(i){return void 0===this.configName||this.configName&&this.gridLegacyConfigName?i:i.concat(v.CONFIGURATOR)}get application(){return o.getContextValue("__SNK__APPLICATION__")}async goToView(i){this._currentViewMode=i,this._viewStack&&(i===p.GRID&&(this.dataUnit.isMultipleEdition=!1),this._viewStack.show(i)),i===p.GRID&&requestAnimationFrame((()=>this.focusToGrid())),i===p.FORM&&requestAnimationFrame((()=>this.focusToForm()))}actionClickListener(i){this.handleTaskbarAction(i.detail),i.stopPropagation()}handleTaskbarAction(i){switch(i){case v.CONFIGURATOR:this._snkConfigurator.open();break;case v.GRID_MODE:this.goToView(p.GRID);break;case v.FORM_MODE:this.goToView(p.FORM);break;case v.UPDATE_MULTIPLE:this.dataUnit.isMultipleEdition=!0,this.goToView(p.FORM)}}async onChangeEntityName(i){if(this.dataUnit)return;const t=o.getContextValue("__SNK__APPLICATION__");this.dataUnit=await t.getDataUnit(i,null,null,this.configName)}onModeChange(){this.mode==g.IN_MEMORY&&this.initInMemoryDataUnit()}observeDataState(i,t){this.handleDataStateChange(i,t)}async observeFormLegacy(i,t){await this.handleUpdateFormLegacyConfig(i,t)}async observeGridLegacy(i,t){await this.handleUpdateGridLegacyConfig(i,t)}async handleDataStateChange(i,t){h.objectToString(t)!=h.objectToString(i)&&this.dataStateChange.emit(i),await this.processRmPrecision()}async processRmPrecision(){var i,t;const s=await this._snkDataUnit.getFieldsWithRmPrecision();for(const e of s||[]){if(!e)continue;const s=null===(t=null===(i=this.dataState)||void 0===i?void 0:i.rowMetadata)||void 0===t?void 0:t.getProp("rm_precision",e);(s||0===s)&&(await this.setFieldProp(e,"precision",s),await this.setFieldProp(e,"prettyPrecision",s))}this._rmPrecisionCustomValueFormatter.setDataState(this.dataState)}async handleUpdateGridLegacyConfig(i,t){null!=i&&i!=t&&this._gridConfigAlreadyLoaded&&await this.loadGridConfig(!0)}async handleUpdateFormLegacyConfig(i,t){null!=i&&i!=t&&this._formConfigAlreadyLoaded&&await this.loadFormConfig(!0)}openConfig(i){this._snkConfigurator.close(),i===p.GRID?this.openGridConfig():i===p.FORM&&this.openFormConfig()}openGridConfig(){this._grid.getColumnsState().then((i=>{this._snkGridConfig.columns=i.filter((i=>i.name)),this._snkGridConfig.selectedIndex=0,this._showPopUpGridConfig=!0}))}async openFormConfig(){(this.formLegacyConfigName||this.configName)&&await this._snkSimpleFormConfig.show()}addGridLegacyConfigName(){this.gridLegacyConfigName&&this.configName&&T.addGridLegacyConfig(this.configName,this.gridLegacyConfigName)}loadGridConfig(i){if(void 0!==this.configName&&(null==this.gridConfig&&!this._gridConfigAlreadyLoaded||i))return this.addGridLegacyConfigName(),this._gridConfigAlreadyLoaded=!0,new Promise(((i,t)=>{T.loadGridConfig(this.configName,this.resolveResourceID()).then((t=>{this.setGridConfig(t),i()})).catch((i=>{t(i)}))}))}formConfigIsLoaded(){return null!=this.formConfig||this._formConfigAlreadyLoaded}async loadFormConfig(i=!1,t=!1){if(void 0===this.configName)return;if(null==this._formConfigManager&&(this._formConfigManager=new I(this.configName,this.resolveResourceID(),void 0,this.dataUnit),this._formConfigManager.setConfig(this.formConfig)),this.formConfigIsLoaded()&&!i)return;this._formConfigAlreadyLoaded=!0;let s=await this._formConfigFetcher.fetchLegacyConfigurableForm(this.formLegacyConfigName);if(null!=s)return this._formConfigManager.setConfig(s),void this.setFormConfig(s,t);this.setFormConfig(await this._formConfigManager.loadConfig())}async componentWillRender(){this.loadTaskbarProcessor(),this._resourceID=await this.application.getResourceID(),this.dataExporterProviderStore(),this.dataExporterProviderStore(),this._taskbarProcessor.process(this.getTaskBarId(),this.taskbarManager,this.dataState,this.getTaskBarDisabledButtons()),void 0!==this.configName&&(null!=this.gridConfig||this._gridConfigAlreadyLoaded||(await this.addGridLegacyConfigName(),await this.loadGridConfig(),await this.loadFormConfig()))}componentDidRender(){this._rmPrecisionCustomValueFormatter.setGrid(this._grid),this.addGridCustomValueFormattters(),this.setFieldsProps(),this.setCustomRenders(),this.setCustomEditors()}componentWillLoad(){this.processMetadata(),this.onModeChange(),this.configDatasource(),this._rmPrecisionCustomValueFormatter=new C,this._continuousInsertUtils=new b(this.application,this.resolveResourceID(),this.configName),this.enableGridInsert&&this._continuousInsertUtils.getConfig().then((i=>this.enableContinuousInsert=i))}componentDidLoad(){c.applyVarsGrid(this._element,this._grid),this.initKeyboardManager(),this.dataUnit.subscribe(this.dataUnitActionHandler.bind(this))}async dataUnitActionHandler(i){i.type!==a.EDITION_CANCELED&&i.type!==a.DATA_SAVED||this.dataUnit.isMultipleEdition&&this.goToView(p.GRID)}getMessage(i,t){var s;return null===(s=this.messagesBuilder)||void 0===s?void 0:s.getMessage(i,t)}disconnectedCallback(){var i;null===(i=this._keyboardManager)||void 0===i||i.unbindAllShortcutKeys()}setCustomRenders(){if(this._grid)for(const[i,t]of this._customRenders)this._grid.addGridCustomRender(i,t),this._customRenders.delete(i)}setCustomEditors(){if(this._grid&&this._form)for(const[i,t]of this._customEditors)this._grid.addCustomEditor(i,t),this._form.addCustomEditor(i,t),this._customEditors.delete(i)}configDatasource(){this._multiSelectionListDataSource.setApplication(this.application),this._multiSelectionListDataSource.setDataUnit(this.dataUnit)}setFieldsProps(){if(this._form)for(const[i,t]of this._fieldsProps){for(const s in t)this._form.setFieldProp(i,s,t[s]);this._fieldsProps.delete(i)}}getTaskBarId(){var i,t;return(null===(i=this.dataState)||void 0===i?void 0:i.isDirty)?D.FINISH_EDITION:this.dataUnit.isMultipleEdition?D.MULTIPLE_EDITION:(null===(t=this.dataState)||void 0===t?void 0:t.selectionInfo)&&!this.dataState.selectionInfo.isAllRecords()&&this.dataState.selectionInfo.length>0?this._currentViewMode===p.GRID?D.GRID_SELECTED:D.FORM_SELECTED:this._currentViewMode===p.GRID?D.GRID_REGULAR:D.FORM_REGULAR}initInMemoryDataUnit(){this._inMemoryLoader=new w(this._metadata,void 0,{autoLoad:this.autoLoad}),this.dataUnit=this._inMemoryLoader.dataUnit,this.dataUnitReady.emit(this.dataUnit)}setMetadata(i){return this._inMemoryLoader?this._inMemoryLoader.metadata=i:this.dataUnit&&(this.dataUnit.metadata=i),Promise.resolve()}setRecords(i){return this._inMemoryLoader?this._inMemoryLoader.records=i:this.dataUnit&&(this.dataUnit.records=i),Promise.resolve()}getRecords(){return Promise.resolve(this.dataUnit.records)}async openConfigurator(){var i;null===(i=this._snkConfigurator)||void 0===i||i.open()}async closeConfigurator(){var i;null===(i=this._snkConfigurator)||void 0===i||i.close()}async updateConfig(){null==this._formConfigManager&&(this._formConfigManager=new I(this.configName,this.resolveResourceID())),this._formConfigManager.setConfig(this.formConfig)}processMetadata(){const i=this._element.querySelectorAll("snk-field-metadata"),t=[],s={fields:[],emptyConfig:!1};i.forEach((i=>{const e={name:i.getAttribute("name")||i.getAttribute("label"),label:i.getAttribute("label"),dataType:r[i.getAttribute("dataType")]||r.TEXT,userInterface:d[i.getAttribute("userInterface")]||d.SHORTTEXT,readOnly:"true"==i.getAttribute("readOnly"),required:"true"==i.getAttribute("required"),tab:i.getAttribute("tab")||void 0,visible:"false"!=i.getAttribute("visible")};s.fields.push({name:e.name,tab:e.tab,visible:e.visible}),t.push(e)})),t.length>0&&(this.formConfig||(this.formConfig=s),this._metadata={name:"SimpleCrud",label:"SimpleCrud",fields:t})}addGridCustomValueFormattters(){var i,t,s;const e=(null===(i=this._metadata)||void 0===i?void 0:i.fields)||(null===(s=null===(t=this.dataUnit)||void 0===t?void 0:t.metadata)||void 0===s?void 0:s.fields);if(!e)return;const n=[];e.forEach((i=>{var t;(null===(t=i.properties)||void 0===t?void 0:t.rm_precision)&&!n.includes(i.name)&&n.push(i.name)})),n.forEach((i=>{this.addCustomValueFormatter(i,this._rmPrecisionCustomValueFormatter)}))}onDataStateChange(i){this.dataState=Object.assign({},i.detail)}getTaskBarDisabledButtons(){var i,t,s,e,n,o;const h=[];return(null===(i=this.dataState)||void 0===i?void 0:i.hasNext)||h.push(v.NEXT),(null===(t=this.dataState)||void 0===t?void 0:t.hasPrevious)||h.push(v.PREVIOUS),(null===(e=null===(s=this.dataState)||void 0===s?void 0:s.selectionInfo)||void 0===e?void 0:e.isEmpty())&&h.push(v.FORM_MODE),(null===(o=null===(n=this.dataState)||void 0===n?void 0:n.selectionInfo)||void 0===o?void 0:o.length)>1&&h.push(v.CLONE),h}handleCancelEdit(){var i;(null===(i=this.dataState)||void 0===i?void 0:i.recordsIsEmpty)&&(this.goToView(p.GRID),this.dataUnit.clearSelection())}handleConfiguratorEvent(i,t){i.stopImmediatePropagation(),"SAVE"!==t?this.configuratorCancel.emit():this.configuratorSave.emit()}onSelectField(i){null!=i&&(this._fieldToGetFocus=i.value)}getFieldSearch(i,t){return null!=this._fieldSearch||(this._splitButtonForm=i,this._fieldSearch=m(t,(({argument:i})=>this.fieldsOptionLoader(i)),(i=>this.onSelectField(i)))),this._fieldSearch}getFormFields(){var i,t;return null!==(t=null===(i=this.formConfig)||void 0===i?void 0:i.fields)&&void 0!==t?t:this._formFields}handleFormSetFields(i){h.equals(this._formFields,i)||(this._formFields=null!=i?i:[])}fieldsOptionLoader(i){const t=null==i?void 0:i.toLowerCase(),s=this.getFormFields().map((i=>{var t;return null===(t=this.dataUnit)||void 0===t?void 0:t.getField(i.name)})).filter((i=>{var s,e;return(null===(s=i.name)||void 0===s?void 0:s.toLowerCase().includes(t))||(null===(e=i.label)||void 0===e?void 0:e.toLowerCase().includes(t))})).map((i=>({value:i.name,label:i.label})));return Promise.resolve(s)}isGridInsertActive(){return this.enableGridInsert&&this.dataUnit.hasNewRecord()}getColumnSearch(i,t){return null!=this._columnSearch||(this._splitButton=i,this._columnSearch=m(t,(({argument:i})=>new Promise((t=>{this._grid.filterColumns(i).then((i=>{t(i.filter((i=>!i.hidden)).map((i=>({label:i.label,value:i.name}))))}))}))),(i=>{null!=i&&this._grid.locateColumn(i.value)}))),this._columnSearch}getActionsList(){const i=[];if(this.enableGridInsert&&i.push(this._continuousInsertUtils.actionContinuousInsert(this.enableContinuousInsert,(()=>{this.enableContinuousInsert=!this.enableContinuousInsert,this._continuousInsertUtils.handleSaveConfig(this.enableContinuousInsert)}))),this.isGridInsertActive())return i;if(null!=this.taskbarManager&&null!=this.taskbarManager.getMoreOptions){const t=this.getTopTaskBarId();return i.concat(this.taskbarManager.getMoreOptions(t,this.configName,this.dataState,this.actionsList))}return i.concat(this.actionsList)}getSettingsListGrid(){return[{value:n.generateUUID(),label:this.getMessage("snkSimpleCrud.findColumn"),disableCloseOnSelect:!0,eagerInitialize:!0,itemBuilder:(i,t)=>this.getColumnSearch(i,t)}]}getSettingsListForm(){return[{value:n.generateUUID(),label:this.getMessage("snkSimpleCrud.findFields"),disableCloseOnSelect:!0,eagerInitialize:!0,itemBuilder:(i,t)=>this.getFieldSearch(i,t)}]}getTopTaskBarId(){var i;return(null===(i=this.dataState)||void 0===i?void 0:i.isDirty)?`snkGridTopTaskbar.finish_edition${y.PRIMARY}`:`snkGridTopTaskbar.regular${y.PRIMARY}`}clearFieldToFocusHandler(){this._fieldToGetFocus=void 0}gridConfigChangeHandler(i){i.stopPropagation(),this.configName&&T.saveGridConfig(i.detail,this.configName,this.resolveResourceID())}modalConfigChangeHandler(i){const t=i.detail;this._grid.setColumnsState(t.columns).then((()=>{this.setGridConfig(t),this.closeGridConfig(),this.dataExporterProviderStore()})),i.stopPropagation()}async dataExporterProviderStore(){if(null==this.dataUnit)return;if(null==this._grid)return;const i=new k(this.dataUnit,this._grid);_.set("exporterProviders",Object.assign(Object.assign({},_.get("exporterProviders")),{[this.getDataExporterStoreKey()]:i}))}getDataExporterStoreKey(){return`SnkSimpleCrudDataExporter:${null==this.configName?this.dataUnit.name:this.configName}`}setGridConfig(i){this.gridConfig=i,S.assertDefaultSorting(this.gridConfig,this.dataUnit)}setFormConfig(i,t){this.formConfig&&!t||(this.formConfig=i)}closeGridConfig(){this._showPopUpGridConfig=!1}getPageSize(){return this.mode===g.IN_MEMORY?0:null==this.pageSize?150:this.pageSize}resolveResourceID(){return n.isEmpty(this.resourceID)?this._resourceID:this.resourceID}getFormConfig(){var i;const t=null===(i=this._formConfigManager)||void 0===i?void 0:i.getConfig(this.dataUnit,this.ignoreReadOnlyFormFields);return this.configName||t?t:this.formConfig}updateFormConfig(){let i=this.formConfig;null==this.formLegacyConfigName&&(i=Object.assign(Object.assign({},this.formConfig),{fields:this.dataUnit.metadata.fields})),this.setFormConfig(i,!0),null==this._formConfigManager&&(this._formConfigManager=new I(this.configName,this.resolveResourceID())),this._formConfigManager.setConfig(this.formConfig)}handleDataUnitOnInsertionMode(){this.enableGridInsert||this.goToView(p.FORM)}async initKeyboardManager(){var i;this._keyboardManager=new l({propagate:!1,element:this._element});const t=this.dataUnit||await(null===(i=this._snkDataUnit)||void 0===i?void 0:i.getDataUnit());null!=t&&this._keyboardManager.bind("F7",(()=>t.saveData()),{description:this.getMessage("snkSimpleCrud.keyboardShortcuts.saveData"),element:this._element}).bind("F8",t.addRecord.bind(t),{description:this.getMessage("snkSimpleCrud.keyboardShortcuts.addRecord"),element:this._element}).bind("F9",t.removeSelectedRecords.bind(t),{description:this.getMessage("snkSimpleCrud.keyboardShortcuts.removeRecord"),element:this._element}).bind("Escape",(()=>{t.isDirty()&&t.cancelEdition()}),{debounceTime:1e3,description:this.getMessage("snkSimpleCrud.keyboardShortcuts.cancelAction"),element:this._element})}async handleFormConfigSaved(){await this.loadFormConfig(!0,!0)}focusToGrid(){this._grid.focus()}focusToForm(){this._form.focus()}renderTaskbarContent(i){var t;return s("snk-taskbar",{class:"ez-box--no-outline ez-box "+(this._currentViewMode===p.FORM?(this.outlineMode?"ez-box--outline":"ez-box--shadow-xsmall")+" ez-padding--small":""),dataUnit:this.dataUnit,primaryButton:(null===(t=this.dataState)||void 0===t?void 0:t.isDirty)?"SAVE":"INSERT","data-element-id":"grid_left",messagesBuilder:this.messagesBuilder,buttons:this._taskbarProcessor.buttons,actionsList:this.getActionsList(),actionsSettingsList:i===p.GRID?this.getSettingsListGrid():this.getSettingsListForm(),disabledButtons:this._taskbarProcessor.disabledButtons,customButtons:this._taskbarProcessor.customButtons,"data-exporter-store-key":this.getDataExporterStoreKey(),slot:"leftButtons",presentationMode:y.SECONDARY,tabindex:"0"},s("slot",{name:"TASKBAR_CUSTOM_ELEMENTS"}))}render(){var i;if(null!=this.dataUnit)return s("snk-data-unit",{ref:i=>this._snkDataUnit=i,class:"simple-crud__container",dataUnit:this.dataUnit,useCancelConfirm:this.useCancelConfirm,onDataStateChange:i=>this.onDataStateChange(i),onCancelEdition:this.handleCancelEdit.bind(this),pageSize:this.getPageSize(),onInsertionMode:this.handleDataUnitOnInsertionMode.bind(this),onDataUnitReady:i=>this.dataUnitReady.emit(i.detail),onMessagesBuilderUpdated:i=>this.messagesBuilder=i.detail,onDataUnitFieldsHidded:this.updateFormConfig.bind(this),domainMessagesBuilder:this.domainMessagesBuilder},s("header",null,s("slot",{name:"snkSimpleCrudHeader"})),s("section",{class:`ez-box ez-box--no-outline ${this.outlineMode?"ez-box--outline":"ez-box--shadow"} simple-crud__container-section`,ref:i=>this._container=i,tabindex:"0"},s("ez-view-stack",{ref:i=>this._viewStack=i,"data-element-id":"simple-crud"},s("stack-item",null,s("ez-grid",{class:"ez-margin-bottom--large ez-box--no-outline",ref:i=>this._grid=i,dataUnit:this.dataUnit,config:this.gridConfig,"no-header":!0,multipleSelection:this.multipleSelection,onEzDoubleClick:()=>this.goToView(p.FORM),onConfigChange:i=>this.gridConfigChangeHandler(i),columnfilterDataSource:this.dataUnit.name&&this.dataUnit.name.includes(w.IN_MEMORY_DATA_UNIT_NAME)?void 0:this._multiSelectionListDataSource,useEnterLikeTab:this.useEnterLikeTab,autoFocus:this.autoFocus,enableGridInsert:this.enableGridInsert,enableContinuousInsert:this.enableContinuousInsert,enableLockManagerTaskbarClick:this.enableLockManagerTaskbarClick,enableLockManagerLoadingComp:this.enableLockManagerLoadingComp,outlineMode:this.outlineMode,tabindex:"0",paginationCounterMode:this.paginationCounterMode},this.renderTaskbarContent(p.GRID),s("div",{slot:"footer"},s("slot",{name:"snkSimpleCrudFooter"})))),s("stack-item",null,this.renderTaskbarContent(p.FORM),s("ez-form",{ref:i=>this._form=i,class:"ez-margin-top--large ez-box--no-outline",dataUnit:this.dataUnit,config:this.getFormConfig(),fieldToFocus:this._fieldToGetFocus,onEzFormSetFields:i=>this.handleFormSetFields(i.detail),onEzFormRequestClearFieldToFocus:this.clearFieldToFocusHandler.bind(this),elementFocusSearchField:this._container,tabindex:"0"}),s("snk-simple-form-config",{ref:i=>this._snkSimpleFormConfig=i,dataUnit:this.dataUnit,onSnkConfigSaved:this.handleFormConfigSaved.bind(this),configName:null!==(i=this.formLegacyConfigName)&&void 0!==i?i:this.configName,messagesBuilder:this.messagesBuilder})),this.messagesBuilder&&s("snk-configurator",{ref:i=>this._snkConfigurator=i,viewMode:this._currentViewMode,messagesBuilder:this.messagesBuilder,onConfigSelected:i=>this.goToView(i.detail),onOpenConfig:i=>this.openConfig(i.detail),showActionButtons:this.showConfiguratorButtons,onSave:i=>this.handleConfiguratorEvent(i,"SAVE"),onCancel:i=>this.handleConfiguratorEvent(i,"CANCEL"),resourceID:this.resolveResourceID(),customContainerId:this._customContainerId,layoutFormConfig:this.layoutFormConfig})),s("div",{id:`${this._customContainerId}`},s("slot",{name:"SnkConfigContainerSlot"}))),s("ez-popup",{size:"medium",heightMode:"auto",useHeader:!1,opened:this._showPopUpGridConfig,onEzClosePopup:()=>this.closeGridConfig()},s("snk-grid-config",{ref:i=>this._snkGridConfig=i,config:this.gridConfig,"data-element-id":this._element.getAttribute(u.DATA_ELEMENT_ID_ATTRIBUTE_NAME),selectedIndex:0,configName:this.configName,onConfigChange:i=>this.modalConfigChangeHandler(i),onConfigCancel:()=>this.closeGridConfig(),resourceID:this.resolveResourceID()})))}get _element(){return e(this)}static get watchers(){return{resourceID:["handleResourceIDChanged"],entityName:["onChangeEntityName"],mode:["onModeChange"],dataState:["observeDataState"],formLegacyConfigName:["observeFormLegacy"],gridLegacyConfigName:["observeGridLegacy"]}}};var D;!function(i){i.FORM_REGULAR="snkSimpleCrudTaskbar.form_regular",i.GRID_REGULAR="snkSimpleCrudTaskbar.grid_regular",i.FORM_SELECTED="snkSimpleCrudTaskbar.form_selected",i.GRID_SELECTED="snkSimpleCrudTaskbar.grid_selected",i.FINISH_EDITION="snkSimpleCrudTaskbar.finish_edition",i.MULTIPLE_EDITION="snkSimpleCrudTaskbar.multiple_edition"}(D||(D={})),M.style=".sc-snk-simple-crud-h{display:flex;height:100%;width:100%;--snk-simple-crud-grid--min-height:300px}.simple-crud__container.sc-snk-simple-crud{display:grid;grid-template-rows:auto 1fr;height:100%;width:100%}.simple-crud__container-section.sc-snk-simple-crud{flex-wrap:unset;flex-direction:column}.simple-crud__form--hidden.sc-snk-simple-crud{display:none}ez-grid.sc-snk-simple-crud{--ez-grid__container--shadow:none;--ez-grid__container--shadow--outline:none;--ez-grid--min-height:var(--snk-simple-crud-grid--min-height)}ez-form.sc-snk-simple-crud{min-height:300px}";export{M as snk_simple_crud}
|
|
1
|
+
import{r as i,c as t,h as s,g as e}from"./p-82bb3eda.js";import{StringUtils as n,ApplicationContext as o,ObjectUtils as h,Action as a,DataType as r,UserInterface as d,KeyboardManager as l,ElementIDUtils as u}from"@sankhyalabs/core";import{CSSVarsUtils as c,buildFieldSearch as m}from"@sankhyalabs/ezui/dist/collection/utils";import{V as p,S as g}from"./p-9019a32f.js";import{T as v}from"./p-1be69fd4.js";import"./p-6768f176.js";import"./p-48a5c311.js";import{S as f,R as C,b,a as S,c as k}from"./p-59158ba4.js";import{P as y}from"./p-0f3698af.js";import"@sankhyalabs/ezui/dist/collection/utils/constants";import"@sankhyalabs/core/dist/dataunit/metadata/UnitMetadata";import{I as w}from"./p-9e4555ab.js";import"./p-ff1990ad.js";import{F}from"./p-7ee6b1bf.js";import{T as E}from"./p-1a0caadb.js";import{C as T}from"./p-1f310bc6.js";import{S as I}from"./p-2ac55a5d.js";import{s as _}from"./p-8336900b.js";import"./p-8d884fab.js";import"./p-7dd49d15.js";import"./p-8f3f2306.js";import"@sankhyalabs/ezui/dist/collection/components/ez-grid/utils/InMemoryFilterColumnDataSource";import"@sankhyalabs/ezui/dist/collection/components/ez-grid/utils";import"@sankhyalabs/core/dist/utils/SortingUtils";import"./p-688dcb4c.js";const z=["INSERT","REFRESH","PREVIOUS","NEXT","DIVIDER","MORE_OPTIONS"],R=["INSERT","REFRESH","PREVIOUS","NEXT","DIVIDER","CLONE","REMOVE","DIVIDER","MORE_OPTIONS"],M=class{constructor(s){i(this,s),this.dataStateChange=t(this,"dataStateChange",3),this.dataUnitReady=t(this,"dataUnitReady",3),this.actionClick=t(this,"actionClick",7),this.formItemsReady=t(this,"formItemsReady",7),this.configuratorSave=t(this,"configuratorSave",7),this.configuratorCancel=t(this,"configuratorCancel",7),this._multiSelectionListDataSource=new f,this._formConfigFetcher=new F,this._customEditors=new Map,this._customRenders=new Map,this._container=void 0,this._showPopUpGridConfig=!1,this._currentViewMode=p.GRID,this._config=void 0,this._fieldToGetFocus=void 0,this._customContainerId=`SNK-SIMPLE-CRUD-CUSTOM-CONTAINER-${n.generateUUID()}`,this.enableLockManagerLoadingComp=!1,this.enableLockManagerTaskbarClick=!1,this.dataState=void 0,this.dataUnit=void 0,this.entityName=void 0,this.mode=g.SERVER,this.gridConfig=void 0,this.formConfig=void 0,this._formFields=[],this._fieldsProps=new Map,this.enableContinuousInsert=!1,this.multipleSelection=void 0,this.useCancelConfirm=!0,this.pageSize=150,this.resourceID=void 0,this.enableGridInsert=!1,this.paginationCounterMode="auto",this.taskbarManager=void 0,this.messagesBuilder=void 0,this.useEnterLikeTab=!1,this.actionsList=void 0,this.configName=void 0,this.showConfiguratorButtons=!1,this.gridLegacyConfigName=void 0,this.formLegacyConfigName=void 0,this.ignoreReadOnlyFormFields=!1,this.autoFocus=!0,this.domainMessagesBuilder=void 0,this.multipleEditionEnabled=!0,this.layoutFormConfig=!0,this.autoLoad=void 0,this.outlineMode=!1}async addCustomEditor(i,t){if(this._grid&&this._form)return this._grid.addCustomEditor(i,t),void this._form.addCustomEditor(i,t);const s=new Map(this._customEditors);s.set(i,t),this._customEditors=s}async addGridCustomRender(i,t){if(this._grid)return void this._grid.addGridCustomRender(i,t);const s=new Map(this._customRenders);s.set(i,t),this._customRenders=s}async handleResourceIDChanged(i,t){n.isEmpty(i)||i!==t&&(await this.loadFormConfig(!0),await this.loadGridConfig(!0))}async addCustomValueFormatter(i,t){this._grid.addCustomValueFormatter(i,t)}async removeCustomValueFormatter(i){this._grid.removeCustomValueFormatter(i)}async setFieldProp(i,t,s){const e=new Map(this._fieldsProps),n=this._fieldsProps.get(i);e.set(i,Object.assign(Object.assign({},n),{[t]:s})),this._fieldsProps=e}loadTaskbarProcessor(){const i={};i[D.FORM_REGULAR]=this.getButtons(!1,[v.GRID_MODE],!0),i[D.GRID_REGULAR]=this.getButtons(!1,[v.DATA_EXPORTER,v.FORM_MODE]),i[D.FORM_SELECTED]=this.getButtons(!0,[v.GRID_MODE],!0),i[D.GRID_SELECTED]=this.getGridSelectedButtonsCallBack.bind(this),i[D.FINISH_EDITION]=this.getFinishEditionButtonsCallback.bind(this),i[D.MULTIPLE_EDITION]=[v.CANCEL],this._taskbarProcessor=new E(i)}getGridSelectedButtonsCallBack(){var i,t,s;return this.multipleEditionEnabled&&1!==(null===(s=null===(t=null===(i=this.dataState)||void 0===i?void 0:i.selectionInfo)||void 0===t?void 0:t.records)||void 0===s?void 0:s.length)?this.getButtons(!0,[v.UPDATE_MULTIPLE,v.DATA_EXPORTER,v.FORM_MODE]):this.getButtons(!0,[v.DATA_EXPORTER,v.FORM_MODE])}getFinishEditionButtonsCallback(){const i=[v.CANCEL,v.SAVE];return this.enableGridInsert&&this._currentViewMode!==p.ATTACHMENT&&i.push(this._currentViewMode===p.GRID?v.FORM_MODE:v.GRID_MODE),i}getButtons(i,t,s){let e=i?R:z;return(s||this.mode===g.IN_MEMORY)&&(e=e.filter((i=>i!==v.REFRESH))),this.addConfigButton(e.concat(t))}addConfigButton(i){return void 0===this.configName||this.configName&&this.gridLegacyConfigName?i:i.concat(v.CONFIGURATOR)}get application(){return o.getContextValue("__SNK__APPLICATION__")}async goToView(i){this._currentViewMode=i,this._viewStack&&(i===p.GRID&&(this.dataUnit.isMultipleEdition=!1),this._viewStack.show(i)),i===p.GRID&&requestAnimationFrame((()=>this.focusToGrid())),i===p.FORM&&requestAnimationFrame((()=>this.focusToForm()))}actionClickListener(i){this.handleTaskbarAction(i.detail),i.stopPropagation()}handleTaskbarAction(i){switch(i){case v.CONFIGURATOR:this._snkConfigurator.open();break;case v.GRID_MODE:this.goToView(p.GRID);break;case v.FORM_MODE:this.goToView(p.FORM);break;case v.UPDATE_MULTIPLE:this.dataUnit.isMultipleEdition=!0,this.goToView(p.FORM)}}async onChangeEntityName(i){if(this.dataUnit)return;const t=o.getContextValue("__SNK__APPLICATION__");this.dataUnit=await t.getDataUnit(i,null,null,this.configName)}onModeChange(){this.mode==g.IN_MEMORY&&this.initInMemoryDataUnit()}observeDataState(i,t){this.handleDataStateChange(i,t)}async observeFormLegacy(i,t){await this.handleUpdateFormLegacyConfig(i,t)}async observeGridLegacy(i,t){await this.handleUpdateGridLegacyConfig(i,t)}async handleDataStateChange(i,t){h.objectToString(t)!=h.objectToString(i)&&this.dataStateChange.emit(i),await this.processRmPrecision()}async processRmPrecision(){var i,t;const s=await this._snkDataUnit.getFieldsWithRmPrecision();for(const e of s||[]){if(!e)continue;const s=null===(t=null===(i=this.dataState)||void 0===i?void 0:i.rowMetadata)||void 0===t?void 0:t.getProp("rm_precision",e);(s||0===s)&&(await this.setFieldProp(e,"precision",s),await this.setFieldProp(e,"prettyPrecision",s))}this._rmPrecisionCustomValueFormatter.setDataState(this.dataState)}async handleUpdateGridLegacyConfig(i,t){null!=i&&i!=t&&this._gridConfigAlreadyLoaded&&await this.loadGridConfig(!0)}async handleUpdateFormLegacyConfig(i,t){null!=i&&i!=t&&this._formConfigAlreadyLoaded&&await this.loadFormConfig(!0)}openConfig(i){this._snkConfigurator.close(),i===p.GRID?this.openGridConfig():i===p.FORM&&this.openFormConfig()}openGridConfig(){this._grid.getColumnsState().then((i=>{this._snkGridConfig.columns=i.filter((i=>i.name)),this._snkGridConfig.selectedIndex=0,this._showPopUpGridConfig=!0}))}async openFormConfig(){(this.formLegacyConfigName||this.configName)&&await this._snkSimpleFormConfig.show()}addGridLegacyConfigName(){this.gridLegacyConfigName&&this.configName&&T.addGridLegacyConfig(this.configName,this.gridLegacyConfigName)}loadGridConfig(i){if(void 0!==this.configName&&(null==this.gridConfig&&!this._gridConfigAlreadyLoaded||i))return this.addGridLegacyConfigName(),this._gridConfigAlreadyLoaded=!0,new Promise(((i,t)=>{T.loadGridConfig(this.configName,this.resolveResourceID()).then((t=>{this.setGridConfig(t),i()})).catch((i=>{t(i)}))}))}formConfigIsLoaded(){return null!=this.formConfig||this._formConfigAlreadyLoaded}async loadFormConfig(i=!1,t=!1){if(void 0===this.configName)return;if(null==this._formConfigManager&&(this._formConfigManager=new I(this.configName,this.resolveResourceID(),void 0,this.dataUnit),this._formConfigManager.setConfig(this.formConfig)),this.formConfigIsLoaded()&&!i)return;this._formConfigAlreadyLoaded=!0;let s=await this._formConfigFetcher.fetchLegacyConfigurableForm(this.formLegacyConfigName);if(null!=s)return this._formConfigManager.setConfig(s),void this.setFormConfig(s,t);this.setFormConfig(await this._formConfigManager.loadConfig())}async componentWillRender(){this.loadTaskbarProcessor(),this._resourceID=await this.application.getResourceID(),this.dataExporterProviderStore(),this.dataExporterProviderStore(),this._taskbarProcessor.process(this.getTaskBarId(),this.taskbarManager,this.dataState,this.getTaskBarDisabledButtons()),void 0!==this.configName&&(null!=this.gridConfig||this._gridConfigAlreadyLoaded||(await this.addGridLegacyConfigName(),await this.loadGridConfig(),await this.loadFormConfig()))}componentDidRender(){this._rmPrecisionCustomValueFormatter.setGrid(this._grid),this.addGridCustomValueFormattters(),this.setFieldsProps(),this.setCustomRenders(),this.setCustomEditors()}componentWillLoad(){this.processMetadata(),this.onModeChange(),this.configDatasource(),this._rmPrecisionCustomValueFormatter=new C,this._continuousInsertUtils=new b(this.application,this.resolveResourceID(),this.configName),this.enableGridInsert&&this._continuousInsertUtils.getConfig().then((i=>this.enableContinuousInsert=i))}componentDidLoad(){c.applyVarsGrid(this._element,this._grid),this.initKeyboardManager(),this.dataUnit.subscribe(this.dataUnitActionHandler.bind(this))}async dataUnitActionHandler(i){i.type!==a.EDITION_CANCELED&&i.type!==a.DATA_SAVED||this.dataUnit.isMultipleEdition&&this.goToView(p.GRID)}getMessage(i,t){var s;return null===(s=this.messagesBuilder)||void 0===s?void 0:s.getMessage(i,t)}disconnectedCallback(){var i;null===(i=this._keyboardManager)||void 0===i||i.unbindAllShortcutKeys()}setCustomRenders(){if(this._grid)for(const[i,t]of this._customRenders)this._grid.addGridCustomRender(i,t),this._customRenders.delete(i)}setCustomEditors(){if(this._grid&&this._form)for(const[i,t]of this._customEditors)this._grid.addCustomEditor(i,t),this._form.addCustomEditor(i,t),this._customEditors.delete(i)}configDatasource(){this._multiSelectionListDataSource.setApplication(this.application),this._multiSelectionListDataSource.setDataUnit(this.dataUnit)}setFieldsProps(){if(this._form)for(const[i,t]of this._fieldsProps){for(const s in t)this._form.setFieldProp(i,s,t[s]);this._fieldsProps.delete(i)}}getTaskBarId(){var i,t;return(null===(i=this.dataState)||void 0===i?void 0:i.isDirty)?D.FINISH_EDITION:this.dataUnit.isMultipleEdition?D.MULTIPLE_EDITION:(null===(t=this.dataState)||void 0===t?void 0:t.selectionInfo)&&!this.dataState.selectionInfo.isAllRecords()&&this.dataState.selectionInfo.length>0?this._currentViewMode===p.GRID?D.GRID_SELECTED:D.FORM_SELECTED:this._currentViewMode===p.GRID?D.GRID_REGULAR:D.FORM_REGULAR}initInMemoryDataUnit(){this._inMemoryLoader=new w(this._metadata,void 0,{autoLoad:this.autoLoad}),this.dataUnit=this._inMemoryLoader.dataUnit,this.dataUnitReady.emit(this.dataUnit)}setMetadata(i){return this._inMemoryLoader?this._inMemoryLoader.metadata=i:this.dataUnit&&(this.dataUnit.metadata=i),Promise.resolve()}setRecords(i){return this._inMemoryLoader?this._inMemoryLoader.records=i:this.dataUnit&&(this.dataUnit.records=i),Promise.resolve()}getRecords(){return Promise.resolve(this.dataUnit.records)}async openConfigurator(){var i;null===(i=this._snkConfigurator)||void 0===i||i.open()}async closeConfigurator(){var i;null===(i=this._snkConfigurator)||void 0===i||i.close()}async updateConfig(){null==this._formConfigManager&&(this._formConfigManager=new I(this.configName,this.resolveResourceID())),this._formConfigManager.setConfig(this.formConfig)}processMetadata(){const i=this._element.querySelectorAll("snk-field-metadata"),t=[],s={fields:[],emptyConfig:!1};i.forEach((i=>{const e={name:i.getAttribute("name")||i.getAttribute("label"),label:i.getAttribute("label"),dataType:r[i.getAttribute("dataType")]||r.TEXT,userInterface:d[i.getAttribute("userInterface")]||d.SHORTTEXT,readOnly:"true"==i.getAttribute("readOnly"),required:"true"==i.getAttribute("required"),tab:i.getAttribute("tab")||void 0,visible:"false"!=i.getAttribute("visible")};s.fields.push({name:e.name,tab:e.tab,visible:e.visible}),t.push(e)})),t.length>0&&(this.formConfig||(this.formConfig=s),this._metadata={name:"SimpleCrud",label:"SimpleCrud",fields:t})}addGridCustomValueFormattters(){var i,t,s;const e=(null===(i=this._metadata)||void 0===i?void 0:i.fields)||(null===(s=null===(t=this.dataUnit)||void 0===t?void 0:t.metadata)||void 0===s?void 0:s.fields);if(!e)return;const n=[];e.forEach((i=>{var t;(null===(t=i.properties)||void 0===t?void 0:t.rm_precision)&&!n.includes(i.name)&&n.push(i.name)})),n.forEach((i=>{this.addCustomValueFormatter(i,this._rmPrecisionCustomValueFormatter)}))}onDataStateChange(i){this.dataState=Object.assign({},i.detail)}getTaskBarDisabledButtons(){var i,t,s,e,n,o;const h=[];return(null===(i=this.dataState)||void 0===i?void 0:i.hasNext)||h.push(v.NEXT),(null===(t=this.dataState)||void 0===t?void 0:t.hasPrevious)||h.push(v.PREVIOUS),(null===(e=null===(s=this.dataState)||void 0===s?void 0:s.selectionInfo)||void 0===e?void 0:e.isEmpty())&&h.push(v.FORM_MODE),(null===(o=null===(n=this.dataState)||void 0===n?void 0:n.selectionInfo)||void 0===o?void 0:o.length)>1&&h.push(v.CLONE),h}handleCancelEdit(){var i;(null===(i=this.dataState)||void 0===i?void 0:i.recordsIsEmpty)&&(this.goToView(p.GRID),this.dataUnit.clearSelection())}handleConfiguratorEvent(i,t){i.stopImmediatePropagation(),"SAVE"!==t?this.configuratorCancel.emit():this.configuratorSave.emit()}onSelectField(i){null!=i&&(this._fieldToGetFocus=i.value)}getFieldSearch(i,t){return null!=this._fieldSearch||(this._splitButtonForm=i,this._fieldSearch=m(t,(({argument:i})=>this.fieldsOptionLoader(i)),(i=>this.onSelectField(i)))),this._fieldSearch}getFormFields(){var i,t;return null!==(t=null===(i=this.formConfig)||void 0===i?void 0:i.fields)&&void 0!==t?t:this._formFields}handleFormSetFields(i){h.equals(this._formFields,i)||(this._formFields=null!=i?i:[])}fieldsOptionLoader(i){const t=null==i?void 0:i.toLowerCase(),s=this.getFormFields().map((i=>{var t;return null===(t=this.dataUnit)||void 0===t?void 0:t.getField(i.name)})).filter((i=>{var s,e;return(null===(s=i.name)||void 0===s?void 0:s.toLowerCase().includes(t))||(null===(e=i.label)||void 0===e?void 0:e.toLowerCase().includes(t))})).map((i=>({value:i.name,label:i.label})));return Promise.resolve(s)}isGridInsertActive(){return this.enableGridInsert&&this.dataUnit.hasNewRecord()}getColumnSearch(i,t){return null!=this._columnSearch||(this._splitButton=i,this._columnSearch=m(t,(({argument:i})=>new Promise((t=>{this._grid.filterColumns(i).then((i=>{t(i.filter((i=>!i.hidden)).map((i=>({label:i.label,value:i.name}))))}))}))),(i=>{null!=i&&this._grid.locateColumn(i.value)}))),this._columnSearch}getActionsList(){const i=[];if(this.enableGridInsert&&i.push(this._continuousInsertUtils.actionContinuousInsert(this.enableContinuousInsert,(()=>{this.enableContinuousInsert=!this.enableContinuousInsert,this._continuousInsertUtils.handleSaveConfig(this.enableContinuousInsert)}))),this.isGridInsertActive())return i;if(null!=this.taskbarManager&&null!=this.taskbarManager.getMoreOptions){const t=this.getTopTaskBarId();return i.concat(this.taskbarManager.getMoreOptions(t,this.configName,this.dataState,this.actionsList))}return i.concat(this.actionsList)}getSettingsListGrid(){return[{value:n.generateUUID(),label:this.getMessage("snkSimpleCrud.findColumn"),disableCloseOnSelect:!0,eagerInitialize:!0,itemBuilder:(i,t)=>this.getColumnSearch(i,t)}]}getSettingsListForm(){return[{value:n.generateUUID(),label:this.getMessage("snkSimpleCrud.findFields"),disableCloseOnSelect:!0,eagerInitialize:!0,itemBuilder:(i,t)=>this.getFieldSearch(i,t)}]}getTopTaskBarId(){var i;return(null===(i=this.dataState)||void 0===i?void 0:i.isDirty)?`snkGridTopTaskbar.finish_edition${y.PRIMARY}`:`snkGridTopTaskbar.regular${y.PRIMARY}`}clearFieldToFocusHandler(){this._fieldToGetFocus=void 0}gridConfigChangeHandler(i){i.stopPropagation(),this.configName&&T.saveGridConfig(i.detail,this.configName,this.resolveResourceID())}modalConfigChangeHandler(i){const t=i.detail;this._grid.setColumnsState(t.columns).then((()=>{this.setGridConfig(t),this.closeGridConfig(),this.dataExporterProviderStore()})),i.stopPropagation()}async dataExporterProviderStore(){if(null==this.dataUnit)return;if(null==this._grid)return;const i=new k(this.dataUnit,this._grid);_.set("exporterProviders",Object.assign(Object.assign({},_.get("exporterProviders")),{[this.getDataExporterStoreKey()]:i}))}getDataExporterStoreKey(){return`SnkSimpleCrudDataExporter:${null==this.configName?this.dataUnit.name:this.configName}`}setGridConfig(i){this.gridConfig=i,S.assertDefaultSorting(this.gridConfig,this.dataUnit)}setFormConfig(i,t){this.formConfig&&!t||(this.formConfig=i)}closeGridConfig(){this._showPopUpGridConfig=!1}getPageSize(){return this.mode===g.IN_MEMORY?0:null==this.pageSize?150:this.pageSize}resolveResourceID(){return n.isEmpty(this.resourceID)?this._resourceID:this.resourceID}getFormConfig(){var i;const t=null===(i=this._formConfigManager)||void 0===i?void 0:i.getConfig(this.dataUnit,this.ignoreReadOnlyFormFields);return this.configName||t?t:this.formConfig}updateFormConfig(){let i=this.formConfig;null==this.formLegacyConfigName&&(i=Object.assign(Object.assign({},this.formConfig),{fields:this.dataUnit.metadata.fields})),this.setFormConfig(i,!0),null==this._formConfigManager&&(this._formConfigManager=new I(this.configName,this.resolveResourceID())),this._formConfigManager.setConfig(this.formConfig)}handleDataUnitOnInsertionMode(){this.enableGridInsert||this.goToView(p.FORM)}async initKeyboardManager(){var i;this._keyboardManager=new l({propagate:!1,element:this._element});const t=this.dataUnit||await(null===(i=this._snkDataUnit)||void 0===i?void 0:i.getDataUnit());null!=t&&this._keyboardManager.bind("F7",(()=>t.saveData()),{description:this.getMessage("snkSimpleCrud.keyboardShortcuts.saveData"),element:this._element}).bind("F8",t.addRecord.bind(t),{description:this.getMessage("snkSimpleCrud.keyboardShortcuts.addRecord"),element:this._element}).bind("F9",t.removeSelectedRecords.bind(t),{description:this.getMessage("snkSimpleCrud.keyboardShortcuts.removeRecord"),element:this._element}).bind("Escape",(()=>{t.isDirty()&&t.cancelEdition()}),{debounceTime:1e3,description:this.getMessage("snkSimpleCrud.keyboardShortcuts.cancelAction"),element:this._element})}async handleFormConfigSaved(){await this.loadFormConfig(!0,!0)}focusToGrid(){this._grid.focus()}focusToForm(){this._form.focus()}renderTaskbarContent(i){var t;return s("snk-taskbar",{class:"ez-box--no-outline ez-box "+(this._currentViewMode===p.FORM?(this.outlineMode?"ez-box--outline":"ez-box--shadow-xsmall")+" ez-padding--small":""),dataUnit:this.dataUnit,primaryButton:(null===(t=this.dataState)||void 0===t?void 0:t.isDirty)?"SAVE":"INSERT","data-element-id":"grid_left",messagesBuilder:this.messagesBuilder,buttons:this._taskbarProcessor.buttons,actionsList:this.getActionsList(),actionsSettingsList:i===p.GRID?this.getSettingsListGrid():this.getSettingsListForm(),disabledButtons:this._taskbarProcessor.disabledButtons,customButtons:this._taskbarProcessor.customButtons,"data-exporter-store-key":this.getDataExporterStoreKey(),slot:"leftButtons",presentationMode:y.SECONDARY,tabindex:"0"},s("slot",{name:"TASKBAR_CUSTOM_ELEMENTS"}))}render(){var i;if(null!=this.dataUnit)return s("snk-data-unit",{ref:i=>this._snkDataUnit=i,class:"simple-crud__container",dataUnit:this.dataUnit,useCancelConfirm:this.useCancelConfirm,onDataStateChange:i=>this.onDataStateChange(i),onCancelEdition:this.handleCancelEdit.bind(this),pageSize:this.getPageSize(),onInsertionMode:this.handleDataUnitOnInsertionMode.bind(this),onDataUnitReady:i=>this.dataUnitReady.emit(i.detail),onMessagesBuilderUpdated:i=>this.messagesBuilder=i.detail,onDataUnitFieldsHidded:this.updateFormConfig.bind(this),domainMessagesBuilder:this.domainMessagesBuilder},s("header",null,s("slot",{name:"snkSimpleCrudHeader"})),s("section",{class:`ez-box ez-box--no-outline ${this.outlineMode?"ez-box--outline":"ez-box--shadow"} simple-crud__container-section`,ref:i=>this._container=i,tabindex:"0"},s("ez-view-stack",{ref:i=>this._viewStack=i,"data-element-id":"simple-crud"},s("stack-item",null,s("ez-grid",{class:"ez-margin-bottom--large ez-box--no-outline",ref:i=>this._grid=i,dataUnit:this.dataUnit,config:this.gridConfig,"no-header":!0,multipleSelection:this.multipleSelection,onEzDoubleClick:()=>this.goToView(p.FORM),onConfigChange:i=>this.gridConfigChangeHandler(i),columnfilterDataSource:this.dataUnit.name&&this.dataUnit.name.includes(w.IN_MEMORY_DATA_UNIT_NAME)?void 0:this._multiSelectionListDataSource,useEnterLikeTab:this.useEnterLikeTab,autoFocus:this.autoFocus,enableGridInsert:this.enableGridInsert,enableContinuousInsert:this.enableContinuousInsert,enableLockManagerTaskbarClick:this.enableLockManagerTaskbarClick,enableLockManagerLoadingComp:this.enableLockManagerLoadingComp,outlineMode:this.outlineMode,tabindex:"0",paginationCounterMode:this.paginationCounterMode},this.renderTaskbarContent(p.GRID),s("div",{slot:"footer"},s("slot",{name:"snkSimpleCrudFooter"})))),s("stack-item",null,this.renderTaskbarContent(p.FORM),s("ez-form",{ref:i=>this._form=i,class:"ez-margin-top--large ez-box--no-outline",dataUnit:this.dataUnit,config:this.getFormConfig(),fieldToFocus:this._fieldToGetFocus,onEzFormSetFields:i=>this.handleFormSetFields(i.detail),onEzFormRequestClearFieldToFocus:this.clearFieldToFocusHandler.bind(this),elementFocusSearchField:this._container,tabindex:"0"}),s("snk-simple-form-config",{ref:i=>this._snkSimpleFormConfig=i,dataUnit:this.dataUnit,onSnkConfigSaved:this.handleFormConfigSaved.bind(this),configName:null!==(i=this.formLegacyConfigName)&&void 0!==i?i:this.configName,messagesBuilder:this.messagesBuilder})),this.messagesBuilder&&s("snk-configurator",{ref:i=>this._snkConfigurator=i,viewMode:this._currentViewMode,messagesBuilder:this.messagesBuilder,onConfigSelected:i=>this.goToView(i.detail),onOpenConfig:i=>this.openConfig(i.detail),showActionButtons:this.showConfiguratorButtons,onSave:i=>this.handleConfiguratorEvent(i,"SAVE"),onCancel:i=>this.handleConfiguratorEvent(i,"CANCEL"),resourceID:this.resolveResourceID(),customContainerId:this._customContainerId,layoutFormConfig:this.layoutFormConfig})),s("div",{id:`${this._customContainerId}`},s("slot",{name:"SnkConfigContainerSlot"}))),s("ez-popup",{size:"medium",heightMode:"auto",useHeader:!1,opened:this._showPopUpGridConfig,onEzClosePopup:()=>this.closeGridConfig()},s("snk-grid-config",{ref:i=>this._snkGridConfig=i,config:this.gridConfig,"data-element-id":this._element.getAttribute(u.DATA_ELEMENT_ID_ATTRIBUTE_NAME),selectedIndex:0,configName:this.configName,onConfigChange:i=>this.modalConfigChangeHandler(i),onConfigCancel:()=>this.closeGridConfig(),resourceID:this.resolveResourceID()})))}get _element(){return e(this)}static get watchers(){return{resourceID:["handleResourceIDChanged"],entityName:["onChangeEntityName"],mode:["onModeChange"],dataState:["observeDataState"],formLegacyConfigName:["observeFormLegacy"],gridLegacyConfigName:["observeGridLegacy"]}}};var D;!function(i){i.FORM_REGULAR="snkSimpleCrudTaskbar.form_regular",i.GRID_REGULAR="snkSimpleCrudTaskbar.grid_regular",i.FORM_SELECTED="snkSimpleCrudTaskbar.form_selected",i.GRID_SELECTED="snkSimpleCrudTaskbar.grid_selected",i.FINISH_EDITION="snkSimpleCrudTaskbar.finish_edition",i.MULTIPLE_EDITION="snkSimpleCrudTaskbar.multiple_edition"}(D||(D={})),M.style=".sc-snk-simple-crud-h{display:flex;height:100%;width:100%;--snk-simple-crud-grid--min-height:300px}.simple-crud__container.sc-snk-simple-crud{display:grid;grid-template-rows:auto 1fr;height:100%;width:100%}.simple-crud__container-section.sc-snk-simple-crud{flex-wrap:unset;flex-direction:column}.simple-crud__form--hidden.sc-snk-simple-crud{display:none}ez-grid.sc-snk-simple-crud{--ez-grid__container--shadow:none;--ez-grid__container--shadow--outline:none;--ez-grid--min-height:var(--snk-simple-crud-grid--min-height)}ez-form.sc-snk-simple-crud{min-height:300px}";export{M as snk_simple_crud}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as e,h as r,H as s,g as t}from"./p-
|
|
1
|
+
import{r as e,h as r,H as s,g as t}from"./p-82bb3eda.js";import{ElementIDUtils as a}from"@sankhyalabs/core";const i=new ResizeObserver((e=>{var r;for(let s of e){const e=(null===(r=null==s?void 0:s.target)||void 0===r?void 0:r.children)||[],{parentElement:t}=(null==s?void 0:s.target)||{};if(!(null==t?void 0:t.clientWidth))return;const a=t.clientWidth-14;if(s.target.hasChildNodes()){const r=[];for(const s of e)r.push(s);r.reduce(((e,r)=>{const s=e+r.clientWidth;return r.style.visibility=s>a?"hidden":"visible",s}),0)}}})),m=class{constructor(r){e(this,r),this.fixed=!1,this.contracted=!1,this.summary=void 0}componentDidRender(){i.disconnect(),this._summaryElement&&i.observe(this._summaryElement)}disconnectedCallback(){i.disconnect()}render(){return a.addIDInfoIfNotExists(this._elem,"ezFormCard"),r(s,null,r("div",{ref:e=>this._summaryElement=e,class:"summary-wrapper"},Object.entries(this.summary).map((([e,s])=>r("div",{class:"summary-container",title:`${e}: ${s}`},r("label",{class:"ez-text summary-field summary-field__title"},e),r("label",{class:" ez-text summary-field summary-field__content"},s))))))}get _elem(){return t(this)}};m.style=".sc-snk-form-summary-h{display:flex;width:100%;--ez-form-card-summary-field-content-weight:700}.summary-wrapper.sc-snk-form-summary{display:flex;overflow:hidden}.summary-container.sc-snk-form-summary{display:flex;flex-direction:column;padding-right:calc(var(--space--extra-large) / 1.5)}.summary-field.sc-snk-form-summary{min-width:30px;max-width:200px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.summary-field__title.sc-snk-form-summary{color:var(--text--primary, #626e82);font-size:var(--title--small);white-space:nowrap;font-weight:var(--text-weight--medium)}.summary-field__content.sc-snk-form-summary{color:var(--title--primary, #2b3a54);font-size:var(--text--large);font-weight:var(--ez-form-card-summary-field-content-weight)}";export{m as snk_form_summary}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as i,c as t,h as s,g as e,H as h}from"./p-d8d8169b.js";import{ElementIDUtils as o,ObjectUtils as a,ApplicationContext as n}from"@sankhyalabs/core";import{S as d}from"./p-2ac55a5d.js";import{R as l}from"./p-688dcb4c.js";import{buildFormConfigFromDataUnit as r}from"@sankhyalabs/ezui/dist/collection/utils/form";import{ApplicationUtils as c}from"@sankhyalabs/ezui/dist/collection/utils";import{U as f}from"./p-7ee6b1bf.js";import{a as g,G as u}from"./p-9019a32f.js";import{b as m,a as v,c as p,d as C,g as b,u as y,e as k}from"./p-8b4d6719.js";import"./p-1f310bc6.js";import"./p-6768f176.js";import"./p-8d884fab.js";import"@sankhyalabs/core/dist/dataunit/metadata/UnitMetadata";import"./p-ff1990ad.js";const w=class{constructor(s){i(this,s),this.exit=t(this,"exit",7),this.actionClick=t(this,"actionClick",7),this.formItemsReady=t(this,"formItemsReady",7),this._customEditors=new Map,this._dataUnit=void 0,this._dataState=void 0,this._showFormConfig=!1,this._configManager=void 0,this.configName=void 0,this.recordsValidator=void 0,this.messagesBuilder=void 0,this.formLegacyConfigName=void 0,this.resourceID=void 0}async showConfig(){this._showFormConfig=!0}async hideConfig(){this._showFormConfig=!1}async addCustomEditor(i,t){if(this._form)return void this._form.addCustomEditor(i,t);const s=new Map(this._customEditors);s.set(i,t),this._customEditors=s}async setFieldProp(i,t,s){await this._form.setFieldProp(i,t,s)}async validate(){await this._form.validate()}closeConfig(){this.hideConfig()}dataunitReady(){o.addIDInfo(this._element,null,{dataUnit:this._dataUnit})}setCustomEditors(){if(this._form)for(const[i,t]of this._customEditors)this._form.addCustomEditor(i,t),this._customEditors.delete(i)}async componentDidRender(){this.setCustomEditors()}async componentWillLoad(){let i=this._element.parentElement;for(;i;){if("SNK-DATA-UNIT"===i.tagName.toUpperCase()){this._snkDataUnit=i,this._dataUnit=this._snkDataUnit.dataUnit,this._dataState=this._snkDataUnit.dataState,this._dataUnit?this.dataunitReady():this._snkDataUnit.addEventListener("dataUnitReady",(i=>{this._dataUnit=i.detail})),this._snkDataUnit.addEventListener("dataStateChange",this.handleDataStateChange.bind(this));break}i=i.parentElement}null==this.resourceID&&(this.resourceID=await l.getResourceID()),this._configManager=new d(this.configName,this.resourceID,void 0,this._dataUnit),this.addFormLegacyConfig(),await this._configManager.loadConfig()}async handleDataStateChange(i){var t;this._dataState=i.detail;const s=await this._snkDataUnit.getFieldsWithRmPrecision();for(const i of s||[]){if(!i)continue;const s=null===(t=this._dataState.rowMetadata)||void 0===t?void 0:t.getProp("rm_precision",i);(s||0===s)&&(await this.setFieldProp(i,"precision",s),await this.setFieldProp(i,"prettyPrecision",s))}}addFormLegacyConfig(){this.formLegacyConfigName&&this._configManager.addFormLegacyConfig(this.formLegacyConfigName)}render(){if(this._dataUnit&&this._dataState)return s("section",null,s("div",{class:"ez-row"},s("div",{class:"ez-col ez-col--sd-12"},s("ez-form",{ref:i=>this._form=i,key:"ezForm"+this._snkDataUnit.entityName,"data-element-id":"embedded",dataUnit:this._dataUnit,config:this._configManager.getConfig(this._dataUnit),recordsValidator:this.recordsValidator,class:this._showFormConfig?"snk-form__form--hidden":""}),this._showFormConfig&&s("snk-form-config",{messagesBuilder:this.messagesBuilder,dataUnit:this._dataUnit,configManager:this._configManager,onConfigClose:()=>this.closeConfig()}))))}get _element(){return e(this)}};w.style=".sc-snk-form-h{--snk-form__header--min-height:94px;display:block}.snk-form__form--hidden.sc-snk-form{display:none}";const F=class{constructor(s){i(this,s),this.configClose=t(this,"configClose",7),this.configChange=t(this,"configChange",7),this.guidesMap=new Map,this.availableFields=[],this.guidesList=[],this.groupsList=[],this.selectedGuide=void 0,this._formConfig={},this.configOptions=[],this.originalConfigSelected=void 0,this.configSelected=void 0,this.hasChanges=!1,this.optionConfigChanged=!1,this.dataUnit=void 0,this.configManager=void 0,this.ignoreReadOnlyFormFields=void 0,this.messagesBuilder=void 0,this.customGuidesConfig=[]}handleFieldConfigChanged(){this.hasChanges=!0}async handleFormConfigOptionSelected({detail:i}){this.configSelected=i,await this.loadConfigByUser(),this.selectedGuide=void 0,this.optionConfigChanged=!a.equals(this.configSelected,this.originalConfigSelected),this.configSelected.origin===f.DEFAULT&&(this.hasChanges=!1)}async handleAddFieldToGuide({detail:i}){var t;this.selectedGuide?this.selectedGuide.isCustom||this.selectedGuide.isDetail?this.showCanNotAddFieldToGuideDialog():(this.availableFields=[...this.availableFields.filter((t=>t.name!==i.name))],await(null===(t=this.refFieldsLayout)||void 0===t?void 0:t.addFieldToLayout(i))):this.showNoGuideSelectedDialog()}async handleSetFieldAsAvailable({detail:i}){this.availableFields.some((t=>t.name===i.name))||(this.availableFields=[...this.availableFields,i])}async handleRemoveFieldFromAvailable({detail:i}){this.availableFields=this.availableFields.filter((t=>t.name!==i.name))}observeSelectedGuide(i){var t;const s=null!==(t=this.guidesMap.get(null==i?void 0:i.name))&&void 0!==t?t:[];this.groupsList=[...s]}observeConfigManager(){this.loadFormConfig()}showNoGuideSelectedDialog(){const i=this.getMessage("snkFormConfig.noGuideSelected.title"),t=this.getMessage("snkFormConfig.noGuideSelected.message");c.alert(i,t)}showCanNotAddFieldToGuideDialog(){const i=this.getMessage("snkFormConfig.canNotAddFieldToGuide.title"),t=this.getMessage("snkFormConfig.canNotAddFieldToGuide.message");c.alert(i,t)}getMessage(i,t){return this.messagesBuilder.getMessage(i,t)}async initializeUserConfig(){if(null!=this.configManager)try{const i=await this.configManager.fetchUserAvailableConfigs();this.configOptions=i;const t=null==this._formConfig||this._formConfig.defaultConfiguration?f.DEFAULT:f.USER;this.configSelected=null==i?void 0:i.find((i=>i.origin===t)),this.originalConfigSelected=null==i?void 0:i.find((i=>i.origin===t))}catch(i){console.error(this.getMessage("snkFormConfig.errors.failFetchUserConfig")),console.error(i)}}async loadConfigByUser(){this.configManager&&this.configSelected&&(this.isConfigDefaultSelected()?await this.handleLoadDefaultConfig():this.loadFormConfig())}async handleLoadDefaultConfig(){const i=await this.configManager.fetchDefaultConfig();if(i)return void this.loadFormConfig(i);const t=this.configManager.getEmptyConfig();t&&this.loadFormConfig(t)}isConfigDefaultSelected(){return this.configSelected.origin===f.DEFAULT}loadFormConfig(i){this._formConfig=i||this.getConfig(),this.loadGuides(),this.initializeAvailableFields()}initializeAvailableFields(){var i;if(null==(null===(i=this._formConfig)||void 0===i?void 0:i.fields))return;const t=[...this._formConfig.fields];this.availableFields=this.dataUnit.metadata.fields.filter((({name:i,visible:s,properties:e})=>{const h=t.some((({name:t})=>t===i));return h||!0!==e.visibleOnConfig||s?!0===s&&!1===h:e.visibleOnConfig}))}getInitialOrder(i){var t,s;return Array.isArray(null===(t=this._formConfig)||void 0===t?void 0:t.tabs)?null===(s=this._formConfig.tabs)||void 0===s?void 0:s.length:i.length>0?Math.max(...i.map((i=>i.order))):0}loadGuides(){var i;this.guidesList=[],this.guidesList.push(...m(this._formConfig,this.getMessage("snkFormConfig.form.mainArea"))),this.guidesList.push(...v(this.dataUnit,this.getInitialOrder(this.guidesList),this.guidesList)),this.guidesList.push(...p(this.customGuidesConfig,this.guidesList)),this.guidesMap=C(null===(i=this._formConfig)||void 0===i?void 0:i.fields,this.guidesList,this.dataUnit,this.getMessage("snkFormConfig.form.tabGeneral"))}getConfig(){let i=this.configManager.getConfig(this.dataUnit,!1);return i.fields&&0===i.fields.length&&(i=void 0),null==i&&(i=r(this.dataUnit)),a.copy(i)}handleSelectGuide({detail:i}){this.selectedGuide=i}handleLayoutChanged({detail:i}){this.hasChanges=!0,this.groupsList=[...i],this.guidesMap.set(this.selectedGuide.name,[...i])}getIsDefaultConfig(){var i;return(null===(i=this.configSelected)||void 0===i?void 0:i.origin)===f.DEFAULT&&!0===this.optionConfigChanged&&!1===this.hasChanges}getTabsToSave(){return this.guidesList.map((i=>({name:i.name,label:i.name===g.main?i.name:i.label,order:i.name===g.main?0:i.order,visible:i.visible})))}async handleSaveConfig(){var i;const t=await this.configManager.saveConfig(this.buildConfigToSave());this.configSelected=null===(i=this.configOptions)||void 0===i?void 0:i.find((i=>i.origin===(this.hasChanges?f.USER:f.DEFAULT))),this.originalConfigSelected=this.configSelected,this.hasChanges=!1,this.optionConfigChanged=!1,c.info(this.getMessage("snkFormConfig.info.successfullyConfigSaved"),{iconName:"check"}),this.configChange.emit(t)}buildConfigToSave(){if(this.getIsDefaultConfig()){const i=this._formConfig;return i.defaultConfiguration=!0,i}const i=a.copy(this._formConfig);return i.tabs=this.getTabsToSave(),i.fields=b(this.guidesMap),i.defaultConfiguration=!1,i}handleAvailableFieldListChanged({detail:i}){this.availableFields=[...i]}handleSetFieldListAsAvailable({detail:i}){this.availableFields=[...this.availableFields,...i]}handleGuideDeleted({detail:i}){var t,s;const e=i.name,h=null!==(t=this.guidesMap.get(e))&&void 0!==t?t:[],o=[];h.forEach((i=>o.push(...i.fields))),this.availableFields=[...this.availableFields,...o],this.guidesList=[...this.guidesList.filter((i=>i.name!==e))],this.guidesMap.delete(e),(null===(s=this.selectedGuide)||void 0===s?void 0:s.name)===e&&(this.selectedGuide=void 0),this.hasChanges=!0}handleGuideListChanged({detail:i}){this.hasChanges=!0,this.guidesList=[...i]}handleGuideRenamed({detail:i}){var t;const s=null!==(t=this.guidesMap.get(this.selectedGuide.name))&&void 0!==t?t:[],e=y(s,i);this.guidesMap.delete(this.selectedGuide.name),this.guidesMap.set(i,e);const h={name:i,label:i,visible:this.selectedGuide.visible,order:this.selectedGuide.order};this.guidesList=[...this.guidesList.map((i=>i.name===this.selectedGuide.name?h:i))],this.groupsList=[...e],this.selectedGuide=h,this.hasChanges=!0}handleCreateNewGuide(){const i=k(this.guidesList,this.getMessage.bind(this)),t={name:i,label:i,visible:!0,order:this.guidesList.length+1},s={name:u.noGroup,fields:[]};this.guidesList=[...this.guidesList,t],this.guidesMap.set(i,[s]),this.selectedGuide=t,this.hasChanges=!0}getGuideNames(){return[...this.guidesList.map((i=>i.name.toLowerCase())),this.getMessage("snkFormConfig.form.mainArea").toLowerCase()]}async componentWillRender(){if(null==this.messagesBuilder){const i=n.getContextValue("__SNK__APPLICATION__");this.messagesBuilder=i.messagesBuilder}}async componentWillLoad(){this.loadFormConfig(),await this.initializeUserConfig()}render(){return s(h,null,s("config-header",{configOptions:this.configOptions,selectedConfig:this.configSelected,messagesBuilder:this.messagesBuilder,hasChanges:this.hasChanges,optionConfigChanged:this.optionConfigChanged,onConfigClose:()=>this.configClose.emit(),onSaveConfig:async()=>await this.handleSaveConfig()}),s("div",{class:"ez-padding--medium"},s("div",{class:"ez-flex sidebarNavigator__container"},s("guides-configurator",{messagesBuilder:this.messagesBuilder,guidesList:this.guidesList,selectedGuide:this.selectedGuide,onGuideSelected:this.handleSelectGuide.bind(this),onGuideListChanged:this.handleGuideListChanged.bind(this),onCreateNewGuide:this.handleCreateNewGuide.bind(this),onGuideDeleted:this.handleGuideDeleted.bind(this)}),s("fields-layout",{ref:i=>this.refFieldsLayout=i,selectedGuide:this.selectedGuide,guideNames:this.getGuideNames(),groupsList:this.groupsList,messagesBuilder:this.messagesBuilder,dataUnit:this.dataUnit,onGuideRenamed:this.handleGuideRenamed.bind(this),onLayoutChanged:this.handleLayoutChanged.bind(this),onSetFieldListAsAvailable:this.handleSetFieldListAsAvailable.bind(this)}),s("fields-selector",{dataUnit:this.dataUnit,availableFields:this.availableFields,onFieldListChanged:this.handleAvailableFieldListChanged.bind(this),messagesBuilder:this.messagesBuilder}))))}static get watchers(){return{selectedGuide:["observeSelectedGuide"],configManager:["observeConfigManager"]}}};F.style='.sc-snk-form-config-h{display:flex;flex-direction:column;height:100vh;width:100vw;font-family:var(--font-pattern, "Roboto");background:white;color:#2b3a54;--snk-form-config-container-height:calc(100vh - 95px);outline:none}.sidebarNavigator__container.sc-snk-form-config{height:var(--snk-form-config-container-height);gap:20px;align-items:flex-start}.guide-header.sc-snk-form-config{display:flex;width:100%;padding-bottom:12px;border-bottom:1px solid #dce0e8;height:30px;font-weight:500;font-size:16px}';export{w as snk_form,F as snk_form_config}
|
|
1
|
+
import{r as i,c as t,h as s,g as e,H as h}from"./p-82bb3eda.js";import{ElementIDUtils as o,ObjectUtils as a,ApplicationContext as n}from"@sankhyalabs/core";import{S as d}from"./p-2ac55a5d.js";import{R as l}from"./p-688dcb4c.js";import{buildFormConfigFromDataUnit as r}from"@sankhyalabs/ezui/dist/collection/utils/form";import{ApplicationUtils as c}from"@sankhyalabs/ezui/dist/collection/utils";import{U as f}from"./p-7ee6b1bf.js";import{a as g,G as u}from"./p-9019a32f.js";import{b as m,a as v,c as p,d as C,g as b,u as y,e as k}from"./p-8b4d6719.js";import"./p-1f310bc6.js";import"./p-6768f176.js";import"./p-8d884fab.js";import"@sankhyalabs/core/dist/dataunit/metadata/UnitMetadata";import"./p-ff1990ad.js";const w=class{constructor(s){i(this,s),this.exit=t(this,"exit",7),this.actionClick=t(this,"actionClick",7),this.formItemsReady=t(this,"formItemsReady",7),this._customEditors=new Map,this._dataUnit=void 0,this._dataState=void 0,this._showFormConfig=!1,this._configManager=void 0,this.configName=void 0,this.recordsValidator=void 0,this.messagesBuilder=void 0,this.formLegacyConfigName=void 0,this.resourceID=void 0}async showConfig(){this._showFormConfig=!0}async hideConfig(){this._showFormConfig=!1}async addCustomEditor(i,t){if(this._form)return void this._form.addCustomEditor(i,t);const s=new Map(this._customEditors);s.set(i,t),this._customEditors=s}async setFieldProp(i,t,s){await this._form.setFieldProp(i,t,s)}async validate(){await this._form.validate()}closeConfig(){this.hideConfig()}dataunitReady(){o.addIDInfo(this._element,null,{dataUnit:this._dataUnit})}setCustomEditors(){if(this._form)for(const[i,t]of this._customEditors)this._form.addCustomEditor(i,t),this._customEditors.delete(i)}async componentDidRender(){this.setCustomEditors()}async componentWillLoad(){let i=this._element.parentElement;for(;i;){if("SNK-DATA-UNIT"===i.tagName.toUpperCase()){this._snkDataUnit=i,this._dataUnit=this._snkDataUnit.dataUnit,this._dataState=this._snkDataUnit.dataState,this._dataUnit?this.dataunitReady():this._snkDataUnit.addEventListener("dataUnitReady",(i=>{this._dataUnit=i.detail})),this._snkDataUnit.addEventListener("dataStateChange",this.handleDataStateChange.bind(this));break}i=i.parentElement}null==this.resourceID&&(this.resourceID=await l.getResourceID()),this._configManager=new d(this.configName,this.resourceID,void 0,this._dataUnit),this.addFormLegacyConfig(),await this._configManager.loadConfig()}async handleDataStateChange(i){var t;this._dataState=i.detail;const s=await this._snkDataUnit.getFieldsWithRmPrecision();for(const i of s||[]){if(!i)continue;const s=null===(t=this._dataState.rowMetadata)||void 0===t?void 0:t.getProp("rm_precision",i);(s||0===s)&&(await this.setFieldProp(i,"precision",s),await this.setFieldProp(i,"prettyPrecision",s))}}addFormLegacyConfig(){this.formLegacyConfigName&&this._configManager.addFormLegacyConfig(this.formLegacyConfigName)}render(){if(this._dataUnit&&this._dataState)return s("section",null,s("div",{class:"ez-row"},s("div",{class:"ez-col ez-col--sd-12"},s("ez-form",{ref:i=>this._form=i,key:"ezForm"+this._snkDataUnit.entityName,"data-element-id":"embedded",dataUnit:this._dataUnit,config:this._configManager.getConfig(this._dataUnit),recordsValidator:this.recordsValidator,class:this._showFormConfig?"snk-form__form--hidden":""}),this._showFormConfig&&s("snk-form-config",{messagesBuilder:this.messagesBuilder,dataUnit:this._dataUnit,configManager:this._configManager,onConfigClose:()=>this.closeConfig()}))))}get _element(){return e(this)}};w.style=".sc-snk-form-h{--snk-form__header--min-height:94px;display:block}.snk-form__form--hidden.sc-snk-form{display:none}";const F=class{constructor(s){i(this,s),this.configClose=t(this,"configClose",7),this.configChange=t(this,"configChange",7),this.guidesMap=new Map,this.availableFields=[],this.guidesList=[],this.groupsList=[],this.selectedGuide=void 0,this._formConfig={},this.configOptions=[],this.originalConfigSelected=void 0,this.configSelected=void 0,this.hasChanges=!1,this.optionConfigChanged=!1,this.dataUnit=void 0,this.configManager=void 0,this.ignoreReadOnlyFormFields=void 0,this.messagesBuilder=void 0,this.customGuidesConfig=[]}handleFieldConfigChanged(){this.hasChanges=!0}async handleFormConfigOptionSelected({detail:i}){this.configSelected=i,await this.loadConfigByUser(),this.selectedGuide=void 0,this.optionConfigChanged=!a.equals(this.configSelected,this.originalConfigSelected),this.configSelected.origin===f.DEFAULT&&(this.hasChanges=!1)}async handleAddFieldToGuide({detail:i}){var t;this.selectedGuide?this.selectedGuide.isCustom||this.selectedGuide.isDetail?this.showCanNotAddFieldToGuideDialog():(this.availableFields=[...this.availableFields.filter((t=>t.name!==i.name))],await(null===(t=this.refFieldsLayout)||void 0===t?void 0:t.addFieldToLayout(i))):this.showNoGuideSelectedDialog()}async handleSetFieldAsAvailable({detail:i}){this.availableFields.some((t=>t.name===i.name))||(this.availableFields=[...this.availableFields,i])}async handleRemoveFieldFromAvailable({detail:i}){this.availableFields=this.availableFields.filter((t=>t.name!==i.name))}observeSelectedGuide(i){var t;const s=null!==(t=this.guidesMap.get(null==i?void 0:i.name))&&void 0!==t?t:[];this.groupsList=[...s]}observeConfigManager(){this.loadFormConfig()}showNoGuideSelectedDialog(){const i=this.getMessage("snkFormConfig.noGuideSelected.title"),t=this.getMessage("snkFormConfig.noGuideSelected.message");c.alert(i,t)}showCanNotAddFieldToGuideDialog(){const i=this.getMessage("snkFormConfig.canNotAddFieldToGuide.title"),t=this.getMessage("snkFormConfig.canNotAddFieldToGuide.message");c.alert(i,t)}getMessage(i,t){return this.messagesBuilder.getMessage(i,t)}async initializeUserConfig(){if(null!=this.configManager)try{const i=await this.configManager.fetchUserAvailableConfigs();this.configOptions=i;const t=null==this._formConfig||this._formConfig.defaultConfiguration?f.DEFAULT:f.USER;this.configSelected=null==i?void 0:i.find((i=>i.origin===t)),this.originalConfigSelected=null==i?void 0:i.find((i=>i.origin===t))}catch(i){console.error(this.getMessage("snkFormConfig.errors.failFetchUserConfig")),console.error(i)}}async loadConfigByUser(){this.configManager&&this.configSelected&&(this.isConfigDefaultSelected()?await this.handleLoadDefaultConfig():this.loadFormConfig())}async handleLoadDefaultConfig(){const i=await this.configManager.fetchDefaultConfig();if(i)return void this.loadFormConfig(i);const t=this.configManager.getEmptyConfig();t&&this.loadFormConfig(t)}isConfigDefaultSelected(){return this.configSelected.origin===f.DEFAULT}loadFormConfig(i){this._formConfig=i||this.getConfig(),this.loadGuides(),this.initializeAvailableFields()}initializeAvailableFields(){var i;if(null==(null===(i=this._formConfig)||void 0===i?void 0:i.fields))return;const t=[...this._formConfig.fields];this.availableFields=this.dataUnit.metadata.fields.filter((({name:i,visible:s,properties:e})=>{const h=t.some((({name:t})=>t===i));return h||!0!==e.visibleOnConfig||s?!0===s&&!1===h:e.visibleOnConfig}))}getInitialOrder(i){var t,s;return Array.isArray(null===(t=this._formConfig)||void 0===t?void 0:t.tabs)?null===(s=this._formConfig.tabs)||void 0===s?void 0:s.length:i.length>0?Math.max(...i.map((i=>i.order))):0}loadGuides(){var i;this.guidesList=[],this.guidesList.push(...m(this._formConfig,this.getMessage("snkFormConfig.form.mainArea"))),this.guidesList.push(...v(this.dataUnit,this.getInitialOrder(this.guidesList),this.guidesList)),this.guidesList.push(...p(this.customGuidesConfig,this.guidesList)),this.guidesMap=C(null===(i=this._formConfig)||void 0===i?void 0:i.fields,this.guidesList,this.dataUnit,this.getMessage("snkFormConfig.form.tabGeneral"))}getConfig(){let i=this.configManager.getConfig(this.dataUnit,!1);return i.fields&&0===i.fields.length&&(i=void 0),null==i&&(i=r(this.dataUnit)),a.copy(i)}handleSelectGuide({detail:i}){this.selectedGuide=i}handleLayoutChanged({detail:i}){this.hasChanges=!0,this.groupsList=[...i],this.guidesMap.set(this.selectedGuide.name,[...i])}getIsDefaultConfig(){var i;return(null===(i=this.configSelected)||void 0===i?void 0:i.origin)===f.DEFAULT&&!0===this.optionConfigChanged&&!1===this.hasChanges}getTabsToSave(){return this.guidesList.map((i=>({name:i.name,label:i.name===g.main?i.name:i.label,order:i.name===g.main?0:i.order,visible:i.visible})))}async handleSaveConfig(){var i;const t=await this.configManager.saveConfig(this.buildConfigToSave());this.configSelected=null===(i=this.configOptions)||void 0===i?void 0:i.find((i=>i.origin===(this.hasChanges?f.USER:f.DEFAULT))),this.originalConfigSelected=this.configSelected,this.hasChanges=!1,this.optionConfigChanged=!1,c.info(this.getMessage("snkFormConfig.info.successfullyConfigSaved"),{iconName:"check"}),this.configChange.emit(t)}buildConfigToSave(){if(this.getIsDefaultConfig()){const i=this._formConfig;return i.defaultConfiguration=!0,i}const i=a.copy(this._formConfig);return i.tabs=this.getTabsToSave(),i.fields=b(this.guidesMap),i.defaultConfiguration=!1,i}handleAvailableFieldListChanged({detail:i}){this.availableFields=[...i]}handleSetFieldListAsAvailable({detail:i}){this.availableFields=[...this.availableFields,...i]}handleGuideDeleted({detail:i}){var t,s;const e=i.name,h=null!==(t=this.guidesMap.get(e))&&void 0!==t?t:[],o=[];h.forEach((i=>o.push(...i.fields))),this.availableFields=[...this.availableFields,...o],this.guidesList=[...this.guidesList.filter((i=>i.name!==e))],this.guidesMap.delete(e),(null===(s=this.selectedGuide)||void 0===s?void 0:s.name)===e&&(this.selectedGuide=void 0),this.hasChanges=!0}handleGuideListChanged({detail:i}){this.hasChanges=!0,this.guidesList=[...i]}handleGuideRenamed({detail:i}){var t;const s=null!==(t=this.guidesMap.get(this.selectedGuide.name))&&void 0!==t?t:[],e=y(s,i);this.guidesMap.delete(this.selectedGuide.name),this.guidesMap.set(i,e);const h={name:i,label:i,visible:this.selectedGuide.visible,order:this.selectedGuide.order};this.guidesList=[...this.guidesList.map((i=>i.name===this.selectedGuide.name?h:i))],this.groupsList=[...e],this.selectedGuide=h,this.hasChanges=!0}handleCreateNewGuide(){const i=k(this.guidesList,this.getMessage.bind(this)),t={name:i,label:i,visible:!0,order:this.guidesList.length+1},s={name:u.noGroup,fields:[]};this.guidesList=[...this.guidesList,t],this.guidesMap.set(i,[s]),this.selectedGuide=t,this.hasChanges=!0}getGuideNames(){return[...this.guidesList.map((i=>i.name.toLowerCase())),this.getMessage("snkFormConfig.form.mainArea").toLowerCase()]}async componentWillRender(){if(null==this.messagesBuilder){const i=n.getContextValue("__SNK__APPLICATION__");this.messagesBuilder=i.messagesBuilder}}async componentWillLoad(){this.loadFormConfig(),await this.initializeUserConfig()}render(){return s(h,null,s("config-header",{configOptions:this.configOptions,selectedConfig:this.configSelected,messagesBuilder:this.messagesBuilder,hasChanges:this.hasChanges,optionConfigChanged:this.optionConfigChanged,onConfigClose:()=>this.configClose.emit(),onSaveConfig:async()=>await this.handleSaveConfig()}),s("div",{class:"ez-padding--medium"},s("div",{class:"ez-flex sidebarNavigator__container"},s("guides-configurator",{messagesBuilder:this.messagesBuilder,guidesList:this.guidesList,selectedGuide:this.selectedGuide,onGuideSelected:this.handleSelectGuide.bind(this),onGuideListChanged:this.handleGuideListChanged.bind(this),onCreateNewGuide:this.handleCreateNewGuide.bind(this),onGuideDeleted:this.handleGuideDeleted.bind(this)}),s("fields-layout",{ref:i=>this.refFieldsLayout=i,selectedGuide:this.selectedGuide,guideNames:this.getGuideNames(),groupsList:this.groupsList,messagesBuilder:this.messagesBuilder,dataUnit:this.dataUnit,onGuideRenamed:this.handleGuideRenamed.bind(this),onLayoutChanged:this.handleLayoutChanged.bind(this),onSetFieldListAsAvailable:this.handleSetFieldListAsAvailable.bind(this)}),s("fields-selector",{dataUnit:this.dataUnit,availableFields:this.availableFields,onFieldListChanged:this.handleAvailableFieldListChanged.bind(this),messagesBuilder:this.messagesBuilder}))))}static get watchers(){return{selectedGuide:["observeSelectedGuide"],configManager:["observeConfigManager"]}}};F.style='.sc-snk-form-config-h{display:flex;flex-direction:column;height:100vh;width:100vw;font-family:var(--font-pattern, "Roboto");background:white;color:#2b3a54;--snk-form-config-container-height:calc(100vh - 95px);outline:none}.sidebarNavigator__container.sc-snk-form-config{height:var(--snk-form-config-container-height);gap:20px;align-items:flex-start}.guide-header.sc-snk-form-config{display:flex;width:100%;padding-bottom:12px;border-bottom:1px solid #dce0e8;height:30px;font-weight:500;font-size:16px}';export{w as snk_form,F as snk_form_config}
|