@sankhyalabs/sankhyablocks 8.16.0-dev.97 → 8.16.0-dev.98
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/cjs/{ClientSideExporterProvider-9bd6fa5a.js → ClientSideExporterProvider-cc82b68a.js} +2 -3
- package/dist/cjs/{ConfigStorage-6b633b10.js → ConfigStorage-2235f35e.js} +1 -1
- package/dist/cjs/{pesquisa-fetcher-30cab386.js → ISave-62fbb1dd.js} +8 -0
- package/dist/cjs/{SnkFormConfigManager-d680be08.js → SnkFormConfigManager-6637cd6b.js} +2 -2
- package/dist/cjs/{auth-fetcher-24ba4135.js → auth-fetcher-abad589f.js} +1 -1
- package/dist/cjs/{form-config-fetcher-e0a512c3.js → form-config-fetcher-db332748.js} +14 -0
- package/dist/cjs/index-f9e81701.js +2 -2
- package/dist/cjs/loader.cjs.js +1 -1
- package/dist/cjs/pesquisa-grid_2.cjs.entry.js +3 -4
- package/dist/cjs/sankhyablocks.cjs.js +1 -1
- package/dist/cjs/{snk-actions-button_5.cjs.entry.js → snk-actions-button_7.cjs.entry.js} +63 -4
- package/dist/cjs/snk-application.cjs.entry.js +48 -5
- package/dist/cjs/snk-attach.cjs.entry.js +3 -4
- package/dist/cjs/snk-config-options_3.cjs.entry.js +3 -3
- package/dist/cjs/snk-configurator.cjs.entry.js +8 -1
- package/dist/cjs/snk-crud.cjs.entry.js +5 -5
- package/dist/cjs/snk-data-exporter.cjs.entry.js +2 -3
- package/dist/cjs/snk-detail-view.cjs.entry.js +5 -6
- package/dist/cjs/snk-filter-bar_4.cjs.entry.js +2 -2
- package/dist/cjs/snk-filter-modal-item.cjs.entry.js +2 -2
- package/dist/cjs/snk-grid.cjs.entry.js +4 -5
- package/dist/cjs/{snk-guides-viewer-c588a295.js → snk-guides-viewer-0e4f3b1a.js} +3 -4
- package/dist/cjs/snk-guides-viewer.cjs.entry.js +5 -6
- package/dist/cjs/snk-personalized-filter.cjs.entry.js +2 -2
- package/dist/cjs/snk-pesquisa.cjs.entry.js +9 -10
- package/dist/cjs/snk-simple-crud.cjs.entry.js +7 -7
- package/dist/collection/collection-manifest.json +2 -0
- package/dist/collection/components/snk-application/snk-application.js +41 -0
- package/dist/collection/components/snk-configurator/snk-configurator.js +26 -1
- package/dist/collection/components/snk-crud/snk-crud.js +20 -1
- package/dist/collection/components/snk-layout-form-config/snk-layout-form-config.css +3 -0
- package/dist/collection/components/snk-layout-form-config/snk-layout-form-config.js +73 -0
- package/dist/collection/components/snk-layout-form-config/snk-view-representation/snk-view-representation.css +78 -0
- package/dist/collection/components/snk-layout-form-config/snk-view-representation/snk-view-representation.js +57 -0
- package/dist/collection/components/snk-simple-crud/snk-simple-crud.js +20 -1
- package/dist/collection/lib/configs/LayoutFormConfig.js +25 -0
- package/dist/collection/lib/http/data-fetcher/fetchers/form-config-fetcher.js +14 -0
- package/dist/components/form-config-fetcher.js +14 -0
- package/dist/components/index.d.ts +2 -0
- package/dist/components/index.js +2 -0
- package/dist/components/snk-application2.js +45 -0
- package/dist/components/snk-attach2.js +34 -22
- package/dist/components/snk-configurator2.js +22 -2
- package/dist/components/snk-crud.js +76 -62
- package/dist/components/snk-detail-view2.js +105 -83
- package/dist/components/snk-layout-form-config.d.ts +11 -0
- package/dist/components/snk-layout-form-config.js +6 -0
- package/dist/components/snk-layout-form-config2.js +73 -0
- package/dist/components/snk-simple-crud2.js +33 -19
- package/dist/components/snk-view-representation.d.ts +11 -0
- package/dist/components/snk-view-representation.js +6 -0
- package/dist/components/snk-view-representation2.js +41 -0
- package/dist/esm/{ClientSideExporterProvider-e42c5a48.js → ClientSideExporterProvider-8191676b.js} +2 -3
- package/dist/esm/{ConfigStorage-e5c1f4c0.js → ConfigStorage-9bd805d6.js} +1 -1
- package/dist/esm/{pesquisa-fetcher-e26c3295.js → ISave-7d546dce.js} +9 -1
- package/dist/esm/{SnkFormConfigManager-1efd102b.js → SnkFormConfigManager-fbc6a9a8.js} +2 -2
- package/dist/esm/{auth-fetcher-9987c66e.js → auth-fetcher-07d33333.js} +1 -1
- package/dist/esm/{form-config-fetcher-34becd23.js → form-config-fetcher-ac17cff4.js} +14 -0
- package/dist/esm/index-a7d3d3f1.js +2 -2
- package/dist/esm/loader.js +1 -1
- package/dist/esm/pesquisa-grid_2.entry.js +2 -3
- package/dist/esm/sankhyablocks.js +1 -1
- package/dist/esm/{snk-actions-button_5.entry.js → snk-actions-button_7.entry.js} +63 -6
- package/dist/esm/snk-application.entry.js +47 -4
- package/dist/esm/snk-attach.entry.js +3 -4
- package/dist/esm/snk-config-options_3.entry.js +3 -3
- package/dist/esm/snk-configurator.entry.js +8 -1
- package/dist/esm/snk-crud.entry.js +5 -5
- package/dist/esm/snk-data-exporter.entry.js +2 -3
- package/dist/esm/snk-detail-view.entry.js +5 -6
- package/dist/esm/snk-filter-bar_4.entry.js +2 -2
- package/dist/esm/snk-filter-modal-item.entry.js +2 -2
- package/dist/esm/snk-grid.entry.js +4 -5
- package/dist/esm/{snk-guides-viewer-c38641c5.js → snk-guides-viewer-80a8709c.js} +3 -4
- package/dist/esm/snk-guides-viewer.entry.js +5 -6
- package/dist/esm/snk-personalized-filter.entry.js +2 -2
- package/dist/esm/snk-pesquisa.entry.js +2 -3
- package/dist/esm/snk-simple-crud.entry.js +7 -7
- package/dist/sankhyablocks/p-01512409.js +26 -0
- package/dist/sankhyablocks/p-02c6dc9f.entry.js +1 -0
- package/dist/sankhyablocks/{p-6c43fcde.entry.js → p-0bcd4757.entry.js} +1 -1
- package/dist/sankhyablocks/{p-ef076eea.js → p-108fee57.js} +2 -2
- package/dist/sankhyablocks/{p-3fcb90d6.js → p-13f17dab.js} +1 -1
- package/dist/sankhyablocks/{p-d3b9b377.entry.js → p-340e2447.entry.js} +1 -1
- package/dist/sankhyablocks/p-35fcf37e.js +1 -0
- package/dist/sankhyablocks/p-3a36d4b3.entry.js +1 -0
- package/dist/sankhyablocks/{p-a77bdadc.js → p-48729c8c.js} +1 -1
- package/dist/sankhyablocks/p-513af002.entry.js +1 -0
- package/dist/sankhyablocks/{p-e5657d22.entry.js → p-6c0afbce.entry.js} +1 -1
- package/dist/sankhyablocks/p-950e3cbe.entry.js +1 -0
- package/dist/sankhyablocks/p-9907cf67.entry.js +1 -0
- package/dist/sankhyablocks/p-af58c9d7.entry.js +1 -0
- package/dist/sankhyablocks/p-c5acb7ba.entry.js +11 -0
- package/dist/sankhyablocks/p-c7c6eab7.entry.js +1 -0
- package/dist/sankhyablocks/{p-3ce68be5.js → p-cb9d725a.js} +1 -1
- package/dist/sankhyablocks/p-d1f04e2c.js +1 -0
- package/dist/sankhyablocks/p-d2065bb4.entry.js +1 -0
- package/dist/sankhyablocks/p-dc617b0c.entry.js +1 -0
- package/dist/sankhyablocks/p-e5d8891d.entry.js +1 -0
- package/dist/sankhyablocks/{p-e66bcb5c.entry.js → p-f467153c.entry.js} +1 -1
- package/dist/sankhyablocks/p-f861bfcb.entry.js +1 -0
- package/dist/sankhyablocks/sankhyablocks.esm.js +1 -1
- package/dist/types/components/snk-application/snk-application.d.ts +10 -0
- package/dist/types/components/snk-configurator/snk-configurator.d.ts +6 -0
- package/dist/types/components/snk-crud/snk-crud.d.ts +4 -0
- package/dist/types/components/snk-layout-form-config/snk-layout-form-config.d.ts +15 -0
- package/dist/types/components/snk-layout-form-config/snk-view-representation/snk-view-representation.d.ts +10 -0
- package/dist/types/components/snk-simple-crud/snk-simple-crud.d.ts +4 -0
- package/dist/types/components.d.ts +69 -1
- package/dist/types/lib/configs/LayoutFormConfig.d.ts +11 -0
- package/dist/types/lib/http/data-fetcher/fetchers/form-config-fetcher.d.ts +6 -0
- package/package.json +1 -1
- package/react/components.d.ts +2 -0
- package/react/components.js +2 -0
- package/react/components.js.map +1 -1
- package/dist/cjs/ISave-e91b70a7.js +0 -9
- package/dist/esm/ISave-d8c8bc59.js +0 -9
- package/dist/sankhyablocks/p-04acdc3a.entry.js +0 -1
- package/dist/sankhyablocks/p-04b96ffe.js +0 -1
- package/dist/sankhyablocks/p-05fda408.entry.js +0 -1
- package/dist/sankhyablocks/p-17af0b1c.entry.js +0 -1
- package/dist/sankhyablocks/p-21749402.js +0 -1
- package/dist/sankhyablocks/p-22ddc147.js +0 -26
- package/dist/sankhyablocks/p-27d12f8f.entry.js +0 -1
- package/dist/sankhyablocks/p-3bab7e9c.entry.js +0 -1
- package/dist/sankhyablocks/p-4b01cbad.entry.js +0 -11
- package/dist/sankhyablocks/p-4c9adf1c.entry.js +0 -1
- package/dist/sankhyablocks/p-6b898a51.entry.js +0 -1
- package/dist/sankhyablocks/p-9523fc40.entry.js +0 -1
- package/dist/sankhyablocks/p-99ab1e1d.entry.js +0 -1
- package/dist/sankhyablocks/p-a18de25e.js +0 -1
- package/dist/sankhyablocks/p-be2e5f36.entry.js +0 -1
- package/dist/sankhyablocks/p-d571e243.entry.js +0 -1
@@ -1 +0,0 @@
|
|
1
|
-
import{r as t,c as i,h as e}from"./p-d2d301a6.js";import{ApplicationContext as a,DataType as s,Action as n,UserInterface as o,StringUtils as r,DataUnitLoaderUtils as h,DataUnit as l}from"@sankhyalabs/core";import{D as d}from"./p-5a7e18f4.js";import"./p-ef076eea.js";import"./p-0f3698af.js";import{S as c}from"./p-21749402.js";import{P as u,D as m,I as v}from"./p-7e0a0aae.js";import"./p-ff1990ad.js";import"./p-22ddc147.js";import{V as A}from"./p-1d19a5b0.js";import{A as O}from"./p-a77bdadc.js";import{T as p}from"./p-3fc82614.js";import"./p-8d884fab.js";import"@sankhyalabs/core/dist/dataunit/metadata/UnitMetadata";import"@sankhyalabs/ezui/dist/collection/utils/constants";import"@sankhyalabs/ezui/dist/collection/components/ez-grid/utils";import"@sankhyalabs/core/dist/utils/SortingUtils";import"./p-688dcb4c.js";import"./p-6dc031de.js";class w{constructor(t){this.dataUnitName=t}async save({dataUnit:t,record:i,updatingFields:e,operation:a}){var s,n;const o="INSERT"==a,r=o?e:i;if(!o&&(null==e?void 0:e.DESCRICAO)&&(null==e?void 0:e.DESCRICAO)!==(null==i?void 0:i.DESCRICAO))throw new Error(c.DESCRIPTION_CANNOT_BE_CHANGED);const h={anexo:{codata:o?null==e?void 0:e.REGISTER_KEY:null==i?void 0:i.CODATA,sequencia:(null==r?void 0:r.SEQUENCIA)||"0",tipo:(null==r?void 0:r.TIPO)||"N",descricao:null==r?void 0:r.DESCRICAO,arquivo:null===(n=null===(s=e.CAMINHO_ARQUIVO)||void 0===s?void 0:s[0])||void 0===n?void 0:n.name,ehInclusao:o?"S":"N",ehArquivoRepositorio:"N"}};return new Promise(((i,a)=>{d.get().callServiceBroker("Attach.save",JSON.stringify(h)).then((a=>{var s;return i([Object.assign(Object.assign(Object.assign({},a),e),{__owner__dataunit__name__:null!==(s=this.dataUnitName)&&void 0!==s?s:t})])})).catch((t=>a(t)))}))}async edit(t){throw new Error("Method not implemented.")}async delete(t){var i={anexo:{codata:t.CODATA,tipo:t.TIPO,descricao:t.DESCRICAO}};const e=await d.get().callServiceBroker("Attach.remove",JSON.stringify(i));return Promise.resolve(e)}async getDownloadKey(t){var i,e,a;if("S"==t.EHARQUIVOREPOSITORIO){const a={config:{path:t.ARQUIVO,tipoconteudo:t.TIPOCONTEUDO}},s=await d.get().callServiceBroker("RepositorioArquivoSP.abreArquivo",JSON.stringify(a));return Promise.resolve({chave:{valor:null===(e=null===(i=null==s?void 0:s.responseBody)||void 0===i?void 0:i.chave)||void 0===e?void 0:e.valor}})}const s={anexo:{codata:t.CODATA,codemp:t.CODEMP,sequencia:t.SEQUENCIA,tipo:t.TIPO,descricao:t.DESCRICAO,tipoConteudo:t.TIPOCONTEUDO}},n=await d.get().callServiceBroker("Attach.view",JSON.stringify(s));return(null==n?void 0:n.chaveAnexo)?Promise.resolve({chave:{valor:null===(a=null==n?void 0:n.chaveAnexo)||void 0===a?void 0:a.idChaveAnexo}}):Promise.reject(new Error("File not found."))}}const I="AnexoSistemaSP.salvar",_="AnexoSistemaSP.excluir",S="AnexoSistemaSP.baixar";class k{constructor(t,i){var e;this.entityName=t,this.dataUnitName=i,this.validateFields=t=>{if(t.LINK&&t.NOMEARQUIVO)throw new Error(c.LINK_AND_FILE_AT_THE_SAME_TIME);if(!t.LINK&&!t.NOMEARQUIVO)throw new Error(c.ANY_LINK_OR_FILE_FILLED);if(!this._registerKey)throw new Error("Register key can not be null")},this.resourceID=window.resourceID||(null===(e=window.workspace)||void 0===e?void 0:e.resourceID)}set registerKey(t){this._registerKey=t}async save(t){var i,e;let{updatingFields:a}=t;a=Object.assign(Object.assign({},a),{NOMEARQUIVO:null===(i=a.NOMEARQUIVO)||void 0===i?void 0:i[0]});try{this.validateFields(a);const t=a.LINK?null:a.NOMEARQUIVO,i={serviceName:I,requestBody:{params:{resourceID:this.resourceID,description:a.DESCRICAO,fileSelect:t?1:0,keySession:null===(e=null==t?void 0:t.properties)||void 0===e?void 0:e.fileNameTmp,nameAttach:null==t?void 0:t.name,link:a.LINK,nameEntity:this.entityName,pkEntity:this._registerKey,typeAcess:a.TIPOACESSO,typeApres:a.TIPOAPRES}}},s=await d.get().callServiceBroker(I,JSON.stringify(i));return Promise.resolve([Object.assign(Object.assign(Object.assign({},s),a),{ARQUIVOOULINK:a.LINK?a.LINK:null==t?void 0:t.name,__owner__dataunit__name__:this.dataUnitName})])}catch(t){return Promise.reject(t)}}async edit(t){var i,e,a;let{updatingFields:s,record:n}=t;const o=t=>void 0!==s[t]?s[t]:n[t],r=o("NOMEARQUIVO"),h=null===(e=null===(i=s.NOMEARQUIVO)||void 0===i?void 0:i[0])||void 0===e?void 0:e.downloadURL;s=Object.assign(Object.assign({},s),{DESCRICAO:o("DESCRICAO"),LINK:o("LINK"),TIPOACESSO:o("TIPOACESSO"),TIPOAPRES:o("TIPOAPRES"),CHAVEARQUIVO:n.CHAVEARQUIVO,NOMEARQUIVO:null==r?void 0:r[0]});const l=s.LINK?null:s.NOMEARQUIVO;try{this.validateFields(s);const t={serviceName:I,requestBody:{params:{resourceID:this.resourceID,nuAttach:null==n?void 0:n.NUATTACH,description:s.DESCRICAO,fileSelect:h?1:0,keySession:null===(a=null==l?void 0:l.properties)||void 0===a?void 0:a.fileNameTmp,keyAttach:s.CHAVEARQUIVO,nameAttach:null==l?void 0:l.name,link:s.LINK,nameEntity:this.entityName,pkEntity:this._registerKey,typeAcess:s.TIPOACESSO,typeApres:s.TIPOAPRES}}},i=await d.get().callServiceBroker(I,JSON.stringify(t));return Promise.resolve([Object.assign(Object.assign(Object.assign({},i),s),{ARQUIVOOULINK:s.LINK?s.LINK:null==l?void 0:l.name,__owner__dataunit__name__:this.dataUnitName})])}catch(t){return Promise.reject(t)}}delete(t){var i;const e=(null===(i=t.NOMEARQUIVO)||void 0===i?void 0:i[0])||{},a={serviceName:_,requestBody:{paramsDelete:{keyAttach:t.CHAVEARQUIVO,nameAttach:null==e?void 0:e.name,nameEntity:t.NOMEINSTANCIA,nuAttach:t.NUATTACH,pkEntity:t.PKREGISTRO}}};return new Promise(((t,i)=>{d.get().callServiceBroker(_,JSON.stringify(a)).then((i=>t(i))).catch((t=>i(t)))}))}getDownloadKey(t){var i;const e=(null===(i=t.NOMEARQUIVO)||void 0===i?void 0:i[0])||{},a={serviceName:S,requestBody:{paramsDown:{nameAttach:null==e?void 0:e.name,nameEntity:t.NOMEINSTANCIA,nuAttach:t.NUATTACH,pkEntity:t.PKREGISTRO,keyAttach:t.CHAVEARQUIVO}}};return new Promise(((t,i)=>{d.get().callServiceBroker(S,JSON.stringify(a)).then((i=>t(i))).catch((t=>i(t)))}))}}class y{constructor(t,i){this.entityName=t,this.getMessage=i,this._application=a.getContextValue("__SNK__APPLICATION__")}initLoaders(t,i,e){this.loader||(this.loader=t.dataLoader),t.dataLoader=(t,i)=>this.dataLoader(t,i),t.saveLoader=(t,a)=>this.saveLoader(a,i).then((t=>(t.length&&e(),t))),t.removeLoader=(t,a)=>this.removeLoader(t,a,i).then((t=>(t.length&&e(),t)))}metadataLoader(t){throw new Error("Method not implemented.")}dataLoader(t,i){return new Promise((e=>{this.loader(t,i).then((t=>{const i=((null==t?void 0:t.records)||[]).map((t=>{let i;return t.LINK||(i=[{name:t.NOMEARQUIVO}]),Object.assign(Object.assign({},t),{ARQUIVOOULINK:t.LINK?t.LINK:t.NOMEARQUIVO,NOMEARQUIVO:i})}));e(Object.assign(Object.assign({},t),{records:i}))}))}))}saveLoader(t,i){return new Promise((e=>{var a;const s=Array.isArray(t)?t[0]:{};((null===(a=null==s?void 0:s.record)||void 0===a?void 0:a.NUATTACH)>=0?i.edit.bind(i):i.save.bind(i))(s).then((t=>{e(t)})).catch((t=>t.message===c.LINK_AND_FILE_AT_THE_SAME_TIME?(this._application.alert(this.getMessage("snkAttach.alertValidation.fileAndLinkAtTheSameTime.title"),this.getMessage("snkAttach.alertValidation.fileAndLinkAtTheSameTime.message")),e([])):t.message===c.ANY_LINK_OR_FILE_FILLED?(this._application.alert(this.getMessage("snkAttach.alertValidation.anyLinkOrFileFilled.title"),this.getMessage("snkAttach.alertValidation.anyLinkOrFileFilled.message")),e([])):t.message?(this._application.error(t.title||t.name,t.message),e([])):void e([])))}))}removeLoader(t,i,e){return new Promise((a=>{const{records:s}=t.getSelectionInfo(),n=s[0];e.delete(n).then((()=>(u.removeRecords(t,[n]),a(i))))}))}getFilters(t){return[{name:"AttachmentsByPK",expression:"this.PKREGISTRO = :PKREGISTRO",params:[{name:"PKREGISTRO",dataType:s.TEXT,value:`${t}_${this.entityName}`}]}]}getInterceptions(t,i,e){return new Promise((a=>i.type===n.EDITION_CANCELED?t.isDirty()?this._application.confirm(this.getMessage("snkAttach.cancelConfirmation.title"),this.getMessage("snkAttach.cancelConfirmation.message")).then((t=>t?(e.goToView(A.GRID),a(i)):a(void 0))):a(i):i.type===n.DATA_SAVED?(t.loadData(),a(i)):void a(i)))}}const b=a.getContextValue("__SNK__APPLICATION__"),f=t=>{var i,e;return null===(e=null===(i=null==b?void 0:b.messagesBuilder)||void 0===i?void 0:i.getMessage)||void 0===e?void 0:e.call(i,t,null)},E={grid:{columns:[{name:"CODATA",orderIndex:0,width:0},{name:"DESCRICAO",orderIndex:1,width:0},{name:"ARQUIVO",orderIndex:2,width:0},{name:"DTALTER",orderIndex:3,width:0},{name:"USUARIO",orderIndex:4,width:0}]},form:{emptyConfig:!1,fields:[{name:"DESCRICAO",label:f("snkAttach.attachMetadata.lblDescription"),visible:!0,readOnly:!1,required:!0},{name:"CAMINHO_ARQUIVO",label:f("snkAttach.attachMetadata.lblFile"),visible:!0,readOnly:!1,required:!0}]}},N={name:"Attach",label:"Attach List",fields:[{name:"CODATA",label:f("snkAttach.attachMetadata.lblCode"),dataType:s.TEXT},{name:"DESCRICAO",label:f("snkAttach.attachMetadata.lblDescription"),dataType:s.TEXT,readOnly:!1},{name:"ARQUIVO",label:f("snkAttach.attachMetadata.lblFileOrLink"),dataType:s.TEXT},{name:"USUARIO",label:f("snkAttach.attachMetadata.lblUser"),dataType:s.TEXT},{name:"DTALTER",label:f("snkAttach.attachMetadata.lblDate"),dataType:s.TEXT},{name:"CAMINHO_ARQUIVO",label:f("snkAttach.attachMetadata.lblFileUpload"),dataType:s.OBJECT,userInterface:o.FILE,readOnly:!1,required:!0,visible:!0,properties:{subTitle:f("snkAttach.attachMetadata.lblSubTitle"),MAX_FILES:1,STORAGESTRATEGY:"SESSION",INTERNAL_FILENAME:"Attach.upload"}}]};class g{constructor(t){this.getMessage=t,this._records=[],this._application=a.getContextValue("__SNK__APPLICATION__")}initLoaders(t,i,e){t.metadataLoader=t=>this.metadataLoader(t),t.dataLoader=(t,i)=>this.dataLoader(t,i),t.saveLoader=(t,a)=>this.saveLoader(a,i).then((t=>(t.length&&e(),t))),t.removeLoader=(t,a)=>this.removeLoader(t,a,i).then((t=>(t.length&&e(),t)))}metadataLoader(t){return Promise.resolve(N)}async dataLoader(t,i){if(!i.source)return Promise.resolve({records:this._records});if(!Number.isNaN(Number(i.source))){const t={criteria:{codata:i.source,tipoAnexo:"N"}},e=await this._application.getDataFetcher(),{anexos:{anexo:a=[]}}=await e.callServiceBroker("Attach.load",JSON.stringify(t)),s=[];a.forEach((t=>{s.push(Object.assign({__record__id__:r.generateUUID(),CAMINHO_ARQUIVO:[{name:null==t?void 0:t.ARQUIVO}]},t))})),this._records=s}return h.buildLoadDataResponse(this._records,t,i)}saveLoader(t,i){return new Promise((e=>{const a=Array.isArray(t)?t[0]:{};i.save(a).then(e).catch((t=>t.message===c.DESCRIPTION_CANNOT_BE_CHANGED?(this._application.alert(this.getMessage("snkAttach.alertValidation.descriptionCannotBeChanged.title"),this.getMessage("snkAttach.alertValidation.descriptionCannotBeChanged.message")),e([])):t.message===c.LINK_AND_FILE_AT_THE_SAME_TIME?(this._application.alert(this.getMessage("snkAttach.alertValidation.fileAndLinkAtTheSameTime.title"),this.getMessage("snkAttach.alertValidation.fileAndLinkAtTheSameTime.message")),e([])):t.message===c.ANY_LINK_OR_FILE_FILLED?(this._application.alert(this.getMessage("snkAttach.alertValidation.anyLinkOrFileFilled.title"),this.getMessage("snkAttach.alertValidation.anyLinkOrFileFilled.message")),e([])):t.message?(this._application.error(t.title||t.name,t.message),e([])):void e([])))}))}removeLoader(t,i,e){return new Promise((a=>{t.getSelectionInfo().records.forEach((async t=>{this._application.hasAccess(O.REMOVE).then((async s=>{s&&(await e.delete(t),a(i))}))}))}))}getFilters(){throw new Error("Method not implemented.")}getInterceptions(t,i,e){return new Promise((a=>i.type===n.EDITION_CANCELED?t.isDirty()?this._application.confirm(this.getMessage("snkAttach.cancelConfirmation.title"),this.getMessage("snkAttach.cancelConfirmation.message")).then((t=>t?(e.goToView(A.GRID),a(i)):a(void 0))):a(i):i.type===n.DATA_SAVED?(t.loadData(),a(i)):void a(i)))}}const C=a.getContextValue("__SNK__APPLICATION__"),P=t=>{var i,e;return null===(e=null===(i=null==C?void 0:C.messagesBuilder)||void 0===i?void 0:i.getMessage)||void 0===e?void 0:e.call(i,t,null)},T={DOWNLOAD:{hint:P("snkAttach.taskbar.titleDownload"),name:"DOWNLOAD",iconName:"file-download"},LINK:{hint:P("snkAttach.taskbar.titleLink"),name:"LINK",iconName:"launch"}},L=()=>{const t=[p.REMOVE,"DOWNLOAD","LINK"];return{getButtons:(t,i,e)=>{const a=e.indexOf(p.REFRESH);if((null==i?void 0:i.insertionMode)||(null==i?void 0:i.isDirty))return e.reverse();-1!==a&&e.splice(a,1);const{selectedRecord:s}=i||{},n=(null==s?void 0:s.LINK)?T.LINK:T.DOWNLOAD;e.splice(e.indexOf(p.DIVIDER)+1,0,p.REMOVE,n,p.DIVIDER);const o=[p.CLONE,p.DATA_EXPORTER],r=Array.from(new Set(e.filter((t=>!o.includes(t)))));return r.splice(r.indexOf(n)+1,0,p.DIVIDER),r},isEnabled:(i,e,a)=>{const s=void 0!==(null==e?void 0:e.selectedRecord);return!(t.includes(a)&&!s)}}},R={grid:{columns:[{name:"ARQUIVOOULINK",orderIndex:0,width:0},{name:"DESCRICAO",orderIndex:1,width:0},{name:"DHCAD",orderIndex:2,width:0},{name:"DHALTER",orderIndex:3,width:0},{name:"TIPOAPRES",orderIndex:4,width:0},{name:"TIPOACESSO",orderIndex:5,width:0},{name:"CODUSU",orderIndex:6,width:0},{name:"CODUSUALT",orderIndex:7,width:0}]},form:{emptyConfig:!1,fields:[{name:"DESCRICAO",required:!0},{name:"TIPOAPRES",required:!0},{name:"TIPOACESSO",required:!0},{name:"LINK"},{name:"NOMEARQUIVO"}]}},x=class{constructor(e){t(this,e),this.back=i(this,"back",7),this.handleTaskbarClick=async({detail:t})=>{if(["DOWNLOAD","LINK"].includes(t))return this.downloadAttachment(this._currentDataUnit.getSelectedRecord());"Attach"===this.fetcherType&&["SAVE"].includes(t)&&this._currentDataUnit.isDirty()&&await this._currentDataUnit.setFieldValue("REGISTER_KEY",this.registerKey)},this.handleBack=()=>{this._currentDataUnit.cancelEdition().then((t=>{t&&this.back.emit()}))},this.handleFinish=()=>{if(!this._currentDataUnit.isDirty())return this.back.emit();this._currentDataUnit.saveData().then((()=>{this.showFinishedToast(),this.back.emit()}))},this.fetcherType=void 0,this.fetcher=void 0,this.dataUnit=void 0,this.dataUnitBuilder=void 0,this.registerKey=void 0,this.entityName=void 0,this.messagesBuilder=void 0,this._currentFetcher=void 0,this._currentDataUnit=void 0,this.crudConfig=void 0}async registerKeyWatcher(t,i){var e;null==this._currentDataUnit&&this.loadAttachmentDataUnit(),i!==t&&(this._currentFetcher instanceof k&&(this._currentFetcher.registerKey=t),await(null===(e=this._currentDataUnit)||void 0===e?void 0:e.loadData()))}getAnexoSistemaFetcherInstance(){var t;const i=new k(this.entityName,null===(t=this._currentDataUnit)||void 0===t?void 0:t.name);return i.registerKey=this.registerKey,i}async initAttach(){var t,i,e,a,s;if(this.fetcherType||this.registerKey){if(this.fetcherType||(this.fetcherType="AnexoSistema"),this.returnToGridMode(),"AnexoSistema"===this.fetcherType)return this._currentFetcher=this.getAnexoSistemaFetcherInstance(),null===(t=this._currentDataUnitBuilder)||void 0===t||t.initLoaders(this._currentDataUnit,this._currentFetcher,this.returnToGridMode.bind(this)),void await(null===(i=this._currentDataUnit)||void 0===i?void 0:i.loadData());if("Attach"===this.fetcherType&&(null===(e=this.registerKey)||void 0===e?void 0:e.split("_").length)>1)return;await(null===(a=this._currentDataUnit)||void 0===a?void 0:a.loadMetadata()),await(null===(s=this._currentDataUnit)||void 0===s?void 0:s.loadData(void 0,void 0,!0,this.registerKey))}}getMessage(t,i){if(this.messagesBuilder)return this.messagesBuilder.getMessage(t,i)}showFinishedToast(){this._application.info(this.getMessage("snkAttach.finishedMessage"),{iconName:"check"})}downloadAttachment(t){if(!t)throw new Error("Nenhum registro selecionado");t.LINK?window.open(`${t.LINK}`):this._currentFetcher.getDownloadKey(t).then((({chave:i})=>{var e;let a=!1;(null===(e=null==t?void 0:t.ARQUIVO)||void 0===e?void 0:e.endsWith(".pdf"))||(a=!0),window.open(`/mge/visualizadorArquivos.mge?chaveArquivo=${i.valor}${a?"&forcarDownload=S":""}`)}))}returnToGridMode(){var t;null===(t=this._currentDataUnit)||void 0===t||t.clearSelection(),this._crudElement&&this._crudElement.goToView(A.GRID)}async loadAttachmentDataUnit(){try{switch(this.fetcherType){case"AnexoSistema":await this.loadAnexoSistema();break;case"Attach":await this.loadAttach();break;default:this._currentFetcher=this.fetcher,this._currentDataUnit=this.dataUnit,this._currentDataUnitBuilder=this.dataUnitBuilder}}catch(t){throw new Error("There was an error while creating the data unit")}}async loadAnexoSistema(){var t,i;this._currentDataUnit=(new m).getDataUnit("AnexoSistema","br.com.sankhya.core.v3.anexoSistema"),this._currentFetcher=this.getAnexoSistemaFetcherInstance(),this._currentDataUnit.metadata||(await(null===(t=this._currentDataUnit)||void 0===t?void 0:t.loadMetadata()),this.crudConfig=Object.assign({},R)),this.initDataUnitLoaders(),this._currentDataUnit.addFilterProvider({getFilter:()=>this._currentDataUnitBuilder.getFilters(this.registerKey)}),this._currentDataUnit.addInterceptor({interceptAction:t=>this._currentDataUnitBuilder.getInterceptions(this._currentDataUnit,t,this._crudElement)}),await(null===(i=this._currentDataUnit)||void 0===i?void 0:i.loadData()),this.disableEditFieldsNotInForm()}async loadAttach(){var t,i;this._currentFetcher=new w,this._currentDataUnit=new l(v.IN_MEMORY_DATA_UNIT_NAME),this.initDataUnitLoaders(),this._currentDataUnit.addInterceptor({interceptAction:t=>{var i;return t.type===n.METADATA_LOADED&&(this.crudConfig=Object.assign({},E),null===(i=this._crudElement)||void 0===i||i.updateConfig()),this._currentDataUnitBuilder.getInterceptions(this._currentDataUnit,t,this._crudElement)}}),this._currentDataUnit.metadata||(await(null===(t=this._currentDataUnit)||void 0===t?void 0:t.loadMetadata()),this.crudConfig=Object.assign({},E),await(null===(i=this._currentDataUnit)||void 0===i?void 0:i.loadData(void 0,void 0,!0,this.registerKey)),this.disableEditFieldsNotInForm())}initDataUnitLoaders(){var t,i;"AnexoSistema"===this.fetcherType&&(this._currentFetcher=this.getAnexoSistemaFetcherInstance(),this._currentDataUnitBuilder=new y(this.entityName,this.getMessage.bind(this)),null===(t=this._currentDataUnitBuilder)||void 0===t||t.initLoaders(this._currentDataUnit,this._currentFetcher,this.returnToGridMode.bind(this))),"Attach"===this.fetcherType&&(this._currentFetcher=new w,this._currentDataUnitBuilder=new g(this.getMessage.bind(this)),null===(i=this._currentDataUnitBuilder)||void 0===i||i.initLoaders(this._currentDataUnit,this._currentFetcher,(async()=>{this.returnToGridMode(),await this._currentDataUnit.loadData(void 0,void 0,!0,this.registerKey)})))}disableEditFieldsNotInForm(){var t;null===(t=this.crudConfig)||void 0===t||t.grid.columns.forEach((t=>{var i;const e=t.name;(null===(i=this.crudConfig)||void 0===i?void 0:i.form.fields.some((t=>t.name===e)))||this._currentDataUnit.disableField(e)}))}async componentWillLoad(){this._application=a.getContextValue("__SNK__APPLICATION__"),await this.initAttach()}componentWillRender(){this.fetcherType||(this.fetcherType="AnexoSistema"),null==this._currentDataUnit&&this.loadAttachmentDataUnit()}async handleOnDataStateChange({detail:t}){"Attach"===this.fetcherType&&(t.insertionMode?this._currentDataUnit.enableField("DESCRICAO"):this._currentDataUnit.disableField("DESCRICAO"),await this._currentDataUnit.loadMetadata())}render(){var t,i;return this._currentDataUnit?e("main",{class:"snk-attach__main"},e("header",{class:"snk-attach__header"},e("snk-simple-bar",{onExit:this.handleBack,messagesBuilder:this.messagesBuilder},e("div",{slot:"rightSlot"},e("ez-button",{class:"ez-button--primary",label:this.getMessage("snkAttach.finish"),onClick:this.handleFinish})))),e("div",{class:"snk-attach__crud-section ez-size-height--full ez-size-width--full ez-flex ez-flex--column"},e("div",{class:"ez-box__container"},e("snk-simple-crud",{ref:t=>this._crudElement=t,dataUnit:this._currentDataUnit,taskbarManager:L(),gridConfig:null===(t=this.crudConfig)||void 0===t?void 0:t.grid,formConfig:null===(i=this.crudConfig)||void 0===i?void 0:i.form,useCancelConfirm:!1,onActionClick:this.handleTaskbarClick,messagesBuilder:this.messagesBuilder,onDataStateChange:this.handleOnDataStateChange.bind(this)},e("div",{slot:"snkSimpleCrudHeader"},e("div",{class:"ez-flex ez-flex--column"},e("span",{class:"ez-title--primary ez-text ez-text--large ez-text--bold ez-padding-bottom--medium"},this.getMessage("snkAttach.title")),e("span",{class:"ez-text ez-text--medium ez-text--secondary ez-padding-bottom--medium"},this.getMessage("snkAttach.description")))))))):null}static get watchers(){return{registerKey:["registerKeyWatcher"]}}};x.style=".snk-attach__header.sc-snk-attach,.snk-attach__crud-section.sc-snk-attach{padding:0 var(--space--lg)}.snk-attach__file-info.sc-snk-attach{padding:var(--space--small);max-width:50%}.snk-attach__main.sc-snk-attach{height:85%}.ez-box__container.sc-snk-attach{height:100%}";export{x as snk_attach}
|
@@ -1,11 +0,0 @@
|
|
1
|
-
import{r as t,c as e,h as i,H as s,g as n}from"./p-d2d301a6.js";import{DateUtils as r,StringUtils as a,ObjectUtils as o,WaitingChangeException as h,WarningException as c,ErrorException as l,KeyboardManager as d,OnboardingUtils as u,DependencyType as p,ArrayUtils as m,SearchUtils as g,ElementIDUtils as w,ApplicationContext as y,DataType as v,ErrorTracking as f,UserAgentUtils as z,LockManager as P,LockManagerOperation as _}from"@sankhyalabs/core";import{ApplicationUtils as k}from"@sankhyalabs/ezui/dist/collection/utils";import{C as A}from"./p-3fcb90d6.js";import{d as x,D as I,U as S}from"./p-5a7e18f4.js";import{A as T,a as b}from"./p-a77bdadc.js";import{P as L,D as C}from"./p-7e0a0aae.js";import{P as N}from"./p-ef076eea.js";import{S as E}from"./p-17425c72.js";import{T as D}from"./p-1d19a5b0.js";import"./p-22ddc147.js";import"./p-ff1990ad.js";import"./p-8d884fab.js";import"@sankhyalabs/core/dist/dataunit/metadata/UnitMetadata";import"@sankhyalabs/ezui/dist/collection/utils/constants";import"@sankhyalabs/ezui/dist/collection/components/ez-grid/utils";import"@sankhyalabs/core/dist/utils/SortingUtils";import"./p-688dcb4c.js";class O{static webConnectionCaller(t,e,i){var s;null===(s=window.AppletCaller)||void 0===s||s.webConnectionCaller(t,e,i)}}const M=R;function R(t,e){const i=j();return(R=function(t){return i[t-=378]})(t,e)}function j(){const t=["true","863GKWjmo","parse","56355fjjjAm","isSup","putAccess","4324480sjuCdS","hasOwnProperty","239748okvJLB","name","6055770tXeRaU","actions","forEach","7RPRvzn","1042CHxkUw","2988126NIwRMm","20MTNzmH","authorizationSf","item","string","hasAccess","isArray","Objeto não pode ser indefinido.","3071943fWslZp","parseFromJSON"];return(j=function(){return t})()}!function(){const t=R,e=j();for(;;)try{if(281287==parseInt(t(399))/1*(-parseInt(t(387))/2)+-parseInt(t(401))/3+parseInt(t(381))/4*(-parseInt(t(389))/5)+parseInt(t(388))/6*(-parseInt(t(386))/7)+parseInt(t(379))/8+parseInt(t(396))/9+parseInt(t(383))/10)break;e.push(e.shift())}catch(t){e.push(e.shift())}}();class U{[M(397)](t){const e=M;if(typeof(t=utxt(t[e(390)]))==e(392)&&(t=JSON[e(400)](t)),null==t)throw Error(e(395));const i=new F("S"===t[e(402)]||!0===t[e(402)]);return Array[e(394)](t[e(391)])&&t[e(391)][e(385)]((t=>i.putAccess(t[e(382)],String(t.status)==e(398)))),i}}class F{constructor(t){const e=M;this.isSup=t,this[e(384)]={}}[M(378)](t,e){this[M(384)][t]=e}[M(393)](t){const e=M;if(this[e(402)])return!0;let i=!0;return this[e(384)][e(380)](t)&&(i=this.actions[t]),i}isUserSup(){return this.isSup}}class ${constructor(){this._embeddedParams=new Map,this._cachedParams=new Map,this.templateByQuery=new Map;try{if(null!=window.MGE_PARAMS){atob(window.MGE_PARAMS).split("__;__").forEach((t=>{const[e,i]=t.split("__=__");this._embeddedParams.set(e,i)}))}}catch(t){console.error("Problemas ao obter parâmetros embarcados"),console.error(t)}this.buldTemplates()}buldTemplates(){this.templateByQuery.set("fetchParam",x.gql`query($name: String!) {
|
2
|
-
$queryAlias$: fetchResource(name: $name){
|
3
|
-
name
|
4
|
-
resource
|
5
|
-
}
|
6
|
-
}`)}async getParam(t){if(this._embeddedParams.has(t))return Promise.resolve(this._embeddedParams.get(t));if(this._cachedParams.has(t))return this._cachedParams.get(t);const e=`param://application?params=${t}`,i=await I.get().callGraphQL({values:{name:e},query:this.templateByQuery.get("fetchParam")});return this._cachedParams.set(t,i),i}async asString(t){const e=await this.getParam(t);return this.getValue(e)}async asInteger(t){const e=await this.getParam(t);return parseInt(this.getValue(e))}async asFloat(t){const e=await this.getParam(t);return parseFloat(this.getValue(e))}async asBoolean(t){const e=await this.getParam(t);return"S"===this.getValue(e)}async asDate(t){const e=await this.getParam(t);return r.strToDate(this.getValue(e))}async getBatchParams(t){const e=await this.getParam(t.join(",")),i={};return e.forEach((t=>i[t.name]=t.resource)),i}getValue(t={}){if(Array.isArray(t)&&t.length>0&&(t=t[0]),"string"==typeof t)return t;if(a.isEmpty(t.resource))return"";try{const e=o.stringToObject(t.resource),[i]=Object.keys(e);return e[i]}catch(t){console.warn("Erro ao converter string JSON.")}}}class q{constructor(){this.templateByQuery=new Map,this.cancel=[],this.buildTemplates()}buildTemplates(){this.templateByQuery.set("fetchTotals",x.gql`query($filters: [InputFilter!] $name: String!) {
|
7
|
-
$queryAlias$: fetchTotals(name: $name, filters: $filters ){
|
8
|
-
name
|
9
|
-
value
|
10
|
-
}
|
11
|
-
}`)}fetchTotals(t,e,i=[]){const s=`${t}_${e}`,n=this.cancel.findIndex((t=>t[s]));return n>=0&&(this.cancel[n][s](),this.cancel.splice(n,1)),Promise.race([new Promise((t=>this.cancel.push({[s]:t}))),this.getTotals(t,e,i)]).then((t=>{let e=new Map;if(t){e=t;const i=this.cancel.findIndex((t=>t[s]));i>=0&&this.cancel.splice(i,1)}return e}))}getTotals(t,e,i=[]){return new Promise(((s,n)=>{I.get().callGraphQL({query:this.templateByQuery.get("fetchTotals"),values:{name:`totals://${t}/${e}`,filters:i}}).then((t=>{if(t.length>0){const e=new Map;return t.forEach((t=>e.set(t.name,parseFloat(t.value)))),s(e)}return n("Não foi possível recuperar os totalizadores")})).catch(n)}))}}function B(){const t=["2909523kXwted","CompanyName=Sankhya Jiva Tecnologia e Inovao Ltda,LicensedApplication=Sankhya Gestao,LicenseType=SingleApplication,LicensedConcurrentDeveloperCount=2,LicensedProductionInstancesCount=0,AssetReference=AG-019460,ExpiryDate=9_November_2022_[v2]_MTY2Nzk1MjAwMDAwMA==10487151e296ee4360f80961ca960869","1131048CARoeW","502909mLEPmu","447255iQEXuN","428UHbJwW","270AFTxAV","194369jhGqTI","1540nWuTrj","2044062GicUQI","30CkXPWg"];return(B=function(){return t})()}const H=K;function K(t,e){const i=B();return(K=function(t){return i[t-=392]})(t,e)}!function(){const t=K,e=B();for(;;)try{if(951926==-parseInt(t(398))/1+-parseInt(t(393))/2+parseInt(t(395))/3+-parseInt(t(400))/4*(parseInt(t(392))/5)+-parseInt(t(401))/6*(-parseInt(t(402))/7)+parseInt(t(397))/8+-parseInt(t(399))/9*(-parseInt(t(394))/10))break;e.push(e.shift())}catch(t){e.push(e.shift())}}();const V=H(396);var W;class G{static openAppActivity(t,e){var i;null===(i=window.workspace)||void 0===i||i.openAppActivity(t,e)}static getAppLabel(t){if(null!=(null===window||void 0===window?void 0:window.workspace))return null==window.workspace.getAppLabel&&(window.workspace.getAppLabel=t=>(t||"").split(".").pop()),window.workspace.getAppLabel(t)}static setScreenToUseV3Layout(){var t;null===(t=window.workspace)||void 0===t||t.setScreenToUseV3Layout()}static setScreenToUseOldLayout(){var t;null===(t=window.workspace)||void 0===t||t.setScreenToUseOldLayout()}static showDesktop(){var t,e;null===(e=null===(t=window.workspace)||void 0===t?void 0:t.showDesktop)||void 0===e||e.call(t)}static searchApp(){var t,e;null===(e=null===(t=window.workspace)||void 0===t?void 0:t.searchApp)||void 0===e||e.call(t)}static openHelp(){var t,e;null===(e=null===(t=window.workspace)||void 0===t?void 0:t.openHelp)||void 0===e||e.call(t)}static applicationClick(){var t,e;(null===(t=window.workspace)||void 0===t?void 0:t.applicationClick)&&(null===(e=window.workspace)||void 0===e||e.applicationClick())}}G.resourceID=null===(W=window.workspace)||void 0===W?void 0:W.resourceID;class J{constructor(t){this._app=t,window.addEventListener("error",(t=>this.errorHandler(t))),window.addEventListener("unhandledrejection",(t=>this.rejectionHandler(t)))}rejectionHandler(t){const e=t.reason;e instanceof h||(e?this.processException(e):this._app.isDebugMode().then((t=>{t&&this._app.error("Promise rejeitada","Erro interno: Uma promise foi rejeitada sem razão determinada.")})))}errorHandler(t){this.processException(t.error)}buildErrorCodeHTML(t){return'<br><a href="#" onclick="try{window.workspace.openHelp(\'_tbcode:'+t+"')} catch(e){alert('Não é possível abrir a ajuda fora do workspace Sankhya');}\">Código: "+t+"</a>"}processException(t){t.errorCode&&(t.message+=this.buildErrorCodeHTML(t.errorCode)),t instanceof h||t instanceof c?this._app.alert(t.title,t.message):t instanceof l?this._app.error(t.title,t.message):this._app.isDebugMode().then((e=>{if(e)if(t instanceof Error)this._app.error(t.name,t.message);else{const e=(null==t?void 0:t.title)||"Erro detectado",i="string"==typeof t?t:t.message||`Erro interno "${o.objectToString(t)}"`;this._app.error(e,i)}}))}}class Y{constructor(){this._debounceTime=1500,this.requests=new Map,this.requestsLoadingBar=[]}onRequestStart(t){if(t.url.includes("quietMode=true"))return;this.requestsLoadingBar.push(t.requestId);const e=setTimeout((()=>{this.ezLoadingBar.show()}),this._debounceTime);this.requests.set(t.requestId,e)}onRequestEnd(t){var e,i,s;const n=this.requests.get(t.requestId);clearTimeout(n),(null===(e=this.requestsLoadingBar)||void 0===e?void 0:e.includes(t.requestId))&&(this.requestsLoadingBar=null===(i=this.requestsLoadingBar)||void 0===i?void 0:i.filter((e=>e!==t.requestId)),!this.requestsLoadingBar.length&&(null===(s=this.ezLoadingBar)||void 0===s||s.hide()))}}class X{constructor(){this._debounceTime=1e3,this._ignoredNameTypes=["totals"],this._countRequest=0}onRequestStart(t){this.isIgnoreLoadingOnRequest(t)||(this._countRequest++,this.ezLoadingBar.show(),this._timerLoading&&clearTimeout(this._timerLoading))}onRequestEnd(t){this.isIgnoreLoadingOnRequest(t)||(this._countRequest--,this._timerLoading=setTimeout((()=>{this._countRequest<=0&&this.ezLoadingBar.hide()}),this._debounceTime))}isIgnoreLoadingOnRequest(t){if(null==t)return!1;if(t.url.includes("quietMode=true"))return!0;if(null==t.requestBody)return!1;if(1==t.requestBody.length){const{name:e}=t.requestBody[0].variables;if(e){const t=e.split(":");return this._ignoredNameTypes.indexOf(t[0])>=0}}return!1}}class Z{static create({strategy:t}){switch(t){case"request_name":return new X;case"request_time":return new Y;default:throw new Error("Strategy not found")}}}const Q=class{constructor(i){t(this,i),this.applicationLoaded=e(this,"applicationLoaded",7),this.applicationLoading=e(this,"applicationLoading",7),this.NEW_VERSION_POPUP_LOCKER="NEW_VERSION_POPUP_LOCKER",this._authPromises=[],this._keyboardManager=new d,this._waitingAppReady=new Array,this._duCache=new Map,this._duPromises=new Map,this._requestListener=Z.create({strategy:"request_time"}),this._maxTimerAppLoading=1e4,this._isBrowserTypeElectron=!1,this._pendingActions=new Map,this._loadPkParameter=null,this._isLoadedByPk=!1,this._applicationReady=!1,this._templateSkeleton=D.GRID,this._activeScrimWindow=!1,this.enableLockManagerLoadingApp=void 0,this.messagesBuilder=void 0,this.configName=void 0,this.gridLegacyConfigName=void 0,this.formLegacyConfigName=void 0,this.loadByPK=void 0}async processPendingActions(t){const e=this._pendingActions.get(t);e&&e.length&&(e.forEach((t=>t())),this._pendingActions.set(t,[]))}get parameters(){return this._parameters||(this._parameters=new $),this._parameters}async getAuth(t){return null==t?this.getApplicationAuth():new Promise(((e,i)=>{this.authFetcher.getData(t).then((t=>{e(t)})).catch((t=>{i(t)}))}))}async getApplicationAuth(){return this._auth?Promise.resolve(this._auth):new Promise(((t,e)=>{const i=this._authPromises.length>0;this._authPromises.push(new tt(t,e)),i||this.authFetcher.getData(this.applicationResourceID).then((t=>{for(this._auth=t;this._authPromises.length>0;)this._authPromises.pop().resolve(this._auth)})).catch((t=>{for(;this._authPromises.length>0;)this._authPromises.pop().reject(t)}))}))}watchPropHandler(t,e){t&&this._loadPkParameter&&(this.loadByPK(this._loadPkParameter.pk,this._loadPkParameter.redirect),this._loadPkParameter=null)}async getKeyboardManager(){return Promise.resolve(this._keyboardManager)}async isUserSup(){return new Promise(((t,e)=>{this.getAuth().then((i=>{this.getAuthList(i).then((e=>{t(e.isSup)})).catch((t=>e(t)))}))}))}async addPendingAction(t,e){var i;const s=null!==(i=this._pendingActions.get(t))&&void 0!==i?i:[];this._pendingActions.set(t,[...s,e])}async callServiceBroker(t,e,i){return I.get().callServiceBroker(t,e,i)}async initOnboarding(t){this.hasToShowNewVersionPopup()?await this.addPendingAction(this.NEW_VERSION_POPUP_LOCKER,(()=>this.doInitOnboarding(t))):this.doInitOnboarding(t)}doInitOnboarding(t){u.getInstance().init(t,window.envContext)}async hasAccess(t,e){return new Promise(((i,s)=>{this.getAuth(e).then((e=>{this.getAuthList(e).then((e=>{i(e.isSup||e.actions[t])})).catch((t=>s(t)))}))}))}async getAllAccess(t){return new Promise(((e,i)=>{this.getAuth(t).then((t=>{this.getAuthList(t).then((t=>{const i={};i.isSup=t.isSup,Object.entries(T).forEach((e=>{i[e[0]]=e[1]===T.CLONE?t.actions[T.INSERT]&&t.actions[T.CLONE]||!1:t.actions[e[1]]||!1})),e(i)})).catch((t=>i(t)))}))}))}async getStringParam(t){return this.parameters.asString(t)}async getIntParam(t){return this.parameters.asInteger(t)}async getFloatParam(t){return this.parameters.asFloat(t)}async getBooleanParam(t){return this.parameters.asBoolean(t)}async getDateParam(t){return this.parameters.asDate(t)}async showPopUp(t,e="full",i=!0,s){this.clearContent(this._popUp),this._popUp.addEventListener("ezClosePopup",(()=>{s()}),{once:!0}),this._popUp.appendChild(t),this._popUp.opened=!0,this._popUp.heightMode=e,this._popUp.useHeader=i,"EZ-MODAL-CONTAINER"===t.tagName&&(this._popUp.useHeader=!1)}async showModal(t){this.clearContent(this._rightModal),this._rightModal.appendChild(t),this._rightModal.opened=!0}showAlerts(t){return k.showAlerts({alerts:t})}async closeModal(){this.clearContent(this._rightModal),this._rightModal.opened=!1}async closePopUp(){this.clearContent(this._popUp),this._popUp.opened=!1,this._popUp.useHeader=!0,this._popUp.heightMode="full"}async temOpcional(t){const e=t.split(",");return new Promise(((t,i)=>{this.getAttributeFromHTMLWrapper("opc0009").then((s=>{"1"===s?t(!0):Promise.all(e.map((t=>this.getAttributeFromHTMLWrapper("opc"+t)))).then((e=>{t(e.includes("1"))})).catch((t=>{i(t)}))})).catch((t=>{i(t)}))}))}async getConfig(t){let e={serviceName:"SystemUtilsSP.getConf",requestBody:{config:{chave:t,tipo:"T"}}};return new Promise(((t,i)=>{I.get().callServiceBroker("SystemUtilsSP.getConf",JSON.stringify(e)).then((e=>{var i;return t(null===(i=e.config)||void 0===i?void 0:i.data)})).catch((t=>i(t)))}))}async saveConfig(t,e){let i={serviceName:"SystemUtilsSP.saveConf",requestBody:{config:{chave:t,tipo:"T",data:e}}};return new Promise(((t,e)=>{I.get().callServiceBroker("SystemUtilsSP.saveConf",JSON.stringify(i)).then((e=>t(e))).catch((t=>e(t)))}))}async getAttributeFromHTMLWrapper(t){return Promise.resolve(window[t])}async openApp(t,e){G.openAppActivity(t,e)}async webConnection(t,e,i){this.getStringParam(t).then((t=>{O.webConnectionCaller(t,e,i)}))}getDuPromissesStack(t){let e;return t&&(e=this._duPromises.get(t),e||(e=[],this._duPromises.set(t,e))),e||[]}async createDataunit(t,e,i,s,n){return null==n&&(n=this.applicationResourceID),new Promise(((r,a)=>{const o=this.getDuPromissesStack(e),h=o.length>0;if(o.push(new tt(r,a)),!h){const r=this.dataUnitFetcher.getDataUnit(t,n,i,s);r.loadMetadata().then((()=>{this.processResolveDataUnit(r,e,o)})).catch((t=>{for(;o.length>0;)o.pop().reject(t)}))}}))}processResolveDataUnit(t,e,i){for(e&&this.updateDataunitCache(void 0,e,t);i.length>0;)i.pop().resolve(t)}async updateDataunitCache(t,e,i){t&&this._duCache.delete(t),this._duCache.set(e,i)}async getDataUnit(t,e,i,s,n){return new Promise(((r,a)=>{const o=this._duCache.get(e);o?r(o):this.createDataunit(t,e,i,s,n).then((t=>{r(t)})).catch((t=>a(t)))}))}async addClientEvent(t,e){return new Promise((i=>{I.addClientEvent(t,e),i()}))}async removeClientEvent(t){return new Promise((e=>{I.removeClientEvent(t),e()}))}async hasClientEvent(t){return new Promise((e=>{e(I.hasClientEvent(t))}))}get applicationResourceID(){return this._applicationResourceID||(this._applicationResourceID=this.urlParams.get("workspaceResourceID")||this.urlParams.get("resourceID")||G.resourceID||"unknown.resource.id"),this._applicationResourceID}async getResourceID(){return Promise.resolve(this.applicationResourceID)}async getUserID(){return Promise.resolve(window.UID)}async alert(t,e,i,s){return k.alert(t,e,i,s)}async error(t,e,i,s){return k.error(t,e,i,s)}async success(t,e,i,s){return k.success(t,e,i,s)}async message(t,e,i,s){return k.message(t,e,i,s)}async confirm(t,e,i,s,n){return k.confirm(t,e,i,s,n)}async info(t,e){return k.info(t,e)}async loadTotals(t,e,i){return this.totalsFetcher.fetchTotals(t,e,i)}async isLoadedByPk(){return Promise.resolve(this._isLoadedByPk)}async preloadMangerRemoveRecord(t,e){const i=e.map((t=>({__record__id__:t})));L.removeRecords(t,i)}getCountSkeleton(t,e,i){i=i||160;const s=window.innerHeight-i;return Math.floor(s/(t+(e||10)))-1||1}getSkeletonRandomWidth(){return`${Math.floor(71*Math.random())+30}%`}async getAuthList(t){return await(new U).parseFromJSON(t)}get urlParams(){return this._urlParams||(this._urlParams=S.getQueryParams(location.search)),this._urlParams}getMessage(t,e){var i;return null===(i=this.messagesBuilder)||void 0===i?void 0:i.getMessage(t,e)}get dataUnitFetcher(){return this._dataUnitFetcher||(this._dataUnitFetcher=new C),this._dataUnitFetcher}get totalsFetcher(){return this._totalsFetcher||(this._totalsFetcher=new q),this._totalsFetcher}get pesquisaFetcher(){return this._pesquisaFetcher||(this._pesquisaFetcher=new N),this._pesquisaFetcher}get authFetcher(){return this._authFetcher||(this._authFetcher=new b),this._authFetcher}async executeSearch(t,e,i,s){const n=null==i?void 0:i.getField(e);if(n){const{mode:e,argument:r}=t,{ENTITYNAME:a,CODEFIELD:o,DESCRIPTIONFIELD:h,ROOTENTITY:c,DESCRIPTIONENTITY:l,ISHIERARCHYENTITY:d}=n.properties,u=n.dependencies;let m;const g={rootEntity:c,descriptionFieldName:h,codeFieldName:o,showInactives:!1,dataUnitId:i.dataUnitId};return null==u||u.filter((t=>t.masterFields)).forEach((t=>{var e;t.type===p.SEARCHING&&(null===(e=t.masterFields)||void 0===e?void 0:e.length)>0&&(m={expression:t.expression,params:t.masterFields.map((t=>{const e=i.getField(t),s=(null==e?void 0:e.dataType)||v.TEXT,n=i.getFieldValue(t);if(null==n)throw this.alert("Erro ao pesquisar",`É necessario informar o campo ${e.label} para executar a pesquisa.`),new Error(`É necessario informar o campo ${e.label} para executar a pesquisa.`);return{name:t,value:n,dataType:s}}))})})),this.executePreparedSearch(e,r,{entity:a,entityDescription:l,isHierarchyEntity:d,criteria:m,searchOptions:g,allowsNonAnalytic:null==s?void 0:s.allowsNonAnalytic})}}filterInvalidFields(t,e,i){return t.fieldsMetadata.filter((s=>{let n=!a.isEmpty(e[s.fieldName])&&!1!==s.visible&&"B"!==s.type&&t.pkField!==s.fieldName&&t.descriptionField!==s.fieldName&&(s.isPrimaryKey||!s.isLinkField)&&!("S"===s.type&&"H"===s.presentationType);return n&&(i[s.fieldName]=s),("string"!=typeof e[s.fieldName]||!(e[s.fieldName].indexOf("<img")>-1||e[s.fieldName].indexOf("<svg")>-1))&&n}))}filterMathFields(t,e,i,s){return t&&Array.isArray(t)&&t.forEach((t=>{let i=m.removeReference(e,s[t]);i&&e.unshift(i)})),e=e.slice(0,i)}builOptionItem(t,e,i,s,n){var r;return{value:a.highlightValue(t,e.__matchFields,null===(r=e[n])||void 0===r?void 0:r.toString(),i,!0),label:s?a.highlightValue(t,e.__matchFields,e[s],i,!0):"",details:g.buildDetails(t,i,e)}}async executePreparedSearch(t,e,i){const s={},{entity:n,entityDescription:r,criteria:a,searchOptions:h,isHierarchyEntity:c,allowsNonAnalytic:l}=i;return new Promise("ADVANCED"===t?(t,i)=>{const s=document.createElement("snk-pesquisa");s[w.DATA_ELEMENT_ID_ATTRIBUTE_NAME]=`entity_${n}`,s.entityName=n,s.argument=e,s.searchLoader=t=>this.pesquisaFetcher.loadAdvancedSearch(n,t,a,h),s.isHierarchyEntity=c,c&&(s.treeLoader=t=>this.pesquisaFetcher.loadTree(n,t,a,h),s.allowsNonAnalytic=l),s.selectItem=e=>{t(e),this.clearPopUpTitle(),this.closePopUp()},this.setPopUpTitle(r),this.showPopUp(s,void 0,void 0,i)}:(t,i)=>{this.pesquisaFetcher.loadAdvancedSearch(n,e,a,h).then((i=>{let n=(i=o.stringToObject(i.json.$)).descriptionField,r=i.pkField;const a=[];i.data.forEach((t=>{let o=this.filterInvalidFields(i,t,s),h=this.filterMathFields(t.__matchFields,o,6,s);a.push(this.builOptionItem(e,t,h,n,r))})),t(a)})).catch((t=>{i(t)}))})}async isDebugMode(){return new Promise((t=>{t(window.isDebugMode)}))}async getAppLabel(){return G.getAppLabel(this.applicationResourceID)}addSearchListener(t,e,i){return new Promise((s=>{s(this.pesquisaFetcher.addSearchListener(t,e.dataUnitId,i))}))}importScript(t){return new Promise((e=>{this.getApplicationPath().then((i=>{let s=[];Array.isArray(t)||(s=[t]),s.forEach((t=>{const e=document.createElement("script");e.src=`${i}/${t}`,e.async=!0,document.body.appendChild(e)})),e()}))}))}async getApplicationPath(){return new Promise((t=>{"dev"===window.applicationenv?t(""):t(`/${this.getModuleName()}/labsApps/${window.APPLICATION_NAME}/build`)}))}getModuleName(){return window.MGE_MODULE_NAME||"mgefin-bff"}executeSelectDistinct(t,e,i){return this.dataUnitFetcher.loadSelectDistinct(t,e,i)}getDataFetcher(){return Promise.resolve(I.get())}async whenApplicationReady(){return y.getContextValue("__SNK__APPLICATION__LOADING__")?Promise.resolve(this):new Promise((t=>{this._waitingAppReady.push((()=>t(this)))}))}async setSearchFilterContext(t,e){y.setContextValue(`__SNK__APPLICATION__FILTER__CONTEXT(${t})__`,e)}clearContent(t){t&&Array.from(t.children).forEach((e=>{t.removeChild(e)}))}clearPopUpTitle(){this._popUp.ezTitle=""}setPopUpTitle(t){this._popUp.ezTitle=t}async pkChangeListener(){const t=top.window.location.hash.split("/")[2];if(this._currentPkParameter===t)return;const e=this.getResourceIdFromToken(),i=S.getPkObjectFromUrlToken(top.window.location.hash),s=window.redirectFrom;if(void 0===i)return;if((!s||-1===s.split("_")[0].indexOf(e.split("_")[0]))&&e!==this.applicationResourceID)return;const n={pk:i};if(this._isLoadedByPk=!0,this.loadByPK)return this.loadByPK(n,s),void(this._currentPkParameter=t);this._loadPkParameter={pk:n,redirect:s},this.defaultLoadByPK(n,t)}getResourceIdFromToken(){return top.window.location.pathname.indexOf("tabContent.jsp")>-1?S.getResourceIdFromUrlToken(window.location.generateHash(window.location.hash)):S.getResourceIdFromUrlToken(top.window.location.hash)}defaultLoadByPK(t,e){if(!(null==t?void 0:t.pk))return;const i=this.getFirstDataUnitFromDOM(),s=i.dataUnit;if(!s)return console.warn("Dataunit não inicializado"),void i.addEventListener("dataUnitReady",(i=>{this.loadDataWithPKFilter(t,i.detail),this._currentPkParameter=e}));this.loadDataWithPKFilter(t,s),this._currentPkParameter=e}loadDataWithPKFilter(t,e){const i={term:"",filter:{name:"LOAD_BY_PK_FILTER",expression:this.buildFilterExpressionByPkObject(t),params:this.getFilterParamsFromPkObject(t,e)}};e.loadData(i)}getFirstDataUnitFromDOM(){let t=this._element.querySelector("snk-data-unit[data-load-by-pk]");if(t||(t=this._element.querySelector("snk-data-unit")),t)return t}getFilterParamsFromPkObject(t,e){var i;const s=[];for(const n in t.pk)t.pk.hasOwnProperty(n)&&!Array.isArray(t.pk[n])&&s.push({name:n,dataType:(null===(i=e.getField(n))||void 0===i?void 0:i.dataType)||this.getDefaultDataTypeLoadByPK(t.pk[n]),value:t.pk[n]});return s}getDefaultDataTypeLoadByPK(t){return"number"==typeof t||t instanceof Number?v.NUMBER:"boolean"==typeof t||t instanceof Boolean?v.BOOLEAN:t instanceof Date?v.DATE:v.TEXT}buildFilterExpressionByPkObject(t){let e="";for(const i in t.pk)a.isEmpty(e)||(e+=" AND "),Array.isArray(t.pk[i])?e+=`${i} IN (${t.pk[i].toString()})`:e+=`${i} = :${i}`;return e}async showNewVersionPopup(){const t=document.createElement("ez-modal-container"),e=await this.getAppLabel();t.modalTitle=this.getMessage("snkApplication.newVersionPopup.title",{screenName:e}),t.okButtonLabel=this.getMessage("snkApplication.newVersionPopup.okButton"),t.cancelButtonLabel=this.getMessage("snkApplication.newVersionPopup.cancelButton");const i=document.createElement("p");i.innerText=this.getMessage("snkApplication.newVersionPopup.info"),i.className="ez-text",t.appendChild(i),t.addEventListener("ezModalAction",this.newVersionPopupEventListener.bind(this));const s=await k.showPopup({content:t});this._removeVersionLayoutPopup=async()=>{await s(),await this.processPendingActions(this.NEW_VERSION_POPUP_LOCKER)}}async newVersionPopupEventListener(t){"LOAD"!==t.detail&&("OK"===t.detail&&G.setScreenToUseV3Layout(),"CANCEL"===t.detail&&G.setScreenToUseOldLayout(),this._popUp.opened=!1,this._removeVersionLayoutPopup&&await this._removeVersionLayoutPopup())}async handleShowNewVersionPopup(){this.hasToShowNewVersionPopup()&&await this.showNewVersionPopup()}hasToShowNewVersionPopup(){const t=new URLSearchParams(window.location.search).get("firstLoadConv");return t&&"S"===t}registerPkChangeListener(){window.hasOwnProperty("onhashchange")?window.onhashchange=this.pkChangeListener.bind(this):setInterval(this.pkChangeListener.bind(this),100)}componentWillLoad(){y.setContextValue("__SNK__APPLICATION__LOADING__",!0),this._errorHandler=new J(this),this.messagesBuilder=new E,y.setContextValue("__EZUI__UPLOAD__ADD__URL__",`${S.getUrlBase()}/mge/upload/file`),y.setContextValue("__EZUI__SEARCH__OPTION__LOADER__",((t,e,i,s)=>this.executeSearch(t,e,i,s))),y.setContextValue("__EZUI__GRID_LICENSE__",V),this.registerPkChangeListener(),f.init(),A.preload(this.applicationResourceID,this.configName,{gridLegacyConfig:this.gridLegacyConfigName,formLegacyConfig:this.formLegacyConfigName}),document.addEventListener("click",(()=>G.applicationClick())),this._waitingAppReady.forEach((t=>t()))}connectedCallback(){this._isBrowserTypeElectron=z.isElectron(),y.setContextValue("__SNK__APPLICATION__",this),I.addRequestListener(this._requestListener)}disconnectedCallback(){null==I||I.removeRequestListener(this._requestListener),this.removeShortcuts(),this._lockManagerTimer&&clearTimeout(this._lockManagerTimer),this._scrimWindowTimer&&clearTimeout(this._scrimWindowTimer)}async componentDidLoad(){this.applicationLoading.emit(!0),window.requestAnimationFrame((()=>{y.setContextValue("__SNK__APPLICATION__LOADING__",!1),this.applicationLoaded.emit(!0),this.pkChangeListener()})),w.addIDInfo(this._element,`resource_${this.applicationResourceID}`),await this.handleShowNewVersionPopup(),this.initKeyboardManager(),this.enableLockManagerLoadingApp?(P.addLockManagerCtxId(this._element),this.resolveApplicationReady()):this._applicationReady=!0}async showScrimApp(t){if(!this.enableLockManagerLoadingApp||!this._applicationReady||!t)return this._activeScrimWindow=!1,void(this._scrimWindowTimer&&clearTimeout(this._scrimWindowTimer));this._activeScrimWindow=!0,this._scrimWindowTimer=setTimeout((async()=>{this._activeScrimWindow&&(this._activeScrimWindow=!1,clearTimeout(this._scrimWindowTimer))}),this._maxTimerAppLoading)}async changeTemplateSkeleton(t){this._templateSkeleton=t||this._templateSkeleton}async markToReload(t){this.enableLockManagerLoadingApp&&(await this.changeTemplateSkeleton(t),this._applicationReady=!1,await P.resetLocks(this._element,_.APP_LOADING),this.resolveApplicationReady())}async addLoadingLock(t=!1,e){if(this.enableLockManagerLoadingApp)return await this.changeTemplateSkeleton(e),t&&(this._applicationReady=!1,this._activeScrimWindow=!!this._applicationReady,await P.resetLocks(this._element,_.APP_LOADING)),this.resolveApplicationReady(),await P.lock(this._element,_.APP_LOADING)}async resolveApplicationReady(){if(!this._applicationReady)try{await this.checkTimeoutLimitLockManager(),await P.whenHasLock(this._element,_.APP_LOADING),await P.whenResolve(this._element,_.APP_LOADING,200),await P.resetLocks(this._element,_.APP_LOADING),this._applicationReady=!0}catch(t){console.warn(t),this._applicationReady=!0}}stopTimeoutLockManager(){this._lockManagerTimer&&clearTimeout(this._lockManagerTimer)}async checkTimeoutLimitLockManager(){this.stopTimeoutLockManager(),this._applicationReady||(this._lockManagerTimer=setTimeout((async()=>{this._applicationReady||(await P.resetLocks(this._element,_.APP_LOADING),this.stopTimeoutLockManager(),this._applicationReady=!0)}),this._maxTimerAppLoading))}initKeyboardManager(){this._keyboardManager.bind("ctrl + g",G.searchApp.bind(this),{description:"Pesquisar por telas"}).bind("ctrl + d",G.showDesktop.bind(this),{description:"Mostrar o desktop"}).bind("F1",G.openHelp.bind(this),{description:"Abrir ajuda"})}removeShortcuts(){this._keyboardManager.unbind("ctrl + g").unbind("ctrl + d").unbind("F1")}renderLoadingSkeleton(){if(this.enableLockManagerLoadingApp){if(this._isBrowserTypeElectron)return this.getSpinnerLoadingDefault();switch(this._templateSkeleton){case D.CUSTOM_TEMPLATE:case D.GRID:return this.getSkeletonTemplateGrid();case D.GRID_WITH_SIDEBAR:return this.getSkeletonTemplateGridWithSidebar();case D.GRID_WITH_PANEL:return this.getSkeletonTemplateGridWithPanel();case D.FORM_WITH_SIDEBAR:return this.getSkeletonTemplateFormWithSidebar();default:return this.getSkeletonTemplateGrid()}}}getLoadingVisibilityStyle(){return{visibility:this._applicationReady?"hidden":"initial",display:this._applicationReady?"none":"unset"}}getSkeletonTemplateGrid(){return i("div",{class:"loading-hidden",style:this.getLoadingVisibilityStyle()},i("div",{class:"ez-flex ez-flex--column ez-margin--large ez-margin-top--medium"},i("div",{class:"ez-margin-bottom--medium"},i("ez-skeleton",{count:1,variant:"rect",width:"20%",height:"35px",animation:"progress"})),i("div",{class:""},i("ez-skeleton",{count:1,variant:"rect",width:"70%",height:"25px",animation:"progress"}))),i("div",{class:"ez-flex ez-flex--justify-start skeleton-content-column ez-margin-horizontal--large",style:{height:"calc(-105px + 100vh)"}},[1,2,3,4].map(((t,e)=>i("div",{class:"ez-margin-right--large",key:e,style:{width:"25%"}},i("ez-skeleton",{count:this.getCountSkeleton(50,10),variant:"rect",width:"100%",height:"50px",animation:"progress",marginBottom:"10px"}))))))}getSkeletonTemplateGridWithSidebar(){return i("div",{class:"loading-hidden",style:this.getLoadingVisibilityStyle()},i("div",{class:"ez-flex ez-flex--column ez-margin--large ez-margin-top--medium"},i("div",{class:"ez-margin-bottom--medium"},i("ez-skeleton",{count:1,variant:"rect",width:"20%",height:"35px",animation:"progress"})),i("div",{class:""},i("ez-skeleton",{count:1,variant:"rect",width:"70%",height:"25px",animation:"progress"}))),i("div",{class:"ez-flex ez-flex--justify-start skeleton-content-column ez-margin-horizontal--large",style:{height:"calc(100vh - 160px)"}},i("div",{class:"ez-flex ez-flex--column ez-margin-right--large",style:{width:"25%",overflow:"hidden"}},Array(this.getCountSkeleton(30,6)).fill(null).map(((t,e)=>i("ez-skeleton",{key:e,count:1,variant:"rect",width:this.getSkeletonRandomWidth(),height:"30px",animation:"progress",marginBottom:"10px"})))),i("div",{class:"ez-margin-right--large",style:{width:"75%"}},i("ez-skeleton",{count:this.getCountSkeleton(50,10),variant:"rect",width:"100%",height:"50px",animation:"progress",marginBottom:"10px"}))))}getSkeletonTemplateGridWithPanel(){return i("div",{class:"loading-hidden",style:this.getLoadingVisibilityStyle()},i("div",{class:"ez-margin--medium ez-margin-top--medium ez-padding--medium"},i("ez-skeleton",{count:1,variant:"rect",width:"70%",height:"25px",animation:"progress"})),i("div",{class:"ez-flex ez-margin--medium ez-margin-top--medium",style:{maxHeight:"calc(-105px + 100vh)",overflow:"hidden"}},i("div",{class:"",style:{width:"70%",overflow:"hidden"}},i("div",{class:"ez-padding--medium",style:{height:"50%"}},i("ez-skeleton",{count:1,variant:"rect",width:"100%",height:"100%",animation:"progress"})),i("div",{class:"ez-padding--medium",style:{}},i("ez-skeleton",{count:1,variant:"rect",width:"250px",height:"25px",animation:"progress"})),i("div",{class:"ez-flex ez-padding--medium",style:{height:"45%"}},[1,2].map((()=>i("div",{style:{width:"50%"}},i("ez-skeleton",{count:1,variant:"rect",width:"100%",height:"100%",animation:"progress"})))))),i("div",{class:"ez-flex ez-flex--column ez-padding--medium",style:{width:"30%",overflow:"hidden"}},Array(this.getCountSkeleton(30,10)).fill(null).map(((t,e)=>i("ez-skeleton",{key:e,count:1,variant:"rect",width:"100%",height:"50px",animation:"progress",marginBottom:"10px"}))))))}getSkeletonTemplateFormWithSidebar(){return i("div",{class:"loading-hidden",style:this.getLoadingVisibilityStyle()},i("div",{class:"ez-margin--medium ez-margin-top--medium ez-padding--medium"},i("ez-skeleton",{count:1,variant:"rect",width:"70%",height:"25px",animation:"progress"})),i("div",{class:"ez-flex ez-margin--medium ez-margin-top--medium",style:{maxHeight:"calc(-105px + 100vh)",overflow:"hidden"}},i("div",{class:"ez-flex ez-flex--column ez-margin-right--large",style:{width:"25%",overflow:"hidden"}},Array(this.getCountSkeleton(30,6)).fill(null).map(((t,e)=>i("ez-skeleton",{key:e,count:1,variant:"rect",width:this.getSkeletonRandomWidth(),height:"30px",animation:"progress",marginBottom:"10px"})))),i("div",{class:"ez-flex ez-flex--column",style:{width:"75%"}},i("div",{class:"ez-padding--medium",style:{width:"100%"}},i("ez-skeleton",{count:1,variant:"rect",width:"30%",height:"25px",animation:"progress"})),i("div",{class:"ez-padding--medium",style:{height:"45%"}},i("div",{class:"ez-flex",style:{width:"100%",height:"100%"}},[1,2,3,4].map(((t,e)=>i("div",{key:e,class:"ez-padding-right--large",style:{width:"25%",overflow:"hidden"}},Array(this.getCountSkeleton(50,20)).fill(null).map(((t,e)=>i("ez-skeleton",{key:e,count:1,variant:"rect",width:"100%",height:"50px",animation:"progress",marginBottom:"10px"})))))))),i("div",{class:"ez-padding--medium",style:{width:"100%"}},i("ez-skeleton",{count:1,variant:"rect",width:"30%",height:"25px",animation:"progress"})),i("div",{class:"ez-padding--medium",style:{height:"45%"}},i("div",{class:"ez-flex",style:{width:"100%",height:"100%"}},[1,2,3,4].map(((t,e)=>i("div",{key:e,class:"ez-padding-right--large",style:{width:"25%",overflow:"hidden"}},Array(this.getCountSkeleton(50,20)).fill(null).map(((t,e)=>i("ez-skeleton",{key:e,count:1,variant:"rect",width:"100%",height:"50px",animation:"progress",marginBottom:"10px"})))))))))))}getSpinnerLoadingDefault(){return i("div",{class:"loading-hidden",style:this.getLoadingVisibilityStyle()},i("div",{class:"ez-flex ez-size-height--full ez-size-width--full ez-flex--justify-center ez-flex--align-items-center spinner"},i("ez-icon",{iconName:"sync",size:"x-large",class:"spin"}),i("span",{class:"ez-title ez-title--secondary ez-title--extra-large"},"Carregando...")))}render(){return i(s,{style:{visibility:!this.enableLockManagerLoadingApp||this._applicationReady?"unset":"hidden",overflow:!this.enableLockManagerLoadingApp||this._applicationReady?"unset":"hidden"}},i("div",null,i("ez-loading-bar",{ref:t=>this._requestListener.ezLoadingBar=t}),i("ez-popup",{opened:!1,ref:t=>this._popUp=t,onEzClosePopup:()=>this.closePopUp()}),i("ez-modal",{opened:!1,ref:t=>this._rightModal=t,"modal-size":"small",closeOutsideClick:!0,closeEsc:!0}),this.renderLoadingSkeleton(),this._activeScrimWindow&&i("div",{class:"ez-scrim ez-scrim--light",style:{cursor:"progress",zIndex:"var(--scrim-z-index)"}})))}get _element(){return n(this)}static get watchers(){return{loadByPK:["watchPropHandler"]}}};class tt{constructor(t,e){this.resolve=t,this.reject=e}}Q.style=".sc-snk-application-h{--scrim-z-index:var(--elevation--100, 100);display:flex;flex-direction:column;height:100%}.sc-snk-application-h>.loading-hidden.sc-snk-application{display:none;pointer-events:none}.skeleton-content-left.sc-snk-application{width:300px;padding-right:5px}.skeleton-content.sc-snk-application{height:calc(100vh - 310px)}.spinner.sc-snk-application{height:100vh;gap:10px}.spinner.sc-snk-application>.spin.sc-snk-application{animation-name:spin;animation-duration:5000ms;animation-iteration-count:infinite;animation-timing-function:linear}@keyframes spin{from{transform:rotate(0deg)}to{transform:rotate(360deg)}}";export{Q as snk_application}
|
@@ -1 +0,0 @@
|
|
1
|
-
import{r as o,c as r,h as t,g as i}from"./p-d2d301a6.js";import{ApplicationContext as n}from"@sankhyalabs/core";import{V as a}from"./p-1d19a5b0.js";import{A as s}from"./p-dc36cfbf.js";const l=class{constructor(t){o(this,t),this.configSelected=r(this,"configSelected",7),this.openConfig=r(this,"openConfig",7),this.save=r(this,"save",7),this.cancel=r(this,"cancel",7),this._opened=!1,this._permissions=void 0,this.showActionButtons=!1,this.configName=void 0,this.resourceID=void 0,this.viewMode=a.GRID,this.customContainerId=void 0,this.messagesBuilder=void 0}async open(){this._opened=!0,this.configSelected.emit(this.getViewModeValue()),this.modal.heightMode="full"}async close(){this.closeConfig()}closeConfig(){this._opened=!1}onViewModeChanged(o){this.viewMode=null==o?void 0:o.detail,this.configSelected.emit(this.viewMode)}onClickOpenConfig(){this.openConfig.emit(this.viewMode)}isAllowed(o){return!s[o]||!!this._permissions&&(this._permissions.isSup||this._permissions[o])}enableModeConfig(){return!(!this.isAllowed(s.CONFIG_GRID)||!this.isAllowed(s.CONFIG))}getViewModeValue(){return null!=this._permissions&&(this.isAllowed(s.CONFIG_GRID)?this.isAllowed(s.CONFIG)||(this.viewMode=a.GRID):this.viewMode=a.FORM),this.viewMode}getMessage(o){var r;return null===(r=this.messagesBuilder)||void 0===r?void 0:r.getMessage(o,{})}componentWillLoad(){this._application=n.getContextValue("__SNK__APPLICATION__"),this._application?this._application.getAllAccess(this.resourceID).then((o=>this._permissions=o)):this._permissions={}}componentDidRender(){if(!this.customContainerId)return;const o=document.querySelector(`#${this.customContainerId}`),r=null==o?void 0:o.querySelector("#SnkConfigContainerSlot");if(!r)return;const t=r.firstElementChild;if(!t)return;const i=this._element.querySelector("#slotContainer");null==i||i.appendChild(t)}render(){return t("ez-modal",{ref:o=>this.modal=o,opened:this._opened,"close-esc":!1,"close-outside-click":!1,"modal-size":"small",scrim:"light"},t("div",{class:"snk-configurator"},t("div",{class:"snk-configurator__header"},t("label",{class:"snk-configurator__title"},this.getMessage("snkConfigurator.titleConfigurations")),t("div",{class:"snk-configurator__button-close"},t("ez-button",{mode:"icon",iconName:"close",size:"medium",onClick:()=>this.closeConfig()}))),t("div",{class:"snk-configurator__main"},t("ez-collapsible-box",{boxBordered:!0,label:"Modo de visualização ",headerSize:"medium",class:"snk-configurator__collapsable-box"},t("ez-radio-button",{value:this.getViewModeValue().toString(),onEzChange:o=>this.onViewModeChanged(o),enabled:this.enableModeConfig()},t("ez-radio-button-option",{label:this.getMessage("snkConfigurator.labelGrid"),value:a.GRID}),t("ez-radio-button-option",{label:this.getMessage("snkConfigurator.labelForm"),value:a.FORM})),t("div",{class:"snk-configurator__collsable-box-action"},t("ez-button",{label:this.getMessage(this.viewMode===a.GRID?"snkConfigurator.labelConfigGrid":"snkConfigurator.labelConfigForm"),class:"snk-configurator__button-config ez-button--secondary",onClick:()=>this.onClickOpenConfig(),id:"openConfigurator"}))),t("div",{id:"slotContainer",class:"snk-configurator__outline"})),this.showActionButtons&&t("div",{class:"snk-configurator__action-buttons"},t("ez-button",{label:"Cancelar",onClick:()=>this.cancel.emit()}),t("ez-button",{label:"Salvar",onClick:()=>this.save.emit(),class:"ez-button--primary"}))))}get _element(){return i(this)}};l.style='.sc-snk-configurator-h{--snk-configurator__button-close--padding-left:var(--space--medium, 12px);--snk-configurator__title--color:var(--title--primary, #2B3A54);--snk-configurator__title--font-family:var(--font-pattern, "Roboto");--snk-configurator__title--font-size:var(--title--large, 20px);--snk-configurator__title--font-weight:var(--text-weight--extra-large, 700);--snk-configurator__subtitle--color:var(--title--primary, #2B3A54);--snk-configurator__subtitle--font-family:var(--font-pattern, "Roboto");--snk-configurator__subtitle--font-size:var(--text--medium, 14px);--snk-configurator__subtitle--font-weight:var(--text-weight--large, 600);--snk-configurator__scrollbar--color-default:var(--scrollbar--default, #626e82);--snk-configurator__scrollbar--color-background:var(--scrollbar--background, #E5EAF0);--snk-configurator__scrollbar--color-hover:var(--scrollbar--hover, #2B3A54);--snk-configurator__scrollbar--color-clicked:var(--scrollbar--clicked, #a2abb9);--snk-configurator__scrollbar--border-radius:var(--border--radius-small, 6px);--snk-configurator__scrollbar--width:var(--space--small, 6px)}.snk-configurator.sc-snk-configurator{display:grid;grid-template-rows:auto 1fr auto;max-height:100%;width:100%}.snk-configurator__collsable-box-action.sc-snk-configurator{width:100%}.snk-configurator__action-buttons.sc-snk-configurator{display:flex;flex-direction:row;justify-content:flex-end;gap:var(--space--medium)}.snk-configurator__outline.sc-snk-configurator{display:flex;flex-direction:column;gap:var(--space--small);margin-top:var(--space--small);margin-bottom:var(--space--large)}@media screen and (min-width: 480px){.snk-configurator.sc-snk-configurator{width:359px;max-width:359px}}.snk-configurator__button-config.sc-snk-configurator{--ez-button--min-width:100%}.snk-configurator__header.sc-snk-configurator{display:flex;justify-content:space-between;align-items:center;width:100%}.snk-configurator__title.sc-snk-configurator{display:flex;margin:0;line-height:normal;letter-spacing:0em;text-align:left;color:var(--snk-configurator__title--color);font-size:var(--snk-configurator__title--font-size);font-family:var(--snk-configurator__title--font-family);font-weight:var(--snk-configurator__title--font-weight)}.snk-configurator__subtitle.sc-snk-configurator{display:flex;margin:0;padding-top:var(--space--medium);padding-bottom:var(--space--small);color:var(--snk-configurator__subtitle--color);font-size:var(--snk-configurator__subtitle--font-size);font-family:var(--snk-configurator__subtitle--font-family);font-weight:var(--snk-configurator__subtitle--font-weight)}.snk-configurator__button-close.sc-snk-configurator{padding-left:var(--snk-configurator__button-close--padding-left)}.snk-configurator__main.sc-snk-configurator{overflow-y:auto;scrollbar-width:thin;margin:var(--space--medium) 0;scrollbar-color:var(--snk-configurator__scrollbar--color-clicked) var(--snk-configurator__scrollbar--color-background)}.snk-configurator__main.sc-snk-configurator::-webkit-scrollbar{background-color:var(--snk-configurator__scrollbar--color-background);width:var(--snk-configurator__scrollbar--width);max-width:var(--snk-configurator__scrollbar--width);min-width:var(--snk-configurator__scrollbar--width)}.snk-configurator__main.sc-snk-configurator::-webkit-scrollbar-track{background-color:var(--snk-configurator__scrollbar--color-background);border-radius:var(--snk-configurator__scrollbar--border-radius)}.snk-configurator__main.sc-snk-configurator::-webkit-scrollbar-thumb{background-color:var(--snk-configurator__scrollbar--color-default);border-radius:var(--snk-configurator__scrollbar--border-radius)}.snk-configurator__main.sc-snk-configurator::-webkit-scrollbar-thumb:vertical:hover,.snk-configurator__main.sc-snk-configurator::-webkit-scrollbar-thumb:horizontal:hover{background-color:var(--snk-configurator__scrollbar--color-hover)}.snk-configurator__main.sc-snk-configurator::-webkit-scrollbar-thumb:vertical:active,.snk-configurator__main.sc-snk-configurator::-webkit-scrollbar-thumb:horizontal:active{background-color:var(--snk-configurator__scrollbar--color-clicked)}';export{l as snk_configurator}
|
@@ -1 +0,0 @@
|
|
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{I as c}from"./p-8f3f2306.js";import{D as u,a as p,b as m}from"./p-0f3698af.js";import{R as v}from"./p-1d19a5b0.js";import{D as x}from"./p-5a7e18f4.js";import{S as g}from"./p-abd9681c.js";import"./p-ef076eea.js";import"./p-21749402.js";import"@sankhyalabs/ezui/dist/collection/utils/constants";import"@sankhyalabs/core/dist/dataunit/metadata/UnitMetadata";import"./p-7e0a0aae.js";import"./p-ff1990ad.js";import"./p-22ddc147.js";import"./p-8d884fab.js";import"./p-17425c72.js";import"@sankhyalabs/core/dist/dataunit/metadata/DataType";import"./p-7dd49d15.js";import"@sankhyalabs/ezui/dist/collection/components/ez-grid/utils";import"@sankhyalabs/core/dist/utils/SortingUtils";import"./p-688dcb4c.js";class f{constructor(t,e){this._selectedNumber=0,this._getMessage=t,this._selectedNumber=e}setExportOption(t,e){const i=this.getExportGroupName();t===u.EXPORT_TO_PDF&&e.push(this.getExportToPDF(i)),t===u.EXPORT_TO_XLS&&e.push(this.getExportToXLS(i)),this.setExportCurrentPage(t,e),this._selectedNumber>0&&this.setExportAllRecords(t,e),this.setExportByEmail(t,e)}setExportCurrentPage(t,e){var i;const s=[u.EXPORT_PAGE_TO_PDF,u.EXPORT_PAGE_TO_XLS];if(t===u.EXPORT_CURRENT_PAGE&&e.push(this.getCurrentPage()),s.includes(t)){let s=e.find((t=>t.id===u.EXPORT_CURRENT_PAGE));null==s&&(e.push(this.getCurrentPage()),s=e.find((t=>t.id===u.EXPORT_CURRENT_PAGE))),(null===(i=null==s?void 0:s.children)||void 0===i?void 0:i.length)||(s.children=[]),t===u.EXPORT_PAGE_TO_PDF&&s.children.push(this.getExportPageToPDF()),t===u.EXPORT_PAGE_TO_XLS&&s.children.push(this.getExportPageToXLS())}}setExportAllRecords(t,e){var i;const s=[u.EXPORT_ALL_RECORDS_TO_PDF,u.EXPORT_ALL_RECORDS_TO_XLS];if(t===u.EXPORT_ALL_RECORDS&&e.push(this.getAllRecords()),s.includes(t)){let s=e.find((t=>t.id===u.EXPORT_ALL_RECORDS));null==s&&(e.push(this.getAllRecords()),s=e.find((t=>t.id===u.EXPORT_ALL_RECORDS))),(null===(i=s.children)||void 0===i?void 0:i.length)||(s.children=[]),t===u.EXPORT_ALL_RECORDS_TO_PDF&&s.children.push(this.getExportAllRecordsToPDF()),t===u.EXPORT_ALL_RECORDS_TO_XLS&&s.children.push(this.getExportAllRecordsToXLS())}}setExportByEmail(t,e){t===u.EXPORT_BY_EMAIL&&e.push(this.getExportByEmail())}getExportToPDF(t){return{id:u.EXPORT_TO_PDF,label:"PDF (.pdf)",group:t}}getExportToXLS(t){return{id:u.EXPORT_TO_XLS,label:`${this._getMessage("snkDataExporter.label.spreadsheet")} (.xls)`,group:t}}getCurrentPage(){return{id:u.EXPORT_CURRENT_PAGE,label:this._getMessage("snkDataExporter.label.currentPage"),group:this._getMessage("snkDataExporter.group.custom")}}getAllRecords(){return{id:u.EXPORT_ALL_RECORDS,label:this._getMessage("snkDataExporter.label.allRecords"),group:this._getMessage("snkDataExporter.group.custom")}}getExportPageToPDF(){return{id:u.EXPORT_PAGE_TO_PDF,label:"PDF (.pdf)"}}getExportPageToXLS(){return{id:u.EXPORT_PAGE_TO_XLS,label:`${this._getMessage("snkDataExporter.label.spreadsheet")} (.xls)`}}getExportAllRecordsToPDF(){return{id:u.EXPORT_ALL_RECORDS_TO_PDF,label:"PDF (.pdf)"}}getExportAllRecordsToXLS(){return{id:u.EXPORT_ALL_RECORDS_TO_XLS,label:`${this._getMessage("snkDataExporter.label.spreadsheet")} (.xlsx)`}}getExportByEmail(){return{id:u.EXPORT_BY_EMAIL,label:`${this._getMessage("snkDataExporter.label.sendByEmail")}...`}}getExportGroupName(){return 1===this._selectedNumber?this._getMessage("snkDataExporter.group.export.selectedLine"):this._selectedNumber>1?this._getMessage("snkDataExporter.group.export.multiSelected").replace("{0}",this._selectedNumber.toString()):this._getMessage("snkDataExporter.group.export.default")}}function b(t){const e=[];let i=0;for(const s of t){if(i+=s.width,i>=860)break;e.push(s)}return e}function E(t){return Object.keys(u).find((e=>u[e]===t))}class w{constructor(t){this._provider=t}async getParsedColumns(){return b(await this._provider.getColumnsMetadata())}async getColumns(t){var e;return(null===(e=E(null==t?void 0:t.exportOption))||void 0===e?void 0:e.includes("PDF"))?await this.getParsedColumns():await this._provider.getColumnsMetadata()}async getParams(t){var e,i,s,o,r,n;const l=null===(i=(e=this._provider).getFilters)||void 0===i?void 0:i.call(e),a=await this.getColumns(t),d=null===(o=(s=this._provider).getOrders)||void 0===o?void 0:o.call(s),h=null===(n=(r=this._provider).getResourceURI)||void 0===n?void 0:n.call(r),c=this._provider.getSelectedIDs(),p=t.exportOption,m=[u.EXPORT_PAGE_TO_PDF,u.EXPORT_PAGE_TO_XLS];delete t.exportOption;let v=Object.assign({filters:l,columns:a,sort:d,resourceURI:h,selectedIDs:c.slice(0,this._provider.getExportLimit())},t);if(m.includes(p)||"page"==t.type){const t=this._provider.getOffset(),e=this._provider.getPageSize();v=Object.assign(Object.assign({},v),{offset:t,limit:e,selectedIDs:[]})}else"all"==t.type&&(v=Object.assign(Object.assign({},v),{offset:0,limit:this._provider.getExportLimit(),selectedIDs:[]}));return Promise.resolve(v)}async executeExport(t){const e=await this.getParams(t),{methodName:i}=e,s=function(t,e){var i={};for(var s in t)Object.prototype.hasOwnProperty.call(t,s)&&e.indexOf(s)<0&&(i[s]=t[s]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(s=Object.getOwnPropertySymbols(t);o<s.length;o++)e.indexOf(s[o])<0&&Object.prototype.propertyIsEnumerable.call(t,s[o])&&(i[s[o]]=t[s[o]])}return i}(e,["methodName"]),n=`${o.getContextValue("__SNK__APPLICATION__").getModuleName()}@DataExporterSPBean.${i}`,l={serviceName:n,requestBody:s};return new Promise(((t,e)=>{x.get().callServiceBroker(n,r.objectToString(l)).then((e=>t(this.getFormatResponse(e)))).catch((t=>e(t)))}))}getFormatResponse(t){var e;const i=null===(e=null==t?void 0:t.json)||void 0===e?void 0:e.$;if(null!=i)return r.stringToObject(i)}}class D{constructor(t){this._provider=t}async getParsedColumns(){return b(await this._provider.getColumnsMetadata())}async executeExport(t){var e;const{methodName:i,gridTitle:s}=t,o=await this._provider.getRecords(t.type),r=(null===(e=E(null==t?void 0:t.exportOption))||void 0===e?void 0:e.includes("PDF"))?await this.getParsedColumns():await this._provider.getColumnsMetadata(),[n,l]=this.getExecutor(i),a={serviceName:n,requestBody:{grid:{gridTitle:s,columns:this.buildColumnsObject(r),rows:this.buildRowsObject(r,o),customOptions:{xlsxExtension:!1}}}};return new Promise(((t,e)=>{x.get().callServiceBroker(n,a).then((e=>t(l(e)))).catch((t=>e(t)))}))}getExecutor(t){return"exportToPDF"===t?["GridPDFBuilderSP.buildPDFFromJson",t=>({fileSessionKey:t.chavePDF.valor,canPrint:"S"===t.permiteImprimir.valor,canExport:"S"===t.permiteExportar.valor,canSendEmail:"S"===t.canSendEmail.valor,useAppPrint:!0})]:["GridXLSBuilderSP.buildXLSFromJson",t=>({fileSessionKey:t.chaveXLS.valor,canPrint:!0,canExport:!0,canSendEmail:!0,useAppPrint:!1})]}buildColumnsObject(t){return{column:t.map(((t,e)=>{const{label:i,id:s,width:o,userInterface:r}=t;return Object.assign({index:e+1,id:s,label:i,width:o,presentationType:"P"},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"}},y=class{constructor(e){t(this,e),this._selectedNumber=0,this._customPrefix="$custom$",this._releasedToExport=[u.EXPORT_TO_PDF,u.EXPORT_TO_XLS,u.EXPORT_BY_EMAIL,u.EXPORT_PDF_TO_EMAIL,u.EXPORT_XLS_TO_EMAIL,u.EXPORT_PAGE_TO_PDF,u.EXPORT_PAGE_TO_XLS,u.EXPORT_ALL_RECORDS_TO_PDF,u.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=m[null==e?void 0:e.toUpperCase()])&&void 0!==r?r:m.PDF;this.resolveExporter({type:t,methodName:n,to:i,subject:s,message:o,fileName:this._appLabel,gridTitle:this._appLabel},(()=>{this._snkEmailSender.close(),d.info(this.getMessage("snkDataExporter.message.emailSuccess"),{iconName:"check"})}))}})}getMessage(t,e){if(null==this.messagesBuilder){const t=g.getNearestInstance(this._element);t&&(this.messagesBuilder=t.messagesBuilder)}return this.messagesBuilder.getMessage(t,e)}positionDropdown(){var t;const e=null===(t=this._ezButton)||void 0===t?void 0:t.getBoundingClientRect();null!=e&&null!=this._dropdownParent&&(this._dropdownParent.style.top=e.y+e.height+5+"px",this._dropdownParent.style.left=e.x+"px")}closeDropdown(t){const e=null==t?void 0:t.target;null!=e&&(e.closest(".snk-data-exporter")||(this._showDropdown=!1))}setEvents(){document.removeEventListener("click",this.closeDropdown.bind(this)),document.addEventListener("click",this.closeDropdown.bind(this)),document.removeEventListener("scroll",this.positionDropdown.bind(this)),document.addEventListener("scroll",this.positionDropdown.bind(this))}controlDropdown(){this._showDropdown=!this._showDropdown}async resolveExporter(t,e){null!=this.provider&&null!=t&&null!=e&&this.getExporterStrategy().executeExport(t).then((t=>e(t))).catch((t=>{console.error(t);let{title:e,message:i,statusMessage:s}=t||{};d.error(e||this.getMessage("snkDataExporter.message.exportError"),s||i||this.getMessage("snkDataExporter.message.unknownFailure"))}))}getExporterStrategy(){return null==this.provider.getRecords?new w(this.provider):new D(this.provider)}getOptionKey(t){return Object.keys(u).find((e=>u[e]===t))}getExportType(t){return t===u.EXPORT_ALL_RECORDS_TO_PDF||t===u.EXPORT_ALL_RECORDS_TO_XLS?c.ALL:t===u.EXPORT_PAGE_TO_PDF||t===u.EXPORT_PAGE_TO_XLS?c.PAGE:c.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={methodName:u[`EXPORT_TO_${n}`],fileName:this._appLabel,gridTitle:this._appLabel,exportOption:t,limit:null===(s=null===(i=this.provider)||void 0===i?void 0:i.getExportLimit)||void 0===s?void 0:s.call(i),type:this.getExportType(t)};await this.resolveExporter(l,(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})):d.error(this.getMessage("snkDataExporter.title.permission"),this.getMessage("snkDataExporter.message.exportPermission"))}))}async processExporter(t){var e,i,s,o,r,n,l;const a=null==t?void 0:t.detail,c=[u.EXPORT_PAGE_TO_PDF,u.EXPORT_PAGE_TO_XLS],p=null===(e=null==a?void 0:a.id)||void 0===e?void 0:e.includes(this._customPrefix);if((null==a?void 0:a.id)===u.EXPORT_CURRENT_PAGE)return;const m=null===(i=this.provider)||void 0===i?void 0:i.getSelectedIDs(),v=null===(s=this.provider)||void 0===s?void 0:s.getTotalRecords(),x=null===(r=null===(o=this.provider)||void 0===o?void 0:o.getPageSize)||void 0===r?void 0:r.call(o),g=null===(l=null===(n=this.provider)||void 0===n?void 0:n.getExportLimit)||void 0===l?void 0:l.call(n);let f=!1;if(c.includes(null==a?void 0:a.id)&&x<=g||p?f=!1:(null==m?void 0:m.length)?f=m.length>g:v>g&&(f=!0),f){const t=g.toLocaleString("pt-BR",{minimumFractionDigits:0}),e={title:this.getMessage("snkDataExporter.limitExceeded.title"),description:`\n ${this.getMessage("snkDataExporter.limitExceeded.description",{limit:t})}\n <br/><br/>\n <b>\n ${this.getMessage("snkDataExporter.limitExceeded.subdescription")}\n </b>\n `,cancel:this.getMessage("snkDataExporter.limitExceeded.cancel"),confirm:this.getMessage("snkDataExporter.limitExceeded.continue")};if(!await d.confirm(e.title,e.description,null,h.WARN,{labelCancel:e.cancel,labelConfirm:e.confirm}))return}if(p)return this.openPersonalizedReports(a.id),void(this._showDropdown=!1);this.getFilteredReleasedToExport().includes(null==a?void 0:a.id)&&(a.id===u.EXPORT_BY_EMAIL?this.exportByEmail():this.dispatchExporter(a.id),this._showDropdown=!1)}getFilteredReleasedToExport(){var t,e;if(null==this.provider)return this._releasedToExport;const i=null===(e=(t=this.provider).getHiddenOptions)||void 0===e?void 0:e.call(t);return null==i?this._releasedToExport:this._releasedToExport.filter((t=>!i.includes(t)))}loadItems(){const t=[];this.getFilteredReleasedToExport().forEach((e=>{var i;null===(i=this._itemBuilder)||void 0===i||i.setExportOption(e,t)})),this.loadPersonalizedItems(t)}async loadPersonalizedItems(t){var e,i;const s=null===(i=null===(e=this.provider)||void 0===e?void 0:e.getRecordID)||void 0===i?void 0:i.call(e);if(null==s)return void(this._items=t);const n=await function(t){const e=`${o.getContextValue("__SNK__APPLICATION__").getModuleName()}@DataExporterSPBean.getPersonalizedReports`,i={serviceName:e,requestBody:t};return new Promise(((t,s)=>x.get().callServiceBroker(e,r.objectToString(i)).then((e=>t(function(t){var e;const i=null===(e=null==t?void 0:t.json)||void 0===e?void 0:e.$;if(null!=i)return r.stringToObject(i)}(e)))).catch((t=>s(t)))))}({recordID:s});null==n||n.forEach((e=>{t.push({id:`${this._customPrefix}_${e.ID}`,label:e.label,group:this.getMessage("snkDataExporter.group.custom")})})),this._items=t}openPersonalizedReports(t){var e,i;const s=[],o=(null==t?void 0:t.replace(this._customPrefix,""))||"";null===(i=null===(e=this.provider)||void 0===e?void 0:e.getSelectedIDs)||void 0===i||i.call(e).forEach((({name:t,type:e,value:i},o)=>{const r={fields:[]};0===o&&(s[`PK_${t}`]={type:this.parseDataType(e),value:i},s.pks=[]);const n={nome:`PK_${t}`,tipo:this.parseDataType(e),valor:i};r.fields.push(n),s.pks.push(r)})),this._application.openApp(`${v}${o}`,s)}parseDataType(t){switch(t){case l.NUMBER:return"I";case l.DATE:return"D";default:return"S"}}loadDropdown(){var t;this._selectedNumber=(null===(t=this.provider)||void 0===t?void 0:t.getSelectedNumber())||0,this._itemBuilder=new f(this.getMessage.bind(this),this._selectedNumber),this.loadItems()}getElementID(t){return{[a.DATA_ELEMENT_ID_ATTRIBUTE_NAME]:a.getInternalIDInfo(t)}}canShowDropdown(){var t;return this._showDropdown&&(null===(t=this._items)||void 0===t?void 0:t.length)>0}componentWillLoad(){var t;this._application=o.getContextValue("__SNK__APPLICATION__"),null===(t=this._application)||void 0===t||t.getAppLabel().then((t=>this._appLabel=t)),this.setEvents()}componentDidLoad(){null!=this._element&&(a.addIDInfo(this._element),this.positionDropdown())}componentWillUpdate(){var t;this._showDropdown&&!(null===(t=this._items)||void 0===t?void 0:t.length)&&this.loadDropdown()}componentDidUpdate(){var t;this._showDropdown?this.positionDropdown():(null===(t=this._items)||void 0===t?void 0:t.length)>0&&(this._items=[])}render(){return e(i,null,e("div",{class:`snk-data-exporter\n ${this.canShowDropdown()?" ez-elevation--16":""}\n `},e("ez-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)}};y.style=".sc-snk-data-exporter-h{display:flex;width:fit-content;height:fit-content}.snk-data-exporter.sc-snk-data-exporter{display:flex;width:fit-content;height:fit-content}.snk-data-exporter__dropdown.sc-snk-data-exporter{display:none}.snk-data-exporter__dropdown--show.sc-snk-data-exporter{display:flex;flex-direction:column;position:fixed}.snk-data-exporter__dropdown.sc-snk-data-exporter>ez-dropdown.sc-snk-data-exporter{position:relative}";export{y as snk_data_exporter}
|
@@ -1 +0,0 @@
|
|
1
|
-
import{r as i,h as t,H as s,g as e,c as n}from"./p-d2d301a6.js";import{ApplicationContext as o,StringUtils as r,ErrorException as a,WarningException as l,ObjectUtils as c,DateUtils as d,ServiceUtils as h,StorageType as u,ArrayUtils as g,ElementIDUtils as f}from"@sankhyalabs/core";import{D as m}from"./p-5a7e18f4.js";import{P as p}from"./p-eaad0aa8.js";import"./p-ef076eea.js";import"./p-0f3698af.js";import"./p-21749402.js";import"@sankhyalabs/ezui/dist/collection/utils/constants";import"@sankhyalabs/core/dist/dataunit/metadata/UnitMetadata";import"./p-7e0a0aae.js";import"./p-ff1990ad.js";import{F as v}from"./p-22ddc147.js";import{O as b}from"./p-1d19a5b0.js";import{g as k}from"./p-7dd49d15.js";import{R as _}from"./p-688dcb4c.js";import{ApplicationUtils as w,DialogType as y}from"@sankhyalabs/ezui/dist/collection/utils";import{CheckMode as C}from"@sankhyalabs/ezui/dist/collection/components/ez-check/CheckMode";import{C as x}from"./p-3fcb90d6.js";import"./p-8d884fab.js";import"@sankhyalabs/ezui/dist/collection/components/ez-grid/utils";import"@sankhyalabs/core/dist/utils/SortingUtils";class S{execute(i){var t;const s={actionID:i.actionID,refreshType:null===(t=i.actionConfig.javaCall)||void 0===t?void 0:t.refreshType};return new Promise((i=>{i({execSource:s,callback:this.callExecJava})}))}async callExecJava(i){const t={requestBody:{javaCall:i}};await m.get().callServiceBroker("ActionButtonsSP.executeJava",JSON.stringify(t))}}class z{execute(i){var t;const s={actionID:i.actionID,refreshType:null===(t=i.actionConfig.runScript)||void 0===t?void 0:t.refreshType};return new Promise((i=>{i({execSource:s,callback:this.callExecScript})}))}async callExecScript(i){const t={runScript:i};await m.get().callServiceBroker("ActionButtonsSP.executeScript",t)}}class A{constructor(){this._application=o.getContextValue("__SNK__APPLICATION__")}async execute(i,t){const s=i.resourceID;if(!s)return;let e=await this.buildLaunchObject(i,t);return this._application.openApp(s,e),null}buildLaunchObject(i,t){return new Promise((s=>{let e=i.actionConfig.params.param;if(e&&e.length>0){let n={},o=[];e.forEach((s=>{const e=s.localField;let l=t.getFieldValue(e);if(!l){let s=t.getField(e).label;throw s=r.isEmpty(t.getField(e).label)?e:s,new a(this._application.messagesBuilder.getMessage("snkActionsButton.title.error",void 0),this._application.messagesBuilder.getMessage("snkActionsButton.launchScreen.emptyField",{description:i.description,localFieldLabel:s}))}l=r.isEmpty(l.toString())?void 0:l.toString(),n[s.targetField]=l,o.push({fieldName:s.targetField,value:l})})),n.ACTION_PARAMETERS=o,n.call_time=Date.now(),s(n)}s(null)}))}}class O{execute(i){var t,s,e;const n=null===(t=i.actionConfig.dbCall)||void 0===t?void 0:t.name,o=null===(s=i.actionConfig.dbCall)||void 0===s?void 0:s.rootEntity,r={actionID:i.actionID,refreshType:null===(e=i.actionConfig.dbCall)||void 0===e?void 0:e.refreshType,procName:n,rootEntity:o};return new Promise((i=>{i({execSource:r,callback:this.callExecProcedure})}))}async callExecProcedure(i){const t={requestBody:{stpCall:i}};await m.get().callServiceBroker("ActionButtonsSP.executeSTP",JSON.stringify(t))}}var P,D;!function(i){i.LAUNCH_SCREEN="LC",i.JAVASCRIPT="SC",i.JAVA="RJ",i.PROCEDURE="SP",i.EMBEDDED="EB"}(P||(P={}));class N{constructor(i){this.actionType=i,this._application=o.getContextValue("__SNK__APPLICATION__")}get executor(){switch(this.actionType){case P.LAUNCH_SCREEN:return new A;case P.JAVASCRIPT:return new z;case P.JAVA:return new S;case P.PROCEDURE:return new O;default:throw new a(this._application.messagesBuilder.getMessage("snkActionsButton.title.error",void 0),this._application.messagesBuilder.getMessage("snkActionsButton.action.nonExistentType",{actionType:this.actionType}))}}}!function(i){i.NONE="NONE",i.PARENT="PARENT",i.MASTER="MASTER",i.ALL="ALL"}(D||(D={}));const E="__MASTER_ROW__";class I{constructor(i,t,s){var e;this._lastValuesCache={},this._actionsExecuteInterface=i,this._dataUnit=t,this._selectedRows=(null===(e=null==t?void 0:t.getSelectionInfo())||void 0===e?void 0:e.isAllRecords())?[]:null==t?void 0:t.getSelectionInfo().records,this._application=o.getContextValue("__SNK__APPLICATION__"),this._appResourceId=s}getPrimaryKeys(){return k(this._dataUnit).map((({name:i})=>i))}apply(i,t){this._application.closePopUp(),this._actionsExecuteInterface.execute(i,this._dataUnit).then((({execSource:s,callback:e})=>{this.resolvePromptParams(i,s,t).then((()=>{this.actionExecute(s,e)}))}))}async execute(i){var t;if(!i.actionConfig)throw new l(this._application.messagesBuilder.getMessage("snkActionsButton.title.warning",void 0),this._application.messagesBuilder.getMessage("snkActionsButton.action.incorrectAction",{description:i.description}));if(null===(t=i.actionConfig.params)||void 0===t?void 0:t.promptParam){const t=i.actionConfig.params.promptParam;let s=!1;for(let i=0;i<t.length;i++)if(!s&&"true"===t[i].saveLast){s=!0;break}s&&(i.actionConfig.params.promptParam=await this.loadSavedValuesIntoParams(i));const e=document.createElement("snk-actions-form");window.document.body.appendChild(e),e.action=c.copy(i),e.applyParameters=i=>{this.apply(i,s)},e.openPopup()}else i.type!=P.LAUNCH_SCREEN?this._actionsExecuteInterface.execute(i,this._dataUnit).then((({execSource:i,callback:t})=>{this.actionExecute(i,t)})):this._actionsExecuteInterface.execute(i,this._dataUnit)}loadSavedValuesIntoParams(i){return this.loadLastValues(i).then((t=>{let s=i.actionConfig.params.promptParam;return t&&t.param.forEach((i=>{s=s.map((t=>t.name!==i.paramName?t:Object.assign(Object.assign({},t),"B"===t.paramType?{value:"S"===i.$}:{value:i.$})))})),s}))}async actionExecute(i,t){i.virtualPage=this.buildVirtualPage(),await this.prepareAndExecute(i,t),this.recordsReloader(i.refreshType)}resolvePromptParams(i,t,s){return new Promise((e=>{let n=[];i.actionConfig.params.promptParam.forEach((i=>{n.push(this.buildPromptParam(i))})),this.putParamsOnExecSource(n,t),s&&this.saveLastValues(i,n),e()}))}buildPromptParam(i){let t,s,e=i.paramType,n=!1,o=i.value;switch(e){case p.DATE:e="D";break;case p.DATETIME:e="H";break;case p.DECIMAL:e="F",t={"sk-precision":Number(i.precision)};break;case p.BOOLEAN:e="S",n=!0,o=i.value?"S":"N";break;case p.ENTITY:t={"sk-entity-name":i.entityName,"sk-allow-show-hierarchical-mode":i.hierarchyEntity,"sk-data-type":"S"},i.hierarchyEntity&&i.entityPK&&(s=i.entityPK),o=i.value?Number(i.value):null;break;case p.OPTIONS:e="O";let r=i.options.split(";").map((function(i,t){let s,e;if(i.indexOf("=")>-1){let t=i.split("=");s=t[0],e=t[1]}else s=t+1,e=i;return{data:s,value:e}}));t={"sk-options":r}}return{description:i.label,required:"true"==i.required,fieldName:i.name,fieldNameOri:i.name,entityPK:s,paramType:i.paramType,type:e,isCheckbox:n,saveLast:i.saveLast,fieldProp:t,value:o,isGeneratedName:i.isGeneratedName}}putParamsOnExecSource(i,t){t.params={param:[]},i.forEach((i=>{if(i.isGeneratedName&&i.value)throw new a(this._application.messagesBuilder.getMessage("snkActionsButton.title.error",void 0),this._application.messagesBuilder.getMessage("snkActionsButton.action.emptyParamName",void 0));r.isEmpty(i.value)||t.params.param.push({type:this.getParamDataType(i.paramType),paramName:i.fieldName,$:this.getParamValue(i)})}))}getParamDataType(i){let t;switch(i){case"D":t="F";break;case"DT":case"DH":t="D";break;case"B":case"ENTITY":case"SO":t="S";break;default:t=i}return t}getParamValue(i){let t=i.value;return t?("DT"==i.paramType?t=d.formatDate(t):"DH"==i.paramType&&(t=d.formatDateTime(t)),t):t}async loadLastValues(i){const t=await this.buildResourceId(i.actionID);return new Promise(((i,s)=>{if(this._lastValuesCache[t])i(this._lastValuesCache[t]);else{const e={config:{chave:t,tipo:"T"}};m.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[t]=o,i(o)})).catch((i=>{s(i)}))}}))}async saveLastValues(i,t){if(this._application){let s={params:{param:[]}};t.forEach((i=>{"true"==i.saveLast&&s.params.param.push({paramName:i.fieldName,$:i.value})}));const e=await this.buildResourceId(i.actionID);this._lastValuesCache[e]=s.params,this._application.saveConfig(e,s)}}async buildResourceId(i){return this._appResourceId+".actionconfig."+i}async prepareAndExecute(i,t){this.addRows(i),await t(i)}addRows(i){const t=this.getPrimaryKeys(),s={row:[]},e=this._selectedRows;for(const i in e){const n=e[i],o={};n.hasOwnProperty(E)&&(o.master="S",o.entityName=n.__ENTITY_NAME__,delete n[E],delete n.__ENTITY_NAME__),o.field||(o.field=[]);for(const i of t)o.field.push({fieldName:i,$:n[i]});s.row.push(o)}s.row.length>0&&(i.rows=s)}recordsReloader(i){switch(i){case D.NONE:break;case D.PARENT:case D.MASTER:case D.ALL:this._dataUnit.loadData();break;default:this._dataUnit.reloadCurrentRecord()}}buildVirtualPage(){var i,t,s,e;if(null===(t=null===(i=this._dataUnit)||void 0===i?void 0:i.getSelectionInfo())||void 0===t?void 0:t.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 L{async clientConfirm(i,t){return new Promise((s=>{const e=o.getContextValue("__SNK__APPLICATION__");let n="";i.content.event.hasOwnProperty("stpCall")?(t.requestBody=i.content.event.stpCall,n=P.PROCEDURE):i.content.event.hasOwnProperty("runScript")?(t.requestBody=i.content.event.runScript,n=P.JAVASCRIPT):i.content.event.hasOwnProperty("javaCall")&&(t.requestBody=i.content.event.javaCall,n=P.JAVA);let r={type:"S",sequence:i.content.event.sequence};t.requestBody.params?Array.isArray(t.requestBody.params.param)||(t.requestBody.params.param=[t.requestBody.params.param]):t.requestBody.params={param:[]},t.requestBody.params.param.push(r);const a=i.content.event.title.$,l=i.content.event.message.$;let c;switch(n){case P.JAVASCRIPT:c={runScript:t.requestBody};break;case P.PROCEDURE:c={requestBody:{stpCall:t.requestBody}};break;case P.JAVA:c={requestBody:{javaCall:t.requestBody}}}if("S"==i.content.event.showNoOption){r.paramName="__ESCOLHA_SIMNAO__";const i=document.createElement("snk-client-confirm");window.document.body.appendChild(i),i.titleMessage=a,i.message=l,i.accept=async()=>{r.$="S",await t.reCall(c),s()},i.cancel=async()=>{r.$="N",await t.reCall(c),s()},i.openPopup()}else e.confirm(a,l,null,"warn",{labelCancel:"Cancelar",labelConfirm:"Sim"}).then((async i=>{i&&(r.paramName="__CONFIRMACAO__",r.$="S",await t.reCall(c),s())}))}))}}const j=class{constructor(t){i(this,t),this.CLIENT_EVENT_CONFIRM_NAME="br.com.sankhya.actionbutton.clientconfirm",this._actions=[],this.handleClick=i=>{const t=this._actions.find((t=>t.actionID==i.detail.id)),s=new N(t.type).executor;new I(s,this._dataUnit,this._resourceID).execute(Object.assign({},t)),this._showDropdown=!1},this._items=[],this._showDropdown=!1}async getActions(){const i=await h.useCacheWithService(`SnkActionsButton_${this._entityName}-${this._resourceID}`,(async()=>{var i;const t={param:{entityName:this._entityName,resourceID:this._resourceID}};return(null===(i=(await m.get().callServiceBroker("ActionButtonsSP.getActions",t)).actions)||void 0===i?void 0:i.action)||[]}),u.IN_MEMORY_CACHE);this._actions=j.parameters.isOrderActions?g.sortAlphabetically(i,"description"):i}controlDropdown(){this._showDropdown=!this._showDropdown}canShowDropdown(){var i;return this._showDropdown&&(null===(i=this._items)||void 0===i?void 0:i.length)>0}positionDropdown(){var i;const t=null===(i=this._ezButton)||void 0===i?void 0:i.getBoundingClientRect();t&&this._dropdownParent&&(this._dropdownParent.style.top=t.y+t.height+5+"px",this._dropdownParent.style.left=t.x+"px")}closeDropdown(i){const t=null==i?void 0:i.target;t&&(t.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__"),await this.loadParameters();const i=this._element.parentElement;this._dataUnit=null==i?void 0:i.dataUnit,this._resourceID=null==i?void 0:i.resourceID,this._entityName=this._dataUnit.name.split("/")[2],null==this._resourceID&&(this._resourceID=await _.getResourceID()),this.setEvents(),await this.getActions(),this.loadItems()}async componentDidLoad(){if(this._element&&(f.addIDInfo(this._element),this.positionDropdown(),!await this._application.hasClientEvent(this.CLIENT_EVENT_CONFIRM_NAME))){const i=new L;this._application.addClientEvent(this.CLIENT_EVENT_CONFIRM_NAME,i.clientConfirm)}}componentDidUpdate(){this.positionDropdown()}loadItems(){this._actions&&0!=this._actions.length&&this._actions.forEach((i=>{this._items.push({id:i.actionID,label:i.description})}))}getElementID(i){return{[f.DATA_ELEMENT_ID_ATTRIBUTE_NAME]:f.getInternalIDInfo(i)}}async loadParameters(){null==j.parameters.isOrderActions&&(j.parameters.isOrderActions=await this._application.getBooleanParam("global.ordenar.acoes.personalizadas"))}render(){return t(s,null,this._actions&&this._actions.length>0&&t("div",{class:`ez-padding-left--medium snk-actions-button\n ${this.canShowDropdown()?" ez-elevation--16":""}\n `},t("ez-button",Object.assign({ref:i=>this._ezButton=i,iconName:"acao",size:"small",mode:"icon",title:this._application.messagesBuilder.getMessage("snkActionsButton.title.actions",void 0),onClick:()=>this.controlDropdown()},this.getElementID("button"))),t("div",Object.assign({ref:i=>this._dropdownParent=i,class:(this.canShowDropdown()?"snk-actions-button__dropdown--show":"snk-actions-button__dropdown")+"\n "},this.getElementID("dropdown")),this.canShowDropdown()&&t("ez-dropdown",Object.assign({items:this._items,onEzClick:i=>this.handleClick(i)},this.getElementID("dropdown"))))),this.canShowDropdown()&&t("div",Object.assign({class:"ez-scrim ez-scrim--light"},this.getElementID("ezScrim"))))}get _element(){return e(this)}};j.parameters={isOrderActions:null},j.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 B=class{constructor(t){i(this,t),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(i,t){return o.getContextValue("__SNK__APPLICATION__").messagesBuilder.getMessage(i,t)}getSortableColumns(){let i=[];return this.columns.filter((i=>{var t;return r.getBooleanValue(null===(t=null==i?void 0:i.props)||void 0===t?void 0:t.get("sortable"),!0)})).forEach((t=>{var s;let e=null===(s=this.config)||void 0===s?void 0:s.columns.find((i=>i.name===t.name)),n={name:t.name,label:t.label};e&&(n.orderIndex=e.orderIndex,n.ascending=e.ascending),t.hidden||i.push(n)})),i}createOrderList(){let i=this.getSortableColumns();i.sort(((i,t)=>0!=i.orderIndex||0!=t.orderIndex||null==i.ascending&&null==t.ascending?null!=i.ascending&&null!=t.ascending?i.orderIndex-t.orderIndex:null!=i.ascending||null!=t.ascending?null!=i.ascending?-1:null!=t.ascending?1:0:i.orderIndex-t.orderIndex:null!=i.ascending?-1:null!=t.ascending?1:0)),this._orderListItems=i}createColumnList(){let i={group:this.getMessage("snkGridConfig.group.visible"),items:[]},t={group:this.getMessage("snkGridConfig.group.hidden"),items:[],sort:b.asc.value};this.columns.forEach((s=>{let e={label:s.label};s.hidden?t.items.push(e):i.items.push(e)})),this._columListItems=[i,t]}createColumnListSlotDataElementId(i){return`configItem_${r.replaceAccentuatedChars(r.toCamelCase(i.label))}`}buildColumnListSlot(i,s){const e=this.createColumnListSlotDataElementId(i);return t("div",null,t("ez-check",{mode:C.SWITCH,id:C.SWITCH+((null==i?void 0:i.label)||"")+((null==s?void 0:s.group)||""),value:s.group===this.getMessage("snkGridConfig.group.visible"),"data-element-id":e,onEzChange:t=>{this.switchColumnGroup(t,i)}}))}createOrderListSlotDataElementId(i){return`${this._element.getAttribute(f.DATA_ELEMENT_ID_ATTRIBUTE_NAME)}_configItem_${r.toCamelCase(i.label)}`}buildOrderListSlot(i){const s=this.createOrderListSlotDataElementId(i);let e=b.none.value;return null!=(null==i?void 0:i.ascending)&&(e=1==i.ascending?b.asc.value:b.desc.value),t("div",null,t("snk-select-box",{selectedOption:e,key:"snk-select-box-"+this._componenteInternalKey+"-"+i,"data-element-id":s,onEzChange:t=>{t.stopPropagation(),this.updateOrder(t.detail,i.label)}}))}updateOrder(i,t){var s;this._dataChanged=!0;let e,n=[...this.columns],o=n.find((i=>i.label===t));o&&(o.sort=i.value===b.none.value?void 0:i.value),(null===(s=this._orderPriorityList)||void 0===s?void 0:s.length)>0?(this._orderPriorityList.find((i=>i.label===o.label)).sort=i,this._orderPriorityList.filter((i=>i.sort)).forEach(((i,t)=>{i.label===o.label&&(o.sortIndex=t)}))):(e=n.filter((i=>i.sort&&!0!==i.hidden)).map(((i,t)=>({label:i.label,orderIndex:t}))),e.forEach((i=>{n.find((t=>t.label===i.label)).sortIndex=i.orderIndex}))),this.columns=n}switchColumnGroup(i,t){i.stopPropagation();let s=[...this._columListItems];if(this._dataChanged=!0,!0===i.detail){let i=s.find((i=>i.group===this.getMessage("snkGridConfig.group.hidden"))),e=i.items.findIndex((i=>i.label===t.label));e>=0&&i.items.splice(e,1),s.find((i=>i.group===this.getMessage("snkGridConfig.group.visible"))).items.push(t),this._columListItems=s,this.createOrderList()}else if(!1===i.detail){let i=s.find((i=>i.group===this.getMessage("snkGridConfig.group.visible"))),e=i.items.findIndex((i=>i.label===t.label));e>=0&&i.items.splice(e,1),s.find((i=>i.group===this.getMessage("snkGridConfig.group.hidden"))).items.push(t),this._columListItems=s,this.createOrderList()}}finish(){if(!this._dataChanged)return void this.closeConfig();let i=[];this._columListItems.forEach((t=>{t.items.forEach((s=>{const e=this.columns.find((i=>i.label===s.label));let n=Object.assign({},e);n.hidden=t.group===this.getMessage("snkGridConfig.group.hidden"),i.push(n)}))})),this.columns=i,this._dataChanged=!1,this.closeConfig(),this.save()}saveGridConfigOnStorage(i){x.saveGridConfig(i,this.configName,this.resourceID).then((i=>{this.configChange.emit(i),this._orderList.clearHistory(),w.info(this.getMessage("snkGridConfig.info.successfullyConfigSaved"),{iconName:"check"})}))}reOrderPriorityColumns(i,t){let s=[];s=i.filter((i=>i.sort&&!0!==i.hidden)).map((i=>({label:i.label,orderIndex:0})));let e=0,n=[];return t.forEach((i=>{let t=s.find((t=>t.label===i.label));t&&(t.orderIndex=e,n.push(t),e++)})),n.length>0&&(s=n),s}save(){var i;let t;t=this.config?this.config:this.createConfigFromState(this.columns);let s,e=[];(null===(i=this._orderPriorityList)||void 0===i?void 0:i.length)>0&&(s=this.reOrderPriorityColumns(this.columns,this._orderPriorityList)),this.columns.forEach((i=>{let n=t.columns.find((t=>i.name===t.name));!0===i.hidden&&n||(n?n.width=i.width:!1===i.hidden&&(n={name:i.name,width:i.width,orderIndex:0}),n&&(i.sort?(n.ascending=i.sort.toUpperCase()===b.asc.value,s?function(i,t){if(s){let e=s.find((t=>t.label===i.label));e&&(t.orderIndex=e.orderIndex)}}(i,n):n.orderIndex=i.sortIndex):(delete n.ascending,n.orderIndex=0),e.push(n)))})),t.columns=e,this.saveGridConfigOnStorage(t)}createConfigFromState(i){let t={columns:[]};return i.forEach((i=>{if(!i.hidden){let s={name:i.name};i.width&&(s.width=i.width),i.sort?(s.ascending=i.sort.toUpperCase()===b.asc.value,s.orderIndex=i.sortIndex):s.orderIndex=0,s&&t.columns.push(s)}})),t}async locateColumn(i,t){var s;const e="Enter"===i.key;if(!(t=t||(null===(s=i.currentTarget)||void 0===s?void 0:s.value)))return void this.removeSelection();const n=await this.getMatchedIndexes(t),o=this.getNewSelectedIndex(n,e);this._selectedIndex=o,1===this.selectedIndex?this.updateOrderListSelection(o):this.updateColumnListSelection(o)}async getMatchedIndexes(i){const t=[];return 1===this.selectedIndex?(await this._orderList.getList()).forEach(((s,e)=>{this.compareWords(s,i)&&t.push(e)})):this.columns.forEach(((s,e)=>{this.compareWords(s,i)&&t.push(e)})),t}getNewSelectedIndex(i,t){if(0===i.length)return-1;if(t)for(const t of i)if(t>this._selectedIndex)return t;return i[0]}updateOrderListSelection(i){-1!==i?this._orderList.getList().then((t=>{const s=t[i];s?this._orderList.setSelection(s,!0):this._orderList.removeSelection()})):this._orderList.removeSelection()}updateColumnListSelection(i){if(-1===i)return void this._columnList.removeSelection();const t=this.columns[i];if(t){const i=this._columListItems.map((i=>i.items)).flat().find((i=>i.label===t.label));i?this._columnList.setSelection(i,!0):this._columnList.removeSelection()}else this._columnList.removeSelection()}removeSelection(){1===this.selectedIndex?this._orderList.removeSelection():this._columnList.removeSelection()}compareWords(i,t){var s,e;const n=null===(s=r.replaceAccentuatedChars(null==i?void 0:i.label))||void 0===s?void 0:s.toUpperCase(),o=null===(e=r.replaceAccentuatedChars(t))||void 0===e?void 0:e.toUpperCase();return!r.isEmpty(n)&&!r.isEmpty(o)&&n.includes(o)}getColumnNames(){const i=[];return i.push(this.getMessage("snkGridConfig.tab.columns")),i.push(this.getMessage("snkGridConfig.tab.lineOrdering")),i.join(",")}closeConfig(){if(this._orderList.scrollToTop(),this._columnList.scrollToTop(),this._searchElement.value="",this._dataChanged){let i={canClose:!1,labelCancel:this.getMessage("snkGridConfig.confirm.cancel"),labelConfirm:this.getMessage("snkGridConfig.confirm.save"),btnConfirmDanger:!1};w.confirm(this.getMessage("snkGridConfig.confirm.alert"),this.getMessage("snkGridConfig.confirm.msgCancel"),null,y.WARN,i).then((i=>{i?this.finish():(this._dataChanged=!1,this.configCancel.emit(),this._orderList.clearHistory(),this._componenteInternalKey=Date.now())}))}else this.configCancel.emit(),this._orderList.clearHistory()}handleTabChange(i){null!=(null==i?void 0:i.index)&&(this.selectedIndex!==i.index&&(0===i.index?this._orderList.scrollToTop():1===i.index&&this._columnList.scrollToTop(),this._searchElement.value=""),1===i.index&&this.createOrderList(),this.selectedIndex=i.index)}handleColumnListChange(i){var t;if(i.detail){let s=null===(t=i.detail.find((i=>i.group===this.getMessage("snkGridConfig.group.visible"))))||void 0===t?void 0:t.items;s&&(this._dataChanged=!0,this._orderListItems=s)}}handleOrderListChange(i){if(i.detail){let t=i.detail;t&&(this._dataChanged=!0,this._orderPriorityList=t)}}componentWillRender(){var i;(null===(i=this.columns)||void 0===i?void 0:i.length)>0&&this.createColumnList()}componentDidRender(){var i;(null===(i=this.columns)||void 0===i?void 0:i.length)>0&&this.locateColumn(new KeyboardEvent("arrow-right",{key:"ArrowRight"}),this._searchElement.value)}componentDidLoad(){f.addIDInfo(this._element)}render(){return t(s,null,t("div",{class:"grid-config__header"},t("div",{class:"title-container"},t("div",{class:""},t("label",{class:"title"},this.getMessage("snkGridConfig.gridConfiguration")),t("label",{class:"subtitle"},this.getMessage("snkGridConfig.columnVisibilityOrder"))),t("div",{class:"button-close"},t("ez-button",{mode:"icon",iconName:"close",size:"medium",onClick:()=>this.closeConfig()}))),t("div",{class:"tabselector-container"},t("ez-tabselector",{selectedIndex:this.selectedIndex,onEzChange:i=>{this.handleTabChange(i.detail)},tabs:this.getColumnNames()})),t("div",null,t("ez-text-input",{"data-element-id":"searchColums",ref:i=>this._searchElement=i,label:this.getMessage("snkGridConfig.findColumn"),onKeyUp:i=>this.locateColumn(i)},t("ez-icon",{slot:"leftIcon",size:"medium",iconName:"search"})))),t("div",{class:"grid-config__main"},t("ez-list",{ref:i=>this._columnList=i,class:0===this.selectedIndex?"":"hidden",dataSource:this._columListItems,onEzChange:i=>this.handleColumnListChange(i),ezDraggable:!0,ezSelectable:!0,itemSlotBuilder:(i,t)=>this.buildColumnListSlot(i,t),useGroups:!0,"data-element-id":"configCols"}),t("div",{class:1===this.selectedIndex?"group-name":"hidden"},this.getMessage("snkGridConfig.info.sortingSequence")),t("ez-list",{ref:i=>this._orderList=i,class:1===this.selectedIndex?"height-calc":"hidden",dataSource:this._orderListItems,ezSelectable:!0,onEzChange:i=>this.handleOrderListChange(i),ezDraggable:!0,itemSlotBuilder:i=>this.buildOrderListSlot(i),"data-element-id":"configDataOrder"})),t("div",{class:"grid-config__footer"},t("ez-button",{class:"padding-right--medium",label:this.getMessage("snkGridConfig.cancel"),onClick:()=>this.closeConfig()}),t("ez-button",{label:this.getMessage("snkGridConfig.complete"),class:"ez-button--primary",onClick:()=>this.finish()})))}static get assetsDirs(){return["../assets"]}get _element(){return e(this)}};B.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--small, 6px);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 T=class{constructor(t){i(this,t),this.ezChange=n(this,"ezChange",7),this.selectedOption=b.none}render(){return t("ez-combo-box",{class:"grid-config-combo ez-input--inverted",label:"",suppressSearch:!0,value:this.selectedOption,enabled:!0,canShowError:!1,suppressEmptyOption:!0},Object.keys(b).map((i=>t("option",{value:b[i].value},b[i].label))))}static get assetsDirs(){return["../assets"]}};T.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 G=class{constructor(t){i(this,t),this.snkConfigSaved=n(this,"snkConfigSaved",7),this._formConfigFetcher=new v,this.fieldsToSave=[],this.dataUnit=void 0,this.configName=void 0,this.avaliableFields=[],this.selectedFields=[]}async show(){var i;await(null===(i=this.ezDoubleListRef)||void 0===i?void 0:i.resetSelectedLists()),await this.initializeFormConfig(),this.ezPopupRef.opened=!0}async initializeFormConfig(){if(!this.configName)return;const i=this.getAllVisibleFieldsFromDataUnit(),t=await this.getConfig();if(0===t.length)return this.avaliableFields=[],this.selectedFields=[...i],void(this.fieldsToSave=[...this.selectedFields]);const s=this.sortDisplayedFields(t,i),e=i.filter((i=>!t.includes(i.id)));this.avaliableFields=[...e],this.selectedFields=[...s],this.fieldsToSave=[...this.selectedFields]}async getConfig(){const i=await this._formConfigFetcher.fetchSimpleFormConfig(this.configName);return[...this.removeDuplicates(i)]}removeDuplicates(i){return i.filter(((t,s)=>i.indexOf(t)===s))}sortDisplayedFields(i,t){const s=[];return i.forEach((i=>{const e=t.find((t=>t.id===i));e&&s.push(e)})),s}getAllVisibleFieldsFromDataUnit(){var i,t,s;return(null!==(s=null===(t=null===(i=this.dataUnit)||void 0===i?void 0:i.metadata)||void 0===t?void 0:t.fields)&&void 0!==s?s:[]).filter((i=>i.visible)).map((i=>({id:i.name,label:i.label})))}close(){this.ezPopupRef.opened=!1}async handleResetConfigs(){await this._formConfigFetcher.restoreFormConfig(this.configName),await this.initializeFormConfig(),await this.handleSave()}handleCancel(){this.close()}async handleSave(){const i=this.fieldsToSave.map((i=>i.id));await this._formConfigFetcher.saveSimpleFormConfig(this.configName,i),this.close(),this.snkConfigSaved.emit()}render(){return t("ez-popup",{ref:i=>this.ezPopupRef=i,heightMode:"auto",size:"auto",ezTitle:"Configurar formulário"},t("div",{class:"config-container"},t("div",{class:"config-lists"},t("ez-double-list",{ref:i=>this.ezDoubleListRef=i,leftList:this.avaliableFields,leftTitle:"Campos disponíveis",rightList:this.selectedFields,rightTitle:"Campos selecionados",onEzRightListChanged:({detail:i})=>this.fieldsToSave=[...i],entityLabel:"campo",entityLabelPlural:"campos"})),t("div",{class:"config-actions"},t("ez-button",{label:"Restaurar",onClick:this.handleResetConfigs.bind(this),size:"small"}),t("ez-button",{label:"Cancelar",onClick:this.handleCancel.bind(this),size:"small"}),t("ez-button",{label:"Salvar",class:"ez-button--primary",onClick:this.handleSave.bind(this),size:"small"}))))}};G.style=":host{display:block}.config-container{display:flex;flex-direction:column;align-items:center;justify-content:space-between}.config-lists{margin-bottom:12px}.config-actions{display:flex;flex-direction:row;justify-content:flex-end;width:100%;gap:12px}";const R=class{constructor(t){i(this,t),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(i){"Escape"!==i.key&&"Esc"!==i.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((i=>void 0!==i)).map((i=>{var t;return{id:i.value,label:i.label,value:i.value,type:null!==(t=i.type)&&void 0!==t?t:"item",children:i.children,iconName:i.iconName,subAction:i.subAction,group:i.group,disableCloseOnSelect:i.disableCloseOnSelect}}))}canShowDropdown(){var i;return this._showDropdown&&(null===(i=this.actions)||void 0===i?void 0:i.length)>0}onSelectAction(i){const t=this.actions.map((i=>Object.assign(Object.assign({},i),{id:i.value}))),s=this.getSelectedAction(i.id,t);this.taskbarActionSelected.emit(s),s.disableCloseOnSelect||(this._showDropdown=!1)}getSelectedAction(i,t){let s=null;for(const e of t){if(e.id===i){s=e;break}if((null==e?void 0:e.children)&&(s=this.getSelectedAction(i,e.children),s))break}return s}dropdownItemBuilder(i,s){const e=this.actions.find((t=>t.value===i.id));if(!e||!e.itemBuilder)return;const n=e.itemBuilder(this._element,e);return"string"==typeof n?t("div",{innerHTML:n}):n}initializeEagerItems(){var i;null===(i=this.actions)||void 0===i||i.forEach((i=>{var t;i&&i.eagerInitialize&&i.itemBuilder&&(null===(t=i.itemBuilder)||void 0===t||t.call(i,this._element,i))}))}componentDidLoad(){this.initializeEagerItems()}componentDidRender(){this._showDropdown&&this.taskbarActionsOpened.emit(this._element)}disconnectedCallback(){this.taskbarActionsButtonDisconnected.emit()}render(){return t(s,null,t("div",{class:this.canShowDropdown()?" ez-elevation--16":""},t("ez-button",{title:this.title,mode:"icon",iconName:"dots-vertical",size:"small",enabled:this.enabled,onClick:()=>this.controlDropdown()}),this.canShowDropdown()&&t("ez-dropdown",{items:this.loadItems(),onEzClick:i=>this.onSelectAction(i.detail),onEzOutsideClick:()=>this._showDropdown=!1,itemBuilder:(i,t)=>this.dropdownItemBuilder(i,t)})))}get _element(){return e(this)}};R.style=".sc-taskbar-actions-button-h{display:flex;width:fit-content;height:fit-content}";export{j as snk_actions_button,B as snk_grid_config,T as snk_select_box,G as snk_simple_form_config,R as taskbar_actions_button}
|
@@ -1 +0,0 @@
|
|
1
|
-
export{S as snk_guides_viewer}from"./p-04b96ffe.js";import"./p-d2d301a6.js";import"@sankhyalabs/core";import"./p-3ce68be5.js";import"./p-3fcb90d6.js";import"./p-22ddc147.js";import"./p-5a7e18f4.js";import"./p-8d884fab.js";import"@sankhyalabs/core/dist/dataunit/metadata/UnitMetadata";import"./p-ff1990ad.js";import"./p-1d19a5b0.js";import"@sankhyalabs/ezui/dist/collection/utils/form";import"./p-23736d75.js";import"./p-3fc82614.js";import"./p-0f3698af.js";import"./p-6dc031de.js";import"./p-ef076eea.js";import"./p-21749402.js";import"@sankhyalabs/ezui/dist/collection/utils/constants";import"./p-7e0a0aae.js";import"@sankhyalabs/ezui/dist/collection/components/ez-grid/utils";import"@sankhyalabs/core/dist/utils/SortingUtils";import"./p-688dcb4c.js";import"@sankhyalabs/core/dist/dataunit/DataUnit";
|
@@ -1 +0,0 @@
|
|
1
|
-
import{D as t}from"./p-5a7e18f4.js";import"./p-ef076eea.js";import{SortMode as i,ApplicationContext as s,UserInterface as e,DateUtils as r,ObjectUtils as n,StringUtils as o,NumberUtils as a,DataType as l}from"@sankhyalabs/core";import{D as u}from"./p-0f3698af.js";import"./p-21749402.js";import"@sankhyalabs/ezui/dist/collection/utils/constants";import{UserInterface as d}from"@sankhyalabs/core/dist/dataunit/metadata/UnitMetadata";import{P as c}from"./p-7e0a0aae.js";import"./p-ff1990ad.js";import"./p-22ddc147.js";import"./p-1d19a5b0.js";import h from"@sankhyalabs/ezui/dist/collection/components/ez-grid/utils/InMemoryFilterColumnDataSource";import{h as v}from"./p-d2d301a6.js";import{g as f}from"./p-7dd49d15.js";import{I as m}from"./p-8f3f2306.js";class p{static assertDefaultSorting(t,s){t&&s&&(s.defaultSorting=t.columns.filter((t=>null!=t.ascending)).sort(((t,i)=>t.orderIndex-i.orderIndex)).map((({name:t,ascending:e})=>{const{dataType:r}=s.getField(t);return{field:t,dataType:r,mode:e?i.ASC:i.DESC}})))}static parseCrudResults(t,i){Array.isArray(t)||(t=[t]);const s=[];for(const e of t){let t={fields:new Map};for(let s in e){let r=e[s];if(r.hasOwnProperty("$")&&t.fields.set(s,r.$),i)break}s.push(t)}return s.length>1?s:s[0]}static find(i,e,r,n=!0,o,a){let l=[],u=[],d={},c=s.getContextValue("__SNK__APPLICATION__");if(e){if(!Array.isArray(e))throw new Error(c.messagesBuilder.getMessage("crudUtils.errorArray",null));e.forEach((t=>{l.push({name:t})}))}if(r)for(const t in r)r.hasOwnProperty(t)&&u.push({nome:t,valor:r[t]});o&&(d={expression:{$:o}});let h={requestBody:{entity:{name:i,criterio:u,fields:{field:l},literalCriteria:d,orderby:a}}};return new Promise((i=>{t.get().callServiceBroker("mge@crud.find",JSON.stringify(h)).then((t=>{var s;let e=null===(s=t.entidades)||void 0===s?void 0:s.entidade;e||i(null);const r=this.parseCrudResults(e,n);i(r)}))}))}}class b{setDataUnit(t){this._dataUnit=t}setApplication(t){this._application=t}formatLabel(t,i){const{userInterface:s}=this._dataUnit.getField(t);return s===e.DATETIME?r.formatDate(this._dataUnit.valueFromString(t,i)):String(this._dataUnit.getFormattedValue(t,i))}async getStaticOptions(t){return Promise.resolve(null==t?void 0:await c.getDistinct(this._dataUnit,t))}fetchData(t,i){return new Promise((s=>{this._application.executeSelectDistinct(this._dataUnit,i,t).then((t=>{s(t.map((t=>this._dataUnit.getField(i).userInterface===e.SEARCH?Object.assign(Object.assign({},JSON.parse(t)),{check:!0}):{value:t,label:this.formatLabel(i,t),check:!0})))}))}))}sortItems(t,i){return h.defaultSorterMultSelectionOption(this._dataUnit,t,i)}}class y{setGrid(t){this._grid||(this._grid=t,this.refreshSelectedRows())}setDataState(t){this._dataState&&n.equals(null==t?void 0:t.metadataByRow,this._dataState.metadataByRow)||(this._dataState=t,this.refreshSelectedRows())}format(t,i,s){var e;if(o.isEmpty(t))return t;const r=null===(e=this._dataState)||void 0===e?void 0:e.metadataByRow.get(s),n=null==r?void 0:r.getProp("rm_precision",i.name);return n||0===n?a.format(t,n,n):t}refreshSelectedRows(){var t;null===(t=this._grid)||void 0===t||t.refreshSelectedRows()}}class g{constructor(t,i){this.MAX_WIDTH_COD=60,this.MIN_WIDTH_COD=10,this.DEFAULT_FONT_SIZE=13,this.dataUnit=t,this.grid=i}async getColumnsMetadata(){var t;return this.columnsState=await(null===(t=this.grid)||void 0===t?void 0:t.getColumnsState())||[],await this.buildColumnsMetadata(this.columnsState)}getColumnsState(){return this.columnsState}async buildColumnsMetadata(t){var i,s,e;const r=[];for(const n of t){if(n.hidden&&"RECDESP"!==n.name)continue;const t=null===(i=this.dataUnit)||void 0===i?void 0:i.getField(n.name),o=await this.grid.getCustomValueFormatter(n.name),a=(null==t?void 0:t.userInterface)===d.SEARCH,u=a?"Cód. ":n.label;let c,h={id:n.name,label:u,width:a?u.length*this.DEFAULT_FONT_SIZE:n.width,type:null==t?void 0:t.dataType,userInterface:null==t?void 0:t.userInterface,customFormatter:o};if(a){if(null!=(null===(s=null==t?void 0:t.properties)||void 0===s?void 0:s.DESCRIPTIONFIELD)){const i=null===(e=null==t?void 0:t.properties)||void 0===e?void 0:e.DESCRIPTIONENTITY,s=t.properties.mergedFrom;c={id:`${s?s+".":""}${t.properties.ENTITYNAME}.${t.properties.DESCRIPTIONFIELD}`,label:i,width:a&&i?i.length*this.DEFAULT_FONT_SIZE-60:n.width,type:l.TEXT,userInterface:d.LONGTEXT,descriptionFrom:t.name}}if(c){const t=this.getWidthByMetaData(null==n?void 0:n.width,null==h?void 0:h.width,null==c?void 0:c.width);h=Object.assign(Object.assign({},h),{width:null==t?void 0:t.codWidth}),c=Object.assign(Object.assign({},c),{width:null==t?void 0:t.descWidth,label:(null==c?void 0:c.label)||(null==n?void 0:n.label)})}}r.push(h),c&&r.push(c)}return r||[]}getWidthByMetaData(t,i,s){const e=i+s,r=s/e;let n=Math.round(t*(i/e)),o=Math.round(t*r);return n>this.MAX_WIDTH_COD?(n=this.MAX_WIDTH_COD,o=t-this.MAX_WIDTH_COD):n<this.MIN_WIDTH_COD&&(n=this.MIN_WIDTH_COD,o=t-this.MIN_WIDTH_COD),{codWidth:n,descWidth:o}}}class w{constructor(t,i,s){this.snkApplication=t,this.keyConfigEnableContinuousInsert=`${i}enableContinuousInsert${s||""}`}handleSaveConfig(t){return this.snkApplication.saveConfig(this.keyConfigEnableContinuousInsert,t)}getConfig(){return this.snkApplication.getConfig(this.keyConfigEnableContinuousInsert).then((t=>!!t&&"true"==t)).catch((()=>!1))}actionContinuousInsert(t,i){return{value:o.generateUUID(),label:t?"Desativar inclusão contínua":"Ativar inclusão contínua",enabled:!0,itemBuilder:()=>v("div",{class:"ez-dropdown__item-wrapper",onClick:i},v("span",{class:"ez-dropdown__item-label"},t?"Desativar inclusão contínua":"Ativar inclusão contínua"))}}}class j extends g{getSelectedNumber(){return this.dataUnit.getSelectionInfo().length}getTotalRecords(){var t,i,s;const{total:e}=(null===(t=this.dataUnit)||void 0===t?void 0:t.getPaginationInfo())||{};return null!=e?e:null===(s=null===(i=this.dataUnit)||void 0===i?void 0:i.records)||void 0===s?void 0:s.length}getSelectedIDs(){return f(this.dataUnit)}getRecordID(){var t,i,s;return null===(s=null===(i=null===(t=this.dataUnit)||void 0===t?void 0:t.records)||void 0===i?void 0:i[0])||void 0===s?void 0:s.__record__id__}async getRecords(t){if(0===this.dataUnit.records.length)return[];switch(t){case m.ALL:return this.dataUnit.getSelectionInfo().getAllRecords();case m.SELECTION:return this.resolveRecordsFromSelection();case m.PAGE:return this.dataUnit.records;default:return this.resolveRecordsFromSelection()}}resolveRecordsFromSelection(){const t=this.dataUnit.getSelectionInfo(),i=t.isEmpty()||t.isAllRecords()?t.getAllRecords():t.records;return i.length?i:this.dataUnit.records}getHiddenOptions(){return[u.EXPORT_BY_EMAIL,u.EXPORT_PDF_TO_EMAIL,u.EXPORT_XLS_TO_EMAIL,u.EXPORT_PAGE_TO_PDF,u.EXPORT_PAGE_TO_XLS]}formatValue(t,i){const{id:s,descriptionFrom:r}=i,n=t[r||s];if(null==n)return"";if(null!=r)return n.label;if(this.dataUnit.getField(s).userInterface===e.SEARCH)return n.value;if(i.customFormatter){const s=this.getColumnsState().find((t=>i.id===t.name));return i.customFormatter.format(n,s,t.__record__id__)}return this.dataUnit.getFormattedValue(s,n)}}export{g as C,y as R,b as S,p as a,w as b,j as c}
|
@@ -1 +0,0 @@
|
|
1
|
-
import{r as i,c as t,h as s,H as e,F as a}from"./p-d2d301a6.js";import{I as o}from"./p-7e0a0aae.js";import"./p-5a7e18f4.js";import{P as r}from"./p-ef076eea.js";import"@sankhyalabs/core";import"./p-0f3698af.js";import"./p-21749402.js";import"@sankhyalabs/ezui/dist/collection/utils/constants";import"@sankhyalabs/core/dist/dataunit/metadata/UnitMetadata";import"./p-ff1990ad.js";import"./p-22ddc147.js";import"./p-1d19a5b0.js";import{ApplicationUtils as n}from"@sankhyalabs/ezui/dist/collection/utils";import"@sankhyalabs/ezui/dist/collection/components/ez-grid/utils";import"@sankhyalabs/core/dist/utils/SortingUtils";import"./p-688dcb4c.js";import"./p-8d884fab.js";const h=class{constructor(s){i(this,s),this.pesquisaGridSelectItem=t(this,"pesquisaGridSelectItem",7),this._pesquisaFetcher=new r,this.metadata=void 0,this.dataSource=[],this.pkField=void 0,this.descriptionField=void 0,this.entityName=void 0,this.shouldLoadConfig=!1,this._gridConfig=void 0,this._inMemoryLoader=void 0,this._dataunit=void 0}observeDataSource(i){this._inMemoryLoader&&this._dataunit&&i&&(this._inMemoryLoader.records=[...i])}observeMetadata(){this.initializeDataUnit()}async observeShouldLoadConfig(i){i&&!this._gridConfig&&await this.loadGridConfig()}async loadGridConfig(){this._gridConfig=await this._pesquisaFetcher.loadPesquisaGridConfig(this.entityName)}initializeDataUnit(){var i;this.metadata&&(this._inMemoryLoader=new o(this.metadata,null!==(i=this.dataSource)&&void 0!==i?i:[]),this._dataunit=this._inMemoryLoader.dataUnit,this._dataunit.pageSize=0)}handleDbClick(i){this.pesquisaGridSelectItem.emit({value:i[this.pkField],label:i[this.descriptionField]})}async handleConfigChanged({detail:i}){var t;const s=null!==(t=null==i?void 0:i.columns)&&void 0!==t?t:[];await this._pesquisaFetcher.savePesquisaGridConfig(this.entityName,s)}render(){if(this.metadata&&this._dataunit)return s(e,null,s("ez-grid",{dataUnit:this._dataunit,config:this._gridConfig,canEdit:!1,suppressCheckboxColumn:!0,compact:!0,autoFocus:!1,onEzDoubleClick:({detail:i})=>this.handleDbClick(i),onConfigChange:async i=>this.handleConfigChanged(i)}))}static get watchers(){return{dataSource:["observeDataSource"],metadata:["observeMetadata"],shouldLoadConfig:["observeShouldLoadConfig"]}}};h.style=".sc-pesquisa-grid-h{background:var(--background--xlight, #FFF);overflow-x:auto}ez-grid.sc-pesquisa-grid{--ez-grid__container--shadow:none;--ez-grid__header--shadow:none}";const l=class{constructor(s){i(this,s),this.pesquisaTreeSelectItem=t(this,"pesquisaTreeSelectItem",7),this.treeLoader=void 0,this.argument=void 0,this.allowsNonAnalytic=!1,this.shouldLoadTree=!1,this.items=[]}async applyFilter(){await this._tree.applyFilter(this.argument)}async observeShouldLoadTree(i){!i||this.items.length>0||await this.loadTree()}async loadTree(){if(!this.shouldLoadTree)return;if(!this.treeLoader||"function"!=typeof this.treeLoader)return;const i=await this.treeLoader((this.argument||"").trim());this.items=[...i]}expandOrCloseAllItems(i,t){return i.map((i=>Object.assign(Object.assign({},i),{expanded:t,children:i.children?this.expandOrCloseAllItems(i.children,t):void 0})))}handleExpandAll(){this.items=[...this.expandOrCloseAllItems(this.items,!0)]}handleCloseAll(){this.items=[...this.expandOrCloseAllItems(this.items,!1)]}handleDbClick(i){var t;this.allowsNonAnalytic||(null===(t=i.props)||void 0===t?void 0:t.analitico)?this.pesquisaTreeSelectItem.emit({value:i.id,label:i.label}):n.error("Erro","Há pelo menos um registro inválido selecionado. Você deve selecionar itens do tipo 'analítico'.")}renderEmptyMessage(){return s("div",{class:"ez-flex ez-flex--justify-center ez-flex--align-items-center ez-margin--large ez-text ez-text--xlarge ez-text--secondary"},s("span",null,"Nenhum registro encontrado..."))}render(){var i;return s(e,null,(null===(i=this.items)||void 0===i?void 0:i.length)?s(a,null,s("div",{class:"actions-container"},s("ez-button",{size:"small",mode:"icon",class:"ez-margin-right--small",iconName:"show-list",title:"Expandir",onClick:()=>this.handleExpandAll()}),s("ez-button",{size:"small",mode:"icon",iconName:"hide-list",title:"Recolher",onClick:()=>this.handleCloseAll()})),s("ez-tree",{ref:i=>this._tree=i,onEzDbClickItem:({detail:i})=>this.handleDbClick(i),items:this.items})):this.renderEmptyMessage())}static get watchers(){return{shouldLoadTree:["observeShouldLoadTree"]}}};l.style=".sc-pesquisa-tree-h{--snk-pesquisa--tree__action-container--top:var(--space--sm);--snk-pesquisa--tree__action-container--right:var(--space--small);--snk-pesquisa--tree__min-height:var(--space--extra-large);background:var(--background--xlight, #FFF);position:relative;min-height:var(--snk-pesquisa--tree__min-height);height:100%;display:block;overflow-y:auto}.sc-pesquisa-tree-h:hover .actions-container.sc-pesquisa-tree{display:flex}.actions-container.sc-pesquisa-tree{flex-direction:row;position:absolute;top:var(--snk-pesquisa--tree__action-container--top);right:var(--snk-pesquisa--tree__action-container--right);display:none}";export{h as pesquisa_grid,l as pesquisa_tree}
|
@@ -1 +0,0 @@
|
|
1
|
-
import{r as s,h as i,H as e,g as t}from"./p-d2d301a6.js";import{ObjectUtils as a,StringUtils as r,ElementIDUtils as o}from"@sankhyalabs/core";import{P as n,b as l,a as c}from"./p-ef076eea.js";import"./p-5a7e18f4.js";import"./p-0f3698af.js";import"./p-21749402.js";import"@sankhyalabs/ezui/dist/collection/utils/constants";import"@sankhyalabs/core/dist/dataunit/metadata/UnitMetadata";import"./p-7e0a0aae.js";import"./p-ff1990ad.js";import"./p-22ddc147.js";import"./p-1d19a5b0.js";import"./p-8d884fab.js";import"@sankhyalabs/ezui/dist/collection/components/ez-grid/utils";import"@sankhyalabs/core/dist/utils/SortingUtils";import"./p-688dcb4c.js";const u=class{constructor(i){s(this,i),this._mdByName={},this._startHighlightTag="<span class='card-item__highlight'>",this._endHighlightTag="</span>",this._specialCharsRegex=/[[.\-\$\+\*,_\&\(\)%\/\\#@!:\|\=\'\"]/gim,this._charsWithAccentuation="ÁÉÍÓÚ_ÃÕ_ÂÊÎÔÛ_ÀÈÌÒÙ_Ü_Ç_áéíóú_ãõ_âêîôû_àèìòù_ü_ç",this._charsWithoutAccentuation="AEIOU_AO_AEIOU_AEIOU_U_C_aeiou_ao_aeiou_aeiou_u_c",this._changeDeboucingTimeout=null,this._limitCharsToSearch=3,this._deboucingTime=450,this._gridDataSource=[],this.pesquisaFetcher=new n,this._itemList=void 0,this._startLoading=!1,this._presentationMode="list",this._currentView=void 0,this.searchLoader=void 0,this.treeLoader=void 0,this.selectItem=void 0,this.entityName=void 0,this.argument=void 0,this.isHierarchyEntity=!1,this.allowsNonAnalytic=!1}observeArgument(){this._textInput&&(this._textInput.value=this.argument)}clearSearch(){this.argument="",this._itemList=void 0}buildDetails(s,i){let e={};for(let t=0;t<s.length;t++){const a=s[t],r=i[a.fieldName];e[a.description]=this.highlightValue(i.__matchFields,a.options&&a.options[r]||r,s,!0)}return e}buildFirstFields(s,i,e=6){return s&&Array.isArray(s)&&s.forEach((s=>{let e=this.removeReference(i,this._mdByName[s]);e&&i.unshift(e)})),i=i.slice(0,e)}doSearch(s){this.searchLoader&&"function"==typeof this.searchLoader&&(this._startLoading=!0,this.searchLoader(s).then((s=>{s&&this.processSearchResponse(s)})).finally((()=>{this._startLoading=!1})))}processSearchResponse(s){let i=(s=a.stringToObject(s.json.$)).descriptionField,e=s.pkField;e&&(this._gridMetadata=l(s),this._gridDataSource=[...s.data],this._pkField=e,this._descriptionField=i,this._itemList=this.buildCardItemList(s,e,i))}buildCardItemList(s,i,e){var t;return null===(t=s.data)||void 0===t?void 0:t.map((t=>{var a;let r=this.filterFieldsMetadata(s,t),o=this.buildFirstFields(t.__matchFields,r);return{key:this.highlightValue(t.__matchFields,null===(a=t[i])||void 0===a?void 0:a.toString(),o,!0),title:e?this.highlightValue(t.__matchFields,t[e],o,!0):"",details:this.buildDetails(o,t)}}))}filterFieldsMetadata(s,i){return s.fieldsMetadata.filter((e=>{let t=!r.isEmpty(i[e.fieldName])&&!1!==e.visible&&"B"!==e.type&&s.pkField!==e.fieldName&&s.descriptionField!==e.fieldName&&(e.isPrimaryKey||!e.isLinkField)&&!("S"===e.type&&"H"===e.presentationType);return t&&(this._mdByName[e.fieldName]=e),("string"!=typeof i[e.fieldName]||!(i[e.fieldName].indexOf("<img")>-1||i[e.fieldName].indexOf("<svg")>-1))&&t}))}removeAtIndex(s,i){if(i>=0&&i<s.length)return s.splice(i,1)[0]}removeReference(s,i){let e=this.indexOf(s,i);return this.removeAtIndex(s,e)}indexOf(s,i){let e=-1;return Array.isArray(s)&&this.find(s,((s,t)=>(e=t,this.equals(i,s)))),e}equals(s,i){return a.objectToString(s)===a.objectToString(i)}find(s,i){if(s)for(let e=0,t=s.length;e<t;e++)if(i(s[e],e,s))return s[e]}highlightValue(s,i,e,t){let a=this.replaceHtmlEntities(i);if(this.argument&&(t||this.isIn(s,e.fieldName))){const s=this.getArgumentNumber();let i=(isNaN(s)?this.argument:s.toString()).split(/%|,|\s+/),t=0,r=this.replaceAccentuatedChars(a);i.forEach((s=>{if(s){s=this.replaceAccentuatedChars(s);let i=this.getSpecialCharacters(s);null!=i&&i.length>0&&(s=this.removeSpecialCharacters(s)),(e.mask||"CGC_CPF"===e.uiType||"Phone"===e.uiType)&&(s=s.split("").join("\\.?\\-?\\/?\\(?\\)?"));let o=new RegExp(s,"ig");o.lastIndex=t;let n=o.exec(r);if(n&&n.length>0){t=n.index;let s=n[0].length,i=a.substring(t,t+s),e=(null==i?void 0:i.trim())?this._startHighlightTag+i+this._endHighlightTag:"",o=a.substring(0,t),l=a.substring(t+s);a=o+e+l,t+=e.length,r=this.replaceAccentuatedChars(a)}}}))}return a}replaceHtmlEntities(s){return null==s?s:String(s).replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""")}replaceAccentuatedChars(s){return null==s?s:this.replaceToSpace(s,["&","<",">","""]).replace(/[^\w ]/g,(s=>{let i=this._charsWithAccentuation.indexOf(s);return i>-1&&(s=this._charsWithoutAccentuation.charAt(i)),s||""}))}replaceToSpace(s,i=[]){return null==s||i.forEach((i=>{const e=new RegExp(i,"g");let t="";for(let s=0;s<i.length;s++)t+=" ";s=String(s).replace(e,t)})),s}isIn(s,i){return this.indexOf(s,i)>-1}getSpecialCharacters(s){let i,e=[];for(;i=this._specialCharsRegex.exec(s);)e.push(s[i.index]);return e}removeSpecialCharacters(s){return this.getSpecialCharacters(s).forEach((i=>{s=this.replaceAll(s,i,"")})),s}replaceAll(s,i,e){let t=(null!=s?s:"").indexOf(i);for(;t>-1;)t=(s=s.replace(i,e)).indexOf(i);return s}getArgumentNumber(){return Number(this.argument||void 0)}createOption(s){let{key:i,title:e}=s;const t=new RegExp(this._startHighlightTag,"g"),a=new RegExp(this._endHighlightTag,"g");e=r.decodeHtmlEntities(e);const o={value:null==i?void 0:i.replace(t,"").replace(a,""),label:null==e?void 0:e.replace(t,"").replace(a,"")};this.selectItem(o)}onChangeValue(s){var i;if(this.clearDeboucingTimeout(),this._startLoading)return void(this._changeDeboucingTimeout=setTimeout((()=>{this.onChangeValue(s)}),this._deboucingTime));if(this.argument=(s.detail||"").trim(),this.isHierarchyEntity&&"list"===this._presentationMode)return void(null===(i=this._pesquisaTree)||void 0===i||i.applyFilter());const e=this.getArgumentNumber();this.argument&&(!isNaN(e)||this.argument.length>=this._limitCharsToSearch)?this._changeDeboucingTimeout=setTimeout((()=>{this.doSearch(isNaN(e)?this.argument:e.toString())}),this._deboucingTime):this._itemList=void 0}clearDeboucingTimeout(){this._changeDeboucingTimeout&&(clearTimeout(this._changeDeboucingTimeout),this._changeDeboucingTimeout=void 0)}onClickSearch(){this.doSearch((this.argument||"").trim())}getMessageView(){return this._startLoading?"Aguarde, buscando registros...":this._itemList?this._itemList.length>=1?`${this._itemList.length} ${this._itemList.length>1?"registros encontrados":"registro encontrado"}`:"Nenhum registro encontrado":"Os resultados de sua pesquisa aparecerão aqui..."}async componentWillLoad(){const s=await this.pesquisaFetcher.loadPresentationConfig(this.entityName);this._presentationMode="list"===s?"list":"table"}async componentDidLoad(){o.addIDInfo(this._element),await this.chooseViewMode()}async handleChangeViewMode(){this._presentationMode="list"===this._presentationMode?"table":"list",await this.chooseViewMode(),await this.pesquisaFetcher.savePresentationConfig(this.entityName,this._presentationMode)}async chooseViewMode(){var s,i;if("list"!==this._presentationMode)return await(null===(s=this._viewStack)||void 0===s?void 0:s.show(c.GRID)),void(this._currentView=c.GRID);const e=this.isHierarchyEntity?c.TREE:c.CARDS;await(null===(i=this._viewStack)||void 0===i?void 0:i.show(e)),this._currentView=e}hideLimitMessage(){return!this._itemList||this._itemList.length<100}hideRecordsMessage(){return"list"===this._presentationMode&&this.isHierarchyEntity}getButtonModeInfo(){return"list"===this._presentationMode?{iconName:"table",title:"Modo grade"}:this.isHierarchyEntity?{iconName:"hierarchical-tree",title:"Modo árvore hierárquica"}:{iconName:"list",title:"Modo lista"}}render(){var s,t;return i(e,null,i("div",{class:"snk-pesquisa"},i("div",{class:"snk-pesquisa__input"},i("ez-text-input",{label:"Buscar",class:"ez-margin-right--medium",canShowError:!1,ref:s=>this._textInput=s,onEzChange:s=>this.onChangeValue(s),value:this.argument,"data-element-id":"searchInput"},i("ez-icon",{slot:"leftIcon",iconName:"search"}),this.argument&&(null===(s=this._textInput)||void 0===s?void 0:s.value)?i("button",{slot:"rightIcon",class:"snk-pesquisa__btn",onClick:()=>this.clearSearch()},i("ez-icon",{iconName:"close"})):void 0),i("ez-button",{class:"ez-button--primary",label:"Pesquisar",onClick:()=>this.onClickSearch()}),i("ez-button",{class:"ez-margin-left--medium",mode:"icon",iconName:this.getButtonModeInfo().iconName,title:this.getButtonModeInfo().title,onClick:async()=>await this.handleChangeViewMode()})),i("div",{class:"snk-pesquisa__records-label "+(this._currentView===c.TREE?"hidden":"")},i("label",{class:"snk-pesquisa__records "+(this.hideRecordsMessage()?"hidden":"")},this.getMessageView()),i("label",{class:"snk-pesquisa__records-limit "+(this.hideLimitMessage()?"hidden":"")},"Essa pesquisa foi limitada, existem mais resultados.")),i("div",{class:"snk-pesquisa__content"},i("ez-view-stack",{ref:s=>this._viewStack=s,"data-element-id":"simple-crud"},i("stack-item",null,i("pesquisa-grid",{metadata:this._gridMetadata,dataSource:this._gridDataSource,pkField:this._pkField,descriptionField:this._descriptionField,entityName:this.entityName,shouldLoadConfig:this._currentView===c.GRID,onPesquisaGridSelectItem:({detail:s})=>this.selectItem(s)})),i("stack-item",null,i("div",{class:"snk-pesquisa__cards-container"},null===(t=this._itemList)||void 0===t?void 0:t.map((s=>i("ez-card-item",{onEzClick:s=>this.createOption(s.detail),item:s}))))),i("stack-item",null,i("pesquisa-tree",{ref:s=>this._pesquisaTree=s,argument:this.argument,treeLoader:this.treeLoader,allowsNonAnalytic:this.allowsNonAnalytic,shouldLoadTree:this._currentView===c.TREE,onPesquisaTreeSelectItem:({detail:s})=>this.selectItem(s)}))))))}get _element(){return t(this)}static get watchers(){return{argument:["observeArgument"]}}};u.style=".sc-snk-pesquisa-h{--snk-pesquisa--font-size:var(--text--medium, 14px);--snk-pesquisa--font-family:var(--font-pattern, Arial);--snk-pesquisa--font-weight:var(--text-weight--medium, 400);--snk-pesquisa__records--color:var(--text--primary, #626e82);--snk-pesquisa__records--color-secondary:var(--text--secondary, #626e82);--snk-pesquisa__records--padding-vertical:var(--space--medium, 12px);--snk-pesquisa__content--padding-right:var(--space--small, 6px);--snk-pesquisa__btn--color:var(--title--primary, #2B3A54);--snk-pesquisa__btn-disabled--color:var(--text--disable, #AFB6C0);--snk-pesquisa__btn-hover--color:var(--color--primary, #4e4e4e);--snk-pesquisa__scrollbar--color-default:var(--scrollbar--default, #626e82);--snk-pesquisa__scrollbar--color-background:var(--scrollbar--background, #E5EAF0);--snk-pesquisa__scrollbar--color-hover:var(--scrollbar--hover, #2B3A54);--snk-pesquisa__scrollbar--color-clicked:var(--scrollbar--clicked, #a2abb9);--snk-pesquisa__scrollbar--border-radius:var(--border--radius-small, 6px);--snk-pesquisa__scrollbar--width:var(--space--small, 6px);height:100%;display:flex;flex-direction:column;overflow-y:auto}.snk-pesquisa.sc-snk-pesquisa{display:flex;flex-direction:column;height:100%}.snk-pesquisa__input.sc-snk-pesquisa{display:flex;width:100%;box-sizing:border-box;padding-top:4px;padding-right:4px}.snk-pesquisa__input.sc-snk-pesquisa ez-icon.sc-snk-pesquisa{--ez-icon--color:inherit;font-weight:var(--text-weight--large, 600)}.snk-pesquisa__content.sc-snk-pesquisa{display:flex;flex-direction:column;overflow-y:hidden;scrollbar-width:thin;scrollbar-color:var(--snk-pesquisa__scrollbar--color-clicked) var(--snk-pesquisa__scrollbar--color-background);padding-right:var(--snk-pesquisa__content--padding-right);height:100vh}.snk-pesquisa__content.sc-snk-pesquisa::-webkit-scrollbar{background-color:var(--snk-pesquisa__scrollbar--color-background);width:var(--snk-pesquisa__scrollbar--width);max-width:var(--snk-pesquisa__scrollbar--width);min-width:var(--snk-pesquisa__scrollbar--width)}.snk-pesquisa__content.sc-snk-pesquisa::-webkit-scrollbar-track{background-color:var(--snk-pesquisa__scrollbar--color-background);border-radius:var(--snk-pesquisa__scrollbar--border-radius)}.snk-pesquisa__content.sc-snk-pesquisa::-webkit-scrollbar-thumb{background-color:var(--snk-pesquisa__scrollbar--color-default);border-radius:var(--snk-pesquisa__scrollbar--border-radius)}.snk-pesquisa__content.sc-snk-pesquisa::-webkit-scrollbar-thumb:vertical:hover,.snk-pesquisa__content.sc-snk-pesquisa::-webkit-scrollbar-thumb:horizontal:hover{background-color:var(--snk-pesquisa__scrollbar--color-hover)}.snk-pesquisa__content.sc-snk-pesquisa::-webkit-scrollbar-thumb:vertical:active,.snk-pesquisa__content.sc-snk-pesquisa::-webkit-scrollbar-thumb:horizontal:active{background-color:var(--snk-pesquisa__scrollbar--color-clicked)}.snk-pesquisa__records-label.sc-snk-pesquisa{display:flex;flex-direction:row;justify-content:space-between;font-family:var(--snk-pesquisa--font-family);font-weight:var(--snk-pesquisa--font-weight);font-size:var(--snk-pesquisa--font-size);padding-bottom:var(--snk-pesquisa__records--padding-vertical);padding-top:var(--snk-pesquisa__records--padding-vertical)}.snk-pesquisa__records-label.hidden.sc-snk-pesquisa{display:none}.snk-pesquisa__records.sc-snk-pesquisa{color:var(--snk-pesquisa__records--color)}.snk-pesquisa__records-limit.sc-snk-pesquisa{color:var(--snk-pesquisa__records--color-secondary)}.snk-pesquisa__records-limit.hidden.sc-snk-pesquisa,.snk-pesquisa__records.hidden.sc-snk-pesquisa{visibility:hidden}.snk-pesquisa__btn.sc-snk-pesquisa{outline:none;border:none;background:none;cursor:pointer;color:var(--snk-pesquisa__btn--color)}.snk-pesquisa__btn.sc-snk-pesquisa:disabled{cursor:unset;color:var(--snk-pesquisa__btn-disabled--color)}.snk-pesquisa__btn.sc-snk-pesquisa:disabled:hover{cursor:unset;color:var(--snk-pesquisa__btn-disabled--color)}.snk-pesquisa__btn.sc-snk-pesquisa:hover{color:var(--snk-pesquisa__btn-hover--color)}.snk-pesquisa__cards-container.sc-snk-pesquisa{height:100%;overflow-y:auto}";export{u as snk_pesquisa}
|