@sankhyalabs/sankhyablocks 8.16.0-rc.7 → 8.16.0-rc.9
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/cjs/{RecordIDUtils-3735135c.js → GetSelectedRecordsIDsInfo-bd50caf1.js} +10 -10
- package/dist/cjs/loader.cjs.js +1 -1
- package/dist/cjs/sankhyablocks.cjs.js +1 -1
- package/dist/cjs/snk-actions-button_4.cjs.entry.js +12 -9
- package/dist/cjs/snk-data-exporter.cjs.entry.js +2 -2
- package/dist/cjs/{snk-data-unit-8af43aa3.js → snk-data-unit-486c7ac4.js} +2 -2
- package/dist/cjs/snk-data-unit.cjs.entry.js +2 -2
- package/dist/cjs/snk-detail-view.cjs.entry.js +1 -1
- package/dist/cjs/snk-grid.cjs.entry.js +2 -2
- package/dist/cjs/snk-simple-crud.cjs.entry.js +2 -2
- package/dist/cjs/snk-taskbar.cjs.entry.js +23 -1
- package/dist/collection/components/snk-actions-button/actions/index.js +12 -9
- package/dist/collection/components/snk-crud/subcomponents/snk-detail-view/snk-detail-view.js +1 -1
- package/dist/collection/components/snk-data-exporter/providers/ClientSideExporterProvider.js +1 -1
- package/dist/collection/components/snk-data-exporter/providers/ServerSideExporterProvider.js +1 -1
- package/dist/collection/components/snk-data-unit/snk-data-unit.js +2 -2
- package/dist/collection/components/snk-taskbar/snk-taskbar.js +64 -0
- package/dist/collection/{components/snk-data-exporter/utils/RecordIDUtils.js → lib/utils/GetSelectedRecordsIDsInfo.js} +9 -9
- package/dist/{esm/RecordIDUtils-87d02110.js → components/GetSelectedRecordsIDsInfo.js} +10 -10
- package/dist/components/snk-actions-button2.js +12 -9
- package/dist/components/snk-data-unit2.js +4 -41
- package/dist/components/snk-detail-view2.js +1 -1
- package/dist/components/snk-grid2.js +2 -2
- package/dist/components/snk-simple-crud2.js +3 -2
- package/dist/components/snk-taskbar2.js +24 -2
- package/dist/esm/GetSelectedRecordsIDsInfo-9fa41508.js +41 -0
- package/dist/esm/loader.js +1 -1
- package/dist/esm/sankhyablocks.js +1 -1
- package/dist/esm/snk-actions-button_4.entry.js +12 -9
- package/dist/esm/snk-data-exporter.entry.js +2 -2
- package/dist/esm/{snk-data-unit-008cb9aa.js → snk-data-unit-ac3423fa.js} +2 -2
- package/dist/esm/snk-data-unit.entry.js +2 -2
- package/dist/esm/snk-detail-view.entry.js +1 -1
- package/dist/esm/snk-grid.entry.js +2 -2
- package/dist/esm/snk-simple-crud.entry.js +2 -2
- package/dist/esm/snk-taskbar.entry.js +23 -1
- package/dist/sankhyablocks/p-18ed15f4.entry.js +1 -0
- package/dist/sankhyablocks/p-1e596b15.entry.js +1 -0
- package/dist/sankhyablocks/{p-89451692.entry.js → p-27b57eb7.entry.js} +1 -1
- package/dist/sankhyablocks/{p-684a2590.entry.js → p-2d6dc51d.entry.js} +1 -1
- package/dist/sankhyablocks/p-7dd49d15.js +1 -0
- package/dist/sankhyablocks/{p-53eb35c1.entry.js → p-81f6d043.entry.js} +1 -1
- package/dist/sankhyablocks/p-e8bd4c15.js +1 -0
- package/dist/sankhyablocks/{p-3c50e9d4.entry.js → p-fa155ad6.entry.js} +1 -1
- package/dist/sankhyablocks/{p-46bb200a.entry.js → p-fd8a58ff.entry.js} +1 -1
- package/dist/sankhyablocks/sankhyablocks.esm.js +1 -1
- package/dist/types/components/snk-actions-button/actions/index.d.ts +1 -0
- package/dist/types/components/snk-taskbar/snk-taskbar.d.ts +11 -0
- package/dist/types/components.d.ts +8 -0
- package/dist/types/lib/utils/GetSelectedRecordsIDsInfo.d.ts +3 -0
- package/package.json +1 -1
- package/dist/sankhyablocks/p-421bec84.entry.js +0 -1
- package/dist/sankhyablocks/p-9863d682.js +0 -1
- package/dist/sankhyablocks/p-cc935517.js +0 -1
- package/dist/sankhyablocks/p-f2809746.entry.js +0 -1
- package/dist/types/components/snk-data-exporter/utils/RecordIDUtils.d.ts +0 -3
@@ -1 +1 @@
|
|
1
|
-
import{r as i,c as t,h as s,F as e,g as a}from"./p-d2d301a6.js";import{Action as r,ElementIDUtils as n,ApplicationContext as d,StringUtils as o}from"@sankhyalabs/core";import{T as h}from"./p-7e7a7473.js";import{C as l}from"./p-3287a6cc.js";import{P as c}from"./p-30cf616e.js";import{T as u,o as g,b as T}from"./p-c2495304.js";import{s as m}from"./p-6dc031de.js";import{C as k,S as E,a as f,R as v}from"./p-76a65660.js";import{SelectionMode as p}from"@sankhyalabs/core/dist/dataunit/DataUnit";import"./p-594bc21d.js";import"./p-25f1fc39.js";import"./p-21749402.js";import"@sankhyalabs/ezui/dist/collection/utils/constants";import"@sankhyalabs/core/dist/dataunit/metadata/UnitMetadata";import"./p-091ce761.js";import"./p-ff1990ad.js";import"./p-181975f1.js";import{g as R}from"./p-9863d682.js";import"@sankhyalabs/ezui/dist/collection/components/ez-grid/utils/InMemoryFilterColumnDataSource";import"./p-8d884fab.js";import"@sankhyalabs/ezui/dist/collection/components/ez-grid/utils";import"@sankhyalabs/core/dist/utils/SortingUtils";import"./p-688dcb4c.js";class O extends k{getFilters(){var i;return null===(i=this.dataUnit)||void 0===i?void 0:i.getAppliedFilters()}getOrders(){var i;return null===(i=this.dataUnit)||void 0===i?void 0:i.getSort()}getResourceURI(){var i;return null===(i=this.dataUnit)||void 0===i?void 0:i.name}getSelectedNumber(){return this.dataUnit.getSelectionInfo().length}getTotalRecords(){var i,t,s;const{total:e}=(null===(i=this.dataUnit)||void 0===i?void 0:i.getPaginationInfo())||{};return null!=e?e:null===(s=null===(t=this.dataUnit)||void 0===t?void 0:t.records)||void 0===s?void 0:s.length}getSelectedIDs(){return R(this.dataUnit)}getOffset(){return this.getExporterOffset(this.getPaginationInfo())}getPageSize(){var i;return null===(i=this.dataUnit)||void 0===i?void 0:i.pageSize}getExportLimit(){return 5e3}getRecordID(){var i,t,s;return null===(s=null===(t=null===(i=this.dataUnit)||void 0===i?void 0:i.records)||void 0===t?void 0:t[0])||void 0===s?void 0:s.__record__id__}getPaginationInfo(){var i;return null===(i=this.dataUnit)||void 0===i?void 0:i.getPaginationInfo()}getExporterOffset(i){if(null==i)return;const t=i.firstRecord;return t>0?t-1:t}}const b=class{constructor(s){i(this,s),this.actionClick=t(this,"actionClick",7),this.gridDoubleClick=t(this,"gridDoubleClick",7),this._customEditors=new Map,this._customRenders=new Map,this._topTaskbarProcessor=new u({"snkGridTopTaskbar.regular":["FORM_MODE","CONFIGURATOR","INSERT"],"snkGridTopTaskbar.regular.secondary":["FORM_MODE","CONFIGURATOR","INSERT"],"snkGridTopTaskbar.regular.singleTaskbar":[],"snkGridTopTaskbar.finish_edition":["CANCEL","SAVE"],"snkGridTopTaskbar.finish_edition.secondary":[],"snkGridTopTaskbar.finish_edition.singleTaskbar":[]}),this._headerTaskbarProcessor=new u({"snkGridHeaderTaskbar.unselected":["REFRESH","DATA_EXPORTER","ACTIONS_BUTTON","MORE_OPTIONS"],"snkGridHeaderTaskbar.selected":["UPDATE","CLONE","REMOVE","MORE_OPTIONS","DIVIDER","ATTACH","REFRESH","DATA_EXPORTER","ACTIONS_BUTTON"],"snkGridHeaderTaskbar.detail.unselected":["REFRESH","MORE_OPTIONS"],"snkGridHeaderTaskbar.detail.selected":["UPDATE","ATTACH","CLONE","REMOVE","MORE_OPTIONS","DIVIDER","REFRESH"],"snkGridHeaderTaskbar.singleTaskbar.unselected":["INSERT","FORM_MODE","CONFIGURATOR","REFRESH","DATA_EXPORTER","ACTIONS_BUTTON","MORE_OPTIONS"],"snkGridHeaderTaskbar.singleTaskbar.selected":["UPDATE","CLONE","REMOVE","MORE_OPTIONS","DIVIDER","ATTACH","FORM_MODE","CONFIGURATOR","REFRESH","DATA_EXPORTER","ACTIONS_BUTTON"],"snkGridHeaderTaskbar.singleTaskbar.detail.unselected":["INSERT","FORM_MODE","CONFIGURATOR","REFRESH","MORE_OPTIONS"],"snkGridHeaderTaskbar.singleTaskbar.detail.selected":["UPDATE","ATTACH","CLONE","REMOVE","MORE_OPTIONS","DIVIDER","FORM_MODE","CONFIGURATOR","REFRESH"],"snkGridHeaderTaskbar.singleTaskbar.finish_edition":["CANCEL","SAVE"]}),this.dataUnitInterceptor={interceptAction:async i=>i.type===r.METADATA_LOADED?await this.interceptMetadataLoaded(i):i},this._dataUnit=void 0,this._dataState=void 0,this._gridConfig=void 0,this._popUpGridConfig=!1,this._showSnkFilterBar=!0,this.columnFilterDataSource=new E,this.configName=void 0,this.filterBarTitle=void 0,this.resourceID=void 0,this.selectionToastConfig=void 0,this.actionsList=void 0,this.isDetail=void 0,this.taskbarManager=void 0,this.statusResolver=void 0,this.multipleSelection=void 0,this.presentationMode=c.PRIMARY,this.messagesBuilder=void 0,this.useEnterLikeTab=!1,this.recordsValidator=void 0,this.canEdit=!0,this.taskbarCustomContainerId=void 0,this.gridHeaderCustomSlotId="GRID_HEADER_CUSTOM_ELEMENTS",this.topTaskbarCustomSlotId="GRID_TASKBAR_CUSTOM_ELEMENTS",this.disablePersonalizedFilter=void 0,this.gridLegacyConfigName=void 0,this.filterBarLegacyConfigName=void 0,this.autoLoad=void 0,this.autoFocus=!0}async showConfig(){null!=this._grid&&this.openGridConfig()}async hideConfig(){null!=this._grid&&this.closeGridConfig()}async setConfig(i){this.setGridConfig(i)}async reloadFilterBar(){var i;null===(i=this._snkFilterBar)||void 0===i||i.reload()}async getFilterBar(){return this._snkFilterBar}async findColumn(){await g(this._moreOptions,this._columnSearch)}async addCustomEditor(i,t,s){if(this._grid)return void this._grid.addCustomEditor(i,t,s);const e=new Map(this._customEditors);e.set(i,{customEditor:t,detailContext:s}),this._customEditors=e}async addGridCustomRender(i,t,s){if(this._grid)return void this._grid.addGridCustomRender(i,t,s);const e=new Map(this._customRenders);e.set(i,{customRender:t,detailContext:s}),this._customRenders=e}async addCustomValueFormatter(i,t){this._grid.addCustomValueFormatter(i,t)}async removeCustomValueFormatter(i){this._grid.removeCustomValueFormatter(i)}async setFocus(){this._grid.setFocus()}async handleGridLegacyConfigName(i,t){i&&i!==t&&(this.addGridLegacyConfigName(),this.loadConfig())}openGridConfig(){this._grid.getColumnsState().then((i=>{this._snkGridConfig.columns=i.filter((i=>i.name)),this._snkGridConfig.selectedIndex=0,this._popUpGridConfig=!0}))}closeGridConfig(){this._popUpGridConfig=!1}setGridConfig(i){this._gridConfig=i,f.assertDefaultSorting(this._gridConfig,this._dataUnit)}loadConfig(){l.loadGridConfig(this.configName,this.resourceID).then((i=>{this.setGridConfig(i)})).catch((i=>{console.warn(i)}))}addGridLegacyConfigName(){this.gridLegacyConfigName&&this.configName&&l.addGridLegacyConfig(this.configName,this.gridLegacyConfigName)}gridConfigChangeHandler(i){l.saveGridConfig(i.detail,this.configName,this.resourceID),i.stopPropagation()}modalConfigChangeHandler(i){const t=i.detail;this._grid.setColumnsState(t.columns).then((()=>{this.setGridConfig(t),this.closeGridConfig(),this.dataExporterProviderStore()})),i.stopPropagation()}async dataExporterProviderStore(){const i=new O(this._dataUnit,this._grid);m.set("exporterProviders",Object.assign(Object.assign({},m.get("exporterProviders")),{[this.configName]:i}))}addElementID(){n.addIDInfo(this._element,null,{dataUnit:this._dataUnit})}loadGridCustomFormatters(i){i&&this._grid&&i.forEach((i=>{var t;(null===(t=i.properties)||void 0===t?void 0:t.rm_precision)&&this.addCustomValueFormatter(i.name,this._rmPrecisionCustomValueFormatter)}))}async interceptMetadataLoaded(i){return this.loadGridCustomFormatters(i.payload.fields),i}finishLoading(){this._dataUnit.addInterceptor(this.dataUnitInterceptor),f.assertDefaultSorting(this._gridConfig,this._dataUnit),this.addElementID(),null!=this.columnFilterDataSource&&(this.columnFilterDataSource.setApplication(this._application),this.columnFilterDataSource.setDataUnit(this._dataUnit))}setCustomRenders(){if(this._grid)for(const[i,t]of this._customRenders)this._grid.addGridCustomRender(i,t.customRender,t.detailContext),this._customRenders.delete(i)}setCustomEditors(){if(this._grid)for(const[i,t]of this._customEditors)this._grid.addCustomEditor(i,t.customEditor,t.detailContext),this._customEditors.delete(i)}componentWillLoad(){this._application=d.getContextValue("__SNK__APPLICATION__");let i=this._element.parentElement;for(;i;){if("SNK-DATA-UNIT"===i.tagName.toUpperCase()){this._snkDataUnit=i,this._dataUnit=this._snkDataUnit.dataUnit,this._dataUnit?this.finishLoading():this._snkDataUnit.addEventListener("dataUnitReady",(i=>{this._dataUnit=i.detail,this.finishLoading()})),this.messagesBuilder||(this.messagesBuilder=this._snkDataUnit.messagesBuilder),this._snkDataUnit.addEventListener("dataStateChange",this.handleDataStateChange.bind(this)),this._snkDataUnit.addEventListener("cancelEdition",(()=>{var i;(null===(i=this._dataState)||void 0===i?void 0:i.recordsIsEmpty)&&this._dataUnit.clearSelection()}));break}i=i.parentElement}this._rmPrecisionCustomValueFormatter=new v,this.addGridLegacyConfigName(),this.loadConfig()}componentDidRender(){this._rmPrecisionCustomValueFormatter.setGrid(this._grid),this.loadGridCustomFormatters(this._dataUnit.metadata.fields),this.setCustomRenders(),this.setCustomEditors()}async handleDataStateChange(i){this._dataState=i.detail,this._rmPrecisionCustomValueFormatter.setDataState(this._dataState)}getHeaderDisabledButtons(){var i;const t=[];return(null===(i=this._dataState)||void 0===i?void 0:i.selectionInfo)&&(this._dataState.selectionInfo.length>1&&t.push(h.CLONE,"ATTACH",h.UPDATE),this._dataState.selectionInfo.isAllRecords()&&t.push("REMOVE")),t}getInvisibleButtons(){let i=[];return this._dataUnit&&0!==this._dataUnit.records.length||i.push("DATA_EXPORTER"),this._dataState&&this._dataState.selectionInfo.mode===p.ALL_RECORDS&&i.push("ACTIONS_BUTTON"),i}componentWillRender(){const i=this.getInvisibleButtons();this._headerTaskbarProcessor.process(this.getHeaderTaskbarId(),this.taskbarManager,this._dataState,this.getHeaderDisabledButtons(),i),this._topTaskbarProcessor.process(this.getTopTaskBarId(),this.taskbarManager,this._dataState,void 0,i),this.dataExporterProviderStore()}getHeaderTaskbarId(){var i,t;const s=this._dataState&&!!(null===(i=this._dataState.selectionInfo)||void 0===i?void 0:i.length),e={primary:this.isDetail?"snkGridHeaderTaskbar.detail":"snkGridHeaderTaskbar",secondary:this.isDetail?"snkGridHeaderTaskbar.detail":"snkGridHeaderTaskbar",singleTaskbar:this.isDetail?"snkGridHeaderTaskbar.singleTaskbar.detail":"snkGridHeaderTaskbar.singleTaskbar"}[this.presentationMode];let a=s?`${e}.selected`:`${e}.unselected`;return(null===(t=this._dataState)||void 0===t?void 0:t.isDirty)&&this.presentationMode===c.SINGLE_TASKBAR&&(a="snkGridHeaderTaskbar.singleTaskbar.finish_edition"),a}getTopTaskBarId(){var i;const t={primary:"",secondary:".secondary",singleTaskbar:".singleTaskbar"}[this.presentationMode];return(null===(i=this._dataState)||void 0===i?void 0:i.isDirty)?`snkGridTopTaskbar.finish_edition${t}`:`snkGridTopTaskbar.regular${t}`}getPrimaryButton(){return{primary:"INSERT",secondary:"",singleTaskbar:"INSERT"}[this.presentationMode]}getColumnSearch(i,t){return null!=this._columnSearch||(this._moreOptions=i,this._columnSearch=T(t,(({argument:i})=>new Promise((t=>{this._grid.filterColumns(i).then((i=>{t(i.filter((i=>!i.hidden)).map((i=>({label:i.label,value:i.name}))))}))}))),(t=>{null!=t&&(this._grid.locateColumn(t.value),i.hideActions())}))),this._columnSearch}getActionsList(){const i=[{value:o.generateUUID(),label:this.messagesBuilder.getMessage("snkGrid.findColumn",{}),disableCloseOnSelect:!0,eagerInitialize:!0,itemBuilder:(i,t)=>this.getColumnSearch(i,t)}];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)}handleFilterConfigUpdated(i){this._showSnkFilterBar=!!i.length&&(1!==i.length||"PERSONALIZED_FILTER_GROUP"!==i[0].id||i[0].groupedItems.length>0)}render(){if(this._dataUnit)return s("div",{class:"snk-grid__container ez-flex ez-flex--column ez-flex-item--auto ez-padding--large"},s("div",{class:"snk-grid__header ez-margin-bottom--medium"},this._showSnkFilterBar&&s(e,null,s("snk-filter-bar",{ref:i=>this._snkFilterBar=i,title:this.filterBarTitle,dataUnit:this._dataUnit,"data-element-id":"gridFilter",class:"snk-grid__filter-bar ez-align--top",configName:this.configName,messagesBuilder:this.messagesBuilder,resourceID:this.resourceID,onConfigUpdated:i=>this.handleFilterConfigUpdated(i.detail),disablePersonalizedFilter:this.disablePersonalizedFilter,filterBarLegacyConfigName:this.filterBarLegacyConfigName,autoLoad:this.autoLoad}),s("hr",{class:"ez-divider-vertical ez-divider--dark ez-margin-left--medium snk-grid__header-divider"})),s("snk-taskbar",{class:"ez-padding-left--medium","data-element-id":"grid_top",key:"topTaskbar",configName:this.configName,dataUnit:this._dataUnit,messagesBuilder:this.messagesBuilder,buttons:this._topTaskbarProcessor.buttons,disabledButtons:this._topTaskbarProcessor.disabledButtons,customButtons:this._topTaskbarProcessor.customButtons,primaryButton:this.getPrimaryButton(),resourceID:this.resourceID,customContainerId:this.taskbarCustomContainerId,customSlotId:this.topTaskbarCustomSlotId,overflowStrategy:"none"},s("slot",{name:this.topTaskbarCustomSlotId}))),s("ez-grid",{ref:i=>this._grid=i,class:(this.presentationMode===c.SECONDARY?"snk-grid-container__without-shadow ":"")+"snk-grid__table","data-element-id":"embedded",dataUnit:this._dataUnit,key:"grid-"+this._snkDataUnit.entityName,config:this._gridConfig,onConfigChange:i=>{this.gridConfigChangeHandler(i)},onEzDoubleClick:i=>this.gridDoubleClick.emit(i.detail),statusResolver:this.statusResolver,multipleSelection:this.multipleSelection,columnfilterDataSource:this.columnFilterDataSource,selectionToastConfig:this.selectionToastConfig,useEnterLikeTab:this.useEnterLikeTab,recordsValidator:this.recordsValidator,canEdit:this.canEdit,autoFocus:this.autoFocus},s("snk-taskbar",{id:"teste",dataUnit:this._dataUnit,configName:this.configName,messagesBuilder:this.messagesBuilder,"data-element-id":"grid_left",buttons:this._headerTaskbarProcessor.buttons,presentationMode:this.presentationMode,disabledButtons:this._headerTaskbarProcessor.disabledButtons,customButtons:this._headerTaskbarProcessor.customButtons,slot:"leftButtons",actionsList:this.getActionsList(),primaryButton:this.getPrimaryButton(),resourceID:this.resourceID,customContainerId:this.taskbarCustomContainerId,customSlotId:this.gridHeaderCustomSlotId},s("slot",{name:this.gridHeaderCustomSlotId}))),s("div",{class:"ez-col ez-col--sd-12"},s("slot",{name:"SnkGridFooter"})),s("ez-modal",{modalSize:"small",closeEsc:!1,closeOutsideClick:!1,opened:this._popUpGridConfig,onEzCloseModal:()=>this.closeGridConfig()},s("snk-grid-config",{ref:i=>this._snkGridConfig=i,config:this._gridConfig,"data-element-id":this._element.getAttribute(n.DATA_ELEMENT_ID_ATTRIBUTE_NAME),selectedIndex:0,configName:this.configName,onConfigChange:i=>this.modalConfigChangeHandler(i),onConfigCancel:()=>this.closeGridConfig(),resourceID:this.resourceID})))}get _element(){return a(this)}static get watchers(){return{gridLegacyConfigName:["handleGridLegacyConfigName"]}}};b.style=".sc-snk-grid-h{--snk-grid-min-height:300px}.snk-grid__container.sc-snk-grid{display:flex;height:100%;width:100%}.snk-grid__header.sc-snk-grid{width:100%;display:flex;flex-wrap:nowrap;justify-content:flex-end}.snk-grid__filter-bar.sc-snk-grid{width:100%}.snk-grid__header-divider.sc-snk-grid{margin-bottom:var(--space--medium)}.snk-grid__table.sc-snk-grid{min-height:var(--snk-grid-min-height)}.snk-grid-container__without-shadow.sc-snk-grid{--ezgrid__container--shadow:unset}";export{b as snk_grid}
|
1
|
+
import{r as i,c as t,h as s,F as e,g as a}from"./p-d2d301a6.js";import{Action as r,ElementIDUtils as n,ApplicationContext as d,StringUtils as o}from"@sankhyalabs/core";import{T as h}from"./p-7e7a7473.js";import{C as l}from"./p-3287a6cc.js";import{P as c}from"./p-30cf616e.js";import{T as u,o as g,b as T}from"./p-c2495304.js";import{s as m}from"./p-6dc031de.js";import{C as k,S as E,a as f,R as v}from"./p-76a65660.js";import{SelectionMode as p}from"@sankhyalabs/core/dist/dataunit/DataUnit";import"./p-594bc21d.js";import"./p-25f1fc39.js";import"./p-21749402.js";import"@sankhyalabs/ezui/dist/collection/utils/constants";import"@sankhyalabs/core/dist/dataunit/metadata/UnitMetadata";import"./p-091ce761.js";import"./p-ff1990ad.js";import"./p-181975f1.js";import{g as R}from"./p-7dd49d15.js";import"@sankhyalabs/ezui/dist/collection/components/ez-grid/utils/InMemoryFilterColumnDataSource";import"./p-8d884fab.js";import"@sankhyalabs/ezui/dist/collection/components/ez-grid/utils";import"@sankhyalabs/core/dist/utils/SortingUtils";import"./p-688dcb4c.js";class O extends k{getFilters(){var i;return null===(i=this.dataUnit)||void 0===i?void 0:i.getAppliedFilters()}getOrders(){var i;return null===(i=this.dataUnit)||void 0===i?void 0:i.getSort()}getResourceURI(){var i;return null===(i=this.dataUnit)||void 0===i?void 0:i.name}getSelectedNumber(){return this.dataUnit.getSelectionInfo().length}getTotalRecords(){var i,t,s;const{total:e}=(null===(i=this.dataUnit)||void 0===i?void 0:i.getPaginationInfo())||{};return null!=e?e:null===(s=null===(t=this.dataUnit)||void 0===t?void 0:t.records)||void 0===s?void 0:s.length}getSelectedIDs(){return R(this.dataUnit)}getOffset(){return this.getExporterOffset(this.getPaginationInfo())}getPageSize(){var i;return null===(i=this.dataUnit)||void 0===i?void 0:i.pageSize}getExportLimit(){return 5e3}getRecordID(){var i,t,s;return null===(s=null===(t=null===(i=this.dataUnit)||void 0===i?void 0:i.records)||void 0===t?void 0:t[0])||void 0===s?void 0:s.__record__id__}getPaginationInfo(){var i;return null===(i=this.dataUnit)||void 0===i?void 0:i.getPaginationInfo()}getExporterOffset(i){if(null==i)return;const t=i.firstRecord;return t>0?t-1:t}}const b=class{constructor(s){i(this,s),this.actionClick=t(this,"actionClick",7),this.gridDoubleClick=t(this,"gridDoubleClick",7),this._customEditors=new Map,this._customRenders=new Map,this._topTaskbarProcessor=new u({"snkGridTopTaskbar.regular":["FORM_MODE","CONFIGURATOR","INSERT"],"snkGridTopTaskbar.regular.secondary":["FORM_MODE","CONFIGURATOR","INSERT"],"snkGridTopTaskbar.regular.singleTaskbar":[],"snkGridTopTaskbar.finish_edition":["CANCEL","SAVE"],"snkGridTopTaskbar.finish_edition.secondary":[],"snkGridTopTaskbar.finish_edition.singleTaskbar":[]}),this._headerTaskbarProcessor=new u({"snkGridHeaderTaskbar.unselected":["REFRESH","DATA_EXPORTER","ACTIONS_BUTTON","MORE_OPTIONS"],"snkGridHeaderTaskbar.selected":["UPDATE","CLONE","REMOVE","MORE_OPTIONS","DIVIDER","ATTACH","REFRESH","DATA_EXPORTER","ACTIONS_BUTTON"],"snkGridHeaderTaskbar.detail.unselected":["REFRESH","MORE_OPTIONS"],"snkGridHeaderTaskbar.detail.selected":["UPDATE","ATTACH","CLONE","REMOVE","MORE_OPTIONS","DIVIDER","REFRESH"],"snkGridHeaderTaskbar.singleTaskbar.unselected":["INSERT","FORM_MODE","CONFIGURATOR","REFRESH","DATA_EXPORTER","ACTIONS_BUTTON","MORE_OPTIONS"],"snkGridHeaderTaskbar.singleTaskbar.selected":["UPDATE","CLONE","REMOVE","MORE_OPTIONS","DIVIDER","ATTACH","FORM_MODE","CONFIGURATOR","REFRESH","DATA_EXPORTER","ACTIONS_BUTTON"],"snkGridHeaderTaskbar.singleTaskbar.detail.unselected":["INSERT","FORM_MODE","CONFIGURATOR","REFRESH","MORE_OPTIONS"],"snkGridHeaderTaskbar.singleTaskbar.detail.selected":["UPDATE","ATTACH","CLONE","REMOVE","MORE_OPTIONS","DIVIDER","FORM_MODE","CONFIGURATOR","REFRESH"],"snkGridHeaderTaskbar.singleTaskbar.finish_edition":["CANCEL","SAVE"]}),this.dataUnitInterceptor={interceptAction:async i=>i.type===r.METADATA_LOADED?await this.interceptMetadataLoaded(i):i},this._dataUnit=void 0,this._dataState=void 0,this._gridConfig=void 0,this._popUpGridConfig=!1,this._showSnkFilterBar=!0,this.columnFilterDataSource=new E,this.configName=void 0,this.filterBarTitle=void 0,this.resourceID=void 0,this.selectionToastConfig=void 0,this.actionsList=void 0,this.isDetail=void 0,this.taskbarManager=void 0,this.statusResolver=void 0,this.multipleSelection=void 0,this.presentationMode=c.PRIMARY,this.messagesBuilder=void 0,this.useEnterLikeTab=!1,this.recordsValidator=void 0,this.canEdit=!0,this.taskbarCustomContainerId=void 0,this.gridHeaderCustomSlotId="GRID_HEADER_CUSTOM_ELEMENTS",this.topTaskbarCustomSlotId="GRID_TASKBAR_CUSTOM_ELEMENTS",this.disablePersonalizedFilter=void 0,this.gridLegacyConfigName=void 0,this.filterBarLegacyConfigName=void 0,this.autoLoad=void 0,this.autoFocus=!0}async showConfig(){null!=this._grid&&this.openGridConfig()}async hideConfig(){null!=this._grid&&this.closeGridConfig()}async setConfig(i){this.setGridConfig(i)}async reloadFilterBar(){var i;null===(i=this._snkFilterBar)||void 0===i||i.reload()}async getFilterBar(){return this._snkFilterBar}async findColumn(){await g(this._moreOptions,this._columnSearch)}async addCustomEditor(i,t,s){if(this._grid)return void this._grid.addCustomEditor(i,t,s);const e=new Map(this._customEditors);e.set(i,{customEditor:t,detailContext:s}),this._customEditors=e}async addGridCustomRender(i,t,s){if(this._grid)return void this._grid.addGridCustomRender(i,t,s);const e=new Map(this._customRenders);e.set(i,{customRender:t,detailContext:s}),this._customRenders=e}async addCustomValueFormatter(i,t){this._grid.addCustomValueFormatter(i,t)}async removeCustomValueFormatter(i){this._grid.removeCustomValueFormatter(i)}async setFocus(){this._grid.setFocus()}async handleGridLegacyConfigName(i,t){i&&i!==t&&(this.addGridLegacyConfigName(),this.loadConfig())}openGridConfig(){this._grid.getColumnsState().then((i=>{this._snkGridConfig.columns=i.filter((i=>i.name)),this._snkGridConfig.selectedIndex=0,this._popUpGridConfig=!0}))}closeGridConfig(){this._popUpGridConfig=!1}setGridConfig(i){this._gridConfig=i,f.assertDefaultSorting(this._gridConfig,this._dataUnit)}loadConfig(){l.loadGridConfig(this.configName,this.resourceID).then((i=>{this.setGridConfig(i)})).catch((i=>{console.warn(i)}))}addGridLegacyConfigName(){this.gridLegacyConfigName&&this.configName&&l.addGridLegacyConfig(this.configName,this.gridLegacyConfigName)}gridConfigChangeHandler(i){l.saveGridConfig(i.detail,this.configName,this.resourceID),i.stopPropagation()}modalConfigChangeHandler(i){const t=i.detail;this._grid.setColumnsState(t.columns).then((()=>{this.setGridConfig(t),this.closeGridConfig(),this.dataExporterProviderStore()})),i.stopPropagation()}async dataExporterProviderStore(){const i=new O(this._dataUnit,this._grid);m.set("exporterProviders",Object.assign(Object.assign({},m.get("exporterProviders")),{[this.configName]:i}))}addElementID(){n.addIDInfo(this._element,null,{dataUnit:this._dataUnit})}loadGridCustomFormatters(i){i&&this._grid&&i.forEach((i=>{var t;(null===(t=i.properties)||void 0===t?void 0:t.rm_precision)&&this.addCustomValueFormatter(i.name,this._rmPrecisionCustomValueFormatter)}))}async interceptMetadataLoaded(i){return this.loadGridCustomFormatters(i.payload.fields),i}finishLoading(){this._dataUnit.addInterceptor(this.dataUnitInterceptor),f.assertDefaultSorting(this._gridConfig,this._dataUnit),this.addElementID(),null!=this.columnFilterDataSource&&(this.columnFilterDataSource.setApplication(this._application),this.columnFilterDataSource.setDataUnit(this._dataUnit))}setCustomRenders(){if(this._grid)for(const[i,t]of this._customRenders)this._grid.addGridCustomRender(i,t.customRender,t.detailContext),this._customRenders.delete(i)}setCustomEditors(){if(this._grid)for(const[i,t]of this._customEditors)this._grid.addCustomEditor(i,t.customEditor,t.detailContext),this._customEditors.delete(i)}componentWillLoad(){this._application=d.getContextValue("__SNK__APPLICATION__");let i=this._element.parentElement;for(;i;){if("SNK-DATA-UNIT"===i.tagName.toUpperCase()){this._snkDataUnit=i,this._dataUnit=this._snkDataUnit.dataUnit,this._dataUnit?this.finishLoading():this._snkDataUnit.addEventListener("dataUnitReady",(i=>{this._dataUnit=i.detail,this.finishLoading()})),this.messagesBuilder||(this.messagesBuilder=this._snkDataUnit.messagesBuilder),this._snkDataUnit.addEventListener("dataStateChange",this.handleDataStateChange.bind(this)),this._snkDataUnit.addEventListener("cancelEdition",(()=>{var i;(null===(i=this._dataState)||void 0===i?void 0:i.recordsIsEmpty)&&this._dataUnit.clearSelection()}));break}i=i.parentElement}this._rmPrecisionCustomValueFormatter=new v,this.addGridLegacyConfigName(),this.loadConfig()}componentDidRender(){this._rmPrecisionCustomValueFormatter.setGrid(this._grid),this.loadGridCustomFormatters(this._dataUnit.metadata.fields),this.setCustomRenders(),this.setCustomEditors()}async handleDataStateChange(i){this._dataState=i.detail,this._rmPrecisionCustomValueFormatter.setDataState(this._dataState)}getHeaderDisabledButtons(){var i;const t=[];return(null===(i=this._dataState)||void 0===i?void 0:i.selectionInfo)&&(this._dataState.selectionInfo.length>1&&t.push(h.CLONE,"ATTACH",h.UPDATE),this._dataState.selectionInfo.isAllRecords()&&t.push("REMOVE")),t}getInvisibleButtons(){let i=[];return this._dataUnit&&0!==this._dataUnit.records.length||i.push("DATA_EXPORTER"),this._dataState&&this._dataState.selectionInfo.mode===p.ALL_RECORDS&&i.push("ACTIONS_BUTTON"),i}componentWillRender(){const i=this.getInvisibleButtons();this._headerTaskbarProcessor.process(this.getHeaderTaskbarId(),this.taskbarManager,this._dataState,this.getHeaderDisabledButtons(),i),this._topTaskbarProcessor.process(this.getTopTaskBarId(),this.taskbarManager,this._dataState,void 0,i),this.dataExporterProviderStore()}getHeaderTaskbarId(){var i,t;const s=this._dataState&&!!(null===(i=this._dataState.selectionInfo)||void 0===i?void 0:i.length),e={primary:this.isDetail?"snkGridHeaderTaskbar.detail":"snkGridHeaderTaskbar",secondary:this.isDetail?"snkGridHeaderTaskbar.detail":"snkGridHeaderTaskbar",singleTaskbar:this.isDetail?"snkGridHeaderTaskbar.singleTaskbar.detail":"snkGridHeaderTaskbar.singleTaskbar"}[this.presentationMode];let a=s?`${e}.selected`:`${e}.unselected`;return(null===(t=this._dataState)||void 0===t?void 0:t.isDirty)&&this.presentationMode===c.SINGLE_TASKBAR&&(a="snkGridHeaderTaskbar.singleTaskbar.finish_edition"),a}getTopTaskBarId(){var i;const t={primary:"",secondary:".secondary",singleTaskbar:".singleTaskbar"}[this.presentationMode];return(null===(i=this._dataState)||void 0===i?void 0:i.isDirty)?`snkGridTopTaskbar.finish_edition${t}`:`snkGridTopTaskbar.regular${t}`}getPrimaryButton(){return{primary:"INSERT",secondary:"",singleTaskbar:"INSERT"}[this.presentationMode]}getColumnSearch(i,t){return null!=this._columnSearch||(this._moreOptions=i,this._columnSearch=T(t,(({argument:i})=>new Promise((t=>{this._grid.filterColumns(i).then((i=>{t(i.filter((i=>!i.hidden)).map((i=>({label:i.label,value:i.name}))))}))}))),(t=>{null!=t&&(this._grid.locateColumn(t.value),i.hideActions())}))),this._columnSearch}getActionsList(){const i=[{value:o.generateUUID(),label:this.messagesBuilder.getMessage("snkGrid.findColumn",{}),disableCloseOnSelect:!0,eagerInitialize:!0,itemBuilder:(i,t)=>this.getColumnSearch(i,t)}];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)}handleFilterConfigUpdated(i){this._showSnkFilterBar=!!i.length&&(1!==i.length||"PERSONALIZED_FILTER_GROUP"!==i[0].id||i[0].groupedItems.length>0)}render(){if(this._dataUnit)return s("div",{class:"snk-grid__container ez-flex ez-flex--column ez-flex-item--auto ez-padding--large"},s("div",{class:"snk-grid__header ez-margin-bottom--medium"},this._showSnkFilterBar&&s(e,null,s("snk-filter-bar",{ref:i=>this._snkFilterBar=i,title:this.filterBarTitle,dataUnit:this._dataUnit,"data-element-id":"gridFilter",class:"snk-grid__filter-bar ez-align--top",configName:this.configName,messagesBuilder:this.messagesBuilder,resourceID:this.resourceID,onConfigUpdated:i=>this.handleFilterConfigUpdated(i.detail),disablePersonalizedFilter:this.disablePersonalizedFilter,filterBarLegacyConfigName:this.filterBarLegacyConfigName,autoLoad:this.autoLoad}),s("hr",{class:"ez-divider-vertical ez-divider--dark ez-margin-left--medium snk-grid__header-divider"})),s("snk-taskbar",{class:"ez-padding-left--medium","data-element-id":"grid_top",key:"topTaskbar",configName:this.configName,dataUnit:this._dataUnit,messagesBuilder:this.messagesBuilder,buttons:this._topTaskbarProcessor.buttons,disabledButtons:this._topTaskbarProcessor.disabledButtons,customButtons:this._topTaskbarProcessor.customButtons,primaryButton:this.getPrimaryButton(),resourceID:this.resourceID,customContainerId:this.taskbarCustomContainerId,customSlotId:this.topTaskbarCustomSlotId,overflowStrategy:"none"},s("slot",{name:this.topTaskbarCustomSlotId}))),s("ez-grid",{ref:i=>this._grid=i,class:(this.presentationMode===c.SECONDARY?"snk-grid-container__without-shadow ":"")+"snk-grid__table","data-element-id":"embedded",dataUnit:this._dataUnit,key:"grid-"+this._snkDataUnit.entityName,config:this._gridConfig,onConfigChange:i=>{this.gridConfigChangeHandler(i)},onEzDoubleClick:i=>this.gridDoubleClick.emit(i.detail),statusResolver:this.statusResolver,multipleSelection:this.multipleSelection,columnfilterDataSource:this.columnFilterDataSource,selectionToastConfig:this.selectionToastConfig,useEnterLikeTab:this.useEnterLikeTab,recordsValidator:this.recordsValidator,canEdit:this.canEdit,autoFocus:this.autoFocus},s("snk-taskbar",{id:"teste",dataUnit:this._dataUnit,configName:this.configName,messagesBuilder:this.messagesBuilder,"data-element-id":"grid_left",buttons:this._headerTaskbarProcessor.buttons,presentationMode:this.presentationMode,disabledButtons:this._headerTaskbarProcessor.disabledButtons,customButtons:this._headerTaskbarProcessor.customButtons,slot:"leftButtons",actionsList:this.getActionsList(),primaryButton:this.getPrimaryButton(),resourceID:this.resourceID,customContainerId:this.taskbarCustomContainerId,customSlotId:this.gridHeaderCustomSlotId},s("slot",{name:this.gridHeaderCustomSlotId}))),s("div",{class:"ez-col ez-col--sd-12"},s("slot",{name:"SnkGridFooter"})),s("ez-modal",{modalSize:"small",closeEsc:!1,closeOutsideClick:!1,opened:this._popUpGridConfig,onEzCloseModal:()=>this.closeGridConfig()},s("snk-grid-config",{ref:i=>this._snkGridConfig=i,config:this._gridConfig,"data-element-id":this._element.getAttribute(n.DATA_ELEMENT_ID_ATTRIBUTE_NAME),selectedIndex:0,configName:this.configName,onConfigChange:i=>this.modalConfigChangeHandler(i),onConfigCancel:()=>this.closeGridConfig(),resourceID:this.resourceID})))}get _element(){return a(this)}static get watchers(){return{gridLegacyConfigName:["handleGridLegacyConfigName"]}}};b.style=".sc-snk-grid-h{--snk-grid-min-height:300px}.snk-grid__container.sc-snk-grid{display:flex;height:100%;width:100%}.snk-grid__header.sc-snk-grid{width:100%;display:flex;flex-wrap:nowrap;justify-content:flex-end}.snk-grid__filter-bar.sc-snk-grid{width:100%}.snk-grid__header-divider.sc-snk-grid{margin-bottom:var(--space--medium)}.snk-grid__table.sc-snk-grid{min-height:var(--snk-grid-min-height)}.snk-grid-container__without-shadow.sc-snk-grid{--ezgrid__container--shadow:unset}";export{b as snk_grid}
|
@@ -0,0 +1 @@
|
|
1
|
+
import{r as t,c as i,h as s,g as e,H as a}from"./p-d2d301a6.js";import{Action as n,ObjectUtils as h,DataUnitAction as r,StringUtils as o,ApplicationContext as d}from"@sankhyalabs/core";import{ApplicationUtils as l,DialogType as c}from"@sankhyalabs/ezui/dist/collection/utils";import{O as u,S as v}from"./p-7c4aabe2.js";import{g as f,a as m}from"./p-091ce761.js";import{convertType as b}from"@sankhyalabs/core/dist/dataunit/metadata/DataType";import{g as p}from"./p-7dd49d15.js";const D=class{constructor(s){t(this,s),this.dataStateChange=i(this,"dataStateChange",3),this.dataUnitReady=i(this,"dataUnitReady",3),this.messagesBuilderUpdated=i(this,"messagesBuilderUpdated",3),this.dataUnitFieldsHidded=i(this,"dataUnitFieldsHidded",7),this.insertionMode=i(this,"insertionMode",3),this.cancelEdition=i(this,"cancelEdition",3),this._onDataUnitResolve=[],this._openedAlert=!1,this._fieldsWithRmp=[],this._fieldsWithRmPrecision=[],this._metadataByRow=new Map,this._rowMetadataCache=new Map,this.REGEX_DATAUNIT_NAME=/dd:\/\/(.+?)\//,this._dataUnitObserver=async t=>{const i=this.buildDataState(t.type);switch(this.dataState=i,this.messagesBuilder.currentOperation=this.getMessageOperation(),t.type){case n.DATA_SAVED:await this.handleDataSaved(t);break;case n.RECORDS_ADDED:case n.RECORDS_COPIED:this.insertionMode.emit();break;case n.EDITION_CANCELED:this.cancelEdition.emit();break;case n.RECORDS_REMOVED:this.handleRecordsRemoved(t);break;case n.METADATA_LOADED:this.fillFieldsWithRmp(this.dataUnit.metadata),this.fillFieldsWithRmPrecision(this.dataUnit.metadata)}},this.fieldsToLink=[],this.dataState=void 0,this.messagesBuilder=void 0,this.dataUnitName=void 0,this.entityName=void 0,this.pageSize=150,this.dataUnit=void 0,this.beforeSave=void 0,this.afterSave=void 0,this.useCancelConfirm=!0,this.ignoreSaveMessage=void 0,this.configName=void 0,this.resourceID=void 0,this.domainMessagesBuilder=void 0}observePageSize(){this.dataUnit&&(this.dataUnit.pageSize=this.pageSize)}observeDataUnitName(t,i){i!=t&&(this.dataUnit?this._application.updateDataunitCache(i,this.dataUnitName,this.dataUnit):this.loadDataUnit())}observeEntityName(t,i){i!=t&&(this.dataUnit=void 0,this.entityName=t,this.loadDataUnit())}observeDataState(t,i){h.objectToString(i)!=h.objectToString(t)&&this.dataStateChange.emit(t)}observeDataUnit(){this.handlerLinkFields(),this.dataUnitReady.emit(this.dataUnit)}observeMessagesBuilder(t){t&&this.messagesBuilderUpdated.emit(t)}async getDataUnit(){return new Promise((t=>{this.dataUnit?t(this.dataUnit):this._onDataUnitResolve.push(t)}))}async getSelectedRecordsIDsInfo(){return p(this.dataUnit)}async getFieldsWithRmp(){return this._fieldsWithRmp}async getFieldsWithRmPrecision(){return this._fieldsWithRmPrecision}async getRowMetadata(t){return this.doGetRowMetadata(t)}doGetRowMetadata(t){const i=this.dataUnit.getSelectedRecord();if(!t&&!i)return;const s=t||i,e=this._metadataByRow.get("string"==typeof s?s:s.__record__id__);return e?(e.getProp=this.buildGetPropRowMetadata(e),Object.assign({},e)):void 0}buildGetPropRowMetadata(t){return(i,s)=>("rm_precision"===i&&(i=this.resolvePrecisionFromMetadata(s)),h.getProp(t,i))}resolvePrecisionFromMetadata(t){var i,s;if(!t)return void l.error(this.getMessage("snkDataUnit.fieldNameRequired"));const e=null===(s=null===(i=this.dataUnit.getField(t))||void 0===i?void 0:i.properties)||void 0===s?void 0:s.rm_precision;return e?e.split(".").filter(((t,i)=>1!==i)).join("."):""}getCleanOnCopyFields(){var t;return null===(t=this.dataUnit.metadata)||void 0===t?void 0:t.fields.filter((t=>{var i;return null===(i=t.properties)||void 0===i?void 0:i.cleanOnCopy})).map((t=>t.name))}fillFieldsWithRmp(t){t.fields.forEach((t=>{var i;(null===(i=t.properties)||void 0===i?void 0:i.rmp)&&!this._fieldsWithRmp.includes(t.name)&&this._fieldsWithRmp.push(t.name)}))}fillFieldsWithRmPrecision(t){t.fields.forEach((t=>{var i;(null===(i=t.properties)||void 0===i?void 0:i.rm_precision)&&!this._fieldsWithRmPrecision.includes(t.name)&&this._fieldsWithRmPrecision.push(t.name)}))}getCacheName(t,i,s){return[t,i,s].join("_")}updateDataStateRmp(t){const i=Object.assign({},t);this.dataState.rowMetadata=i}saveCacheRmd(t){const i=t.__record__metadata__,s=Object.keys(i);s.shift(),s.forEach((s=>{const e=f(t,s),a=this.getCacheName(s,i.provider,e);this._rowMetadataCache.set(a,Object.assign({},i))}))}getMetadataByRow(t){var i;if(!(null===(i=t.records)||void 0===i?void 0:i.length))return t;if(!this._fieldsWithRmp.length){const i=t.records.map((t=>(delete t.__record__metadata__,t)));return Object.assign(Object.assign({},t),{records:i})}const s=t.records.map((t=>{if(!t.__record__metadata__)return t;this.saveCacheRmd(t);const i=Object.assign({},t.__record__metadata__);return i.getProp=this.buildGetPropRowMetadata(i),this._metadataByRow.set(t.__record__id__,i),delete t.__record__metadata__,t}));return Object.assign(Object.assign({},t),{records:s})}interceptRecordsAdded(t){if(this.isAllowed("INSERT"))return new r(n.RECORDS_ADDED,this.handleLinksWithParent(t.payload));l.info(this.getMessage("snkDataUnit.forbiddenInsert"))}interceptRecordsCopied(t){if(this.isAllowed("CLONE"))return new r(n.RECORDS_COPIED,this.handleRecordsCopied(t.payload));l.info(this.getMessage("snkDataUnit.forbiddenClone"))}async interceptDataChange(t){if(this.isAllowed("UPDATE"))return t;this._openedAlert?await this.dataUnit.cancelEdition():(this._openedAlert=!0,await this.dataUnit.cancelEdition(),await l.alert(this.getMessage("snkDataUnit.forbidden"),this.getMessage("snkDataUnit.forbiddenUpdate")),this._openedAlert=!1)}async interceptSavingData(t){if(!this.beforeSave)return t;const i=this.beforeSave(this.dataUnit);return i instanceof Promise?await i?t:void 0:i?t:void 0}interceptDataSaved(t){if(!this.afterSave)return t;this.afterSave(this.dataUnit)}async interceptEditionCanceled(t){var i,s;if(!this.useCancelConfirm||!this.dataState.hasDirtyRecords||(null===(i=t.payload)||void 0===i?void 0:i.fromParent)||(null===(s=t.payload)||void 0===s?void 0:s.silent))return t;const e=this.getMessage("snkDataUnit.cancelConfirmation");if(null==e)return this.showSuccessMessage(this.getMessage("snkDataUnit.cancelInfo")),t;const a=this.getMessage("snkDataUnit.cancelConfirmationTitle"),n=await l.confirm(a,e);return n&&this.showSuccessMessage(this.getMessage("snkDataUnit.cancelInfo")),n?t:void 0}async interceptRemovingRecords(t){var i,s,e;if(!this.isAllowed("REMOVE"))return void l.info(this.getMessage("snkDataUnit.forbiddenRemove"));let a=!1,n=!(null===(i=t.payload)||void 0===i?void 0:i.silent)&&this.getMessage("snkDataUnit.removeConfirmation");const h=null===(s=this.dataUnit)||void 0===s?void 0:s.getSelectionInfo();if(!(null===(e=t.payload)||void 0===e?void 0:e.silent)&&(null==h?void 0:h.length)>1&&(n=this.getMessage("snkDataUnit.removeAllConfirmation",{size:h.length}),a=!0),!n)return t;const r={canClose:!1,labelCancel:this.getMessage("snkDataUnit.confirm."+(a?"no":"cancel")),labelConfirm:this.getMessage("snkDataUnit.confirm."+(a?"yes":"delete")),btnConfirmDanger:!1},o=this.getMessage("snkDataUnit.removeConfirmationTitle");return await l.confirm(o,n,null,c.WARN,r)?t:void 0}interceptDataLoaded(t){const i=this.getMetadataByRow(t.payload);return new r(n.DATA_LOADED,i)}interceptMetadataLoaded(t){return this.fillFieldsWithRmp(t.payload),this.fillFieldsWithRmPrecision(t.payload),new r(n.METADATA_LOADED,this.handleDULinksOnMetadataLoaded(t.payload))}async interceptAction(t){switch(t.type){case n.RECORDS_ADDED:return this.interceptRecordsAdded(t);case n.RECORDS_COPIED:return this.interceptRecordsCopied(t);case n.DATA_CHANGED:return await this.handleLoadRowMetadata(t),await this.interceptDataChange(t);case n.CHANGING_DATA:return await this.interceptDataChange(t);case n.SAVING_DATA:return await this.interceptSavingData(t);case n.DATA_SAVED:return this.interceptDataSaved(t);case n.EDITION_CANCELED:return await this.interceptEditionCanceled(t);case n.REMOVING_RECORDS:return await this.interceptRemovingRecords(t);case n.DATA_LOADED:return this.interceptDataLoaded(t);case n.METADATA_LOADED:return this.interceptMetadataLoaded(t);default:return t}}async handleLoadRowMetadata(t){const i=t.type===n.DATA_CHANGED?t.payload:t.payload.changes[0].record,s=Object.keys(i).find((t=>this._fieldsWithRmp.includes(t)));if(s){const t=this.dataUnit.getField(s).properties.rmp,e=f(i,s);return await this.updateRowMetadata({fieldName:s,fieldValue:e,metadataName:t,updatedFields:i})}}async updateRowMetadata({fieldName:t,fieldValue:i,metadataName:s,updatedFields:e}){const a=this.getCacheName(t,s,i),n=this._rowMetadataCache.get(a);if(n)return this.updateDataStateRmp(n),n;{const i=new m,n=await i.loadRowMetadata(this,t,s,e);return this.updateDataStateRmp(n._rmd),this._rowMetadataCache.set(a,Object.assign({},n._rmd)),Object.assign({},n._rmd)}}handleDULinksOnMetadataLoaded(t){const i=Object.assign({},t);return this.processLinks(i),i}handleRecordsCopied(t){let i=[...t];return i=this.handleCleanOnCopy(i),this.handleLinksWithParent(i)}handleLinksWithParent(t){var i,s;const e=null!==(i=this._parentDataUnit)&&void 0!==i?i:null===(s=this.dataUnit)||void 0===s?void 0:s.getParentDataUnit();if(!e)return t;const a=e.getSelectedRecord(),n=null==e?void 0:e.getChildInfo(this.getCleanDataUnitName()),{links:h}=n;return h&&0!==h.length?t.map((t=>this.buildRecordWithLinkedFields(t,h,a))):t}buildRecordWithLinkedFields(t,i,s){const e=Object.assign({},t);return i.forEach((t=>{const i=b(this.dataUnit.getField(t.target).dataType,s[t.source]);e[t.target]=i})),e}handleCleanOnCopy(t){const i=this.getCleanOnCopyFields();return i.length>0&&(t=t.map((t=>this.buildCopyWithCleanedFields(t,i)))),t}buildCopyWithCleanedFields(t,i){const s=Object.assign({},t);return i.forEach((t=>delete s[t])),s}showSuccessMessage(t){l.info(t,{iconName:"check"})}isAllowed(t){return!!this._permissions&&(this._permissions.isSup||this._permissions[t])}buildDataState(t){var i;const s=this.dataUnit.getSelectionInfo(),e=(this.dataUnit.hasDirtyRecords()||this.dataUnit.hasWaitingChanges())&&(null==s?void 0:s.isEmpty()),a=this.dataUnit.getSelectedRecord();let h=null===(i=this.dataState)||void 0===i?void 0:i.rowMetadata;return!a||h&&![n.SELECTION_CHANGED,n.EDITION_CANCELED,n.NEXT_SELECTED,n.PREVIOUS_SELECTED].includes(t)?h&&(h.getProp=this.buildGetPropRowMetadata(h)):h=this.doGetRowMetadata(a),new w({insertionMode:this.dataUnit.hasNewRecord(),isStartingInsertionMode:e,hasNext:this.dataUnit.hasNext(),hasPrevious:this.dataUnit.hasPrevious(),copyMode:this.dataUnit.hasCopiedRecord(),isDirty:this.dataUnit.isDirty(),hasDirtyRecords:this.dataUnit.hasDirtyRecords(),selectedRecords:void 0,selectionInfo:s,selectedRecord:a,recordsIsEmpty:0===this.dataUnit.records.length,metadataByRow:this._metadataByRow,rowMetadata:h})}async handleDataSaved(t){const i=await this.handleLoadRowMetadata(t);if(i&&(i.getProp=this.buildGetPropRowMetadata(i)),this._metadataByRow.set(t.payload.records[0].__record__id__,i),this.dataState=this.buildDataState(),this.ignoreSaveMessage)return;const s=t.payload.changes[0]._operation.toLowerCase(),e=this.getMessage("snkDataUnit.saveInfo",t.payload.records[0],s);null!=e&&this.showSuccessMessage(e)}handleRecordsRemoved(t){var i,s;const e=t.payload.cachedRecords;let a;a=(null==e?void 0:e.length)>1?this.getMessage("snkDataUnit.removeAllInfo",{size:e.length}):this.getMessage("snkDataUnit.removeInfo",t.payload.cachedRecords[0]),null!=a&&this.showSuccessMessage(a);const n=null!==(s=null===(i=this.dataUnit.records)||void 0===i?void 0:i.length)&&void 0!==s?s:0,h=this.dataUnit.getPaginationInfo();h&&this.dataUnit.gotoPage(n>0||h.hasMore?h.currentPage:0)}getMessage(t,i,s){return i||(i=this.getMessageParams()),s&&(this.messagesBuilder.currentOperation=s),this.messagesBuilder.getMessage(t,i)}getMessageParams(){return this.dataState.selectedRecord}getMessageOperation(){return this.dataState.copyMode?u.CLONE:this.dataState.insertionMode||this.dataState.isStartingInsertionMode?u.INSERT:this.dataState.isDirty?u.UPDATE:u.CLEAN}async getDataUnitParentOrChild(){var t;const i=this.dataUnitName?this.dataUnitName:this.entityName;return this._parentSnkDataUnit?(this._parentDataUnit=await(null===(t=this._parentSnkDataUnit)||void 0===t?void 0:t.getDataUnit()),await this._application.getDataUnit(this.entityName,i,this._parentDataUnit,this.configName,this.resourceID)):await this._application.getDataUnit(this.entityName,i,null,this.configName,this.resourceID)}async loadDataUnit(){var t;if(null==this.dataUnit&&this._application&&this.entityName&&(this.dataUnit=await this.getDataUnitParentOrChild()),this.dataUnit){let i;for(this.dataUnit.pageSize=this.pageSize,this.dataUnit.unsubscribe(this._dataUnitObserver),this.dataUnit.addInterceptor(this),this.dataUnit.subscribe(this._dataUnitObserver),await this.dataUnit.loadMetadata(),(null===(t=this.dataUnit.records)||void 0===t?void 0:t.length)&&this.getMetadataByRow(this.dataUnit),this.dataState=this.buildDataState();i=this._onDataUnitResolve.pop();)i(this.dataUnit)}}getParentSnkDataUnit(){let t=this.element;for(;t.parentNode;){if("SNK-DATA-UNIT"===t.parentNode.nodeName)return t.parentNode;t=t.parentNode}}handlerLinkFields(){var t,i,s,e;const a=null!==(t=this._parentDataUnit)&&void 0!==t?t:null===(i=this.dataUnit)||void 0===i?void 0:i.getParentDataUnit();if(!a)return;const n=null!==(s=this.entityName)&&void 0!==s?s:this.getCleanDataUnitName(),h=a.getChildInfo(n);if(!h)return;const r=null===(e=null==h?void 0:h.links)||void 0===e?void 0:e.map((t=>t.target));this.handleDUWithLinks(r)}handleDUWithLinks(t){this.fieldsToLink=t;const i=Object.assign({},this.dataUnit.metadata);this.processLinks(i),this.dataUnit.metadata=i,this.dataUnitFieldsHidded.emit()}processLinks(t){var i;null===(i=null==t?void 0:t.fields)||void 0===i||i.forEach((t=>{var i;(null===(i=this.fieldsToLink)||void 0===i?void 0:i.includes(t.name))&&(t.visible=!1)}))}getCleanDataUnitName(){var t;const i=this.dataUnit.name;if(o.isEmpty(i))return i;const s=this.REGEX_DATAUNIT_NAME.exec(i);return null!==(t=null==s?void 0:s[1])&&void 0!==t?t:i}static getNearestInstance(t){let i=t.parentElement;for(;i;){if("SNK-DATA-UNIT"===i.tagName.toUpperCase())return i;i=i.parentElement}}instanceMessagesBuilder(){var t;this.messagesBuilder||(this.messagesBuilder=new v(null!==(t=this.domainMessagesBuilder)&&void 0!==t?t:this.entityName))}componentWillLoad(){this._application=d.getContextValue("__SNK__APPLICATION__"),this._application.getAllAccess(this.resourceID).then((t=>this._permissions=t)),this._parentSnkDataUnit=this.getParentSnkDataUnit(),this.instanceMessagesBuilder()}disconnectedCallback(){this.dataUnit&&this.dataUnit.releaseCallbacks()}async componentDidLoad(){await this.loadDataUnit(),this.handlerLinkFields()}render(){return s(a,null)}get element(){return e(this)}static get watchers(){return{pageSize:["observePageSize"],dataUnitName:["observeDataUnitName"],entityName:["observeEntityName"],dataState:["observeDataState"],dataUnit:["observeDataUnit"],messagesBuilder:["observeMessagesBuilder"]}}};class w{constructor(t){this.copyMode=t.copyMode,this.insertionMode=t.insertionMode,this.isStartingInsertionMode=t.isStartingInsertionMode,this.isDirty=t.isDirty,this.hasDirtyRecords=t.hasDirtyRecords,this.hasNext=t.hasNext,this.hasPrevious=t.hasPrevious,this.selectionInfo=t.selectionInfo,this.selectedRecord=t.selectedRecord,this.recordsIsEmpty=t.recordsIsEmpty,this.metadataByRow=t.metadataByRow,this.rowMetadata=t.rowMetadata}get selectedRecords(){var t;if(console.warn("SnkDataUnit: O método `selectedRecords` foi descontinuado. Use o método `selectionInfo`."),null===(t=this.selectionInfo)||void 0===t?void 0:t.isAllRecords())throw new Error("Erro interno: Impossível obter os registros selecionados. A seleção atual é virtual. Use o atributo `selectionInfo`.");return this.selectionInfo.records}}export{D as S}
|
@@ -1 +1 @@
|
|
1
|
-
import{r as t,h as e,H as i,g as s}from"./p-d2d301a6.js";import{ApplicationContext as o,ObjectUtils as r,UserInterface as n,DataType as l,ElementIDUtils as a}from"@sankhyalabs/core";import{ApplicationUtils as d,DialogType as h}from"@sankhyalabs/ezui/dist/collection/utils";import{D as c,a as p,b as u}from"./p-30cf616e.js";import{R as m}from"./p-b0ef4383.js";import{D as v}from"./p-594bc21d.js";import{S as x}from"./p-cc935517.js";import"./p-25f1fc39.js";import"./p-21749402.js";import"@sankhyalabs/ezui/dist/collection/utils/constants";import"@sankhyalabs/core/dist/dataunit/metadata/UnitMetadata";import"./p-091ce761.js";import"./p-ff1990ad.js";import"./p-181975f1.js";import"./p-8d884fab.js";import"./p-7c4aabe2.js";import"./p-9863d682.js";import"@sankhyalabs/core/dist/dataunit/metadata/DataType";import"@sankhyalabs/ezui/dist/collection/components/ez-grid/utils";import"@sankhyalabs/core/dist/utils/SortingUtils";import"./p-688dcb4c.js";class f{constructor(t,e){this._selectedNumber=0,this._getMessage=t,this._selectedNumber=e}setExportOption(t,e){const i=this.getExportGroupName();t===c.EXPORT_TO_PDF&&e.push(this.getExportToPDF(i)),t===c.EXPORT_TO_XLS&&e.push(this.getExportToXLS(i)),this.setExportCurrentPage(t,e),this._selectedNumber>0&&this.setExportAllRecords(t,e),this.setExportByEmail(t,e)}setExportCurrentPage(t,e){var i;const s=[c.EXPORT_PAGE_TO_PDF,c.EXPORT_PAGE_TO_XLS];if(t===c.EXPORT_CURRENT_PAGE&&e.push(this.getCurrentPage()),s.includes(t)){let s=e.find((t=>t.id===c.EXPORT_CURRENT_PAGE));null==s&&(e.push(this.getCurrentPage()),s=e.find((t=>t.id===c.EXPORT_CURRENT_PAGE))),(null===(i=null==s?void 0:s.children)||void 0===i?void 0:i.length)||(s.children=[]),t===c.EXPORT_PAGE_TO_PDF&&s.children.push(this.getExportPageToPDF()),t===c.EXPORT_PAGE_TO_XLS&&s.children.push(this.getExportPageToXLS())}}setExportAllRecords(t,e){var i;const s=[c.EXPORT_ALL_RECORDS_TO_PDF,c.EXPORT_ALL_RECORDS_TO_XLS];if(t===c.EXPORT_ALL_RECORDS&&e.push(this.getAllRecords()),s.includes(t)){let s=e.find((t=>t.id===c.EXPORT_ALL_RECORDS));null==s&&(e.push(this.getAllRecords()),s=e.find((t=>t.id===c.EXPORT_ALL_RECORDS))),(null===(i=s.children)||void 0===i?void 0:i.length)||(s.children=[]),t===c.EXPORT_ALL_RECORDS_TO_PDF&&s.children.push(this.getExportAllRecordsToPDF()),t===c.EXPORT_ALL_RECORDS_TO_XLS&&s.children.push(this.getExportAllRecordsToXLS())}}setExportByEmail(t,e){t===c.EXPORT_BY_EMAIL&&e.push(this.getExportByEmail())}getExportToPDF(t){return{id:c.EXPORT_TO_PDF,label:"PDF (.pdf)",group:t}}getExportToXLS(t){return{id:c.EXPORT_TO_XLS,label:`${this._getMessage("snkDataExporter.label.spreadsheet")} (.xls)`,group:t}}getCurrentPage(){return{id:c.EXPORT_CURRENT_PAGE,label:this._getMessage("snkDataExporter.label.currentPage"),group:this._getMessage("snkDataExporter.group.custom")}}getAllRecords(){return{id:c.EXPORT_ALL_RECORDS,label:this._getMessage("snkDataExporter.label.allRecords"),group:this._getMessage("snkDataExporter.group.custom")}}getExportPageToPDF(){return{id:c.EXPORT_PAGE_TO_PDF,label:"PDF (.pdf)"}}getExportPageToXLS(){return{id:c.EXPORT_PAGE_TO_XLS,label:`${this._getMessage("snkDataExporter.label.spreadsheet")} (.xls)`}}getExportAllRecordsToPDF(){return{id:c.EXPORT_ALL_RECORDS_TO_PDF,label:"PDF (.pdf)"}}getExportAllRecordsToXLS(){return{id:c.EXPORT_ALL_RECORDS_TO_XLS,label:`${this._getMessage("snkDataExporter.label.spreadsheet")} (.xlsx)`}}getExportByEmail(){return{id:c.EXPORT_BY_EMAIL,label:`${this._getMessage("snkDataExporter.label.sendByEmail")}...`}}getExportGroupName(){return 1===this._selectedNumber?this._getMessage("snkDataExporter.group.export.selectedLine"):this._selectedNumber>1?this._getMessage("snkDataExporter.group.export.multiSelected").replace("{0}",this._selectedNumber.toString()):this._getMessage("snkDataExporter.group.export.default")}}function g(t){const e=[];let i=0;for(const s of t){if(i+=s.width,i>=800)break;e.push(s)}return e}function b(t){return Object.keys(c).find((e=>c[e]===t))}class E{constructor(t){this._provider=t}async getParsedColumns(){return g(await this._provider.getColumnsMetadata())}async getParams(t){var e,i,s,o,r,n;const l=null===(i=(e=this._provider).getFilters)||void 0===i?void 0:i.call(e),a=[p.EXPORT_TO_PDF,p.EXPORT_PAGE_TO_PDF,p.EXPORT_PDF_TO_EMAIL,p.EXPORT_ALL_RECORDS_TO_PDF].includes(b(null==t?void 0:t.exportOption))?await this.getParsedColumns():await this._provider.getColumnsMetadata(),d=null===(o=(s=this._provider).getOrders)||void 0===o?void 0:o.call(s),h=null===(n=(r=this._provider).getResourceURI)||void 0===n?void 0:n.call(r),u=this._provider.getSelectedIDs(),m=t.exportOption,v=[c.EXPORT_PAGE_TO_PDF,c.EXPORT_PAGE_TO_XLS];delete t.exportOption;let x=Object.assign({filters:l,columns:a,sort:d,resourceURI:h,selectedIDs:u.slice(0,this._provider.getExportLimit())},t);if(v.includes(m)||"page"==t.type){const t=this._provider.getOffset(),e=this._provider.getPageSize();x=Object.assign(Object.assign({},x),{offset:t,limit:e,selectedIDs:[]})}else"all"==t.type&&(x=Object.assign(Object.assign({},x),{offset:0,limit:this._provider.getExportLimit(),selectedIDs:[]}));return Promise.resolve(x)}async executeExport(t){const e=await this.getParams(t),{methodName:i}=e,s=function(t,e){var i={};for(var s in t)Object.prototype.hasOwnProperty.call(t,s)&&e.indexOf(s)<0&&(i[s]=t[s]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(s=Object.getOwnPropertySymbols(t);o<s.length;o++)e.indexOf(s[o])<0&&Object.prototype.propertyIsEnumerable.call(t,s[o])&&(i[s[o]]=t[s[o]])}return i}(e,["methodName"]),n=`${o.getContextValue("__SNK__APPLICATION__").getModuleName()}@DataExporterSPBean.${i}`,l={serviceName:n,requestBody:s};return new Promise(((t,e)=>{v.get().callServiceBroker(n,r.objectToString(l)).then((e=>t(this.getFormatResponse(e)))).catch((t=>e(t)))}))}getFormatResponse(t){var e;const i=null===(e=null==t?void 0:t.json)||void 0===e?void 0:e.$;if(null!=i)return r.stringToObject(i)}}class w{constructor(t){this._provider=t}async getParsedColumns(){return g(await this._provider.getColumnsMetadata())}async executeExport(t){const{methodName:e,titleGrid:i}=t,s=await this._provider.getRecords(),o=[p.EXPORT_TO_PDF,p.EXPORT_PAGE_TO_PDF,p.EXPORT_PDF_TO_EMAIL,p.EXPORT_ALL_RECORDS_TO_PDF].includes(b(null==t?void 0:t.exportOption))?await this.getParsedColumns():await this._provider.getColumnsMetadata(),[r,n]=this.getExecutor(e),l={serviceName:r,requestBody:{grid:{titleGrid:i,columns:this.buildColumnsObject(o),rows:this.buildRowsObject(o,s),customOptions:{xlsxExtension:!1}}}};return new Promise(((t,e)=>{v.get().callServiceBroker(r,l).then((e=>t(n(e)))).catch((t=>e(t)))}))}getExecutor(t){return"exportToPDF"===t?["GridPDFBuilderSP.buildPDFFromJson",t=>({fileSessionKey:t.chavePDF.valor,canPrint:"S"===t.permiteImprimir.valor,canExport:"S"===t.permiteExportar.valor,canSendEmail:"S"===t.canSendEmail.valor,useAppPrint:!0})]:["GridXLSBuilderSP.buildXLSFromJson",t=>({fileSessionKey:t.chaveXLS.valor,canPrint:!1,canExport:!1,useAppPrint:!1,canSendEmail:!1})]}buildColumnsObject(t){return{column:t.map(((t,e)=>{const{label:i,id:s,width:o,userInterface:r}=t;return Object.assign({index:e+1,id:s,label:i,width:o,presentationType:"P"},k[r]||{type:"S",align:"left"})}))}}buildRowsObject(t,e){return{row:e.map((e=>{const i={};return t.forEach(((t,s)=>i["c"+(s+1)]={$:this.formatValue(e,t)})),i}))}}formatValue(t,e){return null!=this._provider.formatValue?this._provider.formatValue(t,e):t[e.id]||""}}const k={[n.DATE]:{type:"D",align:"center"},[n.DATETIME]:{type:"H",align:"center"},[n.TIME]:{type:"I",align:"right"},[n.ELAPSEDTIME]:{type:"I",align:"right"},[n.DECIMALNUMBER]:{type:"F",align:"right"},[n.INTEGERNUMBER]:{type:"I",align:"right"},[n.SEARCH]:{type:"S",align:"right"}},D=class{constructor(e){t(this,e),this._selectedNumber=0,this._customPrefix="$custom$",this._releasedToExport=[c.EXPORT_TO_PDF,c.EXPORT_TO_XLS,c.EXPORT_BY_EMAIL,c.EXPORT_PDF_TO_EMAIL,c.EXPORT_XLS_TO_EMAIL,c.EXPORT_PAGE_TO_PDF,c.EXPORT_PAGE_TO_XLS,c.EXPORT_ALL_RECORDS_TO_PDF,c.EXPORT_ALL_RECORDS_TO_XLS],this._items=[],this._showDropdown=!1,this.provider=null,this.messagesBuilder=void 0}async exportByEmail(){const t=this._selectedNumber;this._snkEmailSender.open({type:t>0?"selection":"all",selectedRows:t,email:{attachments:[{name:this._appLabel}]},resolver:({type:t,format:e,email:{to:i,subject:s,message:o}})=>{var r;const n=null!==(r=u[null==e?void 0:e.toUpperCase()])&&void 0!==r?r:u.PDF;this.resolveExporter({type:t,methodName:n,to:i,subject:s,message:o,fileName:this._appLabel,titleGrid:this._appLabel},(()=>{this._snkEmailSender.close(),d.info(this.getMessage("snkDataExporter.message.emailSuccess"),{iconName:"check"})}))}})}getMessage(t,e){if(null==this.messagesBuilder){const t=x.getNearestInstance(this._element);t&&(this.messagesBuilder=t.messagesBuilder)}return this.messagesBuilder.getMessage(t,e)}positionDropdown(){var t;const e=null===(t=this._ezButton)||void 0===t?void 0:t.getBoundingClientRect();null!=e&&null!=this._dropdownParent&&(this._dropdownParent.style.top=e.y+e.height+5+"px",this._dropdownParent.style.left=e.x+"px")}closeDropdown(t){const e=null==t?void 0:t.target;null!=e&&(e.closest(".snk-data-exporter")||(this._showDropdown=!1))}setEvents(){document.removeEventListener("click",this.closeDropdown.bind(this)),document.addEventListener("click",this.closeDropdown.bind(this)),document.removeEventListener("scroll",this.positionDropdown.bind(this)),document.addEventListener("scroll",this.positionDropdown.bind(this))}controlDropdown(){this._showDropdown=!this._showDropdown}async resolveExporter(t,e){null!=this.provider&&null!=t&&null!=e&&this.getExporterStrategy().executeExport(t).then((t=>e(t))).catch((t=>{console.error(t);let{title:e,message:i,statusMessage:s}=t||{};d.error(e||this.getMessage("snkDataExporter.message.exportError"),s||i||this.getMessage("snkDataExporter.message.unknownFailure"))}))}getExporterStrategy(){return null==this.provider.getRecords?new E(this.provider):new w(this.provider)}getOptionKey(t){return Object.keys(c).find((e=>c[e]===t))}getExportType(t){return t===c.EXPORT_ALL_RECORDS_TO_PDF||t===c.EXPORT_ALL_RECORDS_TO_XLS?"all":t===c.EXPORT_PAGE_TO_PDF||t===c.EXPORT_PAGE_TO_XLS?"page":"selection"}async dispatchExporter(t){var e,i,s;const r=this.getOptionKey(t),n=null!==(e=p[r])&&void 0!==e?e:p.EXPORT_TO_PDF,l=p[r]===p.EXPORT_TO_XLS,a={methodName:c[`EXPORT_TO_${n}`],fileName:this._appLabel,titleGrid:this._appLabel,exportOption:t,limit:null===(s=null===(i=this.provider)||void 0===i?void 0:i.getExportLimit)||void 0===s?void 0:s.call(i),type:this.getExportType(t)};await this.resolveExporter(a,(t=>{t.canExport||n===p.EXPORT_TO_PDF?function({fileSessionKey:t,isDownload:e}){const i=o.getContextValue("__SNK__APPLICATION__");window.open(`${window.location.protocol}//${window.location.hostname}:${window.location.port}/mge/visualizadorArquivos.mge?chaveArquivo=${t}${e?"&download=S":""}`),d.info(function(t){var e;return null===(e=null==t?void 0:t.messagesBuilder)||void 0===e?void 0:e.getMessage("fileViewer.message.exportSuccess",void 0)}(i),{iconName:"check"})}(Object.assign(Object.assign({},t),{fileType:n,isDownload:l})):d.error(this.getMessage("snkDataExporter.title.permission"),this.getMessage("snkDataExporter.message.exportPermission"))}))}async processExporter(t){var e,i,s,o,r,n,l;const a=null==t?void 0:t.detail,p=[c.EXPORT_PAGE_TO_PDF,c.EXPORT_PAGE_TO_XLS],u=null===(e=null==a?void 0:a.id)||void 0===e?void 0:e.includes(this._customPrefix);if((null==a?void 0:a.id)===c.EXPORT_CURRENT_PAGE)return;const m=null===(i=this.provider)||void 0===i?void 0:i.getSelectedIDs(),v=null===(s=this.provider)||void 0===s?void 0:s.getTotalRecords(),x=null===(r=null===(o=this.provider)||void 0===o?void 0:o.getPageSize)||void 0===r?void 0:r.call(o),f=null===(l=null===(n=this.provider)||void 0===n?void 0:n.getExportLimit)||void 0===l?void 0:l.call(n);let g=!1;if(p.includes(null==a?void 0:a.id)&&x<=f||u?g=!1:(null==m?void 0:m.length)?g=m.length>f:v>f&&(g=!0),g){const t=f.toLocaleString("pt-BR",{minimumFractionDigits:0}),e={title:this.getMessage("snkDataExporter.limitExceeded.title"),description:`\n ${this.getMessage("snkDataExporter.limitExceeded.description",{limit:t})}\n <br/><br/>\n <b>\n ${this.getMessage("snkDataExporter.limitExceeded.subdescription")}\n </b>\n `,cancel:this.getMessage("snkDataExporter.limitExceeded.cancel"),confirm:this.getMessage("snkDataExporter.limitExceeded.continue")};if(!await d.confirm(e.title,e.description,null,h.WARN,{labelCancel:e.cancel,labelConfirm:e.confirm}))return}if(u)return this.openPersonalizedReports(a.id),void(this._showDropdown=!1);this.getFilteredReleasedToExport().includes(null==a?void 0:a.id)&&(a.id===c.EXPORT_BY_EMAIL?this.exportByEmail():this.dispatchExporter(a.id),this._showDropdown=!1)}getFilteredReleasedToExport(){var t,e;if(null==this.provider)return this._releasedToExport;const i=null===(e=(t=this.provider).getHiddenOptions)||void 0===e?void 0:e.call(t);return null==i?this._releasedToExport:this._releasedToExport.filter((t=>!i.includes(t)))}loadItems(){const t=[];this.getFilteredReleasedToExport().forEach((e=>{var i;null===(i=this._itemBuilder)||void 0===i||i.setExportOption(e,t)})),this.loadPersonalizedItems(t)}async loadPersonalizedItems(t){var e,i;const s=null===(i=null===(e=this.provider)||void 0===e?void 0:e.getRecordID)||void 0===i?void 0:i.call(e);if(null==s)return void(this._items=t);const n=await function(t){const e=`${o.getContextValue("__SNK__APPLICATION__").getModuleName()}@DataExporterSPBean.getPersonalizedReports`,i={serviceName:e,requestBody:t};return new Promise(((t,s)=>v.get().callServiceBroker(e,r.objectToString(i)).then((e=>t(function(t){var e;const i=null===(e=null==t?void 0:t.json)||void 0===e?void 0:e.$;if(null!=i)return r.stringToObject(i)}(e)))).catch((t=>s(t)))))}({recordID:s});null==n||n.forEach((e=>{t.push({id:`${this._customPrefix}_${e.ID}`,label:e.label,group:this.getMessage("snkDataExporter.group.custom")})})),this._items=t}openPersonalizedReports(t){var e,i;const s=[],o=(null==t?void 0:t.replace(this._customPrefix,""))||"";null===(i=null===(e=this.provider)||void 0===e?void 0:e.getSelectedIDs)||void 0===i||i.call(e).forEach((({name:t,type:e,value:i},o)=>{const r={fields:[]};0===o&&(s[`PK_${t}`]={type:this.parseDataType(e),value:i},s.pks=[]);const n={nome:`PK_${t}`,tipo:this.parseDataType(e),valor:i};r.fields.push(n),s.pks.push(r)})),this._application.openApp(`${m}${o}`,s)}parseDataType(t){switch(t){case l.NUMBER:return"I";case l.DATE:return"D";default:return"S"}}loadDropdown(){var t;this._selectedNumber=(null===(t=this.provider)||void 0===t?void 0:t.getSelectedNumber())||0,this._itemBuilder=new f(this.getMessage.bind(this),this._selectedNumber),this.loadItems()}getElementID(t){return{[a.DATA_ELEMENT_ID_ATTRIBUTE_NAME]:a.getInternalIDInfo(t)}}canShowDropdown(){var t;return this._showDropdown&&(null===(t=this._items)||void 0===t?void 0:t.length)>0}componentWillLoad(){var t;this._application=o.getContextValue("__SNK__APPLICATION__"),null===(t=this._application)||void 0===t||t.getAppLabel().then((t=>this._appLabel=t)),this.setEvents()}componentDidLoad(){null!=this._element&&(a.addIDInfo(this._element),this.positionDropdown())}componentWillUpdate(){var t;this._showDropdown&&!(null===(t=this._items)||void 0===t?void 0:t.length)&&this.loadDropdown()}componentDidUpdate(){var t;this._showDropdown?this.positionDropdown():(null===(t=this._items)||void 0===t?void 0:t.length)>0&&(this._items=[])}render(){return e(i,null,e("div",{class:`snk-data-exporter\n ${this.canShowDropdown()?" ez-elevation--16":""}\n `},e("ez-button",Object.assign({ref:t=>this._ezButton=t,iconName:"file-download",size:"small",mode:"icon",title:this.getMessage("snkDataExporter.group.export.title"),onClick:()=>this.controlDropdown()},this.getElementID("button"))),e("div",Object.assign({ref:t=>this._dropdownParent=t,class:`snk-data-exporter__dropdown\n ${this.canShowDropdown()?"snk-data-exporter__dropdown--show":""}\n `},this.getElementID("dropdown")),this.canShowDropdown()&&e("ez-dropdown",Object.assign({items:this._items,onEzClick:t=>this.processExporter(t)},this.getElementID("dropdown"))))),this.canShowDropdown()&&e("div",Object.assign({class:"ez-scrim ez-scrim--light"},this.getElementID("ezScrim"))),e("snk-exporter-email-sender",Object.assign({ref:t=>this._snkEmailSender=t,getMessage:(t,e)=>this.getMessage(t,e)},this.getElementID("snkExporterEmailSender"))))}get _element(){return s(this)}};D.style=".sc-snk-data-exporter-h{display:flex;width:fit-content;height:fit-content}.snk-data-exporter.sc-snk-data-exporter{display:flex;width:fit-content;height:fit-content}.snk-data-exporter__dropdown.sc-snk-data-exporter{display:none}.snk-data-exporter__dropdown--show.sc-snk-data-exporter{display:flex;flex-direction:column;position:fixed}.snk-data-exporter__dropdown.sc-snk-data-exporter>ez-dropdown.sc-snk-data-exporter{position:relative}";export{D as snk_data_exporter}
|
1
|
+
import{r as t,h as e,H as i,g as s}from"./p-d2d301a6.js";import{ApplicationContext as o,ObjectUtils as r,UserInterface as n,DataType as l,ElementIDUtils as a}from"@sankhyalabs/core";import{ApplicationUtils as d,DialogType as h}from"@sankhyalabs/ezui/dist/collection/utils";import{D as c,a as p,b as u}from"./p-30cf616e.js";import{R as m}from"./p-b0ef4383.js";import{D as v}from"./p-594bc21d.js";import{S as x}from"./p-e8bd4c15.js";import"./p-25f1fc39.js";import"./p-21749402.js";import"@sankhyalabs/ezui/dist/collection/utils/constants";import"@sankhyalabs/core/dist/dataunit/metadata/UnitMetadata";import"./p-091ce761.js";import"./p-ff1990ad.js";import"./p-181975f1.js";import"./p-8d884fab.js";import"./p-7c4aabe2.js";import"@sankhyalabs/core/dist/dataunit/metadata/DataType";import"./p-7dd49d15.js";import"@sankhyalabs/ezui/dist/collection/components/ez-grid/utils";import"@sankhyalabs/core/dist/utils/SortingUtils";import"./p-688dcb4c.js";class f{constructor(t,e){this._selectedNumber=0,this._getMessage=t,this._selectedNumber=e}setExportOption(t,e){const i=this.getExportGroupName();t===c.EXPORT_TO_PDF&&e.push(this.getExportToPDF(i)),t===c.EXPORT_TO_XLS&&e.push(this.getExportToXLS(i)),this.setExportCurrentPage(t,e),this._selectedNumber>0&&this.setExportAllRecords(t,e),this.setExportByEmail(t,e)}setExportCurrentPage(t,e){var i;const s=[c.EXPORT_PAGE_TO_PDF,c.EXPORT_PAGE_TO_XLS];if(t===c.EXPORT_CURRENT_PAGE&&e.push(this.getCurrentPage()),s.includes(t)){let s=e.find((t=>t.id===c.EXPORT_CURRENT_PAGE));null==s&&(e.push(this.getCurrentPage()),s=e.find((t=>t.id===c.EXPORT_CURRENT_PAGE))),(null===(i=null==s?void 0:s.children)||void 0===i?void 0:i.length)||(s.children=[]),t===c.EXPORT_PAGE_TO_PDF&&s.children.push(this.getExportPageToPDF()),t===c.EXPORT_PAGE_TO_XLS&&s.children.push(this.getExportPageToXLS())}}setExportAllRecords(t,e){var i;const s=[c.EXPORT_ALL_RECORDS_TO_PDF,c.EXPORT_ALL_RECORDS_TO_XLS];if(t===c.EXPORT_ALL_RECORDS&&e.push(this.getAllRecords()),s.includes(t)){let s=e.find((t=>t.id===c.EXPORT_ALL_RECORDS));null==s&&(e.push(this.getAllRecords()),s=e.find((t=>t.id===c.EXPORT_ALL_RECORDS))),(null===(i=s.children)||void 0===i?void 0:i.length)||(s.children=[]),t===c.EXPORT_ALL_RECORDS_TO_PDF&&s.children.push(this.getExportAllRecordsToPDF()),t===c.EXPORT_ALL_RECORDS_TO_XLS&&s.children.push(this.getExportAllRecordsToXLS())}}setExportByEmail(t,e){t===c.EXPORT_BY_EMAIL&&e.push(this.getExportByEmail())}getExportToPDF(t){return{id:c.EXPORT_TO_PDF,label:"PDF (.pdf)",group:t}}getExportToXLS(t){return{id:c.EXPORT_TO_XLS,label:`${this._getMessage("snkDataExporter.label.spreadsheet")} (.xls)`,group:t}}getCurrentPage(){return{id:c.EXPORT_CURRENT_PAGE,label:this._getMessage("snkDataExporter.label.currentPage"),group:this._getMessage("snkDataExporter.group.custom")}}getAllRecords(){return{id:c.EXPORT_ALL_RECORDS,label:this._getMessage("snkDataExporter.label.allRecords"),group:this._getMessage("snkDataExporter.group.custom")}}getExportPageToPDF(){return{id:c.EXPORT_PAGE_TO_PDF,label:"PDF (.pdf)"}}getExportPageToXLS(){return{id:c.EXPORT_PAGE_TO_XLS,label:`${this._getMessage("snkDataExporter.label.spreadsheet")} (.xls)`}}getExportAllRecordsToPDF(){return{id:c.EXPORT_ALL_RECORDS_TO_PDF,label:"PDF (.pdf)"}}getExportAllRecordsToXLS(){return{id:c.EXPORT_ALL_RECORDS_TO_XLS,label:`${this._getMessage("snkDataExporter.label.spreadsheet")} (.xlsx)`}}getExportByEmail(){return{id:c.EXPORT_BY_EMAIL,label:`${this._getMessage("snkDataExporter.label.sendByEmail")}...`}}getExportGroupName(){return 1===this._selectedNumber?this._getMessage("snkDataExporter.group.export.selectedLine"):this._selectedNumber>1?this._getMessage("snkDataExporter.group.export.multiSelected").replace("{0}",this._selectedNumber.toString()):this._getMessage("snkDataExporter.group.export.default")}}function g(t){const e=[];let i=0;for(const s of t){if(i+=s.width,i>=800)break;e.push(s)}return e}function b(t){return Object.keys(c).find((e=>c[e]===t))}class E{constructor(t){this._provider=t}async getParsedColumns(){return g(await this._provider.getColumnsMetadata())}async getParams(t){var e,i,s,o,r,n;const l=null===(i=(e=this._provider).getFilters)||void 0===i?void 0:i.call(e),a=[p.EXPORT_TO_PDF,p.EXPORT_PAGE_TO_PDF,p.EXPORT_PDF_TO_EMAIL,p.EXPORT_ALL_RECORDS_TO_PDF].includes(b(null==t?void 0:t.exportOption))?await this.getParsedColumns():await this._provider.getColumnsMetadata(),d=null===(o=(s=this._provider).getOrders)||void 0===o?void 0:o.call(s),h=null===(n=(r=this._provider).getResourceURI)||void 0===n?void 0:n.call(r),u=this._provider.getSelectedIDs(),m=t.exportOption,v=[c.EXPORT_PAGE_TO_PDF,c.EXPORT_PAGE_TO_XLS];delete t.exportOption;let x=Object.assign({filters:l,columns:a,sort:d,resourceURI:h,selectedIDs:u.slice(0,this._provider.getExportLimit())},t);if(v.includes(m)||"page"==t.type){const t=this._provider.getOffset(),e=this._provider.getPageSize();x=Object.assign(Object.assign({},x),{offset:t,limit:e,selectedIDs:[]})}else"all"==t.type&&(x=Object.assign(Object.assign({},x),{offset:0,limit:this._provider.getExportLimit(),selectedIDs:[]}));return Promise.resolve(x)}async executeExport(t){const e=await this.getParams(t),{methodName:i}=e,s=function(t,e){var i={};for(var s in t)Object.prototype.hasOwnProperty.call(t,s)&&e.indexOf(s)<0&&(i[s]=t[s]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(s=Object.getOwnPropertySymbols(t);o<s.length;o++)e.indexOf(s[o])<0&&Object.prototype.propertyIsEnumerable.call(t,s[o])&&(i[s[o]]=t[s[o]])}return i}(e,["methodName"]),n=`${o.getContextValue("__SNK__APPLICATION__").getModuleName()}@DataExporterSPBean.${i}`,l={serviceName:n,requestBody:s};return new Promise(((t,e)=>{v.get().callServiceBroker(n,r.objectToString(l)).then((e=>t(this.getFormatResponse(e)))).catch((t=>e(t)))}))}getFormatResponse(t){var e;const i=null===(e=null==t?void 0:t.json)||void 0===e?void 0:e.$;if(null!=i)return r.stringToObject(i)}}class w{constructor(t){this._provider=t}async getParsedColumns(){return g(await this._provider.getColumnsMetadata())}async executeExport(t){const{methodName:e,titleGrid:i}=t,s=await this._provider.getRecords(),o=[p.EXPORT_TO_PDF,p.EXPORT_PAGE_TO_PDF,p.EXPORT_PDF_TO_EMAIL,p.EXPORT_ALL_RECORDS_TO_PDF].includes(b(null==t?void 0:t.exportOption))?await this.getParsedColumns():await this._provider.getColumnsMetadata(),[r,n]=this.getExecutor(e),l={serviceName:r,requestBody:{grid:{titleGrid:i,columns:this.buildColumnsObject(o),rows:this.buildRowsObject(o,s),customOptions:{xlsxExtension:!1}}}};return new Promise(((t,e)=>{v.get().callServiceBroker(r,l).then((e=>t(n(e)))).catch((t=>e(t)))}))}getExecutor(t){return"exportToPDF"===t?["GridPDFBuilderSP.buildPDFFromJson",t=>({fileSessionKey:t.chavePDF.valor,canPrint:"S"===t.permiteImprimir.valor,canExport:"S"===t.permiteExportar.valor,canSendEmail:"S"===t.canSendEmail.valor,useAppPrint:!0})]:["GridXLSBuilderSP.buildXLSFromJson",t=>({fileSessionKey:t.chaveXLS.valor,canPrint:!1,canExport:!1,useAppPrint:!1,canSendEmail:!1})]}buildColumnsObject(t){return{column:t.map(((t,e)=>{const{label:i,id:s,width:o,userInterface:r}=t;return Object.assign({index:e+1,id:s,label:i,width:o,presentationType:"P"},k[r]||{type:"S",align:"left"})}))}}buildRowsObject(t,e){return{row:e.map((e=>{const i={};return t.forEach(((t,s)=>i["c"+(s+1)]={$:this.formatValue(e,t)})),i}))}}formatValue(t,e){return null!=this._provider.formatValue?this._provider.formatValue(t,e):t[e.id]||""}}const k={[n.DATE]:{type:"D",align:"center"},[n.DATETIME]:{type:"H",align:"center"},[n.TIME]:{type:"I",align:"right"},[n.ELAPSEDTIME]:{type:"I",align:"right"},[n.DECIMALNUMBER]:{type:"F",align:"right"},[n.INTEGERNUMBER]:{type:"I",align:"right"},[n.SEARCH]:{type:"S",align:"right"}},D=class{constructor(e){t(this,e),this._selectedNumber=0,this._customPrefix="$custom$",this._releasedToExport=[c.EXPORT_TO_PDF,c.EXPORT_TO_XLS,c.EXPORT_BY_EMAIL,c.EXPORT_PDF_TO_EMAIL,c.EXPORT_XLS_TO_EMAIL,c.EXPORT_PAGE_TO_PDF,c.EXPORT_PAGE_TO_XLS,c.EXPORT_ALL_RECORDS_TO_PDF,c.EXPORT_ALL_RECORDS_TO_XLS],this._items=[],this._showDropdown=!1,this.provider=null,this.messagesBuilder=void 0}async exportByEmail(){const t=this._selectedNumber;this._snkEmailSender.open({type:t>0?"selection":"all",selectedRows:t,email:{attachments:[{name:this._appLabel}]},resolver:({type:t,format:e,email:{to:i,subject:s,message:o}})=>{var r;const n=null!==(r=u[null==e?void 0:e.toUpperCase()])&&void 0!==r?r:u.PDF;this.resolveExporter({type:t,methodName:n,to:i,subject:s,message:o,fileName:this._appLabel,titleGrid:this._appLabel},(()=>{this._snkEmailSender.close(),d.info(this.getMessage("snkDataExporter.message.emailSuccess"),{iconName:"check"})}))}})}getMessage(t,e){if(null==this.messagesBuilder){const t=x.getNearestInstance(this._element);t&&(this.messagesBuilder=t.messagesBuilder)}return this.messagesBuilder.getMessage(t,e)}positionDropdown(){var t;const e=null===(t=this._ezButton)||void 0===t?void 0:t.getBoundingClientRect();null!=e&&null!=this._dropdownParent&&(this._dropdownParent.style.top=e.y+e.height+5+"px",this._dropdownParent.style.left=e.x+"px")}closeDropdown(t){const e=null==t?void 0:t.target;null!=e&&(e.closest(".snk-data-exporter")||(this._showDropdown=!1))}setEvents(){document.removeEventListener("click",this.closeDropdown.bind(this)),document.addEventListener("click",this.closeDropdown.bind(this)),document.removeEventListener("scroll",this.positionDropdown.bind(this)),document.addEventListener("scroll",this.positionDropdown.bind(this))}controlDropdown(){this._showDropdown=!this._showDropdown}async resolveExporter(t,e){null!=this.provider&&null!=t&&null!=e&&this.getExporterStrategy().executeExport(t).then((t=>e(t))).catch((t=>{console.error(t);let{title:e,message:i,statusMessage:s}=t||{};d.error(e||this.getMessage("snkDataExporter.message.exportError"),s||i||this.getMessage("snkDataExporter.message.unknownFailure"))}))}getExporterStrategy(){return null==this.provider.getRecords?new E(this.provider):new w(this.provider)}getOptionKey(t){return Object.keys(c).find((e=>c[e]===t))}getExportType(t){return t===c.EXPORT_ALL_RECORDS_TO_PDF||t===c.EXPORT_ALL_RECORDS_TO_XLS?"all":t===c.EXPORT_PAGE_TO_PDF||t===c.EXPORT_PAGE_TO_XLS?"page":"selection"}async dispatchExporter(t){var e,i,s;const r=this.getOptionKey(t),n=null!==(e=p[r])&&void 0!==e?e:p.EXPORT_TO_PDF,l=p[r]===p.EXPORT_TO_XLS,a={methodName:c[`EXPORT_TO_${n}`],fileName:this._appLabel,titleGrid:this._appLabel,exportOption:t,limit:null===(s=null===(i=this.provider)||void 0===i?void 0:i.getExportLimit)||void 0===s?void 0:s.call(i),type:this.getExportType(t)};await this.resolveExporter(a,(t=>{t.canExport||n===p.EXPORT_TO_PDF?function({fileSessionKey:t,isDownload:e}){const i=o.getContextValue("__SNK__APPLICATION__");window.open(`${window.location.protocol}//${window.location.hostname}:${window.location.port}/mge/visualizadorArquivos.mge?chaveArquivo=${t}${e?"&download=S":""}`),d.info(function(t){var e;return null===(e=null==t?void 0:t.messagesBuilder)||void 0===e?void 0:e.getMessage("fileViewer.message.exportSuccess",void 0)}(i),{iconName:"check"})}(Object.assign(Object.assign({},t),{fileType:n,isDownload:l})):d.error(this.getMessage("snkDataExporter.title.permission"),this.getMessage("snkDataExporter.message.exportPermission"))}))}async processExporter(t){var e,i,s,o,r,n,l;const a=null==t?void 0:t.detail,p=[c.EXPORT_PAGE_TO_PDF,c.EXPORT_PAGE_TO_XLS],u=null===(e=null==a?void 0:a.id)||void 0===e?void 0:e.includes(this._customPrefix);if((null==a?void 0:a.id)===c.EXPORT_CURRENT_PAGE)return;const m=null===(i=this.provider)||void 0===i?void 0:i.getSelectedIDs(),v=null===(s=this.provider)||void 0===s?void 0:s.getTotalRecords(),x=null===(r=null===(o=this.provider)||void 0===o?void 0:o.getPageSize)||void 0===r?void 0:r.call(o),f=null===(l=null===(n=this.provider)||void 0===n?void 0:n.getExportLimit)||void 0===l?void 0:l.call(n);let g=!1;if(p.includes(null==a?void 0:a.id)&&x<=f||u?g=!1:(null==m?void 0:m.length)?g=m.length>f:v>f&&(g=!0),g){const t=f.toLocaleString("pt-BR",{minimumFractionDigits:0}),e={title:this.getMessage("snkDataExporter.limitExceeded.title"),description:`\n ${this.getMessage("snkDataExporter.limitExceeded.description",{limit:t})}\n <br/><br/>\n <b>\n ${this.getMessage("snkDataExporter.limitExceeded.subdescription")}\n </b>\n `,cancel:this.getMessage("snkDataExporter.limitExceeded.cancel"),confirm:this.getMessage("snkDataExporter.limitExceeded.continue")};if(!await d.confirm(e.title,e.description,null,h.WARN,{labelCancel:e.cancel,labelConfirm:e.confirm}))return}if(u)return this.openPersonalizedReports(a.id),void(this._showDropdown=!1);this.getFilteredReleasedToExport().includes(null==a?void 0:a.id)&&(a.id===c.EXPORT_BY_EMAIL?this.exportByEmail():this.dispatchExporter(a.id),this._showDropdown=!1)}getFilteredReleasedToExport(){var t,e;if(null==this.provider)return this._releasedToExport;const i=null===(e=(t=this.provider).getHiddenOptions)||void 0===e?void 0:e.call(t);return null==i?this._releasedToExport:this._releasedToExport.filter((t=>!i.includes(t)))}loadItems(){const t=[];this.getFilteredReleasedToExport().forEach((e=>{var i;null===(i=this._itemBuilder)||void 0===i||i.setExportOption(e,t)})),this.loadPersonalizedItems(t)}async loadPersonalizedItems(t){var e,i;const s=null===(i=null===(e=this.provider)||void 0===e?void 0:e.getRecordID)||void 0===i?void 0:i.call(e);if(null==s)return void(this._items=t);const n=await function(t){const e=`${o.getContextValue("__SNK__APPLICATION__").getModuleName()}@DataExporterSPBean.getPersonalizedReports`,i={serviceName:e,requestBody:t};return new Promise(((t,s)=>v.get().callServiceBroker(e,r.objectToString(i)).then((e=>t(function(t){var e;const i=null===(e=null==t?void 0:t.json)||void 0===e?void 0:e.$;if(null!=i)return r.stringToObject(i)}(e)))).catch((t=>s(t)))))}({recordID:s});null==n||n.forEach((e=>{t.push({id:`${this._customPrefix}_${e.ID}`,label:e.label,group:this.getMessage("snkDataExporter.group.custom")})})),this._items=t}openPersonalizedReports(t){var e,i;const s=[],o=(null==t?void 0:t.replace(this._customPrefix,""))||"";null===(i=null===(e=this.provider)||void 0===e?void 0:e.getSelectedIDs)||void 0===i||i.call(e).forEach((({name:t,type:e,value:i},o)=>{const r={fields:[]};0===o&&(s[`PK_${t}`]={type:this.parseDataType(e),value:i},s.pks=[]);const n={nome:`PK_${t}`,tipo:this.parseDataType(e),valor:i};r.fields.push(n),s.pks.push(r)})),this._application.openApp(`${m}${o}`,s)}parseDataType(t){switch(t){case l.NUMBER:return"I";case l.DATE:return"D";default:return"S"}}loadDropdown(){var t;this._selectedNumber=(null===(t=this.provider)||void 0===t?void 0:t.getSelectedNumber())||0,this._itemBuilder=new f(this.getMessage.bind(this),this._selectedNumber),this.loadItems()}getElementID(t){return{[a.DATA_ELEMENT_ID_ATTRIBUTE_NAME]:a.getInternalIDInfo(t)}}canShowDropdown(){var t;return this._showDropdown&&(null===(t=this._items)||void 0===t?void 0:t.length)>0}componentWillLoad(){var t;this._application=o.getContextValue("__SNK__APPLICATION__"),null===(t=this._application)||void 0===t||t.getAppLabel().then((t=>this._appLabel=t)),this.setEvents()}componentDidLoad(){null!=this._element&&(a.addIDInfo(this._element),this.positionDropdown())}componentWillUpdate(){var t;this._showDropdown&&!(null===(t=this._items)||void 0===t?void 0:t.length)&&this.loadDropdown()}componentDidUpdate(){var t;this._showDropdown?this.positionDropdown():(null===(t=this._items)||void 0===t?void 0:t.length)>0&&(this._items=[])}render(){return e(i,null,e("div",{class:`snk-data-exporter\n ${this.canShowDropdown()?" ez-elevation--16":""}\n `},e("ez-button",Object.assign({ref:t=>this._ezButton=t,iconName:"file-download",size:"small",mode:"icon",title:this.getMessage("snkDataExporter.group.export.title"),onClick:()=>this.controlDropdown()},this.getElementID("button"))),e("div",Object.assign({ref:t=>this._dropdownParent=t,class:`snk-data-exporter__dropdown\n ${this.canShowDropdown()?"snk-data-exporter__dropdown--show":""}\n `},this.getElementID("dropdown")),this.canShowDropdown()&&e("ez-dropdown",Object.assign({items:this._items,onEzClick:t=>this.processExporter(t)},this.getElementID("dropdown"))))),this.canShowDropdown()&&e("div",Object.assign({class:"ez-scrim ez-scrim--light"},this.getElementID("ezScrim"))),e("snk-exporter-email-sender",Object.assign({ref:t=>this._snkEmailSender=t,getMessage:(t,e)=>this.getMessage(t,e)},this.getElementID("snkExporterEmailSender"))))}get _element(){return s(this)}};D.style=".sc-snk-data-exporter-h{display:flex;width:fit-content;height:fit-content}.snk-data-exporter.sc-snk-data-exporter{display:flex;width:fit-content;height:fit-content}.snk-data-exporter__dropdown.sc-snk-data-exporter{display:none}.snk-data-exporter__dropdown--show.sc-snk-data-exporter{display:flex;flex-direction:column;position:fixed}.snk-data-exporter__dropdown.sc-snk-data-exporter>ez-dropdown.sc-snk-data-exporter{position:relative}";export{D as snk_data_exporter}
|
@@ -1 +1 @@
|
|
1
|
-
import{r as t,c as i,f as s,h as e,H as a}from"./p-d2d301a6.js";import{Action as o}from"@sankhyalabs/core";import{S as h}from"./p-5f016aed.js";import{FormMetadata as n,buildFormMetadata as r}from"@sankhyalabs/ezui/dist/collection/utils/form";import"./p-594bc21d.js";import"./p-25f1fc39.js";import{P as d}from"./p-30cf616e.js";import"./p-21749402.js";import"@sankhyalabs/ezui/dist/collection/utils/constants";import"@sankhyalabs/core/dist/dataunit/metadata/UnitMetadata";import"./p-091ce761.js";import"./p-ff1990ad.js";import"./p-181975f1.js";import{T as l}from"./p-7e7a7473.js";import{d as c}from"./p-b0ef4383.js";import{S as m}from"./p-1f35c795.js";import{S as u}from"./p-7c4aabe2.js";import"./p-3287a6cc.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-6dc031de.js";import"./p-c2495304.js";import"@sankhyalabs/core/dist/dataunit/DataUnit";class v{constructor(t,i,s){this._parentGuide=t,this._formMetadata=i,this._dataUnit=s}get id(){return this._parentGuide.id}buildGuideItem(t){const i=Object.assign({},this._parentGuide);delete i.expanded,delete i.children;const s=this._dataUnit.getSelectedRecord();if(!s)return i;const e=this._dataUnit.isNewRecord(s.__record__id__),a=Array.from(this._formMetadata.getAllSheets().values()).map((i=>{const{name:s,label:a}=i,o=null!=n.getDetailName(s.split("::").pop()),h=o&&e,r=this._parentGuide.id,d=o?`${r}::${s}`:`${r}__FORM:${s}`;return o&&t.has(d)&&!h?t.get(d).buildGuideItem(t):{id:d,label:a,disabled:h,tooltip:h?"Finalize o cadastro para ter acesso a esta guia.":void 0}})),o=a.shift();return o.label=e?"Novo Registro":s.__record__label__,o.children=a,i.children=[o],i}}const p=class{constructor(s){t(this,s),this.snkDetailGuidesChange=i(this,"snkDetailGuidesChange",7),this.snkSwitchGuide=i(this,"snkSwitchGuide",7),this.formItemsReady=i(this,"formItemsReady",7),this._disabledButtons=void 0,this._currentView=void 0,this.attachmentRegisterKey=void 0,this.formConfigManager=void 0,this.dataUnitName=void 0,this.resourceID=void 0,this.guideItemPath=void 0,this.entityName=void 0,this.label=void 0,this.dataUnit=void 0,this.selectedForm=void 0,this.dataState=void 0,this.messagesBuilder=void 0,this.branchGuide=void 0,this.canEdit=!0,this.taskbarCustomContainerId=void 0,this.customEditors=void 0,this.customRenders=void 0}observeDataUnit(t,i){null==t||t.subscribe(this.dataUnitActionHandler.bind(this)),null==i||i.unsubscribe(this.dataUnitActionHandler)}observerDataState(t,i){const s=!(null==i?void 0:i.insertionMode)&&(null==t?void 0:t.insertionMode),e=(null==i?void 0:i.insertionMode)&&!(null==t?void 0:t.insertionMode);if((s||e)&&this.loadMetadata(),null==this._formMetadata)return;const a=null==t?void 0:t.selectedRecord,o=null==i?void 0:i.selectedRecord;(null==a?void 0:a.__record__id__)!==(null==o?void 0:o.__record__id__)&&this.snkDetailGuidesChange.emit(new v(this.branchGuide,this._formMetadata,this.dataUnit)),s&&setTimeout((()=>{this.changeViewMode(c.FORM)}),0),e&&this.changeViewMode(c.GRID);const h=[];this.dataState.hasPrevious||h.push(l.PREVIOUS),this.dataState.hasNext||h.push(l.NEXT),this.dataState.insertionMode&&h.push(l.INSERT),this._disabledButtons=h}async changeViewMode(t){this.emitSwitchEvent(t)}async configGrid(){this._snkGrid&&this._snkGrid.showConfig()}async showUp(){this._snkFormView&&this._snkFormView.showUp(),this._snkGrid&&this._snkGrid.scrollIntoView({behavior:"smooth",block:"start"})}async addCustomEditor(t,i){var s;const e=this.normalizeBranchGuideId(null===(s=this.branchGuide)||void 0===s?void 0:s.id);this._snkGrid.addCustomEditor(t,i,e),this._snkFormView.addCustomEditor(t,i,e)}async observerPropsCustomEditor(t){for(const i in t)await this.addCustomEditor(i,t[i])}async addGridCustomRender(t,i){var s;const e=this.normalizeBranchGuideId(null===(s=this.branchGuide)||void 0===s?void 0:s.id);await this._snkGrid.addGridCustomRender(t,i,e)}onContentCardChanged(t){m.updateContentCard(t.detail.formName,t.detail.cardConfig,t.detail.propertyChanged,this.formConfigManager).then((()=>s(this))),t.stopPropagation()}async observeCustomRenders(t){for(const i in t){const s=t[i];await this.addGridCustomRender(i,s)}}updateLabel(){const t=this.guideItemPath?this.guideItemPath.length:0;if(t>0){const i=t>0?this.guideItemPath.map((t=>t.label)):void 0;this.label=i.pop(),this._levelPath=i.length>0?i.join(" / "):void 0}else this.label="",this._levelPath=void 0}getFormGuideId(t){var i;if(!t){if(null==(null===(i=this.dataState)||void 0===i?void 0:i.selectedRecord))return;const s=Array.from(this._formMetadata.getAllSheets().keys());if(!s||0==s.length)return;t=s[0]}return`${this.stripFormPattern(this.branchGuide.id)}__FORM:${t}`}stripFormPattern(t){return t.replace(p.REGEX_FORM_ID,"")}loadMetadata(){if(!this.dataUnit)return;if(!this.formConfigManager.isLoaded)return;const t=this.formConfigManager.getConfig(this.dataUnit);this._formMetadata=r(null==t||0===t.fields.length?void 0:t,this.dataUnit,!0)}dataUnitReadyHandler(t){this.dataUnit=t.detail,this.loadMetadata()}updateViewStack(t){var i,s;this._viewStack=t,this._currentView=this.selectedForm?1:0,null===(s=null===(i=this._viewStack)||void 0===i?void 0:i.show)||void 0===s||s.call(i,this._currentView)}getFormFields(){return this.selectedForm&&this._formMetadata?this._formMetadata.getSheet(this.selectedForm).fields:[]}emitSwitchEvent(t){const i=t===c.GRID?this.stripFormPattern(this.branchGuide.id):this.getFormGuideId();i&&this.snkSwitchGuide.emit(i)}handleAttachBack(){this._viewStack.show(c.GRID)}executeActionHandler(t){t.detail===l.GRID_MODE&&(this.emitSwitchEvent(c.GRID),t.stopPropagation()),t.detail
|
1
|
+
import{r as t,c as i,f as s,h as e,H as a}from"./p-d2d301a6.js";import{Action as o}from"@sankhyalabs/core";import{S as h}from"./p-5f016aed.js";import{FormMetadata as n,buildFormMetadata as r}from"@sankhyalabs/ezui/dist/collection/utils/form";import"./p-594bc21d.js";import"./p-25f1fc39.js";import{P as d}from"./p-30cf616e.js";import"./p-21749402.js";import"@sankhyalabs/ezui/dist/collection/utils/constants";import"@sankhyalabs/core/dist/dataunit/metadata/UnitMetadata";import"./p-091ce761.js";import"./p-ff1990ad.js";import"./p-181975f1.js";import{T as l}from"./p-7e7a7473.js";import{d as c}from"./p-b0ef4383.js";import{S as m}from"./p-1f35c795.js";import{S as u}from"./p-7c4aabe2.js";import"./p-3287a6cc.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-6dc031de.js";import"./p-c2495304.js";import"@sankhyalabs/core/dist/dataunit/DataUnit";class v{constructor(t,i,s){this._parentGuide=t,this._formMetadata=i,this._dataUnit=s}get id(){return this._parentGuide.id}buildGuideItem(t){const i=Object.assign({},this._parentGuide);delete i.expanded,delete i.children;const s=this._dataUnit.getSelectedRecord();if(!s)return i;const e=this._dataUnit.isNewRecord(s.__record__id__),a=Array.from(this._formMetadata.getAllSheets().values()).map((i=>{const{name:s,label:a}=i,o=null!=n.getDetailName(s.split("::").pop()),h=o&&e,r=this._parentGuide.id,d=o?`${r}::${s}`:`${r}__FORM:${s}`;return o&&t.has(d)&&!h?t.get(d).buildGuideItem(t):{id:d,label:a,disabled:h,tooltip:h?"Finalize o cadastro para ter acesso a esta guia.":void 0}})),o=a.shift();return o.label=e?"Novo Registro":s.__record__label__,o.children=a,i.children=[o],i}}const p=class{constructor(s){t(this,s),this.snkDetailGuidesChange=i(this,"snkDetailGuidesChange",7),this.snkSwitchGuide=i(this,"snkSwitchGuide",7),this.formItemsReady=i(this,"formItemsReady",7),this._disabledButtons=void 0,this._currentView=void 0,this.attachmentRegisterKey=void 0,this.formConfigManager=void 0,this.dataUnitName=void 0,this.resourceID=void 0,this.guideItemPath=void 0,this.entityName=void 0,this.label=void 0,this.dataUnit=void 0,this.selectedForm=void 0,this.dataState=void 0,this.messagesBuilder=void 0,this.branchGuide=void 0,this.canEdit=!0,this.taskbarCustomContainerId=void 0,this.customEditors=void 0,this.customRenders=void 0}observeDataUnit(t,i){null==t||t.subscribe(this.dataUnitActionHandler.bind(this)),null==i||i.unsubscribe(this.dataUnitActionHandler)}observerDataState(t,i){const s=!(null==i?void 0:i.insertionMode)&&(null==t?void 0:t.insertionMode),e=(null==i?void 0:i.insertionMode)&&!(null==t?void 0:t.insertionMode);if((s||e)&&this.loadMetadata(),null==this._formMetadata)return;const a=null==t?void 0:t.selectedRecord,o=null==i?void 0:i.selectedRecord;(null==a?void 0:a.__record__id__)!==(null==o?void 0:o.__record__id__)&&this.snkDetailGuidesChange.emit(new v(this.branchGuide,this._formMetadata,this.dataUnit)),s&&setTimeout((()=>{this.changeViewMode(c.FORM)}),0),e&&this.changeViewMode(c.GRID);const h=[];this.dataState.hasPrevious||h.push(l.PREVIOUS),this.dataState.hasNext||h.push(l.NEXT),this.dataState.insertionMode&&h.push(l.INSERT),this._disabledButtons=h}async changeViewMode(t){this.emitSwitchEvent(t)}async configGrid(){this._snkGrid&&this._snkGrid.showConfig()}async showUp(){this._snkFormView&&this._snkFormView.showUp(),this._snkGrid&&this._snkGrid.scrollIntoView({behavior:"smooth",block:"start"})}async addCustomEditor(t,i){var s;const e=this.normalizeBranchGuideId(null===(s=this.branchGuide)||void 0===s?void 0:s.id);this._snkGrid.addCustomEditor(t,i,e),this._snkFormView.addCustomEditor(t,i,e)}async observerPropsCustomEditor(t){for(const i in t)await this.addCustomEditor(i,t[i])}async addGridCustomRender(t,i){var s;const e=this.normalizeBranchGuideId(null===(s=this.branchGuide)||void 0===s?void 0:s.id);await this._snkGrid.addGridCustomRender(t,i,e)}onContentCardChanged(t){m.updateContentCard(t.detail.formName,t.detail.cardConfig,t.detail.propertyChanged,this.formConfigManager).then((()=>s(this))),t.stopPropagation()}async observeCustomRenders(t){for(const i in t){const s=t[i];await this.addGridCustomRender(i,s)}}updateLabel(){const t=this.guideItemPath?this.guideItemPath.length:0;if(t>0){const i=t>0?this.guideItemPath.map((t=>t.label)):void 0;this.label=i.pop(),this._levelPath=i.length>0?i.join(" / "):void 0}else this.label="",this._levelPath=void 0}getFormGuideId(t){var i;if(!t){if(null==(null===(i=this.dataState)||void 0===i?void 0:i.selectedRecord))return;const s=Array.from(this._formMetadata.getAllSheets().keys());if(!s||0==s.length)return;t=s[0]}return`${this.stripFormPattern(this.branchGuide.id)}__FORM:${t}`}stripFormPattern(t){return t.replace(p.REGEX_FORM_ID,"")}loadMetadata(){if(!this.dataUnit)return;if(!this.formConfigManager.isLoaded)return;const t=this.formConfigManager.getConfig(this.dataUnit);this._formMetadata=r(null==t||0===t.fields.length?void 0:t,this.dataUnit,!0)}dataUnitReadyHandler(t){this.dataUnit=t.detail,this.loadMetadata()}updateViewStack(t){var i,s;this._viewStack=t,this._currentView=this.selectedForm?1:0,null===(s=null===(i=this._viewStack)||void 0===i?void 0:i.show)||void 0===s||s.call(i,this._currentView)}getFormFields(){return this.selectedForm&&this._formMetadata?this._formMetadata.getSheet(this.selectedForm).fields:[]}emitSwitchEvent(t){const i=t===c.GRID?this.stripFormPattern(this.branchGuide.id):this.getFormGuideId();i&&this.snkSwitchGuide.emit(i)}handleAttachBack(){this._viewStack.show(c.GRID)}executeActionHandler(t){t.detail===l.GRID_MODE&&(this.emitSwitchEvent(c.GRID),t.stopPropagation()),t.detail!==l.FORM_MODE&&t.detail!==l.UPDATE||(this.emitSwitchEvent(c.FORM),t.stopPropagation()),t.detail===l.ATTACH&&(this._viewStack.show(c.ATTACHMENT),t.stopPropagation())}async getAttachmentRegisterKey(){if(this._snkDataUnit)return(await this._snkDataUnit.getSelectedRecordsIDsInfo()).map((({value:t})=>t)).join("_")}async handleDataStateChange({detail:t}){this.dataState=t,void 0!==t.selectedRecord&&this._snkDataUnit&&(this.attachmentRegisterKey=await this.getAttachmentRegisterKey())}componentWillLoad(){this._configName=`dynaform.${this.entityName}`,this.formConfigManager=new h(this._configName,this.resourceID,(()=>this.loadMetadata())),this.formConfigManager.loadConfig(),null==this.messagesBuilder&&(this.messagesBuilder=new u(this.entityName))}async componentDidLoad(){await this.observerPropsCustomEditor(this.customEditors),await this.observeCustomRenders(this.customRenders)}async dataUnitActionHandler(t){t.type===o.FIELD_INVALIDATED&&this.addErrorBadgeToBranchGuide()}addErrorBadgeToBranchGuide(){this.branchGuide=Object.assign(Object.assign({},this.branchGuide),{badge:"error"}),this.snkDetailGuidesChange.emit(new v(this.branchGuide,this._formMetadata,this.dataUnit))}normalizeBranchGuideId(t){return null==t?void 0:t.replace(/child\[(.*?)\]/g,"$1").replace(/::/g,">")}render(){return this.updateLabel(),e(a,null,e("snk-data-unit",{ref:t=>this._snkDataUnit=t,dataUnitName:`${this.dataUnitName}`,onDataUnitReady:t=>this.dataUnitReadyHandler(t),entityName:this.entityName,onDataStateChange:this.handleDataStateChange.bind(this),ignoreSaveMessage:this._currentView===c.GRID,messagesBuilder:this.messagesBuilder,configName:this._configName},e("ez-view-stack",{ref:t=>this.updateViewStack(t)},e("stack-item",null,e("div",{class:"ez-box ez-box--shadow grid-container"},e("div",{class:"ez-flex ez-title--primary ez-size-width--full ez-padding--large detail-header"},e("div",{class:"ez-flex ez-text ez-text--bold ez-flex--justify-start ez-flex--align-items-center"},this._levelPath?e("span",{class:"level-path"},this._levelPath+" /"):void 0,this.label)),e("snk-grid",{class:"ez-size-width--full ez-size-height--full",ref:t=>this._snkGrid=t,configName:this._configName,messagesBuilder:this.messagesBuilder,onGridDoubleClick:()=>this.emitSwitchEvent(c.FORM),onActionClick:t=>this.executeActionHandler(t),presentationMode:d.SECONDARY,canEdit:this.canEdit,isDetail:!0,taskbarCustomContainerId:this.taskbarCustomContainerId,gridHeaderCustomSlotId:"DETAIL_GRID_HEADER_CUSTOM_ELEMENTS",topTaskbarCustomSlotId:"DETAIL_GRID_TASKBAR_CUSTOM_ELEMENTS"}))),e("stack-item",null,e("snk-form-view",{ref:t=>this._snkFormView=t,canExpand:!1,canFix:!1,name:this.selectedForm,formMetadata:this._formMetadata,dataUnit:this.dataUnit,fields:this.getFormFields(),label:this.label,levelPath:this._levelPath,onFormItemsReady:({detail:t})=>this.formItemsReady.emit(t)},e("snk-taskbar",{key:"guideViewerTaskbar",class:"form-taskbar","data-element-id":"guideViewer",configName:this._configName,messagesBuilder:this.messagesBuilder,disabledButtons:this._disabledButtons,buttons:"INSERT,PREVIOUS,NEXT,DIVIDER,CLONE,REMOVE,MORE_OPTIONS,DIVIDER,GRID_MODE,CONFIGURATOR",primaryButton:"INSERT",presentationMode:d.SECONDARY,onActionClick:t=>this.executeActionHandler(t),dataUnit:this.dataUnit,resourceID:this.resourceID,customContainerId:this.taskbarCustomContainerId,customSlotId:"DETAIL_TASKBAR_CUSTOM_ELEMENTS"},e("slot",{name:"DETAIL_TASKBAR_CUSTOM_ELEMENTS"})))),e("stack-item",null,e("snk-attach",{registerKey:this.attachmentRegisterKey,messagesBuilder:this.messagesBuilder,entityName:this.entityName,onBack:this.handleAttachBack.bind(this)})))))}static get watchers(){return{dataUnit:["observeDataUnit"],dataState:["observerDataState"],customEditors:["observerPropsCustomEditor"],customRenders:["observeCustomRenders"]}}};p.REGEX_FORM_ID=/__FORM:[^:]+/g,p.style=".sc-snk-detail-view-h{display:flex;row-gap:24px;flex-direction:column;width:100%;height:100%}.level-path.sc-snk-detail-view{color:var(--color--title-primary, #2B3A54);font-weight:var(--text-weight--medium, 400);padding-right:3px}.form-taskbar.sc-snk-detail-view{padding-bottom:var(--space--medium)}.grid-container.sc-snk-detail-view{background-color:#FFF;min-height:100px}.detail-header.sc-snk-detail-view{padding-bottom:0}";export{p as snk_detail_view}
|
@@ -1 +1 @@
|
|
1
|
-
import{p as e,b as t}from"./p-d2d301a6.js";export{s as setNonce}from"./p-d2d301a6.js";(()=>{const t=import.meta.url,a={};return""!==t&&(a.resourcesUrl=new URL(".",t).href),e(a)})().then((e=>t(JSON.parse('[["p-118e769b",[[1,"teste-pesquisa"]]],["p-70a4af56",[[0,"snk-filter-modal",{"getMessage":[16],"configName":[1025,"config-name"],"filters":[1040],"applyFilters":[16],"closeModal":[16],"addPersonalizedFilter":[16],"editPersonalizedFilter":[16],"deletePersonalizedFilter":[16],"filtersToDelete":[16],"disablePersonalizedFilter":[4,"disable-personalized-filter"]},[[0,"deleteFilter","deletePersonalizedFilterListener"]]]]],["p-ac8d1cd6",[[2,"snk-actions-form",{"action":[16],"applyParameters":[16],"dataUnit":[32],"openPopup":[64]}]]],["p-9531fd46",[[2,"snk-client-confirm",{"titleMessage":[1,"title-message"],"message":[1],"accept":[16],"cancel":[16],"openPopup":[64]}]]],["p-21a81901",[[6,"snk-custom-slot-elements",{"slotName":[1,"slot-name"]}]]],["p-33718dfc",[[2,"snk-entity-list",{"config":[1040],"rightListSlotBuilder":[1040],"maxHeightList":[1,"max-height-list"],"_searchValue":[32],"_ezListSource":[32],"reloadList":[64]}]]],["p-41f8bfa3",[[0,"snk-filter-binary-select",{"value":[1544],"config":[16],"presentationMode":[2,"presentation-mode"],"resetValues":[64]},[[0,"ezChange","ezChangeListener"]]]]],["p-aaa3ee68",[[0,"snk-filter-checkbox-list",{"config":[1040],"optionsList":[32]}]]],["p-d3f53df2",[[4,"snk-filter-list",{"label":[1],"iconName":[1,"icon-name"],"items":[16],"getMessage":[16],"emptyText":[1,"empty-text"],"findFilterText":[1,"find-filter-text"],"buttonClass":[1,"button-class"],"_filterArgument":[32],"_showAll":[32],"hideDetail":[64]},[[2,"keydown","keyDownHandler"]]]]],["p-bf2acf72",[[0,"snk-filter-multi-select",{"value":[1544],"config":[16],"show":[64]},[[0,"ezChange","ezChangeListener"]]]]],["p-01ba23cd",[[0,"snk-filter-number",{"config":[16],"getMessage":[16],"value":[2],"presentationMode":[2,"presentation-mode"],"show":[64]},[[0,"ezChange","ezChangeListener"]]]]],["p-7e2ded86",[[0,"snk-filter-period",{"config":[16],"getMessage":[16],"value":[8],"presentationMode":[2,"presentation-mode"],"show":[64]},[[0,"ezChange","ezChangeListener"]]]]],["p-c8622597",[[0,"snk-filter-search",{"config":[16],"value":[16],"show":[64]},[[0,"ezChange","ezChangeListener"]]]]],["p-96a89d58",[[0,"snk-filter-text",{"config":[16],"value":[1]},[[0,"ezChange","ezChangeListener"]]]]],["p-b11aa1e0",[[2,"snk-personalized-filter-editor",{"messagesBuilder":[1040],"presentationMode":[2,"presentation-mode"],"config":[16],"value":[1040],"items":[32],"show":[64]}]]],["p-72fc257b",[[2,"snk-print-selector",{"_printServerActive":[32],"_selectedPrinter":[32],"_remotePrintersDataSource":[32],"_localPrintersDataSource":[32],"_printJobData":[32],"openPrintSelector":[64]}]]],["p-9dfda04a",[[0,"snk-filter-modal-item",{"filterItem":[1040],"configName":[1025,"config-name"],"resourceID":[1,"resource-i-d"]}]]],["p-d1791da2",[[2,"snk-pesquisa",{"searchLoader":[16],"selectItem":[16],"argument":[1025],"_itemList":[32],"_startLoading":[32]}]]],["p-684a2590",[[6,"snk-simple-crud",{"dataState":[16],"dataUnit":[16],"entityName":[1,"entity-name"],"mode":[2],"gridConfig":[1040],"formConfig":[1040],"multipleSelection":[4,"multiple-selection"],"useCancelConfirm":[4,"use-cancel-confirm"],"pageSize":[2,"page-size"],"resourceID":[1,"resource-i-d"],"taskbarManager":[16],"messagesBuilder":[1040],"useEnterLikeTab":[4,"use-enter-like-tab"],"actionsList":[16],"configName":[1025,"config-name"],"showConfiguratorButtons":[4,"show-configurator-buttons"],"gridLegacyConfigName":[1,"grid-legacy-config-name"],"formLegacyConfigName":[1,"form-legacy-config-name"],"ignoreReadOnlyFormFields":[4,"ignore-read-only-form-fields"],"autoFocus":[4,"auto-focus"],"domainMessagesBuilder":[1,"domain-messages-builder"],"autoLoad":[4,"auto-load"],"_showPopUpGridConfig":[32],"_showFormConfig":[32],"_currentViewMode":[32],"_config":[32],"_fieldToGetFocus":[32],"_customContainerId":[32],"_formFields":[32],"_fieldsProps":[32],"addCustomEditor":[64],"addGridCustomRender":[64],"addCustomValueFormatter":[64],"removeCustomValueFormatter":[64],"setFieldProp":[64],"goToView":[64],"setMetadata":[64],"setRecords":[64],"getRecords":[64],"openConfigurator":[64],"closeConfigurator":[64],"updateConfig":[64]},[[0,"actionClick","actionClickListener"]]]]],["p-42f7b05d",[[2,"snk-attach",{"fetcherType":[1,"fetcher-type"],"fetcher":[16],"dataUnit":[16],"dataUnitBuilder":[16],"registerKey":[1,"register-key"],"entityName":[1,"entity-name"],"messagesBuilder":[1040],"_currentFetcher":[32],"_currentDataUnit":[32],"crudConfig":[32]}]]],["p-26b0ce3e",[[2,"snk-form-summary",{"fixed":[1540],"contracted":[1540],"summary":[16]}]]],["p-1db45d26",[[6,"snk-form-view",{"levelPath":[1,"level-path"],"label":[1],"name":[1],"fields":[16],"formMetadata":[8,"form-metadata"],"dataUnit":[16],"contracted":[4],"fixed":[1540],"summaryFields":[16],"canExpand":[4,"can-expand"],"canFix":[4,"can-fix"],"recordsValidator":[16],"fieldToFocus":[1,"field-to-focus"],"customEditors":[16],"fieldsProps":[16],"showUp":[64],"addCustomEditor":[64],"setFieldProp":[64]}]]],["p-8002dcd0",[[2,"snk-filter-field-search",{"searchable":[4],"fieldsDataSource":[16],"breadcrumbItems":[32],"linkItems":[32],"fieldItems":[32],"searchEmpty":[32],"groupEmpty":[32],"show":[64],"applyFilter":[64]}],[0,"snk-filter-param-config",{"messagesBuilder":[1040],"_opened":[32],"_configType":[32],"_expressionItem":[32],"_informedInstance":[32],"_canSave":[32],"open":[64],"close":[64]}]]],["p-9d3a025a",[[2,"snk-expression-group",{"parentTop":[1026,"parent-top"],"group":[1040],"messagesBuilder":[1040],"filterId":[1025,"filter-id"],"entityURI":[1025,"entity-u-r-i"],"_conditionOperator":[32],"_group":[32],"_selfTop":[32],"canAddExpression":[32],"_showDashes":[32],"getExpressionGroup":[64]},[[8,"ezExpressionLayoutChanged","todoCompletedHandler"]]],[2,"snk-expression-item",{"expression":[16],"canRemove":[516,"can-remove"],"messagesBuilder":[1040],"entityURI":[1025,"entity-u-r-i"],"_showValueVariable":[32],"_fieldSelected":[32],"_optionNotNull":[32]}]]],["p-bd008859",[[2,"snk-personalized-filter",{"messagesBuilder":[1040],"entityUri":[1025,"entity-uri"],"filterId":[1025,"filter-id"],"configName":[1025,"config-name"],"resourceID":[1,"resource-i-d"],"_filterAssistentMode":[32],"_filterAssistent":[32],"createPersonalizedFilter":[64]}]]],["p-e8763234",[[0,"snk-filter-item",{"config":[1040],"getMessage":[16],"showChips":[4,"show-chips"],"detailIsVisible":[32],"showUp":[64],"hideDetail":[64]},[[2,"click","clickListener"],[2,"mousedown","mouseDownListener"],[0,"filterChange","filterChangeListener"]]]]],["p-5b26cc7c",[[2,"snk-filter-bar",{"dataUnit":[1040],"title":[1],"configName":[1,"config-name"],"resourceID":[1,"resource-i-d"],"mode":[1],"filterConfig":[1040],"messagesBuilder":[1040],"disablePersonalizedFilter":[4,"disable-personalized-filter"],"filterBarLegacyConfigName":[1,"filter-bar-legacy-config-name"],"autoLoad":[4,"auto-load"],"allowDefault":[32],"scrollerLocked":[32],"showPersonalizedFilter":[32],"personalizedFilterId":[32],"reload":[64],"getFilterItem":[64],"updateFilterItem":[64],"addFilterItem":[64],"removeFilterItem":[64],"showFilterModal":[64]},[[0,"filterChange","filterChangeListener"]]]]],["p-53eb35c1",[[6,"snk-grid",{"columnFilterDataSource":[1040],"configName":[1,"config-name"],"filterBarTitle":[1,"filter-bar-title"],"resourceID":[1,"resource-i-d"],"selectionToastConfig":[16],"actionsList":[16],"isDetail":[4,"is-detail"],"taskbarManager":[16],"statusResolver":[16],"multipleSelection":[4,"multiple-selection"],"presentationMode":[1,"presentation-mode"],"messagesBuilder":[1040],"useEnterLikeTab":[4,"use-enter-like-tab"],"recordsValidator":[16],"canEdit":[4,"can-edit"],"taskbarCustomContainerId":[1,"taskbar-custom-container-id"],"gridHeaderCustomSlotId":[1,"grid-header-custom-slot-id"],"topTaskbarCustomSlotId":[1,"top-taskbar-custom-slot-id"],"disablePersonalizedFilter":[4,"disable-personalized-filter"],"gridLegacyConfigName":[1,"grid-legacy-config-name"],"filterBarLegacyConfigName":[1,"filter-bar-legacy-config-name"],"autoLoad":[4,"auto-load"],"autoFocus":[4,"auto-focus"],"_dataUnit":[32],"_dataState":[32],"_gridConfig":[32],"_popUpGridConfig":[32],"_showSnkFilterBar":[32],"showConfig":[64],"hideConfig":[64],"setConfig":[64],"reloadFilterBar":[64],"getFilterBar":[64],"findColumn":[64],"addCustomEditor":[64],"addGridCustomRender":[64],"addCustomValueFormatter":[64],"removeCustomValueFormatter":[64],"setFocus":[64]}]]],["p-7663f597",[[2,"snk-configurator",{"showActionButtons":[4,"show-action-buttons"],"configName":[1,"config-name"],"resourceID":[1,"resource-i-d"],"viewMode":[2,"view-mode"],"customContainerId":[1,"custom-container-id"],"messagesBuilder":[1040],"_opened":[32],"_permissions":[32],"open":[64],"close":[64]}]]],["p-89451692",[[2,"snk-data-unit",{"dataState":[1040],"messagesBuilder":[1040],"dataUnitName":[1,"data-unit-name"],"entityName":[1,"entity-name"],"pageSize":[2,"page-size"],"dataUnit":[1040],"beforeSave":[16],"afterSave":[16],"useCancelConfirm":[4,"use-cancel-confirm"],"ignoreSaveMessage":[4,"ignore-save-message"],"configName":[1,"config-name"],"resourceID":[1,"resource-i-d"],"domainMessagesBuilder":[1,"domain-messages-builder"],"fieldsToLink":[32],"getDataUnit":[64],"getSelectedRecordsIDsInfo":[64],"getFieldsWithRmp":[64],"getFieldsWithRmPrecision":[64],"getRowMetadata":[64]}]]],["p-f2809746",[[6,"snk-taskbar",{"alignRigth":[4,"align-rigth"],"customSlotId":[1,"custom-slot-id"],"customContainerId":[1,"custom-container-id"],"overflowStrategy":[1,"overflow-strategy"],"configName":[1,"config-name"],"resourceID":[1,"resource-i-d"],"buttons":[1],"customButtons":[16],"actionsList":[16],"primaryButton":[1,"primary-button"],"disabledButtons":[16],"dataUnit":[16],"presentationMode":[1537,"presentation-mode"],"messagesBuilder":[1040],"_permissions":[32],"_overFlowedElements":[32],"_customElements":[32],"_customElementsId":[32],"_slotContainer":[32],"_hiddenActionsList":[32],"_lastWidth":[32],"_hasToUpdateOverFlow":[32],"_isWaitingForSave":[32]},[[8,"snkCustomSlotElementsLoaded","handleCustomSlotElementsLoaded"]]]]],["p-54a5d52a",[[0,"snk-filter-detail",{"config":[1040],"getMessage":[16],"showHardFixed":[4,"show-hard-fixed"],"show":[64]}]]],["p-3b60db06",[[2,"snk-config-options",{"fieldConfig":[16],"idConfig":[513,"id-config"],"dataUnit":[16],"messagesBuilder":[1040],"_defaultType":[32]}]]],["p-95df461f",[[2,"snk-field-config",{"isConfigActive":[16],"fieldConfig":[16],"modeInsertion":[516,"mode-insertion"],"dataUnit":[16],"messagesBuilder":[1040]}]]],["p-88aa931b",[[6,"snk-simple-bar",{"label":[1],"breadcrumbItens":[16],"messagesBuilder":[1040]}]]],["p-8eb67fa4",[[6,"snk-tab-config",{"selectedIndex":[1538,"selected-index"],"selectedTab":[1537,"selected-tab"],"tabs":[1],"tabItems":[16],"messagesBuilder":[1040],"_processedTabs":[32],"_activeEditText":[32],"_activeEditTextIndex":[32],"_actionsHide":[32],"_actionsShow":[32]}]]],["p-939e15d3",[[2,"snk-form-config",{"dataUnit":[16],"configManager":[16],"messagesBuilder":[1040],"_formConfigOptions":[32],"_fieldConfigSelected":[32],"_layoutFormConfig":[32],"_fieldsAvailable":[32],"_formConfig":[32],"_formConfigChanged":[32],"_optionFormConfigSelected":[32],"_optionFormConfigChanged":[32],"_tempGroups":[32]}]]],["p-16a1dd18",[[0,"snk-exporter-email-sender",{"getMessage":[16],"_config":[32],"_opened":[32],"_currentStep":[32],"open":[64],"close":[64]}]]],["p-53412c1d",[[6,"snk-crud",{"configName":[1025,"config-name"],"filterBarTitle":[1,"filter-bar-title"],"selectionToastConfig":[16],"showActionButtons":[4,"show-action-buttons"],"actionsList":[16],"taskbarManager":[16],"recordsValidator":[16],"statusResolver":[16],"multipleSelection":[4,"multiple-selection"],"presentationMode":[1,"presentation-mode"],"messagesBuilder":[1040],"useEnterLikeTab":[4,"use-enter-like-tab"],"gridLegacyConfigName":[1,"grid-legacy-config-name"],"filterBarLegacyConfigName":[1,"filter-bar-legacy-config-name"],"formLegacyConfigName":[1,"form-legacy-config-name"],"disablePersonalizedFilter":[4,"disable-personalized-filter"],"autoLoad":[4,"auto-load"],"autoFocus":[4,"auto-focus"],"domainMessagesBuilder":[1,"domain-messages-builder"],"_dataUnit":[32],"_dataState":[32],"attachmentRegisterKey":[32],"_currentViewMode":[32],"_canEdit":[32],"_resourceID":[32],"customContainerId":[32],"goToView":[64],"openConfigurator":[64],"closeConfigurator":[64],"reloadFilterBar":[64],"getFilterBar":[64],"addCustomEditor":[64],"addGridCustomRender":[64],"addCustomValueFormatter":[64],"removeCustomValueFormatter":[64],"setFieldProp":[64]}]]],["p-2e9c764c",[[2,"snk-form",{"configName":[1,"config-name"],"recordsValidator":[16],"messagesBuilder":[1040],"formLegacyConfigName":[1,"form-legacy-config-name"],"resourceID":[1,"resource-i-d"],"_dataUnit":[32],"_dataState":[32],"_showFormConfig":[32],"_configManager":[32],"showConfig":[64],"hideConfig":[64],"addCustomEditor":[64],"setFieldProp":[64]}]]],["p-3c50e9d4",[[2,"snk-data-exporter",{"provider":[16],"messagesBuilder":[1040],"_items":[32],"_showDropdown":[32]}]]],["p-7b8f7242",[[6,"snk-guides-viewer",{"dataUnit":[16],"dataState":[16],"configName":[1,"config-name"],"entityPath":[1,"entity-path"],"actionsList":[16],"recordsValidator":[16],"masterFormConfig":[1040],"selectedGuide":[16],"taskbarManager":[16],"messagesBuilder":[1040],"canEdit":[4,"can-edit"],"presentationMode":[1,"presentation-mode"],"resourceID":[1,"resource-i-d"],"detailTaskbarCustomContainerId":[1,"detail-taskbar-custom-container-id"],"formLegacyConfigName":[1,"form-legacy-config-name"],"_hasToCreateFieldSearch":[32],"_breadcrumbItems":[32],"_guides":[32],"_formEditorConfigManager":[32],"_formEditorDataUnit":[32],"_fieldToGetFocus":[32],"_customEditors":[32],"_customRenders":[32],"_fieldsProps":[32],"showFormConfig":[64],"findField":[64],"addCustomEditor":[64],"addGridCustomRender":[64],"setFieldProp":[64],"setFocus":[64]},[[2,"actionClick","onActionClick"],[0,"snkContentCardChanged","onContentCardChanged"]]]]],["p-162b9a59",[[2,"snk-application",{"messagesBuilder":[1040],"configName":[1,"config-name"],"gridLegacyConfigName":[1,"grid-legacy-config-name"],"formLegacyConfigName":[1,"form-legacy-config-name"],"loadByPK":[16],"getKeyboardManager":[64],"isUserSup":[64],"addPendingAction":[64],"callServiceBroker":[64],"initOnboarding":[64],"hasAccess":[64],"getAllAccess":[64],"getStringParam":[64],"getIntParam":[64],"getFloatParam":[64],"getBooleanParam":[64],"getDateParam":[64],"showPopUp":[64],"showModal":[64],"showAlerts":[64],"closeModal":[64],"closePopUp":[64],"temOpcional":[64],"getConfig":[64],"saveConfig":[64],"getAttributeFromHTMLWrapper":[64],"openApp":[64],"webConnection":[64],"createDataunit":[64],"updateDataunitCache":[64],"getDataUnit":[64],"addClientEvent":[64],"removeClientEvent":[64],"hasClientEvent":[64],"getResourceID":[64],"getUserID":[64],"alert":[64],"error":[64],"success":[64],"message":[64],"confirm":[64],"info":[64],"loadTotals":[64],"isLoadedByPk":[64],"executeSearch":[64],"executePreparedSearch":[64],"isDebugMode":[64],"getAppLabel":[64],"addSearchListener":[64],"importScript":[64],"getApplicationPath":[64],"executeSelectDistinct":[64],"getDataFetcher":[64],"whenApplicationReady":[64],"setSearchFilterContext":[64]}]]],["p-3ab6df3d",[[2,"snk-filter-assistent-mode",{"filterAssistent":[1040],"messagesBuilder":[1040],"filterId":[1025,"filter-id"],"entityUri":[1025,"entity-uri"],"application":[1040]}],[2,"snk-filter-advanced-mode",{"filterAssistent":[1040],"application":[1040]}]]],["p-421bec84",[[2,"snk-grid-config",{"selectedIndex":[1026,"selected-index"],"columns":[1040],"config":[1040],"configName":[1,"config-name"],"resourceID":[1,"resource-i-d"]}],[2,"snk-actions-button",{"_items":[32],"_showDropdown":[32],"_actions":[32],"_isOrderActions":[32]}],[1,"snk-select-box",{"selectedOption":[1,"selected-option"]}],[2,"taskbar-actions-button",{"title":[1],"enabled":[4],"actions":[16],"_showDropdown":[32],"showActions":[64],"hideActions":[64],"isOpened":[64]},[[8,"keydown","handleKeyDown"],[8,"ezOpenModal","handleClose"]]]]],["p-46bb200a",[[6,"snk-detail-view",{"formConfigManager":[1040],"dataUnitName":[1,"data-unit-name"],"resourceID":[1,"resource-i-d"],"guideItemPath":[16],"entityName":[1,"entity-name"],"label":[1],"dataUnit":[1040],"selectedForm":[1025,"selected-form"],"dataState":[1040],"messagesBuilder":[1040],"branchGuide":[1040],"canEdit":[4,"can-edit"],"taskbarCustomContainerId":[1,"taskbar-custom-container-id"],"customEditors":[16],"customRenders":[16],"_disabledButtons":[32],"_currentView":[32],"attachmentRegisterKey":[32],"changeViewMode":[64],"configGrid":[64],"showUp":[64],"addCustomEditor":[64],"addGridCustomRender":[64]},[[0,"snkContentCardChanged","onContentCardChanged"]]]]]]'),e)));
|
1
|
+
import{p as e,b as t}from"./p-d2d301a6.js";export{s as setNonce}from"./p-d2d301a6.js";(()=>{const t=import.meta.url,a={};return""!==t&&(a.resourcesUrl=new URL(".",t).href),e(a)})().then((e=>t(JSON.parse('[["p-118e769b",[[1,"teste-pesquisa"]]],["p-70a4af56",[[0,"snk-filter-modal",{"getMessage":[16],"configName":[1025,"config-name"],"filters":[1040],"applyFilters":[16],"closeModal":[16],"addPersonalizedFilter":[16],"editPersonalizedFilter":[16],"deletePersonalizedFilter":[16],"filtersToDelete":[16],"disablePersonalizedFilter":[4,"disable-personalized-filter"]},[[0,"deleteFilter","deletePersonalizedFilterListener"]]]]],["p-ac8d1cd6",[[2,"snk-actions-form",{"action":[16],"applyParameters":[16],"dataUnit":[32],"openPopup":[64]}]]],["p-9531fd46",[[2,"snk-client-confirm",{"titleMessage":[1,"title-message"],"message":[1],"accept":[16],"cancel":[16],"openPopup":[64]}]]],["p-21a81901",[[6,"snk-custom-slot-elements",{"slotName":[1,"slot-name"]}]]],["p-33718dfc",[[2,"snk-entity-list",{"config":[1040],"rightListSlotBuilder":[1040],"maxHeightList":[1,"max-height-list"],"_searchValue":[32],"_ezListSource":[32],"reloadList":[64]}]]],["p-41f8bfa3",[[0,"snk-filter-binary-select",{"value":[1544],"config":[16],"presentationMode":[2,"presentation-mode"],"resetValues":[64]},[[0,"ezChange","ezChangeListener"]]]]],["p-aaa3ee68",[[0,"snk-filter-checkbox-list",{"config":[1040],"optionsList":[32]}]]],["p-d3f53df2",[[4,"snk-filter-list",{"label":[1],"iconName":[1,"icon-name"],"items":[16],"getMessage":[16],"emptyText":[1,"empty-text"],"findFilterText":[1,"find-filter-text"],"buttonClass":[1,"button-class"],"_filterArgument":[32],"_showAll":[32],"hideDetail":[64]},[[2,"keydown","keyDownHandler"]]]]],["p-bf2acf72",[[0,"snk-filter-multi-select",{"value":[1544],"config":[16],"show":[64]},[[0,"ezChange","ezChangeListener"]]]]],["p-01ba23cd",[[0,"snk-filter-number",{"config":[16],"getMessage":[16],"value":[2],"presentationMode":[2,"presentation-mode"],"show":[64]},[[0,"ezChange","ezChangeListener"]]]]],["p-7e2ded86",[[0,"snk-filter-period",{"config":[16],"getMessage":[16],"value":[8],"presentationMode":[2,"presentation-mode"],"show":[64]},[[0,"ezChange","ezChangeListener"]]]]],["p-c8622597",[[0,"snk-filter-search",{"config":[16],"value":[16],"show":[64]},[[0,"ezChange","ezChangeListener"]]]]],["p-96a89d58",[[0,"snk-filter-text",{"config":[16],"value":[1]},[[0,"ezChange","ezChangeListener"]]]]],["p-b11aa1e0",[[2,"snk-personalized-filter-editor",{"messagesBuilder":[1040],"presentationMode":[2,"presentation-mode"],"config":[16],"value":[1040],"items":[32],"show":[64]}]]],["p-72fc257b",[[2,"snk-print-selector",{"_printServerActive":[32],"_selectedPrinter":[32],"_remotePrintersDataSource":[32],"_localPrintersDataSource":[32],"_printJobData":[32],"openPrintSelector":[64]}]]],["p-9dfda04a",[[0,"snk-filter-modal-item",{"filterItem":[1040],"configName":[1025,"config-name"],"resourceID":[1,"resource-i-d"]}]]],["p-d1791da2",[[2,"snk-pesquisa",{"searchLoader":[16],"selectItem":[16],"argument":[1025],"_itemList":[32],"_startLoading":[32]}]]],["p-2d6dc51d",[[6,"snk-simple-crud",{"dataState":[16],"dataUnit":[16],"entityName":[1,"entity-name"],"mode":[2],"gridConfig":[1040],"formConfig":[1040],"multipleSelection":[4,"multiple-selection"],"useCancelConfirm":[4,"use-cancel-confirm"],"pageSize":[2,"page-size"],"resourceID":[1,"resource-i-d"],"taskbarManager":[16],"messagesBuilder":[1040],"useEnterLikeTab":[4,"use-enter-like-tab"],"actionsList":[16],"configName":[1025,"config-name"],"showConfiguratorButtons":[4,"show-configurator-buttons"],"gridLegacyConfigName":[1,"grid-legacy-config-name"],"formLegacyConfigName":[1,"form-legacy-config-name"],"ignoreReadOnlyFormFields":[4,"ignore-read-only-form-fields"],"autoFocus":[4,"auto-focus"],"domainMessagesBuilder":[1,"domain-messages-builder"],"autoLoad":[4,"auto-load"],"_showPopUpGridConfig":[32],"_showFormConfig":[32],"_currentViewMode":[32],"_config":[32],"_fieldToGetFocus":[32],"_customContainerId":[32],"_formFields":[32],"_fieldsProps":[32],"addCustomEditor":[64],"addGridCustomRender":[64],"addCustomValueFormatter":[64],"removeCustomValueFormatter":[64],"setFieldProp":[64],"goToView":[64],"setMetadata":[64],"setRecords":[64],"getRecords":[64],"openConfigurator":[64],"closeConfigurator":[64],"updateConfig":[64]},[[0,"actionClick","actionClickListener"]]]]],["p-42f7b05d",[[2,"snk-attach",{"fetcherType":[1,"fetcher-type"],"fetcher":[16],"dataUnit":[16],"dataUnitBuilder":[16],"registerKey":[1,"register-key"],"entityName":[1,"entity-name"],"messagesBuilder":[1040],"_currentFetcher":[32],"_currentDataUnit":[32],"crudConfig":[32]}]]],["p-26b0ce3e",[[2,"snk-form-summary",{"fixed":[1540],"contracted":[1540],"summary":[16]}]]],["p-1db45d26",[[6,"snk-form-view",{"levelPath":[1,"level-path"],"label":[1],"name":[1],"fields":[16],"formMetadata":[8,"form-metadata"],"dataUnit":[16],"contracted":[4],"fixed":[1540],"summaryFields":[16],"canExpand":[4,"can-expand"],"canFix":[4,"can-fix"],"recordsValidator":[16],"fieldToFocus":[1,"field-to-focus"],"customEditors":[16],"fieldsProps":[16],"showUp":[64],"addCustomEditor":[64],"setFieldProp":[64]}]]],["p-8002dcd0",[[2,"snk-filter-field-search",{"searchable":[4],"fieldsDataSource":[16],"breadcrumbItems":[32],"linkItems":[32],"fieldItems":[32],"searchEmpty":[32],"groupEmpty":[32],"show":[64],"applyFilter":[64]}],[0,"snk-filter-param-config",{"messagesBuilder":[1040],"_opened":[32],"_configType":[32],"_expressionItem":[32],"_informedInstance":[32],"_canSave":[32],"open":[64],"close":[64]}]]],["p-9d3a025a",[[2,"snk-expression-group",{"parentTop":[1026,"parent-top"],"group":[1040],"messagesBuilder":[1040],"filterId":[1025,"filter-id"],"entityURI":[1025,"entity-u-r-i"],"_conditionOperator":[32],"_group":[32],"_selfTop":[32],"canAddExpression":[32],"_showDashes":[32],"getExpressionGroup":[64]},[[8,"ezExpressionLayoutChanged","todoCompletedHandler"]]],[2,"snk-expression-item",{"expression":[16],"canRemove":[516,"can-remove"],"messagesBuilder":[1040],"entityURI":[1025,"entity-u-r-i"],"_showValueVariable":[32],"_fieldSelected":[32],"_optionNotNull":[32]}]]],["p-bd008859",[[2,"snk-personalized-filter",{"messagesBuilder":[1040],"entityUri":[1025,"entity-uri"],"filterId":[1025,"filter-id"],"configName":[1025,"config-name"],"resourceID":[1,"resource-i-d"],"_filterAssistentMode":[32],"_filterAssistent":[32],"createPersonalizedFilter":[64]}]]],["p-e8763234",[[0,"snk-filter-item",{"config":[1040],"getMessage":[16],"showChips":[4,"show-chips"],"detailIsVisible":[32],"showUp":[64],"hideDetail":[64]},[[2,"click","clickListener"],[2,"mousedown","mouseDownListener"],[0,"filterChange","filterChangeListener"]]]]],["p-5b26cc7c",[[2,"snk-filter-bar",{"dataUnit":[1040],"title":[1],"configName":[1,"config-name"],"resourceID":[1,"resource-i-d"],"mode":[1],"filterConfig":[1040],"messagesBuilder":[1040],"disablePersonalizedFilter":[4,"disable-personalized-filter"],"filterBarLegacyConfigName":[1,"filter-bar-legacy-config-name"],"autoLoad":[4,"auto-load"],"allowDefault":[32],"scrollerLocked":[32],"showPersonalizedFilter":[32],"personalizedFilterId":[32],"reload":[64],"getFilterItem":[64],"updateFilterItem":[64],"addFilterItem":[64],"removeFilterItem":[64],"showFilterModal":[64]},[[0,"filterChange","filterChangeListener"]]]]],["p-81f6d043",[[6,"snk-grid",{"columnFilterDataSource":[1040],"configName":[1,"config-name"],"filterBarTitle":[1,"filter-bar-title"],"resourceID":[1,"resource-i-d"],"selectionToastConfig":[16],"actionsList":[16],"isDetail":[4,"is-detail"],"taskbarManager":[16],"statusResolver":[16],"multipleSelection":[4,"multiple-selection"],"presentationMode":[1,"presentation-mode"],"messagesBuilder":[1040],"useEnterLikeTab":[4,"use-enter-like-tab"],"recordsValidator":[16],"canEdit":[4,"can-edit"],"taskbarCustomContainerId":[1,"taskbar-custom-container-id"],"gridHeaderCustomSlotId":[1,"grid-header-custom-slot-id"],"topTaskbarCustomSlotId":[1,"top-taskbar-custom-slot-id"],"disablePersonalizedFilter":[4,"disable-personalized-filter"],"gridLegacyConfigName":[1,"grid-legacy-config-name"],"filterBarLegacyConfigName":[1,"filter-bar-legacy-config-name"],"autoLoad":[4,"auto-load"],"autoFocus":[4,"auto-focus"],"_dataUnit":[32],"_dataState":[32],"_gridConfig":[32],"_popUpGridConfig":[32],"_showSnkFilterBar":[32],"showConfig":[64],"hideConfig":[64],"setConfig":[64],"reloadFilterBar":[64],"getFilterBar":[64],"findColumn":[64],"addCustomEditor":[64],"addGridCustomRender":[64],"addCustomValueFormatter":[64],"removeCustomValueFormatter":[64],"setFocus":[64]}]]],["p-7663f597",[[2,"snk-configurator",{"showActionButtons":[4,"show-action-buttons"],"configName":[1,"config-name"],"resourceID":[1,"resource-i-d"],"viewMode":[2,"view-mode"],"customContainerId":[1,"custom-container-id"],"messagesBuilder":[1040],"_opened":[32],"_permissions":[32],"open":[64],"close":[64]}]]],["p-27b57eb7",[[2,"snk-data-unit",{"dataState":[1040],"messagesBuilder":[1040],"dataUnitName":[1,"data-unit-name"],"entityName":[1,"entity-name"],"pageSize":[2,"page-size"],"dataUnit":[1040],"beforeSave":[16],"afterSave":[16],"useCancelConfirm":[4,"use-cancel-confirm"],"ignoreSaveMessage":[4,"ignore-save-message"],"configName":[1,"config-name"],"resourceID":[1,"resource-i-d"],"domainMessagesBuilder":[1,"domain-messages-builder"],"fieldsToLink":[32],"getDataUnit":[64],"getSelectedRecordsIDsInfo":[64],"getFieldsWithRmp":[64],"getFieldsWithRmPrecision":[64],"getRowMetadata":[64]}]]],["p-18ed15f4",[[6,"snk-taskbar",{"alignRigth":[4,"align-rigth"],"customSlotId":[1,"custom-slot-id"],"customContainerId":[1,"custom-container-id"],"overflowStrategy":[1,"overflow-strategy"],"configName":[1,"config-name"],"resourceID":[1,"resource-i-d"],"buttons":[1],"customButtons":[16],"actionsList":[16],"primaryButton":[1,"primary-button"],"disabledButtons":[16],"dataUnit":[16],"presentationMode":[1537,"presentation-mode"],"messagesBuilder":[1040],"_permissions":[32],"_overFlowedElements":[32],"_customElements":[32],"_customElementsId":[32],"_slotContainer":[32],"_hiddenActionsList":[32],"_lastWidth":[32],"_hasToUpdateOverFlow":[32],"_isWaitingForSave":[32]},[[8,"snkCustomSlotElementsLoaded","handleCustomSlotElementsLoaded"],[8,"taskbarSaveLocker","handleTaskbarSaveLocker"],[8,"taskbarSaveUnlocker","handleTaskbarSaveUnlocker"]]]]],["p-54a5d52a",[[0,"snk-filter-detail",{"config":[1040],"getMessage":[16],"showHardFixed":[4,"show-hard-fixed"],"show":[64]}]]],["p-3b60db06",[[2,"snk-config-options",{"fieldConfig":[16],"idConfig":[513,"id-config"],"dataUnit":[16],"messagesBuilder":[1040],"_defaultType":[32]}]]],["p-95df461f",[[2,"snk-field-config",{"isConfigActive":[16],"fieldConfig":[16],"modeInsertion":[516,"mode-insertion"],"dataUnit":[16],"messagesBuilder":[1040]}]]],["p-88aa931b",[[6,"snk-simple-bar",{"label":[1],"breadcrumbItens":[16],"messagesBuilder":[1040]}]]],["p-8eb67fa4",[[6,"snk-tab-config",{"selectedIndex":[1538,"selected-index"],"selectedTab":[1537,"selected-tab"],"tabs":[1],"tabItems":[16],"messagesBuilder":[1040],"_processedTabs":[32],"_activeEditText":[32],"_activeEditTextIndex":[32],"_actionsHide":[32],"_actionsShow":[32]}]]],["p-939e15d3",[[2,"snk-form-config",{"dataUnit":[16],"configManager":[16],"messagesBuilder":[1040],"_formConfigOptions":[32],"_fieldConfigSelected":[32],"_layoutFormConfig":[32],"_fieldsAvailable":[32],"_formConfig":[32],"_formConfigChanged":[32],"_optionFormConfigSelected":[32],"_optionFormConfigChanged":[32],"_tempGroups":[32]}]]],["p-16a1dd18",[[0,"snk-exporter-email-sender",{"getMessage":[16],"_config":[32],"_opened":[32],"_currentStep":[32],"open":[64],"close":[64]}]]],["p-53412c1d",[[6,"snk-crud",{"configName":[1025,"config-name"],"filterBarTitle":[1,"filter-bar-title"],"selectionToastConfig":[16],"showActionButtons":[4,"show-action-buttons"],"actionsList":[16],"taskbarManager":[16],"recordsValidator":[16],"statusResolver":[16],"multipleSelection":[4,"multiple-selection"],"presentationMode":[1,"presentation-mode"],"messagesBuilder":[1040],"useEnterLikeTab":[4,"use-enter-like-tab"],"gridLegacyConfigName":[1,"grid-legacy-config-name"],"filterBarLegacyConfigName":[1,"filter-bar-legacy-config-name"],"formLegacyConfigName":[1,"form-legacy-config-name"],"disablePersonalizedFilter":[4,"disable-personalized-filter"],"autoLoad":[4,"auto-load"],"autoFocus":[4,"auto-focus"],"domainMessagesBuilder":[1,"domain-messages-builder"],"_dataUnit":[32],"_dataState":[32],"attachmentRegisterKey":[32],"_currentViewMode":[32],"_canEdit":[32],"_resourceID":[32],"customContainerId":[32],"goToView":[64],"openConfigurator":[64],"closeConfigurator":[64],"reloadFilterBar":[64],"getFilterBar":[64],"addCustomEditor":[64],"addGridCustomRender":[64],"addCustomValueFormatter":[64],"removeCustomValueFormatter":[64],"setFieldProp":[64]}]]],["p-2e9c764c",[[2,"snk-form",{"configName":[1,"config-name"],"recordsValidator":[16],"messagesBuilder":[1040],"formLegacyConfigName":[1,"form-legacy-config-name"],"resourceID":[1,"resource-i-d"],"_dataUnit":[32],"_dataState":[32],"_showFormConfig":[32],"_configManager":[32],"showConfig":[64],"hideConfig":[64],"addCustomEditor":[64],"setFieldProp":[64]}]]],["p-fa155ad6",[[2,"snk-data-exporter",{"provider":[16],"messagesBuilder":[1040],"_items":[32],"_showDropdown":[32]}]]],["p-7b8f7242",[[6,"snk-guides-viewer",{"dataUnit":[16],"dataState":[16],"configName":[1,"config-name"],"entityPath":[1,"entity-path"],"actionsList":[16],"recordsValidator":[16],"masterFormConfig":[1040],"selectedGuide":[16],"taskbarManager":[16],"messagesBuilder":[1040],"canEdit":[4,"can-edit"],"presentationMode":[1,"presentation-mode"],"resourceID":[1,"resource-i-d"],"detailTaskbarCustomContainerId":[1,"detail-taskbar-custom-container-id"],"formLegacyConfigName":[1,"form-legacy-config-name"],"_hasToCreateFieldSearch":[32],"_breadcrumbItems":[32],"_guides":[32],"_formEditorConfigManager":[32],"_formEditorDataUnit":[32],"_fieldToGetFocus":[32],"_customEditors":[32],"_customRenders":[32],"_fieldsProps":[32],"showFormConfig":[64],"findField":[64],"addCustomEditor":[64],"addGridCustomRender":[64],"setFieldProp":[64],"setFocus":[64]},[[2,"actionClick","onActionClick"],[0,"snkContentCardChanged","onContentCardChanged"]]]]],["p-162b9a59",[[2,"snk-application",{"messagesBuilder":[1040],"configName":[1,"config-name"],"gridLegacyConfigName":[1,"grid-legacy-config-name"],"formLegacyConfigName":[1,"form-legacy-config-name"],"loadByPK":[16],"getKeyboardManager":[64],"isUserSup":[64],"addPendingAction":[64],"callServiceBroker":[64],"initOnboarding":[64],"hasAccess":[64],"getAllAccess":[64],"getStringParam":[64],"getIntParam":[64],"getFloatParam":[64],"getBooleanParam":[64],"getDateParam":[64],"showPopUp":[64],"showModal":[64],"showAlerts":[64],"closeModal":[64],"closePopUp":[64],"temOpcional":[64],"getConfig":[64],"saveConfig":[64],"getAttributeFromHTMLWrapper":[64],"openApp":[64],"webConnection":[64],"createDataunit":[64],"updateDataunitCache":[64],"getDataUnit":[64],"addClientEvent":[64],"removeClientEvent":[64],"hasClientEvent":[64],"getResourceID":[64],"getUserID":[64],"alert":[64],"error":[64],"success":[64],"message":[64],"confirm":[64],"info":[64],"loadTotals":[64],"isLoadedByPk":[64],"executeSearch":[64],"executePreparedSearch":[64],"isDebugMode":[64],"getAppLabel":[64],"addSearchListener":[64],"importScript":[64],"getApplicationPath":[64],"executeSelectDistinct":[64],"getDataFetcher":[64],"whenApplicationReady":[64],"setSearchFilterContext":[64]}]]],["p-3ab6df3d",[[2,"snk-filter-assistent-mode",{"filterAssistent":[1040],"messagesBuilder":[1040],"filterId":[1025,"filter-id"],"entityUri":[1025,"entity-uri"],"application":[1040]}],[2,"snk-filter-advanced-mode",{"filterAssistent":[1040],"application":[1040]}]]],["p-1e596b15",[[2,"snk-grid-config",{"selectedIndex":[1026,"selected-index"],"columns":[1040],"config":[1040],"configName":[1,"config-name"],"resourceID":[1,"resource-i-d"]}],[2,"snk-actions-button",{"_items":[32],"_showDropdown":[32],"_actions":[32],"_isOrderActions":[32]}],[1,"snk-select-box",{"selectedOption":[1,"selected-option"]}],[2,"taskbar-actions-button",{"title":[1],"enabled":[4],"actions":[16],"_showDropdown":[32],"showActions":[64],"hideActions":[64],"isOpened":[64]},[[8,"keydown","handleKeyDown"],[8,"ezOpenModal","handleClose"]]]]],["p-fd8a58ff",[[6,"snk-detail-view",{"formConfigManager":[1040],"dataUnitName":[1,"data-unit-name"],"resourceID":[1,"resource-i-d"],"guideItemPath":[16],"entityName":[1,"entity-name"],"label":[1],"dataUnit":[1040],"selectedForm":[1025,"selected-form"],"dataState":[1040],"messagesBuilder":[1040],"branchGuide":[1040],"canEdit":[4,"can-edit"],"taskbarCustomContainerId":[1,"taskbar-custom-container-id"],"customEditors":[16],"customRenders":[16],"_disabledButtons":[32],"_currentView":[32],"attachmentRegisterKey":[32],"changeViewMode":[64],"configGrid":[64],"showUp":[64],"addCustomEditor":[64],"addGridCustomRender":[64]},[[0,"snkContentCardChanged","onContentCardChanged"]]]]]]'),e)));
|
@@ -9,6 +9,7 @@ export default class Actions {
|
|
9
9
|
private _lastValuesCache;
|
10
10
|
private _appResourceId;
|
11
11
|
constructor(actionsExecuteInterface: ExecuteActionsInterface, dataUnit: DataUnit, appResourceId: string);
|
12
|
+
private getPrimaryKeys;
|
12
13
|
private apply;
|
13
14
|
execute(action: IAction): Promise<void>;
|
14
15
|
private loadSavedValuesIntoParams;
|
@@ -88,7 +88,17 @@ export declare class SnkTaskbar {
|
|
88
88
|
* Emitido sempre que houver click de botão ou ação.
|
89
89
|
*/
|
90
90
|
actionClick: EventEmitter<string>;
|
91
|
+
/**
|
92
|
+
* Emitido sempre que um save é iniciado pela taskbar.
|
93
|
+
*/
|
94
|
+
taskbarSaveLocker: EventEmitter<void>;
|
95
|
+
/**
|
96
|
+
* Emitido sempre que o ocorre alguma action que libera o save.
|
97
|
+
*/
|
98
|
+
taskbarSaveUnlocker: EventEmitter<void>;
|
91
99
|
handleCustomSlotElementsLoaded(event: CustomEvent): void;
|
100
|
+
handleTaskbarSaveLocker(): void;
|
101
|
+
handleTaskbarSaveUnlocker(): void;
|
92
102
|
private hasToSearchCustomElements;
|
93
103
|
_titleKeyByElement: {
|
94
104
|
UPDATE: string;
|
@@ -109,6 +119,7 @@ export declare class SnkTaskbar {
|
|
109
119
|
observeButtons(): void;
|
110
120
|
observeDisabledButtons(): void;
|
111
121
|
observeLastWidth(newValue: any, oldValue: any): void;
|
122
|
+
observeIsWaitingForSave(newValue: any, oldValue: any): void;
|
112
123
|
elementsFromString(strButtons: string): Array<TaskbarElement>;
|
113
124
|
private isAllowed;
|
114
125
|
/**
|
@@ -3862,6 +3862,14 @@ declare namespace LocalJSX {
|
|
3862
3862
|
* Emitido sempre que houver click de botão ou ação.
|
3863
3863
|
*/
|
3864
3864
|
"onActionClick"?: (event: SnkTaskbarCustomEvent<string>) => void;
|
3865
|
+
/**
|
3866
|
+
* Emitido sempre que um save é iniciado pela taskbar.
|
3867
|
+
*/
|
3868
|
+
"onTaskbarSaveLocker"?: (event: SnkTaskbarCustomEvent<void>) => void;
|
3869
|
+
/**
|
3870
|
+
* Emitido sempre que o ocorre alguma action que libera o save.
|
3871
|
+
*/
|
3872
|
+
"onTaskbarSaveUnlocker"?: (event: SnkTaskbarCustomEvent<void>) => void;
|
3865
3873
|
/**
|
3866
3874
|
* Define como será o comportamento da taskbar quando ocorrer overflow
|
3867
3875
|
*/
|
package/package.json
CHANGED
@@ -1 +0,0 @@
|
|
1
|
-
import{r as t,h as i,H as s,g as e,c as n}from"./p-d2d301a6.js";import{ApplicationContext as o,StringUtils as r,ErrorException as a,WarningException as c,ObjectUtils as l,DateUtils as d,ArrayUtils as h,ElementIDUtils as u}from"@sankhyalabs/core";import{D as g}from"./p-594bc21d.js";import{P as f}from"./p-eaad0aa8.js";import"./p-25f1fc39.js";import"./p-30cf616e.js";import"./p-21749402.js";import"@sankhyalabs/ezui/dist/collection/utils/constants";import"@sankhyalabs/core/dist/dataunit/metadata/UnitMetadata";import"./p-091ce761.js";import"./p-ff1990ad.js";import"./p-181975f1.js";import{R as m}from"./p-688dcb4c.js";import{ApplicationUtils as p,DialogType as v}from"@sankhyalabs/ezui/dist/collection/utils";import{CheckMode as b}from"@sankhyalabs/ezui/dist/collection/components/ez-check/CheckMode";import{C as k}from"./p-3287a6cc.js";import{O as _}from"./p-b0ef4383.js";import"./p-8d884fab.js";import"@sankhyalabs/ezui/dist/collection/components/ez-grid/utils";import"@sankhyalabs/core/dist/utils/SortingUtils";class w{execute(t){var i;const s={actionID:t.actionID,refreshType:null===(i=t.actionConfig.javaCall)||void 0===i?void 0:i.refreshType};return new Promise((t=>{t({execSource:s,callback:this.callExecJava})}))}async callExecJava(t){const i={requestBody:{javaCall:t}};await g.get().callServiceBroker("ActionButtonsSP.executeJava",JSON.stringify(i))}}class C{execute(t){var i;const s={actionID:t.actionID,refreshType:null===(i=t.actionConfig.runScript)||void 0===i?void 0:i.refreshType};return new Promise((t=>{t({execSource:s,callback:this.callExecScript})}))}async callExecScript(t){const i={runScript:t};await g.get().callServiceBroker("ActionButtonsSP.executeScript",i)}}class y{constructor(){this._application=o.getContextValue("__SNK__APPLICATION__")}async execute(t,i){const s=t.resourceID;if(!s)return;let e=await this.buildLaunchObject(t,i);return this._application.openApp(s,e),null}buildLaunchObject(t,i){return new Promise((s=>{let e=t.actionConfig.params.param;if(e&&e.length>0){let n={},o=[];e.forEach((s=>{const e=s.localField;let c=i.getFieldValue(e);if(!c){let s=i.getField(e).label;throw s=r.isEmpty(i.getField(e).label)?e:s,new a(this._application.messagesBuilder.getMessage("snkActionsButton.title.error",void 0),this._application.messagesBuilder.getMessage("snkActionsButton.launchScreen.emptyField",{description:t.description,localFieldLabel:s}))}c=r.isEmpty(c.toString())?void 0:c.toString(),n[s.targetField]=c,o.push({fieldName:s.targetField,value:c})})),n.ACTION_PARAMETERS=o,n.call_time=Date.now(),s(n)}s(null)}))}}class x{execute(t){var i,s,e;const n=null===(i=t.actionConfig.dbCall)||void 0===i?void 0:i.name,o=null===(s=t.actionConfig.dbCall)||void 0===s?void 0:s.rootEntity,r={actionID:t.actionID,refreshType:null===(e=t.actionConfig.dbCall)||void 0===e?void 0:e.refreshType,procName:n,rootEntity:o};return new Promise((t=>{t({execSource:r,callback:this.callExecProcedure})}))}async callExecProcedure(t){const i={requestBody:{stpCall:t}};await g.get().callServiceBroker("ActionButtonsSP.executeSTP",JSON.stringify(i))}}var S,z;!function(t){t.LAUNCH_SCREEN="LC",t.JAVASCRIPT="SC",t.JAVA="RJ",t.PROCEDURE="SP",t.EMBEDDED="EB"}(S||(S={}));class A{constructor(t){this.actionType=t,this._application=o.getContextValue("__SNK__APPLICATION__")}get executor(){switch(this.actionType){case S.LAUNCH_SCREEN:return new y;case S.JAVASCRIPT:return new C;case S.JAVA:return new w;case S.PROCEDURE:return new x;default:throw new a(this._application.messagesBuilder.getMessage("snkActionsButton.title.error",void 0),this._application.messagesBuilder.getMessage("snkActionsButton.action.nonExistentType",{actionType:this.actionType}))}}}!function(t){t.NONE="NONE",t.PARENT="PARENT",t.MASTER="MASTER",t.ALL="ALL"}(z||(z={}));const O="__MASTER_ROW__";class N{constructor(t,i,s){var e;this._lastValuesCache={},this._actionsExecuteInterface=t,this._dataUnit=i,this._selectedRows=(null===(e=null==i?void 0:i.getSelectionInfo())||void 0===e?void 0:e.isAllRecords())?[]:null==i?void 0:i.getSelectionInfo().records,this._application=o.getContextValue("__SNK__APPLICATION__"),this._appResourceId=s}apply(t,i){this._application.closePopUp(),this._actionsExecuteInterface.execute(t,this._dataUnit).then((({execSource:s,callback:e})=>{this.resolvePromptParams(t,s,i).then((()=>{this.actionExecute(s,e)}))}))}async execute(t){var i;if(!t.actionConfig)throw new c(this._application.messagesBuilder.getMessage("snkActionsButton.title.warning",void 0),this._application.messagesBuilder.getMessage("snkActionsButton.action.incorrectAction",{description:t.description}));if(null===(i=t.actionConfig.params)||void 0===i?void 0:i.promptParam){const i=t.actionConfig.params.promptParam;let s=!1;for(let t=0;t<i.length;t++)if(!s&&"true"===i[t].saveLast){s=!0;break}s&&(t.actionConfig.params.promptParam=await this.loadSavedValuesIntoParams(t));const e=document.createElement("snk-actions-form");window.document.body.appendChild(e),e.action=l.copy(t),e.applyParameters=t=>{this.apply(t,s)},e.openPopup()}else t.type!=S.LAUNCH_SCREEN?this._actionsExecuteInterface.execute(t,this._dataUnit).then((({execSource:t,callback:i})=>{this.actionExecute(t,i)})):this._actionsExecuteInterface.execute(t,this._dataUnit)}loadSavedValuesIntoParams(t){return this.loadLastValues(t).then((i=>{let s=t.actionConfig.params.promptParam;return i&&i.param.forEach((t=>{s=s.map((i=>i.name!==t.paramName?i:Object.assign(Object.assign({},i),"B"===i.paramType?{value:"S"===t.$}:{value:t.$})))})),s}))}actionExecute(t,i){t.virtualPage=this.buildVirtualPage(),this.prepareAndExecute(t,i),this.recordsReloader(t.refreshType)}resolvePromptParams(t,i,s){return new Promise((e=>{let n=[];t.actionConfig.params.promptParam.forEach((t=>{n.push(this.buildPromptParam(t))})),this.putParamsOnExecSource(n,i),s&&this.saveLastValues(t,n),e()}))}buildPromptParam(t){let i,s,e=t.paramType,n=!1,o=t.value;switch(e){case f.DATE:e="D";break;case f.DATETIME:e="H";break;case f.DECIMAL:e="F",i={"sk-precision":Number(t.precision)};break;case f.BOOLEAN:e="S",n=!0,o=t.value?"S":"N";break;case f.ENTITY:i={"sk-entity-name":t.entityName,"sk-allow-show-hierarchical-mode":t.hierarchyEntity,"sk-data-type":"S"},t.hierarchyEntity&&t.entityPK&&(s=t.entityPK),o=t.value?Number(t.value):null;break;case f.OPTIONS:e="O";let r=t.options.split(";").map((function(t,i){let s,e;if(t.indexOf("=")>-1){let i=t.split("=");s=i[0],e=i[1]}else s=i+1,e=t;return{data:s,value:e}}));i={"sk-options":r}}return{description:t.label,required:"true"==t.required,fieldName:t.name,fieldNameOri:t.name,entityPK:s,paramType:t.paramType,type:e,isCheckbox:n,saveLast:t.saveLast,fieldProp:i,value:o,isGeneratedName:t.isGeneratedName}}putParamsOnExecSource(t,i){i.params={param:[]},t.forEach((t=>{if(t.isGeneratedName&&t.value)throw new a(this._application.messagesBuilder.getMessage("snkActionsButton.title.error",void 0),this._application.messagesBuilder.getMessage("snkActionsButton.action.emptyParamName",void 0));r.isEmpty(t.value)||i.params.param.push({type:this.getParamDataType(t.paramType),paramName:t.fieldName,$:this.getParamValue(t)})}))}getParamDataType(t){let i;switch(t){case"D":i="F";break;case"DT":case"DH":i="D";break;case"B":case"ENTITY":case"SO":i="S";break;default:i=t}return i}getParamValue(t){let i=t.value;return i?("DT"==t.paramType?i=d.formatDate(i):"DH"==t.paramType&&(i=d.formatDateTime(i)),i):i}async loadLastValues(t){const i=await this.buildResourceId(t.actionID);return new Promise(((t,s)=>{if(this._lastValuesCache[i])t(this._lastValuesCache[i]);else{const e={config:{chave:i,tipo:"T"}};g.get().callServiceBroker("SystemUtilsSP.getConf",e).then((s=>{var e,n;let o;(null===(n=null===(e=s.config)||void 0===e?void 0:e.data)||void 0===n?void 0:n.params)&&(o=s.config.data.params,Array.isArray(o.param)||(o.param=[o.param])),this._lastValuesCache[i]=o,t(o)})).catch((t=>{s(t)}))}}))}async saveLastValues(t,i){if(this._application){let s={params:{param:[]}};i.forEach((t=>{"true"==t.saveLast&&s.params.param.push({paramName:t.fieldName,$:t.value})}));const e=await this.buildResourceId(t.actionID);this._lastValuesCache[e]=s.params,this._application.saveConfig(e,s)}}async buildResourceId(t){return this._appResourceId+".actionconfig."+t}prepareAndExecute(t,i){this.addRows(t),i(t)}addRows(t){const i={row:[]},s=this._selectedRows;for(const t in s){const e=s[t],n={};e.hasOwnProperty(O)&&(n.master="S",n.entityName=e.__ENTITY_NAME__,delete e[O],delete e.__ENTITY_NAME__);for(const t in e)"NUFIN"===t&&(n.field||(n.field=[]),n.field.push({fieldName:t,$:e[t]}));i.row.push(n)}i.row.length>0&&(t.rows=i)}recordsReloader(t){switch(t){case z.NONE:break;case z.PARENT:case z.MASTER:case z.ALL:this._dataUnit.loadData();break;default:this._dataUnit.reloadCurrentRecord()}}buildVirtualPage(){var t,i,s,e;if(null===(i=null===(t=this._dataUnit)||void 0===t?void 0:t.getSelectionInfo())||void 0===i?void 0:i.isAllRecords())return{filters:{filters:null===(s=this._dataUnit)||void 0===s?void 0:s.getAppliedFilters()},orders:{orders:null===(e=this._dataUnit)||void 0===e?void 0:e.getSort()}}}}class P{async clientConfirm(t,i){return new Promise((s=>{const e=o.getContextValue("__SNK__APPLICATION__");let n="";t.content.event.hasOwnProperty("stpCall")?(i.requestBody=t.content.event.stpCall,n=S.PROCEDURE):t.content.event.hasOwnProperty("runScript")?(i.requestBody=t.content.event.runScript,n=S.JAVASCRIPT):t.content.event.hasOwnProperty("javaCall")&&(i.requestBody=t.content.event.javaCall,n=S.JAVA);let r={type:"S",sequence:t.content.event.sequence};i.requestBody.params?Array.isArray(i.requestBody.params.param)||(i.requestBody.params.param=[i.requestBody.params.param]):i.requestBody.params={param:[]},i.requestBody.params.param.push(r);const a=t.content.event.title.$,c=t.content.event.message.$;let l;switch(n){case S.JAVASCRIPT:l={runScript:i.requestBody};break;case S.PROCEDURE:l={requestBody:{stpCall:i.requestBody}};break;case S.JAVA:l={requestBody:{javaCall:i.requestBody}}}if("S"==t.content.event.showNoOption){r.paramName="__ESCOLHA_SIMNAO__";const t=document.createElement("snk-client-confirm");window.document.body.appendChild(t),t.titleMessage=a,t.message=c,t.accept=async()=>{r.$="S",await i.reCall(l),s()},t.cancel=async()=>{r.$="N",await i.reCall(l),s()},t.openPopup()}else e.confirm(a,c,null,"warn",{labelCancel:"Cancelar",labelConfirm:"Sim"}).then((async t=>{t&&(r.paramName="__CONFIRMACAO__",r.$="S",await i.reCall(l),s())}))}))}}const D=class{constructor(i){t(this,i),this.CLIENT_EVENT_CONFIRM_NAME="br.com.sankhya.actionbutton.clientconfirm",this.handleClick=t=>{const i=this._actions.find((i=>i.actionID==t.detail.id)),s=new A(i.type).executor;new N(s,this._dataUnit,this._resourceID).execute(Object.assign({},i)),this._showDropdown=!1},this._items=[],this._showDropdown=!1,this._actions=[],this._isOrderActions=!1}async getActions(){let t={param:{entityName:this._entityName,resourceID:this._resourceID}};return g.get().callServiceBroker("ActionButtonsSP.getActions",t).then((t=>{var i;(null===(i=t.actions)||void 0===i?void 0:i.action)&&(this._actions=this._isOrderActions?h.sortAlphabetically(t.actions.action,"description"):t.actions.action)}))}controlDropdown(){this._showDropdown=!this._showDropdown}canShowDropdown(){var t;return this._showDropdown&&(null===(t=this._items)||void 0===t?void 0:t.length)>0}positionDropdown(){var t;const i=null===(t=this._ezButton)||void 0===t?void 0:t.getBoundingClientRect();i&&this._dropdownParent&&(this._dropdownParent.style.top=i.y+i.height+5+"px",this._dropdownParent.style.left=i.x+"px")}closeDropdown(t){const i=null==t?void 0:t.target;i&&(i.closest(".snk-actions-button")||(this._showDropdown=!1))}setEvents(){document.removeEventListener("click",this.closeDropdown.bind(this)),document.addEventListener("click",this.closeDropdown.bind(this)),document.removeEventListener("scroll",this.positionDropdown.bind(this)),document.addEventListener("scroll",this.positionDropdown.bind(this))}async componentWillLoad(){this._application=o.getContextValue("__SNK__APPLICATION__"),this._isOrderActions=await this._application.getBooleanParam("global.ordenar.acoes.personalizadas");const t=this._element.parentElement;this._dataUnit=null==t?void 0:t.dataUnit,this._resourceID=null==t?void 0:t.resourceID,this._entityName=this._dataUnit.name.split("/")[2],null==this._resourceID&&(this._resourceID=await m.getResourceID()),this.setEvents(),this.getActions().then((()=>{this.loadItems()}))}async componentDidLoad(){if(this._element&&(u.addIDInfo(this._element),this.positionDropdown(),!await this._application.hasClientEvent(this.CLIENT_EVENT_CONFIRM_NAME))){const t=new P;this._application.addClientEvent(this.CLIENT_EVENT_CONFIRM_NAME,t.clientConfirm)}}componentDidUpdate(){this.positionDropdown()}loadItems(){this._actions&&0!=this._actions.length&&this._actions.forEach((t=>{this._items.push({id:t.actionID,label:t.description})}))}getElementID(t){return{[u.DATA_ELEMENT_ID_ATTRIBUTE_NAME]:u.getInternalIDInfo(t)}}render(){return i(s,null,this._actions&&this._actions.length>0&&i("div",{class:`ez-padding-left--medium snk-actions-button\n ${this.canShowDropdown()?" ez-elevation--16":""}\n `},i("ez-button",Object.assign({ref:t=>this._ezButton=t,iconName:"acao",size:"small",mode:"icon",title:this._application.messagesBuilder.getMessage("snkActionsButton.title.actions",void 0),onClick:()=>this.controlDropdown()},this.getElementID("button"))),i("div",Object.assign({ref:t=>this._dropdownParent=t,class:(this.canShowDropdown()?"snk-actions-button__dropdown--show":"snk-actions-button__dropdown")+"\n "},this.getElementID("dropdown")),this.canShowDropdown()&&i("ez-dropdown",Object.assign({items:this._items,onEzClick:t=>this.handleClick(t)},this.getElementID("dropdown"))))),this.canShowDropdown()&&i("div",Object.assign({class:"ez-scrim ez-scrim--light"},this.getElementID("ezScrim"))))}get _element(){return e(this)}};D.style=".sc-snk-actions-button-h{display:flex;width:fit-content;height:fit-content}.snk-actions-button.sc-snk-actions-button{display:flex;width:fit-content;height:fit-content}.snk-actions-button__dropdown--show.sc-snk-actions-button{display:flex;flex-direction:column;position:fixed}.snk-actions-button__dropdown.sc-snk-actions-button>ez-dropdown.sc-snk-actions-button{position:relative}.snk-actions-button__dropdown.sc-snk-actions-button{display:none}";const I=class{constructor(i){t(this,i),this.configChange=n(this,"configChange",7),this.configCancel=n(this,"configCancel",7),this._orderListItems=[],this._orderPriorityList=[],this._columListItems=[],this._selectedIndex=-1,this._dataChanged=!1,this._componenteInternalKey=Date.now(),this.selectedIndex=0,this.columns=void 0,this.config=void 0,this.configName=void 0,this.resourceID=void 0}getMessage(t,i){return o.getContextValue("__SNK__APPLICATION__").messagesBuilder.getMessage(t,i)}getSortableColumns(){let t=[];return this.columns.filter((t=>{var i;return r.getBooleanValue(null===(i=null==t?void 0:t.props)||void 0===i?void 0:i.get("sortable"),!0)})).forEach((i=>{var s;let e=null===(s=this.config)||void 0===s?void 0:s.columns.find((t=>t.name===i.name)),n={name:i.name,label:i.label};e&&(n.orderIndex=e.orderIndex,n.ascending=e.ascending),i.hidden||t.push(n)})),t}createOrderList(){let t=this.getSortableColumns();t.sort(((t,i)=>0!=t.orderIndex||0!=i.orderIndex||null==t.ascending&&null==i.ascending?null!=t.ascending&&null!=i.ascending?t.orderIndex-i.orderIndex:null!=t.ascending||null!=i.ascending?null!=t.ascending?-1:null!=i.ascending?1:0:t.orderIndex-i.orderIndex:null!=t.ascending?-1:null!=i.ascending?1:0)),this._orderListItems=t}createColumnList(){let t={group:this.getMessage("snkGridConfig.group.visible"),items:[]},i={group:this.getMessage("snkGridConfig.group.hidden"),items:[],sort:_.asc.value};this.columns.forEach((s=>{let e={label:s.label};s.hidden?i.items.push(e):t.items.push(e)})),this._columListItems=[t,i]}createColumnListSlotDataElementId(t){return`configItem_${r.replaceAccentuatedChars(r.toCamelCase(t.label))}`}buildColumnListSlot(t,s){const e=this.createColumnListSlotDataElementId(t);return i("div",null,i("ez-check",{mode:b.SWITCH,id:b.SWITCH+((null==t?void 0:t.label)||"")+((null==s?void 0:s.group)||""),value:s.group===this.getMessage("snkGridConfig.group.visible"),"data-element-id":e,onEzChange:i=>{this.switchColumnGroup(i,t)}}))}createOrderListSlotDataElementId(t){return`${this._element.getAttribute(u.DATA_ELEMENT_ID_ATTRIBUTE_NAME)}_configItem_${r.toCamelCase(t.label)}`}buildOrderListSlot(t){const s=this.createOrderListSlotDataElementId(t);let e=_.none.value;return null!=(null==t?void 0:t.ascending)&&(e=1==t.ascending?_.asc.value:_.desc.value),i("div",null,i("snk-select-box",{selectedOption:e,key:"snk-select-box-"+this._componenteInternalKey+"-"+t,"data-element-id":s,onEzChange:i=>{i.stopPropagation(),this.updateOrder(i.detail,t.label)}}))}updateOrder(t,i){var s;this._dataChanged=!0;let e,n=[...this.columns],o=n.find((t=>t.label===i));o&&(o.sort=t.value===_.none.value?void 0:t.value),(null===(s=this._orderPriorityList)||void 0===s?void 0:s.length)>0?(this._orderPriorityList.find((t=>t.label===o.label)).sort=t,this._orderPriorityList.filter((t=>t.sort)).forEach(((t,i)=>{t.label===o.label&&(o.sortIndex=i)}))):(e=n.filter((t=>t.sort&&!0!==t.hidden)).map(((t,i)=>({label:t.label,orderIndex:i}))),e.forEach((t=>{n.find((i=>i.label===t.label)).sortIndex=t.orderIndex}))),this.columns=n}switchColumnGroup(t,i){t.stopPropagation();let s=[...this._columListItems];if(this._dataChanged=!0,!0===t.detail){let t=s.find((t=>t.group===this.getMessage("snkGridConfig.group.hidden"))),e=t.items.findIndex((t=>t.label===i.label));e>=0&&t.items.splice(e,1),s.find((t=>t.group===this.getMessage("snkGridConfig.group.visible"))).items.push(i),this._columListItems=s,this.createOrderList()}else if(!1===t.detail){let t=s.find((t=>t.group===this.getMessage("snkGridConfig.group.visible"))),e=t.items.findIndex((t=>t.label===i.label));e>=0&&t.items.splice(e,1),s.find((t=>t.group===this.getMessage("snkGridConfig.group.hidden"))).items.push(i),this._columListItems=s,this.createOrderList()}}finish(){if(!this._dataChanged)return void this.closeConfig();let t=[];this._columListItems.forEach((i=>{i.items.forEach((s=>{const e=this.columns.find((t=>t.label===s.label));let n=Object.assign({},e);n.hidden=i.group===this.getMessage("snkGridConfig.group.hidden"),t.push(n)}))})),this.columns=t,this._dataChanged=!1,this.closeConfig(),this.save()}saveGridConfigOnStorage(t){k.saveGridConfig(t,this.configName,this.resourceID).then((t=>{this.configChange.emit(t),this._orderList.clearHistory(),p.info(this.getMessage("snkGridConfig.info.successfullyConfigSaved"),{iconName:"check"})}))}reOrderPriorityColumns(t,i){let s=[];s=t.filter((t=>t.sort&&!0!==t.hidden)).map((t=>({label:t.label,orderIndex:0})));let e=0,n=[];return i.forEach((t=>{let i=s.find((i=>i.label===t.label));i&&(i.orderIndex=e,n.push(i),e++)})),n.length>0&&(s=n),s}save(){var t;let i;i=this.config?this.config:this.createConfigFromState(this.columns);let s,e=[];(null===(t=this._orderPriorityList)||void 0===t?void 0:t.length)>0&&(s=this.reOrderPriorityColumns(this.columns,this._orderPriorityList)),this.columns.forEach((t=>{let n=i.columns.find((i=>t.name===i.name));!0===t.hidden&&n||(n?n.width=t.width:!1===t.hidden&&(n={name:t.name,width:t.width,orderIndex:0}),n&&(t.sort?(n.ascending=t.sort.toUpperCase()===_.asc.value,s?function(t,i){if(s){let e=s.find((i=>i.label===t.label));e&&(i.orderIndex=e.orderIndex)}}(t,n):n.orderIndex=t.sortIndex):(delete n.ascending,n.orderIndex=0),e.push(n)))})),i.columns=e,this.saveGridConfigOnStorage(i)}createConfigFromState(t){let i={columns:[]};return t.forEach((t=>{if(!t.hidden){let s={name:t.name};t.width&&(s.width=t.width),t.sort?(s.ascending=t.sort.toUpperCase()===_.asc.value,s.orderIndex=t.sortIndex):s.orderIndex=0,s&&i.columns.push(s)}})),i}async locateColumn(t,i){var s;const e="Enter"===t.key;if(!(i=i||(null===(s=t.currentTarget)||void 0===s?void 0:s.value)))return void this.removeSelection();const n=await this.getMatchedIndexes(i),o=this.getNewSelectedIndex(n,e);this._selectedIndex=o,1===this.selectedIndex?this.updateOrderListSelection(o):this.updateColumnListSelection(o)}async getMatchedIndexes(t){const i=[];return 1===this.selectedIndex?(await this._orderList.getList()).forEach(((s,e)=>{this.compareWords(s,t)&&i.push(e)})):this.columns.forEach(((s,e)=>{this.compareWords(s,t)&&i.push(e)})),i}getNewSelectedIndex(t,i){if(0===t.length)return-1;if(i)for(const i of t)if(i>this._selectedIndex)return i;return t[0]}updateOrderListSelection(t){-1!==t?this._orderList.getList().then((i=>{const s=i[t];s?this._orderList.setSelection(s,!0):this._orderList.removeSelection()})):this._orderList.removeSelection()}updateColumnListSelection(t){if(-1===t)return void this._columnList.removeSelection();const i=this.columns[t];if(i){const t=this._columListItems.map((t=>t.items)).flat().find((t=>t.label===i.label));t?this._columnList.setSelection(t,!0):this._columnList.removeSelection()}else this._columnList.removeSelection()}removeSelection(){1===this.selectedIndex?this._orderList.removeSelection():this._columnList.removeSelection()}compareWords(t,i){var s,e;const n=null===(s=r.replaceAccentuatedChars(null==t?void 0:t.label))||void 0===s?void 0:s.toUpperCase(),o=null===(e=r.replaceAccentuatedChars(i))||void 0===e?void 0:e.toUpperCase();return!r.isEmpty(n)&&!r.isEmpty(o)&&n.includes(o)}getColumnNames(){const t=[];return t.push(this.getMessage("snkGridConfig.tab.columns")),t.push(this.getMessage("snkGridConfig.tab.lineOrdering")),t.join(",")}closeConfig(){if(this._orderList.scrollToTop(),this._columnList.scrollToTop(),this._searchElement.value="",this._dataChanged){let t={canClose:!1,labelCancel:this.getMessage("snkGridConfig.confirm.cancel"),labelConfirm:this.getMessage("snkGridConfig.confirm.save"),btnConfirmDanger:!1};p.confirm(this.getMessage("snkGridConfig.confirm.alert"),this.getMessage("snkGridConfig.confirm.msgCancel"),null,v.WARN,t).then((t=>{t?this.finish():(this._dataChanged=!1,this.configCancel.emit(),this._orderList.clearHistory(),this._componenteInternalKey=Date.now())}))}else this.configCancel.emit(),this._orderList.clearHistory()}handleTabChange(t){null!=(null==t?void 0:t.index)&&(this.selectedIndex!==t.index&&(0===t.index?this._orderList.scrollToTop():1===t.index&&this._columnList.scrollToTop(),this._searchElement.value=""),1===t.index&&this.createOrderList(),this.selectedIndex=t.index)}handleColumnListChange(t){var i;if(t.detail){let s=null===(i=t.detail.find((t=>t.group===this.getMessage("snkGridConfig.group.visible"))))||void 0===i?void 0:i.items;s&&(this._dataChanged=!0,this._orderListItems=s)}}handleOrderListChange(t){if(t.detail){let i=t.detail;i&&(this._dataChanged=!0,this._orderPriorityList=i)}}componentWillRender(){var t;(null===(t=this.columns)||void 0===t?void 0:t.length)>0&&this.createColumnList()}componentDidRender(){var t;(null===(t=this.columns)||void 0===t?void 0:t.length)>0&&this.locateColumn(new KeyboardEvent("arrow-right",{key:"ArrowRight"}),this._searchElement.value)}componentDidLoad(){u.addIDInfo(this._element)}render(){return i(s,null,i("div",{class:"grid-config__header"},i("div",{class:"title-container"},i("div",{class:""},i("label",{class:"title"},this.getMessage("snkGridConfig.gridConfiguration")),i("label",{class:"subtitle"},this.getMessage("snkGridConfig.columnVisibilityOrder"))),i("div",{class:"button-close"},i("ez-button",{mode:"icon",iconName:"close",size:"medium",onClick:()=>this.closeConfig()}))),i("div",{class:"tabselector-container"},i("ez-tabselector",{selectedIndex:this.selectedIndex,onEzChange:t=>{this.handleTabChange(t.detail)},tabs:this.getColumnNames()})),i("div",null,i("ez-text-input",{"data-element-id":"searchColums",ref:t=>this._searchElement=t,label:this.getMessage("snkGridConfig.findColumn"),onKeyUp:t=>this.locateColumn(t)},i("ez-icon",{slot:"leftIcon",size:"medium",iconName:"search"})))),i("div",{class:"grid-config__main"},i("ez-list",{ref:t=>this._columnList=t,class:0===this.selectedIndex?"":"hidden",dataSource:this._columListItems,onEzChange:t=>this.handleColumnListChange(t),ezDraggable:!0,ezSelectable:!0,itemSlotBuilder:(t,i)=>this.buildColumnListSlot(t,i),useGroups:!0,"data-element-id":"configCols"}),i("div",{class:1===this.selectedIndex?"group-name":"hidden"},this.getMessage("snkGridConfig.info.sortingSequence")),i("ez-list",{ref:t=>this._orderList=t,class:1===this.selectedIndex?"height-calc":"hidden",dataSource:this._orderListItems,ezSelectable:!0,onEzChange:t=>this.handleOrderListChange(t),ezDraggable:!0,itemSlotBuilder:t=>this.buildOrderListSlot(t),"data-element-id":"configDataOrder"})),i("div",{class:"grid-config__footer"},i("ez-button",{class:"padding-right--medium",label:this.getMessage("snkGridConfig.cancel"),onClick:()=>this.closeConfig()}),i("ez-button",{label:this.getMessage("snkGridConfig.complete"),class:"ez-button--primary",onClick:()=>this.finish()})))}static get assetsDirs(){return["../assets"]}get _element(){return e(this)}};I.style='.sc-snk-grid-config-h{--snk-grid-config__footer--padding-top:var(--space--medium, 12px);--snk-grid-config__main--padding-right:var(--space--medium, 12px);--snk-grid-config__tabselector-container--padding:var(--space--medium, 12px);--snk-grid-config__button-close--padding-left:var(--space--medium, 12px);--snk-grid-config__title--color:var(--title--primary, #2B3A54);--snk-grid-config__title--font-family:var(--font-pattern, "Roboto");--snk-grid-config__title--font-size:var(--title--large, 20px);--snk-grid-config__title--font-weight:var(--text-weight--extra-large, 700);--snk-grid-config__subtitle--font-family:var(--font-pattern, "Roboto");--snk-grid-config__subtitle--font-size:var(--text--medium, 14px);--snk-grid-config__group--font-family:var(--font-pattern, "Roboto");--snk-grid-config__group--font-size:var(--text--medium, 14px);--snk-grid-config__group--font-weight:var(--text-weight--large, 600);--snk-grid-config__group--padding-bottom:var(--space-small, 6px);--snk-grid-config__scrollbar--color-default:var(--scrollbar--default, #626e82);--snk-grid-config__scrollbar--color-background:var(--scrollbar--background, #E5EAF0);--snk-grid-config__scrollbar--color-hover:var(--scrollbar--hover, #2B3A54);--snk-grid-config__scrollbar--color-clicked:var(--scrollbar--clicked, #a2abb9);--snk-grid-config__scrollbar--border-radius:var(--border--radius-small, 6px);--snk-grid-config__scrollbar--width:var(--space--medium, 12px);display:grid;grid-template-rows:auto 1fr auto;max-height:100%;width:100%}@media screen and (min-width: 480px){.sc-snk-grid-config-h{width:359px;max-width:359px}}.padding-right--medium.sc-snk-grid-config{padding-right:var(--space--medium)}ez-list.sc-snk-grid-config{height:100%}.height-calc.sc-snk-grid-config{max-height:calc(100% - 24px)}.grid-config__footer.sc-snk-grid-config{display:flex;justify-content:flex-end;width:100%;padding-top:var(--snk-grid-config__footer--padding-top)}.hidden.sc-snk-grid-config{display:none}.tabselector-container.sc-snk-grid-config{padding:var(--snk-grid-config__tabselector-container--padding) 0}.button-close.sc-snk-grid-config{padding-left:var(--snk-grid-config__button-close--padding-left)}.title-container.sc-snk-grid-config{display:flex;justify-content:space-between;align-items:center;width:100%}.title.sc-snk-grid-config{display:flex;margin:0;line-height:normal;letter-spacing:0em;text-align:left;color:var(--snk-grid-config__title--color);font-size:var(--snk-grid-config__title--font-size);font-family:var(--snk-grid-config__title--font-family);font-weight:var(--snk-grid-config__title--font-weight)}.subtitle.sc-snk-grid-config{color:var(--text--primary);font-size:var(--snk-grid-config__subtitle--font-size);font-family:var(--snk-grid-config__subtitle--font-family)}.grid-config__main.sc-snk-grid-config{overflow-y:auto;scrollbar-width:thin;scrollbar-color:var(--snk-grid-config__scrollbar--color-clicked) var(--snk-grid-config__scrollbar--color-background);padding-right:var(--snk-grid-config__main--padding-right)}.grid-config__main.sc-snk-grid-config::-webkit-scrollbar{width:var(--snk-grid-config__scrollbar--width);max-width:var(--snk-grid-config__scrollbar--width);min-width:var(--snk-grid-config__scrollbar--width);background-color:var(--snk-grid-config__scrollbar--color-background)}.grid-config__main.sc-snk-grid-config::-webkit-scrollbar-track{background-color:var(--snk-grid-config__scrollbar--color-background);border-radius:var(--snk-grid-config__scrollbar--border-radius)}.grid-config__main.sc-snk-grid-config::-webkit-scrollbar-thumb{background-color:var(--snk-grid-config__scrollbar--color-default);border-radius:var(--snk-grid-config__scrollbar--border-radius)}.grid-config__main.sc-snk-grid-config::-webkit-scrollbar-thumb:vertical:hover,.grid-config__main.sc-snk-grid-config::-webkit-scrollbar-thumb:horizontal:hover{background-color:var(--snk-grid-config__scrollbar--color-hover)}.grid-config__main.sc-snk-grid-config::-webkit-scrollbar-thumb:vertical:active,.grid-config__main.sc-snk-grid-config::-webkit-scrollbar-thumb:horizontal:active{background-color:var(--snk-grid-config__scrollbar--color-clicked)}.group-name.sc-snk-grid-config{font-family:var(--snk-grid-config__group--font-family);font-size:var(--snk-grid-config__group--font-size);font-weight:var(--snk-grid-config__group--font-weight);padding-bottom:var(--snk-grid-config__group--padding-bottom)}';const E=class{constructor(i){t(this,i),this.ezChange=n(this,"ezChange",7),this.selectedOption=_.none}render(){return i("ez-combo-box",{class:"grid-config-combo ez-input--inverted",label:"",suppressSearch:!0,value:this.selectedOption,enabled:!0,canShowError:!1,suppressEmptyOption:!0},Object.keys(_).map((t=>i("option",{value:_[t].value},_[t].label))))}static get assetsDirs(){return["../assets"]}};E.style="ez-combo-box{width:100px}.grid-config-combo{--ez-text-input--height:28px;--ez-text-input__input--background-color:#fff;--ez-text-input__input--border-color:#dce0e8}";const j=class{constructor(i){t(this,i),this.taskbarActionSelected=n(this,"taskbarActionSelected",7),this.taskbarActionsOpened=n(this,"taskbarActionsOpened",7),this.taskbarActionsButtonDisconnected=n(this,"taskbarActionsButtonDisconnected",7),this._showDropdown=!1,this.title=void 0,this.enabled=void 0,this.actions=void 0}async handleKeyDown(t){"Escape"!==t.key&&"Esc"!==t.key||await this.hideActions()}async handleClose(){await this.hideActions()}async showActions(){this._showDropdown=!0,requestAnimationFrame((()=>{this._element.scrollIntoView({behavior:"smooth",block:"nearest",inline:"nearest"})}))}async hideActions(){this._showDropdown=!1}async isOpened(){return this._showDropdown}controlDropdown(){this._showDropdown=!this._showDropdown}loadItems(){return this.actions.filter((t=>void 0!==t)).map((t=>{var i;return{id:t.value,label:t.label,value:t.value,type:null!==(i=t.type)&&void 0!==i?i:"item",children:t.children,iconName:t.iconName,subAction:t.subAction,group:t.group,disableCloseOnSelect:t.disableCloseOnSelect}}))}canShowDropdown(){var t;return this._showDropdown&&(null===(t=this.actions)||void 0===t?void 0:t.length)>0}onSelectAction(t){const i=this.actions.map((t=>Object.assign(Object.assign({},t),{id:t.value}))),s=this.getSelectedAction(t.id,i);this.taskbarActionSelected.emit(s),s.disableCloseOnSelect||(this._showDropdown=!1)}getSelectedAction(t,i){let s=null;for(const e of i){if(e.id===t){s=e;break}if((null==e?void 0:e.children)&&(s=this.getSelectedAction(t,e.children),s))break}return s}dropdownItemBuilder(t,s){const e=this.actions.find((i=>i.value===t.id));if(!e||!e.itemBuilder)return;const n=e.itemBuilder(this._element,e);return"string"==typeof n?i("div",{innerHTML:n}):n}initializeEagerItems(){var t;null===(t=this.actions)||void 0===t||t.forEach((t=>{var i;t&&t.eagerInitialize&&t.itemBuilder&&(null===(i=t.itemBuilder)||void 0===i||i.call(t,this._element,t))}))}componentDidLoad(){this.initializeEagerItems()}componentDidRender(){this._showDropdown&&this.taskbarActionsOpened.emit(this._element)}disconnectedCallback(){this.taskbarActionsButtonDisconnected.emit()}render(){return i(s,null,i("div",{class:this.canShowDropdown()?" ez-elevation--16":""},i("ez-button",{title:this.title,mode:"icon",iconName:"dots-vertical",size:"small",enabled:this.enabled,onClick:()=>this.controlDropdown()}),this.canShowDropdown()&&i("ez-dropdown",{items:this.loadItems(),onEzClick:t=>this.onSelectAction(t.detail),onEzOutsideClick:()=>this._showDropdown=!1,itemBuilder:(t,i)=>this.dropdownItemBuilder(t,i)})))}get _element(){return e(this)}};j.style=".sc-taskbar-actions-button-h{display:flex;width:fit-content;height:fit-content}";export{D as snk_actions_button,I as snk_grid_config,E as snk_select_box,j as taskbar_actions_button}
|
@@ -1 +0,0 @@
|
|
1
|
-
import{JSUtils as n,DataType as o}from"@sankhyalabs/core";const t=t=>{const e=t.getSelectionInfo();if(null==e?void 0:e.isAllRecords())return[];const l=[],r=null==e?void 0:e.recordIds;return(null==r?void 0:r.length)>0&&r.forEach((e=>{if(!t.isNewRecord(e)){if(!n.isBase64(e))return void l.push({name:"__record__id__",type:o.TEXT,value:e});const r=JSON.parse(window.atob(e));Object.entries(r).forEach((([n,o])=>{const e=null==t?void 0:t.getField(n);null!=e&&l.push(Object.assign({name:n,type:e.dataType},o))}))}})),l};export{t as g}
|
@@ -1 +0,0 @@
|
|
1
|
-
import{r as t,c as i,h as s,g as e,H as a}from"./p-d2d301a6.js";import{Action as n,ObjectUtils as h,DataUnitAction as r,StringUtils as o,ApplicationContext as d}from"@sankhyalabs/core";import{ApplicationUtils as l,DialogType as c}from"@sankhyalabs/ezui/dist/collection/utils";import{O as u,S as v}from"./p-7c4aabe2.js";import{g as m,a as f}from"./p-091ce761.js";import{g as b}from"./p-9863d682.js";import{convertType as p}from"@sankhyalabs/core/dist/dataunit/metadata/DataType";const D=class{constructor(s){t(this,s),this.dataStateChange=i(this,"dataStateChange",3),this.dataUnitReady=i(this,"dataUnitReady",3),this.messagesBuilderUpdated=i(this,"messagesBuilderUpdated",3),this.dataUnitFieldsHidded=i(this,"dataUnitFieldsHidded",7),this.insertionMode=i(this,"insertionMode",3),this.cancelEdition=i(this,"cancelEdition",3),this._onDataUnitResolve=[],this._openedAlert=!1,this._fieldsWithRmp=[],this._fieldsWithRmPrecision=[],this._metadataByRow=new Map,this._rowMetadataCache=new Map,this.REGEX_DATAUNIT_NAME=/dd:\/\/(.+?)\//,this._dataUnitObserver=async t=>{const i=this.buildDataState(t.type);switch(this.dataState=i,this.messagesBuilder.currentOperation=this.getMessageOperation(),t.type){case n.DATA_SAVED:await this.handleDataSaved(t);break;case n.RECORDS_ADDED:case n.RECORDS_COPIED:this.insertionMode.emit();break;case n.EDITION_CANCELED:this.cancelEdition.emit();break;case n.RECORDS_REMOVED:this.handleRecordsRemoved(t);break;case n.METADATA_LOADED:this.fillFieldsWithRmp(this.dataUnit.metadata),this.fillFieldsWithRmPrecision(this.dataUnit.metadata)}},this.fieldsToLink=[],this.dataState=void 0,this.messagesBuilder=void 0,this.dataUnitName=void 0,this.entityName=void 0,this.pageSize=150,this.dataUnit=void 0,this.beforeSave=void 0,this.afterSave=void 0,this.useCancelConfirm=!0,this.ignoreSaveMessage=void 0,this.configName=void 0,this.resourceID=void 0,this.domainMessagesBuilder=void 0}observePageSize(){this.dataUnit&&(this.dataUnit.pageSize=this.pageSize)}observeDataUnitName(t,i){i!=t&&(this.dataUnit?this._application.updateDataunitCache(i,this.dataUnitName,this.dataUnit):this.loadDataUnit())}observeEntityName(t,i){i!=t&&(this.dataUnit=void 0,this.entityName=t,this.loadDataUnit())}observeDataState(t,i){h.objectToString(i)!=h.objectToString(t)&&this.dataStateChange.emit(t)}observeDataUnit(){this.handlerLinkFields(),this.dataUnitReady.emit(this.dataUnit)}observeMessagesBuilder(t){t&&this.messagesBuilderUpdated.emit(t)}async getDataUnit(){return new Promise((t=>{this.dataUnit?t(this.dataUnit):this._onDataUnitResolve.push(t)}))}async getSelectedRecordsIDsInfo(){return Promise.resolve(b(this.dataUnit))}async getFieldsWithRmp(){return this._fieldsWithRmp}async getFieldsWithRmPrecision(){return this._fieldsWithRmPrecision}async getRowMetadata(t){return this.doGetRowMetadata(t)}doGetRowMetadata(t){const i=this.dataUnit.getSelectedRecord();if(!t&&!i)return;const s=t||i,e=this._metadataByRow.get("string"==typeof s?s:s.__record__id__);return e?(e.getProp=this.buildGetPropRowMetadata(e),Object.assign({},e)):void 0}buildGetPropRowMetadata(t){return(i,s)=>("rm_precision"===i&&(i=this.resolvePrecisionFromMetadata(s)),h.getProp(t,i))}resolvePrecisionFromMetadata(t){var i,s;if(!t)return void l.error(this.getMessage("snkDataUnit.fieldNameRequired"));const e=null===(s=null===(i=this.dataUnit.getField(t))||void 0===i?void 0:i.properties)||void 0===s?void 0:s.rm_precision;return e?e.split(".").filter(((t,i)=>1!==i)).join("."):""}getCleanOnCopyFields(){var t;return null===(t=this.dataUnit.metadata)||void 0===t?void 0:t.fields.filter((t=>{var i;return null===(i=t.properties)||void 0===i?void 0:i.cleanOnCopy})).map((t=>t.name))}fillFieldsWithRmp(t){t.fields.forEach((t=>{var i;(null===(i=t.properties)||void 0===i?void 0:i.rmp)&&!this._fieldsWithRmp.includes(t.name)&&this._fieldsWithRmp.push(t.name)}))}fillFieldsWithRmPrecision(t){t.fields.forEach((t=>{var i;(null===(i=t.properties)||void 0===i?void 0:i.rm_precision)&&!this._fieldsWithRmPrecision.includes(t.name)&&this._fieldsWithRmPrecision.push(t.name)}))}getCacheName(t,i,s){return[t,i,s].join("_")}updateDataStateRmp(t){const i=Object.assign({},t);this.dataState.rowMetadata=i}saveCacheRmd(t){const i=t.__record__metadata__,s=Object.keys(i);s.shift(),s.forEach((s=>{const e=m(t,s),a=this.getCacheName(s,i.provider,e);this._rowMetadataCache.set(a,Object.assign({},i))}))}getMetadataByRow(t){var i;if(!(null===(i=t.records)||void 0===i?void 0:i.length))return t;if(!this._fieldsWithRmp.length){const i=t.records.map((t=>(delete t.__record__metadata__,t)));return Object.assign(Object.assign({},t),{records:i})}const s=t.records.map((t=>{if(!t.__record__metadata__)return t;this.saveCacheRmd(t);const i=Object.assign({},t.__record__metadata__);return i.getProp=this.buildGetPropRowMetadata(i),this._metadataByRow.set(t.__record__id__,i),delete t.__record__metadata__,t}));return Object.assign(Object.assign({},t),{records:s})}interceptRecordsAdded(t){if(this.isAllowed("INSERT"))return new r(n.RECORDS_ADDED,this.handleLinksWithParent(t.payload));l.info(this.getMessage("snkDataUnit.forbiddenInsert"))}interceptRecordsCopied(t){if(this.isAllowed("CLONE"))return new r(n.RECORDS_COPIED,this.handleRecordsCopied(t.payload));l.info(this.getMessage("snkDataUnit.forbiddenClone"))}async interceptDataChange(t){if(this.isAllowed("UPDATE"))return t;this._openedAlert?await this.dataUnit.cancelEdition():(this._openedAlert=!0,await this.dataUnit.cancelEdition(),await l.alert(this.getMessage("snkDataUnit.forbidden"),this.getMessage("snkDataUnit.forbiddenUpdate")),this._openedAlert=!1)}async interceptSavingData(t){if(!this.beforeSave)return t;const i=this.beforeSave(this.dataUnit);return i instanceof Promise?await i?t:void 0:i?t:void 0}interceptDataSaved(t){if(!this.afterSave)return t;this.afterSave(this.dataUnit)}async interceptEditionCanceled(t){var i,s;if(!this.useCancelConfirm||!this.dataState.hasDirtyRecords||(null===(i=t.payload)||void 0===i?void 0:i.fromParent)||(null===(s=t.payload)||void 0===s?void 0:s.silent))return t;const e=this.getMessage("snkDataUnit.cancelConfirmation");if(null==e)return this.showSuccessMessage(this.getMessage("snkDataUnit.cancelInfo")),t;const a=this.getMessage("snkDataUnit.cancelConfirmationTitle"),n=await l.confirm(a,e);return n&&this.showSuccessMessage(this.getMessage("snkDataUnit.cancelInfo")),n?t:void 0}async interceptRemovingRecords(t){var i,s,e;if(!this.isAllowed("REMOVE"))return void l.info(this.getMessage("snkDataUnit.forbiddenRemove"));let a=!1,n=!(null===(i=t.payload)||void 0===i?void 0:i.silent)&&this.getMessage("snkDataUnit.removeConfirmation");const h=null===(s=this.dataUnit)||void 0===s?void 0:s.getSelectionInfo();if(!(null===(e=t.payload)||void 0===e?void 0:e.silent)&&(null==h?void 0:h.length)>1&&(n=this.getMessage("snkDataUnit.removeAllConfirmation",{size:h.length}),a=!0),!n)return t;const r={canClose:!1,labelCancel:this.getMessage("snkDataUnit.confirm."+(a?"no":"cancel")),labelConfirm:this.getMessage("snkDataUnit.confirm."+(a?"yes":"delete")),btnConfirmDanger:!1},o=this.getMessage("snkDataUnit.removeConfirmationTitle");return await l.confirm(o,n,null,c.WARN,r)?t:void 0}interceptDataLoaded(t){const i=this.getMetadataByRow(t.payload);return new r(n.DATA_LOADED,i)}interceptMetadataLoaded(t){return this.fillFieldsWithRmp(t.payload),this.fillFieldsWithRmPrecision(t.payload),new r(n.METADATA_LOADED,this.handleDULinksOnMetadataLoaded(t.payload))}async interceptAction(t){switch(t.type){case n.RECORDS_ADDED:return this.interceptRecordsAdded(t);case n.RECORDS_COPIED:return this.interceptRecordsCopied(t);case n.DATA_CHANGED:return await this.handleLoadRowMetadata(t),await this.interceptDataChange(t);case n.CHANGING_DATA:return await this.interceptDataChange(t);case n.SAVING_DATA:return await this.interceptSavingData(t);case n.DATA_SAVED:return this.interceptDataSaved(t);case n.EDITION_CANCELED:return await this.interceptEditionCanceled(t);case n.REMOVING_RECORDS:return await this.interceptRemovingRecords(t);case n.DATA_LOADED:return this.interceptDataLoaded(t);case n.METADATA_LOADED:return this.interceptMetadataLoaded(t);default:return t}}async handleLoadRowMetadata(t){const i=t.type===n.DATA_CHANGED?t.payload:t.payload.changes[0].record,s=Object.keys(i).find((t=>this._fieldsWithRmp.includes(t)));if(s){const t=this.dataUnit.getField(s).properties.rmp,e=m(i,s);return await this.updateRowMetadata({fieldName:s,fieldValue:e,metadataName:t,updatedFields:i})}}async updateRowMetadata({fieldName:t,fieldValue:i,metadataName:s,updatedFields:e}){const a=this.getCacheName(t,s,i),n=this._rowMetadataCache.get(a);if(n)return this.updateDataStateRmp(n),n;{const i=new f,n=await i.loadRowMetadata(this,t,s,e);return this.updateDataStateRmp(n._rmd),this._rowMetadataCache.set(a,Object.assign({},n._rmd)),Object.assign({},n._rmd)}}handleDULinksOnMetadataLoaded(t){const i=Object.assign({},t);return this.processLinks(i),i}handleRecordsCopied(t){let i=[...t];return i=this.handleCleanOnCopy(i),this.handleLinksWithParent(i)}handleLinksWithParent(t){var i,s;const e=null!==(i=this._parentDataUnit)&&void 0!==i?i:null===(s=this.dataUnit)||void 0===s?void 0:s.getParentDataUnit();if(!e)return t;const a=e.getSelectedRecord(),n=null==e?void 0:e.getChildInfo(this.getCleanDataUnitName()),{links:h}=n;return h&&0!==h.length?t.map((t=>this.buildRecordWithLinkedFields(t,h,a))):t}buildRecordWithLinkedFields(t,i,s){const e=Object.assign({},t);return i.forEach((t=>{const i=p(this.dataUnit.getField(t.target).dataType,s[t.source]);e[t.target]=i})),e}handleCleanOnCopy(t){const i=this.getCleanOnCopyFields();return i.length>0&&(t=t.map((t=>this.buildCopyWithCleanedFields(t,i)))),t}buildCopyWithCleanedFields(t,i){const s=Object.assign({},t);return i.forEach((t=>delete s[t])),s}showSuccessMessage(t){l.info(t,{iconName:"check"})}isAllowed(t){return!!this._permissions&&(this._permissions.isSup||this._permissions[t])}buildDataState(t){var i;const s=this.dataUnit.getSelectionInfo(),e=(this.dataUnit.hasDirtyRecords()||this.dataUnit.hasWaitingChanges())&&(null==s?void 0:s.isEmpty()),a=this.dataUnit.getSelectedRecord();let h=null===(i=this.dataState)||void 0===i?void 0:i.rowMetadata;return!a||h&&![n.SELECTION_CHANGED,n.EDITION_CANCELED,n.NEXT_SELECTED,n.PREVIOUS_SELECTED].includes(t)?h&&(h.getProp=this.buildGetPropRowMetadata(h)):h=this.doGetRowMetadata(a),new w({insertionMode:this.dataUnit.hasNewRecord(),isStartingInsertionMode:e,hasNext:this.dataUnit.hasNext(),hasPrevious:this.dataUnit.hasPrevious(),copyMode:this.dataUnit.hasCopiedRecord(),isDirty:this.dataUnit.isDirty(),hasDirtyRecords:this.dataUnit.hasDirtyRecords(),selectedRecords:void 0,selectionInfo:s,selectedRecord:a,recordsIsEmpty:0===this.dataUnit.records.length,metadataByRow:this._metadataByRow,rowMetadata:h})}async handleDataSaved(t){const i=await this.handleLoadRowMetadata(t);if(i&&(i.getProp=this.buildGetPropRowMetadata(i)),this._metadataByRow.set(t.payload.records[0].__record__id__,i),this.dataState=this.buildDataState(),this.ignoreSaveMessage)return;const s=t.payload.changes[0]._operation.toLowerCase(),e=this.getMessage("snkDataUnit.saveInfo",t.payload.records[0],s);null!=e&&this.showSuccessMessage(e)}handleRecordsRemoved(t){var i,s;const e=t.payload.cachedRecords;let a;a=(null==e?void 0:e.length)>1?this.getMessage("snkDataUnit.removeAllInfo",{size:e.length}):this.getMessage("snkDataUnit.removeInfo",t.payload.cachedRecords[0]),null!=a&&this.showSuccessMessage(a);const n=null!==(s=null===(i=this.dataUnit.records)||void 0===i?void 0:i.length)&&void 0!==s?s:0,h=this.dataUnit.getPaginationInfo();h&&this.dataUnit.gotoPage(n>0||h.hasMore?h.currentPage:0)}getMessage(t,i,s){return i||(i=this.getMessageParams()),s&&(this.messagesBuilder.currentOperation=s),this.messagesBuilder.getMessage(t,i)}getMessageParams(){return this.dataState.selectedRecord}getMessageOperation(){return this.dataState.copyMode?u.CLONE:this.dataState.insertionMode||this.dataState.isStartingInsertionMode?u.INSERT:this.dataState.isDirty?u.UPDATE:u.CLEAN}async getDataUnitParentOrChild(){var t;const i=this.dataUnitName?this.dataUnitName:this.entityName;return this._parentSnkDataUnit?(this._parentDataUnit=await(null===(t=this._parentSnkDataUnit)||void 0===t?void 0:t.getDataUnit()),await this._application.getDataUnit(this.entityName,i,this._parentDataUnit,this.configName,this.resourceID)):await this._application.getDataUnit(this.entityName,i,null,this.configName,this.resourceID)}async loadDataUnit(){var t;if(null==this.dataUnit&&this._application&&this.entityName&&(this.dataUnit=await this.getDataUnitParentOrChild()),this.dataUnit){let i;for(this.dataUnit.pageSize=this.pageSize,this.dataUnit.unsubscribe(this._dataUnitObserver),this.dataUnit.addInterceptor(this),this.dataUnit.subscribe(this._dataUnitObserver),await this.dataUnit.loadMetadata(),(null===(t=this.dataUnit.records)||void 0===t?void 0:t.length)&&this.getMetadataByRow(this.dataUnit),this.dataState=this.buildDataState();i=this._onDataUnitResolve.pop();)i(this.dataUnit)}}getParentSnkDataUnit(){let t=this.element;for(;t.parentNode;){if("SNK-DATA-UNIT"===t.parentNode.nodeName)return t.parentNode;t=t.parentNode}}handlerLinkFields(){var t,i,s,e;const a=null!==(t=this._parentDataUnit)&&void 0!==t?t:null===(i=this.dataUnit)||void 0===i?void 0:i.getParentDataUnit();if(!a)return;const n=null!==(s=this.entityName)&&void 0!==s?s:this.getCleanDataUnitName(),h=a.getChildInfo(n);if(!h)return;const r=null===(e=null==h?void 0:h.links)||void 0===e?void 0:e.map((t=>t.target));this.handleDUWithLinks(r)}handleDUWithLinks(t){this.fieldsToLink=t;const i=Object.assign({},this.dataUnit.metadata);this.processLinks(i),this.dataUnit.metadata=i,this.dataUnitFieldsHidded.emit()}processLinks(t){var i;null===(i=null==t?void 0:t.fields)||void 0===i||i.forEach((t=>{var i;(null===(i=this.fieldsToLink)||void 0===i?void 0:i.includes(t.name))&&(t.visible=!1)}))}getCleanDataUnitName(){var t;const i=this.dataUnit.name;if(o.isEmpty(i))return i;const s=this.REGEX_DATAUNIT_NAME.exec(i);return null!==(t=null==s?void 0:s[1])&&void 0!==t?t:i}static getNearestInstance(t){let i=t.parentElement;for(;i;){if("SNK-DATA-UNIT"===i.tagName.toUpperCase())return i;i=i.parentElement}}instanceMessagesBuilder(){var t;this.messagesBuilder||(this.messagesBuilder=new v(null!==(t=this.domainMessagesBuilder)&&void 0!==t?t:this.entityName))}componentWillLoad(){this._application=d.getContextValue("__SNK__APPLICATION__"),this._application.getAllAccess(this.resourceID).then((t=>this._permissions=t)),this._parentSnkDataUnit=this.getParentSnkDataUnit(),this.instanceMessagesBuilder()}disconnectedCallback(){this.dataUnit&&this.dataUnit.releaseCallbacks()}async componentDidLoad(){await this.loadDataUnit(),this.handlerLinkFields()}render(){return s(a,null)}get element(){return e(this)}static get watchers(){return{pageSize:["observePageSize"],dataUnitName:["observeDataUnitName"],entityName:["observeEntityName"],dataState:["observeDataState"],dataUnit:["observeDataUnit"],messagesBuilder:["observeMessagesBuilder"]}}};class w{constructor(t){this.copyMode=t.copyMode,this.insertionMode=t.insertionMode,this.isStartingInsertionMode=t.isStartingInsertionMode,this.isDirty=t.isDirty,this.hasDirtyRecords=t.hasDirtyRecords,this.hasNext=t.hasNext,this.hasPrevious=t.hasPrevious,this.selectionInfo=t.selectionInfo,this.selectedRecord=t.selectedRecord,this.recordsIsEmpty=t.recordsIsEmpty,this.metadataByRow=t.metadataByRow,this.rowMetadata=t.rowMetadata}get selectedRecords(){var t;if(console.warn("SnkDataUnit: O método `selectedRecords` foi descontinuado. Use o método `selectionInfo`."),null===(t=this.selectionInfo)||void 0===t?void 0:t.isAllRecords())throw new Error("Erro interno: Impossível obter os registros selecionados. A seleção atual é virtual. Use o atributo `selectionInfo`.");return this.selectionInfo.records}}export{D as S}
|