@sankhyalabs/sankhyablocks 4.8.1 → 4.8.2

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.
Files changed (35) hide show
  1. package/dist/cjs/pesquisa-fetcher-d9dda5c6.js +162 -0
  2. package/dist/cjs/snk-application.cjs.entry.js +2 -149
  3. package/dist/cjs/snk-crud.cjs.entry.js +1 -0
  4. package/dist/cjs/snk-detail-view.cjs.entry.js +2 -1
  5. package/dist/cjs/{snk-guides-viewer-cb02e675.js → snk-guides-viewer-19e24b86.js} +1 -0
  6. package/dist/cjs/snk-guides-viewer.cjs.entry.js +2 -1
  7. package/dist/cjs/snk-simple-crud.cjs.entry.js +1 -0
  8. package/dist/collection/lib/http/data-fetcher/fetchers/pesquisa-fetcher.js +10 -2
  9. package/dist/components/pesquisa-fetcher.js +160 -0
  10. package/dist/components/snk-application2.js +2 -149
  11. package/dist/components/snk-crud.js +1 -0
  12. package/dist/components/snk-detail-view2.js +1 -0
  13. package/dist/components/snk-simple-crud.js +1 -0
  14. package/dist/esm/pesquisa-fetcher-b0c7f275.js +160 -0
  15. package/dist/esm/snk-application.entry.js +2 -149
  16. package/dist/esm/snk-crud.entry.js +1 -0
  17. package/dist/esm/snk-detail-view.entry.js +2 -1
  18. package/dist/esm/{snk-guides-viewer-b13cff0a.js → snk-guides-viewer-5284f800.js} +1 -0
  19. package/dist/esm/snk-guides-viewer.entry.js +2 -1
  20. package/dist/esm/snk-simple-crud.entry.js +1 -0
  21. package/dist/sankhyablocks/p-31dba496.js +1 -0
  22. package/dist/sankhyablocks/p-722f0e95.entry.js +83 -0
  23. package/dist/sankhyablocks/p-c78cd6e6.entry.js +1 -0
  24. package/dist/sankhyablocks/{p-6181e6cb.entry.js → p-c7ca2118.entry.js} +1 -1
  25. package/dist/sankhyablocks/p-d3324c6c.js +6 -0
  26. package/dist/sankhyablocks/p-d9508a7f.entry.js +1 -0
  27. package/dist/sankhyablocks/p-f59bee89.entry.js +1 -0
  28. package/dist/sankhyablocks/sankhyablocks.esm.js +1 -1
  29. package/dist/types/lib/http/data-fetcher/fetchers/pesquisa-fetcher.d.ts +4 -1
  30. package/package.json +1 -1
  31. package/dist/sankhyablocks/p-2eab10a4.entry.js +0 -88
  32. package/dist/sankhyablocks/p-5afa5b01.entry.js +0 -1
  33. package/dist/sankhyablocks/p-5b80ee28.entry.js +0 -1
  34. package/dist/sankhyablocks/p-64f21075.entry.js +0 -1
  35. package/dist/sankhyablocks/p-e1dbaecb.js +0 -1
@@ -0,0 +1,83 @@
1
+ import{r as t,c as e,h as s,g as r}from"./p-b9667fbe.js";import{WaitingChangeException as n,WarningException as i,ErrorException as a,ObjectUtils as o,DataUnit as c,StringUtils as h,DataType as l,DataUnitStorage as u,ChangeOperation as d,DateUtils as p,DependencyType as m,ElementIDUtils as f,ApplicationContext as y,ErrorTracking as w}from"@sankhyalabs/core";import{d as _,D as v,U as g}from"./p-0c11c980.js";import{ApplicationUtils as I}from"@sankhyalabs/ezui/dist/collection/utils";import{P}from"./p-d3324c6c.js";import{S as D}from"./p-28c800b9.js";import{G as $,C as b}from"./p-3c4823fc.js";import{R as A}from"./p-9f98fc3c.js";import"./p-112455b1.js";class S{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 n||(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 n||t instanceof i?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)}}))}}function T(){const t=["2909523kXwted","CompanyName=Sankhya Jiva Tecnologia e Inovao Ltda,LicensedApplication=Sankhya Gestao,LicenseType=SingleApplication,LicensedConcurrentDeveloperCount=2,LicensedProductionInstancesCount=0,AssetReference=AG-019460,ExpiryDate=9_November_2022_[v2]_MTY2Nzk1MjAwMDAwMA==10487151e296ee4360f80961ca960869","1131048CARoeW","502909mLEPmu","447255iQEXuN","428UHbJwW","270AFTxAV","194369jhGqTI","1540nWuTrj","2044062GicUQI","30CkXPWg"];return(T=function(){return t})()}const C=E;function E(t,e){const s=T();return(E=function(t){return s[t-=392]})(t,e)}!function(){const t=E,e=T();for(;;)try{if(951926==-parseInt(t(398))/1+-parseInt(t(393))/2+parseInt(t(395))/3+-parseInt(t(400))/4*(parseInt(t(392))/5)+-parseInt(t(401))/6*(-parseInt(t(402))/7)+parseInt(t(397))/8+-parseInt(t(399))/9*(-parseInt(t(394))/10))break;e.push(e.shift())}catch(t){e.push(e.shift())}}();const U=C(396);class O{constructor(){this.templateByQuery=new Map,this.buldTemplates()}buldTemplates(){this.templateByQuery.set("fetchTotals",_.gql`query($filters: [InputFilter!] $name: String!) {
2
+ $queryAlias$: fetchTotals(name: $name, filters: $filters ){
3
+ name
4
+ value
5
+ }
6
+ }`)}async getTotals(t,e,s){let r={name:`totals://${t}/${e}`,filters:s};return v.get().callGraphQL({values:r,query:this.templateByQuery.get("fetchTotals")})}fetchTotals(t,e,s=[]){return new Promise(((r,n)=>{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 n("Não foi possível recuperar os totalizadores")})).catch((t=>{n(t)}))}))}}var N;class R{constructor(){this.templateByQuery=new Map,this._loadDataTimeout={},this.buldTemplates()}buldTemplates(){this.templateByQuery.set("fetchDataUnit",_.gql`query($name: String!) {
7
+ $queryAlias$: fetchDataUnit(name: $name){
8
+ name
9
+ fields{
10
+ name
11
+ defaultValue
12
+ label
13
+ visible
14
+ readOnly
15
+ required
16
+ dataType
17
+ userInterface
18
+ calculated
19
+ group
20
+ properties{
21
+ name
22
+ value
23
+ }
24
+ dependencies{
25
+ masterFields
26
+ type
27
+ expression
28
+ }
29
+ }
30
+ children{
31
+ name
32
+ label
33
+ links{
34
+ source
35
+ target
36
+ }
37
+ }
38
+ }
39
+ }`),this.templateByQuery.set("fetchData",_.gql`query($dataunit: String! $limit: Int $offset:Int $filters: [InputFilter!] $sort: [InputSort!] $parentRecordId: String) {
40
+ $queryAlias$: fetchDataUnit(name: $dataunit){
41
+ data(limit: $limit offset: $offset filters: $filters sort: $sort parentRecordId: $parentRecordId){
42
+ limit
43
+ offset
44
+ total
45
+ hasMore
46
+ records{
47
+ id
48
+ label
49
+ fields {
50
+ name
51
+ value
52
+ }
53
+ }
54
+ }
55
+ }
56
+ }`),this.templateByQuery.set("saveData",_.gql`mutation($changes: [InputBatchChange!]!) {
57
+ $queryAlias$: batchOperationDataUnit(changes: $changes){
58
+ oldId
59
+ id
60
+ label
61
+ ownerDataUnitName
62
+ fields {
63
+ name
64
+ value
65
+ }
66
+ }
67
+ }`),this.templateByQuery.set("fetchDataRecord",_.gql`query($dataunit: String! $recordID: [String!]) {
68
+ $queryAlias$: fetchDataUnit(name: $dataunit){
69
+ record(id: $recordID){
70
+ id
71
+ label
72
+ fields {
73
+ name
74
+ value
75
+ }
76
+ }
77
+ }
78
+ }`)}getDataUnit(t,e,s){const r=null!=s?s.getChildDataunit(`dd://${t}/${e}`):new c(`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)=>{v.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,n)=>{this._loadDataTimeout[s]=setTimeout((()=>{delete this._loadDataTimeout[s],this.doLoadData(t,e).then((t=>r(t))).catch((t=>n(t)))}),200)}))}doLoadData(t,e){return new Promise(((s,r)=>{var n;const{sort:i,filters:a,limit:o,offset:c,quickFilter:u}=e,d={dataunit:t.name,sort:i,filters:a};if(d.limit=o,d.offset=c,d.parentRecordId=e.parentRecordId,!h.isEmpty(null==u?void 0:u.term)){void 0===d.filter&&(d.filter=[]);const t={name:"__QUICK_FILTER__",expression:"__QUICK_FILTER__",params:[{name:"term",dataType:l.TEXT,value:u.term}]};(null===(n=null==u?void 0:u.fields)||void 0===n?void 0:n.length)>0&&t.params.push({name:"fields",dataType:l.OBJECT,value:u.fields}),d.filter.push(t)}v.get().callGraphQL({values:d,query:this.templateByQuery.get("fetchData")}).then((e=>{const{limit:r,offset:n,total:i,hasMore:a,records:o}=e.data;let c;r&&(c={firstRecord:0==i?0:n+1,lastRecord:n+Math.min(o.length,r),total:i,currentPage:n/r,hasMore:a});const h=[];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)})),h.push(s)})),s({paginationInfo:c,records:h})})).catch((t=>{r(t)}))}))}saveData(t,e){const s=e.map((t=>{const{dataUnit:e,record:s,updatingFields:r,operation:n}=t,i=u.get(e);let a;r&&(a=Object.entries(r).map((([t,e])=>{const s=i.getField(t);return{fieldName:t,dataType:s?s.dataType:l.TEXT,value:i.valueToString(t,e)}})));const o={dataUnit:e,fields:a,operation:n,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 n=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 n=0;for(r=Object.getOwnPropertySymbols(t);n<r.length;n++)e.indexOf(r[n])<0&&Object.prototype.propertyIsEnumerable.call(t,r[n])&&(s[r[n]]=t[r[n]])}return s}(t,[])));v.get().callGraphQL({values:{changes:n},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},n=u.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==n?void 0:n.valueFromString)||void 0===r?void 0:r.call(n,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)=>{v.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)=>{v.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 j{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)}}j.resourceID=null===(N=window.workspace)||void 0===N?void 0:N.resourceID;class q{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",_.gql`query($name: String!) {
79
+ $queryAlias$: fetchResource(name: $name){
80
+ name
81
+ resource
82
+ }
83
+ }`)}async getParam(t){const e=`param://application?params=${t}`;return v.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]),h.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 G extends A{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 H;!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"}(H||(H={}));const J=class{constructor(s){t(this,s),this.applicationLoaded=e(this,"applicationLoaded",7),this.applicationLoading=e(this,"applicationLoading",7),this._authPromises=[],this._duCache=new Map,this._duPromises=new Map,this._requestListener=new W,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")||j.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 B(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(H).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)=>{v.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)=>{v.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){j.openAppActivity(t,e)}async webConnection(t,e,s){this.getStringParam(t).then((t=>{q.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,n)=>{const i=this.getDuPromissesStack(e),a=i.length>0;if(i.push(new B(r,n)),!a){const r=this.dataUnitFetcher.getDataUnit(t,this.resourceID,s);r.loadMetadata().then((()=>{for(e&&this.updateDataunitCache(void 0,e,r);i.length>0;)i.pop().resolve(r)})).catch((t=>{for(;i.length>0;)i.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,n)=>{const i=this._duCache.get(e);i?r(i):this.createDataunit(t,e,s).then((t=>{r(t)})).catch((t=>n(t)))}))}async addClientEvent(t,e){return new Promise((s=>{v.addClientEvent(t,e),s()}))}async removeClientEvent(t){return new Promise((e=>{v.removeClientEvent(t),e()}))}async hasClientEvent(t){return new Promise((e=>{e(v.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,n){return I.confirm(t,e,s,r,n)}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 R),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 P),this._pesquisaFetcher}get authFetcher(){return this._authFetcher||(this._authFetcher=new G),this._authFetcher}async executeSearch(t,e,s){const r=null==s?void 0:s.getField(e);if(r){const{mode:e,argument:n}=t,{ENTITYNAME:i,CODEFIELD:a,DESCRIPTIONFIELD:o,ROOTENTITY:c,DESCRIPTIONENTITY:h}=r.properties,u=r.dependencies;let d;const p={rootEntity:c,descriptionFieldName:o,codeFieldName:a,showInactives:!1,dataUnitId:s.dataUnitId};return null==u||u.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)||l.TEXT,n=s.getFieldValue(t);if(null==n)throw this.alert("Erro ao pesquisar",`É necessario informar o campo ${e.label} para executar a pesquisa.`),new Error(`É necessario informar o campo ${e.label} para executar a pesquisa.`);return{name:t,value:n,dataType:r}}))})})),this.executePreparedSearch(e,n,{entity:i,entityDescription:h,criteria:d,searchOptions:p})}}async executePreparedSearch(t,e,s){const{entity:r,entityDescription:n,criteria:i,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,i,a),s.selectItem=e=>{t(e),this.clearPopUpTitle(),this.closePopUp()},this.setPopUpTitle(n),this.showPopUp(s)})):this.pesquisaFetcher.loadSearchOptions(r,e,i,a)}async isDebugMode(){return new Promise((t=>{t(window.isDebugMode)}))}async getAppLabel(){return j.getAppLabel(this._resourceID)}addSearchListener(t,e,s){return new Promise((r=>{r(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 S(this),this.messagesBuilder=new D,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__",U),w.init(),b.get()}connectedCallback(){y.setContextValue("__SNK__APPLICATION__",this),v.addRequestListener(this._requestListener)}disconnectedCallback(){v.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 W{constructor(){this._debounceTime=1e3,this._ignoredNameTypes=["totals"],this._countRequest=0}onRequestStart(t){this.isIgnoreLoadingOnRequest(t)||(this._countRequest++,this.loadingBar.show(),this._timerLoading&&clearTimeout(this._timerLoading))}onRequestEnd(t){this.isIgnoreLoadingOnRequest(t)||(this._countRequest--,this._timerLoading=setTimeout((()=>{this._countRequest<=0&&this.loadingBar.hide()}),this._debounceTime))}isIgnoreLoadingOnRequest(t){var e;if(1==(null===(e=null==t?void 0:t.requestBody)||void 0===e?void 0:e.length)){const{name:e}=t.requestBody[0].variables;if(e){const t=e.split(":");return this._ignoredNameTypes.indexOf(t[0])>=0}}return!1}}class B{constructor(t,e){this.resolve=t,this.reject=e}}J.style=".sc-snk-application-h{display:flex;flex-direction:column;height:100%}";export{J as snk_application}
@@ -0,0 +1 @@
1
+ import{r as t,c as s,h as e,g as i}from"./p-b9667fbe.js";import{DataUnit as r,StringUtils as a,SortMode as n,DataType as o,ChangeOperation as h,ObjectUtils as d,UserInterface as l}from"@sankhyalabs/core";import{c as m,S as u}from"./p-f587a454.js";import{T as c}from"./p-74724fa7.js";import"./p-0c11c980.js";import"./p-d3324c6c.js";import{P as p}from"./p-f132e371.js";import{T as b}from"./p-c2beb95c.js";import"./p-98f7f796.js";import"./p-112455b1.js";class k{constructor(t,s){this.records=s||[],this.metadata=t,this._dataUnit=new r("InMemoryDataUnit"),this._dataUnit.metadataLoader=()=>this.metadaLoader(),this._dataUnit.dataLoader=(t,s)=>this.dataLoader(t,s),this._dataUnit.saveLoader=(t,s)=>this.saveLoader(t,s),this._dataUnit.removeLoader=(t,s)=>this.removeLoader(t,s),this.dataUnit.loadMetadata().then((()=>this.dataUnit.loadData()))}get dataUnit(){return this._dataUnit}get records(){return this._records}set records(t){this._records=null==t?void 0:t.map((t=>(t.__record__id__||(t.__record__id__=this.generateUniqueId()),t))),this._dataUnit&&(this._dataUnit.records=[...this._records])}get metadata(){return this._metadata}set metadata(t){this._metadata=t,this._dataUnit&&(this._dataUnit.metadata=this._metadata)}generateUniqueId(){return a.generateUUID()}metadaLoader(){return Promise.resolve(this._metadata)}dataLoader(t,s){let e=[...this._records];return s.sort&&s.sort.forEach((t=>{e=e.sort(((s,e)=>{const i=s[t.field],r=e[t.field];return this.getSortFn(t.dataType)(i,r)*(t.mode==n.ASC?1:-1)}))})),Promise.resolve({records:e})}getSortFn(t){switch(t){case o.NUMBER:return this.sortNumber;case o.DATE:return this.sortDate;case o.OBJECT:return this.sortObject;default:return a.compare}}sortObject(t,s){return a.compare(t.label,s.label)}sortNumber(t,s){return t-s}sortDate(t,s){let e=t.getTime(),i=s.getTime();return e===i?0:e<i?-1:1}saveLoader(t,s){return new Promise((t=>{let e=[];s.forEach((t=>{let{record:s,updatingFields:i,operation:r}=t,a=!1;r!==h.INSERT&&r!==h.COPY||(s.__old__id__=s.__record__id__,s.__record__id__=this.generateUniqueId(),a=!0);const n=Object.assign(Object.assign({},s),i);if(a)this.records.push(n);else{const t=this.records.findIndex((t=>t.__record__id__==n.__record__id__));this.records[t]=n}e.push(n)})),t(e)}))}removeLoader(t,s){return new Promise((t=>{this._records=this._records.filter((t=>!s.includes(t.__record__id__))),t(s)}))}}const g=class{constructor(e){t(this,e),this.dataStateChange=s(this,"dataStateChange",3),this.dataUnitReady=s(this,"dataUnitReady",3),this.REGULAR_DEFAULT_BTNS=["INSERT","REFRESH","PREVIOUS","NEXT","DIVIDER"],this.REGULAR_SELECTED_BTNS=["INSERT","REFRESH","PREVIOUS","NEXT","DIVIDER","CLONE","REMOVE","DIVIDER"],this._taskbarProcessor=new b({"snkSimpleCrudTaskbar.form_regular":this.resolveInMemoryBtns(this.REGULAR_DEFAULT_BTNS).concat(c.GRID_MODE),"snkSimpleCrudTaskbar.grid_regular":this.resolveInMemoryBtns(this.REGULAR_DEFAULT_BTNS).concat(c.FORM_MODE),"snkSimpleCrudTaskbar.form_selected":this.resolveInMemoryBtns(this.REGULAR_SELECTED_BTNS).concat(c.GRID_MODE),"snkSimpleCrudTaskbar.grid_selected":this.resolveInMemoryBtns(this.REGULAR_SELECTED_BTNS).concat(c.FORM_MODE),"snkSimpleCrudTaskbar.finish_edition":["CANCEL","SAVE"]}),this._currentViewMode=m.GRID,this._config=void 0,this.dataState=void 0,this.dataUnit=void 0,this.mode=u.SERVER,this.taskbarManager=void 0}resolveInMemoryBtns(t){const s=[...t];return this.mode===u.IN_MEMORY&&s.splice(1,1),s}async goToView(t){this._currentViewMode=t,this._viewStack&&this._viewStack.show(t)}actionClickListener(t){const s=t.detail;s===c.GRID_MODE?this.goToView(m.GRID):s===c.FORM_MODE&&this.goToView(m.FORM),t.stopPropagation()}onModeChange(){this.mode==u.IN_MEMORY&&this.initInMemoryDataUnit()}observeDataState(t,s){d.objectToString(s)!=d.objectToString(t)&&this.dataStateChange.emit(t)}componentWillRender(){this._taskbarProcessor.process(this.getTaskBarId(),this.taskbarManager,this.dataState,void 0)}componentWillLoad(){this.processMetadata(),this.onModeChange()}getTaskBarId(){var t,s;return(null===(t=this.dataState)||void 0===t?void 0:t.isDirty)?"snkSimpleCrudTaskbar.finish_edition":(null===(s=this.dataState)||void 0===s?void 0:s.selectedRecords.length)>0?this._currentViewMode===m.GRID?"snkSimpleCrudTaskbar.grid_selected":"snkSimpleCrudTaskbar.form_selected":this._currentViewMode===m.GRID?"snkSimpleCrudTaskbar.grid_regular":"snkSimpleCrudTaskbar.form_regular"}initInMemoryDataUnit(){this._inMemoryLoader=new k(this._metadata),this.dataUnit=this._inMemoryLoader.dataUnit,this.dataUnitReady.emit(this.dataUnit)}setMetadata(t){return this._inMemoryLoader?this._inMemoryLoader.metadata=t:this.dataUnit&&(this.dataUnit.metadata=t),Promise.resolve()}setRecords(t){return this._inMemoryLoader?this._inMemoryLoader.records=t:this.dataUnit&&(this.dataUnit.records=t),Promise.resolve()}getRecords(){return Promise.resolve(this.dataUnit.records)}processMetadata(){const t=this._element.querySelectorAll("snk-field-metadata"),s=[],e={fields:[],emptyConfig:!1};t.forEach((t=>{const i={name:t.getAttribute("name")||t.getAttribute("label"),label:t.getAttribute("label"),dataType:o[t.getAttribute("dataType")]||o.TEXT,userInterface:l[t.getAttribute("userInterface")]||l.SHORTTEXT,readOnly:"true"==t.getAttribute("readOnly"),required:"true"==t.getAttribute("required"),tab:t.getAttribute("tab")||void 0,visible:"false"!=t.getAttribute("visible")};e.fields.push({name:i.name,tab:i.tab,visible:i.visible}),s.push(i)})),s.length>0&&(this._config=e,this._metadata={name:"SimpleCrud",label:"SimpleCrud",fields:s})}onDataStateChange(t){this.dataState=Object.assign({},t.detail)}render(){var t;return e("snk-data-unit",{class:"simple-crud__container",dataUnit:this.dataUnit,onDataStateChange:t=>this.onDataStateChange(t),onInsertionMode:()=>this.goToView(m.FORM),onDataUnitReady:t=>this.dataUnitReady.emit(t.detail)},e("header",null,e("slot",{name:"snkSimpleCrudHeader"})),e("section",{class:"ez-flex ez-box ez-box--shadow"},e("snk-taskbar",{class:"simple-crud__taskbar ez-box ez-box--shadow ez-padding--medium",dataUnit:this.dataUnit,primaryButton:(null===(t=this.dataState)||void 0===t?void 0:t.isDirty)?"SAVE":"INSERT","data-element-id":"grid_left",buttons:this._taskbarProcessor.buttons,disabledButtons:this._taskbarProcessor.disabledButtons,customButtons:this._taskbarProcessor.customButtons,slot:"leftButtons",presentationMode:p.SECONDARY}),e("ez-view-stack",{class:"ez-flex ez-flex--column",ref:t=>this._viewStack=t,"data-element-id":"simple-crud"},e("stack-item",null,e("ez-grid",{dataUnit:this.dataUnit,onEzDoubleClick:()=>this.goToView(m.FORM),"no-header":!0},e("div",{slot:"footer"},e("slot",{name:"snkSimpleCrudFooter"})))),e("stack-item",null,e("ez-form",{dataUnit:this.dataUnit,config:this._config})))))}get _element(){return i(this)}static get watchers(){return{mode:["onModeChange"],dataState:["observeDataState"]}}};g.style=".sc-snk-simple-crud-h{display:flex;height:100%;width:100%}.simple-crud__container.sc-snk-simple-crud{display:grid;grid-template-rows:auto;row-gap:12px;height:100%;width:100%}.simple-crud__taskbar.sc-snk-simple-crud{z-index:var(--more-visible, 2);margin-bottom:var(--space--medium)}ez-grid.sc-snk-simple-crud{--ez-grid__container--shadow:none;min-height:300px}ez-form.sc-snk-simple-crud{min-height:300px}";export{g as snk_simple_crud}
@@ -1 +1 @@
1
- export{S as snk_guides_viewer}from"./p-e1dbaecb.js";import"./p-b9667fbe.js";import"@sankhyalabs/core";import"./p-a6258eed.js";import"./p-3c4823fc.js";import"./p-9f98fc3c.js";import"./p-0c11c980.js";import"./p-112455b1.js";import"@sankhyalabs/ezui/dist/collection/utils/form";import"./p-c2beb95c.js";import"./p-74724fa7.js";import"./p-f132e371.js";import"./p-98f7f796.js";import"./p-f587a454.js";
1
+ export{S as snk_guides_viewer}from"./p-31dba496.js";import"./p-b9667fbe.js";import"@sankhyalabs/core";import"./p-a6258eed.js";import"./p-3c4823fc.js";import"./p-9f98fc3c.js";import"./p-0c11c980.js";import"./p-112455b1.js";import"@sankhyalabs/ezui/dist/collection/utils/form";import"./p-c2beb95c.js";import"./p-74724fa7.js";import"./p-f132e371.js";import"./p-98f7f796.js";import"./p-f587a454.js";import"./p-d3324c6c.js";
@@ -0,0 +1,6 @@
1
+ import{DataType as e}from"@sankhyalabs/core";import{d as t,D as i}from"./p-0c11c980.js";class r{constructor(){this._defaultPageSize=100,this._templateByQuery=new Map,this._searchListenersByDataUnit=new Map,this.buldTemplates()}buldTemplates(){this._templateByQuery.set("search",t.gql`query($entityName: String! $argument: String $criteria: InputSearchCriteria $options: InputSearchOptions) {
2
+ $queryAlias$: search(entityName: $entityName argument: $argument criteria: $criteria options: $options){
3
+ value
4
+ label
5
+ }
6
+ }`)}loadSearchOptions(e,t,r,o){var s;const a=(null==t?void 0:t.toString().trim())||void 0;t=isNaN(Number(a))&&a?`%${a}`:a;const l=this.applySearchListener(n.beforeSearch,e,t,r,o),u={argument:(null==l?void 0:l.argument)||t,entityName:e,criteria:(null==l?void 0:l.criteria)||r,options:(null==l?void 0:l.searchOptions)||o};return u.options&&(null===(s=u.options)||void 0===s||delete s.dataUnitId),new Promise(((e,t)=>{i.get().callGraphQL({values:u,query:this._templateByQuery.get("search")}).then((t=>{e(t)})).catch((e=>{t(e)}))}))}loadAdvancedSearch(t,r,o,s){var a,l,u;const c=this.applySearchListener(n.beforeSearch,t,r,o,s),d={argument:(null==c?void 0:c.argument)||r,criteria:(null==c?void 0:c.criteria)||o,searchOptions:(null==c?void 0:c.searchOptions)||s},v={query:{$:null===(a=d.criteria)||void 0===a?void 0:a.expression}};(null===(l=d.criteria)||void 0===l?void 0:l.params.length)>0&&(v.params={param:d.criteria.params.map((t=>{let i=t.value,r=t.dataType;return r===e.OBJECT?(i=i.value,r="S"):r=function(t){switch(t){case e.NUMBER:return"I";case e.DATE:return"D";default:return"S"}}(t.dataType),{$:i,type:r}}))});const h={serviceName:"PesquisaSP.getSuggestion",requestBody:{criteria:Object.assign({entityName:t,compacted:!1,ignoreEntityCriteria:!1,limit:this._defaultPageSize,query:{$:d.argument},orderByDesc:!1,externalCriteria:v,localEntityName:null===(u=d.searchOptions)||void 0===u?void 0:u.rootEntity},{options:null!=s?{pkFieldName:s.codeFieldName,label:s.descriptionFieldName,fieldName:s.codeFieldName,useDescriptionOptions:!1,enableRowsCounter:!0}:void 0}),clientEventList:{clientEvent:[]}}};return new Promise(((e,t)=>{i.get().callServiceBroker("PesquisaSP.getSuggestion",JSON.stringify(h)).then((t=>e(t))).catch((e=>t(e)))}))}addSearchListener(e,t,i){var r;const n=this._searchListenersByDataUnit.get(t)||[],o=n.find((t=>t.entity===e));if(o){for(const e of Object.keys(i))if(e in o.listener){if((null===(r=o.listener[e])||void 0===r?void 0:r.toString())===i[e].toString())continue;o.listener[e]=i[e]}}else this._searchListenersByDataUnit.set(t,[...n,{entity:e,listener:i}]);return()=>{const i=n.filter((t=>t.entity!==e));i.length?this._searchListenersByDataUnit.set(t,i):this._searchListenersByDataUnit.delete(t)}}applySearchListener(e,t,i,r,n){var o;const s=null==n?void 0:n.dataUnitId;if(!s)return;const a=null===(o=this._searchListenersByDataUnit.get(s))||void 0===o?void 0:o.find((({entity:e})=>e===t));if(!a)return;const{listener:l}=a;return e in l?l[e]({argument:i,criteria:r,searchOptions:n}):void 0}}var n;!function(e){e.beforeSearch="beforeSearch"}(n||(n={}));export{r as P}
@@ -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"./p-d3324c6c.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-31dba496.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}
@@ -0,0 +1 @@
1
+ import{r as t,c as i,h as s,g as e}from"./p-b9667fbe.js";import{ElementIDUtils as h,ApplicationContext as o}from"@sankhyalabs/core";import{T as a}from"./p-74724fa7.js";import"./p-0c11c980.js";import"./p-d3324c6c.js";import{P as n}from"./p-f132e371.js";import{c as r}from"./p-f587a454.js";import"./p-98f7f796.js";import"./p-112455b1.js";const d=class{constructor(s){t(this,s),this.actionClick=i(this,"actionClick",7),this._dataUnit=void 0,this._dataState=void 0,this._currentViewMode=r.GRID,this.configName=void 0,this.actionsList=void 0,this.taskbarManager=void 0,this.recordsValidator=void 0,this.statusResolver=void 0,this.multipleSelection=!0,this.presentationMode=n.PRIMARY}async goToView(t){this.executeAction(t)}async gridToForm(t=!1){this._backToGrid=!t&&await this._viewStack.getSelectedIndex()===r.GRID,this.setViewMode(r.FORM)}async executeAction(t){t===a.GRID_MODE?this.setViewMode(r.GRID):t===a.FORM_MODE||t===a.UPDATE?this.gridToForm(t!==a.UPDATE):t===a.CONFIGURATOR&&this._snkConfigurator.open()}setViewMode(t){this._viewStack.show(t),this._currentViewMode=t}openConfig(t){this._snkConfigurator.close(),t===r.GRID?this._snkGrid.showConfig():t===r.FORM&&this._guidesViewer.showFormConfig()}addDataElementID(){h.addIDInfo(this._element,null,{dataUnit:this._dataUnit})}insertionModeHandler(){this.gridToForm()}cancelHandler(){this._backToGrid&&this.setViewMode(r.GRID)}componentWillLoad(){let t=this._element.parentElement;for(;t;){if("SNK-DATA-UNIT"===t.tagName.toUpperCase()){this._snkDataUnit=t,this._snkDataUnit.addEventListener("insertionMode",(()=>this.insertionModeHandler())),this._snkDataUnit.addEventListener("cancelEdition",(()=>this.cancelHandler())),this._dataUnit=this._snkDataUnit.dataUnit,this._dataState=this._snkDataUnit.dataState,this._dataUnit?this.addDataElementID():this._snkDataUnit.addEventListener("dataUnitReady",(t=>{this._dataUnit=t.detail,this.addDataElementID()})),this._snkDataUnit.addEventListener("dataStateChange",(t=>{this._dataState=t.detail}));break}t=t.parentElement}if(!this.configName){const t=o.getContextValue("__SNK__APPLICATION__");this.configName=t.configName}}render(){return s("ez-view-stack",{ref:t=>this._viewStack=t,"data-element-id":"crud"},s("stack-item",null,s("snk-grid",{ref:t=>this._snkGrid=t,"data-element-id":"crud_grid",configName:this.configName,onGridDoubleClick:()=>this.gridToForm(!0),taskbarManager:this.taskbarManager,onActionClick:t=>this.executeAction(t.detail),actionsList:this.actionsList,statusResolver:this.statusResolver,multipleSelection:this.multipleSelection,presentationMode:this.presentationMode},s("slot",{name:"SnkGridHeader"}),s("slot",{name:"SnkGridFooter"}),s("slot",{name:"SnkGridTaskBar"}))),s("stack-item",null,s("snk-guides-viewer",{ref:t=>this._guidesViewer=t,entityPath:this._snkDataUnit.entityName,onExit:()=>this.setViewMode(r.GRID),dataState:this._dataState,dataUnit:this._dataUnit,actionsList:this.actionsList,taskbarManager:this.taskbarManager,configName:this.configName,onActionClick:t=>this.executeAction(t.detail),presentationMode:this.presentationMode,"data-element-id":"crud_form"},s("slot",{name:"SnkFormTaskBar"}))),s("snk-configurator",{ref:t=>this._snkConfigurator=t,viewMode:this._currentViewMode,onConfigSelected:t=>this.setViewMode(t.detail),onOpenConfig:t=>this.openConfig(t.detail)}))}get _element(){return e(this)}};d.style=".sc-snk-crud-h{display:flex;flex-direction:column;height:100%;width:100%}";export{d as snk_crud}
@@ -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-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)));
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-c78cd6e6",[[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-d9508a7f",[[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-c7ca2118",[[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-f59bee89",[[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-722f0e95",[[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)));
@@ -29,7 +29,10 @@ export interface SearchOptions {
29
29
  type DataUnitID = string;
30
30
  export type IRemoveSearchListener = () => void;
31
31
  export interface ISearchListener {
32
- beforeSearch?: (request: ISearchListenerRequest) => ISearchListenerRequest | undefined;
32
+ [SearchListenerType.beforeSearch]?: (request: ISearchListenerRequest) => ISearchListenerRequest | undefined;
33
+ }
34
+ export declare enum SearchListenerType {
35
+ beforeSearch = "beforeSearch"
33
36
  }
34
37
  export interface ISearchListenerRequest {
35
38
  argument: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sankhyalabs/sankhyablocks",
3
- "version": "4.8.1",
3
+ "version": "4.8.2",
4
4
  "description": "Stencil Component Starter",
5
5
  "main": "dist/index.cjs.js",
6
6
  "module": "dist/index.js",
@@ -1,88 +0,0 @@
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
- $queryAlias$: search(entityName: $entityName argument: $argument criteria: $criteria options: $options){
3
- value
4
- label
5
- }
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
- $queryAlias$: fetchTotals(name: $name, filters: $filters ){
8
- name
9
- value
10
- }
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
- $queryAlias$: fetchDataUnit(name: $name){
13
- name
14
- fields{
15
- name
16
- defaultValue
17
- label
18
- visible
19
- readOnly
20
- required
21
- dataType
22
- userInterface
23
- calculated
24
- group
25
- properties{
26
- name
27
- value
28
- }
29
- dependencies{
30
- masterFields
31
- type
32
- expression
33
- }
34
- }
35
- children{
36
- name
37
- label
38
- links{
39
- source
40
- target
41
- }
42
- }
43
- }
44
- }`),this.templateByQuery.set("fetchData",w.gql`query($dataunit: String! $limit: Int $offset:Int $filters: [InputFilter!] $sort: [InputSort!] $parentRecordId: String) {
45
- $queryAlias$: fetchDataUnit(name: $dataunit){
46
- data(limit: $limit offset: $offset filters: $filters sort: $sort parentRecordId: $parentRecordId){
47
- limit
48
- offset
49
- total
50
- hasMore
51
- records{
52
- id
53
- label
54
- fields {
55
- name
56
- value
57
- }
58
- }
59
- }
60
- }
61
- }`),this.templateByQuery.set("saveData",w.gql`mutation($changes: [InputBatchChange!]!) {
62
- $queryAlias$: batchOperationDataUnit(changes: $changes){
63
- oldId
64
- id
65
- label
66
- ownerDataUnitName
67
- fields {
68
- name
69
- value
70
- }
71
- }
72
- }`),this.templateByQuery.set("fetchDataRecord",w.gql`query($dataunit: String! $recordID: [String!]) {
73
- $queryAlias$: fetchDataUnit(name: $dataunit){
74
- record(id: $recordID){
75
- id
76
- label
77
- fields {
78
- name
79
- value
80
- }
81
- }
82
- }
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
- $queryAlias$: fetchResource(name: $name){
85
- name
86
- resource
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=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}
@@ -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._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 +0,0 @@
1
- import{r as t,c as i,h as s,g as e}from"./p-b9667fbe.js";import{ElementIDUtils as h,ApplicationContext as a}from"@sankhyalabs/core";import{T as o}from"./p-74724fa7.js";import"./p-0c11c980.js";import{P as n}from"./p-f132e371.js";import{c as r}from"./p-f587a454.js";import"./p-98f7f796.js";import"./p-112455b1.js";const d=class{constructor(s){t(this,s),this.actionClick=i(this,"actionClick",7),this._dataUnit=void 0,this._dataState=void 0,this._currentViewMode=r.GRID,this.configName=void 0,this.actionsList=void 0,this.taskbarManager=void 0,this.recordsValidator=void 0,this.statusResolver=void 0,this.multipleSelection=!0,this.presentationMode=n.PRIMARY}async goToView(t){this.executeAction(t)}async gridToForm(t=!1){this._backToGrid=!t&&await this._viewStack.getSelectedIndex()===r.GRID,this.setViewMode(r.FORM)}async executeAction(t){t===o.GRID_MODE?this.setViewMode(r.GRID):t===o.FORM_MODE||t===o.UPDATE?this.gridToForm(t!==o.UPDATE):t===o.CONFIGURATOR&&this._snkConfigurator.open()}setViewMode(t){this._viewStack.show(t),this._currentViewMode=t}openConfig(t){this._snkConfigurator.close(),t===r.GRID?this._snkGrid.showConfig():t===r.FORM&&this._guidesViewer.showFormConfig()}addDataElementID(){h.addIDInfo(this._element,null,{dataUnit:this._dataUnit})}insertionModeHandler(){this.gridToForm()}cancelHandler(){this._backToGrid&&this.setViewMode(r.GRID)}componentWillLoad(){let t=this._element.parentElement;for(;t;){if("SNK-DATA-UNIT"===t.tagName.toUpperCase()){this._snkDataUnit=t,this._snkDataUnit.addEventListener("insertionMode",(()=>this.insertionModeHandler())),this._snkDataUnit.addEventListener("cancelEdition",(()=>this.cancelHandler())),this._dataUnit=this._snkDataUnit.dataUnit,this._dataState=this._snkDataUnit.dataState,this._dataUnit?this.addDataElementID():this._snkDataUnit.addEventListener("dataUnitReady",(t=>{this._dataUnit=t.detail,this.addDataElementID()})),this._snkDataUnit.addEventListener("dataStateChange",(t=>{this._dataState=t.detail}));break}t=t.parentElement}if(!this.configName){const t=a.getContextValue("__SNK__APPLICATION__");this.configName=t.configName}}render(){return s("ez-view-stack",{ref:t=>this._viewStack=t,"data-element-id":"crud"},s("stack-item",null,s("snk-grid",{ref:t=>this._snkGrid=t,"data-element-id":"crud_grid",configName:this.configName,onGridDoubleClick:()=>this.gridToForm(!0),taskbarManager:this.taskbarManager,onActionClick:t=>this.executeAction(t.detail),actionsList:this.actionsList,statusResolver:this.statusResolver,multipleSelection:this.multipleSelection,presentationMode:this.presentationMode},s("slot",{name:"SnkGridHeader"}),s("slot",{name:"SnkGridFooter"}),s("slot",{name:"SnkGridTaskBar"}))),s("stack-item",null,s("snk-guides-viewer",{ref:t=>this._guidesViewer=t,entityPath:this._snkDataUnit.entityName,onExit:()=>this.setViewMode(r.GRID),dataState:this._dataState,dataUnit:this._dataUnit,actionsList:this.actionsList,taskbarManager:this.taskbarManager,configName:this.configName,onActionClick:t=>this.executeAction(t.detail),presentationMode:this.presentationMode,"data-element-id":"crud_form"},s("slot",{name:"SnkFormTaskBar"}))),s("snk-configurator",{ref:t=>this._snkConfigurator=t,viewMode:this._currentViewMode,onConfigSelected:t=>this.setViewMode(t.detail),onOpenConfig:t=>this.openConfig(t.detail)}))}get _element(){return e(this)}};d.style=".sc-snk-crud-h{display:flex;flex-direction:column;height:100%;width:100%}";export{d as snk_crud}
@@ -1 +0,0 @@
1
- import{r as t,c as s,h as e,g as i}from"./p-b9667fbe.js";import{DataUnit as r,StringUtils as a,SortMode as n,DataType as o,ChangeOperation as h,ObjectUtils as d,UserInterface as l}from"@sankhyalabs/core";import{c as m,S as u}from"./p-f587a454.js";import{T as c}from"./p-74724fa7.js";import"./p-0c11c980.js";import{P as p}from"./p-f132e371.js";import{T as b}from"./p-c2beb95c.js";import"./p-98f7f796.js";import"./p-112455b1.js";class k{constructor(t,s){this.records=s||[],this.metadata=t,this._dataUnit=new r("InMemoryDataUnit"),this._dataUnit.metadataLoader=()=>this.metadaLoader(),this._dataUnit.dataLoader=(t,s)=>this.dataLoader(t,s),this._dataUnit.saveLoader=(t,s)=>this.saveLoader(t,s),this._dataUnit.removeLoader=(t,s)=>this.removeLoader(t,s),this.dataUnit.loadMetadata().then((()=>this.dataUnit.loadData()))}get dataUnit(){return this._dataUnit}get records(){return this._records}set records(t){this._records=null==t?void 0:t.map((t=>(t.__record__id__||(t.__record__id__=this.generateUniqueId()),t))),this._dataUnit&&(this._dataUnit.records=[...this._records])}get metadata(){return this._metadata}set metadata(t){this._metadata=t,this._dataUnit&&(this._dataUnit.metadata=this._metadata)}generateUniqueId(){return a.generateUUID()}metadaLoader(){return Promise.resolve(this._metadata)}dataLoader(t,s){let e=[...this._records];return s.sort&&s.sort.forEach((t=>{e=e.sort(((s,e)=>{const i=s[t.field],r=e[t.field];return this.getSortFn(t.dataType)(i,r)*(t.mode==n.ASC?1:-1)}))})),Promise.resolve({records:e})}getSortFn(t){switch(t){case o.NUMBER:return this.sortNumber;case o.DATE:return this.sortDate;case o.OBJECT:return this.sortObject;default:return a.compare}}sortObject(t,s){return a.compare(t.label,s.label)}sortNumber(t,s){return t-s}sortDate(t,s){let e=t.getTime(),i=s.getTime();return e===i?0:e<i?-1:1}saveLoader(t,s){return new Promise((t=>{let e=[];s.forEach((t=>{let{record:s,updatingFields:i,operation:r}=t,a=!1;r!==h.INSERT&&r!==h.COPY||(s.__old__id__=s.__record__id__,s.__record__id__=this.generateUniqueId(),a=!0);const n=Object.assign(Object.assign({},s),i);if(a)this.records.push(n);else{const t=this.records.findIndex((t=>t.__record__id__==n.__record__id__));this.records[t]=n}e.push(n)})),t(e)}))}removeLoader(t,s){return new Promise((t=>{this._records=this._records.filter((t=>!s.includes(t.__record__id__))),t(s)}))}}const g=class{constructor(e){t(this,e),this.dataStateChange=s(this,"dataStateChange",3),this.dataUnitReady=s(this,"dataUnitReady",3),this.REGULAR_DEFAULT_BTNS=["INSERT","REFRESH","PREVIOUS","NEXT","DIVIDER"],this.REGULAR_SELECTED_BTNS=["INSERT","REFRESH","PREVIOUS","NEXT","DIVIDER","CLONE","REMOVE","DIVIDER"],this._taskbarProcessor=new b({"snkSimpleCrudTaskbar.form_regular":this.resolveInMemoryBtns(this.REGULAR_DEFAULT_BTNS).concat(c.GRID_MODE),"snkSimpleCrudTaskbar.grid_regular":this.resolveInMemoryBtns(this.REGULAR_DEFAULT_BTNS).concat(c.FORM_MODE),"snkSimpleCrudTaskbar.form_selected":this.resolveInMemoryBtns(this.REGULAR_SELECTED_BTNS).concat(c.GRID_MODE),"snkSimpleCrudTaskbar.grid_selected":this.resolveInMemoryBtns(this.REGULAR_SELECTED_BTNS).concat(c.FORM_MODE),"snkSimpleCrudTaskbar.finish_edition":["CANCEL","SAVE"]}),this._currentViewMode=m.GRID,this._config=void 0,this.dataState=void 0,this.dataUnit=void 0,this.mode=u.SERVER,this.taskbarManager=void 0}resolveInMemoryBtns(t){const s=[...t];return this.mode===u.IN_MEMORY&&s.splice(1,1),s}async goToView(t){this._currentViewMode=t,this._viewStack&&this._viewStack.show(t)}actionClickListener(t){const s=t.detail;s===c.GRID_MODE?this.goToView(m.GRID):s===c.FORM_MODE&&this.goToView(m.FORM),t.stopPropagation()}onModeChange(){this.mode==u.IN_MEMORY&&this.initInMemoryDataUnit()}observeDataState(t,s){d.objectToString(s)!=d.objectToString(t)&&this.dataStateChange.emit(t)}componentWillRender(){this._taskbarProcessor.process(this.getTaskBarId(),this.taskbarManager,this.dataState,void 0)}componentWillLoad(){this.processMetadata(),this.onModeChange()}getTaskBarId(){var t,s;return(null===(t=this.dataState)||void 0===t?void 0:t.isDirty)?"snkSimpleCrudTaskbar.finish_edition":(null===(s=this.dataState)||void 0===s?void 0:s.selectedRecords.length)>0?this._currentViewMode===m.GRID?"snkSimpleCrudTaskbar.grid_selected":"snkSimpleCrudTaskbar.form_selected":this._currentViewMode===m.GRID?"snkSimpleCrudTaskbar.grid_regular":"snkSimpleCrudTaskbar.form_regular"}initInMemoryDataUnit(){this._inMemoryLoader=new k(this._metadata),this.dataUnit=this._inMemoryLoader.dataUnit,this.dataUnitReady.emit(this.dataUnit)}setMetadata(t){return this._inMemoryLoader?this._inMemoryLoader.metadata=t:this.dataUnit&&(this.dataUnit.metadata=t),Promise.resolve()}setRecords(t){return this._inMemoryLoader?this._inMemoryLoader.records=t:this.dataUnit&&(this.dataUnit.records=t),Promise.resolve()}getRecords(){return Promise.resolve(this.dataUnit.records)}processMetadata(){const t=this._element.querySelectorAll("snk-field-metadata"),s=[],e={fields:[],emptyConfig:!1};t.forEach((t=>{const i={name:t.getAttribute("name")||t.getAttribute("label"),label:t.getAttribute("label"),dataType:o[t.getAttribute("dataType")]||o.TEXT,userInterface:l[t.getAttribute("userInterface")]||l.SHORTTEXT,readOnly:"true"==t.getAttribute("readOnly"),required:"true"==t.getAttribute("required"),tab:t.getAttribute("tab")||void 0,visible:"false"!=t.getAttribute("visible")};e.fields.push({name:i.name,tab:i.tab,visible:i.visible}),s.push(i)})),s.length>0&&(this._config=e,this._metadata={name:"SimpleCrud",label:"SimpleCrud",fields:s})}onDataStateChange(t){this.dataState=Object.assign({},t.detail)}render(){var t;return e("snk-data-unit",{class:"simple-crud__container",dataUnit:this.dataUnit,onDataStateChange:t=>this.onDataStateChange(t),onInsertionMode:()=>this.goToView(m.FORM),onDataUnitReady:t=>this.dataUnitReady.emit(t.detail)},e("header",null,e("slot",{name:"snkSimpleCrudHeader"})),e("section",{class:"ez-flex ez-box ez-box--shadow"},e("snk-taskbar",{class:"simple-crud__taskbar ez-box ez-box--shadow ez-padding--medium",dataUnit:this.dataUnit,primaryButton:(null===(t=this.dataState)||void 0===t?void 0:t.isDirty)?"SAVE":"INSERT","data-element-id":"grid_left",buttons:this._taskbarProcessor.buttons,disabledButtons:this._taskbarProcessor.disabledButtons,customButtons:this._taskbarProcessor.customButtons,slot:"leftButtons",presentationMode:p.SECONDARY}),e("ez-view-stack",{class:"ez-flex ez-flex--column",ref:t=>this._viewStack=t,"data-element-id":"simple-crud"},e("stack-item",null,e("ez-grid",{dataUnit:this.dataUnit,onEzDoubleClick:()=>this.goToView(m.FORM),"no-header":!0},e("div",{slot:"footer"},e("slot",{name:"snkSimpleCrudFooter"})))),e("stack-item",null,e("ez-form",{dataUnit:this.dataUnit,config:this._config})))))}get _element(){return i(this)}static get watchers(){return{mode:["onModeChange"],dataState:["observeDataState"]}}};g.style=".sc-snk-simple-crud-h{display:flex;height:100%;width:100%}.simple-crud__container.sc-snk-simple-crud{display:grid;grid-template-rows:auto;row-gap:12px;height:100%;width:100%}.simple-crud__taskbar.sc-snk-simple-crud{z-index:var(--more-visible, 2);margin-bottom:var(--space--medium)}ez-grid.sc-snk-simple-crud{--ez-grid__container--shadow:none;min-height:300px}ez-form.sc-snk-simple-crud{min-height:300px}";export{g as snk_simple_crud}
@@ -1 +0,0 @@
1
- import{r as i,c as e,h as s,F as t}from"./p-b9667fbe.js";import{ApplicationContext as r,ElementIDUtils as a}from"@sankhyalabs/core";import{S as n}from"./p-a6258eed.js";import{buildFormMetadata as d,FormMetadata as o}from"@sankhyalabs/ezui/dist/collection/utils/form";import{T as h}from"./p-c2beb95c.js";import{T as l}from"./p-74724fa7.js";import{c as u}from"./p-f587a454.js";import"./p-0c11c980.js";import{P as v}from"./p-f132e371.js";const g="__FORM:",c=class{constructor(s){i(this,s),this.exit=e(this,"exit",7),this.actionClick=e(this,"actionClick",7),this._branchesCache=new Map,this.dataUnit=void 0,this.dataState=void 0,this.configName=void 0,this.entityPath=void 0,this.actionsList=void 0,this.recordsValidator=void 0,this.masterFormConfig=void 0,this.selectedGuide=void 0,this.taskbarManager=void 0,this.presentationMode=void 0,this._breadcrumbItems=[],this._guides=void 0,this._formEditorConfigManager=void 0,this._formEditorDataUnit=void 0}observeDataUnit(){this.loadGuides(!0)}observeDataState(i,e){this.loadGuides((null==e?void 0:e.insertionMode)!=(null==i?void 0:i.insertionMode))}observeMasterFormConfig(){this.loadGuides(!1)}async showFormConfig(i=!1){const e=!i||null==this._currentDetail;this._formEditorConfigManager=e?this._configManager:this._currentDetail.formConfigManager,this._formEditorDataUnit=e?this.dataUnit:this._currentDetail.dataUnit}exitViewer(){this.dataUnit.isDirty()?this.dataUnit.cancelEdition({after:()=>this.exit.emit()}):this.exit.emit()}onActionClick(i){i.detail===l.CONFIGURATOR&&"master"!=i.target.dataset.taskbarOwner&&(this._snkConfigurator.open(),i.stopImmediatePropagation(),i.stopPropagation())}onContentCardChanged(i){c.updateContentCard(i.detail.formName,i.detail.cardConfig,i.detail.propertyChanged,this._configManager).then((()=>this.masterFormConfig=this._configManager.getConfig(this.dataState.insertionMode,this.dataUnit)))}getMessage(i){return this._application.messagesBuilder.getMessage(i,this.dataUnit.getSelectedRecord())}loadGuides(i){if(!this.dataUnit)return;if(!this._configManager.isLoaded)return;this._masterFormMetadata=d(this.masterFormConfig,this.dataUnit,!0);const e=this._masterFormMetadata.getAllSheets(),s=this.dataUnit.getSelectedRecord(),t=!s||this.dataUnit.isNewRecord(s.__record__id__),r=[];Array.from(e.values()).forEach((i=>{const e={id:i.name,label:i.label};this.isDetail(i.name)&&t&&(e.tooltip="Para alterar detalhes é necessário estar com um registro selecionado.",e.disabled=!0),r.push(e)})),this._guides=r,i&&(this.selectedGuide=this._guides.length>0?this._guides[0]:void 0)}isDetail(i){return null!=o.getDetailName(i)}getChildrenMap(i){if(i&&Array.isArray(i.children))return new Map(i.children.map((i=>[i.id,i])))}restoreBranch(i,e){if(!e)return;const s=this.getChildrenMap(this._branchesCache.get(e));Array.isArray(i.children)&&s&&i.children.forEach((i=>{const e=s.get(i.id);e&&(i.children=e.children,i.expanded=e.expanded)})),this._branchesCache.set(e,i)}updateGuide(i,{item:e,recordId:s}){e&&this.restoreBranch(e,s),this._guideNavigator&&this._guideNavigator.getItem(i).then((i=>{i&&(i.children=e?[e]:void 0,i.expanded=!0,this._guideNavigator.updateItem(i),this._guideNavigator.getCurrentPath().then((i=>{this._breadcrumbItems=i})))}))}loadTaskbarProcessor(){var i,e;const s=(null===(i=this.dataState)||void 0===i?void 0:i.isDirty)?"snkGuideViewer.finish_edition":"snkGuideViewer.regular",t=[];this.dataState&&this.dataState.hasPrevious||t.push("PREVIOUS"),this.dataState&&this.dataState.hasNext||t.push("NEXT"),(null===(e=this.dataState)||void 0===e?void 0:e.selectionInfo)&&(this.dataState.selectionInfo.length>1&&t.push("CLONE"),this.dataState.selectionInfo.isAllRecords()&&t.push("REMOVE"));const r=["PREVIOUS","NEXT","DIVIDER","CLONE","REMOVE","MORE_OPTIONS","DIVIDER","GRID_MODE","CONFIGURATOR"];this.presentationMode==v.SECONDARY?r.unshift("INSERT"):r.push("INSERT"),this._taskbarProcessor=new h({"snkGuideViewer.regular":r,"snkGuideViewer.finish_edition":["CANCEL","SAVE"]}),this._taskbarProcessor.process(s,this.taskbarManager,this.dataState,t)}static updateContentCard(i,e,s,t){return t.saveCardState(i,e,s)}static buildFixedForms(i,e,r,a,n,d){const o=null==i?void 0:i.cardsState;if(null!=o)return s(t,null,Array.from(o.entries()).filter((([i,e])=>(null==e?void 0:e.fixed)&&i!=r)).sort((([,i],[,e])=>((null==i?void 0:i.fixSequence)||0)-((null==e?void 0:e.fixSequence)||0))).map((([t,r])=>{var o;const h=e.getSheet(t);if(null!=h)return s("snk-form-view",{levelPath:d,label:h.label,name:t,fields:h.fields,formMetadata:e,dataUnit:a,recordsValidator:n,contracted:"CONTRACTED"===(null==r?void 0:r.presentation),fixed:null==r?void 0:r.fixed,summaryFields:null===(o=null==i?void 0:i.summary)||void 0===o?void 0:o.get(t),key:t})})))}wrapDetail(i,e){if(0===i.length)return e;const t=i.pop(),r=o.getDetailName(t);return r?this.wrapDetail(i,s("snk-data-unit",{dataUnitName:`${this.getDataUnitName(i,r)}`,entityName:r},e)):void 0}getDataUnitName(i,e){if(i.length>0){const s=i.map((i=>o.getDetailName(i)));return`${this.entityPath}/${s.join("/")}/${e}`}return`${this.entityPath}/${e}`}getContent(){var i,e,t,r;if(!this.selectedGuide)return;const a=this.selectedGuide.id;let n;const d=a.split("::"),h=d.pop(),l=o.getDetailName(h);let u=a;if(l||d.length>0){let i;a.includes(g)&&([u,i]=a.split(g)),n=this.wrapDetail(d,s("snk-detail-view",{ref:i=>this._currentDetail=i,dataUnitName:this.getDataUnitName(d,l),onSnkDetailGuidesChange:i=>this.updateGuide(u,i.detail),entityName:l,selectedForm:i,guideItemPath:this._breadcrumbItems,key:`detail${u}`,onSnkSwitchGuide:i=>this._guideNavigator.selectGuide(i.detail)}))}else{const d=this.selectedGuide.id,o=this._masterFormMetadata.getSheet(d);if(o){const h=null===(e=null===(i=this.masterFormConfig)||void 0===i?void 0:i.cardsState)||void 0===e?void 0:e.get(d);n=s("snk-form-view",{ref:i=>this._mainForm=i,fixed:null==h?void 0:h.fixed,summaryFields:null===(r=null===(t=this.masterFormConfig)||void 0===t?void 0:t.summary)||void 0===r?void 0:r.get(d),name:d,label:o.label,fields:o.fields,dataUnit:this.dataUnit,formMetadata:this._masterFormMetadata,recordsValidator:this.recordsValidator,key:a},this.presentationMode==v.SECONDARY&&this.buildTaskBar())}}return n}onBreadcrumbClickHandler(i){null!=(null==i?void 0:i.id)&&this._guideNavigator.selectGuide(i.id)}updateSelectedGuideHandler(i){this._guideHasChanged=this.selectedGuide!=i,this.selectedGuide=i,this._guideNavigator.getCurrentPath().then((i=>{this._breadcrumbItems=i}))}getConfigViewMode(){return u.GRID}changeConfigViewMode(i){this._currentDetail&&this._currentDetail.changeViewMode(i)}openConfig(i){this._snkConfigurator.close(),this._currentDetail&&(i===u.FORM?this.showFormConfig(!0):this._currentDetail.configGrid())}componentWillLoad(){this._application=r.getContextValue("__SNK__APPLICATION__"),this._configManager=new n(this.configName,(i=>this.masterFormConfig=i)),this._configManager.loadConfig()}componentDidRender(){this._guideHasChanged&&(this._currentDetail?this._currentDetail.showUp():this._mainForm&&this._mainForm.showUp(),this._guideHasChanged=!1)}buildTaskBar(){var i;return s("div",{class:"ez-col ez-flex-item--align-center ez-col--sd-6 ez-col--tb-6 "+(this.presentationMode!=v.SECONDARY?"ez-align--right":"ez-padding-bottom--medium")},s("snk-taskbar",{key:"guideViewerTaskbar","data-element-id":"guideViewer",configName:this.configName,buttons:this._taskbarProcessor.buttons,disabledButtons:this._taskbarProcessor.disabledButtons,customButtons:this._taskbarProcessor.customButtons,actionsList:this.actionsList,presentationMode:this.presentationMode,primaryButton:(null===(i=this.dataState)||void 0===i?void 0:i.isDirty)?"SAVE":"INSERT","data-taskbar-owner":"master",dataUnit:this.dataUnit}))}render(){var i,e;if(null!=this._formEditorConfigManager)return s("snk-form-config",{dataUnit:this._formEditorDataUnit,configManager:this._formEditorConfigManager,onConfigClose:()=>this._formEditorConfigManager=null});if(!this.dataUnit)return;if(!this._configManager.isLoaded)return;this.loadTaskbarProcessor();const t=this._guides&&this._guides.length>1;return s("section",{class:"snk-guides-viewer"},s("div",{class:"ez-row snk-guides-viewer__header"},s("div",{class:"ez-col ez-col--sd-6 ez-col--tb-6 ez-flex--align-items-center ez-flex-item--align-center ez-padding-left--large",key:"header"},s("ez-button",{onClick:()=>this.exitViewer(),title:this.getMessage("snkCrud.goBackTitle"),mode:"icon",iconName:"arrow_back",class:"ez-padding-right--medium",size:"small"}),s("div",{class:"ez-flex ez-flex--column ez-flex-item--auto"},s("h1",{class:"ez-title ez-title--primary ez-title--xlarge"},this.getMessage("snkCrud.title")),(null===(i=this._breadcrumbItems)||void 0===i?void 0:i.length)>1&&s("div",{class:"ez-margin-top--extra-small"},s("ez-breadcrumb",Object.assign({items:this._breadcrumbItems,onSelectedItem:i=>this.onBreadcrumbClickHandler(null==i?void 0:i.detail)},{[a.DATA_ELEMENT_ID_ATTRIBUTE_NAME]:`${a.getInternalIDInfo("breadcrumb")}`}))))),this.presentationMode!=v.SECONDARY&&this.buildTaskBar()),s("div",{class:t?"snk-guides-viewer__container":void 0},t&&s("ez-guide-navigator",{ref:i=>this._guideNavigator=i,class:"snk-guides-viewer__guide-navigator",items:this._guides,selectedId:this.selectedGuide?this.selectedGuide.id:void 0,onEzChange:i=>this.updateSelectedGuideHandler(i.detail)}),s("div",{class:"snk-guides-viewer__detail-container"},c.buildFixedForms(this.masterFormConfig,this._masterFormMetadata,null===(e=this.selectedGuide)||void 0===e?void 0:e.id,this.dataUnit,this.recordsValidator),this.getContent())),s("snk-configurator",{ref:i=>this._snkConfigurator=i,viewMode:this.getConfigViewMode(),onConfigSelected:i=>this.changeConfigViewMode(i.detail),onOpenConfig:i=>this.openConfig(i.detail)}))}static get watchers(){return{dataUnit:["observeDataUnit"],dataState:["observeDataState"],masterFormConfig:["observeMasterFormConfig"]}}};c.style=".sc-snk-guides-viewer-h{--snk-guides-viewer--space-large:var(--space--large, 24px);--snk-guides-viewer--space-medium:var(--space--medium, 12px);--snk-guides-viewer__header--min-height:94px;--snk-guides-viewer__header--z-index:var(--more-visible, 2);--snk-guides-viewer__header--background-color:var(--background--body, #fafcff);--snk-guides-viewer__guide-navigator--width:340px;display:block}snk-form-view.sc-snk-guides-viewer{width:100%}.snk-guides-viewer.sc-snk-guides-viewer{position:relative;padding-left:0px;padding-top:0px;padding-right:var(--snk-guides-viewer--space-large);padding-bottom:var(--snk-guides-viewer--space-large)}.snk-guides-viewer__detail-container.sc-snk-guides-viewer{display:flex;row-gap:24px;flex-direction:column}.snk-guides-viewer__header.sc-snk-guides-viewer{position:sticky;align-items:center;top:0;z-index:var(--snk-guides-viewer__header--z-index);background-color:var(--snk-guides-viewer__header--background-color);min-height:var(--snk-guides-viewer__header--min-height);width:calc(100% + (var(--snk-guides-viewer--space-large) * 2));padding-left:var(--snk-guides-viewer--space-large);padding-right:var(--snk-guides-viewer--space-large);padding-top:var(--snk-guides-viewer--space-large);padding-bottom:var(--snk-guides-viewer--space-medium);margin-left:calc(var(--snk-guides-viewer--space-large) * -1);margin-right:calc(var(--snk-guides-viewer--space-large) * -1);margin-bottom:var(--snk-guides-viewer--space-medium)}.snk-guides-viewer__container.sc-snk-guides-viewer{display:grid;grid-template-columns:minmax(0, auto) minmax(0, 100%);height:100%;column-gap:var(--snk-guides-viewer--space-large)}.snk-guides-viewer__guide-navigator.sc-snk-guides-viewer{position:sticky;top:calc(var(--snk-guides-viewer__header--min-height) + var(--snk-guides-viewer--space-medium));height:calc(100vh - var(--snk-guides-viewer__header--min-height) - var(--snk-guides-viewer--space-large) - var(--snk-guides-viewer--space-medium))}.snk-guides-viewer__guide-navigator[open].sc-snk-guides-viewer{width:var(--snk-guides-viewer__guide-navigator--width);max-width:var(--snk-guides-viewer__guide-navigator--width);min-width:var(--snk-guides-viewer__guide-navigator--width)}.snk-guides-viewer__detail-content.sc-snk-guides-viewer{min-height:100%;align-items:flex-start;align-content:flex-start}";export{c as S}