@sankhyalabs/sankhyablocks 3.2.0 → 3.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/{index-2cd6f753.js → index-21bd01e1.js} +111 -2
- package/dist/cjs/{index-696b5c3b.js → index-fc7ca86c.js} +1 -1
- package/dist/cjs/loader.cjs.js +3 -2
- package/dist/cjs/sankhyablocks.cjs.js +6 -2
- package/dist/cjs/snk-application.cjs.entry.js +3 -1
- package/dist/cjs/snk-config-options.cjs.entry.js +4 -4
- package/dist/cjs/snk-configurator_3.cjs.entry.js +14 -14
- package/dist/cjs/snk-crud.cjs.entry.js +10 -9
- package/dist/cjs/snk-data-exporter_8.cjs.entry.js +41 -16
- package/dist/cjs/snk-data-unit.cjs.entry.js +8 -5
- package/dist/cjs/snk-exporter-email-sender.cjs.entry.js +3 -1
- package/dist/cjs/snk-filter-binary-select.cjs.entry.js +3 -1
- package/dist/cjs/snk-filter-detail.cjs.entry.js +3 -1
- package/dist/cjs/snk-filter-multi-select.cjs.entry.js +3 -1
- package/dist/cjs/snk-filter-number.cjs.entry.js +3 -1
- package/dist/cjs/snk-filter-period.cjs.entry.js +3 -1
- package/dist/cjs/snk-filter-personalized.cjs.entry.js +5 -1
- package/dist/cjs/snk-filter-search.cjs.entry.js +3 -1
- package/dist/cjs/snk-filter-text.cjs.entry.js +3 -1
- package/dist/cjs/snk-form-config.cjs.entry.js +7 -4
- package/dist/cjs/snk-form.cjs.entry.js +7 -4
- package/dist/cjs/snk-pesquisa.cjs.entry.js +5 -1
- package/dist/cjs/snk-tab-config.cjs.entry.js +7 -1
- package/dist/cjs/{taskbar-elements-81ad590c.js → taskbar-elements-8d38f43a.js} +2 -2
- package/dist/cjs/teste-pesquisa.cjs.entry.js +1 -1
- package/dist/collection/collection-manifest.json +2 -2
- package/dist/collection/components/snk-application/snk-application.js +2 -0
- package/dist/collection/components/snk-configurator/snk-configurator.js +2 -3
- package/dist/collection/components/snk-crud/snk-crud.js +7 -6
- package/dist/collection/components/snk-data-exporter/exporter-email-sender/snk-exporter-email-sender.js +2 -0
- package/dist/collection/components/snk-data-exporter/snk-data-exporter.js +0 -3
- package/dist/collection/components/snk-data-unit/snk-data-unit.js +7 -4
- package/dist/collection/components/snk-filter-bar/filter-item/editors/snk-filter-binary-select.js +4 -0
- package/dist/collection/components/snk-filter-bar/filter-item/editors/snk-filter-multi-select.js +4 -0
- package/dist/collection/components/snk-filter-bar/filter-item/editors/snk-filter-number.js +4 -0
- package/dist/collection/components/snk-filter-bar/filter-item/editors/snk-filter-period.js +4 -0
- package/dist/collection/components/snk-filter-bar/filter-item/editors/snk-filter-personalized.js +6 -0
- package/dist/collection/components/snk-filter-bar/filter-item/editors/snk-filter-search.js +4 -0
- package/dist/collection/components/snk-filter-bar/filter-item/editors/snk-filter-text.js +4 -0
- package/dist/collection/components/snk-filter-bar/filter-item/snk-filter-detail.js +4 -0
- package/dist/collection/components/snk-filter-bar/filter-item/snk-filter-item.js +3 -0
- package/dist/collection/components/snk-filter-bar/filter-list/snk-filter-list.js +9 -0
- package/dist/collection/components/snk-filter-bar/filter-modal/snk-filter-modal.js +12 -0
- package/dist/collection/components/snk-filter-bar/snk-filter-bar.js +4 -0
- package/dist/collection/components/snk-form/snk-form.js +6 -3
- package/dist/collection/components/snk-form/subcomponents/snk-config-options/snk-config-options.js +3 -3
- package/dist/collection/components/snk-form/subcomponents/snk-field-config/snk-field-config.js +2 -6
- package/dist/collection/components/snk-form/subcomponents/snk-form-config/snk-form-config.js +6 -3
- package/dist/collection/components/snk-form/subcomponents/snk-tab-config/snk-tab-config.js +6 -0
- package/dist/collection/components/snk-grid/snk-grid.js +8 -3
- package/dist/collection/components/snk-grid/subcomponents/snk-grid-config/snk-grid-config.js +3 -3
- package/dist/collection/components/snk-grid/subcomponents/snk-select-box/snk-select-box.js +0 -3
- package/dist/collection/components/snk-pesquisa/snk-pesquisa.js +4 -0
- package/dist/collection/components/snk-taskbar/snk-taskbar.js +9 -4
- package/dist/components/index.d.ts +9 -0
- package/dist/components/index.js +1 -1
- package/dist/components/snk-application2.js +2 -0
- package/dist/components/snk-config-options2.js +3 -3
- package/dist/components/snk-configurator2.js +2 -3
- package/dist/components/snk-crud.js +7 -6
- package/dist/components/snk-data-exporter2.js +0 -3
- package/dist/components/snk-data-unit.js +7 -4
- package/dist/components/snk-exporter-email-sender2.js +2 -0
- package/dist/components/snk-field-config2.js +2 -6
- package/dist/components/snk-filter-bar2.js +4 -0
- package/dist/components/snk-filter-binary-select.js +2 -0
- package/dist/components/snk-filter-detail2.js +2 -0
- package/dist/components/snk-filter-item2.js +3 -0
- package/dist/components/snk-filter-list2.js +9 -0
- package/dist/components/snk-filter-modal2.js +10 -0
- package/dist/components/snk-filter-multi-select.js +2 -0
- package/dist/components/snk-filter-number.js +2 -0
- package/dist/components/snk-filter-period.js +2 -0
- package/dist/components/snk-filter-personalized.js +4 -0
- package/dist/components/snk-filter-search.js +2 -0
- package/dist/components/snk-filter-text.js +2 -0
- package/dist/components/snk-form-config2.js +6 -3
- package/dist/components/snk-form2.js +6 -3
- package/dist/components/snk-grid-config2.js +3 -3
- package/dist/components/snk-grid2.js +8 -3
- package/dist/components/snk-pesquisa2.js +4 -0
- package/dist/components/snk-select-box2.js +0 -3
- package/dist/components/snk-tab-config2.js +6 -0
- package/dist/components/snk-taskbar2.js +9 -4
- package/dist/esm/{index-a77b6f35.js → index-cfd4bb13.js} +111 -3
- package/dist/esm/{index-d89e384f.js → index-e467ade5.js} +1 -1
- package/dist/esm/loader.js +3 -2
- package/dist/esm/polyfills/css-shim.js +1 -1
- package/dist/esm/sankhyablocks.js +3 -2
- package/dist/esm/snk-application.entry.js +3 -1
- package/dist/esm/snk-config-options.entry.js +4 -4
- package/dist/esm/snk-configurator_3.entry.js +14 -14
- package/dist/esm/snk-crud.entry.js +10 -9
- package/dist/esm/snk-data-exporter_8.entry.js +41 -16
- package/dist/esm/snk-data-unit.entry.js +8 -5
- package/dist/esm/snk-exporter-email-sender.entry.js +3 -1
- package/dist/esm/snk-filter-binary-select.entry.js +3 -1
- package/dist/esm/snk-filter-detail.entry.js +3 -1
- package/dist/esm/snk-filter-multi-select.entry.js +3 -1
- package/dist/esm/snk-filter-number.entry.js +3 -1
- package/dist/esm/snk-filter-period.entry.js +3 -1
- package/dist/esm/snk-filter-personalized.entry.js +5 -1
- package/dist/esm/snk-filter-search.entry.js +3 -1
- package/dist/esm/snk-filter-text.entry.js +3 -1
- package/dist/esm/snk-form-config.entry.js +7 -4
- package/dist/esm/snk-form.entry.js +7 -4
- package/dist/esm/snk-pesquisa.entry.js +5 -1
- package/dist/esm/snk-tab-config.entry.js +7 -1
- package/dist/esm/{taskbar-elements-9b0a87f1.js → taskbar-elements-24655695.js} +2 -2
- package/dist/esm/teste-pesquisa.entry.js +1 -1
- package/dist/sankhyablocks/p-01fdcc77.entry.js +1 -0
- package/dist/sankhyablocks/p-0b86c7f0.entry.js +1 -0
- package/dist/sankhyablocks/p-123732eb.entry.js +1 -0
- package/dist/sankhyablocks/p-125c2d01.entry.js +1 -0
- package/dist/sankhyablocks/p-2cd74aa1.entry.js +1 -0
- package/dist/sankhyablocks/{p-4cec3835.entry.js → p-31e36df4.entry.js} +4 -4
- package/dist/sankhyablocks/p-4133f9e5.entry.js +1 -0
- package/dist/sankhyablocks/p-5360f8fa.entry.js +1 -0
- package/dist/sankhyablocks/p-5e62a17b.entry.js +1 -0
- package/dist/sankhyablocks/p-5fc55684.entry.js +1 -0
- package/dist/sankhyablocks/p-6b992e43.js +1 -0
- package/dist/sankhyablocks/p-86d29b6f.entry.js +1 -0
- package/dist/sankhyablocks/p-93c92b97.entry.js +1 -0
- package/dist/sankhyablocks/p-93d8ea09.js +2 -2
- package/dist/sankhyablocks/{p-112bb324.js → p-98f7f796.js} +1 -1
- package/dist/sankhyablocks/p-9fab987d.entry.js +1 -0
- package/dist/sankhyablocks/p-ad51bf1c.entry.js +1 -0
- package/dist/sankhyablocks/p-afba9bbe.entry.js +1 -0
- package/dist/sankhyablocks/p-b9667fbe.js +2 -0
- package/dist/sankhyablocks/p-c336170d.entry.js +1 -0
- package/dist/sankhyablocks/p-d5c9c1f8.entry.js +1 -0
- package/dist/sankhyablocks/{p-57895452.entry.js → p-e551b19a.entry.js} +1 -1
- package/dist/sankhyablocks/p-e701646c.entry.js +1 -0
- package/dist/sankhyablocks/p-ee82c157.entry.js +1 -0
- package/dist/sankhyablocks/sankhyablocks.esm.js +1 -1
- package/dist/types/stencil-public-runtime.d.ts +64 -3
- package/loader/index.d.ts +9 -0
- package/package.json +5 -5
- package/dist/sankhyablocks/p-048e126b.entry.js +0 -1
- package/dist/sankhyablocks/p-12ebe36a.entry.js +0 -1
- package/dist/sankhyablocks/p-187b0d06.entry.js +0 -1
- package/dist/sankhyablocks/p-1ccaea51.entry.js +0 -1
- package/dist/sankhyablocks/p-1dbe9dd8.entry.js +0 -1
- package/dist/sankhyablocks/p-3c7ec56e.entry.js +0 -1
- package/dist/sankhyablocks/p-3f6c05c7.entry.js +0 -1
- package/dist/sankhyablocks/p-5ebc029c.entry.js +0 -1
- package/dist/sankhyablocks/p-7dad1d5e.js +0 -1
- package/dist/sankhyablocks/p-91c23d20.entry.js +0 -1
- package/dist/sankhyablocks/p-a77dd79a.js +0 -2
- package/dist/sankhyablocks/p-ab4ff312.entry.js +0 -1
- package/dist/sankhyablocks/p-bcb2fb03.entry.js +0 -1
- package/dist/sankhyablocks/p-c15108d5.entry.js +0 -1
- package/dist/sankhyablocks/p-d3e402d3.entry.js +0 -1
- package/dist/sankhyablocks/p-d7ae56ce.entry.js +0 -1
- package/dist/sankhyablocks/p-df5d94c6.entry.js +0 -1
- package/dist/sankhyablocks/p-e075dba7.entry.js +0 -1
- package/dist/sankhyablocks/p-f6f71be7.entry.js +0 -1
- package/dist/sankhyablocks/p-f9829109.entry.js +0 -1
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import{r as t,c as e,h as s,g as i}from"./p-
|
|
1
|
+
import{r as t,c as e,h as s,g as i}from"./p-b9667fbe.js";import{WaitingChangeException as r,WarningException as n,ErrorException as a,ObjectUtils as o,DataType as c,DataUnit as h,StringUtils as u,ChangeOperation as l,DateUtils as d,DependencyType as p,ElementIDUtils as m,ApplicationContext as f,ErrorTracking as y}from"@sankhyalabs/core";import{d as g,D as w,R as v,U as I,F as $,G as _,C as P}from"./p-93d8ea09.js";import{ApplicationUtils as S}from"@sankhyalabs/ezui/dist/collection/utils";import{S as D}from"./p-3187b31c.js";import"./p-112455b1.js";class C{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 r||(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.errorCode+"')} catch(e){alert('Não é possível abrir a ajuda fora do workspace Sankhya');}\">Código: "+t.errorCode+"</a>"}processException(t){t.errorCode&&(t.message+=this.buildErrorCodeHTML(t)),t instanceof r||t instanceof n?this._app.alert(t.title,t.message):t instanceof a?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",s="string"==typeof t?t:t.message||`Erro interno "${o.objectToString(t)}"`;this._app.error(e,s)}}))}}class A{constructor(){this._defaultPageSize=100,this._templateByQuery=new Map,this.buldTemplates()}buldTemplates(){this._templateByQuery.set("search",g.gql`query($entityName: String! $argument: String $criteria: InputSearchCriteria $options: InputSearchOptions) {
|
|
2
2
|
$queryAlias$: search(entityName: $entityName argument: $argument criteria: $criteria options: $options){
|
|
3
3
|
value
|
|
4
4
|
label
|
|
5
5
|
}
|
|
6
|
-
}`)}loadSearchOptions(t,e,s,i){const r=(null==e?void 0:e.trim())||void 0;return e=isNaN(Number(r))&&r?`%${r}`:r,new Promise(((r,n)=>{w.get().callGraphQL({values:{argument:e,entityName:t,criteria:s,options:i},query:this._templateByQuery.get("search")}).then((t=>{r(t)})).catch((t=>{n(t)}))}))}loadAdvancedSearch(t,e,s,i){const r={query:{$:null==s?void 0:s.expression}};(null==s?void 0:s.params.length)>0&&(r.params={param:s.params.map((t=>{let e=t.value,s=t.dataType;return s===c.OBJECT?(e=e.value,s="S"):s=function(t){switch(t){case c.NUMBER:return"I";case c.DATE:return"D";default:return"S"}}(t.dataType),{$:e,type:s}}))});const n={serviceName:"PesquisaSP.getSuggestion",requestBody:{criteria:{entityName:t,compacted:!1,ignoreEntityCriteria:!1,limit:this._defaultPageSize,query:{$:e},orderByDesc:!1,externalCriteria:r,localEntityName:null==i?void 0:i.rootEntity},clientEventList:{clientEvent:[]}}};return new Promise(((t,e)=>{w.get().callServiceBroker("PesquisaSP.getSuggestion",JSON.stringify(n)).then((e=>t(e))).catch((t=>e(t)))}))}}function T(){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(T=function(){return t})()}const N
|
|
6
|
+
}`)}loadSearchOptions(t,e,s,i){const r=(null==e?void 0:e.trim())||void 0;return e=isNaN(Number(r))&&r?`%${r}`:r,new Promise(((r,n)=>{w.get().callGraphQL({values:{argument:e,entityName:t,criteria:s,options:i},query:this._templateByQuery.get("search")}).then((t=>{r(t)})).catch((t=>{n(t)}))}))}loadAdvancedSearch(t,e,s,i){const r={query:{$:null==s?void 0:s.expression}};(null==s?void 0:s.params.length)>0&&(r.params={param:s.params.map((t=>{let e=t.value,s=t.dataType;return s===c.OBJECT?(e=e.value,s="S"):s=function(t){switch(t){case c.NUMBER:return"I";case c.DATE:return"D";default:return"S"}}(t.dataType),{$:e,type:s}}))});const n={serviceName:"PesquisaSP.getSuggestion",requestBody:{criteria:{entityName:t,compacted:!1,ignoreEntityCriteria:!1,limit:this._defaultPageSize,query:{$:e},orderByDesc:!1,externalCriteria:r,localEntityName:null==i?void 0:i.rootEntity},clientEventList:{clientEvent:[]}}};return new Promise(((t,e)=>{w.get().callServiceBroker("PesquisaSP.getSuggestion",JSON.stringify(n)).then((e=>t(e))).catch((t=>e(t)))}))}}function T(){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(T=function(){return t})()}const b=N;function N(t,e){const s=T();return(N=function(t){return s[t-=392]})(t,e)}!function(){const t=N,e=T();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 E=b(396);class q{constructor(){this.templateByQuery=new Map,this.buldTemplates()}buldTemplates(){this.templateByQuery.set("fetchTotals",g.gql`query($filters: [InputFilter!] $name: String!) {
|
|
7
7
|
$queryAlias$: fetchTotals(name: $name, filters: $filters ){
|
|
8
8
|
name
|
|
9
9
|
value
|
|
@@ -75,9 +75,9 @@ import{r as t,c as e,h as s,g as i}from"./p-a77dd79a.js";import{WaitingChangeExc
|
|
|
75
75
|
}
|
|
76
76
|
}
|
|
77
77
|
}
|
|
78
|
-
}`)}getDataUnit(t,e,s){const i=null!=s?s.getChildDataunit(`dd://${t}/${e}`):new h(`dd://${t}/${e}`);return i.metadataLoader=t=>this.loadMetadata(t),i.dataLoader=(t,e)=>this.loadData(t,e),i.saveLoader=(t,e)=>this.saveData(t,e),i.removeLoader=(t,e)=>this.removeRecords(t,e),i.recordLoader=(t,e)=>this.loadRecord(t,e),i}loadMetadata(t){return new Promise(((e,s)=>{w.get().callGraphQL({values:{name:t.name},query:this.templateByQuery.get("fetchDataUnit")}).then((t=>{var s;const i={name:t.name,label:t.name,children:[...t.children],fields:[]};null===(s=t.fields)||void 0===s||s.forEach((t=>{let e;Array.isArray(t.properties)&&(e={},t.calculated&&(e.gridHeaderTooltip="Campos calculados não podem ser ordenados"),t.properties.forEach((t=>e[t.name]=t.value))),i.fields.push(Object.assign(Object.assign({},t),{properties:e}))})),e(i)})).catch((t=>{s(t)}))}))}loadData(t,e){const s=t.name;return this._loadDataTimeout[s]&&(clearTimeout(this._loadDataTimeout[s]),delete this._loadDataTimeout[s]),new Promise(((i,r)=>{this._loadDataTimeout[s]=setTimeout((()=>{delete this._loadDataTimeout[s],this.doLoadData(t,e).then((t=>i(t))).catch((t=>r(t)))}),200)}))}doLoadData(t,e){return new Promise(((s,i)=>{var r;const{sort:n,filters:a,limit:o,offset:h,quickFilter:l}=e,d={dataunit:t.name,sort:n,filters:a};if(d.limit=o,d.offset=h,d.parentRecordId=e.parentRecordId,!u.isEmpty(null==l?void 0:l.term)){void 0===d.filter&&(d.filter=[]);const t={name:"__QUICK_FILTER__",expression:"__QUICK_FILTER__",params:[{name:"term",dataType:c.TEXT,value:l.term}]};(null===(r=null==l?void 0:l.fields)||void 0===r?void 0:r.length)>0&&t.params.push({name:"fields",dataType:c.OBJECT,value:l.fields}),d.filter.push(t)}w.get().callGraphQL({values:d,query:this.templateByQuery.get("fetchData")}).then((e=>{const{limit:i,offset:r,total:n,hasMore:a,records:o}=e.data;let c;i&&(c={firstRecord:0==n?0:r+1,lastRecord:r+Math.min(o.length,i),total:n,currentPage:r/i,hasMore:a});const h=[];o.forEach((e=>{const s={__record__id__:e.id};e.fields.forEach((({name:e,value:i})=>{s[e]=t.valueFromString(e,i)})),h.push(s)})),s({paginationInfo:c,records:h})})).catch((t=>{i(t)}))}))}saveData(t,e){const s=e.map((e=>{const{dataUnit:s,record:i,updatingFields:r,operation:n}=e;let a;r&&(a=Object.entries(r).map((([e,s])=>{const i=t.getField(e);return{fieldName:e,dataType:i?i.dataType:c.TEXT,value:t.valueToString(e,s)}})));const o={dataUnit:s,fields:a,operation:n,recordId:i.__record__id__};return e.sourceId&&(o.sourceId=e.sourceId),i.__parent__record__id__&&(o.parentRecordId=i.__parent__record__id__),o}));return new Promise(((e,i)=>{w.get().callGraphQL({values:{changes:s},query:this.templateByQuery.get("saveData")}).then((s=>{const i=[];null==s||s.forEach((e=>{const s={__record__id__:e.id};e.oldId&&(s.__old__id__=e.oldId),e.fields.forEach((({name:e,value:i})=>{s[e]=t.valueFromString(e,i)})),i.push(s)})),e(i)})).catch((t=>{i(t)}))}))}removeRecords(t,e){const s=e.map((e=>({dataUnit:t.name,operation:l.DELETE,recordId:e})));return new Promise(((t,i)=>{w.get().callGraphQL({values:{changes:s},query:this.templateByQuery.get("saveData")}).then((()=>{t(e)})).catch((t=>{i(t)}))}))}loadRecord(t,e){return new Promise(((s,i)=>{w.get().callGraphQL({values:{recordID:e,dataunit:t.name},query:this.templateByQuery.get("fetchDataRecord")}).then((e=>{const i=[];e.record.forEach((e=>{const s={__record__id__:e.id};e.fields.forEach((({name:e,value:i})=>{s[e]=t.valueFromString(e,i)})),i.push(s)})),s(i)})).catch((t=>{i(t)}))}))}}var F;class R{static openAppActivity(t,e){var s;null===(s=window.workspace)||void 0===s||s.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)}}R.resourceID=null===(F=window.workspace)||void 0===F?void 0:F.resourceID;class L{constructor(){this.templateByQuery=new Map,this.buldTemplates()}buldTemplates(){this.templateByQuery.set("fetchParam",g.gql`query($name: String!) {
|
|
78
|
+
}`)}getDataUnit(t,e,s){const i=null!=s?s.getChildDataunit(`dd://${t}/${e}`):new h(`dd://${t}/${e}`);return i.metadataLoader=t=>this.loadMetadata(t),i.dataLoader=(t,e)=>this.loadData(t,e),i.saveLoader=(t,e)=>this.saveData(t,e),i.removeLoader=(t,e)=>this.removeRecords(t,e),i.recordLoader=(t,e)=>this.loadRecord(t,e),i}loadMetadata(t){return new Promise(((e,s)=>{w.get().callGraphQL({values:{name:t.name},query:this.templateByQuery.get("fetchDataUnit")}).then((t=>{var s;const i={name:t.name,label:t.name,children:[...t.children],fields:[]};null===(s=t.fields)||void 0===s||s.forEach((t=>{let e;Array.isArray(t.properties)&&(e={},t.calculated&&(e.gridHeaderTooltip="Campos calculados não podem ser ordenados"),t.properties.forEach((t=>e[t.name]=t.value))),i.fields.push(Object.assign(Object.assign({},t),{properties:e}))})),e(i)})).catch((t=>{s(t)}))}))}loadData(t,e){const s=t.name;return this._loadDataTimeout[s]&&(clearTimeout(this._loadDataTimeout[s]),delete this._loadDataTimeout[s]),new Promise(((i,r)=>{this._loadDataTimeout[s]=setTimeout((()=>{delete this._loadDataTimeout[s],this.doLoadData(t,e).then((t=>i(t))).catch((t=>r(t)))}),200)}))}doLoadData(t,e){return new Promise(((s,i)=>{var r;const{sort:n,filters:a,limit:o,offset:h,quickFilter:l}=e,d={dataunit:t.name,sort:n,filters:a};if(d.limit=o,d.offset=h,d.parentRecordId=e.parentRecordId,!u.isEmpty(null==l?void 0:l.term)){void 0===d.filter&&(d.filter=[]);const t={name:"__QUICK_FILTER__",expression:"__QUICK_FILTER__",params:[{name:"term",dataType:c.TEXT,value:l.term}]};(null===(r=null==l?void 0:l.fields)||void 0===r?void 0:r.length)>0&&t.params.push({name:"fields",dataType:c.OBJECT,value:l.fields}),d.filter.push(t)}w.get().callGraphQL({values:d,query:this.templateByQuery.get("fetchData")}).then((e=>{const{limit:i,offset:r,total:n,hasMore:a,records:o}=e.data;let c;i&&(c={firstRecord:0==n?0:r+1,lastRecord:r+Math.min(o.length,i),total:n,currentPage:r/i,hasMore:a});const h=[];o.forEach((e=>{const s={__record__id__:e.id};e.fields.forEach((({name:e,value:i})=>{s[e]=t.valueFromString(e,i)})),h.push(s)})),s({paginationInfo:c,records:h})})).catch((t=>{i(t)}))}))}saveData(t,e){const s=e.map((e=>{const{dataUnit:s,record:i,updatingFields:r,operation:n}=e;let a;r&&(a=Object.entries(r).map((([e,s])=>{const i=t.getField(e);return{fieldName:e,dataType:i?i.dataType:c.TEXT,value:t.valueToString(e,s)}})));const o={dataUnit:s,fields:a,operation:n,recordId:i.__record__id__};return e.sourceId&&(o.sourceId=e.sourceId),i.__parent__record__id__&&(o.parentRecordId=i.__parent__record__id__),o}));return new Promise(((e,i)=>{w.get().callGraphQL({values:{changes:s},query:this.templateByQuery.get("saveData")}).then((s=>{const i=[];null==s||s.forEach((e=>{const s={__record__id__:e.id};e.oldId&&(s.__old__id__=e.oldId),e.fields.forEach((({name:e,value:i})=>{s[e]=t.valueFromString(e,i)})),i.push(s)})),e(i)})).catch((t=>{i(t)}))}))}removeRecords(t,e){const s=e.map((e=>({dataUnit:t.name,operation:l.DELETE,recordId:e})));return new Promise(((t,i)=>{w.get().callGraphQL({values:{changes:s},query:this.templateByQuery.get("saveData")}).then((()=>{t(e)})).catch((t=>{i(t)}))}))}loadRecord(t,e){return new Promise(((s,i)=>{w.get().callGraphQL({values:{recordID:e,dataunit:t.name},query:this.templateByQuery.get("fetchDataRecord")}).then((e=>{const i=[];e.record.forEach((e=>{const s={__record__id__:e.id};e.fields.forEach((({name:e,value:i})=>{s[e]=t.valueFromString(e,i)})),i.push(s)})),s(i)})).catch((t=>{i(t)}))}))}}var F;class R{static openAppActivity(t,e){var s;null===(s=window.workspace)||void 0===s||s.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)}}R.resourceID=null===(F=window.workspace)||void 0===F?void 0:F.resourceID;class L{static webConnectionCaller(t,e,s){var i;null===(i=window.AppletCaller)||void 0===i||i.webConnectionCaller(t,e,s)}}class j{constructor(){this.templateByQuery=new Map,this.buldTemplates()}buldTemplates(){this.templateByQuery.set("fetchParam",g.gql`query($name: String!) {
|
|
79
79
|
$queryAlias$: fetchResource(name: $name){
|
|
80
80
|
name
|
|
81
81
|
resource
|
|
82
82
|
}
|
|
83
|
-
}`)}async getParam(t){const e=`param://application?params=${t}`;return w.get().callGraphQL({values:{name:e},query:this.templateByQuery.get("fetchParam")})}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 this.getValue(e).includes('"S"')}async asDate(t){const e=await this.getParam(t);return d.strToDate(this.getValue(e))}async getBatchParams(t){const e=await this.getParam(t.join(",")),s={};return e.forEach((t=>s[t.name]=t.resource)),s}getValue(t={}){return Array.isArray(t)&&t.length>0&&(t=t[0]),u.isEmpty(t.resource)?"":t.resource}}const j=k;function k(t,e){const s=M();return(k=function(t){return s[t-=378]})(t,e)}function M(){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(M=function(){return t})()}!function(){const t=k,e=M();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 x{[j(397)](t){const e=j;if(typeof(t=utxt(t[e(390)]))==e(392)&&(t=JSON[e(400)](t)),null==t)throw Error(e(395));const s=new B("S"===t[e(402)]||!0===t[e(402)]);return Array[e(394)](t[e(391)])&&t[e(391)][e(385)]((t=>s.putAccess(t[e(382)],String(t.status)==e(398)))),s}}class B{constructor(t){const e=j;this.isSup=t,this[e(384)]={}}[j(378)](t,e){this[j(384)][t]=e}[j(393)](t){const e=j;if(this[e(402)])return!0;let s=!0;return this[e(384)][e(380)](t)&&(s=this.actions[t]),s}isUserSup(){return this.isSup}}class z extends v{getData(t){const e=`cfg://auth/${t}`;return new Promise(((t,s)=>{this.loadResource(e).then((e=>{let s=o.stringToObject(e);s&&"object"==typeof s&&t(s)})).catch((t=>{s(t)}))}))}}var G;function J(t){if(null==t)return t;if(t instanceof Date)return t.toISOString();if("object"==typeof t){if(t instanceof Array)return t.map((t=>J(t)));{const e=Object.assign({},t);return Object.keys(t).forEach((s=>{t[s]?e[s]=J(t[s]):delete e[s]})),e}}return t}!function(t){t.INSERT="I",t.UPDATE="A",t.REMOVE="E",t.SHOW="C",t.CONFIG="F",t.CONFIG_NUMBER="N",t.CLONE="D",t.CONFIG_GRID="G"}(G||(G={}));class H extends v{saveConfig(t,e,s){const i=t.map((t=>{const{id:e,value:s,fixed:i,visible:r}=t,n={id:e};return s&&(n.value=J(s)),i&&(n.fixed=i),r&&(n.visible=!0),n}));return this.saveResource(i,`cfg://filter/FilterBarState:${e}/${s}`)}getConfig(t,e){return new Promise(((s,i)=>{this.loadResource(`cfg://filter/FilterBarState:${t}/${e}`).then((t=>{let e;t&&(e=JSON.parse(t).items),s(e||[])})).catch((t=>{i(t)}))}))}}const V=class{constructor(s){t(this,s),this.applicationLoaded=e(this,"applicationLoaded",7),this.applicationLoading=e(this,"applicationLoading",7),this._authPromises=[],this._duCache=new Map,this._duPromises=new Map,this._requestListener=new W}get parameters(){return this._parameters||(this._parameters=new L),this._parameters}get resourceID(){return this._resourceID||(this._resourceID=this.urlParams.get("workspaceResourceID")||this.urlParams.get("resourceID")||R.resourceID||"unknown.resource.id"),this._resourceID}get auth(){return this._auth?Promise.resolve(this._auth):new Promise(((t,e)=>{const s=this._authPromises.length>0;this._authPromises.push(new Z(t,e)),s||this.authFetcher.getData(this.resourceID).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)}))}))}async isUserSup(){return new Promise(((t,e)=>{this.auth.then((s=>{this.getAuthList(s).then((e=>{t(e.isSup)})).catch((t=>e(t)))}))}))}async hasAccess(t){return new Promise(((e,s)=>{this.auth.then((i=>{this.getAuthList(i).then((s=>{e(s.isSup||s.actions[t])})).catch((t=>s(t)))}))}))}async getAllAccess(){return new Promise(((t,e)=>{this.auth.then((s=>{this.getAuthList(s).then((e=>{const s={};s.isSup=e.isSup,Object.entries(G).forEach((t=>{s[t[0]]=e.actions[t[1]]||!1})),t(s)})).catch((t=>e(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",s=!0){this.clearContent(this._popUp),this._popUp.appendChild(t),this._popUp.opened=!0,this._popUp.heightMode=e,this._popUp.useHeader=s,"EZ-MODAL-CONTAINER"===t.tagName&&(this._popUp.useHeader=!1)}async showModal(t){this.clearContent(this._rightModal),this._rightModal.appendChild(t),this._rightModal.opened=!0}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,s)=>{this.getAttributeFromHTMLWrapper("opc0009").then((i=>{"1"===i?t(!0):Promise.all(e.map((t=>this.getAttributeFromHTMLWrapper("opc"+t)))).then((e=>{t(e.includes("1"))})).catch((t=>{s(t)}))})).catch((t=>{s(t)}))}))}async getConfig(t){let e={serviceName:"SystemUtilsSP.getConf",requestBody:{config:{chave:t,tipo:"T"}}};return new Promise(((t,s)=>{w.get().callServiceBroker("SystemUtilsSP.getConf",JSON.stringify(e)).then((e=>{var s;return t(null===(s=e.config)||void 0===s?void 0:s.data)})).catch((t=>s(t)))}))}async saveConfig(t,e){let s={serviceName:"SystemUtilsSP.saveConf",requestBody:{config:{chave:t,tipo:"T",data:e}}};return new Promise(((t,e)=>{w.get().callServiceBroker("SystemUtilsSP.saveConf",JSON.stringify(s)).then((e=>t(e))).catch((t=>e(t)))}))}async getAttributeFromHTMLWrapper(t){return Promise.resolve(window[t])}async openApp(t,e){R.openAppActivity(t,e)}async webConnection(t,e,s){this.getStringParam(t).then((t=>{(class{static webConnectionCaller(t,e,s){var i;null===(i=window.AppletCaller)||void 0===i||i.webConnectionCaller(t,e,s)}}).webConnectionCaller(t,e,s)}))}getDuPromissesStack(t){let e;return t&&(e=this._duPromises.get(t),e||(e=[],this._duPromises.set(t,e))),e||[]}async createDataunit(t,e,s){return new Promise(((i,r)=>{const n=this.getDuPromissesStack(e),a=n.length>0;if(n.push(new Z(i,r)),!a){const i=this.dataUnitFetcher.getDataUnit(t,this.resourceID,s);i.loadMetadata().then((()=>{for(e&&this._duCache.set(e,i);n.length>0;)n.pop().resolve(i)})).catch((t=>{for(;n.length>0;)n.pop().reject(t)}))}}))}async getDataUnit(t,e,s){return new Promise(((i,r)=>{const n=this._duCache.get(e);n?i(n):this.createDataunit(t,e,s).then((t=>{i(t)})).catch((t=>r(t)))}))}async getResourceID(){return Promise.resolve(this.resourceID)}async getUserID(){return Promise.resolve(window.UID)}async alert(t,e,s,i){return S.alert(t,e,s,i)}async error(t,e,s,i){return S.error(t,e,s,i)}async success(t,e,s,i){return S.success(t,e,s,i)}async message(t,e,s,i){return S.message(t,e,s,i)}async confirm(t,e,s,i,r){return S.confirm(t,e,s,i,r)}async info(t,e){return S.info(t,e)}async loadFormConfig(t){return this.formConfigFetcher.loadFormConfig(t,this.resourceID)}async loadGridConfig(t){return this.gridConfigFetcher.getConfig(t,this.resourceID)}async fetchUserAvailableConfigs(t){return this.formConfigFetcher.fetchUserAvailableConfigs(t,this.resourceID)}async fetchLegacyConfig(t){return this.formConfigFetcher.fetchLegacyConfig(t,this.resourceID)}async fetchDefaultConfig(t){return this.formConfigFetcher.fetchDefaultConfig(t,this.resourceID)}async loadTotals(t,e,s){return this.totalsFetcher.fetchTotals(t,e,s)}async saveGridConfig(t){return this.gridConfigFetcher.saveConfig(t,this.resourceID)}async getFilterBarConfig(t){return new Promise(((e,s)=>{this.configName===t&&this._filterBarConfig?e(this._filterBarConfig):this.configName===t&&null!=this._filterConfigPromise?Promise.all([this._filterConfigPromise]).then((t=>e(t[0]))).catch((t=>s(t[0]))):this.filterBarConfigFetcher.getConfig(this.resourceID,t).then((t=>e(t))).catch((t=>s(t)))}))}async saveFilterBarConfig(t,e){return this.filterBarConfigFetcher.saveConfig(t,this.resourceID,e)}async saveFormConfig(t,e){return this.formConfigFetcher.saveConfig(t,e,this.resourceID)}async getDefaultValues(){return this.defaultValuesFetcher.getDefaultValues(this.resourceID)}async getDefaultValue(t){return this._defaultValues&&this._defaultValues[t]}async getAuthList(t){return await(new x).parseFromJSON(t)}get urlParams(){return this._urlParams||(this._urlParams=I.getQueryParams(location.search)),this._urlParams}get dataUnitFetcher(){return this._dataUnitFetcher||(this._dataUnitFetcher=new O),this._dataUnitFetcher}get formConfigFetcher(){return this._formConfigFetcher||(this._formConfigFetcher=new $),this._formConfigFetcher}get gridConfigFetcher(){return this._gridConfigFetcher||(this._gridConfigFetcher=new _),this._gridConfigFetcher}get totalsFetcher(){return this._totalsFetcher||(this._totalsFetcher=new q),this._totalsFetcher}get pesquisaFetcher(){return this._pesquisaFetcher||(this._pesquisaFetcher=new A),this._pesquisaFetcher}get authFetcher(){return this._authFetcher||(this._authFetcher=new z),this._authFetcher}get filterBarConfigFetcher(){return this._filterBarConfigFetcher||(this._filterBarConfigFetcher=new H),this._filterBarConfigFetcher}get defaultValuesFetcher(){return this._defaultValuesFetcher||(this._defaultValuesFetcher=new U),this._defaultValuesFetcher}async executeSearch(t,e,s){const i=null==s?void 0:s.getField(e);if(i){const{mode:e,argument:r}=t,{ENTITYNAME:n,CODEFIELD:a,DESCRIPTIONFIELD:o,ROOTENTITY:h,DESCRIPTIONENTITY:u}=i.properties,l=i.dependencies;let d;const m={rootEntity:h,descriptionFieldName:o,codeFieldName:a,showInactives:!1};return null==l||l.filter((t=>{var e;return null===(e=t.masterFields)||void 0===e?void 0:e.every((t=>{var e;return null===(e=s.getField(t))||void 0===e?void 0:e.visible}))})).forEach((t=>{var e;t.type===p.SEARCHING&&(null===(e=t.masterFields)||void 0===e?void 0:e.length)>0&&(d={expression:t.expression,params:t.masterFields.map((t=>{const e=s.getField(t),i=(null==e?void 0:e.dataType)||c.TEXT,r=s.getFieldValue(t);if(null==r)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:r,dataType:i}}))})})),this.executePreparedSearch(e,r,{entity:n,entityDescription:u,criteria:d,searchOptions:m})}}async executePreparedSearch(t,e,s){const{entity:i,entityDescription:r,criteria:n,searchOptions:a}=s;return"ADVANCED"===t?new Promise((t=>{const s=document.createElement("snk-pesquisa");s[m.DATA_ELEMENT_ID_ATTRIBUTE_NAME]=`entity_${i}`,s.argument=e,s.searchLoader=t=>this.pesquisaFetcher.loadAdvancedSearch(i,t,n,a),s.selectItem=e=>{t(e),this.clearPopUpTitle(),this.closePopUp()},this.setPopUpTitle(r),this.showPopUp(s)})):this.pesquisaFetcher.loadSearchOptions(i,e,n,a)}async isDebugMode(){return new Promise((t=>{t(window.isDebugMode)}))}async getAppLabel(){return R.getAppLabel(this._resourceID)}clearContent(t){t&&Array.from(t.children).forEach((e=>{t.removeChild(e)}))}clearPopUpTitle(){this._popUp.ezTitle=""}setPopUpTitle(t){this._popUp.ezTitle=t}componentWillLoad(){this._errorHandler=new C(this),this.messagesBuilder=new D,f.setContextValue("__EZUI__UPLOAD__ADD__URL__",`${I.getUrlBase()}/mge/upload/file`),f.setContextValue("__EZUI__SEARCH__OPTION__LOADER__",((t,e,s)=>this.executeSearch(t,e,s))),f.setContextValue("__EZUI__GRID_LICENSE__",b),this.configName&&(this._filterConfigPromise=new Promise(((t,e)=>{this.filterBarConfigFetcher.getConfig(this.resourceID,this.configName).then((e=>{this._filterBarConfig=e,t(e)})).catch((t=>e(t)))}))),y.init(),P.get(),this.getDefaultValues().then((t=>{this._defaultValues=t}))}connectedCallback(){f.setContextValue("__SNK__APPLICATION__",this),w.addRequestListener(this._requestListener)}disconnectedCallback(){w.removeRequestListener(this._requestListener)}componentDidLoad(){this.applicationLoading.emit(!0),window.requestAnimationFrame((()=>{this.applicationLoaded.emit(!0)})),m.addIDInfo(this._element,`resource_${this._resourceID}`)}render(){return s("div",null,s("ez-loading-bar",{ref:t=>this._requestListener.loadingBar=t}),s("ez-popup",{opened:!1,ref:t=>this._popUp=t,onEzClosePopup:()=>this.closePopUp()}),s("ez-modal",{opened:!1,ref:t=>this._rightModal=t,"modal-size":"small",closeOutsideClick:!0,closeEsc:!0}))}get _element(){return i(this)}};class W{constructor(){this._debounceTime=1e3,this._ignoredNameTypes=["totals"],this._countRequest=0}onRequestStart(t){this.isIgnoreLoadingOnRequest(t)||(this._countRequest++,this.loadingBar.show(),this._timerLoading&&clearTimeout(this._timerLoading))}onRequestEnd(t){this.isIgnoreLoadingOnRequest(t)||(this._countRequest--,this._timerLoading=setTimeout((()=>{this._countRequest<=0&&this.loadingBar.hide()}),this._debounceTime))}isIgnoreLoadingOnRequest(t){var e;if(1==(null===(e=null==t?void 0:t.requestBody)||void 0===e?void 0:e.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{constructor(t,e){this.resolve=t,this.reject=e}}V.style=".sc-snk-application-h{display:flex;flex-direction:column;height:100%}";export{V as snk_application}
|
|
83
|
+
}`)}async getParam(t){const e=`param://application?params=${t}`;return w.get().callGraphQL({values:{name:e},query:this.templateByQuery.get("fetchParam")})}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 this.getValue(e).includes('"S"')}async asDate(t){const e=await this.getParam(t);return d.strToDate(this.getValue(e))}async getBatchParams(t){const e=await this.getParam(t.join(",")),s={};return e.forEach((t=>s[t.name]=t.resource)),s}getValue(t={}){return Array.isArray(t)&&t.length>0&&(t=t[0]),u.isEmpty(t.resource)?"":t.resource}}const k=M;function M(t,e){const s=x();return(M=function(t){return s[t-=378]})(t,e)}function x(){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(x=function(){return t})()}!function(){const t=M,e=x();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 B{[k(397)](t){const e=k;if(typeof(t=utxt(t[e(390)]))==e(392)&&(t=JSON[e(400)](t)),null==t)throw Error(e(395));const s=new z("S"===t[e(402)]||!0===t[e(402)]);return Array[e(394)](t[e(391)])&&t[e(391)][e(385)]((t=>s.putAccess(t[e(382)],String(t.status)==e(398)))),s}}class z{constructor(t){const e=k;this.isSup=t,this[e(384)]={}}[k(378)](t,e){this[k(384)][t]=e}[k(393)](t){const e=k;if(this[e(402)])return!0;let s=!0;return this[e(384)][e(380)](t)&&(s=this.actions[t]),s}isUserSup(){return this.isSup}}class G extends v{getData(t){const e=`cfg://auth/${t}`;return new Promise(((t,s)=>{this.loadResource(e).then((e=>{let s=o.stringToObject(e);s&&"object"==typeof s&&t(s)})).catch((t=>{s(t)}))}))}}var J;function H(t){if(null==t)return t;if(t instanceof Date)return t.toISOString();if("object"==typeof t){if(t instanceof Array)return t.map((t=>H(t)));{const e=Object.assign({},t);return Object.keys(t).forEach((s=>{t[s]?e[s]=H(t[s]):delete e[s]})),e}}return t}!function(t){t.INSERT="I",t.UPDATE="A",t.REMOVE="E",t.SHOW="C",t.CONFIG="F",t.CONFIG_NUMBER="N",t.CLONE="D",t.CONFIG_GRID="G"}(J||(J={}));class V extends v{saveConfig(t,e,s){const i=t.map((t=>{const{id:e,value:s,fixed:i,visible:r}=t,n={id:e};return s&&(n.value=H(s)),i&&(n.fixed=i),r&&(n.visible=!0),n}));return this.saveResource(i,`cfg://filter/FilterBarState:${e}/${s}`)}getConfig(t,e){return new Promise(((s,i)=>{this.loadResource(`cfg://filter/FilterBarState:${t}/${e}`).then((t=>{let e;t&&(e=JSON.parse(t).items),s(e||[])})).catch((t=>{i(t)}))}))}}const W=class{constructor(s){t(this,s),this.applicationLoaded=e(this,"applicationLoaded",7),this.applicationLoading=e(this,"applicationLoading",7),this._authPromises=[],this._duCache=new Map,this._duPromises=new Map,this._requestListener=new Z,this.messagesBuilder=void 0,this.configName=void 0}get parameters(){return this._parameters||(this._parameters=new j),this._parameters}get resourceID(){return this._resourceID||(this._resourceID=this.urlParams.get("workspaceResourceID")||this.urlParams.get("resourceID")||R.resourceID||"unknown.resource.id"),this._resourceID}get auth(){return this._auth?Promise.resolve(this._auth):new Promise(((t,e)=>{const s=this._authPromises.length>0;this._authPromises.push(new K(t,e)),s||this.authFetcher.getData(this.resourceID).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)}))}))}async isUserSup(){return new Promise(((t,e)=>{this.auth.then((s=>{this.getAuthList(s).then((e=>{t(e.isSup)})).catch((t=>e(t)))}))}))}async hasAccess(t){return new Promise(((e,s)=>{this.auth.then((i=>{this.getAuthList(i).then((s=>{e(s.isSup||s.actions[t])})).catch((t=>s(t)))}))}))}async getAllAccess(){return new Promise(((t,e)=>{this.auth.then((s=>{this.getAuthList(s).then((e=>{const s={};s.isSup=e.isSup,Object.entries(J).forEach((t=>{s[t[0]]=e.actions[t[1]]||!1})),t(s)})).catch((t=>e(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",s=!0){this.clearContent(this._popUp),this._popUp.appendChild(t),this._popUp.opened=!0,this._popUp.heightMode=e,this._popUp.useHeader=s,"EZ-MODAL-CONTAINER"===t.tagName&&(this._popUp.useHeader=!1)}async showModal(t){this.clearContent(this._rightModal),this._rightModal.appendChild(t),this._rightModal.opened=!0}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,s)=>{this.getAttributeFromHTMLWrapper("opc0009").then((i=>{"1"===i?t(!0):Promise.all(e.map((t=>this.getAttributeFromHTMLWrapper("opc"+t)))).then((e=>{t(e.includes("1"))})).catch((t=>{s(t)}))})).catch((t=>{s(t)}))}))}async getConfig(t){let e={serviceName:"SystemUtilsSP.getConf",requestBody:{config:{chave:t,tipo:"T"}}};return new Promise(((t,s)=>{w.get().callServiceBroker("SystemUtilsSP.getConf",JSON.stringify(e)).then((e=>{var s;return t(null===(s=e.config)||void 0===s?void 0:s.data)})).catch((t=>s(t)))}))}async saveConfig(t,e){let s={serviceName:"SystemUtilsSP.saveConf",requestBody:{config:{chave:t,tipo:"T",data:e}}};return new Promise(((t,e)=>{w.get().callServiceBroker("SystemUtilsSP.saveConf",JSON.stringify(s)).then((e=>t(e))).catch((t=>e(t)))}))}async getAttributeFromHTMLWrapper(t){return Promise.resolve(window[t])}async openApp(t,e){R.openAppActivity(t,e)}async webConnection(t,e,s){this.getStringParam(t).then((t=>{L.webConnectionCaller(t,e,s)}))}getDuPromissesStack(t){let e;return t&&(e=this._duPromises.get(t),e||(e=[],this._duPromises.set(t,e))),e||[]}async createDataunit(t,e,s){return new Promise(((i,r)=>{const n=this.getDuPromissesStack(e),a=n.length>0;if(n.push(new K(i,r)),!a){const i=this.dataUnitFetcher.getDataUnit(t,this.resourceID,s);i.loadMetadata().then((()=>{for(e&&this._duCache.set(e,i);n.length>0;)n.pop().resolve(i)})).catch((t=>{for(;n.length>0;)n.pop().reject(t)}))}}))}async getDataUnit(t,e,s){return new Promise(((i,r)=>{const n=this._duCache.get(e);n?i(n):this.createDataunit(t,e,s).then((t=>{i(t)})).catch((t=>r(t)))}))}async getResourceID(){return Promise.resolve(this.resourceID)}async getUserID(){return Promise.resolve(window.UID)}async alert(t,e,s,i){return S.alert(t,e,s,i)}async error(t,e,s,i){return S.error(t,e,s,i)}async success(t,e,s,i){return S.success(t,e,s,i)}async message(t,e,s,i){return S.message(t,e,s,i)}async confirm(t,e,s,i,r){return S.confirm(t,e,s,i,r)}async info(t,e){return S.info(t,e)}async loadFormConfig(t){return this.formConfigFetcher.loadFormConfig(t,this.resourceID)}async loadGridConfig(t){return this.gridConfigFetcher.getConfig(t,this.resourceID)}async fetchUserAvailableConfigs(t){return this.formConfigFetcher.fetchUserAvailableConfigs(t,this.resourceID)}async fetchLegacyConfig(t){return this.formConfigFetcher.fetchLegacyConfig(t,this.resourceID)}async fetchDefaultConfig(t){return this.formConfigFetcher.fetchDefaultConfig(t,this.resourceID)}async loadTotals(t,e,s){return this.totalsFetcher.fetchTotals(t,e,s)}async saveGridConfig(t){return this.gridConfigFetcher.saveConfig(t,this.resourceID)}async getFilterBarConfig(t){return new Promise(((e,s)=>{this.configName===t&&this._filterBarConfig?e(this._filterBarConfig):this.configName===t&&null!=this._filterConfigPromise?Promise.all([this._filterConfigPromise]).then((t=>e(t[0]))).catch((t=>s(t[0]))):this.filterBarConfigFetcher.getConfig(this.resourceID,t).then((t=>e(t))).catch((t=>s(t)))}))}async saveFilterBarConfig(t,e){return this.filterBarConfigFetcher.saveConfig(t,this.resourceID,e)}async saveFormConfig(t,e){return this.formConfigFetcher.saveConfig(t,e,this.resourceID)}async getDefaultValues(){return this.defaultValuesFetcher.getDefaultValues(this.resourceID)}async getDefaultValue(t){return this._defaultValues&&this._defaultValues[t]}async getAuthList(t){return await(new B).parseFromJSON(t)}get urlParams(){return this._urlParams||(this._urlParams=I.getQueryParams(location.search)),this._urlParams}get dataUnitFetcher(){return this._dataUnitFetcher||(this._dataUnitFetcher=new O),this._dataUnitFetcher}get formConfigFetcher(){return this._formConfigFetcher||(this._formConfigFetcher=new $),this._formConfigFetcher}get gridConfigFetcher(){return this._gridConfigFetcher||(this._gridConfigFetcher=new _),this._gridConfigFetcher}get totalsFetcher(){return this._totalsFetcher||(this._totalsFetcher=new q),this._totalsFetcher}get pesquisaFetcher(){return this._pesquisaFetcher||(this._pesquisaFetcher=new A),this._pesquisaFetcher}get authFetcher(){return this._authFetcher||(this._authFetcher=new G),this._authFetcher}get filterBarConfigFetcher(){return this._filterBarConfigFetcher||(this._filterBarConfigFetcher=new V),this._filterBarConfigFetcher}get defaultValuesFetcher(){return this._defaultValuesFetcher||(this._defaultValuesFetcher=new U),this._defaultValuesFetcher}async executeSearch(t,e,s){const i=null==s?void 0:s.getField(e);if(i){const{mode:e,argument:r}=t,{ENTITYNAME:n,CODEFIELD:a,DESCRIPTIONFIELD:o,ROOTENTITY:h,DESCRIPTIONENTITY:u}=i.properties,l=i.dependencies;let d;const m={rootEntity:h,descriptionFieldName:o,codeFieldName:a,showInactives:!1};return null==l||l.filter((t=>{var e;return null===(e=t.masterFields)||void 0===e?void 0:e.every((t=>{var e;return null===(e=s.getField(t))||void 0===e?void 0:e.visible}))})).forEach((t=>{var e;t.type===p.SEARCHING&&(null===(e=t.masterFields)||void 0===e?void 0:e.length)>0&&(d={expression:t.expression,params:t.masterFields.map((t=>{const e=s.getField(t),i=(null==e?void 0:e.dataType)||c.TEXT,r=s.getFieldValue(t);if(null==r)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:r,dataType:i}}))})})),this.executePreparedSearch(e,r,{entity:n,entityDescription:u,criteria:d,searchOptions:m})}}async executePreparedSearch(t,e,s){const{entity:i,entityDescription:r,criteria:n,searchOptions:a}=s;return"ADVANCED"===t?new Promise((t=>{const s=document.createElement("snk-pesquisa");s[m.DATA_ELEMENT_ID_ATTRIBUTE_NAME]=`entity_${i}`,s.argument=e,s.searchLoader=t=>this.pesquisaFetcher.loadAdvancedSearch(i,t,n,a),s.selectItem=e=>{t(e),this.clearPopUpTitle(),this.closePopUp()},this.setPopUpTitle(r),this.showPopUp(s)})):this.pesquisaFetcher.loadSearchOptions(i,e,n,a)}async isDebugMode(){return new Promise((t=>{t(window.isDebugMode)}))}async getAppLabel(){return R.getAppLabel(this._resourceID)}clearContent(t){t&&Array.from(t.children).forEach((e=>{t.removeChild(e)}))}clearPopUpTitle(){this._popUp.ezTitle=""}setPopUpTitle(t){this._popUp.ezTitle=t}componentWillLoad(){this._errorHandler=new C(this),this.messagesBuilder=new D,f.setContextValue("__EZUI__UPLOAD__ADD__URL__",`${I.getUrlBase()}/mge/upload/file`),f.setContextValue("__EZUI__SEARCH__OPTION__LOADER__",((t,e,s)=>this.executeSearch(t,e,s))),f.setContextValue("__EZUI__GRID_LICENSE__",E),this.configName&&(this._filterConfigPromise=new Promise(((t,e)=>{this.filterBarConfigFetcher.getConfig(this.resourceID,this.configName).then((e=>{this._filterBarConfig=e,t(e)})).catch((t=>e(t)))}))),y.init(),P.get(),this.getDefaultValues().then((t=>{this._defaultValues=t}))}connectedCallback(){f.setContextValue("__SNK__APPLICATION__",this),w.addRequestListener(this._requestListener)}disconnectedCallback(){w.removeRequestListener(this._requestListener)}componentDidLoad(){this.applicationLoading.emit(!0),window.requestAnimationFrame((()=>{this.applicationLoaded.emit(!0)})),m.addIDInfo(this._element,`resource_${this._resourceID}`)}render(){return s("div",null,s("ez-loading-bar",{ref:t=>this._requestListener.loadingBar=t}),s("ez-popup",{opened:!1,ref:t=>this._popUp=t,onEzClosePopup:()=>this.closePopUp()}),s("ez-modal",{opened:!1,ref:t=>this._rightModal=t,"modal-size":"small",closeOutsideClick:!0,closeEsc:!0}))}get _element(){return i(this)}};class Z{constructor(){this._debounceTime=1e3,this._ignoredNameTypes=["totals"],this._countRequest=0}onRequestStart(t){this.isIgnoreLoadingOnRequest(t)||(this._countRequest++,this.loadingBar.show(),this._timerLoading&&clearTimeout(this._timerLoading))}onRequestEnd(t){this.isIgnoreLoadingOnRequest(t)||(this._countRequest--,this._timerLoading=setTimeout((()=>{this._countRequest<=0&&this.loadingBar.hide()}),this._debounceTime))}isIgnoreLoadingOnRequest(t){var e;if(1==(null===(e=null==t?void 0:t.requestBody)||void 0===e?void 0:e.length)){const{name:e}=t.requestBody[0].variables;if(e){const t=e.split(":");return this._ignoredNameTypes.indexOf(t[0])>=0}}return!1}}class K{constructor(t,e){this.resolve=t,this.reject=e}}W.style=".sc-snk-application-h{display:flex;flex-direction:column;height:100%}";export{W as snk_application}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{r as i,c as t,h as s,g as e}from"./p-b9667fbe.js";import{DateUtils as a,ObjectUtils as o,ElementIDUtils as r,ApplicationContext as n}from"@sankhyalabs/core";import{C as h}from"./p-93d8ea09.js";import{P as d}from"./p-5534e08c.js";import{T as l}from"./p-5a3e0eb6.js";import"./p-112455b1.js";const c=class{constructor(s){i(this,s),this.exit=t(this,"exit",7),this.actionClick=t(this,"actionClick",7),this._renderTimer=500,this._dataUnit=void 0,this._dataState=void 0,this._editionFormConfig={},this._insertionFormConfig={},this._showFormConfig=!1,this.configName=void 0,this.recordsValidator=void 0,this.actionsList=void 0,this.taskbarManager=void 0,this.presentationMode=d.PRIMARY}async showConfig(){this._showFormConfig=!0}async hideConfig(){this._showFormConfig=!1}getFinishEditionTaskbarButtons(){return this.presentationMode===d.PRIMARY?["CANCEL","SAVE"]:["SAVE","CANCEL"]}getRegularTaskbarButtons(){return this.presentationMode===d.PRIMARY?["PREVIOUS","NEXT","DIVIDER","CLONE","REMOVE","MORE_OPTIONS","DIVIDER","GRID_MODE","CONFIGURATOR","INSERT"]:["INSERT","PREVIOUS","NEXT","DIVIDER","CLONE","REMOVE","MORE_OPTIONS","DIVIDER","GRID_MODE","CONFIGURATOR"]}loadConfig(){null!=this.configName&&h.get().then((i=>{i.loadFormConfig(this.configName).then((i=>{this.setConfig(i)||this.loadInsertionConfig()})).catch((i=>{console.warn(i)}))}))}setConfig(i){return null!=(null==i?void 0:i.fields)&&(setTimeout((async()=>{for(const t of i.fields)if(t.defaultValue&&"value"in t.defaultValue){const i=t.defaultValue.value;await this.getFormattedValue(i).then((i=>{t.defaultValue.formattedValue=i}))}this._editionFormConfig=i,this.loadInsertionConfig()}),this._renderTimer),!0)}async getFormattedValue(i){switch(i){case"${data}":return()=>a.getToday();case"${datahora}":return()=>a.getToday(!0);case"${usuario}":case"${usuario.empresa}":case"${usuario.vendedor}":case"${usuario.centroresultado}":let t;return await this._application.getDefaultValue(i).then((i=>{t=i})),t;default:return i}}loadInsertionConfig(){var i;if(this._dataUnit){const t=o.copy(this._editionFormConfig||{});t.fields=null===(i=t.fields)||void 0===i?void 0:i.filter((i=>{const t=this._dataUnit.getField(i.name);return!(null==t?void 0:t.readOnly)})),this._insertionFormConfig=t}}getFormConfig(){return this._dataState&&this._dataState.insertionMode?this._insertionFormConfig:this._editionFormConfig}exitForm(){this._dataUnit.isDirty()?this._dataUnit.cancelEdition({after:()=>this.exit.emit()}):this.exit.emit()}getMessage(i){return this._application.messagesBuilder.getMessage(i,this.getMessageParams())}getMessageParams(){var i;return(null===(i=this._dataState)||void 0===i?void 0:i.selectedRecords)?this._dataState.selectedRecords[0]:void 0}changeConfig(i){this._editionFormConfig={},this.setConfig(i)||this.loadInsertionConfig()}closeConfig(){this.hideConfig()}validatePresentationMode(){Object.values(d).includes(this.presentationMode)||(this.presentationMode=d.PRIMARY)}dataunitReady(){this.loadInsertionConfig(),r.addIDInfo(this._element,null,{dataUnit:this._dataUnit})}loadTaskbarProcessor(){var i;const t=(null===(i=this._dataState)||void 0===i?void 0:i.isDirty)?"snkForm.finish_edition":"snkForm.regular",s=[];this._dataState&&this._dataState.hasPrevious||s.push("PREVIOUS"),this._dataState&&this._dataState.hasNext||s.push("NEXT"),this._taskbarProcessor=new l({"snkForm.regular":this.getRegularTaskbarButtons(),"snkForm.finish_edition":this.getFinishEditionTaskbarButtons()}),this._taskbarProcessor.process(t,this.taskbarManager,this._dataState,s)}getDisabledButtons(){const i=[];return this._dataState.hasPrevious||i.push("PREVIOUS"),this._dataState.hasNext||i.push("NEXT"),i}componentWillLoad(){this._application=n.getContextValue("__SNK__APPLICATION__");let i=this._element.parentElement;for(;i;){if("SNK-DATA-UNIT"===i.tagName.toUpperCase()){this._snkDataUnit=i,this._dataUnit=this._snkDataUnit.dataUnit,this._dataState=this._snkDataUnit.dataState,this._dataUnit?this.dataunitReady():this._snkDataUnit.addEventListener("dataUnitReady",(i=>{this._dataUnit=i.detail,this.loadInsertionConfig()})),this._snkDataUnit.addEventListener("dataStateChange",(i=>{this._dataState=i.detail}));break}i=i.parentElement}this.loadConfig()}componentWillRender(){this.validatePresentationMode(),this.loadTaskbarProcessor()}render(){var i;if(this._dataUnit&&this._dataState)return s("section",{class:"snk-form"},s("div",{class:`snk-form__header ez-row\n ${this.presentationMode===d.PRIMARY?"snk-form__header--fixed":""}\n `},this.presentationMode===d.PRIMARY&&s("div",{class:"ez-col ez-col--sd-6 ez-col--tb-6",key:"formHeader"},s("ez-button",{title:this.getMessage("snkForm.goBackTitle"),mode:"icon",iconName:"arrow_back",class:"ez-padding-right--medium",size:"small",onClick:()=>this.exitForm(),"data-element-id":"formToBack"}),s("h1",{class:"ez-title ez-title--primary ez-title--xlarge ez-align--middle"},this.getMessage("snkForm.title"))),s("div",{class:`ez-col\n ${this.presentationMode===d.PRIMARY?"ez-col--sd-6 ez-col--tb-6 ez-align--right":""}\n `},s("snk-taskbar",{key:"formTaskbar","data-element-id":"form",configName:this.configName,buttons:this._taskbarProcessor.buttons,disabledButtons:this._taskbarProcessor.disabledButtons,customButtons:this._taskbarProcessor.customButtons,actionsList:this.actionsList,primaryButton:(null===(i=this._dataState)||void 0===i?void 0:i.isDirty)?"SAVE":"INSERT",dataUnit:this._dataUnit,presentationMode:this.presentationMode}))),s("section",null,s("div",{class:"ez-row"},s("div",{class:"ez-col ez-col--sd-12"},s("ez-form",{key:"ezForm"+this._snkDataUnit.entityName,"data-element-id":"embedded",dataUnit:this._dataUnit,config:this.getFormConfig(),recordsValidator:this.recordsValidator,class:this._showFormConfig?"snk-form__form--hidden":""}),this._showFormConfig&&s("snk-form-config",{dataUnit:this._dataUnit,formConfig:this.getFormConfig(),configName:this.configName,onConfigChange:i=>this.changeConfig(i.detail),onConfigClose:()=>this.closeConfig()})))))}get _element(){return e(this)}};c.style=".sc-snk-form-h{display:block}.snk-form.sc-snk-form{position:relative;padding:var(--space--large);padding-top:var(--space--medium)}.snk-form__header.sc-snk-form{position:relative;padding-top:var(--space--medium);padding-bottom:var(--space--medium);margin-bottom:var(--space--medium)}.snk-form__header--fixed.sc-snk-form{position:sticky;top:0;background:var(--background--body);z-index:var(--visible);padding-left:var(--space--large);padding-right:var(--space--large);margin-left:calc(var(--space--large) * -1);margin-right:calc(var(--space--large) * -1);width:calc(100% + (var(--space--large) * 2))}.snk-form__form--hidden.sc-snk-form{display:none}";export{c as snk_form}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{r as t,c as i,h as o,F as a,H as n,g as s}from"./p-b9667fbe.js";import{d as c}from"./p-b6d6b172.js";import{ApplicationContext as e,ElementIDUtils as b}from"@sankhyalabs/core";import{C as r,K as l,b as f,T as g}from"./p-b4093344.js";import"./p-112455b1.js";const h=class{constructor(o){t(this,o),this.ezTabChange=i(this,"ezTabChange",7),this.editionTitleTab=i(this,"editionTitleTab",7),this.deleteTab=i(this,"deleteTab",7),this.hideTab=i(this,"hideTab",7),this.ezOrderChange=i(this,"ezOrderChange",7),this.canStartDrag=i(this,"canStartDrag",7),this._refTabActions=[],this._processedTabs=void 0,this._activeEditText=void 0,this._activeEditTextIndex=void 0,this._actionsHide=[],this._actionsShow=[],this.selectedIndex=void 0,this.selectedTab=void 0,this.tabs=void 0}getMessage(t,i){return this._application.messagesBuilder.getMessage(t,i)}controlSortableTab(){this._sortableTab&&this._sortableTab.destroy(),this._sortableTab=new c.Sortable(this._hostElem.querySelectorAll('[data-draggable-parent="tab"]'),{draggable:'[data-draggable-element="tab"]',mirror:{constrainDimensions:!0}}),this._sortableTab.on(r.dragStart,(t=>this.controlStartDraggingTab(t))),this._sortableTab.on(r.dragStop,(t=>this.controlStopDraggingTab(t)))}controlStartDraggingTab(t){var i,o;const a=null===(i=null==t?void 0:t.dragEvent)||void 0===i?void 0:i.originalEvent,n=null==a?void 0:a.target,s=null===(o=null==n?void 0:n.tagName)||void 0===o?void 0:o.toUpperCase();!0===this._activeEditText||"EZ-ACTIONS-BUTTON"===s?null==t||t.cancel():this.canStartDrag.emit()}controlStopDraggingTab(t){t.data.newIndex!==t.data.oldIndex&&setTimeout((()=>{this.ezOrderChange.emit((t.data.newIndex||0)+1)}),500)}handleTabClick(t){this.selectedIndex=t.index,this._focusedIndex=t.index,this.selectedTab=t.tabKey,this.ezTabChange.emit(t),this.setFocusedBtn(!1,t.index),this.setFocusedTab(t.index)}handleSlotChange(t){const i=t.target.assignedElements()[0];i&&i.classList.add("tab-config__slot")}scrollBackward(){const t=this._scrollContainer;t&&(t.scrollLeft-=t.clientWidth)}scrollFoward(){const t=this._scrollContainer;if(t){let i=null;t.querySelectorAll(".tab-config__tab").forEach((o=>{o.getBoundingClientRect().right<t.clientWidth&&(i=o)})),t.scrollLeft=i.offsetLeft+i.offsetWidth}}updateScroll(){const t=this._scrollContainer;if(t){const{scrollWidth:i,clientWidth:o,scrollLeft:a}=t,n=i-o-Math.ceil(a);this._startHidden=t.scrollLeft>0,this._endHidden=n>0,this._startHidden?this._backwardButton.classList.remove("tab-config__hidden"):this._backwardButton.classList.add("tab-config__hidden"),this._endHidden?this._forwardButton.classList.remove("tab-config__hidden"):this._forwardButton.classList.add("tab-config__hidden")}}domScrollHandler(){window.clearTimeout(this._scrollCallBackScroll),this._scrollCallBackScroll=window.setTimeout((()=>{this.updateScroll()}),200)}setFocusedTab(t){window.clearTimeout(this._scrollCallBackFocus),this._scrollCallBackFocus=window.setTimeout((()=>{this._scrollContainer.querySelector(`#tab${t}`).scrollIntoView({behavior:"smooth",block:"nearest",inline:"nearest"})}),200)}controlKeyEventEnter(t){t.preventDefault();const i=this._processedTabs[this._focusedIndex];this.handleTabClick(i),this.setFocusedTab(i.index)}controlKeyEventArrow(t){let i;if(t.key===l.arrowLeft)i=!1;else{if(t.key!==l.arrowRight)return;i=!0}this._focusedIndex=void 0===this._focusedIndex?!1===i?void 0!==this.selectedIndex?this.selectedIndex-1:void 0:void 0!==this.selectedIndex?this.selectedIndex+1:void 0:!1===i?this._focusedIndex-1:this._focusedIndex+1,this._focusedIndex<0?this._focusedIndex=0:this._focusedIndex>this._processedTabs.length-1&&(this._focusedIndex=this._processedTabs.length-1),this.setFocusedBtn(!0,this._focusedIndex),this.setFocusedTab(this._focusedIndex)}controlKeyEventEscape(t){t.preventDefault();const i=this._processedTabs[this.selectedIndex];this._focusedIndex=void 0,this.handleTabClick(i),this.setFocusedTab(this.selectedIndex)}setFocusedParam(t){!0!==this._activeEditText&&null!=t&&(t.key!==l.enter?t.key!==l.arrowLeft&&t.key!==l.arrowRight?t.key!==l.tab&&t.key!==l.escape||this.controlKeyEventEscape(t):this.controlKeyEventArrow(t):this.controlKeyEventEnter(t))}setFocusedBtn(t,i){this._scrollContainer.querySelectorAll(".tab-config__tab").forEach((o=>{o.classList.remove("tab-config__tab--is-focused"),o.id==="tab"+i&&t&&o.classList.add("tab-config__tab--is-focused")}))}getStyledLabel(t){const i=this._hostElem.querySelector(`#${t}`);if(null!=i)return{fontSize:window.getComputedStyle(i).getPropertyValue("font-size"),fontWeight:window.getComputedStyle(i).getPropertyValue("font-weight"),fontFamily:window.getComputedStyle(i).getPropertyValue("font-family")}}cancelEditText(){var t;this._activeEditText=!1,null!=this._scrollContainer&&(null===(t=this._scrollContainer.querySelector(".tab-config__tab--is-active"))||void 0===t||t.focus())}handleActions(t,i){const{value:o}=t.detail;o===f.rename?(this._activeEditText=!0,this._activeEditTextIndex=i.index):o===f.hide||o===f.show?this.hideTab.emit(i):o===f.delete&&this.deleteTab.emit(i)}handleSaveEditionText(t){const{value:i,newValue:o}=t.detail;this._processedTabs.forEach((a=>{a.label===i&&(a.label=o,this.cancelEditText(),this.editionTitleTab.emit(t))}))}onHideActions(t){const i=this._refTabActions[t];i&&i.isOpened().then((t=>{t&&(null==i||i.hideActions())}))}componentWillLoad(){this._application=e.getContextValue("__SNK__APPLICATION__"),null!=this._application&&(this._actionsHide=[{value:f.rename,label:this.getMessage("snkTabConfig.labelRename")},{value:f.hide,label:this.getMessage("snkTabConfig.labelHide")},{value:f.delete,label:this.getMessage("snkTabConfig.labelDelete")}],this._actionsShow=[{value:f.rename,label:this.getMessage("snkTabConfig.labelRename")},{value:f.show,label:this.getMessage("snkTabConfig.labelShow")},{value:f.delete,label:this.getMessage("snkTabConfig.labelDelete")}])}componentWillRender(){null==this._processedTabs&&(this._processedTabs=[],this.tabs&&this.tabs.split(",").forEach((t=>{t=t.trim(),this._processedTabs.push({label:t,tabKey:t,index:this._processedTabs.length})})),this._hostElem.querySelectorAll("snk-tab").forEach((t=>{const i=t.getAttribute("tabKey"),o=t.getAttribute("label")!==g.main?t.getAttribute("label"):this.getMessage("snkFormConfig.form.mainArea"),a=t.hasAttribute("visible"),n={label:o,tabKey:i,index:this._processedTabs.length,visible:a},s=t.firstChild;s&&(s.setAttribute("slot","tab"+n.index),this._hostElem.appendChild(s)),this._processedTabs.push(n)})))}componentDidRender(){this.updateScroll(),this.controlSortableTab()}componentDidLoad(){b.addIDInfo(this._hostElem,"itemConfig"),this._processedTabs.forEach(((t,i)=>{const o={id:t.label};b.addIDInfo(this._hostElem.querySelector(`#tab${i}`),"itemConfig",o)}))}render(){return o(n,null,o("button",{class:"tab-config__backward-button",ref:t=>this._backwardButton=t,onClick:()=>this.scrollBackward()}),o("div",{class:"tab-config__lower-bar"}),o("div",{class:"tab-config__scroll",ref:t=>this._scrollContainer=t,onScroll:()=>this.domScrollHandler(),onKeyDown:t=>this.setFocusedParam(t),"data-draggable-parent":"tab"},this._processedTabs.map(((t,i)=>{const n="tab"+i,s=i===this.selectedIndex||this.selectedTab&&t.tabKey===this.selectedTab;return s&&(this.selectedTab=t.tabKey,this.selectedIndex=i),o("button",{id:n,class:"tab-config__tab"+(s?" tab-config__tab--is-active":""),onClick:()=>this.handleTabClick(t),onDblClick:()=>{this._activeEditText=!0,this._activeEditTextIndex=i},"data-draggable-element":i>0?"tab":"",onMouseLeave:()=>this.onHideActions(i)},!0===this._activeEditText&&this._activeEditTextIndex===i&&i>0||o(a,null,i>0&&o("ez-icon",{iconName:t.leftIcon||"drag-indicator",class:"tab-config__left-icon"}),!1===t.visible&&i>0&&o("ez-icon",{iconName:t.leftIcon||"eye-off",class:"tab-config__left-icon tab-config__left-icon--eye-off"}),o("span",{class:"tab-config__tab-label"+(!1===t.visible&&i>0?" tab-config__tab-label-disabled":""),title:t.label},t.label),i>0&&o("ez-actions-button",{class:"tab-config__actions-button",size:"small",ref:t=>this._refTabActions[i]=t,actions:!1===t.visible?this._actionsShow:this._actionsHide,isTransparent:!0,arrowActive:!0,onEzAction:i=>this.handleActions(i,t)}),o("slot",{name:n,onSlotchange:t=>{this.handleSlotChange(t)}})),!0===this._activeEditText&&i>0&&this._activeEditTextIndex===i&&o("ez-text-edit",{value:t.label,styled:this.getStyledLabel(n),class:"tab-config__edit-text",onSaveEdition:t=>this.handleSaveEditionText(t),onCancelEdition:()=>this.cancelEditText()}))}))),o("button",{class:"tab-config__forward-button",ref:t=>this._forwardButton=t,onClick:()=>this.scrollFoward()}))}get _hostElem(){return s(this)}};h.style='@keyframes activate{0%{clip-path:inset(calc(100% - 3px) 50% 0px 50%)}100%{clip-path:inset(calc(100% - 3px) 0px 0px 0px)}}.sc-snk-tab-config-h{--snk-tab-config--backward-icon:url(\'data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" version="1.1" height="16px" width="10px"><path d="M 9.7808475,13.860393 3.9204526,8.0000004 9.7808475,2.0624965 7.9301965,0.28895552 0.21915255,8.0000004 7.9301965,15.711044 Z"/></svg>\');--snk-tab-config--forward-icon:url(\'data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" version="1.1" height="16px" width="10px"><path d="M 0.21915251,13.860393 6.0795475,8.0000007 0.21915251,2.0624968 2.0698036,0.28895588 9.7808475,8.0000007 2.0698036,15.711044 Z"/></svg>\');--snk-tab-config__lower-bar--background-color:var(--color--disable-primary, #e5eaf0);--snk-tab-config__lower-bar--border:2px solid var(--color--disable-primary, #e5eaf0);--snk-tab-config__tab--color:var(--text--primary, #626e82);--snk-tab-config__tab--font-family:var(--font-pattern, "Roboto");--snk-tab-config__tab--font-size:var(--title--small, 14px);--snk-tab-config__tab--padding:var(--space--small, 6px) var(--space--medium, 12px);--snk-tab-config__tab-is-active--color:var(--color--primary, #008561);--snk-tab-config__tab-hover--color:var(--color--secondary, #383c45);--snk-tab-config__tab-is-focused--border:1px dashed var(--color--primary, #008561);--snk-tab-config__tab-label--text-shadow:var(--text-shadow, 0 0 0 #353535, 0 0 1px transparent);--snk-tab-config__tab-label--margin-bottom:var(--space--extra-small, 3px);--snk-tab-config__new-button-icon--color:var(--color--secondary-700, #1C1D22);--snk-tab-config__forward-button--background-color:var(--text--primary, #626e82);--snk-tab-config__forward-button-hover--background-color:var(--color--primary, #008561);--snk-tab-config__left-icon--padding-right:var(--space--small, 6px);--snk-tab-config__left-icon--color:var(--text--disable, #AFB6C0);--snk-tab-config__tab-label-disabled--color:var(--text--disable, #AFB6C0);--snk-tab-config__slot--margin-left:var(--space--small, 6px);display:flex;position:relative;width:100%;overflow:hidden}.tab-config__scroll.sc-snk-tab-config{display:flex;width:100%;scroll-behavior:smooth;overflow-x:auto;scrollbar-width:none}.tab-config__lower-bar.sc-snk-tab-config{position:absolute;left:0%;right:0%;top:91%;bottom:0%;border-radius:2px;background-color:var(--snk-tab-config__lower-bar--background-color);border:var(--snk-tab-config__lower-bar--border)}.tab-config__tab.sc-snk-tab-config{display:flex;border:none;background-color:unset;cursor:pointer;align-items:center;justify-content:center;min-width:fit-content;color:var(--snk-tab-config__tab--color);font-family:var(--snk-tab-config__tab--font-family);font-size:var(--snk-tab-config__tab--font-size);padding:var(--snk-tab-config__tab--padding)}.tab-config__tab.sc-snk-tab-config:focus,.tab-config__forward-button.sc-snk-tab-config,.tab-config__backward-button.sc-snk-tab-config{outline:none}.tab-config__tab--is-active.sc-snk-tab-config{position:relative;color:var(--snk-tab-config__tab-is-active--color)}.tab-config__tab.sc-snk-tab-config:hover{color:var(--snk-tab-config__tab-hover--color)}.tab-config__tab--is-active.sc-snk-tab-config:hover{color:var(--snk-tab-config__tab-is-active--color)}.tab-config__tab--is-active.sc-snk-tab-config::after{content:"";position:absolute;width:100%;height:100%;clip-path:inset(calc(100% - 3px) 0px 0px 0px);animation:activate 0.25s ease-in-out;background-color:var(--snk-tab-config__tab-is-active--color)}.tab-config__tab--is-focused.sc-snk-tab-config{border:var(--snk-tab-config__tab-is-focused--border)}.tab-config__tab-label.sc-snk-tab-config{overflow:hidden;white-space:nowrap;text-overflow:ellipsis;text-shadow:var(--snk-tab-config__tab-label--text-shadow);margin-bottom:var(--snk-tab-config__tab-label--margin-bottom)}.tab-config__forward-button.sc-snk-tab-config,.tab-config__backward-button.sc-snk-tab-config{position:absolute;z-index:1;display:flex;box-sizing:border-box;padding:0px;top:0px;right:0px;width:16px;height:100%;border:none;background-color:unset;cursor:pointer;justify-content:center;align-items:center}.tab-config__new-button.sc-snk-tab-config{position:absolute;z-index:1;display:flex;box-sizing:border-box;padding:0px;top:0px;right:0px;height:100%;border:none;background-color:unset;cursor:pointer;justify-content:center;align-items:center}.tab-config__new-button.sc-snk-tab-config ez-icon.sc-snk-tab-config{--ez-icon--color:var(--snk-tab-config__new-button-icon--color)}.tab-config__backward-button.sc-snk-tab-config{left:0px;box-shadow:10px 10px 5px 5px white;background:white}.tab-config__forward-button.sc-snk-tab-config{box-shadow:10px 10px 5px 20px white;background:white}.tab-config__forward-button.sc-snk-tab-config::after,.tab-config__backward-button.sc-snk-tab-config::after{content:\'\';display:flex;width:10px;height:16px;background-color:var(--snk-tab-config__forward-button--background-color)}.tab-config__forward-button.sc-snk-tab-config::after{-webkit-mask-image:var(--snk-tab-config--forward-icon);mask-image:var(--snk-tab-config--forward-icon)}.tab-config__backward-button.sc-snk-tab-config::after{-webkit-mask-image:var(--snk-tab-config--backward-icon);mask-image:var(--snk-tab-config--backward-icon)}.tab-config__forward-button.sc-snk-tab-config:hover::after,.tab-config__backward-button.sc-snk-tab-config:hover::after{background-color:var(--snk-tab-config__forward-button-hover--background-color)}.tab-config__new-button.sc-snk-tab-config:hover ez-icon.sc-snk-tab-config{--ez-icon--color:var(--snk-tab-config__forward-button-hover--background-color)}.tab-config__hidden.sc-snk-tab-config{display:none}.tab-config__scroll.sc-snk-tab-config::-webkit-scrollbar{display:none}.tab-config__left-icon.sc-snk-tab-config{padding-right:var(--snk-tab-config__left-icon--padding-right);--ez-icon--color:var(--snk-tab-config__left-icon--color)}.tab-config__left-icon--eye-off.sc-snk-tab-config{--ez-icon--color:var(--snk-tab-config__left-icon--color)}.tab-config__right-icon.sc-snk-tab-config{visibility:hidden;padding-left:var(--snk-tab-config__left-icon--padding-right)}.tab-config__tab.sc-snk-tab-config:hover .tab-config__right-icon.sc-snk-tab-config{visibility:visible}.tab-config__tab--is-active.sc-snk-tab-config .tab-config__right-icon.sc-snk-tab-config{visibility:visible;--ez-icon--color:var(--snk-tab-config__tab-is-active--color)}.tab-config__tab.sc-snk-tab-config:hover .tab-config__right-icon.sc-snk-tab-config{--ez-icon--color:var(--snk-tab-config__tab-hover--color)}.tab-config__tab--is-active.sc-snk-tab-config:hover .tab-config__right-icon.sc-snk-tab-config{--ez-icon--color:var(--snk-tab-config__tab-is-active--color)}.tab-config__actions-button.sc-snk-tab-config{--ez-actions-button__btn-action--min-width:100px;visibility:hidden;opacity:0;transition:visibility 1s linear, opacity 0.3s linear}.tab-config__tab.sc-snk-tab-config:hover .tab-config__actions-button.sc-snk-tab-config{visibility:visible;opacity:1;transition:visibility 0.2s linear, opacity 0.10s linear}[data-draggable-element].sc-snk-tab-config{cursor:grab}.tab-config__tab-label-disabled.sc-snk-tab-config{color:var(--snk-tab-config__tab-label-disabled--color)}.tab-config__slot.sc-snk-tab-config{margin-left:var(--snk-tab-config__slot--margin-left)}';export{h as snk_tab_config}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{r as t,h as s,g as e}from"./p-b9667fbe.js";import{ElementIDUtils as i,ApplicationContext as r}from"@sankhyalabs/core";import{F as o}from"./p-9dd2b8cb.js";const h=class{constructor(s){t(this,s),this.config=void 0,this.value=void 0}ezChangeListener(t){this.value=this._searchInput.value}componentDidLoad(){this._element&&i.addIDInfo(this._element,"filterContentEditor")}doSearch(t,s){const e=r.getContextValue("__SNK__APPLICATION__");return new Promise(((i,r)=>{e.executePreparedSearch(t,s,this.config.props.searchContext).then((t=>{i(t)})).catch((t=>{r(t)}))}))}async show(){this._searchInput.setFocus()}render(){if(this.config&&this.config.type===o.SEARCH)return s("ez-search",{id:this.config.id,suppressEmptyOption:!0,value:this.config.value,label:this.config.label,ref:t=>this._searchInput=t,optionLoader:({mode:t,argument:s})=>this.doSearch(t,s)})}get _element(){return e(this)}};export{h as snk_filter_search}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{r as t,h as e,g as s}from"./p-b9667fbe.js";import{ElementIDUtils as i}from"@sankhyalabs/core";import{F as r}from"./p-9dd2b8cb.js";const n=class{constructor(e){t(this,e),this.config=void 0,this.value=void 0}ezChangeListener(){const t=this._startDate.value,e=this._endDate.value;this.value=t||e?{start:t,end:e}:void 0}componentDidLoad(){this._element&&i.addIDInfo(this._element,"filterContentEditor")}getDate(t){const e=this.value?this.value[t]:null;if(e instanceof Date)return e;if("string"==typeof e){let t=new Date(e);return t.setMinutes(t.getMinutes()+t.getTimezoneOffset()),t}return null}async show(){this._startDate.setFocus()}render(){if(this.config&&this.config.type===r.PERIOD)return e("div",{class:"ez-col ez-col--nowrap"},e("ez-date-input",{id:`${this.config.id}_start`,label:this.config.label,ref:t=>this._startDate=t,value:this.getDate("start")}),e("label",{class:"ez-text ez-text--medium ez-text--primary ez-margin--medium"},"até"),e("ez-date-input",{id:`${this.config.id}_end`,label:this.config.label,ref:t=>this._endDate=t,value:this.getDate("end")}))}get _element(){return s(this)}};export{n as snk_filter_period}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{h as e}from"./p-b9667fbe.js";import{P as t}from"./p-5534e08c.js";import{s as n}from"./p-98f7f796.js";var a,r,s;!function(e){e.PREVIOUS="PREVIOUS",e.NEXT="NEXT",e.REFRESH="REFRESH",e.UPDATE="UPDATE",e.CLONE="CLONE",e.REMOVE="REMOVE",e.INSERT="INSERT",e.CANCEL="CANCEL",e.SAVE="SAVE",e.GRID_MODE="GRID_MODE",e.FORM_MODE="FORM_MODE",e.MORE_OPTIONS="MORE_OPTIONS",e.DIVIDER="DIVIDER",e.CONFIGURATOR="CONFIGURATOR",e.DATA_EXPORTER="DATA_EXPORTER"}(a||(a={})),function(e){e.UPDATE="UPDATE",e.CLONE="CLONE",e.REMOVE="REMOVE",e.INSERT="INSERT",e.CONFIGURATOR="CONFIGURATOR"}(r||(r={})),function(e){e.CONFIGURATOR="CONFIGURATOR"}(s||(s={}));const i=(e,t,n,a,r)=>{const{hint:s,text:i,iconName:c}=e;return c?i?d(c,e.name,t,n,s,i,a,r):l(c,e.name,t,n,s,a,r):o(e.name,t,n,i,s,a,r)},c=(r,s,i,c,u,m,E,R,O)=>{var v;const b=c(r);switch(r){case a.PREVIOUS:return l("chevron-left",r,s,i,b,u,m);case a.NEXT:return l("chevron-right",r,s,i,b,u,m);case a.REFRESH:return l("sync",r,s,i,b,u,m);case a.UPDATE:return l("edit",r,s,i,b,u,m);case a.CLONE:return l("copy",r,s,i,b,u,m);case a.REMOVE:return l("delete",r,s,i,b,u,m);case a.INSERT:return O===t.PRIMARY?d("plus",r,s,i,b,b,u,m):l("plus",r,s,i,b,u,m);case a.CANCEL:return o(r,s,i,b,b,u,m);case a.SAVE:return O===t.PRIMARY?d("save",r,s,i,b,b,u,m):l("save",r,s,i,b,u,m);case a.GRID_MODE:return l("table",r,s,i,b,u,m);case a.FORM_MODE:return l("list",r,s,i,b,u,m);case a.CONFIGURATOR:return l("settings-inverted",r,s,i,b,u,m);case a.MORE_OPTIONS:return function(t,n,a,r,s,i,c){return c&&c.length>0?e("ez-actions-button",{title:r,size:"small","data-element-id":a,arrowActive:!0,class:n,enabled:i(t),onEzAction:e=>s(e.detail.value),actions:c}):void 0}(r,s,i,b,u,m,E);case a.DIVIDER:return e("hr",{class:"ez-divider-vertical ez-divider--dark ez-margin-horizontal--medium","data-taskbar-divider":!0});case a.DATA_EXPORTER:const c=null===(v=n.get("exporterProviders"))||void 0===v?void 0:v[R];return e("snk-data-exporter",{class:s,provider:c,"data-element-id":i})}};function o(t,n,a,r,s,i,c){return e("ez-button",{title:s,label:r,size:"small",class:n,"data-element-id":a,enabled:c(t),onClick:()=>i(t)})}function l(t,n,a,r,s,i,c){return e("ez-button",{name:t,title:s,mode:"icon",size:"small",class:a,"data-element-id":r,iconName:t,enabled:c(n),onClick:()=>i(n)})}function d(t,n,a,r,s,i,c,o){return e("ez-button",{name:t,title:i,label:s,size:"small",class:a,"data-element-id":r,enabled:o(n),onClick:()=>c(n)},e("ez-icon",{class:"ez-padding-right--small",slot:"leftIcon",iconName:t}))}export{r as A,a as T,s as V,i as a,c as b}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{r as t,h as s,H as i,g as e}from"./p-b9667fbe.js";import{ElementIDUtils as h}from"@sankhyalabs/core";import{F as r}from"./p-9dd2b8cb.js";const o=class{constructor(s){t(this,s),this.value=void 0,this.config=void 0}isSelected(t){return null==this.value||this.value===t}ezChangeListener(t){t.detail||this.assertCheckedOption(t.target),this.updateValue()}componentDidLoad(){this._element&&h.addIDInfo(this._element,"filterContentEditor")}assertCheckedOption(t){t===this._checkOne?this._checkTwo.value=!0:this._checkOne.value=!0}updateValue(){if(this._checkOne.value&&this._checkTwo.value)this.value=void 0;else{const[t,s]=this.config.props.options;this.value=this._checkOne.value?t.name:s.name}}async show(){this._checkOne.setFocus()}render(){if(!this.config||this.config.type!==r.BINARY_SELECT)return;const[t,e]=this.config.props.options;return s(i,null,s("ez-check",{id:`${this.config.id}_${t.name||"option1"}`,label:t.label,class:"sc-snk-filter-bar editor__ez-check",ref:t=>this._checkOne=t,value:this.isSelected(t.name)}),s("ez-check",{id:`${this.config.id}_${e.name||"option2"}`,label:e.label,class:"sc-snk-filter-bar editor__ez-check",ref:t=>this._checkTwo=t,value:this.isSelected(e.name)}))}get _element(){return e(this)}};export{o as snk_filter_binary_select}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{r as i,c as e,h as t,H as l,g as s}from"./p-b9667fbe.js";import{UserInterface as n,ObjectUtils as o,StringUtils as a,ApplicationContext as d,ElementIDUtils as r}from"@sankhyalabs/core";import{DataType as u,getConvertedValue as h}from"@sankhyalabs/core/dist/dataunit/metadata/DataType";import{CheckMode as c}from"@sankhyalabs/ezui/dist/collection/utils";import{V as v,D as p,a as b}from"./p-b4093344.js";const g=class{constructor(t){i(this,t),this.configOptionsChanged=e(this,"configOptionsChanged",7),this._defaultType=void 0,this.fieldConfig={},this.idConfig=void 0,this.dataUnit=void 0}onConfigDefault(i){null!=i&&(this._defaultType=i,this.fieldConfig.defaultValue={type:this._defaultType},this.configOptionsChanged.emit(this.fieldConfig))}buildOptions(){var i,e,t;let l=null===(t=null===(i=this.dataUnit)||void 0===i?void 0:i.getField(null===(e=this.fieldConfig)||void 0===e?void 0:e.name))||void 0===t?void 0:t.userInterface;return l===n.SEARCH&&(l=n.INTEGERNUMBER),v.UserInterface[l]}enabledValueDefault(){var i,e,t;const l=null===(i=this.dataUnit)||void 0===i?void 0:i.getField(null===(e=this.fieldConfig)||void 0===e?void 0:e.name),s=null===(t=null==l?void 0:l.properties)||void 0===t?void 0:t.allowDefault,o=v.UserInterface.hasOwnProperty(null==l?void 0:l.userInterface)||(null==l?void 0:l.userInterface)===n.SEARCH;return!(null!=s&&"true"!==s||!o)}isAllowDefault(){var i,e;const t=null===(e=null===(i=this._fieldProperties)||void 0===i?void 0:i.properties)||void 0===e?void 0:e.allowDefault;return null==t||"true"===t}loadDefaultValue(){var i;null==this.fieldConfig?(this._defaultType=p.fixed,this.fieldConfig={defaultValue:{type:this._defaultType}}):null==(null===(i=this.fieldConfig.defaultValue)||void 0===i?void 0:i.type)?(this._defaultType=p.fixed,this.fieldConfig.defaultValue={type:this._defaultType}):this._defaultType=this.fieldConfig.defaultValue.type}getFieldProperties(i){var e;if(null!=i)return null===(e=this.dataUnit)||void 0===e?void 0:e.getField(i)}getMessage(i,e){return this._application.messagesBuilder.getMessage(i,e)}getDefaultType(){var i;return null!==(i=this.fieldConfig.defaultValue.type)&&void 0!==i?i:p.fixed}getEnabledByProperty(i){const e=this._fieldProperties;return null==e||!0!==e[i]}getValueByProperty(i){const e=this._fieldProperties;return null!=e&&!0===e[i]||this.fieldConfig[i]}getValidatedValue(i){var e,t;if(null==i)return;const l=null===(e=this.dataUnit)||void 0===e?void 0:e.getField(null===(t=this.fieldConfig)||void 0===t?void 0:t.name),s=null==l?void 0:l.dataType;if(null==s)return;const n=null!=(null==i?void 0:i.waitmessage)?void 0:s!==u.OBJECT&&s!==u.DATE&&"object"==typeof i?i.value:i;return s===u.OBJECT?JSON.stringify(n):n}buildInputDefault({value:i,enabled:e,label:l,name:s,required:a,userInterface:d},r,u){let h,c=0,v=0;const p=null==d||null==b[d]?b.DEFAULT:b[d];if(d===n.OPTIONSELECTOR){const i=null==r?void 0:r.options;if("string"==typeof i){const e=o.stringToObject(i);h=Object.keys(e).map((i=>({value:i,label:e[i]})))}else h=i}else d===n.DECIMALNUMBER&&(c=Number((null==r?void 0:r.precision)||2),v=Number((null==r?void 0:r.prettyPrecision)||c));return t(p,Object.assign({value:i,enabled:e,label:l,"data-field-name":s,key:s,onEzChange:i=>this.onChange(null==i?void 0:i.detail)},this.getConditionalAttributes(d,a,h,c,v,u)))}getConditionalAttributes(i,e,t,l,s,o){switch(i){case n.SEARCH:return{suppressEmptyOption:e,optionLoader:i=>this.onSearch(i)};case n.OPTIONSELECTOR:return{suppressEmptyOption:e,options:t};case n.CHECKBOX:case n.SWITCH:return{mode:o};case n.INTEGERNUMBER:case n.DECIMALNUMBER:return{precision:l,prettyPrecision:s,onEzStartChange:i=>this.onChange(null==i?void 0:i.detail)};case n.DATE:case n.DATETIME:case n.TIME:return{onEzStartChange:i=>this.onChange(null==i?void 0:i.detail)};default:return{}}}onChange(i){this.fieldConfig.defaultValue.value=this.getValidatedValue(i),this.configOptionsChanged.emit(this.fieldConfig)}onSearch(i){if(null!=this._application&&null!=this.fieldConfig)return this._application.executeSearch(i,this.fieldConfig.name,this.dataUnit)}buildField(i,e){const{name:t,label:l,readOnly:s,required:o,defaultValue:d}=e,{userInterface:r,properties:u}=i;let v,p=a.getBooleanValue(null==u?void 0:u.allowDefault,!s);r===n.FILE&&(p=!1),p&&(v=null==d?void 0:d.value,null!=v&&(v=h(null==i?void 0:i.dataType,v)));const b={value:v,enabled:p,label:l,name:t,required:o,userInterface:r};switch(r){case n.SWITCH:return this.buildInputDefault(b,void 0,c.SWITCH);case n.CHECKBOX:return this.buildInputDefault(b,void 0,c.REGULAR);case n.OPTIONSELECTOR:case n.DECIMALNUMBER:return this.buildInputDefault(b,u);default:return this.buildInputDefault(b)}}componentWillLoad(){var i;this.loadDefaultValue(),this._application=d.getContextValue("__SNK__APPLICATION__"),this._fieldProperties=this.getFieldProperties(null===(i=this.fieldConfig)||void 0===i?void 0:i.name)}componentDidLoad(){r.addIDInfo(this._element,this.fieldConfig.name)}render(){var i,e;return t(l,null,t("div",{id:this.idConfig},t("div",{class:"ez-row ez-padding--medium"},t("div",{class:"ez-col ez-col--sd-12 ez-col--tb-4 ez-padding--small"},t("ez-text-input",{label:this.getMessage("snkConfigOptions.label.nameField"),value:null===(i=this.fieldConfig)||void 0===i?void 0:i.label,onEzChange:i=>{this.fieldConfig.label=i.detail,this.configOptionsChanged.emit(this.fieldConfig)}})),t("div",{class:"ez-col ez-col--sd-12 ez-col--tb-4 ez-padding--small"},t("ez-combo-box",{label:this.getMessage("snkConfigOptions.label.typeValueDefault"),suppressEmptyOption:!0,enabled:this.enabledValueDefault(),onEzChange:i=>{var e;return this.onConfigDefault(null===(e=i.detail)||void 0===e?void 0:e.value)},value:this.getDefaultType()},t("option",{value:p.fixed},this.getMessage("snkConfigOptions.options.valueFixed")),t("option",{value:p.variable},this.getMessage("snkConfigOptions.options.variable")))),t("div",{class:"ez-col ez-col--sd-12 ez-col--tb-4 ez-padding--small"},this._defaultType===p.variable?t("ez-combo-box",{label:this.getMessage("snkConfigOptions.label.valueDefault"),enabled:this.isAllowDefault(),onEzChange:i=>{var e;this.fieldConfig.defaultValue.value=null===(e=i.detail)||void 0===e?void 0:e.value,this.configOptionsChanged.emit(this.fieldConfig)},value:this.fieldConfig.defaultValue.value,options:this.buildOptions()}):(null===(e=this._fieldProperties)||void 0===e?void 0:e.userInterface)&&this.buildField(this._fieldProperties,this.fieldConfig))),t("div",{class:"ez-row ez-padding--medium config-options__switch-row"},t("div",{class:"ez-col ez-col--sd-12 ez-col--tb-4 ez-padding--small"},t("ez-check",{mode:c.SWITCH,label:this.getMessage("snkConfigOptions.label.clearDuplicate"),value:this.fieldConfig.cleanOnCopy,onEzChange:i=>{this.fieldConfig.cleanOnCopy=i.detail,this.configOptionsChanged.emit(this.fieldConfig)}})),t("div",{class:"ez-col ez-col--sd-12 ez-col--tb-4 ez-padding--small"},t("ez-check",{mode:c.SWITCH,label:this.getMessage("snkConfigOptions.label.requiredField"),enabled:this.getEnabledByProperty("required"),value:this.getValueByProperty("required"),onEzChange:i=>{this.fieldConfig.required=i.detail,this.configOptionsChanged.emit(this.fieldConfig)}})),t("div",{class:"ez-col ez-col--sd-12 ez-col--tb-4 ez-padding--small"},t("ez-check",{mode:c.SWITCH,label:this.getMessage("snkConfigOptions.label.protectedField"),enabled:this.getEnabledByProperty("readOnly"),value:this.getValueByProperty("readOnly"),onEzChange:i=>{this.fieldConfig.readOnly=i.detail,this.configOptionsChanged.emit(this.fieldConfig)}})))))}get _element(){return s(this)}};g.style=".sc-snk-config-options-h{--snk-config-options--border:2px solid var(--color--secondary-200, #D2D3DA);width:100%;border-radius:15px;border:var(--snk-config-options--border)}.config-options__switch-row.sc-snk-config-options{margin-top:-30px}";export{g as snk_config_options}
|