@sankhyalabs/sankhyablocks 4.2.1 → 4.3.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/snk-application.cjs.entry.js +1 -1
- package/dist/collection/components/snk-application/snk-application.js +1 -1
- package/dist/components/snk-application2.js +1 -1
- package/dist/esm/snk-application.entry.js +1 -1
- package/dist/sankhyablocks/{p-ad3a0128.entry.js → p-5bf3e2fa.entry.js} +8 -8
- package/dist/sankhyablocks/sankhyablocks.esm.js +1 -1
- package/package.json +1 -1
@@ -1110,7 +1110,7 @@ const SnkApplication = class {
|
|
1110
1110
|
codeFieldName: CODEFIELD,
|
1111
1111
|
showInactives: false
|
1112
1112
|
};
|
1113
|
-
dependencies === null || dependencies === void 0 ? void 0 : dependencies.filter(dep =>
|
1113
|
+
dependencies === null || dependencies === void 0 ? void 0 : dependencies.filter(dep => dep.masterFields).forEach(dependency => {
|
1114
1114
|
var _a;
|
1115
1115
|
if (dependency.type === core.DependencyType.SEARCHING) {
|
1116
1116
|
if (((_a = dependency.masterFields) === null || _a === void 0 ? void 0 : _a.length) > 0) {
|
@@ -483,7 +483,7 @@ export class SnkApplication {
|
|
483
483
|
codeFieldName: CODEFIELD,
|
484
484
|
showInactives: false
|
485
485
|
};
|
486
|
-
dependencies === null || dependencies === void 0 ? void 0 : dependencies.filter(dep =>
|
486
|
+
dependencies === null || dependencies === void 0 ? void 0 : dependencies.filter(dep => dep.masterFields).forEach(dependency => {
|
487
487
|
var _a;
|
488
488
|
if (dependency.type === DependencyType.SEARCHING) {
|
489
489
|
if (((_a = dependency.masterFields) === null || _a === void 0 ? void 0 : _a.length) > 0) {
|
@@ -1107,7 +1107,7 @@ const SnkApplication = /*@__PURE__*/ proxyCustomElement(class extends HTMLElemen
|
|
1107
1107
|
codeFieldName: CODEFIELD,
|
1108
1108
|
showInactives: false
|
1109
1109
|
};
|
1110
|
-
dependencies === null || dependencies === void 0 ? void 0 : dependencies.filter(dep =>
|
1110
|
+
dependencies === null || dependencies === void 0 ? void 0 : dependencies.filter(dep => dep.masterFields).forEach(dependency => {
|
1111
1111
|
var _a;
|
1112
1112
|
if (dependency.type === DependencyType.SEARCHING) {
|
1113
1113
|
if (((_a = dependency.masterFields) === null || _a === void 0 ? void 0 : _a.length) > 0) {
|
@@ -1106,7 +1106,7 @@ const SnkApplication = class {
|
|
1106
1106
|
codeFieldName: CODEFIELD,
|
1107
1107
|
showInactives: false
|
1108
1108
|
};
|
1109
|
-
dependencies === null || dependencies === void 0 ? void 0 : dependencies.filter(dep =>
|
1109
|
+
dependencies === null || dependencies === void 0 ? void 0 : dependencies.filter(dep => dep.masterFields).forEach(dependency => {
|
1110
1110
|
var _a;
|
1111
1111
|
if (dependency.type === DependencyType.SEARCHING) {
|
1112
1112
|
if (((_a = dependency.masterFields) === null || _a === void 0 ? void 0 : _a.length) > 0) {
|
@@ -1,14 +1,14 @@
|
|
1
|
-
import{r as t,c as e,h as s,g as r}from"./p-b9667fbe.js";import{WaitingChangeException as i,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
|
1
|
+
import{r as t,c as e,h as s,g as r}from"./p-b9667fbe.js";import{WaitingChangeException as i,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 w}from"@sankhyalabs/core";import{d as v,D as _,U as g}from"./p-9c8982de.js";import{ApplicationUtils as I}from"@sankhyalabs/ezui/dist/collection/utils";import{S as P}from"./p-c4483cb2.js";import{G as $,C as D}from"./p-9e5f04f9.js";import{R as S}from"./p-4190e963.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 i||(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 i||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",v.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,r){const i=(null==e?void 0:e.toString().trim())||void 0;return e=isNaN(Number(i))&&i?`%${i}`:i,new Promise(((i,n)=>{_.get().callGraphQL({values:{argument:e,entityName:t,criteria:s,options:r},query:this._templateByQuery.get("search")}).then((t=>{i(t)})).catch((t=>{n(t)}))}))}loadAdvancedSearch(t,e,s,r){const i={query:{$:null==s?void 0:s.expression}};(null==s?void 0:s.params.length)>0&&(i.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:Object.assign({entityName:t,compacted:!1,ignoreEntityCriteria:!1,limit:this._defaultPageSize,query:{$:e},orderByDesc:!1,externalCriteria:i,localEntityName:null==r?void 0:r.rootEntity},{options:null!=r?{pkFieldName:r.codeFieldName,label:r.descriptionFieldName,fieldName:r.codeFieldName,useDescriptionOptions:!1,enableRowsCounter:!0}:void 0}),clientEventList:{clientEvent:[]}}};return new Promise(((t,e)=>{_.get().callServiceBroker("PesquisaSP.getSuggestion",JSON.stringify(n)).then((e=>t(e))).catch((t=>e(t)))}))}}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",
|
6
|
+
}`)}loadSearchOptions(t,e,s,r){const i=(null==e?void 0:e.toString().trim())||void 0;return e=isNaN(Number(i))&&i?`%${i}`:i,new Promise(((i,n)=>{_.get().callGraphQL({values:{argument:e,entityName:t,criteria:s,options:r},query:this._templateByQuery.get("search")}).then((t=>{i(t)})).catch((t=>{n(t)}))}))}loadAdvancedSearch(t,e,s,r){const i={query:{$:null==s?void 0:s.expression}};(null==s?void 0:s.params.length)>0&&(i.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:Object.assign({entityName:t,compacted:!1,ignoreEntityCriteria:!1,limit:this._defaultPageSize,query:{$:e},orderByDesc:!1,externalCriteria:i,localEntityName:null==r?void 0:r.rootEntity},{options:null!=r?{pkFieldName:r.codeFieldName,label:r.descriptionFieldName,fieldName:r.codeFieldName,useDescriptionOptions:!1,enableRowsCounter:!0}:void 0}),clientEventList:{clientEvent:[]}}};return new Promise(((t,e)=>{_.get().callServiceBroker("PesquisaSP.getSuggestion",JSON.stringify(n)).then((e=>t(e))).catch((t=>e(t)))}))}}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",v.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 r={name:`totals://${t}/${e}`,filters:s};return _.get().callGraphQL({values:r,query:this.templateByQuery.get("fetchTotals")})}fetchTotals(t,e,s=[]){return new Promise(((r,i)=>{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))})),r(e)}else i("Não foi possível recuperar os totalizadores")})).catch((t=>{i(t)}))}))}}var q;class U{constructor(){this.templateByQuery=new Map,this._loadDataTimeout={},this.buldTemplates()}buldTemplates(){this.templateByQuery.set("fetchDataUnit",
|
11
|
+
}`)}async getTotals(t,e,s){let r={name:`totals://${t}/${e}`,filters:s};return _.get().callGraphQL({values:r,query:this.templateByQuery.get("fetchTotals")})}fetchTotals(t,e,s=[]){return new Promise(((r,i)=>{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))})),r(e)}else i("Não foi possível recuperar os totalizadores")})).catch((t=>{i(t)}))}))}}var q;class U{constructor(){this.templateByQuery=new Map,this._loadDataTimeout={},this.buldTemplates()}buldTemplates(){this.templateByQuery.set("fetchDataUnit",v.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",v.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",v.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",v.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 r=null!=s?s.getChildDataunit(`dd://${t}/${e}`):new l(`dd://${t}/${e}`);return r.metadataLoader=t=>this.loadMetadata(t),r.dataLoader=(t,e)=>this.loadData(t,e),r.saveLoader=(t,e)=>this.saveData(r,e),r.removeLoader=(t,e)=>this.removeRecords(t,e),r.recordLoader=(t,e)=>this.loadRecord(t,e),r}loadMetadata(t){return new Promise(((e,s)=>{_.get().callGraphQL({values:{name:t.name},query:this.templateByQuery.get("fetchDataUnit")}).then((t=>{var s;const r={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))),r.fields.push(Object.assign(Object.assign({},t),{properties:e}))})),e(r)})).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(((r,i)=>{this._loadDataTimeout[s]=setTimeout((()=>{delete this._loadDataTimeout[s],this.doLoadData(t,e).then((t=>r(t))).catch((t=>i(t)))}),200)}))}doLoadData(t,e){return new Promise(((s,r)=>{var i;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===(i=null==h?void 0:h.fields)||void 0===i?void 0:i.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:r,offset:i,total:n,hasMore:a,records:o}=e.data;let c;r&&(c={firstRecord:0==n?0:i+1,lastRecord:i+Math.min(o.length,r),total:n,currentPage:i/r,hasMore:a});const l=[];o.forEach((e=>{const s={__record__id__:e.id,__record__label__:e.label};e.fields.forEach((({name:e,value:r})=>{s[e]=t.valueFromString(e,r)})),l.push(s)})),s({paginationInfo:c,records:l})})).catch((t=>{r(t)}))}))}saveData(t,e){const s=e.map((t=>{const{dataUnit:e,record:s,updatingFields:r,operation:i}=t,n=h.get(e);let a;r&&(a=Object.entries(r).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:i,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,r)=>{const i=s.map((t=>function(t,e){var s={};for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&e.indexOf(r)<0&&(s[r]=t[r]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols){var i=0;for(r=Object.getOwnPropertySymbols(t);i<r.length;i++)e.indexOf(r[i])<0&&Object.prototype.propertyIsEnumerable.call(t,r[i])&&(s[r[i]]=t[r[i]])}return s}(t,[])));_.get().callGraphQL({values:{changes:i},query:this.templateByQuery.get("saveData")}).then((s=>{const r=[];null==s||s.forEach((e=>{const s={__record__id__:e.id,__record__label__:e.label,__owner__dataunit__name__:e.ownerDataUnitName},i=h.get(s.__owner__dataunit__name__)||t;e.oldId&&(s.__old__id__=e.oldId),e.fields.forEach((({name:t,value:e})=>{var r;s[t]=(null===(r=null==i?void 0:i.valueFromString)||void 0===r?void 0:r.call(i,t,e))||e})),r.push(s)})),e(r)})).catch((t=>{r(t)}))}))}removeRecords(t,e){const s=e.map((e=>({dataUnit:t.name,operation:d.DELETE,recordId:e})));return new Promise(((t,r)=>{_.get().callGraphQL({values:{changes:s},query:this.templateByQuery.get("saveData")}).then((()=>{t(e)})).catch((t=>{r(t)}))}))}loadRecord(t,e){return new Promise(((s,r)=>{_.get().callGraphQL({values:{recordID:e,dataunit:t.name},query:this.templateByQuery.get("fetchDataRecord")}).then((e=>{const r=[];e.record.forEach((e=>{const s={__record__id__:e.id,__record__label__:e.label};e.fields.forEach((({name:e,value:r})=>{s[e]=t.valueFromString(e,r)})),r.push(s)})),s(r)})).catch((t=>{r(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 r;null===(r=window.AppletCaller)||void 0===r||r.webConnectionCaller(t,e,s)}}class L{constructor(){this.templateByQuery=new Map,this.buldTemplates()}buldTemplates(){this.templateByQuery.set("fetchParam",
|
83
|
+
}`)}getDataUnit(t,e,s){const r=null!=s?s.getChildDataunit(`dd://${t}/${e}`):new l(`dd://${t}/${e}`);return r.metadataLoader=t=>this.loadMetadata(t),r.dataLoader=(t,e)=>this.loadData(t,e),r.saveLoader=(t,e)=>this.saveData(r,e),r.removeLoader=(t,e)=>this.removeRecords(t,e),r.recordLoader=(t,e)=>this.loadRecord(t,e),r}loadMetadata(t){return new Promise(((e,s)=>{_.get().callGraphQL({values:{name:t.name},query:this.templateByQuery.get("fetchDataUnit")}).then((t=>{var s;const r={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))),r.fields.push(Object.assign(Object.assign({},t),{properties:e}))})),e(r)})).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(((r,i)=>{this._loadDataTimeout[s]=setTimeout((()=>{delete this._loadDataTimeout[s],this.doLoadData(t,e).then((t=>r(t))).catch((t=>i(t)))}),200)}))}doLoadData(t,e){return new Promise(((s,r)=>{var i;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===(i=null==h?void 0:h.fields)||void 0===i?void 0:i.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:r,offset:i,total:n,hasMore:a,records:o}=e.data;let c;r&&(c={firstRecord:0==n?0:i+1,lastRecord:i+Math.min(o.length,r),total:n,currentPage:i/r,hasMore:a});const l=[];o.forEach((e=>{const s={__record__id__:e.id,__record__label__:e.label};e.fields.forEach((({name:e,value:r})=>{s[e]=t.valueFromString(e,r)})),l.push(s)})),s({paginationInfo:c,records:l})})).catch((t=>{r(t)}))}))}saveData(t,e){const s=e.map((t=>{const{dataUnit:e,record:s,updatingFields:r,operation:i}=t,n=h.get(e);let a;r&&(a=Object.entries(r).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:i,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,r)=>{const i=s.map((t=>function(t,e){var s={};for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&e.indexOf(r)<0&&(s[r]=t[r]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols){var i=0;for(r=Object.getOwnPropertySymbols(t);i<r.length;i++)e.indexOf(r[i])<0&&Object.prototype.propertyIsEnumerable.call(t,r[i])&&(s[r[i]]=t[r[i]])}return s}(t,[])));_.get().callGraphQL({values:{changes:i},query:this.templateByQuery.get("saveData")}).then((s=>{const r=[];null==s||s.forEach((e=>{const s={__record__id__:e.id,__record__label__:e.label,__owner__dataunit__name__:e.ownerDataUnitName},i=h.get(s.__owner__dataunit__name__)||t;e.oldId&&(s.__old__id__=e.oldId),e.fields.forEach((({name:t,value:e})=>{var r;s[t]=(null===(r=null==i?void 0:i.valueFromString)||void 0===r?void 0:r.call(i,t,e))||e})),r.push(s)})),e(r)})).catch((t=>{r(t)}))}))}removeRecords(t,e){const s=e.map((e=>({dataUnit:t.name,operation:d.DELETE,recordId:e})));return new Promise(((t,r)=>{_.get().callGraphQL({values:{changes:s},query:this.templateByQuery.get("saveData")}).then((()=>{t(e)})).catch((t=>{r(t)}))}))}loadRecord(t,e){return new Promise(((s,r)=>{_.get().callGraphQL({values:{recordID:e,dataunit:t.name},query:this.templateByQuery.get("fetchDataRecord")}).then((e=>{const r=[];e.record.forEach((e=>{const s={__record__id__:e.id,__record__label__:e.label};e.fields.forEach((({name:e,value:r})=>{s[e]=t.valueFromString(e,r)})),r.push(s)})),s(r)})).catch((t=>{r(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 r;null===(r=window.AppletCaller)||void 0===r||r.webConnectionCaller(t,e,s)}}class L{constructor(){this.templateByQuery=new Map,this.buldTemplates()}buldTemplates(){this.templateByQuery.set("fetchParam",v.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=>{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===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),v.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=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}
|
@@ -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-e551b19a",[[1,"teste-pesquisa"]]],["p-86d29b6f",[[0,"snk-filter-binary-select",{value:[1544],config:[16],show:[64]},[[0,"ezChange","ezChangeListener"]]]]],["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-60733cf4",[[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],changeViewMode:[64],configGrid:[64],showUp:[64]},[[0,"snkContentCardChanged","onContentCardChanged"]]]]],["p-43d8d388",[[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-e0416591",[[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-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-5bd8f4eb",[[2,"snk-grid-config",{selectedIndex:[1026,"selected-index"],application:[16],columns:[1040],config:[1040],configName:[1,"config-name"]}]]],["p-6e6ef989",[[2,"snk-field-config",{isConfigActive:[16],fieldConfig:[16],modeInsertion:[516,"mode-insertion"],dataUnit:[16]}]]],["p-afba9bbe",[[0,"snk-filter-detail",{config:[1040],getMessage:[16],show:[64]}]]],["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-0fc003e4",[[2,"snk-filter-bar",{dataUnit:[1040],configName:[1,"config-name"],filterConfig:[1040],allowDefault:[32],scrollerLocked:[32]},[[0,"filterChange","filterChangeListener"]]]]],["p-48464413",[[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-fc86a31e",[[2,"snk-config-options",{fieldConfig:[16],idConfig:[513,"id-config"],dataUnit:[16],_defaultType:[32]}]]],["p-99742169",[[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-715c38b3",[[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-22e44b9d",[[0,"snk-exporter-email-sender",{getMessage:[16],_config:[32],_opened:[32],_currentStep:[32],open:[64],close:[64]}]]],["p-ba47d0b5",[[2,"snk-data-exporter",{provider:[16],_items:[32],_showDropdown:[32],_releasedToExport:[32]}]]],["p-896c71d8",[[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-4720a8fd",[[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-c1f74a90",[[2,"snk-form",{configName:[1,"config-name"],recordsValidator:[16],_dataUnit:[32],_dataState:[32],_showFormConfig:[32],_configManager:[32],showConfig:[64],hideConfig:[64]}]]],["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-e551b19a",[[1,"teste-pesquisa"]]],["p-86d29b6f",[[0,"snk-filter-binary-select",{value:[1544],config:[16],show:[64]},[[0,"ezChange","ezChangeListener"]]]]],["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-60733cf4",[[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],changeViewMode:[64],configGrid:[64],showUp:[64]},[[0,"snkContentCardChanged","onContentCardChanged"]]]]],["p-43d8d388",[[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-e0416591",[[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-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-5bd8f4eb",[[2,"snk-grid-config",{selectedIndex:[1026,"selected-index"],application:[16],columns:[1040],config:[1040],configName:[1,"config-name"]}]]],["p-6e6ef989",[[2,"snk-field-config",{isConfigActive:[16],fieldConfig:[16],modeInsertion:[516,"mode-insertion"],dataUnit:[16]}]]],["p-afba9bbe",[[0,"snk-filter-detail",{config:[1040],getMessage:[16],show:[64]}]]],["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-0fc003e4",[[2,"snk-filter-bar",{dataUnit:[1040],configName:[1,"config-name"],filterConfig:[1040],allowDefault:[32],scrollerLocked:[32]},[[0,"filterChange","filterChangeListener"]]]]],["p-48464413",[[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-fc86a31e",[[2,"snk-config-options",{fieldConfig:[16],idConfig:[513,"id-config"],dataUnit:[16],_defaultType:[32]}]]],["p-99742169",[[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-715c38b3",[[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-22e44b9d",[[0,"snk-exporter-email-sender",{getMessage:[16],_config:[32],_opened:[32],_currentStep:[32],open:[64],close:[64]}]]],["p-ba47d0b5",[[2,"snk-data-exporter",{provider:[16],_items:[32],_showDropdown:[32],_releasedToExport:[32]}]]],["p-896c71d8",[[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-4720a8fd",[[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-c1f74a90",[[2,"snk-form",{configName:[1,"config-name"],recordsValidator:[16],_dataUnit:[32],_dataState:[32],_showFormConfig:[32],_configManager:[32],showConfig:[64],hideConfig:[64]}]]],["p-5bf3e2fa",[[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]}]]],["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]}]]],["p-9d62bbca",[[1,"snk-select-box",{selectedOption:[1,"selected-option"]}]]]],e)));
|