@sankhyalabs/sankhyablocks 8.15.0-dev.9 → 8.15.0-rc.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 (159) 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 +33 -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 +25 -3
  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 +39 -2
  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/parameters-fecher.js +21 -0
  51. package/dist/collection/lib/http/data-fetcher/fetchers/pesquisa-fetcher.js +7 -1
  52. package/dist/collection/lib/index.js +1 -1
  53. package/dist/collection/lib/message/resources/snk-attach.msg.js +13 -0
  54. package/dist/components/SnkMessageBuilder.js +13 -0
  55. package/dist/components/dataunit-fetcher.js +54 -27
  56. package/dist/components/snk-actions-button2.js +1 -0
  57. package/dist/components/snk-application2.js +32 -1
  58. package/dist/components/snk-attach2.js +394 -57
  59. package/dist/components/snk-data-exporter2.js +1 -1
  60. package/dist/components/snk-filter-bar2.js +26 -3
  61. package/dist/components/snk-filter-item2.js +4 -47
  62. package/dist/components/snk-filter-modal.js +4 -2
  63. package/dist/components/snk-filter-multi-select.js +2 -1
  64. package/dist/components/snk-pesquisa2.js +1 -1
  65. package/dist/components/snk-simple-crud2.js +15 -1
  66. package/dist/components/taskbar-actions-button2.js +3 -1
  67. package/dist/esm/{ISave-4412b20c.js → ISave-d8c8bc59.js} +1 -0
  68. package/dist/esm/{SnkMessageBuilder-ca843d1b.js → SnkMessageBuilder-0fb796b9.js} +13 -0
  69. package/dist/esm/loader.js +1 -1
  70. package/dist/esm/{dataunit-fetcher-0fc935a0.js → pesquisa-fetcher-fa0c2540.js} +215 -27
  71. package/dist/esm/sankhyablocks.js +1 -1
  72. package/dist/esm/snk-actions-button_2.entry.js +5 -4
  73. package/dist/esm/snk-application.entry.js +32 -3
  74. package/dist/esm/snk-attach.entry.js +389 -58
  75. package/dist/esm/snk-crud.entry.js +2 -3
  76. package/dist/esm/snk-data-exporter.entry.js +3 -3
  77. package/dist/esm/{snk-data-unit-6208ebf0.js → snk-data-unit-5d201fb3.js} +1 -1
  78. package/dist/esm/snk-data-unit.entry.js +2 -2
  79. package/dist/esm/snk-detail-view.entry.js +4 -5
  80. package/dist/esm/snk-filter-bar.entry.js +25 -3
  81. package/dist/esm/snk-filter-item.entry.js +4 -47
  82. package/dist/esm/snk-filter-modal.entry.js +2 -1
  83. package/dist/esm/snk-filter-multi-select.entry.js +2 -1
  84. package/dist/esm/{snk-guides-viewer-98a8e45e.js → snk-guides-viewer-f49613c6.js} +2 -3
  85. package/dist/esm/snk-guides-viewer.entry.js +3 -4
  86. package/dist/esm/snk-pesquisa.entry.js +1 -1
  87. package/dist/esm/snk-simple-crud.entry.js +15 -4
  88. package/dist/sankhyablocks/p-02e3a45b.entry.js +1 -0
  89. package/dist/sankhyablocks/{p-ff6064e7.js → p-05243555.js} +1 -1
  90. package/dist/sankhyablocks/p-0ec5b2e5.js +1 -0
  91. package/dist/sankhyablocks/{p-9e7d65a4.js → p-21749402.js} +1 -1
  92. package/dist/sankhyablocks/p-2582537c.entry.js +1 -0
  93. package/dist/sankhyablocks/p-282789a6.entry.js +1 -0
  94. package/dist/sankhyablocks/p-3b0e4e08.js +65 -0
  95. package/dist/sankhyablocks/{p-0874adb5.entry.js → p-40915359.entry.js} +1 -1
  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-96ef14f9.entry.js +1 -0
  99. package/dist/sankhyablocks/p-9b5944a4.entry.js +1 -0
  100. package/dist/sankhyablocks/p-9bdbc7d8.entry.js +1 -0
  101. package/dist/sankhyablocks/{p-90f9b4db.entry.js → p-a52b9254.entry.js} +3 -3
  102. package/dist/sankhyablocks/p-ac384baf.entry.js +1 -0
  103. package/dist/sankhyablocks/p-bf2acf72.entry.js +1 -0
  104. package/dist/sankhyablocks/p-c4874327.entry.js +1 -0
  105. package/dist/sankhyablocks/{p-247a8b36.entry.js → p-d1791da2.entry.js} +1 -1
  106. package/dist/sankhyablocks/{p-32f0935f.js → p-f3d1c48e.js} +1 -1
  107. package/dist/sankhyablocks/sankhyablocks.esm.js +1 -1
  108. package/dist/types/components/snk-actions-button/subcomponents/snk-actions-form.d.ts +1 -1
  109. package/dist/types/components/snk-application/snk-application.d.ts +7 -0
  110. package/dist/types/components/snk-attach/{structure/crud-config-builder.d.ts → interfaces/ICrudConfig.d.ts} +1 -2
  111. package/dist/types/components/snk-attach/interfaces/TFetcherType.d.ts +1 -0
  112. package/dist/types/components/snk-attach/snk-attach.d.ts +27 -6
  113. package/dist/types/components/snk-attach/structure/builder/anexo-sistema-crud-config.builder.d.ts +2 -0
  114. package/dist/types/components/snk-attach/structure/builder/attach-crud-config.builder.d.ts +31 -0
  115. package/dist/types/components/snk-attach/structure/{taskbar-builder.d.ts → builder/taskbar-builder.d.ts} +1 -1
  116. package/dist/types/components/snk-attach/structure/fetcher/facade/fetcher.facade.d.ts +11 -0
  117. package/dist/types/components/snk-attach/structure/fetcher/factory/anexo-sistema-data-unit.factory.d.ts +17 -0
  118. package/dist/types/components/snk-attach/structure/fetcher/factory/attach-fetcher-data-unit.factory.d.ts +15 -0
  119. package/dist/types/components/snk-attach/structure/index.d.ts +6 -3
  120. package/dist/types/components/snk-filter-bar/filter-item/snk-filter-item.d.ts +1 -2
  121. package/dist/types/components/snk-filter-bar/filter-modal/snk-filter-modal.d.ts +5 -0
  122. package/dist/types/components/snk-filter-bar/snk-filter-bar.d.ts +7 -0
  123. package/dist/types/components/snk-filter-bar/utils/SnkFilterModalFactory.d.ts +3 -1
  124. package/dist/types/components/snk-simple-crud/snk-simple-crud.d.ts +10 -1
  125. package/dist/types/components.d.ts +74 -2
  126. package/dist/types/lib/http/data-fetcher/DataFetcher.d.ts +1 -1
  127. package/dist/types/lib/http/data-fetcher/fetchers/{attach-fetcher.d.ts → AttachFetcher/anexo-sistema-fetcher.d.ts} +3 -2
  128. package/dist/types/lib/http/data-fetcher/fetchers/AttachFetcher/attach-fetcher.d.ts +11 -0
  129. package/dist/types/lib/http/data-fetcher/fetchers/AttachFetcher/facade/attach-fetcher.facade.d.ts +8 -0
  130. package/dist/types/lib/http/data-fetcher/fetchers/AttachFetcher/index.d.ts +3 -0
  131. package/dist/types/lib/http/data-fetcher/fetchers/{fecthAttach → AttachFetcher}/interfaces/ISave.d.ts +2 -1
  132. package/dist/types/lib/http/data-fetcher/fetchers/data-unit/dataunit-fetcher.d.ts +1 -0
  133. package/dist/types/lib/http/data-fetcher/fetchers/data-unit/loadstrategy/DatasetStrategy.d.ts +1 -0
  134. package/dist/types/lib/http/data-fetcher/fetchers/parameters-fecher.d.ts +1 -0
  135. package/dist/types/lib/index.d.ts +1 -1
  136. package/package.json +5 -5
  137. package/dist/cjs/pesquisa-fetcher-ef050a47.js +0 -167
  138. package/dist/esm/pesquisa-fetcher-dd3ca0a5.js +0 -165
  139. package/dist/sankhyablocks/p-20726710.entry.js +0 -1
  140. package/dist/sankhyablocks/p-41560fd8.entry.js +0 -1
  141. package/dist/sankhyablocks/p-4775a293.entry.js +0 -1
  142. package/dist/sankhyablocks/p-6678d5d4.entry.js +0 -1
  143. package/dist/sankhyablocks/p-71439fd9.entry.js +0 -1
  144. package/dist/sankhyablocks/p-7d8d7fe9.entry.js +0 -1
  145. package/dist/sankhyablocks/p-a91bb13d.js +0 -1
  146. package/dist/sankhyablocks/p-a9e5b094.entry.js +0 -1
  147. package/dist/sankhyablocks/p-abfa8101.entry.js +0 -1
  148. package/dist/sankhyablocks/p-b3020263.entry.js +0 -1
  149. package/dist/sankhyablocks/p-bf93a748.js +0 -60
  150. package/dist/sankhyablocks/p-c6f89389.entry.js +0 -1
  151. package/dist/sankhyablocks/p-cebae710.entry.js +0 -1
  152. package/dist/sankhyablocks/p-d9bb09b3.js +0 -6
  153. package/dist/types/components/snk-attach/structure/data-unit-builder.d.ts +0 -15
  154. /package/dist/collection/{lib/http/data-fetcher/fetchers/fecthAttach/interfaces/IDelete.js → components/snk-attach/interfaces/ICrudConfig.js} +0 -0
  155. /package/dist/collection/{lib/http/data-fetcher/fetchers/fecthAttach/interfaces/IDownloadKey.js → components/snk-attach/interfaces/TFetcherType.js} +0 -0
  156. /package/dist/collection/lib/http/data-fetcher/fetchers/{fecthAttach → AttachFetcher}/interfaces/index.js +0 -0
  157. /package/dist/types/lib/http/data-fetcher/fetchers/{fecthAttach → AttachFetcher}/interfaces/IDelete.d.ts +0 -0
  158. /package/dist/types/lib/http/data-fetcher/fetchers/{fecthAttach → AttachFetcher}/interfaces/IDownloadKey.d.ts +0 -0
  159. /package/dist/types/lib/http/data-fetcher/fetchers/{fecthAttach → AttachFetcher}/interfaces/index.d.ts +0 -0
@@ -1 +0,0 @@
1
- import{r as t,h as i}from"./p-d2d301a6.js";import{ModalAction as e}from"@sankhyalabs/ezui/dist/collection/components/ez-modal-container";import{ApplicationUtils as s}from"@sankhyalabs/ezui/dist/collection/utils";import{F as l}from"./p-d9804798.js";import{F as r}from"./p-ff1990ad.js";import{ObjectUtils as o}from"@sankhyalabs/core";import{P as a}from"./p-057fad05.js";import{F as n}from"./p-fa80e546.js";import"./p-933c0c0b.js";const d=class{constructor(i){t(this,i),this.getMessage=void 0,this.configName=void 0,this.filters=void 0,this.applyFilters=void 0,this.closeModal=void 0,this.addPersonalizedFilter=void 0,this.editPersonalizedFilter=void 0,this.deletePersonalizedFilter=void 0,this.filtersToDelete=[]}deletePersonalizedFilterListener(t){this.filtersToDelete.push(t.detail)}getCustomMessage(t,i){var e;return null===(e=this.getMessage)||void 0===e?void 0:e.call(this,`snkFilterBar.filterModal.${t}`,i)}handleClearAll(){const{customFilters:t,quickFilters:i,otherFilters:e,multiListFilters:s}=this.filters.reduce(((t,i)=>i.type===r.MULTI_LIST?(t.multiListFilters.push(i),t):i.filterType===l.QUICK_FILTER?(t.quickFilters.push(i),t):i.filterType===l.CUSTOM_FILTER?(t.customFilters.push(i),t):i.filterType===l.OTHER_FILTERS?(t.otherFilters.push(i),t):t),{quickFilters:[],customFilters:[],otherFilters:[],multiListFilters:[]});this.handleClearFilterList(i),this.handleClearCustomFilters(t),this.handleClearOthersFilters(e),s.forEach((t=>this.handleClearSigleFilter(t)))}handleClearOthersFilters(t){this.filters=this.filters.map((i=>t.includes(i)?Object.assign(Object.assign({},i),{value:void 0}):i))}handleClearCustomFilters(t){this.filters.forEach(((i,e)=>{i.filterType===l.CUSTOM_FILTER&&(this.filters[e]=this.clearAllCustomFilter(t).shift())}))}clearAllCustomFilter(t){return t.map((t=>{const i=Object.assign({},t);return delete i.value,i.visible=!1,i.groupedItems&&(i.groupedItems=this.clearAllCustomFilter(i.groupedItems)),i}))}handleClose(){if(o.objectToString(this.filters)!==o.objectToString(this._originalFilterConfig))return s.confirm(this.getCustomMessage("validations.notSaved.title"),this.getCustomMessage("validations.notSaved.message")).then((t=>{t&&this.closeModal()}));this.closeModal()}handleApplyFilters(){const t=this.filters.find((t=>t.filterType===l.CUSTOM_FILTER));this.isValidCustomFilter(t)&&this.applyFilters(this.filters),this.filtersToDelete.length>0&&(this.filtersToDelete.forEach((t=>{this.deletePersonalizedFilter(t,this.configName)})),this.filtersToDelete=[])}isValidCustomFilter(t){return!!a.validateVariableValues(t)||(s.alert(this.getCustomMessage("validations.notFullFilled.title"),this.getCustomMessage("validations.notFullFilled.message")),!1)}modalActionListener(t){switch(t.detail){case e.CANCEL:this.handleClearAll();break;case e.OK:this.handleApplyFilters();break;case e.CLOSE:this.handleClose()}}handleFilterChange(t){this.filters=this.filters.map((i=>i.id===t.id?t:i))}handleClearFilterList(t){this.filters=this.filters.map((i=>t.includes(i)?Object.assign(Object.assign({},i),{value:void 0}):i))}handleClearSigleFilter(t){if(r.MULTI_LIST===t.type){let i=o.copy(t);this.uncheckFilterValues(i.value);const e=o.copy(this.filters),s=e.findIndex((i=>i.id===t.id));return e.splice(s,1,i),void(this.filters=o.copy(e))}if(r.CHECK_BOX_LIST===t.type){const i=o.copy(this.filters);return i.find((i=>i.id===t.id)).value=void 0,void(this.filters=o.copy(i))}this.filters.find((i=>i.id===t.id)).value=void 0}uncheckFilterValues(t){return t.forEach((t=>{t&&(t.check=!1)})),t}renderFilterItem(t,e){return i("snk-filter-modal-item",{class:e?"ez-col ez-col--sd-12":"ez-col ez-col--sd-6 ez-padding--small",filterItem:t,configName:this.configName,onFilterChange:t=>this.handleFilterChange(t.detail),onEditPersonalizedFilter:t=>this.editPersonalizedFilter(t.detail),onAddPersonalizedFilter:()=>this.addPersonalizedFilter()})}isDefaultFilterNumberVariation(t){var i;return t.type===r.NUMBER&&(!t.props.variation||(null===(i=t.props)||void 0===i?void 0:i.variation)===n.DEFAULT)}mountFiltersLines(t){let i=0,e=!1;const s={};for(let l=0;l<t.length;l++){s[i]=s[i]||[];const o=t[l],a=l===t.length-1,n=o.type===r.TEXT||this.isDefaultFilterNumberVariation(o),d=!a&&(t[l+1].type===r.TEXT||this.isDefaultFilterNumberVariation(t[l+1]));n&&d||e?(s[i].push(o),e=s[i].length<2,2===s[i].length&&++i):(s[i]=s[i]||[],s[i].push(o),++i)}return Object.values(s)}renderFilterLine(t){const i=1===t.length;return t.map((t=>this.renderFilterItem(t,i)))}getIformedFiltersCount(t){let i=0;return t.forEach((t=>{var e,s,l,o,a,n;r.MULTI_LIST!==t.type?r.CHECK_BOX_LIST!==t.type?null==t.groupedItems?t.value&&i++:i=t.groupedItems.filter((t=>t.visible)).length:i+=Object.entries(null!==(n=t.value)&&void 0!==n?n:{}).filter((([t,i])=>!0===i)).map((([t,i])=>t)).length:i+=null!==(a=null===(o=null===(l=null!==(s=null===(e=t.value)||void 0===e?void 0:e.elements)&&void 0!==s?s:t.value)||void 0===l?void 0:l.filter((t=>null==t?void 0:t.check)))||void 0===o?void 0:o.length)&&void 0!==a?a:0})),i}renderCollapsibleFilterBox(t,e,s,l=!0){if(!e.length)return null;const r=this.getIformedFiltersCount(e),o=this.mountFiltersLines(e);return i("ez-collapsible-box",{class:"snk-filter-modal__collapsible-box",headerSize:"medium",value:!0,label:t},!!r&&i("ez-badge",{class:"ez-badge--primary-subtle",slot:"rightSlot",label:null==r?void 0:r.toString()}),i("div",{class:"ez-row snk-filter-modal__rendered-items"},o.map(this.renderFilterLine.bind(this))),l&&i("div",{class:"ez-flex ez-flex--justify-end grow"},i("ez-button",{class:"ez-button--tertiary",size:"medium",label:"Limpar",onClick:()=>s?this.handleClearSigleFilter(e[0]):this.handleClearFilterList(e)})))}componentWillRender(){this._modalTitle=this.getCustomMessage("title"),this._okButtonLabel=this.getCustomMessage("okButtonLabel"),this._cancelButtonLabel=this.getCustomMessage("cancelButtonLabel")}componentDidLoad(){this._originalFilterConfig||(this._originalFilterConfig=this.filters)}render(){const t=this.filters.filter((t=>t.filterType===l.CUSTOM_FILTER)),e=this.filters.filter((t=>t.filterType===l.QUICK_FILTER)),s=this.filters.filter((t=>t.filterType===l.OTHER_FILTERS));return i("ez-modal-container",{class:"snk-filter-modal__container",modalTitle:this._modalTitle,cancelButtonLabel:this._cancelButtonLabel,okButtonLabel:this._okButtonLabel,onEzModalAction:this.modalActionListener.bind(this)},i("div",{class:"snk-filter-modal__content ez-col--sd-12"},this.renderCollapsibleFilterBox(this.getCustomMessage("customFilters"),t,!1,!1),this.renderCollapsibleFilterBox(this.getCustomMessage("quickFilters"),e,!1),s.map((t=>this.renderCollapsibleFilterBox(t.label,[t],!0)))))}};d.style="ez-modal{--ez-modal-content-padding:24px 12px}.snk-filter-modal__container{width:344px;max-width:344px;min-width:344px;overflow:hidden}.snk-filter-modal__content{display:flex;flex-direction:column;gap:var(--space--medium, 12px);padding-right:var(--space--3xs, 4px)}.snk-filter-modal__collapsible-box{border:var(--border--small, 1px solid) var(--color--strokes, #DCE0E8);border-radius:var(--border--radius-medium);padding:var(--space--medium, 12px) var(--space--small, 6px)}.snk-filter-modal__rendered-items{max-height:760px;overflow-x:clip;overflow-y:auto}.snk-filter-modal__rendered-items::-webkit-scrollbar{width:var(--space--small);min-width:var(--space--small);max-width:var(--space--small)}";export{d as snk_filter_modal}
@@ -1 +0,0 @@
1
- import{r as t,c as i,h as e}from"./p-d2d301a6.js";import{ApplicationContext as s,DataType as n,Action as a}from"@sankhyalabs/core";import{D as r}from"./p-9695f78b.js";import{S as o}from"./p-9e7d65a4.js";import{d as h}from"./p-b0ef4383.js";import{D as l}from"./p-bf93a748.js";import{P as d}from"./p-c22c1d8e.js";import{T as c}from"./p-374d03f6.js";import"./p-8d884fab.js";import"@sankhyalabs/core/dist/dataunit/metadata/UnitMetadata";import"@sankhyalabs/ezui/dist/collection/utils/constants";import"./p-688dcb4c.js";import"@sankhyalabs/ezui/dist/collection/components/ez-grid/utils";import"./p-38289a55.js";import"./p-6dc031de.js";class m{constructor(t,i,e){var s;this.entityName=t,this.registerKey=i,this.dataUnitName=e,this.validateFields=t=>{if(t.LINK&&t.NOMEARQUIVO)throw new Error(o.LINK_AND_FILE_AT_THE_SAME_TIME);if(!t.LINK&&!t.NOMEARQUIVO)throw new Error(o.ANY_LINK_OR_FILE_FILLED);if(!this.registerKey)throw new Error("Register key can not be null")},this.resourceID=window.resourceID||(null===(s=window.workspace)||void 0===s?void 0:s.resourceID)}async save(t){var i,e;const s="AnexoSistemaSP.salvar";let{updatingFields:n}=t;n=Object.assign(Object.assign({},n),{NOMEARQUIVO:null===(i=n.NOMEARQUIVO)||void 0===i?void 0:i[0]});try{this.validateFields(n);const t=n.LINK?null:n.NOMEARQUIVO,i={serviceName:s,requestBody:{params:{resourceID:this.resourceID,description:n.DESCRICAO,fileSelect:t?1:0,keySession:null===(e=null==t?void 0:t.properties)||void 0===e?void 0:e.fileNameTmp,nameAttach:null==t?void 0:t.name,link:n.LINK,nameEntity:this.entityName,pkEntity:this.registerKey,typeAcess:n.TIPOACESSO,typeApres:n.TIPOAPRES}}},a=await r.get().callServiceBroker(s,JSON.stringify(i));return Promise.resolve([Object.assign(Object.assign(Object.assign({},a),n),{ARQUIVOOULINK:n.LINK?n.LINK:null==t?void 0:t.name,__owner__dataunit__name__:this.dataUnitName})])}catch(t){return Promise.reject(t)}}async edit(t){var i,e,s;const n="AnexoSistemaSP.salvar";let{updatingFields:a,record:o}=t;const h=t=>void 0!==a[t]?a[t]:o[t],l=h("NOMEARQUIVO"),d=null===(e=null===(i=a.NOMEARQUIVO)||void 0===i?void 0:i[0])||void 0===e?void 0:e.downloadURL;a=Object.assign(Object.assign({},a),{DESCRICAO:h("DESCRICAO"),LINK:h("LINK"),TIPOACESSO:h("TIPOACESSO"),TIPOAPRES:h("TIPOAPRES"),CHAVEARQUIVO:o.CHAVEARQUIVO,NOMEARQUIVO:null==l?void 0:l[0]});const c=a.LINK?null:a.NOMEARQUIVO;try{this.validateFields(a);const t={serviceName:n,requestBody:{params:{resourceID:this.resourceID,nuAttach:null==o?void 0:o.NUATTACH,description:a.DESCRICAO,fileSelect:d?1:0,keySession:null===(s=null==c?void 0:c.properties)||void 0===s?void 0:s.fileNameTmp,keyAttach:a.CHAVEARQUIVO,nameAttach:null==c?void 0:c.name,link:a.LINK,nameEntity:this.entityName,pkEntity:this.registerKey,typeAcess:a.TIPOACESSO,typeApres:a.TIPOAPRES}}},i=await r.get().callServiceBroker(n,JSON.stringify(t));return Promise.resolve([Object.assign(Object.assign(Object.assign({},i),a),{ARQUIVOOULINK:a.LINK?a.LINK:null==c?void 0:c.name,__owner__dataunit__name__:this.dataUnitName})])}catch(t){return Promise.reject(t)}}delete(t){var i;const e="AnexoSistemaSP.excluir",s=(null===(i=t.NOMEARQUIVO)||void 0===i?void 0:i[0])||{},n={serviceName:e,requestBody:{paramsDelete:{keyAttach:t.CHAVEARQUIVO,nameAttach:null==s?void 0:s.name,nameEntity:t.NOMEINSTANCIA,nuAttach:t.NUATTACH,pkEntity:t.PKREGISTRO}}};return new Promise(((t,i)=>{r.get().callServiceBroker(e,JSON.stringify(n)).then((i=>t(i))).catch((t=>i(t)))}))}getDownloadKey(t){var i;const e="AnexoSistemaSP.baixar",s=(null===(i=t.NOMEARQUIVO)||void 0===i?void 0:i[0])||{},n={serviceName:e,requestBody:{paramsDown:{nameAttach:null==s?void 0:s.name,nameEntity:t.NOMEINSTANCIA,nuAttach:t.NUATTACH,pkEntity:t.PKREGISTRO,keyAttach:t.CHAVEARQUIVO}}};return new Promise(((t,i)=>{r.get().callServiceBroker(e,JSON.stringify(n)).then((i=>t(i))).catch((t=>i(t)))}))}}class u{constructor(t,i){this.entityName=t,this.getMessage=i,this._application=s.getContextValue("__SNK__APPLICATION__")}initLoaders(t,i,e){this.loader||(this.loader=t.dataLoader),t.dataLoader=(t,i)=>this.dataLoader(t,i),t.saveLoader=(t,s)=>this.saveLoader(s,i).then((t=>(t.length&&e(),t))),t.removeLoader=(t,s)=>this.removeLoader(t,s,i).then((t=>(t.length&&e(),t)))}dataLoader(t,i){return new Promise((e=>{this.loader(t,i).then((t=>{const i=((null==t?void 0:t.records)||[]).map((t=>{let i;return t.LINK||(i=[{name:t.NOMEARQUIVO}]),Object.assign(Object.assign({},t),{ARQUIVOOULINK:t.LINK?t.LINK:t.NOMEARQUIVO,NOMEARQUIVO:i})}));e(Object.assign(Object.assign({},t),{records:i}))}))}))}saveLoader(t,i){return new Promise((e=>{var s;const n=Array.isArray(t)?t[0]:{};((null===(s=null==n?void 0:n.record)||void 0===s?void 0:s.NUATTACH)>=0?i.edit.bind(i):i.save.bind(i))(n).then((t=>{e(t)})).catch((t=>t.message===o.LINK_AND_FILE_AT_THE_SAME_TIME?(this._application.alert(this.getMessage("snkAttach.alertValidation.fileAndLinkAtTheSameTime.title"),this.getMessage("snkAttach.alertValidation.fileAndLinkAtTheSameTime.message")),e([])):t.message===o.ANY_LINK_OR_FILE_FILLED?(this._application.alert(this.getMessage("snkAttach.alertValidation.anyLinkOrFileFilled.title"),this.getMessage("snkAttach.alertValidation.anyLinkOrFileFilled.message")),e([])):t.message?(this._application.error(t.title||t.name,t.message),e([])):void e([])))}))}removeLoader(t,i,e){return new Promise((s=>{const{records:n}=t.getSelectionInfo(),a=n[0];e.delete(a).then((()=>(d.removeRecords(t,[a]),s(i))))}))}getFilters(t){return[{name:"AttachmentsByPK",expression:"this.PKREGISTRO = :PKREGISTRO",params:[{name:"PKREGISTRO",dataType:n.TEXT,value:`${t}_${this.entityName}`}]}]}getInterceptions(t,i,e){return new Promise((s=>i.type===a.EDITION_CANCELED?t.isDirty()?this._application.confirm(this.getMessage("snkAttach.cancelConfirmation.title"),this.getMessage("snkAttach.cancelConfirmation.message")).then((t=>t?(e.goToView(h.GRID),s(i)):s(void 0))):s(i):i.type===a.DATA_SAVED?(t.loadData(),s(i)):void s(i)))}}const v=s.getContextValue("__SNK__APPLICATION__"),A=t=>{var i,e;return null===(e=null===(i=null==v?void 0:v.messagesBuilder)||void 0===i?void 0:i.getMessage)||void 0===e?void 0:e.call(i,t,null)},O={DOWNLOAD:{hint:A("snkAttach.taskbar.titleDownload"),name:"DOWNLOAD",iconName:"file-download"},LINK:{hint:A("snkAttach.taskbar.titleLink"),name:"LINK",iconName:"launch"}},p=()=>{const t=[c.REMOVE,"DOWNLOAD","LINK"];return{getButtons:(t,i,e)=>{if((null==i?void 0:i.insertionMode)||(null==i?void 0:i.isDirty))return e.reverse();e.splice(e.indexOf(c.REFRESH),1);const{selectedRecord:s}=i||{},n=(null==s?void 0:s.LINK)?O.LINK:O.DOWNLOAD;e.splice(e.indexOf(c.DIVIDER)+1,0,c.REMOVE,n,c.DIVIDER);const a=Array.from(new Set(e.filter((t=>t!==c.CLONE))));return a.splice(a.indexOf(n)+1,0,c.DIVIDER),a},isEnabled:(i,e,s)=>{const n=void 0!==(null==e?void 0:e.selectedRecord);return!(t.includes(s)&&!n)}}},k={grid:{columns:[{name:"ARQUIVOOULINK",orderIndex:0,width:0},{name:"DESCRICAO",orderIndex:1,width:0},{name:"DHCAD",orderIndex:2,width:0},{name:"DHALTER",orderIndex:3,width:0},{name:"TIPOAPRES",orderIndex:4,width:0},{name:"TIPOACESSO",orderIndex:5,width:0},{name:"CODUSU",orderIndex:6,width:0},{name:"CODUSUALT",orderIndex:7,width:0}]},form:{emptyConfig:!1,fields:[{name:"DESCRICAO",required:!0},{name:"TIPOAPRES",required:!0},{name:"TIPOACESSO",required:!0},{name:"LINK"},{name:"NOMEARQUIVO"}]}},I=class{constructor(e){t(this,e),this.back=i(this,"back",7),this.handleTaskbarClick=({detail:t})=>{if(["DOWNLOAD","LINK"].includes(t))return this.downloadAttachment(this.dataUnit.getSelectedRecord())},this.handleBack=()=>{this.dataUnit.cancelEdition().then((t=>{t&&this.back.emit()}))},this.handleFinish=()=>{if(!this.dataUnit.isDirty())return this.back.emit();this.dataUnit.saveData().then((()=>{this.showFinishedToast(),this.back.emit()}))},this.registerKey=void 0,this.entityName=void 0,this.messagesBuilder=void 0,this.dataUnit=void 0,this.crudConfig=void 0}registerKeyWatcher(t,i){var e;null==this.dataUnit&&this.loadAttachmentDataUnit(),i!==t&&(this.returnToGridMode(),this._attachFetcher=new m(this.entityName,this.registerKey,null===(e=this.dataUnit)||void 0===e?void 0:e.name),this._dataUnitBuilder.initLoaders(this.dataUnit,this._attachFetcher,(()=>{this.returnToGridMode()})),this.dataUnit.loadData())}getMessage(t,i){if(this.messagesBuilder)return this.messagesBuilder.getMessage(t,i)}showFinishedToast(){this._application.info(this.getMessage("snkAttach.finishedMessage"),{iconName:"check"})}downloadAttachment(t){if(!t)throw new Error("Nenhum registro selecionado");t.LINK?window.open(`${t.LINK}`):this._attachFetcher.getDownloadKey(t).then((({chave:t})=>{window.open(`/mge/visualizadorArquivos.mge?chaveArquivo=${t.valor}&forcarDownload=S`)}))}returnToGridMode(){this.dataUnit.clearSelection(),this._crudElement&&this._crudElement.goToView(h.GRID)}loadAttachmentDataUnit(){var t;try{const i=this.dataUnit||(new l).getDataUnit("AnexoSistema","br.com.sankhya.core.v3.anexoSistema");return this._attachFetcher=new m(this.entityName,this.registerKey,null===(t=this.dataUnit)||void 0===t?void 0:t.name),i.metadata||i.loadMetadata().then((()=>{this.crudConfig=k})),this._dataUnitBuilder=new u(this.entityName,this.getMessage.bind(this)),i.addFilterProvider({getFilter:()=>this._dataUnitBuilder.getFilters(this.registerKey)}),i.addInterceptor({interceptAction:t=>this._dataUnitBuilder.getInterceptions(i,t,this._crudElement)}),this.dataUnit=i,this.dataUnit.loadData().then((()=>{this.disableEditFieldsNotInForm()})),this.dataUnit}catch(t){throw new Error("There was an error while creating the data unit")}}disableEditFieldsNotInForm(){var t;null===(t=this.crudConfig)||void 0===t||t.grid.columns.forEach((t=>{var i;const e=t.name;(null===(i=this.crudConfig)||void 0===i?void 0:i.form.fields.some((t=>t.name===e)))||this.dataUnit.disableField(e)}))}componentWillLoad(){this._application=s.getContextValue("__SNK__APPLICATION__")}componentWillRender(){null==this.dataUnit&&this.loadAttachmentDataUnit()}render(){var t,i;return this.dataUnit?e("main",{class:"snk-attach__main"},e("header",{class:"snk-attach__header"},e("snk-simple-bar",{onExit:this.handleBack,messagesBuilder:this.messagesBuilder},e("div",{slot:"rightSlot"},e("ez-button",{class:"ez-button--primary",label:this.getMessage("snkAttach.finish"),onClick:this.handleFinish})))),e("div",{class:"snk-attach__crud-section ez-size-height--full ez-size-width--full ez-flex ez-flex--column"},e("div",{class:"ez-box__container"},e("snk-simple-crud",{ref:t=>this._crudElement=t,dataUnit:this.dataUnit,taskbarManager:p(),gridConfig:null===(t=this.crudConfig)||void 0===t?void 0:t.grid,formConfig:null===(i=this.crudConfig)||void 0===i?void 0:i.form,useCancelConfirm:!1,onActionClick:this.handleTaskbarClick,messagesBuilder:this.messagesBuilder},e("div",{slot:"snkSimpleCrudHeader"},e("div",{class:"ez-flex ez-flex--column"},e("span",{class:"ez-title--primary ez-text ez-text--large ez-text--bold ez-padding-bottom--medium"},this.getMessage("snkAttach.title")),e("span",{class:"ez-text ez-text--medium ez-text--secondary"},this.getMessage("snkAttach.description")))))))):null}static get watchers(){return{registerKey:["registerKeyWatcher"]}}};I.style=".snk-attach__header.sc-snk-attach,.snk-attach__crud-section.sc-snk-attach{padding:0 var(--space--lg)}.snk-attach__file-info.sc-snk-attach{padding:var(--space--small);max-width:50%}.snk-attach__main.sc-snk-attach{height:85%}.ez-box__container.sc-snk-attach{height:100%}";export{I as snk_attach}
@@ -1 +0,0 @@
1
- import{r as t,c as i,h as s,H as e,g as a}from"./p-d2d301a6.js";import{StringUtils as o,ElementIDUtils as n,ApplicationContext as h,JSUtils as r,FloatingManager as c}from"@sankhyalabs/core";import{T as d}from"./p-374d03f6.js";import"./p-9695f78b.js";import"./p-d9bb09b3.js";import{P as l}from"./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{d as m}from"./p-b0ef4383.js";import{A as u}from"./p-e6380c60.js";import"./p-6dc031de.js";import"./p-8d884fab.js";import"./p-688dcb4c.js";import"@sankhyalabs/ezui/dist/collection/components/ez-grid/utils";const p=class{constructor(s){t(this,s),this.actionClick=i(this,"actionClick",7),this.configuratorSave=i(this,"configuratorSave",7),this.configuratorCancel=i(this,"configuratorCancel",7),this.formItemsReady=i(this,"formItemsReady",7),this._keyDownHandler=async t=>this.keyDownListener(t),this._viewHistory=[],this._dataUnit=void 0,this._dataState=void 0,this.attachmentRegisterKey=void 0,this._currentViewMode=m.GRID,this._canEdit=void 0,this._resourceID=void 0,this.configName=void 0,this.selectionToastConfig=void 0,this.showActionButtons=!1,this.actionsList=void 0,this.taskbarManager=void 0,this.recordsValidator=void 0,this.statusResolver=void 0,this.multipleSelection=!0,this.presentationMode=l.PRIMARY,this.messagesBuilder=void 0,this.useEnterLikeTab=!1,this.customContainerId=`SNK-CRUD-CUSTOM-CONTAINER-${o.generateUUID()}`}async goToView(t){this.executeAction(t)}async openConfigurator(){var t;null===(t=this._snkConfigurator)||void 0===t||t.open()}async closeConfigurator(){var t;null===(t=this._snkConfigurator)||void 0===t||t.close()}async reloadFilterBar(){var t;null===(t=this._snkGrid)||void 0===t||t.reloadFilterBar()}async getFilterBar(){return await this._snkGrid.getFilterBar()}currentViewModeWatcher(t){this._viewHistory=[...this._viewHistory.slice(-1),t]}async gridToForm(t=!1){this._backToGrid=!t&&await this._viewStack.getSelectedIndex()===m.GRID,this.setViewMode(m.FORM)}async executeAction(t){return t===d.GRID_MODE?this.setViewMode(m.GRID):t===d.FORM_MODE||t===d.UPDATE?this.gridToForm(t!==d.UPDATE):t===d.CONFIGURATOR?this._snkConfigurator.open():"ATTACH"===t?this.setViewMode(m.ATTACHMENT):void 0}backView(){const t=this._viewHistory.at(-2)||m.GRID;this.setViewMode(t)}setViewMode(t){this._viewStack.show(t),this._currentViewMode=t}openConfig(t){this._snkConfigurator.close(),t===m.GRID?this._snkGrid.showConfig():t===m.FORM&&this._guidesViewer.showFormConfig()}addDataElementID(){n.addIDInfo(this._element,null,{dataUnit:this._dataUnit})}insertionModeHandler(){this.gridToForm()}cancelHandler(){this._backToGrid&&this.setViewMode(m.GRID)}async getAttachmentRegisterKey(){if(this._snkDataUnit)return(await this._snkDataUnit.getSelectedRecordsIDsInfo()).map((({value:t})=>t)).join("_")}componentWillLoad(){this._application=h.getContextValue("__SNK__APPLICATION__");let t=this._element.parentElement;for(this._application.hasAccess(u.UPDATE,this._resourceID).then((t=>this._canEdit=t));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.initDataUnit():this._snkDataUnit.addEventListener("dataUnitReady",(t=>{this._dataUnit=t.detail,this.initDataUnit()})),this._snkDataUnit.addEventListener("dataStateChange",(async({detail:t})=>{this._dataState=t,void 0!==t.selectedRecord&&(this.attachmentRegisterKey=await this.getAttachmentRegisterKey())}));break}t=t.parentElement}this.configName||(this.configName=this._application.configName)}componentDidLoad(){this.initKeyboardManager()}disconnectedCallback(){this.removeShortcuts(),window.removeEventListener("keydown",this._keyDownHandler)}async initKeyboardManager(){const t=await this._application.getKeyboardManager();if(t){const i=this._dataUnit||await this._snkDataUnit.getDataUnit();async function s(){const t=document.activeElement,s=t==document.body;s||t.blur(),await i.saveData(),s||null==t.setFocus?s||t.focus():t.setFocus()}t.bind("F6",this.toggleView.bind(this),{description:"Alterna entre modo formulário e grade."}).bind("F7",s.bind(this),{description:"Salva os dados."}).bind("ctrl + \\",s.bind(this),{description:"Salva os dados."}).bind("F8",i.addRecord.bind(i),{description:"Adiciona um novo registro."}).bind("F9",i.removeSelectedRecords.bind(i),{description:"Remove o registro selecionado."}).bind("ctrl + F9",i.removeSelectedRecords.bind(i),{description:"Remove o registro selecionado."}).bind("ctrl + .",(()=>0===i.getSelectionInfo().records.length?i.selectFirst():i.nextRecord()),{description:"Avança para o próximo registro."}).bind("ctrl + ,",i.previousRecord.bind(i),{description:"Retorna ao registro anterior."}).bind("F5",(async()=>{const t=await this._viewStack.getSelectedIndex();m.GRID===t&&i.loadData()}),{description:"Atualiza os dados."}).bind("Escape",(()=>{i.isDirty()&&i.cancelEdition()}),{debounceTime:1e3,description:"Cancela uma ação."})}}async removeShortcuts(){const t=await this._application.getKeyboardManager();t&&t.unbind("F6").unbind("F7").unbind("ctrl + \\").unbind("F8").unbind("F9").unbind("ctrl + F9").unbind("ctrl + .").unbind("ctrl + ,").unbind("F5").unbind("Escape")}async toggleView(){const t=await this._viewStack.getSelectedIndex();this.setViewMode(m.GRID===t?m.FORM:m.GRID)}async initDataUnit(){this.addDataElementID(),this.messagesBuilder||(this.messagesBuilder=this._snkDataUnit.messagesBuilder),null==this._resourceID&&(this._resourceID=this._snkDataUnit.resourceID,null==this._resourceID&&(this._resourceID=await this._application.getResourceID()))}handleConfiguratorEvent(t,i){t.stopImmediatePropagation(),"SAVE"!==i?this.configuratorCancel.emit():this.configuratorSave.emit()}async keyDownListener(t){t.ctrlKey&&null!=t.key&&"F"===t.key.toUpperCase()&&null!=this._element&&(r.isHiddenElement(this._element)||(c.closeAll(),this._currentViewMode===m.GRID?await this._snkGrid.findColumn():await this._guidesViewer.findField(),t.preventDefault()))}connectedCallback(){window.addEventListener("keydown",this._keyDownHandler,{capture:!0})}render(){if(null!=this._resourceID)return this._snkDataUnit.ignoreSaveMessage=this._currentViewMode===m.GRID,s(e,null,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),messagesBuilder:this.messagesBuilder,actionsList:this.actionsList,statusResolver:this.statusResolver,multipleSelection:this.multipleSelection,presentationMode:this.presentationMode,recordsValidator:this.recordsValidator,selectionToastConfig:this.selectionToastConfig,useEnterLikeTab:this.useEnterLikeTab,canEdit:this._canEdit,resourceID:this._resourceID},s("slot",{name:"GRID_TASKBAR_CUSTOM_ELEMENTS"}),s("slot",{name:"GRID_HEADER_CUSTOM_ELEMENTS"}),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,messagesBuilder:this.messagesBuilder,onExit:()=>this.setViewMode(m.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",canEdit:this._canEdit,recordsValidator:this.recordsValidator,resourceID:this._resourceID,detailTaskbarCustomContainerId:this.customContainerId},s("slot",{name:"GUIDES_VIEWER_TASKBAR_CUSTOM_ELEMENTS"}),s("slot",{name:"SnkFormTaskBar"}))),s("stack-item",null,s("snk-attach",{registerKey:this.attachmentRegisterKey,messagesBuilder:this.messagesBuilder,entityName:this._snkDataUnit.entityName,onBack:this.backView.bind(this)})),s("snk-configurator",{ref:t=>this._snkConfigurator=t,viewMode:this._currentViewMode,messagesBuilder:this.messagesBuilder,onConfigSelected:t=>this.setViewMode(t.detail),onOpenConfig:t=>this.openConfig(t.detail),showActionButtons:this.showActionButtons,onSave:t=>this.handleConfiguratorEvent(t,"SAVE"),onCancel:t=>this.handleConfiguratorEvent(t,"CANCEL"),resourceID:this._resourceID,customContainerId:this.customContainerId})),s("div",{id:`${this.customContainerId}`},s("slot",{name:"SnkConfigContainerSlot"}),s("slot",{name:"DETAIL_GRID_HEADER_CUSTOM_ELEMENTS"}),s("slot",{name:"DETAIL_GRID_TASKBAR_CUSTOM_ELEMENTS"}),s("slot",{name:"DETAIL_TASKBAR_CUSTOM_ELEMENTS"})))}get _element(){return a(this)}static get watchers(){return{_currentViewMode:["currentViewModeWatcher"]}}};p.style=".sc-snk-crud-h{display:flex;flex-direction:column;height:100%;width:100%}";export{p as snk_crud}
@@ -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
- }