@sankhyalabs/sankhyablocks 4.6.2 → 4.7.0
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/loader.cjs.js +1 -1
- package/dist/cjs/sankhyablocks.cjs.js +1 -1
- package/dist/cjs/snk-application.cjs.entry.js +70 -6
- package/dist/cjs/snk-detail-view.cjs.entry.js +10 -1
- package/dist/collection/components/snk-application/snk-application.js +48 -1
- package/dist/collection/components/snk-crud/subcomponents/snk-detail-view.js +15 -1
- package/dist/collection/lib/http/data-fetcher/fetchers/pesquisa-fetcher.js +59 -5
- package/dist/components/snk-application2.js +72 -7
- package/dist/components/snk-detail-view2.js +11 -1
- package/dist/esm/loader.js +1 -1
- package/dist/esm/sankhyablocks.js +1 -1
- package/dist/esm/snk-application.entry.js +70 -6
- package/dist/esm/snk-detail-view.entry.js +10 -1
- package/dist/sankhyablocks/{p-0d9f624f.entry.js → p-2eab10a4.entry.js} +8 -8
- package/dist/sankhyablocks/p-5afa5b01.entry.js +1 -0
- package/dist/sankhyablocks/sankhyablocks.esm.js +1 -1
- package/dist/types/components/snk-application/snk-application.d.ts +5 -1
- package/dist/types/components/snk-crud/subcomponents/snk-detail-view.d.ts +1 -0
- package/dist/types/components.d.ts +5 -1
- package/dist/types/lib/http/data-fetcher/fetchers/pesquisa-fetcher.d.ts +15 -0
- package/package.json +1 -1
- package/dist/sankhyablocks/p-a61d2aa0.entry.js +0 -1
@@ -1,14 +1,14 @@
|
|
1
|
-
import{r as t,c as e,h as s,g as
|
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 l,StringUtils as u,DataUnitStorage as h,ChangeOperation as d,DateUtils as p,DependencyType as m,ElementIDUtils as f,ApplicationContext as y,ErrorTracking as v}from"@sankhyalabs/core";import{d as w,D as _,U as g}from"./p-0c11c980.js";import{ApplicationUtils as I}from"@sankhyalabs/ezui/dist/collection/utils";import{S as P}from"./p-28c800b9.js";import{G as $,C as S}from"./p-3c4823fc.js";import{R as D}from"./p-9f98fc3c.js";import"./p-112455b1.js";class b{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._searchListenersByDataUnit=new Map,this.buldTemplates()}buldTemplates(){this._templateByQuery.set("search",w.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,
|
6
|
+
}`)}loadSearchOptions(t,e,s,i){const r=(null==e?void 0:e.toString().trim())||void 0;e=isNaN(Number(r))&&r?`%${r}`:r;const n=this.applySearchListener("beforeSearch",t,e,s,i),a={argument:(null==n?void 0:n.argument)||e,entityName:t,criteria:(null==n?void 0:n.criteria)||s,options:(null==n?void 0:n.searchOptions)||i};return new Promise(((t,e)=>{_.get().callGraphQL({values:a,query:this._templateByQuery.get("search")}).then((e=>{t(e)})).catch((t=>{e(t)}))}))}loadAdvancedSearch(t,e,s,i){var r,n,a;const o=this.applySearchListener("beforeSearch",t,e,s,i),l={argument:(null==o?void 0:o.argument)||e,criteria:(null==o?void 0:o.criteria)||s,searchOptions:(null==o?void 0:o.searchOptions)||i},u={query:{$:null===(r=l.criteria)||void 0===r?void 0:r.expression}};(null===(n=l.criteria)||void 0===n?void 0:n.params.length)>0&&(u.params={param:l.criteria.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 h={serviceName:"PesquisaSP.getSuggestion",requestBody:{criteria:Object.assign({entityName:t,compacted:!1,ignoreEntityCriteria:!1,limit:this._defaultPageSize,query:{$:l.argument},orderByDesc:!1,externalCriteria:u,localEntityName:null===(a=l.searchOptions)||void 0===a?void 0:a.rootEntity},{options:null!=i?{pkFieldName:i.codeFieldName,label:i.descriptionFieldName,fieldName:i.codeFieldName,useDescriptionOptions:!1,enableRowsCounter:!0}:void 0}),clientEventList:{clientEvent:[]}}};return new Promise(((t,e)=>{_.get().callServiceBroker("PesquisaSP.getSuggestion",JSON.stringify(h)).then((e=>t(e))).catch((t=>e(t)))}))}addSearchListener(t,e,s){var i;const r=this._searchListenersByDataUnit.get(e)||[],n=r.find((e=>e.entity===t));if(n){for(const t of Object.keys(s))if(t in n.listener){if((null===(i=n.listener[t])||void 0===i?void 0:i.toString())===s[t].toString())continue;n.listener[t]=s[t]}}else this._searchListenersByDataUnit.set(e,[...r,{entity:t,listener:s}]);return()=>{const s=r.filter((e=>e.entity!==t));s.length?this._searchListenersByDataUnit.set(e,s):this._searchListenersByDataUnit.delete(e)}}applySearchListener(t,e,s,i,r){var n;const a=null==r?void 0:r.dataUnitId;if(!a)return;const o=null===(n=this._searchListenersByDataUnit.get(a))||void 0===n?void 0:n.find((({entity:t})=>t===e));if(!o)return;const{listener:c}=o;return t in c?c[t]({argument:s,criteria:i,searchOptions:r}):void 0}}function C(){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(C=function(){return t})()}const E=N;function N(t,e){const s=C();return(N=function(t){return s[t-=392]})(t,e)}!function(){const t=N,e=C();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 T=E(396);class O{constructor(){this.templateByQuery=new Map,this.buldTemplates()}buldTemplates(){this.templateByQuery.set("fetchTotals",w.gql`query($filters: [InputFilter!] $name: String!) {
|
7
7
|
$queryAlias$: fetchTotals(name: $name, filters: $filters ){
|
8
8
|
name
|
9
9
|
value
|
10
10
|
}
|
11
|
-
}`)}async getTotals(t,e,s){let
|
11
|
+
}`)}async getTotals(t,e,s){let i={name:`totals://${t}/${e}`,filters:s};return _.get().callGraphQL({values:i,query:this.templateByQuery.get("fetchTotals")})}fetchTotals(t,e,s=[]){return new Promise(((i,r)=>{this.getTotals(t,e,s).then((t=>{if(t.length>0){const e=new Map;t.forEach((t=>{e.set(t.name,parseFloat(t.value))})),i(e)}else r("Não foi possível recuperar os totalizadores")})).catch((t=>{r(t)}))}))}}var q;class U{constructor(){this.templateByQuery=new Map,this._loadDataTimeout={},this.buldTemplates()}buldTemplates(){this.templateByQuery.set("fetchDataUnit",w.gql`query($name: String!) {
|
12
12
|
$queryAlias$: fetchDataUnit(name: $name){
|
13
13
|
name
|
14
14
|
fields{
|
@@ -41,7 +41,7 @@ import{r as t,c as e,h as s,g as r}from"./p-b9667fbe.js";import{WaitingChangeExc
|
|
41
41
|
}
|
42
42
|
}
|
43
43
|
}
|
44
|
-
}`),this.templateByQuery.set("fetchData",
|
44
|
+
}`),this.templateByQuery.set("fetchData",w.gql`query($dataunit: String! $limit: Int $offset:Int $filters: [InputFilter!] $sort: [InputSort!] $parentRecordId: String) {
|
45
45
|
$queryAlias$: fetchDataUnit(name: $dataunit){
|
46
46
|
data(limit: $limit offset: $offset filters: $filters sort: $sort parentRecordId: $parentRecordId){
|
47
47
|
limit
|
@@ -58,7 +58,7 @@ import{r as t,c as e,h as s,g as r}from"./p-b9667fbe.js";import{WaitingChangeExc
|
|
58
58
|
}
|
59
59
|
}
|
60
60
|
}
|
61
|
-
}`),this.templateByQuery.set("saveData",
|
61
|
+
}`),this.templateByQuery.set("saveData",w.gql`mutation($changes: [InputBatchChange!]!) {
|
62
62
|
$queryAlias$: batchOperationDataUnit(changes: $changes){
|
63
63
|
oldId
|
64
64
|
id
|
@@ -69,7 +69,7 @@ import{r as t,c as e,h as s,g as r}from"./p-b9667fbe.js";import{WaitingChangeExc
|
|
69
69
|
value
|
70
70
|
}
|
71
71
|
}
|
72
|
-
}`),this.templateByQuery.set("fetchDataRecord",
|
72
|
+
}`),this.templateByQuery.set("fetchDataRecord",w.gql`query($dataunit: String! $recordID: [String!]) {
|
73
73
|
$queryAlias$: fetchDataUnit(name: $dataunit){
|
74
74
|
record(id: $recordID){
|
75
75
|
id
|
@@ -80,9 +80,9 @@ import{r as t,c as e,h as s,g as r}from"./p-b9667fbe.js";import{WaitingChangeExc
|
|
80
80
|
}
|
81
81
|
}
|
82
82
|
}
|
83
|
-
}`)}getDataUnit(t,e,s){const
|
83
|
+
}`)}getDataUnit(t,e,s){const i=null!=s?s.getChildDataunit(`dd://${t}/${e}`):new l(`dd://${t}/${e}`);return i.metadataLoader=t=>this.loadMetadata(t),i.dataLoader=(t,e)=>this.loadData(t,e),i.saveLoader=(t,e)=>this.saveData(i,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)=>{_.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:l,quickFilter:h}=e,d={dataunit:t.name,sort:n,filters:a};if(d.limit=o,d.offset=l,d.parentRecordId=e.parentRecordId,!u.isEmpty(null==h?void 0:h.term)){void 0===d.filter&&(d.filter=[]);const t={name:"__QUICK_FILTER__",expression:"__QUICK_FILTER__",params:[{name:"term",dataType:c.TEXT,value:h.term}]};(null===(r=null==h?void 0:h.fields)||void 0===r?void 0:r.length)>0&&t.params.push({name:"fields",dataType:c.OBJECT,value:h.fields}),d.filter.push(t)}_.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 l=[];o.forEach((e=>{const s={__record__id__:e.id,__record__label__:e.label};e.fields.forEach((({name:e,value:i})=>{s[e]=t.valueFromString(e,i)})),l.push(s)})),s({paginationInfo:c,records:l})})).catch((t=>{i(t)}))}))}saveData(t,e){const s=e.map((t=>{const{dataUnit:e,record:s,updatingFields:i,operation:r}=t,n=h.get(e);let a;i&&(a=Object.entries(i).map((([t,e])=>{const s=n.getField(t);return{fieldName:t,dataType:s?s.dataType:c.TEXT,value:n.valueToString(t,e)}})));const o={dataUnit:e,fields:a,operation:r,recordId:s.__record__id__};return t.sourceId&&(o.sourceId=t.sourceId),s.__parent__record__id__&&(o.parentRecordId=s.__parent__record__id__),o}));return new Promise(((e,i)=>{const r=s.map((t=>function(t,e){var s={};for(var i in t)Object.prototype.hasOwnProperty.call(t,i)&&e.indexOf(i)<0&&(s[i]=t[i]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols){var r=0;for(i=Object.getOwnPropertySymbols(t);r<i.length;r++)e.indexOf(i[r])<0&&Object.prototype.propertyIsEnumerable.call(t,i[r])&&(s[i[r]]=t[i[r]])}return s}(t,[])));_.get().callGraphQL({values:{changes:r},query:this.templateByQuery.get("saveData")}).then((s=>{const i=[];null==s||s.forEach((e=>{const s={__record__id__:e.id,__record__label__:e.label,__owner__dataunit__name__:e.ownerDataUnitName},r=h.get(s.__owner__dataunit__name__)||t;e.oldId&&(s.__old__id__=e.oldId),e.fields.forEach((({name:t,value:e})=>{var i;s[t]=(null===(i=null==r?void 0:r.valueFromString)||void 0===i?void 0:i.call(r,t,e))||e})),i.push(s)})),e(i)})).catch((t=>{i(t)}))}))}removeRecords(t,e){const s=e.map((e=>({dataUnit:t.name,operation:d.DELETE,recordId:e})));return new Promise(((t,i)=>{_.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)=>{_.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,__record__label__:e.label};e.fields.forEach((({name:e,value:i})=>{s[e]=t.valueFromString(e,i)})),i.push(s)})),s(i)})).catch((t=>{i(t)}))}))}}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===(q=window.workspace)||void 0===q?void 0:q.resourceID;class j{static webConnectionCaller(t,e,s){var i;null===(i=window.AppletCaller)||void 0===i||i.webConnectionCaller(t,e,s)}}class L{constructor(){this.templateByQuery=new Map,this.buldTemplates()}buldTemplates(){this.templateByQuery.set("fetchParam",w.gql`query($name: String!) {
|
84
84
|
$queryAlias$: fetchResource(name: $name){
|
85
85
|
name
|
86
86
|
resource
|
87
87
|
}
|
88
|
-
}`)}async getParam(t){const e=`param://application?params=${t}`;return _.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"S"===this.getValue(e)}async asDate(t){const e=await this.getParam(t);return p.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={}){if(Array.isArray(t)&&t.length>0&&(t=t[0]),u.isEmpty(t.resource))return"";try{const e=o.stringToObject(t.resource),[s]=Object.keys(e);return e[s]}catch(t){console.warn("Erro ao converter string JSON.")}}}const k=F;function F(t,e){const s=M();return(F=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=F,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{[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 B extends S{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(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={}));const H=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 J,this.messagesBuilder=void 0,this.configName=void 0}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 W(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((r=>{this.getAuthList(r).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((r=>{"1"===r?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)=>{_.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)=>{_.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=>{j.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(((r,i)=>{const n=this.getDuPromissesStack(e),a=n.length>0;if(n.push(new W(r,i)),!a){const r=this.dataUnitFetcher.getDataUnit(t,this.resourceID,s);r.loadMetadata().then((()=>{for(e&&this.updateDataunitCache(void 0,e,r);n.length>0;)n.pop().resolve(r)})).catch((t=>{for(;n.length>0;)n.pop().reject(t)}))}}))}async updateDataunitCache(t,e,s){t&&this._duCache.delete(t),this._duCache.set(e,s)}async getDataUnit(t,e,s){return new Promise(((r,i)=>{const n=this._duCache.get(e);n?r(n):this.createDataunit(t,e,s).then((t=>{r(t)})).catch((t=>i(t)))}))}async addClientEvent(t,e){return new Promise((s=>{_.addClientEvent(t,e),s()}))}async removeClientEvent(t){return new Promise((e=>{_.removeClientEvent(t),e()}))}async hasClientEvent(t){return new Promise((e=>{e(_.hasClientEvent(t))}))}async getResourceID(){return Promise.resolve(this.resourceID)}async getUserID(){return Promise.resolve(window.UID)}async alert(t,e,s,r){return I.alert(t,e,s,r)}async error(t,e,s,r){return I.error(t,e,s,r)}async success(t,e,s,r){return I.success(t,e,s,r)}async message(t,e,s,r){return I.message(t,e,s,r)}async confirm(t,e,s,r,i){return I.confirm(t,e,s,r,i)}async info(t,e){return I.info(t,e)}async loadGridConfig(t){return this.gridConfigFetcher.getConfig(t,this.resourceID)}async loadTotals(t,e,s){return this.totalsFetcher.fetchTotals(t,e,s)}async getAuthList(t){return await(new x).parseFromJSON(t)}get urlParams(){return this._urlParams||(this._urlParams=g.getQueryParams(location.search)),this._urlParams}get dataUnitFetcher(){return this._dataUnitFetcher||(this._dataUnitFetcher=new U),this._dataUnitFetcher}get gridConfigFetcher(){return this._gridConfigFetcher||(this._gridConfigFetcher=new $),this._gridConfigFetcher}get totalsFetcher(){return this._totalsFetcher||(this._totalsFetcher=new O),this._totalsFetcher}get pesquisaFetcher(){return this._pesquisaFetcher||(this._pesquisaFetcher=new A),this._pesquisaFetcher}get authFetcher(){return this._authFetcher||(this._authFetcher=new B),this._authFetcher}async executeSearch(t,e,s){const r=null==s?void 0:s.getField(e);if(r){const{mode:e,argument:i}=t,{ENTITYNAME:n,CODEFIELD:a,DESCRIPTIONFIELD:o,ROOTENTITY:l,DESCRIPTIONENTITY:u}=r.properties,h=r.dependencies;let d;const p={rootEntity:l,descriptionFieldName:o,codeFieldName:a,showInactives:!1};return null==h||h.filter((t=>t.masterFields)).forEach((t=>{var e;t.type===m.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),r=(null==e?void 0:e.dataType)||c.TEXT,i=s.getFieldValue(t);if(null==i)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:i,dataType:r}}))})})),this.executePreparedSearch(e,i,{entity:n,entityDescription:u,criteria:d,searchOptions:p})}}async executePreparedSearch(t,e,s){const{entity:r,entityDescription:i,criteria:n,searchOptions:a}=s;return"ADVANCED"===t?new Promise((t=>{const s=document.createElement("snk-pesquisa");s[f.DATA_ELEMENT_ID_ATTRIBUTE_NAME]=`entity_${r}`,s.argument=e,s.searchLoader=t=>this.pesquisaFetcher.loadAdvancedSearch(r,t,n,a),s.selectItem=e=>{t(e),this.clearPopUpTitle(),this.closePopUp()},this.setPopUpTitle(i),this.showPopUp(s)})):this.pesquisaFetcher.loadSearchOptions(r,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 b(this),this.messagesBuilder=new P,y.setContextValue("__EZUI__UPLOAD__ADD__URL__",`${g.getUrlBase()}/mge/upload/file`),y.setContextValue("__EZUI__SEARCH__OPTION__LOADER__",((t,e,s)=>this.executeSearch(t,e,s))),y.setContextValue("__EZUI__GRID_LICENSE__",T),w.init(),D.get()}connectedCallback(){y.setContextValue("__SNK__APPLICATION__",this),_.addRequestListener(this._requestListener)}disconnectedCallback(){_.removeRequestListener(this._requestListener)}componentDidLoad(){this.applicationLoading.emit(!0),window.requestAnimationFrame((()=>{this.applicationLoaded.emit(!0)})),f.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 r(this)}};class J{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 W{constructor(t,e){this.resolve=t,this.reject=e}}H.style=".sc-snk-application-h{display:flex;flex-direction:column;height:100%}";export{H as snk_application}
|
88
|
+
}`)}async getParam(t){const e=`param://application?params=${t}`;return _.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"S"===this.getValue(e)}async asDate(t){const e=await this.getParam(t);return p.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={}){if(Array.isArray(t)&&t.length>0&&(t=t[0]),u.isEmpty(t.resource))return"";try{const e=o.stringToObject(t.resource),[s]=Object.keys(e);return e[s]}catch(t){console.warn("Erro ao converter string JSON.")}}}const k=M;function M(t,e){const s=F();return(M=function(t){return s[t-=378]})(t,e)}function F(){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(F=function(){return t})()}!function(){const t=M,e=F();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{[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 B extends D{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(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={}));const H=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 J,this.messagesBuilder=void 0,this.configName=void 0}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 W(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)=>{_.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)=>{_.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=>{j.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 W(i,r)),!a){const i=this.dataUnitFetcher.getDataUnit(t,this.resourceID,s);i.loadMetadata().then((()=>{for(e&&this.updateDataunitCache(void 0,e,i);n.length>0;)n.pop().resolve(i)})).catch((t=>{for(;n.length>0;)n.pop().reject(t)}))}}))}async updateDataunitCache(t,e,s){t&&this._duCache.delete(t),this._duCache.set(e,s)}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 addClientEvent(t,e){return new Promise((s=>{_.addClientEvent(t,e),s()}))}async removeClientEvent(t){return new Promise((e=>{_.removeClientEvent(t),e()}))}async hasClientEvent(t){return new Promise((e=>{e(_.hasClientEvent(t))}))}async getResourceID(){return Promise.resolve(this.resourceID)}async getUserID(){return Promise.resolve(window.UID)}async alert(t,e,s,i){return I.alert(t,e,s,i)}async error(t,e,s,i){return I.error(t,e,s,i)}async success(t,e,s,i){return I.success(t,e,s,i)}async message(t,e,s,i){return I.message(t,e,s,i)}async confirm(t,e,s,i,r){return I.confirm(t,e,s,i,r)}async info(t,e){return I.info(t,e)}async loadGridConfig(t){return this.gridConfigFetcher.getConfig(t,this.resourceID)}async loadTotals(t,e,s){return this.totalsFetcher.fetchTotals(t,e,s)}async getAuthList(t){return await(new x).parseFromJSON(t)}get urlParams(){return this._urlParams||(this._urlParams=g.getQueryParams(location.search)),this._urlParams}get dataUnitFetcher(){return this._dataUnitFetcher||(this._dataUnitFetcher=new U),this._dataUnitFetcher}get gridConfigFetcher(){return this._gridConfigFetcher||(this._gridConfigFetcher=new $),this._gridConfigFetcher}get totalsFetcher(){return this._totalsFetcher||(this._totalsFetcher=new O),this._totalsFetcher}get pesquisaFetcher(){return this._pesquisaFetcher||(this._pesquisaFetcher=new A),this._pesquisaFetcher}get authFetcher(){return this._authFetcher||(this._authFetcher=new B),this._authFetcher}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:l,DESCRIPTIONENTITY:u}=i.properties,h=i.dependencies;let d;const p={rootEntity:l,descriptionFieldName:o,codeFieldName:a,showInactives:!1,dataUnitId:s.dataUnitId};return null==h||h.filter((t=>t.masterFields)).forEach((t=>{var e;t.type===m.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:p})}}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[f.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)}addSearchListener(t,e,s){return new Promise((i=>{i(this.pesquisaFetcher.addSearchListener(t,e.dataUnitId,s))}))}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 b(this),this.messagesBuilder=new P,y.setContextValue("__EZUI__UPLOAD__ADD__URL__",`${g.getUrlBase()}/mge/upload/file`),y.setContextValue("__EZUI__SEARCH__OPTION__LOADER__",((t,e,s)=>this.executeSearch(t,e,s))),y.setContextValue("__EZUI__GRID_LICENSE__",T),v.init(),S.get()}connectedCallback(){y.setContextValue("__SNK__APPLICATION__",this),_.addRequestListener(this._requestListener)}disconnectedCallback(){_.removeRequestListener(this._requestListener)}componentDidLoad(){this.applicationLoading.emit(!0),window.requestAnimationFrame((()=>{this.applicationLoaded.emit(!0)})),f.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 J{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 W{constructor(t,e){this.resolve=t,this.reject=e}}H.style=".sc-snk-application-h{display:flex;flex-direction:column;height:100%}";export{H as snk_application}
|
@@ -0,0 +1 @@
|
|
1
|
+
import{r as t,c as i,f as s,h as e,H as a}from"./p-b9667fbe.js";import{S as o}from"./p-a6258eed.js";import{FormMetadata as h,buildFormMetadata as r}from"@sankhyalabs/ezui/dist/collection/utils/form";import"./p-0c11c980.js";import"@sankhyalabs/core";import{P as n}from"./p-f132e371.js";import{T as d}from"./p-74724fa7.js";import{c as l}from"./p-f587a454.js";import{S as c}from"./p-e1dbaecb.js";import"./p-3c4823fc.js";import"./p-9f98fc3c.js";import"./p-112455b1.js";import"./p-98f7f796.js";import"./p-c2beb95c.js";const u=class{constructor(s){t(this,s),this.snkDetailGuidesChange=i(this,"snkDetailGuidesChange",7),this.snkSwitchGuide=i(this,"snkSwitchGuide",7),this._disabledButtons=void 0,this.formConfigManager=void 0,this.dataUnitName=void 0,this.guideItemPath=void 0,this.entityName=void 0,this.label=void 0,this.dataUnit=void 0,this.selectedForm=void 0,this.dataState=void 0}observerDataState(t,i){var s;const e=!(null==i?void 0:i.insertionMode)&&(null==t?void 0:t.insertionMode),a=(null==i?void 0:i.insertionMode)&&!(null==t?void 0:t.insertionMode);if((e||a)&&this.loadMetadata(),null==this._formMetadata)return;const o=null===(s=this.dataState)||void 0===s?void 0:s.selectedRecord,h=this.getNewGuideItem(o);this.snkDetailGuidesChange.emit({item:h,recordId:null==o?void 0:o.__record__id__}),e&&setTimeout((()=>{this.changeViewMode(l.FORM)}),0),a&&this.changeViewMode(l.GRID);const r=[];this.dataState.hasPrevious||r.push(d.PREVIOUS),this.dataState.hasNext||r.push(d.NEXT),this._disabledButtons=r}async changeViewMode(t){this.emitSwitchEvent(t)}async configGrid(){this._snkGrid&&this._snkGrid.showConfig()}async showUp(){this._snkFormView&&this._snkFormView.showUp(),this._snkGrid&&this._snkGrid.scrollIntoView({behavior:"smooth",block:"start"})}onContentCardChanged(t){c.updateContentCard(t.detail.formName,t.detail.cardConfig,t.detail.propertyChanged,this.formConfigManager).then((()=>s(this))),t.stopPropagation()}updateLabel(){const t=this.guideItemPath?this.guideItemPath.length:0;if(t>0){const i=t>0?this.guideItemPath.map((t=>t.label)):void 0;this.label=i.pop(),this._levelPath=i.length>0?i.join(" / "):void 0,this._guideId=this.guideItemPath[t-1].id}else this.label="",this._levelPath=void 0,this._guideId=void 0}getNewGuideItem(t){if(null==t)return;const i=this.dataUnit.isNewRecord(t.__record__id__),s=Array.from(this._formMetadata.getAllSheets().values()).map((t=>{const{name:s,label:e}=t,a=null!=h.getDetailName(s.split("::").pop()),o=a&&i;return{id:a?this.getChildGuideId(s):this.getFormGuideId(s),label:e,disabled:o,tooltip:o?"Finalize o cadastro para ter acesso a esta guia.":void 0}})),e=s.shift();return e.label=i?"Novo Registro":t.__record__label__,e.children=s,e.expanded=!0,e}getFormGuideId(t){var i;if(!t){if(null==(null===(i=this.dataState)||void 0===i?void 0:i.selectedRecord))return;const s=Array.from(this._formMetadata.getAllSheets().keys());if(!s||0==s.length)return;t=s[0]}return`${this.stripFormPattern(this._guideId)}__FORM:${t}`}getChildGuideId(t){return`${this.stripFormPattern(this._guideId)}::${t}`}stripFormPattern(t){return t.replace(u.REGEX_FORM_ID,"")}loadMetadata(){var t;if(!this.dataUnit)return;if(!this.formConfigManager.isLoaded)return;const i=this.formConfigManager.getConfig(null===(t=this.dataState)||void 0===t?void 0:t.insertionMode,this.dataUnit);this._formMetadata=r(null==i||0===i.fields.length?void 0:i,this.dataUnit,!0)}dataUnitReadyHandler(t){this.dataUnit=t.detail,this.loadMetadata()}updateViewStack(t){t.show(this.selectedForm?1:0)}getFormFields(){return this.selectedForm&&this._formMetadata?this._formMetadata.getSheet(this.selectedForm).fields:[]}emitSwitchEvent(t){const i=t===l.GRID?this.stripFormPattern(this._guideId):this.getFormGuideId();i&&this.snkSwitchGuide.emit(i)}executeActionHandler(t){t.detail===d.GRID_MODE&&(this.emitSwitchEvent(l.GRID),t.stopPropagation()),t.detail===d.FORM_MODE&&(this.emitSwitchEvent(l.FORM),t.stopPropagation())}componentWillLoad(){this._configName=`dynaform.${this.entityName}`,this.formConfigManager=new o(this._configName,(()=>this.loadMetadata())),this.formConfigManager.loadConfig()}render(){return this.updateLabel(),e(a,null,e("snk-data-unit",{dataUnitName:`${this.dataUnitName}`,onDataUnitReady:t=>this.dataUnitReadyHandler(t),entityName:this.entityName,onDataStateChange:t=>this.dataState=t.detail},e("ez-view-stack",{ref:t=>this.updateViewStack(t)},e("stack-item",null,e("div",{class:"ez-box ez-box--shadow grid-container"},e("div",{class:"ez-flex ez-size-width--full ez-padding--large detail-header"},e("div",{class:"ez-flex ez-text ez-text--bold ez-flex--justify-start ez-flex--align-items-center"},this._levelPath?e("span",{class:"level-path"},this._levelPath+" /"):void 0,this.label)),e("snk-grid",{class:"ez-size-width--full ez-size-height--full",ref:t=>this._snkGrid=t,configName:this._configName,onGridDoubleClick:()=>this.emitSwitchEvent(l.FORM),onActionClick:t=>this.executeActionHandler(t),presentationMode:n.SECONDARY}))),e("stack-item",null,e("snk-form-view",{ref:t=>this._snkFormView=t,canExpand:!1,canFix:!1,name:this.selectedForm,formMetadata:this._formMetadata,dataUnit:this.dataUnit,fields:this.getFormFields(),label:this.label,levelPath:this._levelPath},e("snk-taskbar",{key:"guideViewerTaskbar",class:"form-taskbar","data-element-id":"guideViewer",configName:this._configName,disabledButtons:this._disabledButtons,buttons:"INSERT,PREVIOUS,NEXT,DIVIDER,CLONE,REMOVE,MORE_OPTIONS,DIVIDER,GRID_MODE,CONFIGURATOR",primaryButton:"INSERT",presentationMode:n.SECONDARY,onActionClick:t=>this.executeActionHandler(t),dataUnit:this.dataUnit}))))))}static get watchers(){return{dataState:["observerDataState"]}}};u.REGEX_FORM_ID=/__FORM:[^:]+/g,u.style=".sc-snk-detail-view-h{display:flex;row-gap:24px;flex-direction:column;width:100%;height:100%}.level-path.sc-snk-detail-view{color:var(--color--title-primary, #2B3A54);font-weight:var(--text-weight--medium, 400);padding-right:3px}.form-taskbar.sc-snk-detail-view{padding-bottom:var(--space--medium)}.grid-container.sc-snk-detail-view{background-color:#FFF;min-height:100px}.detail-header.sc-snk-detail-view{padding-bottom:0}";export{u as snk_detail_view}
|
@@ -1 +1 @@
|
|
1
|
-
import{p as e,b as t}from"./p-b9667fbe.js";export{s as setNonce}from"./p-b9667fbe.js";(()=>{const t=import.meta.url,a={};return""!==t&&(a.resourcesUrl=new URL(".",t).href),e(a)})().then((e=>t([["p-64f21075",[[6,"snk-simple-crud",{dataState:[16],dataUnit:[16],mode:[2],taskbarManager:[16],_currentViewMode:[32],_config:[32],goToView:[64],setMetadata:[64],setRecords:[64],getRecords:[64]},[[0,"actionClick","actionClickListener"]]]]],["p-e551b19a",[[1,"teste-pesquisa"]]],["p-86d29b6f",[[0,"snk-filter-binary-select",{value:[1544],config:[16],show:[64]},[[0,"ezChange","ezChangeListener"]]]]],["p-79d22df0",[[2,"snk-filter-field-search",{searchable:[4],breadcrumbItems:[32],linkItems:[32],fieldItems:[32],setDataSource:[64],filterDataSource:[64]}]]],["p-ee82c157",[[0,"snk-filter-multi-select",{value:[1544],config:[16],show:[64]},[[0,"ezChange","ezChangeListener"]]]]],["p-ad51bf1c",[[0,"snk-filter-number",{config:[16],value:[2],show:[64]},[[0,"ezChange","ezChangeListener"]]]]],["p-0154ae58",[[2,"snk-filter-param-config",{_opened:[32],_configType:[32],_expressionItem:[32],_informedInstance:[32],_canSave:[32],open:[64],close:[64]}]]],["p-5fc55684",[[0,"snk-filter-period",{config:[16],value:[8],show:[64]},[[0,"ezChange","ezChangeListener"]]]]],["p-d5c9c1f8",[[0,"snk-filter-personalized",{config:[16],value:[1040],fix:[16],unfix:[16],show:[64]}]]],["p-5e62a17b",[[0,"snk-filter-search",{config:[16],value:[16],show:[64]},[[0,"ezChange","ezChangeListener"]]]]],["p-c336170d",[[0,"snk-filter-text",{config:[16],value:[1]},[[0,"ezChange","ezChangeListener"]]]]],["p-
|
1
|
+
import{p as e,b as t}from"./p-b9667fbe.js";export{s as setNonce}from"./p-b9667fbe.js";(()=>{const t=import.meta.url,a={};return""!==t&&(a.resourcesUrl=new URL(".",t).href),e(a)})().then((e=>t([["p-64f21075",[[6,"snk-simple-crud",{dataState:[16],dataUnit:[16],mode:[2],taskbarManager:[16],_currentViewMode:[32],_config:[32],goToView:[64],setMetadata:[64],setRecords:[64],getRecords:[64]},[[0,"actionClick","actionClickListener"]]]]],["p-e551b19a",[[1,"teste-pesquisa"]]],["p-86d29b6f",[[0,"snk-filter-binary-select",{value:[1544],config:[16],show:[64]},[[0,"ezChange","ezChangeListener"]]]]],["p-79d22df0",[[2,"snk-filter-field-search",{searchable:[4],breadcrumbItems:[32],linkItems:[32],fieldItems:[32],setDataSource:[64],filterDataSource:[64]}]]],["p-ee82c157",[[0,"snk-filter-multi-select",{value:[1544],config:[16],show:[64]},[[0,"ezChange","ezChangeListener"]]]]],["p-ad51bf1c",[[0,"snk-filter-number",{config:[16],value:[2],show:[64]},[[0,"ezChange","ezChangeListener"]]]]],["p-0154ae58",[[2,"snk-filter-param-config",{_opened:[32],_configType:[32],_expressionItem:[32],_informedInstance:[32],_canSave:[32],open:[64],close:[64]}]]],["p-5fc55684",[[0,"snk-filter-period",{config:[16],value:[8],show:[64]},[[0,"ezChange","ezChangeListener"]]]]],["p-d5c9c1f8",[[0,"snk-filter-personalized",{config:[16],value:[1040],fix:[16],unfix:[16],show:[64]}]]],["p-5e62a17b",[[0,"snk-filter-search",{config:[16],value:[16],show:[64]},[[0,"ezChange","ezChangeListener"]]]]],["p-c336170d",[[0,"snk-filter-text",{config:[16],value:[1]},[[0,"ezChange","ezChangeListener"]]]]],["p-5afa5b01",[[2,"snk-detail-view",{formConfigManager:[1040],dataUnitName:[1,"data-unit-name"],guideItemPath:[16],entityName:[1,"entity-name"],label:[1],dataUnit:[1040],selectedForm:[1025,"selected-form"],dataState:[1040],_disabledButtons:[32],changeViewMode:[64],configGrid:[64],showUp:[64]},[[0,"snkContentCardChanged","onContentCardChanged"]]]]],["p-31d4e5d4",[[2,"snk-configurator",{configName:[1,"config-name"],viewMode:[2,"view-mode"],_opened:[32],_permissions:[32],open:[64],close:[64]}]]],["p-e701646c",[[2,"snk-pesquisa",{searchLoader:[16],selectItem:[16],argument:[1025],_itemList:[32],_startLoading:[32]}]]],["p-a056d61f",[[2,"snk-filter-bar",{dataUnit:[1040],configName:[1,"config-name"],filterConfig:[1040],allowDefault:[32],scrollerLocked:[32]},[[0,"filterChange","filterChangeListener"]]]]],["p-fa8a62f2",[[2,"snk-grid-config",{selectedIndex:[1026,"selected-index"],application:[16],columns:[1040],config:[1040],configName:[1,"config-name"]}]]],["p-af8cf505",[[2,"snk-config-options",{fieldConfig:[16],idConfig:[513,"id-config"],dataUnit:[16],_defaultType:[32]}]]],["p-94fef424",[[2,"snk-data-unit",{dataState:[1040],dataUnitName:[1,"data-unit-name"],entityName:[1,"entity-name"],pageSize:[2,"page-size"],dataUnit:[1040],beforeSave:[16],afterSave:[16],getDataUnit:[64],getSelectedRecordsIDsInfo:[64]}]]],["p-f9ca6d74",[[2,"snk-field-config",{isConfigActive:[16],fieldConfig:[16],modeInsertion:[516,"mode-insertion"],dataUnit:[16]}]]],["p-c88c4f80",[[6,"snk-tab-config",{selectedIndex:[1538,"selected-index"],selectedTab:[1537,"selected-tab"],tabs:[1],_processedTabs:[32],_activeEditText:[32],_activeEditTextIndex:[32],_actionsHide:[32],_actionsShow:[32]}]]],["p-1374b0e2",[[2,"snk-form-config",{dataUnit:[16],configManager:[16],_formConfigOptions:[32],_fieldConfigSelected:[32],_layoutFormConfig:[32],_fieldsAvailable:[32],_formConfig:[32],_formConfigChanged:[32],_optionFormConfigSelected:[32],_optionFormConfigChanged:[32],_tempGroups:[32]}]]],["p-eb7b2496",[[6,"snk-taskbar",{configName:[1,"config-name"],buttons:[1],customButtons:[16],actionsList:[16],primaryButton:[1,"primary-button"],disabledButtons:[16],dataUnit:[16],presentationMode:[1537,"presentation-mode"],_permissions:[32]}]]],["p-3a2ce158",[[0,"snk-filter-item",{config:[1040],getMessage:[16],detailIsVisible:[32],showUp:[64],hideDetail:[64]},[[2,"click","clickListener"],[2,"mousedown","mouseDownListener"],[0,"filterChange","filterChangeListener"]]]]],["p-093febff",[[4,"snk-filter-list",{label:[1],iconName:[1,"icon-name"],items:[16],getMessage:[16],emptyText:[1,"empty-text"],findFilterText:[1,"find-filter-text"],buttonClass:[1,"button-class"],_filterArgument:[32],_showAll:[32],hideDetail:[64]},[[2,"keydown","keyDownHandler"]]]]],["p-3169584f",[[1,"snk-select-box",{selectedOption:[1,"selected-option"]}]]],["p-22e44b9d",[[0,"snk-exporter-email-sender",{getMessage:[16],_config:[32],_opened:[32],_currentStep:[32],open:[64],close:[64]}]]],["p-604e6970",[[2,"snk-data-exporter",{provider:[16],_items:[32],_showDropdown:[32],_releasedToExport:[32]}]]],["p-6181e6cb",[[2,"snk-guides-viewer",{dataUnit:[16],dataState:[16],configName:[1,"config-name"],entityPath:[1,"entity-path"],actionsList:[16],recordsValidator:[16],masterFormConfig:[1040],selectedGuide:[16],taskbarManager:[16],presentationMode:[1,"presentation-mode"],_breadcrumbItems:[32],_guides:[32],_formEditorConfigManager:[32],_formEditorDataUnit:[32],showFormConfig:[64]},[[2,"actionClick","onActionClick"],[0,"snkContentCardChanged","onContentCardChanged"]]]]],["p-5b80ee28",[[6,"snk-crud",{configName:[1025,"config-name"],actionsList:[16],taskbarManager:[16],recordsValidator:[16],statusResolver:[16],multipleSelection:[4,"multiple-selection"],presentationMode:[1,"presentation-mode"],_dataUnit:[32],_dataState:[32],_currentViewMode:[32],goToView:[64]}]]],["p-d3199c18",[[2,"snk-form",{configName:[1,"config-name"],recordsValidator:[16],_dataUnit:[32],_dataState:[32],_showFormConfig:[32],_configManager:[32],showConfig:[64],hideConfig:[64]}]]],["p-2eab10a4",[[2,"snk-application",{messagesBuilder:[1040],configName:[1,"config-name"],isUserSup:[64],hasAccess:[64],getAllAccess:[64],getStringParam:[64],getIntParam:[64],getFloatParam:[64],getBooleanParam:[64],getDateParam:[64],showPopUp:[64],showModal:[64],closeModal:[64],closePopUp:[64],temOpcional:[64],getConfig:[64],saveConfig:[64],getAttributeFromHTMLWrapper:[64],openApp:[64],webConnection:[64],createDataunit:[64],updateDataunitCache:[64],getDataUnit:[64],addClientEvent:[64],removeClientEvent:[64],hasClientEvent:[64],getResourceID:[64],getUserID:[64],alert:[64],error:[64],success:[64],message:[64],confirm:[64],info:[64],loadGridConfig:[64],loadTotals:[64],executeSearch:[64],executePreparedSearch:[64],isDebugMode:[64],getAppLabel:[64],addSearchListener:[64]}]]],["p-afba9bbe",[[0,"snk-filter-detail",{config:[1040],getMessage:[16],show:[64]}]]],["p-0c0c086f",[[6,"snk-grid",{configName:[1,"config-name"],actionsList:[16],taskbarManager:[16],statusResolver:[16],multipleSelection:[4,"multiple-selection"],presentationMode:[1,"presentation-mode"],_dataUnit:[32],_dataState:[32],_gridConfig:[32],_popUpGridConfig:[32],showConfig:[64],hideConfig:[64],setConfig:[64]}]]],["p-900b2889",[[2,"snk-form-summary",{fixed:[1540],contracted:[1540],summary:[16]}]]],["p-9ebb164d",[[6,"snk-form-view",{levelPath:[1,"level-path"],label:[1],name:[1],fields:[16],formMetadata:[8,"form-metadata"],dataUnit:[16],contracted:[4],fixed:[1540],summaryFields:[16],canExpand:[4,"can-expand"],canFix:[4,"can-fix"],recordsValidator:[16],showUp:[64]}]]],["p-73e830cf",[[0,"snk-filter-modal",{getMessage:[16],items:[1040],modalTitle:[1,"modal-title"],modalSubTitle:[1,"modal-sub-title"],cancelButtonLabel:[1,"cancel-button-label"],okButtonLabel:[1,"ok-button-label"],infoText:[1,"info-text"],useSearch:[4,"use-search"],processModalAction:[16],_filterArgument:[32]}]]]],e)));
|
@@ -5,7 +5,7 @@ import { MessageOptions, DialogType } from "@sankhyalabs/ezui/dist/collection/ut
|
|
5
5
|
import { IGridConfig } from "@sankhyalabs/ezui/dist/types/components/ez-grid/controller/EzGridController";
|
6
6
|
import { IOption, ISearchArgument } from "@sankhyalabs/ezui/dist/types/components/ez-combo-box/ez-combo-box";
|
7
7
|
import { SnkErrorHandler } from "./errorhandler/snk-error-handler";
|
8
|
-
import { PesquisaFetcher } from "../../lib/http/data-fetcher/fetchers/pesquisa-fetcher";
|
8
|
+
import { IRemoveSearchListener, ISearchListener, PesquisaFetcher } from "../../lib/http/data-fetcher/fetchers/pesquisa-fetcher";
|
9
9
|
import { TotalsFetcher } from "../../lib/http/data-fetcher/fetchers/totals-fetcher";
|
10
10
|
import { SnkMessageBuilder } from "../../lib/message/SnkMessageBuilder";
|
11
11
|
import { SnkFilterItemConfig } from "../snk-filter-bar/filter-item/snk-filter-item";
|
@@ -231,6 +231,10 @@ export declare class SnkApplication {
|
|
231
231
|
* Obtém o nome das telas da aplicação
|
232
232
|
*/
|
233
233
|
getAppLabel(): Promise<string>;
|
234
|
+
/**
|
235
|
+
* Adiciona um listener no fetcher de Pesquisa
|
236
|
+
*/
|
237
|
+
addSearchListener(entityName: string, dataUnit: DataUnit, listener: ISearchListener): Promise<IRemoveSearchListener>;
|
234
238
|
private clearContent;
|
235
239
|
private clearPopUpTitle;
|
236
240
|
private setPopUpTitle;
|
@@ -14,7 +14,7 @@ import { IDataFetcherRecaller } from "./lib/http/data-fetcher/recaller/IDataFetc
|
|
14
14
|
import { DialogType, MessageOptions } from "@sankhyalabs/ezui/dist/collection/utils";
|
15
15
|
import { EzGridColumn, IGridConfig, IStatusResolver } from "@sankhyalabs/ezui/dist/types/components/ez-grid/controller/EzGridController";
|
16
16
|
import { IOption, ISearchArgument } from "@sankhyalabs/ezui/dist/types/components/ez-combo-box/ez-combo-box";
|
17
|
-
import { SearchCriteria } from "./lib/http/data-fetcher/fetchers/pesquisa-fetcher";
|
17
|
+
import { IRemoveSearchListener, ISearchListener, SearchCriteria } from "./lib/http/data-fetcher/fetchers/pesquisa-fetcher";
|
18
18
|
import { IFieldConfig, IFormCardConfig, IFormConfig, IRecordValidator, ISummaryField } from "@sankhyalabs/ezui/dist/types/utils/form/interfaces";
|
19
19
|
import { SIMPLE_CRUD_MODE, VIEW_MODE } from "./lib/utils/constants";
|
20
20
|
import { Action, TaskbarManager } from "./components/snk-taskbar/snk-taskbar";
|
@@ -48,6 +48,10 @@ export namespace Components {
|
|
48
48
|
* @param handler - Função de callback que será chamada quando o client event ocorrer.
|
49
49
|
*/
|
50
50
|
"addClientEvent": (eventID: String, handler: (clientEvent: IClientEventResponse, dataFetcherReacaller: IDataFetcherRecaller) => void) => Promise<void>;
|
51
|
+
/**
|
52
|
+
* Adiciona um listener no fetcher de Pesquisa
|
53
|
+
*/
|
54
|
+
"addSearchListener": (entityName: string, dataUnit: DataUnit, listener: ISearchListener) => Promise<IRemoveSearchListener>;
|
51
55
|
/**
|
52
56
|
* Exibe o diálogo de alerta de acordo com os parâmetros passados.
|
53
57
|
*/
|
@@ -2,10 +2,13 @@ import { DataType } from "@sankhyalabs/core";
|
|
2
2
|
export declare class PesquisaFetcher {
|
3
3
|
private _defaultPageSize;
|
4
4
|
private _templateByQuery;
|
5
|
+
private _searchListenersByDataUnit;
|
5
6
|
constructor();
|
6
7
|
private buldTemplates;
|
7
8
|
loadSearchOptions(entityName: string, argument: string, criteria?: SearchCriteria, options?: SearchOptions): Promise<any>;
|
8
9
|
loadAdvancedSearch(entityName: string, argument: string, criteria?: SearchCriteria, searchOptions?: SearchOptions): Promise<any>;
|
10
|
+
addSearchListener(entityName: string, dataUnitID: DataUnitID, listener: ISearchListener): IRemoveSearchListener;
|
11
|
+
private applySearchListener;
|
9
12
|
}
|
10
13
|
export interface SearchCriteria {
|
11
14
|
expression: string;
|
@@ -21,4 +24,16 @@ export interface SearchOptions {
|
|
21
24
|
descriptionFieldName?: string;
|
22
25
|
codeFieldName?: string;
|
23
26
|
showInactives?: boolean;
|
27
|
+
dataUnitId?: string;
|
24
28
|
}
|
29
|
+
type DataUnitID = string;
|
30
|
+
export type IRemoveSearchListener = () => void;
|
31
|
+
export interface ISearchListener {
|
32
|
+
beforeSearch?: (request: ISearchListenerRequest) => ISearchListenerRequest | undefined;
|
33
|
+
}
|
34
|
+
export interface ISearchListenerRequest {
|
35
|
+
argument: string;
|
36
|
+
criteria?: SearchCriteria;
|
37
|
+
searchOptions?: SearchOptions;
|
38
|
+
}
|
39
|
+
export {};
|
package/package.json
CHANGED
@@ -1 +0,0 @@
|
|
1
|
-
import{r as t,c as i,f as s,h as e,H as a}from"./p-b9667fbe.js";import{S as o}from"./p-a6258eed.js";import{FormMetadata as h,buildFormMetadata as r}from"@sankhyalabs/ezui/dist/collection/utils/form";import"./p-0c11c980.js";import"@sankhyalabs/core";import{P as n}from"./p-f132e371.js";import{T as d}from"./p-74724fa7.js";import{c as l}from"./p-f587a454.js";import{S as c}from"./p-e1dbaecb.js";import"./p-3c4823fc.js";import"./p-9f98fc3c.js";import"./p-112455b1.js";import"./p-98f7f796.js";import"./p-c2beb95c.js";const u=class{constructor(s){t(this,s),this.snkDetailGuidesChange=i(this,"snkDetailGuidesChange",7),this.snkSwitchGuide=i(this,"snkSwitchGuide",7),this.formConfigManager=void 0,this.dataUnitName=void 0,this.guideItemPath=void 0,this.entityName=void 0,this.label=void 0,this.dataUnit=void 0,this.selectedForm=void 0,this.dataState=void 0}observerDataState(t,i){var s;const e=!(null==i?void 0:i.insertionMode)&&(null==t?void 0:t.insertionMode),a=(null==i?void 0:i.insertionMode)&&!(null==t?void 0:t.insertionMode);if((e||a)&&this.loadMetadata(),null==this._formMetadata)return;const o=null===(s=this.dataState)||void 0===s?void 0:s.selectedRecord,h=this.getNewGuideItem(o);this.snkDetailGuidesChange.emit({item:h,recordId:null==o?void 0:o.__record__id__}),e&&setTimeout((()=>{this.changeViewMode(l.FORM)}),0),a&&this.changeViewMode(l.GRID)}async changeViewMode(t){this.emitSwitchEvent(t)}async configGrid(){this._snkGrid&&this._snkGrid.showConfig()}async showUp(){this._snkFormView&&this._snkFormView.showUp(),this._snkGrid&&this._snkGrid.scrollIntoView({behavior:"smooth",block:"start"})}onContentCardChanged(t){c.updateContentCard(t.detail.formName,t.detail.cardConfig,t.detail.propertyChanged,this.formConfigManager).then((()=>s(this))),t.stopPropagation()}updateLabel(){const t=this.guideItemPath?this.guideItemPath.length:0;if(t>0){const i=t>0?this.guideItemPath.map((t=>t.label)):void 0;this.label=i.pop(),this._levelPath=i.length>0?i.join(" / "):void 0,this._guideId=this.guideItemPath[t-1].id}else this.label="",this._levelPath=void 0,this._guideId=void 0}getNewGuideItem(t){if(null==t)return;const i=this.dataUnit.isNewRecord(t.__record__id__),s=Array.from(this._formMetadata.getAllSheets().values()).map((t=>{const{name:s,label:e}=t,a=null!=h.getDetailName(s.split("::").pop()),o=a&&i;return{id:a?this.getChildGuideId(s):this.getFormGuideId(s),label:e,disabled:o,tooltip:o?"Finalize o cadastro para ter acesso a esta guia.":void 0}})),e=s.shift();return e.label=i?"Novo Registro":t.__record__label__,e.children=s,e.expanded=!0,e}getFormGuideId(t){var i;if(!t){if(null==(null===(i=this.dataState)||void 0===i?void 0:i.selectedRecord))return;const s=Array.from(this._formMetadata.getAllSheets().keys());if(!s||0==s.length)return;t=s[0]}return`${this.stripFormPattern(this._guideId)}__FORM:${t}`}getChildGuideId(t){return`${this.stripFormPattern(this._guideId)}::${t}`}stripFormPattern(t){return t.replace(u.REGEX_FORM_ID,"")}loadMetadata(){var t;if(!this.dataUnit)return;if(!this.formConfigManager.isLoaded)return;const i=this.formConfigManager.getConfig(null===(t=this.dataState)||void 0===t?void 0:t.insertionMode,this.dataUnit);this._formMetadata=r(null==i||0===i.fields.length?void 0:i,this.dataUnit,!0)}dataUnitReadyHandler(t){this.dataUnit=t.detail,this.loadMetadata()}updateViewStack(t){t.show(this.selectedForm?1:0)}getFormFields(){return this.selectedForm&&this._formMetadata?this._formMetadata.getSheet(this.selectedForm).fields:[]}emitSwitchEvent(t){const i=t===l.GRID?this.stripFormPattern(this._guideId):this.getFormGuideId();i&&this.snkSwitchGuide.emit(i)}executeActionHandler(t){t.detail===d.GRID_MODE&&(this.emitSwitchEvent(l.GRID),t.stopPropagation()),t.detail===d.FORM_MODE&&(this.emitSwitchEvent(l.FORM),t.stopPropagation())}componentWillLoad(){this._configName=`dynaform.${this.entityName}`,this.formConfigManager=new o(this._configName,(()=>this.loadMetadata())),this.formConfigManager.loadConfig()}render(){return this.updateLabel(),e(a,null,e("snk-data-unit",{dataUnitName:`${this.dataUnitName}`,onDataUnitReady:t=>this.dataUnitReadyHandler(t),entityName:this.entityName,onDataStateChange:t=>this.dataState=t.detail},e("ez-view-stack",{ref:t=>this.updateViewStack(t)},e("stack-item",null,e("div",{class:"ez-box ez-box--shadow grid-container"},e("div",{class:"ez-flex ez-size-width--full ez-padding--large detail-header"},e("div",{class:"ez-flex ez-text ez-text--bold ez-flex--justify-start ez-flex--align-items-center"},this._levelPath?e("span",{class:"level-path"},this._levelPath+" /"):void 0,this.label)),e("snk-grid",{class:"ez-size-width--full ez-size-height--full",ref:t=>this._snkGrid=t,configName:this._configName,onGridDoubleClick:()=>this.emitSwitchEvent(l.FORM),onActionClick:t=>this.executeActionHandler(t),presentationMode:n.SECONDARY}))),e("stack-item",null,e("snk-form-view",{ref:t=>this._snkFormView=t,canExpand:!1,canFix:!1,name:this.selectedForm,formMetadata:this._formMetadata,dataUnit:this.dataUnit,fields:this.getFormFields(),label:this.label,levelPath:this._levelPath},e("snk-taskbar",{key:"guideViewerTaskbar",class:"form-taskbar","data-element-id":"guideViewer",configName:this._configName,buttons:"INSERT,PREVIOUS,NEXT,DIVIDER,CLONE,REMOVE,MORE_OPTIONS,DIVIDER,GRID_MODE,CONFIGURATOR",primaryButton:"INSERT",presentationMode:n.SECONDARY,onActionClick:t=>this.executeActionHandler(t),dataUnit:this.dataUnit}))))))}static get watchers(){return{dataState:["observerDataState"]}}};u.REGEX_FORM_ID=/__FORM:[^:]+/g,u.style=".sc-snk-detail-view-h{display:flex;row-gap:24px;flex-direction:column;width:100%;height:100%}.level-path.sc-snk-detail-view{color:var(--color--title-primary, #2B3A54);font-weight:var(--text-weight--medium, 400);padding-right:3px}.form-taskbar.sc-snk-detail-view{padding-bottom:var(--space--medium)}.grid-container.sc-snk-detail-view{background-color:#FFF;min-height:100px}.detail-header.sc-snk-detail-view{padding-bottom:0}";export{u as snk_detail_view}
|