@sankhyalabs/sankhyablocks 8.15.0-dev.9 → 8.15.0-rc.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (157) hide show
  1. package/dist/cjs/{ISave-d68ce3cd.js → ISave-e91b70a7.js} +1 -0
  2. package/dist/cjs/{SnkMessageBuilder-7293d0ad.js → SnkMessageBuilder-e7dcf408.js} +13 -0
  3. package/dist/cjs/loader.cjs.js +1 -1
  4. package/dist/cjs/{dataunit-fetcher-353e4af2.js → pesquisa-fetcher-e4a7c4c3.js} +215 -26
  5. package/dist/cjs/sankhyablocks.cjs.js +1 -1
  6. package/dist/cjs/snk-actions-button_2.cjs.entry.js +5 -4
  7. package/dist/cjs/snk-application.cjs.entry.js +12 -4
  8. package/dist/cjs/snk-attach.cjs.entry.js +388 -57
  9. package/dist/cjs/snk-crud.cjs.entry.js +2 -3
  10. package/dist/cjs/snk-data-exporter.cjs.entry.js +3 -3
  11. package/dist/cjs/{snk-data-unit-1bc69073.js → snk-data-unit-82c08a8c.js} +1 -1
  12. package/dist/cjs/snk-data-unit.cjs.entry.js +2 -2
  13. package/dist/cjs/snk-detail-view.cjs.entry.js +4 -5
  14. package/dist/cjs/snk-filter-bar.cjs.entry.js +8 -1
  15. package/dist/cjs/snk-filter-item.cjs.entry.js +4 -47
  16. package/dist/cjs/snk-filter-modal.cjs.entry.js +2 -1
  17. package/dist/cjs/snk-filter-multi-select.cjs.entry.js +2 -1
  18. package/dist/cjs/{snk-guides-viewer-e60ccc5e.js → snk-guides-viewer-d32c096f.js} +2 -3
  19. package/dist/cjs/snk-guides-viewer.cjs.entry.js +3 -4
  20. package/dist/cjs/snk-pesquisa.cjs.entry.js +1 -1
  21. package/dist/cjs/snk-simple-crud.cjs.entry.js +17 -6
  22. package/dist/collection/components/snk-application/snk-application.js +52 -9
  23. package/dist/collection/components/snk-attach/snk-attach.js +188 -39
  24. package/dist/collection/components/snk-attach/structure/{crud-config-builder.js → builder/anexo-sistema-crud-config.builder.js} +1 -1
  25. package/dist/collection/components/snk-attach/structure/builder/attach-crud-config.builder.js +62 -0
  26. package/dist/collection/components/snk-attach/structure/{taskbar-builder.js → builder/taskbar-builder.js} +1 -1
  27. package/dist/collection/components/snk-attach/structure/fetcher/facade/fetcher.facade.js +1 -0
  28. package/dist/collection/components/snk-attach/structure/{data-unit-builder.js → fetcher/factory/anexo-sistema-data-unit.factory.js} +14 -11
  29. package/dist/collection/components/snk-attach/structure/fetcher/factory/attach-fetcher-data-unit.factory.js +111 -0
  30. package/dist/collection/components/snk-attach/structure/index.js +6 -3
  31. package/dist/collection/components/snk-data-exporter/snk-data-exporter.js +1 -1
  32. package/dist/collection/components/snk-filter-bar/filter-item/editors/snk-filter-multi-select.js +2 -1
  33. package/dist/collection/components/snk-filter-bar/filter-item/snk-filter-item.js +4 -47
  34. package/dist/collection/components/snk-filter-bar/filter-modal/snk-filter-modal.js +19 -1
  35. package/dist/collection/components/snk-filter-bar/snk-filter-bar.js +22 -0
  36. package/dist/collection/components/snk-filter-bar/utils/SnkFilterModalFactory.js +3 -1
  37. package/dist/collection/components/snk-pesquisa/snk-pesquisa.css +2 -4
  38. package/dist/collection/components/snk-simple-crud/snk-simple-crud.js +53 -1
  39. package/dist/collection/components/snk-taskbar/elements/taskbar-actions-button/taskbar-actions-button.js +3 -1
  40. package/dist/collection/lib/dataUnit/InMemoryLoader.js +1 -1
  41. package/dist/collection/lib/http/data-fetcher/fetchers/{attach-fetcher.js → AttachFetcher/anexo-sistema-fetcher.js} +16 -15
  42. package/dist/collection/lib/http/data-fetcher/fetchers/AttachFetcher/attach-fetcher.js +90 -0
  43. package/dist/collection/lib/http/data-fetcher/fetchers/AttachFetcher/facade/attach-fetcher.facade.js +1 -0
  44. package/dist/collection/lib/http/data-fetcher/fetchers/AttachFetcher/index.js +2 -0
  45. package/dist/collection/lib/http/data-fetcher/fetchers/AttachFetcher/interfaces/IDelete.js +1 -0
  46. package/dist/collection/lib/http/data-fetcher/fetchers/AttachFetcher/interfaces/IDownloadKey.js +1 -0
  47. package/dist/collection/lib/http/data-fetcher/fetchers/{fecthAttach → AttachFetcher}/interfaces/ISave.js +1 -0
  48. package/dist/collection/lib/http/data-fetcher/fetchers/data-unit/dataunit-fetcher.js +17 -3
  49. package/dist/collection/lib/http/data-fetcher/fetchers/data-unit/loadstrategy/DatasetStrategy.js +29 -22
  50. package/dist/collection/lib/http/data-fetcher/fetchers/pesquisa-fetcher.js +7 -1
  51. package/dist/collection/lib/index.js +1 -1
  52. package/dist/collection/lib/message/resources/snk-attach.msg.js +13 -0
  53. package/dist/components/SnkMessageBuilder.js +13 -0
  54. package/dist/components/dataunit-fetcher.js +54 -27
  55. package/dist/components/snk-actions-button2.js +1 -0
  56. package/dist/components/snk-application2.js +11 -1
  57. package/dist/components/snk-attach2.js +394 -57
  58. package/dist/components/snk-data-exporter2.js +1 -1
  59. package/dist/components/snk-filter-bar2.js +9 -1
  60. package/dist/components/snk-filter-item2.js +4 -47
  61. package/dist/components/snk-filter-modal.js +4 -2
  62. package/dist/components/snk-filter-multi-select.js +2 -1
  63. package/dist/components/snk-pesquisa2.js +1 -1
  64. package/dist/components/snk-simple-crud2.js +15 -1
  65. package/dist/components/taskbar-actions-button2.js +3 -1
  66. package/dist/esm/{ISave-4412b20c.js → ISave-d8c8bc59.js} +1 -0
  67. package/dist/esm/{SnkMessageBuilder-ca843d1b.js → SnkMessageBuilder-0fb796b9.js} +13 -0
  68. package/dist/esm/loader.js +1 -1
  69. package/dist/esm/{dataunit-fetcher-0fc935a0.js → pesquisa-fetcher-fa0c2540.js} +215 -27
  70. package/dist/esm/sankhyablocks.js +1 -1
  71. package/dist/esm/snk-actions-button_2.entry.js +5 -4
  72. package/dist/esm/snk-application.entry.js +11 -3
  73. package/dist/esm/snk-attach.entry.js +389 -58
  74. package/dist/esm/snk-crud.entry.js +2 -3
  75. package/dist/esm/snk-data-exporter.entry.js +3 -3
  76. package/dist/esm/{snk-data-unit-6208ebf0.js → snk-data-unit-5d201fb3.js} +1 -1
  77. package/dist/esm/snk-data-unit.entry.js +2 -2
  78. package/dist/esm/snk-detail-view.entry.js +4 -5
  79. package/dist/esm/snk-filter-bar.entry.js +8 -1
  80. package/dist/esm/snk-filter-item.entry.js +4 -47
  81. package/dist/esm/snk-filter-modal.entry.js +2 -1
  82. package/dist/esm/snk-filter-multi-select.entry.js +2 -1
  83. package/dist/esm/{snk-guides-viewer-98a8e45e.js → snk-guides-viewer-f49613c6.js} +2 -3
  84. package/dist/esm/snk-guides-viewer.entry.js +3 -4
  85. package/dist/esm/snk-pesquisa.entry.js +1 -1
  86. package/dist/esm/snk-simple-crud.entry.js +15 -4
  87. package/dist/sankhyablocks/p-02e3a45b.entry.js +1 -0
  88. package/dist/sankhyablocks/{p-ff6064e7.js → p-05243555.js} +1 -1
  89. package/dist/sankhyablocks/p-0ec5b2e5.js +1 -0
  90. package/dist/sankhyablocks/{p-9e7d65a4.js → p-21749402.js} +1 -1
  91. package/dist/sankhyablocks/p-2582537c.entry.js +1 -0
  92. package/dist/sankhyablocks/p-282789a6.entry.js +1 -0
  93. package/dist/sankhyablocks/p-3b0e4e08.js +65 -0
  94. package/dist/sankhyablocks/{p-0874adb5.entry.js → p-40915359.entry.js} +1 -1
  95. package/dist/sankhyablocks/p-62896624.entry.js +1 -0
  96. package/dist/sankhyablocks/p-70a4af56.entry.js +1 -0
  97. package/dist/sankhyablocks/p-86801b08.entry.js +1 -0
  98. package/dist/sankhyablocks/p-9b5944a4.entry.js +1 -0
  99. package/dist/sankhyablocks/p-9bdbc7d8.entry.js +1 -0
  100. package/dist/sankhyablocks/p-ac384baf.entry.js +1 -0
  101. package/dist/sankhyablocks/p-bf2acf72.entry.js +1 -0
  102. package/dist/sankhyablocks/p-c4874327.entry.js +1 -0
  103. package/dist/sankhyablocks/{p-247a8b36.entry.js → p-d1791da2.entry.js} +1 -1
  104. package/dist/sankhyablocks/{p-90f9b4db.entry.js → p-e817f254.entry.js} +3 -3
  105. package/dist/sankhyablocks/{p-32f0935f.js → p-f3d1c48e.js} +1 -1
  106. package/dist/sankhyablocks/sankhyablocks.esm.js +1 -1
  107. package/dist/types/components/snk-actions-button/subcomponents/snk-actions-form.d.ts +1 -1
  108. package/dist/types/components/snk-application/snk-application.d.ts +7 -0
  109. package/dist/types/components/snk-attach/{structure/crud-config-builder.d.ts → interfaces/ICrudConfig.d.ts} +1 -2
  110. package/dist/types/components/snk-attach/interfaces/TFetcherType.d.ts +1 -0
  111. package/dist/types/components/snk-attach/snk-attach.d.ts +27 -6
  112. package/dist/types/components/snk-attach/structure/builder/anexo-sistema-crud-config.builder.d.ts +2 -0
  113. package/dist/types/components/snk-attach/structure/builder/attach-crud-config.builder.d.ts +31 -0
  114. package/dist/types/components/snk-attach/structure/{taskbar-builder.d.ts → builder/taskbar-builder.d.ts} +1 -1
  115. package/dist/types/components/snk-attach/structure/fetcher/facade/fetcher.facade.d.ts +11 -0
  116. package/dist/types/components/snk-attach/structure/fetcher/factory/anexo-sistema-data-unit.factory.d.ts +17 -0
  117. package/dist/types/components/snk-attach/structure/fetcher/factory/attach-fetcher-data-unit.factory.d.ts +15 -0
  118. package/dist/types/components/snk-attach/structure/index.d.ts +6 -3
  119. package/dist/types/components/snk-filter-bar/filter-item/snk-filter-item.d.ts +1 -2
  120. package/dist/types/components/snk-filter-bar/filter-modal/snk-filter-modal.d.ts +5 -0
  121. package/dist/types/components/snk-filter-bar/snk-filter-bar.d.ts +5 -0
  122. package/dist/types/components/snk-filter-bar/utils/SnkFilterModalFactory.d.ts +3 -1
  123. package/dist/types/components/snk-simple-crud/snk-simple-crud.d.ts +10 -1
  124. package/dist/types/components.d.ts +74 -2
  125. package/dist/types/lib/http/data-fetcher/DataFetcher.d.ts +1 -1
  126. package/dist/types/lib/http/data-fetcher/fetchers/{attach-fetcher.d.ts → AttachFetcher/anexo-sistema-fetcher.d.ts} +3 -2
  127. package/dist/types/lib/http/data-fetcher/fetchers/AttachFetcher/attach-fetcher.d.ts +11 -0
  128. package/dist/types/lib/http/data-fetcher/fetchers/AttachFetcher/facade/attach-fetcher.facade.d.ts +8 -0
  129. package/dist/types/lib/http/data-fetcher/fetchers/AttachFetcher/index.d.ts +3 -0
  130. package/dist/types/lib/http/data-fetcher/fetchers/{fecthAttach → AttachFetcher}/interfaces/ISave.d.ts +2 -1
  131. package/dist/types/lib/http/data-fetcher/fetchers/data-unit/dataunit-fetcher.d.ts +1 -0
  132. package/dist/types/lib/http/data-fetcher/fetchers/data-unit/loadstrategy/DatasetStrategy.d.ts +1 -0
  133. package/dist/types/lib/index.d.ts +1 -1
  134. package/package.json +5 -5
  135. package/dist/cjs/pesquisa-fetcher-ef050a47.js +0 -167
  136. package/dist/esm/pesquisa-fetcher-dd3ca0a5.js +0 -165
  137. package/dist/sankhyablocks/p-20726710.entry.js +0 -1
  138. package/dist/sankhyablocks/p-41560fd8.entry.js +0 -1
  139. package/dist/sankhyablocks/p-4775a293.entry.js +0 -1
  140. package/dist/sankhyablocks/p-6678d5d4.entry.js +0 -1
  141. package/dist/sankhyablocks/p-71439fd9.entry.js +0 -1
  142. package/dist/sankhyablocks/p-7d8d7fe9.entry.js +0 -1
  143. package/dist/sankhyablocks/p-a91bb13d.js +0 -1
  144. package/dist/sankhyablocks/p-a9e5b094.entry.js +0 -1
  145. package/dist/sankhyablocks/p-abfa8101.entry.js +0 -1
  146. package/dist/sankhyablocks/p-b3020263.entry.js +0 -1
  147. package/dist/sankhyablocks/p-bf93a748.js +0 -60
  148. package/dist/sankhyablocks/p-c6f89389.entry.js +0 -1
  149. package/dist/sankhyablocks/p-cebae710.entry.js +0 -1
  150. package/dist/sankhyablocks/p-d9bb09b3.js +0 -6
  151. package/dist/types/components/snk-attach/structure/data-unit-builder.d.ts +0 -15
  152. /package/dist/collection/{lib/http/data-fetcher/fetchers/fecthAttach/interfaces/IDelete.js → components/snk-attach/interfaces/ICrudConfig.js} +0 -0
  153. /package/dist/collection/{lib/http/data-fetcher/fetchers/fecthAttach/interfaces/IDownloadKey.js → components/snk-attach/interfaces/TFetcherType.js} +0 -0
  154. /package/dist/collection/lib/http/data-fetcher/fetchers/{fecthAttach → AttachFetcher}/interfaces/index.js +0 -0
  155. /package/dist/types/lib/http/data-fetcher/fetchers/{fecthAttach → AttachFetcher}/interfaces/IDelete.d.ts +0 -0
  156. /package/dist/types/lib/http/data-fetcher/fetchers/{fecthAttach → AttachFetcher}/interfaces/IDownloadKey.d.ts +0 -0
  157. /package/dist/types/lib/http/data-fetcher/fetchers/{fecthAttach → AttachFetcher}/interfaces/index.d.ts +0 -0
@@ -1,60 +0,0 @@
1
- import{DataUnit as e,DataType as t,DateUtils as r,StringUtils as n,ChangeOperation as a,ApplicationContext as s,UserInterface as i,DataUnitStorage as o}from"@sankhyalabs/core";import{D as l,d as c}from"./p-9695f78b.js";import{DISTINCT_FILTER_NAME_PREFIX as d}from"@sankhyalabs/ezui/dist/collection/utils/constants";import{DataUnitTransient as u}from"@sankhyalabs/core/dist/dataunit/metadata/UnitMetadata";import{P as h}from"./p-c22c1d8e.js";import{R as m}from"./p-688dcb4c.js";import{ColumnFilterManager as f}from"@sankhyalabs/ezui/dist/collection/components/ez-grid/utils";class _{constructor(t,r){this.metadata=t,this.records=r,this._dataUnit=new e(_.IN_MEMORY_DATA_UNIT_NAME),this._dataUnit.metadataLoader=()=>this.metadaLoader(),this._dataUnit.dataLoader=(e,t)=>this.inMemoryLoader(e,t,this.getRecordsToLoad()),this._dataUnit.saveLoader=(e,t)=>this.saveLoader(e,t),this._dataUnit.removeLoader=(e,t)=>this.removeLoader(e,t),this.dataUnit.loadMetadata().then((()=>this.dataUnit.loadData()))}getRecordsToLoad(){return null==this._initialRecords&&this.dataUnit.records.length>0&&(this._initialRecords=this.dataUnit.records),this._initialRecords}get dataUnit(){return this._dataUnit}get records(){return this.dataUnit.records}static getConvertedValue(e,n){return e.dataType===t.BOOLEAN?"S"===n:e.dataType===t.NUMBER?Number(n):e.dataType===t.DATE?r.strToDate(n,!0):e.dataType===t.OBJECT?JSON.parse(n):n}set records(e){const t=this._metadata?new Map(this._metadata.fields.map((e=>[e.name,e]))):void 0,r=null==e?void 0:e.map((e=>{if(e.__record__id__||(e.__record__id__=this.generateUniqueId()),null!=t)for(const r in e){const n=e[r];"string"==typeof n&&t.has(r)&&(e[r]=_.getConvertedValue(t.get(r),n))}return e}));this._initialRecords=r,this._dataUnit&&this._dataUnit.gotoPage(0)}get metadata(){return this._metadata}set metadata(e){this._metadata=e,this._dataUnit&&(this._dataUnit.metadata=this._metadata)}generateUniqueId(){return n.generateUUID()}inMemoryLoader(e,t,r){let n=this.applyFilter(r,e,t.filters);return n=this.applySorting(n,e,t.sort),Promise.resolve({records:n,paginationInfo:p(t,n)})}applyFilter(e,t,r){const n=f.getColumnFilters(r,"");if(null==n||0==n.size)return e;const a=f.getFilterFunction(t,Array.from(n.values()));return null==a?e:e.filter(a)}applySorting(e,t,r){if(null==r||0==r.length)return e;const n=h.getSortingFunction(t,r);return null==n?e:e.sort(n)}metadaLoader(){return Promise.resolve(this._metadata)}saveLoader(e,t){return new Promise((e=>{let r=[];t.forEach((e=>{let{record:t,updatingFields:n,operation:s}=e;const i=Object.assign(Object.assign({},t),n);if(s===a.INSERT||s===a.COPY)i.__old__id__=t.__record__id__,i.__record__id__=this.generateUniqueId(),this.records.push(i);else{const e=this.records.findIndex((e=>e.__record__id__==i.__record__id__));this.records[e]=i}r.push(i)})),e(r)}))}removeLoader(e,t){return new Promise((e=>{e(t)}))}}function p({offset:e,limit:t},r){if(void 0===e||void 0===t)return;const n=Math.min(e+t,r.length);return{currentPage:Math.ceil(e/t),firstRecord:e,lastRecord:n,total:r.length,hasMore:!!(r.length-n)}}_.IN_MEMORY_DATA_UNIT_NAME="InMemoryDataUnit";class g{canSlice(){return!1}async load(e,t,r){if(null==e.metadata)return Promise.resolve({records:[],loadingInfo:r});try{const n=[],a=[];if(null!=t.sort)for(const r of t.sort){const t=e.getField(r.field);null!=t&&null!=t.properties&&"true"===t.properties.calculated?n.push(r):a.push(r)}const s=this.getFieldsList(e),i="DatasetSP.loadRecords",o=this.buildRequestBody(i,s,e,t,r,a),c=r.quiet?{urlParams:{quietMode:"true"}}:void 0,{result:d,pagerID:u}=await l.get().callServiceBroker(i,o,c),h=this.processRecords(e,s,d),m=null!=u,f=r.count+h.length,_=!m&&n.length>0;return Promise.resolve({records:h,loadingInfo:Object.assign(Object.assign({},r),{pagerId:u,loadingInProgress:m,total:m?void 0:f,count:f,needReload:_})})}catch(e){return console.error(e),Promise.reject(e)}}getFieldsList(e){let t=["__record__id__","__record__label__"];return e.metadata.fields.forEach((e=>{e.standAlone||(t=t.concat(this.getFieldNames(e)))})),t}getStandAloneFieldsList(e){let t={};return e.metadata.fields.forEach((e=>{e.standAlone&&(t=Object.assign(Object.assign({},t),{[e.name]:{fieldType:e.dataType,userType:e.userInterface}}))})),t}getFieldNames(e){const t=this.getSearchDescriptionField(e);return null==t?e.name:[e.name,t]}buildRequestBody(e,t,r,n,a,s){const i=r.dataUnitId,o=v.parseDataUnitName(r.name).entityName,l=!(!n.limit&&!n.offset),c={serviceName:e,requestBody:{dataSetID:i,fields:t,entityName:o,pageNumber:a.pageNumber,totalRecordsCount:a.count,pagerID:a.pagerId,standAlone:!1,standAloneFieldsMD:Object.assign({__record__id__:{fieldType:"S",userType:"P"},__record__label__:{fieldType:"S",userType:"P"}},this.getStandAloneFieldsList(r)),tryJoinedFields:!0,parallelLoader:l,crudListener:`br.com.sankhya.bff.${this.getModuleName()}.BFFDataUnitDatasetAdapter`,txProperties:this.getTxProperties(r,n,s),useDefaultRowsLimit:!1}};return JSON.stringify(c)}getModuleName(){return s.getContextValue("__SNK__APPLICATION__").getModuleName().replace("-bff","")}getTxProperties(e,t,r){var n,a;const s={"__DATA_UNIT_ADAPTER__[dataUnitName]":e.name},i=null!==(a=null===(n=t.filters)||void 0===n?void 0:n.filter((e=>!e.name.startsWith("FILTRO_COLUNA_"))))&&void 0!==a?a:[];0!==i.length&&(s["__DATA_UNIT_ADAPTER__[criteria]"]=JSON.stringify(i)),null!=r&&0!==r.length&&(s["__DATA_UNIT_ADAPTER__[sorting]"]=JSON.stringify(r)),null!=t.parentRecordId&&(s["__DATA_UNIT_ADAPTER__[parentRecordId]"]=t.parentRecordId);const o=e.getGlobalLoaderProps();return null==o||0===o.size||Array.from(o.entries()).forEach((([e,t])=>{s[e]=t})),s}processRecords(e,t,r){return r.map((r=>{const n={__record__id__:r[0],__record__label__:r[1]};return e.metadata.fields.forEach((e=>{n[e.name]=this.buildFieldValue(e,t,r)})),n}))}buildFieldValue(e,t,r){const a=t.indexOf(e.name);if(a<0)return null;const s=r[a];if(n.isEmpty(s))return null;const o=this.getSearchDescriptionField(e);if(null!=o){const e=t.indexOf(o);if(e>=0)return{value:s,label:r[e]}}return e.userInterface===i.SEARCH?isNaN(Number(s))?s:Number(s):_.getConvertedValue(e,s)}getSearchDescriptionField(e){if(e.userInterface===i.SEARCH){const{ENTITYNAME:t,mergedFrom:r,DESCRIPTIONFIELD:a}=e.properties;if(!n.isEmpty(a))return null!=r?`${r}.${t}.${a}`:`${t}.${a}`}}}class b{static async debounce(e,t){const r=e.name;b._debouncingTimeouts[r]&&(clearTimeout(b._debouncingTimeouts[r]),delete b._debouncingTimeouts[r]),b._debouncingTimeouts[r]=setTimeout((()=>{delete b._debouncingTimeouts[r],t()}),100)}static async loadData(e,t){return new Promise(((r,n)=>{b.debounce(e,(()=>{h.loadData(e,t,this.loadFromServer).then((e=>r(e))).catch((e=>n(e)))}))}))}static async loadFromServer(e,t,r){try{r=b.registryLoading(e,r);const n=await b.callLoader(e,t,r);if(null==n)return;const a=n.records,s=b.buildPaginationInfo(a.length,t,n.loadingInfo),i=null==s?a:a.slice(0,s.lastRecord);return Promise.resolve({records:i,paginationInfo:s})}catch(e){return console.error(e),Promise.reject(e)}}static async callLoader(e,t,r,n){null==n&&(n=new g);const a=await n.load(e,t,r),{records:s,loadingInfo:i}=a;if(b.isOldRequest(e,i))return Promise.resolve(void 0);const o=!n.canSlice()||0===i.count;if(h.cacheRecords(e,s,o,i.loadingInProgress),h.isCacheEnabled(e)&&i.loadingInProgress){const r=Object.assign(Object.assign({},t),{offset:i.count}),a=Object.assign(Object.assign({},i),{pageNumber:(i.pageNumber||0)+1,quiet:!0});this.callLoader(e,r,a,n).then((t=>b.afterLoadingPage(e,t.loadingInfo))).catch((e=>console.error(e)))}return Promise.resolve(a)}static afterLoadingPage(e,t){h.setLoadingStatus(e,t.loadingInProgress);const r=e.getPaginationInfo();if(null==r)return;const n=t.count;t.loadingInProgress?e.updatePagination(Object.assign(Object.assign({},r),{count:n})):t.needReload?e.gotoPage(0):e.updatePagination(Object.assign(Object.assign({},r),{total:n,count:n}))}static registryLoading(e,t){return null==t&&(t={requestTime:(new Date).getTime(),count:0}),b._requestTimeByDataUnit.set(e.name,t.requestTime),t}static isOldRequest(e,t){return b._requestTimeByDataUnit.get(e.name)>t.requestTime}static buildPaginationInfo(e,t,r){let{limit:n,offset:a}=t;if(!n)return;1===r.pageNumber&&(a=0);const{total:s,count:i,loadingInProgress:o}=r,l=0===i||0===e?0:a+1,c=a+Math.min(e,n);return{total:s,count:i,lastRecord:c,firstRecord:l,currentPage:a/n,hasMore:c<i||o}}}b._requestTimeByDataUnit=new Map,b._debouncingTimeouts={};const y=/dd:\/\/([^/]+)\/([^/?]+)/;class v{constructor(){this.templateByQuery=new Map,this.buldTemplates()}buldTemplates(){this.templateByQuery.set("fetchDataUnit",c.gql`query($name: String!) {
2
- $queryAlias$: fetchDataUnit(name: $name){
3
- name
4
- fields{
5
- name
6
- defaultValue
7
- label
8
- visible
9
- standAlone
10
- readOnly
11
- required
12
- dataType
13
- userInterface
14
- calculated
15
- group
16
- order
17
- properties{
18
- name
19
- value
20
- }
21
- dependencies{
22
- masterFields
23
- type
24
- expression
25
- }
26
- }
27
- children{
28
- name
29
- label
30
- links{
31
- source
32
- target
33
- }
34
- }
35
- }
36
- }`),this.templateByQuery.set("saveData",c.gql`mutation($changes: [InputBatchChange!]!) {
37
- $queryAlias$: batchOperationDataUnit(changes: $changes){
38
- oldId
39
- id
40
- label
41
- ownerDataUnitName
42
- fields {
43
- name
44
- value
45
- }
46
- }
47
- }`),this.templateByQuery.set("fetchDataRecord",c.gql`query($dataunit: String! $recordID: [String!]) {
48
- $queryAlias$: fetchDataUnit(name: $dataunit){
49
- record(id: $recordID){
50
- id
51
- label
52
- fields {
53
- name
54
- value
55
- }
56
- }
57
- }
58
- }`),this.templateByQuery.set("fetchDistinctColumn",c.gql`query($dataUnit: String!, $fieldName: String!, $argument: String, $filters: [InputFilter], $parentRecordId: String) {
59
- $queryAlias$: selectDistinct(dataUnit: $dataUnit, fieldName: $fieldName, argument: $argument, filters: $filters, parentRecordId: $parentRecordId)
60
- }`)}static parseDataUnitName(e){if(null==e)return;const t=y.exec(e);return t?{entityName:t[1],resourceID:t[2]}:void 0}getDataUnit(t,r,n,a){null==h.applicationResourceID&&m.getResourceID().then((e=>h.applicationResourceID=e));const s=`dd://${t}/${r}${a?"/"+a:""}`,i=null!=n?n.getChildDataunit(s):new e(s);return i.metadataLoader=e=>this.loadMetadata(e),i.dataLoader=(e,t)=>b.loadData(e,t),i.saveLoader=(e,t)=>this.saveData(i,t),i.removeLoader=(e,t)=>this.removeRecords(e,t),i.recordLoader=(e,t)=>this.loadRecord(e,t),i}loadMetadata(e){return new Promise(((t,r)=>{l.get().callGraphQL({values:{name:e.name},query:this.templateByQuery.get("fetchDataUnit")}).then((e=>{var r;const n={name:e.name,label:e.name,children:[...e.children],fields:[]};null===(r=e.fields)||void 0===r||r.forEach((e=>{let t;Array.isArray(e.properties)&&(t={},e.calculated&&(t.gridHeaderTooltip="Campos calculados não podem ser ordenados"),e.properties.forEach((e=>t[e.name]=e.value))),n.fields.push(Object.assign(Object.assign({},e),{properties:t}))})),n.fields.sort(((e,t)=>e.order-t.order)),t(n)})).catch((e=>{r(e)}))}))}loadSelectDistinct(e,t,r){const{parentRecordId:n,filters:a}=e.getLastLoadRequest()||{},s=a.filter((e=>e.name!==`${d}${t}`)),i={dataUnit:e.name,argument:r,fieldName:t,parentRecordId:n,filters:s};return new Promise(((e,t)=>{l.get().callGraphQL({values:i,query:this.templateByQuery.get("fetchDistinctColumn")}).then((t=>{e(t)})).catch((e=>{t(e)}))}))}addTransientProperties(e,t){const r=e.getGlobalLoaderProps();return null==r||0===r.size||(null==t&&(t={}),Array.from(r.entries()).forEach((([e,r])=>{t[`transient.${e}`]=r}))),t}saveData(e,r){const n=[],s=[],i=r.map((r=>{const{dataUnit:i,record:l,updatingFields:c,operation:d}=r,u=o.get(i);let h;c&&(h=Object.entries(this.addTransientProperties(e,c)).map((([e,r])=>{const n=u.getField(e);return{fieldName:e,dataType:n?n.dataType:t.TEXT,value:u.valueToString(e,r)}}))),i===e.name&&(d===a.INSERT||d===a.COPY?s.push(l.__record__id__):n.push(l.__record__id__));const m={dataUnit:i,fields:h,operation:d,recordId:l.__record__id__};return r.sourceId&&(m.sourceId=r.sourceId),l.__parent__record__id__&&(m.parentRecordId=l.__parent__record__id__),m}));return new Promise(((t,r)=>{const a=i.map((e=>function(e,t){var r={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.indexOf(n)<0&&(r[n]=e[n]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var a=0;for(n=Object.getOwnPropertySymbols(e);a<n.length;a++)t.indexOf(n[a])<0&&Object.prototype.propertyIsEnumerable.call(e,n[a])&&(r[n[a]]=e[n[a]])}return r}(e,[])));l.get().callGraphQL({values:{changes:a},query:this.templateByQuery.get("saveData")}).then((r=>{const a=[];null==r||r.forEach((t=>{const r={__record__id__:t.id,__record__label__:t.label,__owner__dataunit__name__:t.ownerDataUnitName},n=o.get(r.__owner__dataunit__name__)||e;t.oldId&&(r.__old__id__=t.oldId),t.fields.forEach((({name:e,value:t})=>{var a;const s=null===(a=null==n?void 0:n.valueFromString)||void 0===a?void 0:a.call(n,e,t);r[e]=void 0!==s?s:t})),a.push(r)})),this.updateCache(e,a,n,s),t(a)})).catch((e=>{r(e)}))}))}updateCache(e,t,r,n){const a=new Map(t.map((e=>[e.__old__id__||e.__record__id__,e]))),s=n.map((e=>{const t=Object.assign({},a.get(e));return delete t.__old__id__,t}));s.length>0&&h.insertRecords(e,e.records[0],s);const i=r.map((e=>Object.assign({},a.get(e))));h.updateRecords(e,i)}getTransientInfo(e,r){const{records:n}=e.getSelectionInfo();return Object.entries(n.filter((e=>e.__record__id__==r))[0]).filter((([e])=>e.startsWith(u.DATA_UNIT_TRANSIENT_PREFIX_NAME))).map((([e,r])=>({fieldName:e,value:r,dataType:t.TEXT})))}removeRecords(e,t){const r=t.map((t=>({dataUnit:e.name,operation:a.DELETE,recordId:t,fields:this.getTransientInfo(e,t)})));return new Promise(((n,a)=>{l.get().callGraphQL({values:{changes:r},query:this.templateByQuery.get("saveData")}).then((()=>{h.removeRecords(e,e.records.filter((e=>t.includes(e.__record__id__)))),n(t)})).catch((e=>{a(e)}))}))}loadRecord(e,t){return new Promise(((r,n)=>{l.get().callGraphQL({values:{recordID:t,dataunit:e.name},query:this.templateByQuery.get("fetchDataRecord")}).then((t=>{const n=[];t.record.forEach((t=>{const r={__record__id__:t.id,__record__label__:t.label};t.fields.forEach((({name:t,value:n})=>{r[t]=e.valueFromString(t,n)})),n.push(r)})),r(n)})).catch((e=>{n(e)}))}))}}export{v as D,_ as I}
@@ -1 +0,0 @@
1
- import{r as t,h as i,H as s,g as e,c as n}from"./p-d2d301a6.js";import{ApplicationContext as o,StringUtils as a,ErrorException as c,WarningException as r,ObjectUtils as l,DateUtils as h,ArrayUtils as d,ElementIDUtils as u}from"@sankhyalabs/core";import{D as p}from"./p-9695f78b.js";import{P as m}from"./p-eaad0aa8.js";import"./p-d9bb09b3.js";import"./p-38289a55.js";import"./p-9e7d65a4.js";import"@sankhyalabs/ezui/dist/collection/utils/constants";import"@sankhyalabs/core/dist/dataunit/metadata/UnitMetadata";import"./p-bf93a748.js";import"./p-c22c1d8e.js";import"./p-ff1990ad.js";import"./p-0d7863ed.js";import{R as v}from"./p-688dcb4c.js";import"./p-8d884fab.js";import"@sankhyalabs/ezui/dist/collection/components/ez-grid/utils";class b{execute(t){var i;const s={actionID:t.actionID,refreshType:null===(i=t.actionConfig.javaCall)||void 0===i?void 0:i.refreshType};return new Promise((t=>{t({execSource:s,callback:this.callExecJava})}))}async callExecJava(t){const i={requestBody:{javaCall:t}};await p.get().callServiceBroker("ActionButtonsSP.executeJava",JSON.stringify(i))}}class w{execute(t){var i;const s={actionID:t.actionID,refreshType:null===(i=t.actionConfig.runScript)||void 0===i?void 0:i.refreshType};return new Promise((t=>{t({execSource:s,callback:this.callExecScript})}))}async callExecScript(t){const i={runScript:t};await p.get().callServiceBroker("ActionButtonsSP.executeScript",i)}}class f{constructor(){this._application=o.getContextValue("__SNK__APPLICATION__")}async execute(t,i){const s=t.resourceID;if(!s)return;let e=await this.buildLaunchObject(t,i);return this._application.openApp(s,e),null}buildLaunchObject(t,i){return new Promise((s=>{let e=t.actionConfig.params.param;if(e&&e.length>0){let n={},o=[];e.forEach((s=>{const e=s.localField;let r=i.getFieldValue(e);if(!r){let s=i.getField(e).label;throw s=a.isEmpty(i.getField(e).label)?e:s,new c(this._application.messagesBuilder.getMessage("snkActionsButton.title.error",void 0),this._application.messagesBuilder.getMessage("snkActionsButton.launchScreen.emptyField",{description:t.description,localFieldLabel:s}))}r=a.isEmpty(r.toString())?void 0:r.toString(),n[s.targetField]=r,o.push({fieldName:s.targetField,value:r})})),n.ACTION_PARAMETERS=o,n.call_time=Date.now(),s(n)}s(null)}))}}class k{execute(t){var i,s,e;const n=null===(i=t.actionConfig.dbCall)||void 0===i?void 0:i.name,o=null===(s=t.actionConfig.dbCall)||void 0===s?void 0:s.rootEntity,a={actionID:t.actionID,refreshType:null===(e=t.actionConfig.dbCall)||void 0===e?void 0:e.refreshType,procName:n,rootEntity:o};return new Promise((t=>{t({execSource:a,callback:this.callExecProcedure})}))}async callExecProcedure(t){const i={requestBody:{stpCall:t}};await p.get().callServiceBroker("ActionButtonsSP.executeSTP",JSON.stringify(i))}}var _,y;!function(t){t.LAUNCH_SCREEN="LC",t.JAVASCRIPT="SC",t.JAVA="RJ",t.PROCEDURE="SP",t.EMBEDDED="EB"}(_||(_={}));class S{constructor(t){this.actionType=t,this._application=o.getContextValue("__SNK__APPLICATION__")}get executor(){switch(this.actionType){case _.LAUNCH_SCREEN:return new f;case _.JAVASCRIPT:return new w;case _.JAVA:return new b;case _.PROCEDURE:return new k;default:throw new c(this._application.messagesBuilder.getMessage("snkActionsButton.title.error",void 0),this._application.messagesBuilder.getMessage("snkActionsButton.action.nonExistentType",{actionType:this.actionType}))}}}!function(t){t.NONE="NONE",t.PARENT="PARENT",t.MASTER="MASTER",t.ALL="ALL"}(y||(y={}));const A="__MASTER_ROW__";class P{constructor(t,i,s){var e;this._lastValuesCache={},this._actionsExecuteInterface=t,this._dataUnit=i,this._selectedRows=(null===(e=null==i?void 0:i.getSelectionInfo())||void 0===e?void 0:e.isAllRecords())?[]:null==i?void 0:i.getSelectionInfo().records,this._application=o.getContextValue("__SNK__APPLICATION__"),this._appResourceId=s}apply(t,i){this._application.closePopUp(),this._actionsExecuteInterface.execute(t,this._dataUnit).then((({execSource:s,callback:e})=>{this.resolvePromptParams(t,s,i).then((()=>{this.actionExecute(s,e)}))}))}async execute(t){var i;if(!t.actionConfig)throw new r(this._application.messagesBuilder.getMessage("snkActionsButton.title.warning",void 0),this._application.messagesBuilder.getMessage("snkActionsButton.action.incorrectAction",{description:t.description}));if(null===(i=t.actionConfig.params)||void 0===i?void 0:i.promptParam){const i=t.actionConfig.params.promptParam;let s=!1;for(let t=0;t<i.length;t++)if(!s&&"true"===i[t].saveLast){s=!0;break}s&&(t.actionConfig.params.promptParam=await this.loadSavedValuesIntoParams(t));const e=document.createElement("snk-actions-form");window.document.body.appendChild(e),e.action=l.copy(t),e.applyParameters=t=>{this.apply(t,s)},e.openPopup()}else t.type!=_.LAUNCH_SCREEN?this._actionsExecuteInterface.execute(t,this._dataUnit).then((({execSource:t,callback:i})=>{this.actionExecute(t,i)})):this._actionsExecuteInterface.execute(t,this._dataUnit)}loadSavedValuesIntoParams(t){return this.loadLastValues(t).then((i=>{let s=t.actionConfig.params.promptParam;return i&&i.param.forEach((t=>{s=s.map((i=>i.name!==t.paramName?i:Object.assign(Object.assign({},i),"B"===i.paramType?{value:"S"===t.$}:{value:t.$})))})),s}))}actionExecute(t,i){t.virtualPage=this.buildVirtualPage(),this.prepareAndExecute(t,i),this.recordsReloader(t.refreshType)}resolvePromptParams(t,i,s){return new Promise((e=>{let n=[];t.actionConfig.params.promptParam.forEach((t=>{n.push(this.buildPromptParam(t))})),this.putParamsOnExecSource(n,i),s&&this.saveLastValues(t,n),e()}))}buildPromptParam(t){let i,s,e=t.paramType,n=!1,o=t.value;switch(e){case m.DATE:e="D";break;case m.DATETIME:e="H";break;case m.DECIMAL:e="F",i={"sk-precision":Number(t.precision)};break;case m.BOOLEAN:e="S",n=!0,o=t.value?"S":"N";break;case m.ENTITY:i={"sk-entity-name":t.entityName,"sk-allow-show-hierarchical-mode":t.hierarchyEntity,"sk-data-type":"S"},t.hierarchyEntity&&t.entityPK&&(s=t.entityPK),o=t.value?Number(t.value):null;break;case m.OPTIONS:e="O";let a=t.options.split(";").map((function(t,i){let s,e;if(t.indexOf("=")>-1){let i=t.split("=");s=i[0],e=i[1]}else s=i+1,e=t;return{data:s,value:e}}));i={"sk-options":a}}return{description:t.label,required:"true"==t.required,fieldName:t.name,fieldNameOri:t.name,entityPK:s,paramType:t.paramType,type:e,isCheckbox:n,saveLast:t.saveLast,fieldProp:i,value:o,isGeneratedName:t.isGeneratedName}}putParamsOnExecSource(t,i){i.params={param:[]},t.forEach((t=>{if(t.isGeneratedName&&t.value)throw new c(this._application.messagesBuilder.getMessage("snkActionsButton.title.error",void 0),this._application.messagesBuilder.getMessage("snkActionsButton.action.emptyParamName",void 0));a.isEmpty(t.value)||i.params.param.push({type:this.getParamDataType(t.paramType),paramName:t.fieldName,$:this.getParamValue(t)})}))}getParamDataType(t){let i;switch(t){case"D":i="F";break;case"DT":case"DH":i="D";break;case"B":case"ENTITY":case"SO":i="S";break;default:i=t}return i}getParamValue(t){let i=t.value;return i?("DT"==t.paramType?i=h.formatDate(i):"DH"==t.paramType&&(i=h.formatDateTime(i)),i):i}async loadLastValues(t){const i=await this.buildResourceId(t.actionID);return new Promise(((t,s)=>{if(this._lastValuesCache[i])t(this._lastValuesCache[i]);else{const e={config:{chave:i,tipo:"T"}};p.get().callServiceBroker("SystemUtilsSP.getConf",e).then((s=>{var e,n;let o;(null===(n=null===(e=s.config)||void 0===e?void 0:e.data)||void 0===n?void 0:n.params)&&(o=s.config.data.params,Array.isArray(o.param)||(o.param=[o.param])),this._lastValuesCache[i]=o,t(o)})).catch((t=>{s(t)}))}}))}async saveLastValues(t,i){if(this._application){let s={params:{param:[]}};i.forEach((t=>{"true"==t.saveLast&&s.params.param.push({paramName:t.fieldName,$:t.value})}));const e=await this.buildResourceId(t.actionID);this._lastValuesCache[e]=s.params,this._application.saveConfig(e,s)}}async buildResourceId(t){return this._appResourceId+".actionconfig."+t}prepareAndExecute(t,i){this.addRows(t),i(t)}addRows(t){const i={row:[]},s=this._selectedRows;for(const t in s){const e=s[t],n={};e.hasOwnProperty(A)&&(n.master="S",n.entityName=e.__ENTITY_NAME__,delete e[A],delete e.__ENTITY_NAME__);for(const t in e)"NUFIN"===t&&(n.field||(n.field=[]),n.field.push({fieldName:t,$:e[t]}));i.row.push(n)}i.row.length>0&&(t.rows=i)}recordsReloader(t){switch(t){case y.NONE:break;case y.PARENT:case y.MASTER:case y.ALL:this._dataUnit.loadData();break;default:this._dataUnit.reloadCurrentRecord()}}buildVirtualPage(){var t,i,s,e;if(null===(i=null===(t=this._dataUnit)||void 0===t?void 0:t.getSelectionInfo())||void 0===i?void 0:i.isAllRecords())return{filters:{filters:null===(s=this._dataUnit)||void 0===s?void 0:s.getAppliedFilters()},orders:{orders:null===(e=this._dataUnit)||void 0===e?void 0:e.getSort()}}}}class N{async clientConfirm(t,i){return new Promise((s=>{const e=o.getContextValue("__SNK__APPLICATION__");let n="";t.content.event.hasOwnProperty("stpCall")?(i.requestBody=t.content.event.stpCall,n=_.PROCEDURE):t.content.event.hasOwnProperty("runScript")?(i.requestBody=t.content.event.runScript,n=_.JAVASCRIPT):t.content.event.hasOwnProperty("javaCall")&&(i.requestBody=t.content.event.javaCall,n=_.JAVA);let a={type:"S",sequence:t.content.event.sequence};i.requestBody.params?Array.isArray(i.requestBody.params.param)||(i.requestBody.params.param=[i.requestBody.params.param]):i.requestBody.params={param:[]},i.requestBody.params.param.push(a);const c=t.content.event.title.$,r=t.content.event.message.$;let l;switch(n){case _.JAVASCRIPT:l={runScript:i.requestBody};break;case _.PROCEDURE:l={requestBody:{stpCall:i.requestBody}};break;case _.JAVA:l={requestBody:{javaCall:i.requestBody}}}if("S"==t.content.event.showNoOption){a.paramName="__ESCOLHA_SIMNAO__";const t=document.createElement("snk-client-confirm");window.document.body.appendChild(t),t.titleMessage=c,t.message=r,t.accept=async()=>{a.$="S",await i.reCall(l),s()},t.cancel=async()=>{a.$="N",await i.reCall(l),s()},t.openPopup()}else e.confirm(c,r,null,"warn",{labelCancel:"Cancelar",labelConfirm:"Sim"}).then((async t=>{t&&(a.paramName="__CONFIRMACAO__",a.$="S",await i.reCall(l),s())}))}))}}const x=class{constructor(i){t(this,i),this.CLIENT_EVENT_CONFIRM_NAME="br.com.sankhya.actionbutton.clientconfirm",this.handleClick=t=>{const i=this._actions.find((i=>i.actionID==t.detail.id)),s=new S(i.type).executor;new P(s,this._dataUnit,this._resourceID).execute(Object.assign({},i)),this._showDropdown=!1},this._items=[],this._showDropdown=!1,this._actions=[],this._isOrderActions=!1}async getActions(){let t={param:{entityName:this._entityName,resourceID:this._resourceID}};return p.get().callServiceBroker("ActionButtonsSP.getActions",t).then((t=>{var i;(null===(i=t.actions)||void 0===i?void 0:i.action)&&(this._actions=this._isOrderActions?d.sortAlphabetically(t.actions.action,"description"):t.actions.action)}))}controlDropdown(){this._showDropdown=!this._showDropdown}canShowDropdown(){var t;return this._showDropdown&&(null===(t=this._items)||void 0===t?void 0:t.length)>0}positionDropdown(){var t;const i=null===(t=this._ezButton)||void 0===t?void 0:t.getBoundingClientRect();i&&this._dropdownParent&&(this._dropdownParent.style.top=i.y+i.height+5+"px",this._dropdownParent.style.left=i.x+"px")}closeDropdown(t){const i=null==t?void 0:t.target;i&&(i.closest(".snk-actions-button")||(this._showDropdown=!1))}setEvents(){document.removeEventListener("click",this.closeDropdown.bind(this)),document.addEventListener("click",this.closeDropdown.bind(this)),document.removeEventListener("scroll",this.positionDropdown.bind(this)),document.addEventListener("scroll",this.positionDropdown.bind(this))}async componentWillLoad(){this._application=o.getContextValue("__SNK__APPLICATION__"),this._isOrderActions=await this._application.getBooleanParam("global.ordenar.acoes.personalizadas");const t=this._element.parentElement;this._dataUnit=null==t?void 0:t.dataUnit,this._resourceID=null==t?void 0:t.resourceID,this._entityName=this._dataUnit.name.split("/")[2],null==this._resourceID&&(this._resourceID=await v.getResourceID()),this.setEvents(),this.getActions().then((()=>{this.loadItems()}))}async componentDidLoad(){if(this._element&&(u.addIDInfo(this._element),this.positionDropdown(),!await this._application.hasClientEvent(this.CLIENT_EVENT_CONFIRM_NAME))){const t=new N;this._application.addClientEvent(this.CLIENT_EVENT_CONFIRM_NAME,t.clientConfirm)}}componentDidUpdate(){this.positionDropdown()}loadItems(){this._actions&&0!=this._actions.length&&this._actions.forEach((t=>{this._items.push({id:t.actionID,label:t.description})}))}getElementID(t){return{[u.DATA_ELEMENT_ID_ATTRIBUTE_NAME]:u.getInternalIDInfo(t)}}render(){return i(s,null,this._actions&&this._actions.length>0&&i("div",{class:`ez-padding-left--medium snk-actions-button\n ${this.canShowDropdown()?" ez-elevation--16":""}\n `},i("ez-button",Object.assign({ref:t=>this._ezButton=t,iconName:"acao",size:"small",mode:"icon",title:this._application.messagesBuilder.getMessage("snkActionsButton.title.actions",void 0),onClick:()=>this.controlDropdown()},this.getElementID("button"))),i("div",Object.assign({ref:t=>this._dropdownParent=t,class:(this.canShowDropdown()?"snk-actions-button__dropdown--show":"snk-actions-button__dropdown")+"\n "},this.getElementID("dropdown")),this.canShowDropdown()&&i("ez-dropdown",Object.assign({items:this._items,onEzClick:t=>this.handleClick(t)},this.getElementID("dropdown"))))),this.canShowDropdown()&&i("div",Object.assign({class:"ez-scrim ez-scrim--light"},this.getElementID("ezScrim"))))}get _element(){return e(this)}};x.style=".sc-snk-actions-button-h{display:flex;width:fit-content;height:fit-content}.snk-actions-button.sc-snk-actions-button{display:flex;width:fit-content;height:fit-content}.snk-actions-button__dropdown--show.sc-snk-actions-button{display:flex;flex-direction:column;position:fixed}.snk-actions-button__dropdown.sc-snk-actions-button>ez-dropdown.sc-snk-actions-button{position:relative}.snk-actions-button__dropdown.sc-snk-actions-button{display:none}";const O=class{constructor(i){t(this,i),this.taskbarActionSelected=n(this,"taskbarActionSelected",7),this.taskbarActionsOpened=n(this,"taskbarActionsOpened",7),this.taskbarActionsButtonDisconnected=n(this,"taskbarActionsButtonDisconnected",7),this._showDropdown=!1,this.title=void 0,this.enabled=void 0,this.actions=void 0}async handleKeyDown(t){"Escape"!==t.key&&"Esc"!==t.key||await this.hideActions()}async handleClose(){await this.hideActions()}async showActions(){this._showDropdown=!0,requestAnimationFrame((()=>{this._element.scrollIntoView({behavior:"smooth",block:"nearest",inline:"nearest"})}))}async hideActions(){this._showDropdown=!1}async isOpened(){return this._showDropdown}controlDropdown(){this._showDropdown=!this._showDropdown}loadItems(){return this.actions.filter((t=>void 0!==t)).map((t=>{var i;return{id:t.value,label:t.label,value:t.value,type:null!==(i=t.type)&&void 0!==i?i:"item",children:t.children,iconName:t.iconName,subAction:t.subAction,group:t.group,disableCloseOnSelect:t.disableCloseOnSelect}}))}canShowDropdown(){var t;return this._showDropdown&&(null===(t=this.actions)||void 0===t?void 0:t.length)>0}onSelectAction(t){const i=this.actions.map((t=>Object.assign(Object.assign({},t),{id:t.value}))),s=this.getSelectedAction(t.id,i);this.taskbarActionSelected.emit(s),s.disableCloseOnSelect||(this._showDropdown=!1)}getSelectedAction(t,i){let s;for(const e of i){if(e.id===t){s=e;break}(null==e?void 0:e.children)&&(s=this.getSelectedAction(t,e.children))}return s}dropdownItemBuilder(t,s){const e=this.actions.find((i=>i.value===t.id));if(!e||!e.itemBuilder)return;const n=e.itemBuilder(this._element,e);return"string"==typeof n?i("div",{innerHTML:n}):n}initializeEagerItems(){var t;null===(t=this.actions)||void 0===t||t.forEach((t=>{var i;t&&t.eagerInitialize&&t.itemBuilder&&(null===(i=t.itemBuilder)||void 0===i||i.call(t,this._element,t))}))}componentDidLoad(){this.initializeEagerItems()}componentDidRender(){this._showDropdown&&this.taskbarActionsOpened.emit(this._element)}disconnectedCallback(){this.taskbarActionsButtonDisconnected.emit()}render(){return i(s,null,i("div",{class:"ez-padding-left--medium "+(this.canShowDropdown()?" ez-elevation--16":"")},i("ez-button",{title:this.title,mode:"icon",iconName:"dots-vertical",size:"small",enabled:this.enabled,onClick:()=>this.controlDropdown()}),this.canShowDropdown()&&i("ez-dropdown",{items:this.loadItems(),onEzClick:t=>this.onSelectAction(t.detail),onEzOutsideClick:()=>this._showDropdown=!1,itemBuilder:(t,i)=>this.dropdownItemBuilder(t,i)})))}get _element(){return e(this)}};O.style=".sc-taskbar-actions-button-h{display:flex;width:fit-content;height:fit-content}";export{x as snk_actions_button,O as taskbar_actions_button}
@@ -1 +0,0 @@
1
- export{S as snk_guides_viewer}from"./p-a91bb13d.js";import"./p-d2d301a6.js";import"@sankhyalabs/core";import"./p-573a07c5.js";import"./p-aa95fb2c.js";import"./p-0d7863ed.js";import"./p-9695f78b.js";import"./p-8d884fab.js";import"@sankhyalabs/core/dist/dataunit/metadata/UnitMetadata";import"./p-ff1990ad.js";import"@sankhyalabs/ezui/dist/collection/utils/form";import"./p-c2495304.js";import"./p-374d03f6.js";import"./p-38289a55.js";import"./p-6dc031de.js";import"./p-b0ef4383.js";import"./p-d9bb09b3.js";import"./p-9e7d65a4.js";import"@sankhyalabs/ezui/dist/collection/utils/constants";import"./p-bf93a748.js";import"./p-c22c1d8e.js";import"@sankhyalabs/ezui/dist/collection/components/ez-grid/utils";import"./p-688dcb4c.js";import"@sankhyalabs/core/dist/dataunit/DataUnit";
@@ -1,6 +0,0 @@
1
- import{DataType as e}from"@sankhyalabs/core";import{d as t,D as i}from"./p-9695f78b.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(t,r,o,s){var a;const l=(null==r?void 0:r.toString().trim())||void 0;r=isNaN(Number(l))&&l?`%${l}`:l,null==o||o.params.forEach((t=>{t.dataType===e.OBJECT&&(t.value=JSON.stringify(t.value))}));const u=this.applySearchListener(n.beforeSearch,t,r,o,s),c={argument:(null==u?void 0:u.argument)||r,entityName:t,criteria:(null==u?void 0:u.criteria)||o,options:(null==u?void 0:u.searchOptions)||s};return c.options&&(null===(a=c.options)||void 0===a||delete a.dataUnitId),new Promise(((e,t)=>{i.get().callGraphQL({values:c,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}
@@ -1,15 +0,0 @@
1
- import { Change, DataUnit, DataUnitAction, Filter, LoadDataRequest, LoadDataResponse, SavedRecord } from "@sankhyalabs/core";
2
- import { AttachFetcher } from "../../../lib/http/data-fetcher/fetchers/attach-fetcher";
3
- export declare class AttachmentDataUnitBuilder {
4
- private entityName;
5
- private getMessage;
6
- private _application;
7
- private loader;
8
- constructor(entityName: string, getMessage: Function);
9
- initLoaders(dataUnit: DataUnit, attachFetcher: AttachFetcher, onSuccess: (data?: any) => void): void;
10
- dataLoader(dataUnit: DataUnit, request: LoadDataRequest): Promise<LoadDataResponse>;
11
- saveLoader(changes: Array<Change>, attachFetcher: AttachFetcher): Promise<Array<SavedRecord>>;
12
- removeLoader(dataUnit: DataUnit, ids: string[], attachFetcher: AttachFetcher): Promise<string[]>;
13
- getFilters(registerKey: string): Array<Filter>;
14
- getInterceptions(dataUnit: DataUnit, action: DataUnitAction, crudRef: HTMLSnkSimpleCrudElement): Promise<DataUnitAction>;
15
- }