@sankhyalabs/sankhyablocks 10.1.0-dev.13 → 10.1.0-dev.15

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 (199) hide show
  1. package/dist/cjs/{ConfigStorage-5c0590b3.js → ConfigStorage-a4e1e518.js} +2 -2
  2. package/dist/cjs/{DataFetcher-5181a917.js → DataFetcher-0b6aa084.js} +11 -22
  3. package/dist/cjs/{ISave-0f98a457.js → ISave-2c455a77.js} +1 -1
  4. package/dist/cjs/{SnkFormConfigManager-1907ffed.js → SnkFormConfigManager-b8c81493.js} +2 -2
  5. package/dist/cjs/{SnkMultiSelectionListDataSource-e4e38139.js → SnkMultiSelectionListDataSource-72925620.js} +5 -5
  6. package/dist/cjs/{auth-fetcher-cff55b1f.js → auth-fetcher-7e7796c9.js} +1 -1
  7. package/dist/cjs/config-header.cjs.entry.js +1 -1
  8. package/dist/cjs/configs-button.cjs.entry.js +1 -1
  9. package/dist/cjs/{dataunit-fetcher-1ba5e2cc.js → dataunit-fetcher-8dffbcdf.js} +1 -1
  10. package/dist/cjs/field-config_2.cjs.entry.js +1 -1
  11. package/dist/cjs/fields-layout.cjs.entry.js +1 -1
  12. package/dist/cjs/fields-selector.cjs.entry.js +1 -1
  13. package/dist/cjs/{form-config-fetcher-4a679e23.js → form-config-fetcher-5516d68a.js} +1 -1
  14. package/dist/cjs/guides-configurator.cjs.entry.js +1 -1
  15. package/dist/cjs/{index-13d05f03.js → index-516250fa.js} +1 -1
  16. package/dist/cjs/{index-1cf293c1.js → index-dc83c596.js} +0 -17
  17. package/dist/cjs/loader.cjs.js +1 -1
  18. package/dist/cjs/pesquisa-grid_2.cjs.entry.js +5 -5
  19. package/dist/cjs/sankhyablocks.cjs.js +1 -1
  20. package/dist/cjs/snk-actions-button_9.cjs.entry.js +6 -6
  21. package/dist/cjs/snk-actions-form.cjs.entry.js +1 -1
  22. package/dist/cjs/snk-application.cjs.entry.js +7 -7
  23. package/dist/cjs/snk-attach.cjs.entry.js +8 -8
  24. package/dist/cjs/snk-client-confirm.cjs.entry.js +1 -1
  25. package/dist/cjs/snk-configurator.cjs.entry.js +1 -1
  26. package/dist/cjs/snk-crud.cjs.entry.js +8 -8
  27. package/dist/cjs/snk-custom-slot-elements.cjs.entry.js +1 -1
  28. package/dist/cjs/snk-custom-slot-guide.cjs.entry.js +1 -1
  29. package/dist/cjs/snk-data-exporter.cjs.entry.js +6 -6
  30. package/dist/cjs/{snk-data-unit-061487a8.js → snk-data-unit-47f02b9e.js} +3 -3
  31. package/dist/cjs/snk-data-unit.cjs.entry.js +4 -4
  32. package/dist/cjs/snk-default-filter.cjs.entry.js +1 -1
  33. package/dist/cjs/snk-detail-view.cjs.entry.js +10 -10
  34. package/dist/cjs/snk-entity-list.cjs.entry.js +1 -1
  35. package/dist/cjs/snk-exporter-email-sender.cjs.entry.js +1 -1
  36. package/dist/cjs/snk-expression-group_2.cjs.entry.js +2 -2
  37. package/dist/cjs/snk-filter-advanced-mode_2.cjs.entry.js +1 -1
  38. package/dist/cjs/snk-filter-bar_4.cjs.entry.js +4 -4
  39. package/dist/cjs/snk-filter-binary-select.cjs.entry.js +1 -1
  40. package/dist/cjs/snk-filter-checkbox-list.cjs.entry.js +1 -1
  41. package/dist/cjs/snk-filter-detail.cjs.entry.js +1 -1
  42. package/dist/cjs/snk-filter-field-search_2.cjs.entry.js +1 -1
  43. package/dist/cjs/snk-filter-modal-item.cjs.entry.js +4 -4
  44. package/dist/cjs/snk-filter-multi-select.cjs.entry.js +1 -1
  45. package/dist/cjs/snk-filter-number.cjs.entry.js +1 -1
  46. package/dist/cjs/snk-filter-period.cjs.entry.js +1 -1
  47. package/dist/cjs/snk-filter-search.cjs.entry.js +1 -1
  48. package/dist/cjs/snk-filter-text.cjs.entry.js +1 -1
  49. package/dist/cjs/snk-form-summary.cjs.entry.js +1 -1
  50. package/dist/cjs/snk-form-view.cjs.entry.js +1 -1
  51. package/dist/cjs/snk-form_2.cjs.entry.js +5 -5
  52. package/dist/cjs/snk-grid.cjs.entry.js +20 -14
  53. package/dist/cjs/{snk-guides-viewer-2efe60a7.js → snk-guides-viewer-41c22d96.js} +7 -7
  54. package/dist/cjs/snk-guides-viewer.cjs.entry.js +10 -10
  55. package/dist/cjs/snk-personalized-filter-editor.cjs.entry.js +1 -1
  56. package/dist/cjs/snk-personalized-filter.cjs.entry.js +5 -5
  57. package/dist/cjs/snk-pesquisa.cjs.entry.js +5 -5
  58. package/dist/cjs/snk-print-selector.cjs.entry.js +1 -1
  59. package/dist/cjs/snk-simple-bar.cjs.entry.js +1 -1
  60. package/dist/cjs/snk-simple-crud.cjs.entry.js +10 -10
  61. package/dist/cjs/snk-taskbar.cjs.entry.js +3 -3
  62. package/dist/cjs/{taskbar-elements-fb5d1e08.js → taskbar-elements-756fcbe7.js} +2 -2
  63. package/dist/cjs/teste-pesquisa.cjs.entry.js +1 -1
  64. package/dist/collection/components/snk-grid/snk-grid.js +12 -7
  65. package/dist/collection/lib/message/SnkMessageBuilder.js +11 -2
  66. package/dist/components/DataFetcher.js +11 -2
  67. package/dist/components/snk-grid2.js +12 -6
  68. package/dist/esm/{ConfigStorage-bd096633.js → ConfigStorage-39ac8fef.js} +2 -2
  69. package/dist/esm/{DataFetcher-5780ad39.js → DataFetcher-0b9da57d.js} +11 -2
  70. package/dist/esm/{ISave-8a22ec18.js → ISave-f1c9269b.js} +1 -1
  71. package/dist/esm/{SnkFormConfigManager-437e98bb.js → SnkFormConfigManager-a87566c8.js} +2 -2
  72. package/dist/esm/{SnkMultiSelectionListDataSource-42125ef4.js → SnkMultiSelectionListDataSource-493ae8c8.js} +5 -5
  73. package/dist/esm/{auth-fetcher-28b9d0db.js → auth-fetcher-acdc1cb4.js} +1 -1
  74. package/dist/esm/config-header.entry.js +1 -1
  75. package/dist/esm/configs-button.entry.js +1 -1
  76. package/dist/esm/{dataunit-fetcher-c4251d80.js → dataunit-fetcher-4c312b43.js} +1 -1
  77. package/dist/esm/field-config_2.entry.js +1 -1
  78. package/dist/esm/fields-layout.entry.js +1 -1
  79. package/dist/esm/fields-selector.entry.js +1 -1
  80. package/dist/esm/{form-config-fetcher-d0536a71.js → form-config-fetcher-7cda6254.js} +1 -1
  81. package/dist/esm/guides-configurator.entry.js +1 -1
  82. package/dist/esm/{index-446f9341.js → index-3355bd17.js} +1 -1
  83. package/dist/esm/{index-479e1293.js → index-7fd74680.js} +0 -17
  84. package/dist/esm/loader.js +2 -2
  85. package/dist/esm/pesquisa-grid_2.entry.js +5 -5
  86. package/dist/esm/sankhyablocks.js +2 -2
  87. package/dist/esm/snk-actions-button_9.entry.js +6 -6
  88. package/dist/esm/snk-actions-form.entry.js +1 -1
  89. package/dist/esm/snk-application.entry.js +7 -7
  90. package/dist/esm/snk-attach.entry.js +8 -8
  91. package/dist/esm/snk-client-confirm.entry.js +1 -1
  92. package/dist/esm/snk-configurator.entry.js +1 -1
  93. package/dist/esm/snk-crud.entry.js +8 -8
  94. package/dist/esm/snk-custom-slot-elements.entry.js +1 -1
  95. package/dist/esm/snk-custom-slot-guide.entry.js +1 -1
  96. package/dist/esm/snk-data-exporter.entry.js +6 -6
  97. package/dist/esm/{snk-data-unit-4a1ef77f.js → snk-data-unit-9e9d9d46.js} +3 -3
  98. package/dist/esm/snk-data-unit.entry.js +4 -4
  99. package/dist/esm/snk-default-filter.entry.js +1 -1
  100. package/dist/esm/snk-detail-view.entry.js +10 -10
  101. package/dist/esm/snk-entity-list.entry.js +1 -1
  102. package/dist/esm/snk-exporter-email-sender.entry.js +1 -1
  103. package/dist/esm/snk-expression-group_2.entry.js +2 -2
  104. package/dist/esm/snk-filter-advanced-mode_2.entry.js +1 -1
  105. package/dist/esm/snk-filter-bar_4.entry.js +4 -4
  106. package/dist/esm/snk-filter-binary-select.entry.js +1 -1
  107. package/dist/esm/snk-filter-checkbox-list.entry.js +1 -1
  108. package/dist/esm/snk-filter-detail.entry.js +1 -1
  109. package/dist/esm/snk-filter-field-search_2.entry.js +1 -1
  110. package/dist/esm/snk-filter-modal-item.entry.js +4 -4
  111. package/dist/esm/snk-filter-multi-select.entry.js +1 -1
  112. package/dist/esm/snk-filter-number.entry.js +1 -1
  113. package/dist/esm/snk-filter-period.entry.js +1 -1
  114. package/dist/esm/snk-filter-search.entry.js +1 -1
  115. package/dist/esm/snk-filter-text.entry.js +1 -1
  116. package/dist/esm/snk-form-summary.entry.js +1 -1
  117. package/dist/esm/snk-form-view.entry.js +1 -1
  118. package/dist/esm/snk-form_2.entry.js +5 -5
  119. package/dist/esm/snk-grid.entry.js +20 -14
  120. package/dist/esm/{snk-guides-viewer-c182d058.js → snk-guides-viewer-31ef5fc6.js} +7 -7
  121. package/dist/esm/snk-guides-viewer.entry.js +10 -10
  122. package/dist/esm/snk-personalized-filter-editor.entry.js +1 -1
  123. package/dist/esm/snk-personalized-filter.entry.js +5 -5
  124. package/dist/esm/snk-pesquisa.entry.js +5 -5
  125. package/dist/esm/snk-print-selector.entry.js +1 -1
  126. package/dist/esm/snk-simple-bar.entry.js +1 -1
  127. package/dist/esm/snk-simple-crud.entry.js +10 -10
  128. package/dist/esm/snk-taskbar.entry.js +3 -3
  129. package/dist/esm/{taskbar-elements-faaf5d8f.js → taskbar-elements-bf5b73f1.js} +2 -2
  130. package/dist/esm/teste-pesquisa.entry.js +1 -1
  131. package/dist/sankhyablocks/p-02cb4829.entry.js +1 -0
  132. package/dist/sankhyablocks/{p-78d4b3e3.entry.js → p-0893a694.entry.js} +1 -1
  133. package/dist/sankhyablocks/{p-5d408e7e.entry.js → p-0da30fd9.entry.js} +1 -1
  134. package/dist/sankhyablocks/{p-55d7abe7.js → p-156c9f38.js} +1 -1
  135. package/dist/sankhyablocks/{p-f35f2eb3.entry.js → p-17856827.entry.js} +1 -1
  136. package/dist/sankhyablocks/{p-b987e15d.js → p-1be69fd4.js} +1 -1
  137. package/dist/sankhyablocks/{p-e679c75a.entry.js → p-1dba30c9.entry.js} +1 -1
  138. package/dist/sankhyablocks/{p-21107f0d.entry.js → p-1e469905.entry.js} +1 -1
  139. package/dist/sankhyablocks/{p-0e4f8b86.js → p-1f310bc6.js} +1 -1
  140. package/dist/sankhyablocks/{p-96d45943.entry.js → p-227e82b2.entry.js} +1 -1
  141. package/dist/sankhyablocks/p-2624dfd2.entry.js +1 -0
  142. package/dist/sankhyablocks/{p-aca74b21.js → p-2ac55a5d.js} +1 -1
  143. package/dist/sankhyablocks/{p-99a11017.entry.js → p-301baf9c.entry.js} +1 -1
  144. package/dist/sankhyablocks/{p-2e882241.entry.js → p-357e10e0.entry.js} +1 -1
  145. package/dist/sankhyablocks/{p-987cd79d.entry.js → p-35a26068.entry.js} +1 -1
  146. package/dist/sankhyablocks/{p-180716b2.entry.js → p-3671cdd4.entry.js} +1 -1
  147. package/dist/sankhyablocks/{p-27482793.entry.js → p-4575c4aa.entry.js} +1 -1
  148. package/dist/sankhyablocks/{p-3c046287.js → p-48a5c311.js} +2 -2
  149. package/dist/sankhyablocks/{p-3d41f5a8.entry.js → p-497ece60.entry.js} +1 -1
  150. package/dist/sankhyablocks/{p-6e5af618.entry.js → p-4deb7f46.entry.js} +1 -1
  151. package/dist/sankhyablocks/{p-9f16d33e.entry.js → p-4e9e570c.entry.js} +1 -1
  152. package/dist/sankhyablocks/{p-3b167a03.entry.js → p-516411de.entry.js} +1 -1
  153. package/dist/sankhyablocks/{p-162bddae.entry.js → p-522d36aa.entry.js} +1 -1
  154. package/dist/sankhyablocks/p-52691b42.js +1 -0
  155. package/dist/sankhyablocks/{p-825098c1.entry.js → p-56b1b397.entry.js} +1 -1
  156. package/dist/sankhyablocks/{p-d3534985.js → p-59158ba4.js} +1 -1
  157. package/dist/sankhyablocks/{p-c98c79c3.entry.js → p-5c9bea92.entry.js} +1 -1
  158. package/dist/sankhyablocks/{p-91a9abb6.entry.js → p-613eb22e.entry.js} +1 -1
  159. package/dist/sankhyablocks/{p-49ddc27a.entry.js → p-670b8802.entry.js} +1 -1
  160. package/dist/sankhyablocks/{p-60dd1d27.entry.js → p-67137d7c.entry.js} +1 -1
  161. package/dist/sankhyablocks/{p-1b1373b6.js → p-6768f176.js} +1 -1
  162. package/dist/sankhyablocks/{p-03f02b12.entry.js → p-7375bf6a.entry.js} +1 -1
  163. package/dist/sankhyablocks/{p-b7e891cc.entry.js → p-7961c550.entry.js} +1 -1
  164. package/dist/sankhyablocks/{p-4db9dbf8.js → p-7ee6b1bf.js} +1 -1
  165. package/dist/sankhyablocks/{p-75af335e.entry.js → p-82b59a45.entry.js} +1 -1
  166. package/dist/sankhyablocks/p-82bb3eda.js +2 -0
  167. package/dist/sankhyablocks/{p-55798617.js → p-8336900b.js} +1 -1
  168. package/dist/sankhyablocks/{p-d2ec9a24.entry.js → p-8488fa7e.entry.js} +1 -1
  169. package/dist/sankhyablocks/{p-cb4343c4.entry.js → p-8783d550.entry.js} +1 -1
  170. package/dist/sankhyablocks/{p-471b34f4.entry.js → p-8d76a0ca.entry.js} +1 -1
  171. package/dist/sankhyablocks/{p-9a63f3f7.entry.js → p-8d84d6ab.entry.js} +1 -1
  172. package/dist/sankhyablocks/{p-a1d23fef.js → p-907e96eb.js} +1 -1
  173. package/dist/sankhyablocks/{p-e258de96.entry.js → p-939523b3.entry.js} +1 -1
  174. package/dist/sankhyablocks/{p-a9b16874.entry.js → p-959fe522.entry.js} +1 -1
  175. package/dist/sankhyablocks/{p-7e250432.entry.js → p-98c70173.entry.js} +1 -1
  176. package/dist/sankhyablocks/{p-82a3d522.entry.js → p-98e3d0a1.entry.js} +1 -1
  177. package/dist/sankhyablocks/{p-9ab6ae1e.js → p-9e4555ab.js} +2 -2
  178. package/dist/sankhyablocks/{p-2fdac5e6.entry.js → p-abfc9880.entry.js} +1 -1
  179. package/dist/sankhyablocks/{p-1037ea7b.entry.js → p-b5832fa0.entry.js} +1 -1
  180. package/dist/sankhyablocks/{p-01ca59fc.entry.js → p-c2bb0659.entry.js} +1 -1
  181. package/dist/sankhyablocks/{p-7f7fe6c4.entry.js → p-c60d864f.entry.js} +1 -1
  182. package/dist/sankhyablocks/{p-028fb380.entry.js → p-cb7c592f.entry.js} +1 -1
  183. package/dist/sankhyablocks/{p-f3027bc9.entry.js → p-cc68a0c1.entry.js} +1 -1
  184. package/dist/sankhyablocks/{p-c3dbf441.entry.js → p-ce207f2a.entry.js} +1 -1
  185. package/dist/sankhyablocks/{p-c4fcf1fb.entry.js → p-cfa4c183.entry.js} +1 -1
  186. package/dist/sankhyablocks/{p-42272de8.entry.js → p-d5d7fe52.entry.js} +1 -1
  187. package/dist/sankhyablocks/{p-b04db4ac.entry.js → p-dd89bc02.entry.js} +1 -1
  188. package/dist/sankhyablocks/{p-667cab42.entry.js → p-def17f0e.entry.js} +1 -1
  189. package/dist/sankhyablocks/p-e41c86b2.entry.js +1 -0
  190. package/dist/sankhyablocks/{p-4c2e2767.entry.js → p-e47d6f17.entry.js} +1 -1
  191. package/dist/sankhyablocks/{p-7345782c.entry.js → p-fd1a5a61.entry.js} +1 -1
  192. package/dist/sankhyablocks/sankhyablocks.esm.js +1 -1
  193. package/dist/types/components/snk-grid/snk-grid.d.ts +1 -0
  194. package/package.json +1 -1
  195. package/dist/sankhyablocks/p-30a58e29.entry.js +0 -1
  196. package/dist/sankhyablocks/p-903fa0b4.entry.js +0 -1
  197. package/dist/sankhyablocks/p-b9699067.js +0 -1
  198. package/dist/sankhyablocks/p-d8d8169b.js +0 -2
  199. package/dist/sankhyablocks/p-fd05e31d.entry.js +0 -1
@@ -1 +1 @@
1
- import{r as t,c as i,h as s,g as e,H as n}from"./p-d8d8169b.js";import{ApplicationContext as a,Action as r,ObjectUtils as o,DataUnitAction as h,StringUtils as d}from"@sankhyalabs/core";import{ApplicationUtils as l,DialogType as c}from"@sankhyalabs/ezui/dist/collection/utils";import{O as u,S as v}from"./p-1b1373b6.js";import{g as m,a as f}from"./p-9ab6ae1e.js";import{convertType as p}from"@sankhyalabs/core/dist/dataunit/metadata/DataType";import{g as b}from"./p-7dd49d15.js";const g="__NO_TAB_NAME__";const w=class{constructor(s){t(this,s),this.dataStateChange=i(this,"dataStateChange",3),this.dataUnitReady=i(this,"dataUnitReady",3),this.messagesBuilderUpdated=i(this,"messagesBuilderUpdated",3),this.dataUnitFieldsHidded=i(this,"dataUnitFieldsHidded",7),this.insertionMode=i(this,"insertionMode",3),this.cancelEdition=i(this,"cancelEdition",3),this._onDataUnitResolve=[],this._openedAlert=!1,this._fieldsWithRmp=[],this._fieldsWithRmPrecision=[],this._metadataByRow=new Map,this._rowMetadataCache=new Map,this._formFieldsConfig=[],this.REGEX_DATAUNIT_NAME=/dd:\/\/(.+?)\//,this._dataUnitObserver=async t=>{const i=await this.buildDataState(t.type);switch(this.dataState=i,this.messagesBuilder.currentOperation=this.getMessageOperation(),t.type){case r.DATA_SAVED:await this.handleDataSaved(t);break;case r.RECORDS_ADDED:case r.RECORDS_COPIED:this.insertionMode.emit();break;case r.EDITION_CANCELED:this.cancelEdition.emit();break;case r.RECORDS_REMOVED:this.handleRecordsRemoved(t);break;case r.METADATA_LOADED:this.fillFieldsWithRmp(this.dataUnit.metadata),this.fillFieldsWithRmPrecision(this.dataUnit.metadata)}},this.fieldsToLink=[],this.dataState=void 0,this.messagesBuilder=void 0,this.dataUnitName=void 0,this.entityName=void 0,this.pageSize=150,this.dataUnit=void 0,this.beforeSave=void 0,this.afterSave=void 0,this.useCancelConfirm=!0,this.ignoreSaveMessage=void 0,this.configName=void 0,this.resourceID=void 0,this.domainMessagesBuilder=void 0}observePageSize(){this.dataUnit&&(this.dataUnit.pageSize=this.pageSize)}observeDataUnitName(t,i){i!=t&&(this.dataUnit?this._application.updateDataunitCache(i,this.dataUnitName,this.dataUnit):this.loadDataUnit())}observeEntityName(t,i){i!=t&&(this.dataUnit=void 0,this.entityName=t,this.loadDataUnit())}observeDataState(t,i){o.objectToString(i)!=o.objectToString(t)&&this.dataStateChange.emit(t)}observeDataUnit(){this.handlerLinkFields(),this.dataUnitReady.emit(this.dataUnit)}observeMessagesBuilder(t){t&&this.messagesBuilderUpdated.emit(t)}onMasterFormConfigChange({detail:t}){var i;this._formFieldsConfig=null!==(i=null==t?void 0:t.fields)&&void 0!==i?i:[]}async getDataUnit(){return new Promise((t=>{this.dataUnit?t(this.dataUnit):this._onDataUnitResolve.push(t)}))}async getSelectedRecordsIDsInfo(){return b(this.dataUnit)}async getFieldsWithRmp(){return this._fieldsWithRmp}async getFieldsWithRmPrecision(){return this._fieldsWithRmPrecision}async getRowMetadata(t){return this.doGetRowMetadata(t)}async doGetRowMetadata(t){const i=this.dataUnit.getSelectedRecord();if(!t&&!i)return;const s=t||i,e="string"==typeof s?s:s.__record__id__;let n=this._metadataByRow.get(e);return this.dataUnit.isNewRecord(e)&&!n&&(n=await this.handleLoadRowMetadata(i)),n?(n.getProp=this.buildGetPropRowMetadata(n),Object.assign({},n)):void 0}buildGetPropRowMetadata(t){return(i,s)=>("rm_precision"===i&&(i=this.resolvePrecisionFromMetadata(s)),o.getProp(t,i))}resolvePrecisionFromMetadata(t){var i,s;if(!t)return void l.error(this.getMessage("snkDataUnit.fieldNameRequired"));const e=null===(s=null===(i=this.dataUnit.getField(t))||void 0===i?void 0:i.properties)||void 0===s?void 0:s.rm_precision;return e?e.split(".").filter(((t,i)=>1!==i)).join("."):""}getCleanOnCopyFields(){var t;return null===(t=this.dataUnit.metadata)||void 0===t?void 0:t.fields.filter((t=>{var i;return null===(i=t.properties)||void 0===i?void 0:i.cleanOnCopy})).map((t=>t.name))}fillFieldsWithRmp(t){t.fields.forEach((t=>{var i;(null===(i=t.properties)||void 0===i?void 0:i.rmp)&&!this._fieldsWithRmp.includes(t.name)&&this._fieldsWithRmp.push(t.name)}))}fillFieldsWithRmPrecision(t){t.fields.forEach((t=>{var i;(null===(i=t.properties)||void 0===i?void 0:i.rm_precision)&&!this._fieldsWithRmPrecision.includes(t.name)&&this._fieldsWithRmPrecision.push(t.name)}))}getCacheName(t,i,s){return[t,i,s].join("_")}updateDataStateRmp(t){const i=Object.assign({},t);this.dataState.rowMetadata=i}saveCacheRmd(t){const i=t.__record__metadata__,s=Object.keys(i);s.shift(),s.forEach((s=>{const e=m(t,s),n=this.getCacheName(s,i.provider,e);this._rowMetadataCache.set(n,Object.assign({},i))}))}getMetadataByRow(t){var i;if(!(null===(i=t.records)||void 0===i?void 0:i.length))return t;if(!this._fieldsWithRmp.length){const i=t.records.map((t=>(delete t.__record__metadata__,t)));return Object.assign(Object.assign({},t),{records:i})}const s=t.records.map((t=>{if(!t.__record__metadata__)return t;this.saveCacheRmd(t);const i=Object.assign({},t.__record__metadata__);return i.getProp=this.buildGetPropRowMetadata(i),this._metadataByRow.set(t.__record__id__,i),delete t.__record__metadata__,t}));return Object.assign(Object.assign({},t),{records:s})}interceptRecordsAdded(t){if(this.isAllowed("INSERT"))return new h(r.RECORDS_ADDED,this.handleLinksWithParent(t.payload));l.info(this.getMessage("snkDataUnit.forbiddenInsert"))}interceptRecordsCopied(t){if(this.isAllowed("CLONE"))return new h(r.RECORDS_COPIED,this.handleRecordsCopied(t.payload));l.info(this.getMessage("snkDataUnit.forbiddenClone"))}async interceptDataChange(t){var i;const s=null===(i=this.dataUnit.getSelectedRecord())||void 0===i?void 0:i.__record__id__;if(this.isAllowed("UPDATE")||this.dataUnit.isNewRecord(s))return t;this._openedAlert?await this.dataUnit.cancelEdition():(this._openedAlert=!0,await this.dataUnit.cancelEdition(),await l.alert(this.getMessage("snkDataUnit.forbidden"),this.getMessage("snkDataUnit.forbiddenUpdate")),this._openedAlert=!1)}async interceptSavingData(t){if(this.dataUnit.isMultipleEdition&&!await this.confirmMultipleSavingData())return;if(!this.beforeSave)return t;const i=this.beforeSave(this.dataUnit);return i instanceof Promise?await i?t:void 0:i?t:void 0}async confirmMultipleSavingData(){const t=this.dataUnit.getSelectionInfo().records,i=this.getMessage("snkDataUnit.multipleUpdateConfirmationTitle"),s=this.getMessage("snkDataUnit.multipleUpdateConfirmationMessage",{size:t.length}),e=this.getMessage("snkDataUnit.confirm.cancel"),n=this.getMessage("snkDataUnit.confirm.updateMultipleConfirm");return await async function({title:t,labelBtnConfirm:i,labelBtnCancel:s,message:e,changingFields:n}){return new Promise((r=>{const o=function(t,i){const s=document.createElement("ez-popup");return s.opened=!0,s.size="small",s.ezTitle=t,s.heightMode="auto",s.addEventListener("ezClosePopup",(()=>{document.body.removeChild(s),i(!1)}),{once:!0}),s.addEventListener("ezPopupAction",(()=>{document.body.removeChild(s),i(!1)}),{once:!0}),s}(t,r),h=function(){const t=document.createElement("div");return t.style.display="flex",t.style.flexDirection="column",t.style.fontFamily="var(--font-pattern, Roboto)",t.style.fontSize="var(--text--medium, 14px)",t}();h.appendChild(function(t){const i=document.createElement("p");return i.textContent=t,i.style.fontSize="var(--text--medium, 14px)",i}(e)),h.appendChild(function(t){const i=document.createElement("div");i.style.flexDirection="column",i.style.display="flex",i.style.overflow="auto",i.style.maxHeight="300px";const s=function(t){const i=new Map;return t.forEach((t=>{var s;const e=null!==(s=t.tabName)&&void 0!==s?s:g;i.has(e)||i.set(e,[]),i.get(e).push(t)})),i}(t);return s.forEach(((t,s)=>{i.appendChild(function(t,i){const s=document.createElement("span");s.innerText=function(t){const i=a.getContextValue("__SNK__APPLICATION__").messagesBuilder.getMessage("snkDataUnit.main");switch(t){case g:return"";case"__main":return i;default:return t}}(t),s.style.display="block",s.style.fontWeight="var(--text-weight--large, 500)",s.style.fontSize="var(--text--medium, 14px)",s.style.marginBottom="var(--space--small, 6px)";const e=document.createElement("div");return e.style.padding="var(--space--medium, 12px) 0",e.style.borderTop="1px solid var(--color--disable-secondary, #f2f5f8)",e.appendChild(s),i.forEach((t=>{const i=document.createElement("span");i.innerHTML=`${t.label}: <span style="color: var(--text--primary, #626e82)">${t.value}</span>`,i.style.display="block",i.style.marginBottom="var(--space--extra-small, 3px)",e.appendChild(i)})),e}(s,t))})),i}(n));const d=function(){const t=document.createElement("div");return t.style.display="flex",t.style.flexDirection="row",t.style.justifyContent="flex-end",t.style.gap="5px",t}();d.appendChild(function(t,i,s){const e=document.createElement("ez-button");return e.label=i,e.size="medium",e.onclick=()=>{document.body.removeChild(t),s(!1)},e}(o,s,r)),d.appendChild(function(t,i,s){const e=document.createElement("ez-button");return e.label=i,e.size="medium",e.classList.add("ez-button--primary"),e.onclick=()=>{document.body.removeChild(t),s(!0)},e}(o,i,r)),h.appendChild(d),o.appendChild(h),document.body.appendChild(o)}))}({title:i,message:s,labelBtnConfirm:n,labelBtnCancel:e,changingFields:this.getChangingFields()})}getChangingFields(){const t=this.dataUnit.buildChangesToSave();if(!(null==t?void 0:t.length))return[];const i=t[0];return Object.keys(i.updatingFields).map((t=>this.buildChangingField(t,i[t])))}buildChangingField(t,i){return{label:this.dataUnit.getField(t).label,value:this.dataUnit.getFormattedValue(t,i),tabName:this.getFieldTabName(t)}}getFieldTabName(t){var i;const s=null===(i=this._formFieldsConfig.find((i=>i.name===t)))||void 0===i?void 0:i.tab;if(s)return"string"==typeof s?s:s.label}interceptDataSaved(t){if(!this.afterSave)return t;this.afterSave(this.dataUnit)}async interceptEditionCanceled(t){var i,s;if(!this.useCancelConfirm||!this.dataState.hasDirtyRecords||(null===(i=t.payload)||void 0===i?void 0:i.fromParent)||(null===(s=t.payload)||void 0===s?void 0:s.silent))return t;const e=this.getMessage("snkDataUnit.cancelConfirmation");if(null==e)return this.showSuccessMessage(this.getMessage("snkDataUnit.cancelInfo")),t;const n=this.getMessage("snkDataUnit.cancelConfirmationTitle"),a=await l.confirm(n,e);if(a){let t;if(this.dataUnit.isMultipleEdition){const i=this.dataUnit.getSelectionInfo().records;t=this.buildMultipleUpdateMessage(i,!0)}else t=this.getMessage("snkDataUnit.cancelInfo");this.showSuccessMessage(t)}return a?t:void 0}async interceptRemovingRecords(t){var i,s,e;if(!this.isAllowed("REMOVE"))return void l.info(this.getMessage("snkDataUnit.forbiddenRemove"));let n=!1,a=!(null===(i=t.payload)||void 0===i?void 0:i.silent)&&this.getMessage("snkDataUnit.removeConfirmation");const r=null===(s=this.dataUnit)||void 0===s?void 0:s.getSelectionInfo();if(!(null===(e=t.payload)||void 0===e?void 0:e.silent)&&(null==r?void 0:r.length)>1&&(a=this.getMessage("snkDataUnit.removeAllConfirmation",{size:r.length}),n=!0),!a)return t;const o={canClose:!1,labelCancel:this.getMessage("snkDataUnit.confirm."+(n?"no":"cancel")),labelConfirm:this.getMessage("snkDataUnit.confirm."+(n?"yes":"delete")),btnConfirmDanger:!1},h=this.getMessage("snkDataUnit.removeConfirmationTitle");return await l.confirm(h,a,null,c.WARN,o)?t:void 0}interceptDataLoaded(t){const i=this.getMetadataByRow(t.payload);return new h(r.DATA_LOADED,i)}interceptMetadataLoaded(t){return this.fillFieldsWithRmp(t.payload),this.fillFieldsWithRmPrecision(t.payload),new h(r.METADATA_LOADED,this.handleDULinksOnMetadataLoaded(t.payload))}async interceptAction(t){switch(t.type){case r.RECORDS_ADDED:return this.interceptRecordsAdded(t);case r.RECORDS_COPIED:return this.interceptRecordsCopied(t);case r.DATA_CHANGED:return await this.handleLoadRowMetadata(t.payload),await this.interceptDataChange(t);case r.CHANGING_DATA:return await this.interceptDataChange(t);case r.SAVING_DATA:return await this.interceptSavingData(t);case r.DATA_SAVED:return this.interceptDataSaved(t);case r.EDITION_CANCELED:return await this.interceptEditionCanceled(t);case r.REMOVING_RECORDS:return await this.interceptRemovingRecords(t);case r.DATA_LOADED:return this.interceptDataLoaded(t);case r.METADATA_LOADED:return this.interceptMetadataLoaded(t);default:return t}}async handleLoadRowMetadata(t){if(!t)return;const i=Object.keys(t).find((t=>this._fieldsWithRmp.includes(t)));if(i){const s=this.dataUnit.getField(i).properties.rmp,e=m(t,i);return await this.updateRowMetadata({fieldName:i,fieldValue:e,metadataName:s,updatedFields:t})}}async updateRowMetadata({fieldName:t,fieldValue:i,metadataName:s,updatedFields:e}){const n=this.getCacheName(t,s,i),a=this._rowMetadataCache.get(n);if(a)return this.updateDataStateRmp(a),a;{const i=new f,a=await i.loadRowMetadata(this,t,s,e);return this.updateDataStateRmp(a._rmd),this._rowMetadataCache.set(n,Object.assign({},a._rmd)),Object.assign({},a._rmd)}}handleDULinksOnMetadataLoaded(t){const i=Object.assign({},t);return this.processLinks(i),i}handleRecordsCopied(t){let i=[...t];return i=this.handleCleanOnCopy(i),this.handleLinksWithParent(i)}handleLinksWithParent(t){var i,s;const e=null!==(i=this._parentDataUnit)&&void 0!==i?i:null===(s=this.dataUnit)||void 0===s?void 0:s.getParentDataUnit();if(!e)return t;const n=e.getSelectedRecord(),a=null==e?void 0:e.getChildInfo(this.getCleanDataUnitName());if(!a)return t;const{links:r}=a;return r&&0!==r.length?t.map((t=>this.buildRecordWithLinkedFields(t,r,n))):t}buildRecordWithLinkedFields(t,i,s){const e=Object.assign({},t);return i.forEach((t=>{const i=p(this.dataUnit.getField(t.target).dataType,s[t.source]);e[t.target]=i})),e}handleCleanOnCopy(t){const i=this.getCleanOnCopyFields();return i.length>0&&(t=t.map((t=>this.buildCopyWithCleanedFields(t,i)))),t}buildCopyWithCleanedFields(t,i){const s=Object.assign({},t);return i.forEach((t=>delete s[t])),s}showSuccessMessage(t){l.info(t,{iconName:"check"})}isAllowed(t){return!!this._permissions&&(this._permissions.isSup||this._permissions[t])}async buildDataState(t){var i;const s=this.dataUnit.getSelectionInfo(),e=(this.dataUnit.hasDirtyRecords()||this.dataUnit.hasWaitingChanges())&&(null==s?void 0:s.isEmpty()),n=this.dataUnit.getSelectedRecord();let a=null===(i=this.dataState)||void 0===i?void 0:i.rowMetadata;return!n||a&&![r.SELECTION_CHANGED,r.EDITION_CANCELED,r.NEXT_SELECTED,r.PREVIOUS_SELECTED].includes(t)?a&&(a.getProp=this.buildGetPropRowMetadata(a)):a=await this.doGetRowMetadata(n),new D({insertionMode:this.dataUnit.hasNewRecord(),isStartingInsertionMode:e,hasNext:this.dataUnit.hasNext(),hasPrevious:this.dataUnit.hasPrevious(),copyMode:this.dataUnit.hasCopiedRecord(),isDirty:this.dataUnit.isDirty(),hasDirtyRecords:this.dataUnit.hasDirtyRecords(),selectedRecords:void 0,selectionInfo:s,selectedRecord:n,recordsIsEmpty:0===this.dataUnit.records.length,metadataByRow:this._metadataByRow,rowMetadata:a})}async handleDataSaved(t){var i,s,e;const n=null===(i=null==t?void 0:t.payload)||void 0===i?void 0:i.changes,a=null===(s=null==t?void 0:t.payload)||void 0===s?void 0:s.records,r=await this.handleLoadRowMetadata(null===(e=null==n?void 0:n[0])||void 0===e?void 0:e.record);r&&(r.getProp=this.buildGetPropRowMetadata(r)),this._metadataByRow.set(a[0].__record__id__,r),this.dataState=await this.buildDataState();let o=n[0]._operation.toLowerCase();if("copy"==o&&(o=u.CLONE),this.canIgnoreOperationMessage(o))return;let h=this.buildOperationMessage(o,a);null!=h&&this.showSuccessMessage(h)}canIgnoreOperationMessage(t){return this.ignoreSaveMessage&&!this.isCloneOrInsertOperation(t)}isCloneOrInsertOperation(t){return[u.CLONE,u.INSERT].includes(t)}buildOperationMessage(t,i){return this.isMultiplesUpdate(t,i)?this.buildMultipleUpdateMessage(i):this.getMessage("snkDataUnit.saveInfo",i[0],t)}buildMultipleUpdateMessage(t,i){return this.getMessage("snkDataUnit."+(i?"cancelInfo":"saveInfo"),{records:t},u.UPDATE_MULTIPLES)}isMultiplesUpdate(t,i){return t===u.UPDATE&&i.length>1}handleRecordsRemoved(t){var i,s;let e=this.buildRemoveFinishMessage(t);null!=e&&this.showSuccessMessage(e);const n=null!==(s=null===(i=this.dataUnit.records)||void 0===i?void 0:i.length)&&void 0!==s?s:0,a=this.dataUnit.getPaginationInfo();a&&this.dataUnit.gotoPage(n>0||a.hasMore?a.currentPage:0)}buildRemoveFinishMessage(t){const i=t.payload.records;if(i&&i.length)return(null==i?void 0:i.length)>1?this.getMessage("snkDataUnit.removeAllInfo",{size:i.length}):this.getMessage("snkDataUnit.removeInfo",i)}getMessage(t,i,s){return i||(i=this.getMessageParams()),s&&(this.messagesBuilder.currentOperation=s),this.messagesBuilder.getMessage(t,i)}getMessageParams(){return this.dataState.selectedRecord}getMessageOperation(){return this.dataState.copyMode?u.CLONE:this.dataState.insertionMode||this.dataState.isStartingInsertionMode?u.INSERT:this.dataState.isDirty?u.UPDATE:u.CLEAN}async getDataUnitParentOrChild(){var t;const i=this.dataUnitName?this.dataUnitName:this.entityName;return this._parentSnkDataUnit?(this._parentDataUnit=await(null===(t=this._parentSnkDataUnit)||void 0===t?void 0:t.getDataUnit()),await this._application.getDataUnit(this.entityName,i,this._parentDataUnit,this.configName,this.resourceID)):await this._application.getDataUnit(this.entityName,i,null,this.configName,this.resourceID)}updateMetadataWithRMP(){this.fillFieldsWithRmp(this.dataUnit.metadata),this.fillFieldsWithRmPrecision(this.dataUnit.metadata);const t=this.handleDULinksOnMetadataLoaded(this.dataUnit.metadata);this.dataUnit.metadata=t}async loadDataUnit(){var t,i;if(null==this.dataUnit&&this._application&&this.entityName&&(this.dataUnit=await this.getDataUnitParentOrChild()),this.dataUnit){if(this.dataUnit.pageSize=this.pageSize,this.dataUnit.unsubscribe(this._dataUnitObserver),this.dataUnit.subscribe(this._dataUnitObserver),(null===(t=this.dataUnit)||void 0===t?void 0:t.metadata)&&this.updateMetadataWithRMP(),this.dataUnit.addInterceptor(this),null===(i=this.dataUnit.records)||void 0===i?void 0:i.length){const{records:t}=this.getMetadataByRow(this.dataUnit);this.dataUnit.setRecordsKeepingSelection(t)}let s;for(this.dataState=await this.buildDataState();s=this._onDataUnitResolve.pop();)s(this.dataUnit)}}getParentSnkDataUnit(){let t=this.element;for(;t.parentNode;){if("SNK-DATA-UNIT"===t.parentNode.nodeName)return t.parentNode;t=t.parentNode}}handlerLinkFields(){var t,i,s,e;const n=null!==(t=this._parentDataUnit)&&void 0!==t?t:null===(i=this.dataUnit)||void 0===i?void 0:i.getParentDataUnit();if(!n)return;const a=null!==(s=this.entityName)&&void 0!==s?s:this.getCleanDataUnitName(),r=n.getChildInfo(a);if(!r)return;const o=null===(e=null==r?void 0:r.links)||void 0===e?void 0:e.map((t=>t.target));this.handleDUWithLinks(o)}handleDUWithLinks(t){this.fieldsToLink=t;const i=Object.assign({},this.dataUnit.metadata);this.processLinks(i),this.dataUnit.metadata=i,this.dataUnitFieldsHidded.emit()}processLinks(t){var i;null===(i=null==t?void 0:t.fields)||void 0===i||i.forEach((t=>{var i;(null===(i=this.fieldsToLink)||void 0===i?void 0:i.includes(t.name))&&(t.visible=!1)}))}getCleanDataUnitName(){var t;const i=this.dataUnit.name;if(d.isEmpty(i))return i;const s=this.REGEX_DATAUNIT_NAME.exec(i);return null!==(t=null==s?void 0:s[1])&&void 0!==t?t:i}static getNearestInstance(t){let i=t.parentElement;for(;i;){if("SNK-DATA-UNIT"===i.tagName.toUpperCase())return i;i=i.parentElement}}instanceMessagesBuilder(){var t;this.messagesBuilder||(this.messagesBuilder=new v(null!==(t=this.domainMessagesBuilder)&&void 0!==t?t:this.entityName))}componentWillLoad(){this._application=a.getContextValue("__SNK__APPLICATION__"),this._application.getAllAccess(this.resourceID).then((t=>this._permissions=t)),this._parentSnkDataUnit=this.getParentSnkDataUnit(),this.instanceMessagesBuilder()}disconnectedCallback(){this.dataUnit&&this.dataUnit.releaseCallbacks()}async componentDidLoad(){await this.loadDataUnit(),this.handlerLinkFields()}render(){return s(n,null)}get element(){return e(this)}static get watchers(){return{pageSize:["observePageSize"],dataUnitName:["observeDataUnitName"],entityName:["observeEntityName"],dataState:["observeDataState"],dataUnit:["observeDataUnit"],messagesBuilder:["observeMessagesBuilder"]}}};class D{constructor(t){this.copyMode=t.copyMode,this.insertionMode=t.insertionMode,this.isStartingInsertionMode=t.isStartingInsertionMode,this.isDirty=t.isDirty,this.hasDirtyRecords=t.hasDirtyRecords,this.hasNext=t.hasNext,this.hasPrevious=t.hasPrevious,this.selectionInfo=t.selectionInfo,this.selectedRecord=t.selectedRecord,this.recordsIsEmpty=t.recordsIsEmpty,this.metadataByRow=t.metadataByRow,this.rowMetadata=t.rowMetadata}}export{w as S}
1
+ import{r as t,c as i,h as s,g as e,H as n}from"./p-82bb3eda.js";import{ApplicationContext as a,Action as r,ObjectUtils as o,DataUnitAction as h,StringUtils as d}from"@sankhyalabs/core";import{ApplicationUtils as l,DialogType as c}from"@sankhyalabs/ezui/dist/collection/utils";import{O as u,S as v}from"./p-6768f176.js";import{g as m,a as f}from"./p-9e4555ab.js";import{convertType as p}from"@sankhyalabs/core/dist/dataunit/metadata/DataType";import{g as b}from"./p-7dd49d15.js";const g="__NO_TAB_NAME__";const w=class{constructor(s){t(this,s),this.dataStateChange=i(this,"dataStateChange",3),this.dataUnitReady=i(this,"dataUnitReady",3),this.messagesBuilderUpdated=i(this,"messagesBuilderUpdated",3),this.dataUnitFieldsHidded=i(this,"dataUnitFieldsHidded",7),this.insertionMode=i(this,"insertionMode",3),this.cancelEdition=i(this,"cancelEdition",3),this._onDataUnitResolve=[],this._openedAlert=!1,this._fieldsWithRmp=[],this._fieldsWithRmPrecision=[],this._metadataByRow=new Map,this._rowMetadataCache=new Map,this._formFieldsConfig=[],this.REGEX_DATAUNIT_NAME=/dd:\/\/(.+?)\//,this._dataUnitObserver=async t=>{const i=await this.buildDataState(t.type);switch(this.dataState=i,this.messagesBuilder.currentOperation=this.getMessageOperation(),t.type){case r.DATA_SAVED:await this.handleDataSaved(t);break;case r.RECORDS_ADDED:case r.RECORDS_COPIED:this.insertionMode.emit();break;case r.EDITION_CANCELED:this.cancelEdition.emit();break;case r.RECORDS_REMOVED:this.handleRecordsRemoved(t);break;case r.METADATA_LOADED:this.fillFieldsWithRmp(this.dataUnit.metadata),this.fillFieldsWithRmPrecision(this.dataUnit.metadata)}},this.fieldsToLink=[],this.dataState=void 0,this.messagesBuilder=void 0,this.dataUnitName=void 0,this.entityName=void 0,this.pageSize=150,this.dataUnit=void 0,this.beforeSave=void 0,this.afterSave=void 0,this.useCancelConfirm=!0,this.ignoreSaveMessage=void 0,this.configName=void 0,this.resourceID=void 0,this.domainMessagesBuilder=void 0}observePageSize(){this.dataUnit&&(this.dataUnit.pageSize=this.pageSize)}observeDataUnitName(t,i){i!=t&&(this.dataUnit?this._application.updateDataunitCache(i,this.dataUnitName,this.dataUnit):this.loadDataUnit())}observeEntityName(t,i){i!=t&&(this.dataUnit=void 0,this.entityName=t,this.loadDataUnit())}observeDataState(t,i){o.objectToString(i)!=o.objectToString(t)&&this.dataStateChange.emit(t)}observeDataUnit(){this.handlerLinkFields(),this.dataUnitReady.emit(this.dataUnit)}observeMessagesBuilder(t){t&&this.messagesBuilderUpdated.emit(t)}onMasterFormConfigChange({detail:t}){var i;this._formFieldsConfig=null!==(i=null==t?void 0:t.fields)&&void 0!==i?i:[]}async getDataUnit(){return new Promise((t=>{this.dataUnit?t(this.dataUnit):this._onDataUnitResolve.push(t)}))}async getSelectedRecordsIDsInfo(){return b(this.dataUnit)}async getFieldsWithRmp(){return this._fieldsWithRmp}async getFieldsWithRmPrecision(){return this._fieldsWithRmPrecision}async getRowMetadata(t){return this.doGetRowMetadata(t)}async doGetRowMetadata(t){const i=this.dataUnit.getSelectedRecord();if(!t&&!i)return;const s=t||i,e="string"==typeof s?s:s.__record__id__;let n=this._metadataByRow.get(e);return this.dataUnit.isNewRecord(e)&&!n&&(n=await this.handleLoadRowMetadata(i)),n?(n.getProp=this.buildGetPropRowMetadata(n),Object.assign({},n)):void 0}buildGetPropRowMetadata(t){return(i,s)=>("rm_precision"===i&&(i=this.resolvePrecisionFromMetadata(s)),o.getProp(t,i))}resolvePrecisionFromMetadata(t){var i,s;if(!t)return void l.error(this.getMessage("snkDataUnit.fieldNameRequired"));const e=null===(s=null===(i=this.dataUnit.getField(t))||void 0===i?void 0:i.properties)||void 0===s?void 0:s.rm_precision;return e?e.split(".").filter(((t,i)=>1!==i)).join("."):""}getCleanOnCopyFields(){var t;return null===(t=this.dataUnit.metadata)||void 0===t?void 0:t.fields.filter((t=>{var i;return null===(i=t.properties)||void 0===i?void 0:i.cleanOnCopy})).map((t=>t.name))}fillFieldsWithRmp(t){t.fields.forEach((t=>{var i;(null===(i=t.properties)||void 0===i?void 0:i.rmp)&&!this._fieldsWithRmp.includes(t.name)&&this._fieldsWithRmp.push(t.name)}))}fillFieldsWithRmPrecision(t){t.fields.forEach((t=>{var i;(null===(i=t.properties)||void 0===i?void 0:i.rm_precision)&&!this._fieldsWithRmPrecision.includes(t.name)&&this._fieldsWithRmPrecision.push(t.name)}))}getCacheName(t,i,s){return[t,i,s].join("_")}updateDataStateRmp(t){const i=Object.assign({},t);this.dataState.rowMetadata=i}saveCacheRmd(t){const i=t.__record__metadata__,s=Object.keys(i);s.shift(),s.forEach((s=>{const e=m(t,s),n=this.getCacheName(s,i.provider,e);this._rowMetadataCache.set(n,Object.assign({},i))}))}getMetadataByRow(t){var i;if(!(null===(i=t.records)||void 0===i?void 0:i.length))return t;if(!this._fieldsWithRmp.length){const i=t.records.map((t=>(delete t.__record__metadata__,t)));return Object.assign(Object.assign({},t),{records:i})}const s=t.records.map((t=>{if(!t.__record__metadata__)return t;this.saveCacheRmd(t);const i=Object.assign({},t.__record__metadata__);return i.getProp=this.buildGetPropRowMetadata(i),this._metadataByRow.set(t.__record__id__,i),delete t.__record__metadata__,t}));return Object.assign(Object.assign({},t),{records:s})}interceptRecordsAdded(t){if(this.isAllowed("INSERT"))return new h(r.RECORDS_ADDED,this.handleLinksWithParent(t.payload));l.info(this.getMessage("snkDataUnit.forbiddenInsert"))}interceptRecordsCopied(t){if(this.isAllowed("CLONE"))return new h(r.RECORDS_COPIED,this.handleRecordsCopied(t.payload));l.info(this.getMessage("snkDataUnit.forbiddenClone"))}async interceptDataChange(t){var i;const s=null===(i=this.dataUnit.getSelectedRecord())||void 0===i?void 0:i.__record__id__;if(this.isAllowed("UPDATE")||this.dataUnit.isNewRecord(s))return t;this._openedAlert?await this.dataUnit.cancelEdition():(this._openedAlert=!0,await this.dataUnit.cancelEdition(),await l.alert(this.getMessage("snkDataUnit.forbidden"),this.getMessage("snkDataUnit.forbiddenUpdate")),this._openedAlert=!1)}async interceptSavingData(t){if(this.dataUnit.isMultipleEdition&&!await this.confirmMultipleSavingData())return;if(!this.beforeSave)return t;const i=this.beforeSave(this.dataUnit);return i instanceof Promise?await i?t:void 0:i?t:void 0}async confirmMultipleSavingData(){const t=this.dataUnit.getSelectionInfo().records,i=this.getMessage("snkDataUnit.multipleUpdateConfirmationTitle"),s=this.getMessage("snkDataUnit.multipleUpdateConfirmationMessage",{size:t.length}),e=this.getMessage("snkDataUnit.confirm.cancel"),n=this.getMessage("snkDataUnit.confirm.updateMultipleConfirm");return await async function({title:t,labelBtnConfirm:i,labelBtnCancel:s,message:e,changingFields:n}){return new Promise((r=>{const o=function(t,i){const s=document.createElement("ez-popup");return s.opened=!0,s.size="small",s.ezTitle=t,s.heightMode="auto",s.addEventListener("ezClosePopup",(()=>{document.body.removeChild(s),i(!1)}),{once:!0}),s.addEventListener("ezPopupAction",(()=>{document.body.removeChild(s),i(!1)}),{once:!0}),s}(t,r),h=function(){const t=document.createElement("div");return t.style.display="flex",t.style.flexDirection="column",t.style.fontFamily="var(--font-pattern, Roboto)",t.style.fontSize="var(--text--medium, 14px)",t}();h.appendChild(function(t){const i=document.createElement("p");return i.textContent=t,i.style.fontSize="var(--text--medium, 14px)",i}(e)),h.appendChild(function(t){const i=document.createElement("div");i.style.flexDirection="column",i.style.display="flex",i.style.overflow="auto",i.style.maxHeight="300px";const s=function(t){const i=new Map;return t.forEach((t=>{var s;const e=null!==(s=t.tabName)&&void 0!==s?s:g;i.has(e)||i.set(e,[]),i.get(e).push(t)})),i}(t);return s.forEach(((t,s)=>{i.appendChild(function(t,i){const s=document.createElement("span");s.innerText=function(t){const i=a.getContextValue("__SNK__APPLICATION__").messagesBuilder.getMessage("snkDataUnit.main");switch(t){case g:return"";case"__main":return i;default:return t}}(t),s.style.display="block",s.style.fontWeight="var(--text-weight--large, 500)",s.style.fontSize="var(--text--medium, 14px)",s.style.marginBottom="var(--space--small, 6px)";const e=document.createElement("div");return e.style.padding="var(--space--medium, 12px) 0",e.style.borderTop="1px solid var(--color--disable-secondary, #f2f5f8)",e.appendChild(s),i.forEach((t=>{const i=document.createElement("span");i.innerHTML=`${t.label}: <span style="color: var(--text--primary, #626e82)">${t.value}</span>`,i.style.display="block",i.style.marginBottom="var(--space--extra-small, 3px)",e.appendChild(i)})),e}(s,t))})),i}(n));const d=function(){const t=document.createElement("div");return t.style.display="flex",t.style.flexDirection="row",t.style.justifyContent="flex-end",t.style.gap="5px",t}();d.appendChild(function(t,i,s){const e=document.createElement("ez-button");return e.label=i,e.size="medium",e.onclick=()=>{document.body.removeChild(t),s(!1)},e}(o,s,r)),d.appendChild(function(t,i,s){const e=document.createElement("ez-button");return e.label=i,e.size="medium",e.classList.add("ez-button--primary"),e.onclick=()=>{document.body.removeChild(t),s(!0)},e}(o,i,r)),h.appendChild(d),o.appendChild(h),document.body.appendChild(o)}))}({title:i,message:s,labelBtnConfirm:n,labelBtnCancel:e,changingFields:this.getChangingFields()})}getChangingFields(){const t=this.dataUnit.buildChangesToSave();if(!(null==t?void 0:t.length))return[];const i=t[0];return Object.keys(i.updatingFields).map((t=>this.buildChangingField(t,i[t])))}buildChangingField(t,i){return{label:this.dataUnit.getField(t).label,value:this.dataUnit.getFormattedValue(t,i),tabName:this.getFieldTabName(t)}}getFieldTabName(t){var i;const s=null===(i=this._formFieldsConfig.find((i=>i.name===t)))||void 0===i?void 0:i.tab;if(s)return"string"==typeof s?s:s.label}interceptDataSaved(t){if(!this.afterSave)return t;this.afterSave(this.dataUnit)}async interceptEditionCanceled(t){var i,s;if(!this.useCancelConfirm||!this.dataState.hasDirtyRecords||(null===(i=t.payload)||void 0===i?void 0:i.fromParent)||(null===(s=t.payload)||void 0===s?void 0:s.silent))return t;const e=this.getMessage("snkDataUnit.cancelConfirmation");if(null==e)return this.showSuccessMessage(this.getMessage("snkDataUnit.cancelInfo")),t;const n=this.getMessage("snkDataUnit.cancelConfirmationTitle"),a=await l.confirm(n,e);if(a){let t;if(this.dataUnit.isMultipleEdition){const i=this.dataUnit.getSelectionInfo().records;t=this.buildMultipleUpdateMessage(i,!0)}else t=this.getMessage("snkDataUnit.cancelInfo");this.showSuccessMessage(t)}return a?t:void 0}async interceptRemovingRecords(t){var i,s,e;if(!this.isAllowed("REMOVE"))return void l.info(this.getMessage("snkDataUnit.forbiddenRemove"));let n=!1,a=!(null===(i=t.payload)||void 0===i?void 0:i.silent)&&this.getMessage("snkDataUnit.removeConfirmation");const r=null===(s=this.dataUnit)||void 0===s?void 0:s.getSelectionInfo();if(!(null===(e=t.payload)||void 0===e?void 0:e.silent)&&(null==r?void 0:r.length)>1&&(a=this.getMessage("snkDataUnit.removeAllConfirmation",{size:r.length}),n=!0),!a)return t;const o={canClose:!1,labelCancel:this.getMessage("snkDataUnit.confirm."+(n?"no":"cancel")),labelConfirm:this.getMessage("snkDataUnit.confirm."+(n?"yes":"delete")),btnConfirmDanger:!1},h=this.getMessage("snkDataUnit.removeConfirmationTitle");return await l.confirm(h,a,null,c.WARN,o)?t:void 0}interceptDataLoaded(t){const i=this.getMetadataByRow(t.payload);return new h(r.DATA_LOADED,i)}interceptMetadataLoaded(t){return this.fillFieldsWithRmp(t.payload),this.fillFieldsWithRmPrecision(t.payload),new h(r.METADATA_LOADED,this.handleDULinksOnMetadataLoaded(t.payload))}async interceptAction(t){switch(t.type){case r.RECORDS_ADDED:return this.interceptRecordsAdded(t);case r.RECORDS_COPIED:return this.interceptRecordsCopied(t);case r.DATA_CHANGED:return await this.handleLoadRowMetadata(t.payload),await this.interceptDataChange(t);case r.CHANGING_DATA:return await this.interceptDataChange(t);case r.SAVING_DATA:return await this.interceptSavingData(t);case r.DATA_SAVED:return this.interceptDataSaved(t);case r.EDITION_CANCELED:return await this.interceptEditionCanceled(t);case r.REMOVING_RECORDS:return await this.interceptRemovingRecords(t);case r.DATA_LOADED:return this.interceptDataLoaded(t);case r.METADATA_LOADED:return this.interceptMetadataLoaded(t);default:return t}}async handleLoadRowMetadata(t){if(!t)return;const i=Object.keys(t).find((t=>this._fieldsWithRmp.includes(t)));if(i){const s=this.dataUnit.getField(i).properties.rmp,e=m(t,i);return await this.updateRowMetadata({fieldName:i,fieldValue:e,metadataName:s,updatedFields:t})}}async updateRowMetadata({fieldName:t,fieldValue:i,metadataName:s,updatedFields:e}){const n=this.getCacheName(t,s,i),a=this._rowMetadataCache.get(n);if(a)return this.updateDataStateRmp(a),a;{const i=new f,a=await i.loadRowMetadata(this,t,s,e);return this.updateDataStateRmp(a._rmd),this._rowMetadataCache.set(n,Object.assign({},a._rmd)),Object.assign({},a._rmd)}}handleDULinksOnMetadataLoaded(t){const i=Object.assign({},t);return this.processLinks(i),i}handleRecordsCopied(t){let i=[...t];return i=this.handleCleanOnCopy(i),this.handleLinksWithParent(i)}handleLinksWithParent(t){var i,s;const e=null!==(i=this._parentDataUnit)&&void 0!==i?i:null===(s=this.dataUnit)||void 0===s?void 0:s.getParentDataUnit();if(!e)return t;const n=e.getSelectedRecord(),a=null==e?void 0:e.getChildInfo(this.getCleanDataUnitName());if(!a)return t;const{links:r}=a;return r&&0!==r.length?t.map((t=>this.buildRecordWithLinkedFields(t,r,n))):t}buildRecordWithLinkedFields(t,i,s){const e=Object.assign({},t);return i.forEach((t=>{const i=p(this.dataUnit.getField(t.target).dataType,s[t.source]);e[t.target]=i})),e}handleCleanOnCopy(t){const i=this.getCleanOnCopyFields();return i.length>0&&(t=t.map((t=>this.buildCopyWithCleanedFields(t,i)))),t}buildCopyWithCleanedFields(t,i){const s=Object.assign({},t);return i.forEach((t=>delete s[t])),s}showSuccessMessage(t){l.info(t,{iconName:"check"})}isAllowed(t){return!!this._permissions&&(this._permissions.isSup||this._permissions[t])}async buildDataState(t){var i;const s=this.dataUnit.getSelectionInfo(),e=(this.dataUnit.hasDirtyRecords()||this.dataUnit.hasWaitingChanges())&&(null==s?void 0:s.isEmpty()),n=this.dataUnit.getSelectedRecord();let a=null===(i=this.dataState)||void 0===i?void 0:i.rowMetadata;return!n||a&&![r.SELECTION_CHANGED,r.EDITION_CANCELED,r.NEXT_SELECTED,r.PREVIOUS_SELECTED].includes(t)?a&&(a.getProp=this.buildGetPropRowMetadata(a)):a=await this.doGetRowMetadata(n),new D({insertionMode:this.dataUnit.hasNewRecord(),isStartingInsertionMode:e,hasNext:this.dataUnit.hasNext(),hasPrevious:this.dataUnit.hasPrevious(),copyMode:this.dataUnit.hasCopiedRecord(),isDirty:this.dataUnit.isDirty(),hasDirtyRecords:this.dataUnit.hasDirtyRecords(),selectedRecords:void 0,selectionInfo:s,selectedRecord:n,recordsIsEmpty:0===this.dataUnit.records.length,metadataByRow:this._metadataByRow,rowMetadata:a})}async handleDataSaved(t){var i,s,e;const n=null===(i=null==t?void 0:t.payload)||void 0===i?void 0:i.changes,a=null===(s=null==t?void 0:t.payload)||void 0===s?void 0:s.records,r=await this.handleLoadRowMetadata(null===(e=null==n?void 0:n[0])||void 0===e?void 0:e.record);r&&(r.getProp=this.buildGetPropRowMetadata(r)),this._metadataByRow.set(a[0].__record__id__,r),this.dataState=await this.buildDataState();let o=n[0]._operation.toLowerCase();if("copy"==o&&(o=u.CLONE),this.canIgnoreOperationMessage(o))return;let h=this.buildOperationMessage(o,a);null!=h&&this.showSuccessMessage(h)}canIgnoreOperationMessage(t){return this.ignoreSaveMessage&&!this.isCloneOrInsertOperation(t)}isCloneOrInsertOperation(t){return[u.CLONE,u.INSERT].includes(t)}buildOperationMessage(t,i){return this.isMultiplesUpdate(t,i)?this.buildMultipleUpdateMessage(i):this.getMessage("snkDataUnit.saveInfo",i[0],t)}buildMultipleUpdateMessage(t,i){return this.getMessage("snkDataUnit."+(i?"cancelInfo":"saveInfo"),{records:t},u.UPDATE_MULTIPLES)}isMultiplesUpdate(t,i){return t===u.UPDATE&&i.length>1}handleRecordsRemoved(t){var i,s;let e=this.buildRemoveFinishMessage(t);null!=e&&this.showSuccessMessage(e);const n=null!==(s=null===(i=this.dataUnit.records)||void 0===i?void 0:i.length)&&void 0!==s?s:0,a=this.dataUnit.getPaginationInfo();a&&this.dataUnit.gotoPage(n>0||a.hasMore?a.currentPage:0)}buildRemoveFinishMessage(t){const i=t.payload.records;if(i&&i.length)return(null==i?void 0:i.length)>1?this.getMessage("snkDataUnit.removeAllInfo",{size:i.length}):this.getMessage("snkDataUnit.removeInfo",i)}getMessage(t,i,s){return i||(i=this.getMessageParams()),s&&(this.messagesBuilder.currentOperation=s),this.messagesBuilder.getMessage(t,i)}getMessageParams(){return this.dataState.selectedRecord}getMessageOperation(){return this.dataState.copyMode?u.CLONE:this.dataState.insertionMode||this.dataState.isStartingInsertionMode?u.INSERT:this.dataState.isDirty?u.UPDATE:u.CLEAN}async getDataUnitParentOrChild(){var t;const i=this.dataUnitName?this.dataUnitName:this.entityName;return this._parentSnkDataUnit?(this._parentDataUnit=await(null===(t=this._parentSnkDataUnit)||void 0===t?void 0:t.getDataUnit()),await this._application.getDataUnit(this.entityName,i,this._parentDataUnit,this.configName,this.resourceID)):await this._application.getDataUnit(this.entityName,i,null,this.configName,this.resourceID)}updateMetadataWithRMP(){this.fillFieldsWithRmp(this.dataUnit.metadata),this.fillFieldsWithRmPrecision(this.dataUnit.metadata);const t=this.handleDULinksOnMetadataLoaded(this.dataUnit.metadata);this.dataUnit.metadata=t}async loadDataUnit(){var t,i;if(null==this.dataUnit&&this._application&&this.entityName&&(this.dataUnit=await this.getDataUnitParentOrChild()),this.dataUnit){if(this.dataUnit.pageSize=this.pageSize,this.dataUnit.unsubscribe(this._dataUnitObserver),this.dataUnit.subscribe(this._dataUnitObserver),(null===(t=this.dataUnit)||void 0===t?void 0:t.metadata)&&this.updateMetadataWithRMP(),this.dataUnit.addInterceptor(this),null===(i=this.dataUnit.records)||void 0===i?void 0:i.length){const{records:t}=this.getMetadataByRow(this.dataUnit);this.dataUnit.setRecordsKeepingSelection(t)}let s;for(this.dataState=await this.buildDataState();s=this._onDataUnitResolve.pop();)s(this.dataUnit)}}getParentSnkDataUnit(){let t=this.element;for(;t.parentNode;){if("SNK-DATA-UNIT"===t.parentNode.nodeName)return t.parentNode;t=t.parentNode}}handlerLinkFields(){var t,i,s,e;const n=null!==(t=this._parentDataUnit)&&void 0!==t?t:null===(i=this.dataUnit)||void 0===i?void 0:i.getParentDataUnit();if(!n)return;const a=null!==(s=this.entityName)&&void 0!==s?s:this.getCleanDataUnitName(),r=n.getChildInfo(a);if(!r)return;const o=null===(e=null==r?void 0:r.links)||void 0===e?void 0:e.map((t=>t.target));this.handleDUWithLinks(o)}handleDUWithLinks(t){this.fieldsToLink=t;const i=Object.assign({},this.dataUnit.metadata);this.processLinks(i),this.dataUnit.metadata=i,this.dataUnitFieldsHidded.emit()}processLinks(t){var i;null===(i=null==t?void 0:t.fields)||void 0===i||i.forEach((t=>{var i;(null===(i=this.fieldsToLink)||void 0===i?void 0:i.includes(t.name))&&(t.visible=!1)}))}getCleanDataUnitName(){var t;const i=this.dataUnit.name;if(d.isEmpty(i))return i;const s=this.REGEX_DATAUNIT_NAME.exec(i);return null!==(t=null==s?void 0:s[1])&&void 0!==t?t:i}static getNearestInstance(t){let i=t.parentElement;for(;i;){if("SNK-DATA-UNIT"===i.tagName.toUpperCase())return i;i=i.parentElement}}instanceMessagesBuilder(){var t;this.messagesBuilder||(this.messagesBuilder=new v(null!==(t=this.domainMessagesBuilder)&&void 0!==t?t:this.entityName))}componentWillLoad(){this._application=a.getContextValue("__SNK__APPLICATION__"),this._application.getAllAccess(this.resourceID).then((t=>this._permissions=t)),this._parentSnkDataUnit=this.getParentSnkDataUnit(),this.instanceMessagesBuilder()}disconnectedCallback(){this.dataUnit&&this.dataUnit.releaseCallbacks()}async componentDidLoad(){await this.loadDataUnit(),this.handlerLinkFields()}render(){return s(n,null)}get element(){return e(this)}static get watchers(){return{pageSize:["observePageSize"],dataUnitName:["observeDataUnitName"],entityName:["observeEntityName"],dataState:["observeDataState"],dataUnit:["observeDataUnit"],messagesBuilder:["observeMessagesBuilder"]}}};class D{constructor(t){this.copyMode=t.copyMode,this.insertionMode=t.insertionMode,this.isStartingInsertionMode=t.isStartingInsertionMode,this.isDirty=t.isDirty,this.hasDirtyRecords=t.hasDirtyRecords,this.hasNext=t.hasNext,this.hasPrevious=t.hasPrevious,this.selectionInfo=t.selectionInfo,this.selectedRecord=t.selectedRecord,this.recordsIsEmpty=t.recordsIsEmpty,this.metadataByRow=t.metadataByRow,this.rowMetadata=t.rowMetadata}}export{w as S}
@@ -1 +1 @@
1
- import{r as i,c as e,f as t,h as s,H as l}from"./p-d8d8169b.js";import{UserInterface as n,StringUtils as a,ObjectUtils as o,ApplicationContext as h}from"@sankhyalabs/core";import{b as d,D as r,c as u}from"./p-9019a32f.js";import{getConvertedValue as c}from"@sankhyalabs/core/dist/dataunit/metadata/DataType";import{CheckMode as f}from"@sankhyalabs/ezui/dist/collection/utils";import{h as p,i as v,j as b,k as g}from"./p-8b4d6719.js";const m=class{constructor(t){i(this,t),this.fieldConfigChanged=e(this,"fieldConfigChanged",7),this.fieldLabel=void 0,this.fieldLabelErrorMessage=void 0,this.fieldDefaultValue=void 0,this.fieldCleanOnCopy=void 0,this.fieldRequired=void 0,this.fieldReadOnly=void 0,this._defaultType=void 0,this.dataUnit=void 0,this.fieldConfig=void 0,this.fieldDescriptor=void 0,this.messagesBuilder=void 0}observeFieldLabel(){this.validateFieldLabel&&(this.fieldLabelErrorMessage=void 0)}async show(i){this._popoupElement.opened=!0,this.initializeValues(),t(this)}validateFieldLabel(){var i;return!!(null===(i=this.fieldLabel)||void 0===i?void 0:i.trim())||(this.applyErrorMessage(),!1)}getMessage(i,e){return this.messagesBuilder.getMessage(i,e)}isAllowDefault(){var i;const e=null===(i=this.fieldDescriptor.properties)||void 0===i?void 0:i.allowDefault;return null==e||"true"===e}enabledValueDefault(){var i,e,t;const s=null===(i=this.fieldDescriptor.properties)||void 0===i?void 0:i.allowDefault;return(d.UserInterface.hasOwnProperty(null===(e=this.fieldDescriptor)||void 0===e?void 0:e.userInterface)||(null===(t=this.fieldDescriptor)||void 0===t?void 0:t.userInterface)===n.SEARCH)&&(null==s||"true"===s)}getDefaultType(){var i,e;return null!==(e=null===(i=this.fieldDefaultValue)||void 0===i?void 0:i.type)&&void 0!==e?e:r.fixed}emitFieldChanged(){this.fieldConfigChanged.emit(this.fieldConfig)}handleLabelChanged({detail:i}){this.fieldLabel=i}handleDefaultTypeChanged({detail:i}){const e=i.value;null!=e&&(this._defaultType=e,this.fieldDefaultValue={type:this._defaultType})}handleDefaultValueChanged({detail:i}){this.fieldDefaultValue.value=null==i?void 0:i.value}onChangeDefaultValue(i){this.fieldDefaultValue.value=p(i,this.dataUnit,this.fieldConfig.name)}handleClearDuplicateChanged({detail:i}){this.fieldCleanOnCopy=i}handleRequiredChanged({detail:i}){this.fieldRequired=i}handleReadOnlyChanged({detail:i}){this.fieldReadOnly=i}loadDefaultValue(){var i;(null===(i=this.fieldConfig.defaultValue)||void 0===i?void 0:i.type)?this._defaultType=this.fieldConfig.defaultValue.type:(this._defaultType=r.fixed,this.fieldConfig.defaultValue={type:this._defaultType})}buildOptions(){let i=this.fieldDescriptor.userInterface;return i===n.SEARCH&&(i=n.INTEGERNUMBER),d.UserInterface[i]}renderDefaultValueEditor(){return this._defaultType===r.variable?s("ez-combo-box",{label:this.getMessage("snkConfigOptions.label.valueDefault"),enabled:this.isAllowDefault(),onEzChange:i=>this.handleDefaultValueChanged(i),value:this.fieldDefaultValue.value,options:this.buildOptions()}):this.fieldDescriptor.userInterface&&this.buildFieldDefaultValueElement()}buildFieldDefaultValueElement(){var i;const{userInterface:e,properties:t,dataType:s}=this.fieldDescriptor;let l,o=a.getBooleanValue(null==t?void 0:t.allowDefault,!this.fieldReadOnly);e===n.FILE&&(o=!1),o&&(l=null===(i=this.fieldDefaultValue)||void 0===i?void 0:i.value,null!=l&&(l=c(s,l)));const h={value:l,enabled:o,label:this.fieldConfig.label,name:this.fieldConfig.name,required:this.fieldRequired,userInterface:e};switch(e){case n.SWITCH:return this.buildInputDefault(h,void 0,f.SWITCH);case n.CHECKBOX:return this.buildInputDefault(h,void 0,f.REGULAR);case n.OPTIONSELECTOR:case n.DECIMALNUMBER:return this.buildInputDefault(h,t);default:return this.buildInputDefault(h)}}buildInputDefault({value:i,enabled:e,label:t,name:l,required:a,userInterface:h},d,r){let c,f=0,p=0;const v=null==h||null==u[h]?u.DEFAULT:u[h];if(h===n.OPTIONSELECTOR){const i=null==d?void 0:d.options;if("string"==typeof i){const e=o.stringToObject(i);c=Object.keys(e).map((i=>({value:i,label:e[i]})))}else c=i}else h===n.DECIMALNUMBER&&(f=Number((null==d?void 0:d.precision)||2),p=Number((null==d?void 0:d.prettyPrecision)||f));return s(v,Object.assign({value:i,enabled:e,label:t,"data-field-name":l,key:l,onEzChange:i=>this.onChangeDefaultValue(null==i?void 0:i.detail)},this.getConditionalAttributes(h,a,c,f,p,r)))}getConditionalAttributes(i,e,t,s,l,a){const o=i==n.SEARCHPLUS;switch(i){case n.SEARCH:case n.SEARCHPLUS:return{suppressEmptyOption:e,optionLoader:i=>this.onSearchDefaultValue(i,{useSearchPlus:o})};case n.OPTIONSELECTOR:return{suppressEmptyOption:e,options:t};case n.CHECKBOX:case n.SWITCH:return{mode:a};case n.INTEGERNUMBER:case n.DECIMALNUMBER:return{precision:s,prettyPrecision:l,onEzStartChange:i=>this.onChangeDefaultValue(null==i?void 0:i.detail)};case n.DATE:case n.DATETIME:case n.TIME:return{onEzStartChange:i=>this.onChangeDefaultValue(null==i?void 0:i.detail)};default:return{}}}onSearchDefaultValue(i,e){if(this._application&&this.fieldConfig)return this._application.executeSearch(i,this.fieldConfig.name,this.dataUnit,e)}initializeValues(){this.fieldLabel=this.fieldConfig.label,this.fieldDefaultValue=this.fieldConfig.defaultValue,this.fieldRequired=this.fieldConfig.required,this.fieldReadOnly=this.fieldConfig.readOnly,this.fieldCleanOnCopy=this.fieldConfig.cleanOnCopy}handleApplyChanges(){this.validateFieldLabel()&&(this.fieldConfig.label=this.fieldLabel,this.fieldConfig.defaultValue=this.fieldDefaultValue,this.fieldConfig.required=this.fieldRequired,this.fieldConfig.readOnly=this.fieldReadOnly,this.fieldConfig.cleanOnCopy=this.fieldCleanOnCopy,this.emitFieldChanged(),this._popoupElement.opened=!1)}applyErrorMessage(){this.fieldLabelErrorMessage=`${this.getMessage("snkConfigOptions.validation.requiredField")} ${this.getMessage("snkConfigOptions.label.nameField")}`}handleDiscardChanges(){this.initializeValues(),this._popoupElement.opened=!1}componentWillLoad(){this.loadDefaultValue(),this._application=h.getContextValue("__SNK__APPLICATION__")}render(){return s("ez-popup",{heightMode:"auto",size:"auto","ez-title":this.getMessage("snkConfigOptions.fieldConfig.title"),onEzClosePopup:()=>this.handleDiscardChanges(),ref:i=>this._popoupElement=i},s("div",{class:"field-config-container"},s("ez-text-input",{label:this.getMessage("snkConfigOptions.label.nameField"),value:this.fieldLabel,errorMessage:this.fieldLabelErrorMessage,hasInvalid:!!this.fieldLabelErrorMessage,onEzChange:i=>this.handleLabelChanged(i)}),s("ez-combo-box",{label:this.getMessage("snkConfigOptions.label.typeValueDefault"),suppressEmptyOption:!0,enabled:this.enabledValueDefault(),onEzChange:i=>this.handleDefaultTypeChanged(i),value:this.getDefaultType()},s("option",{value:r.fixed},this.getMessage("snkConfigOptions.options.valueFixed")),s("option",{value:r.variable},this.getMessage("snkConfigOptions.options.variable"))),this.renderDefaultValueEditor(),s("ez-check",{label:this.getMessage("snkConfigOptions.label.clearDuplicate"),value:this.fieldCleanOnCopy,onEzChange:i=>this.handleClearDuplicateChanged(i)}),s("ez-check",{label:this.getMessage("snkConfigOptions.label.requiredField"),enabled:v("required","systemRequired",this.fieldDescriptor),value:b("required",this.fieldDescriptor,this.fieldRequired),onEzChange:i=>this.handleRequiredChanged(i)}),s("ez-check",{label:this.getMessage("snkConfigOptions.label.protectedField"),enabled:v("readOnly","systemReadOnly",this.fieldDescriptor),value:b("readOnly",this.fieldDescriptor,this.fieldReadOnly),onEzChange:i=>this.handleReadOnlyChanged(i)}),s("div",{class:"actions"},s("ez-button",{label:this.getMessage("snkConfigOptions.fieldConfig.buttons.cancel"),onClick:()=>this.handleDiscardChanges()}),s("ez-button",{label:this.getMessage("snkConfigOptions.fieldConfig.buttons.confirm"),class:"ez-button--primary",onClick:()=>this.handleApplyChanges()}))))}static get watchers(){return{fieldLabel:["observeFieldLabel"]}}};m.style=".field-config-container.sc-field-config{font-family:'Roboto';color:#2b3a54;display:flex;flex-direction:column;gap:10px;width:330px;justify-content:space-between}.header.sc-field-config{display:flex;font-weight:500;font-size:16px}.actions.sc-field-config{display:flex;align-items:flex-end;gap:12px}";const C=class{constructor(t){i(this,t),this.setFieldAsAvailable=e(this,"setFieldAsAvailable",7),this.addFieldToGuide=e(this,"addFieldToGuide",7),this.fieldDescriptor=void 0,this.fieldConfig=void 0,this.onLayoutConfig=!1,this.dataUnit=void 0,this.messagesBuilder=void 0}observeDataUnit(){this.loadFieldDescriptor()}isRequired(){var i,e;const t=this.dataUnit&&this.dataUnit.getField(null===(i=this.fieldConfig)||void 0===i?void 0:i.name);return!0===(null==t?void 0:t.required)||!0===(null===(e=this.fieldConfig)||void 0===e?void 0:e.required)}async showFieldConfig(){var i;await(null===(i=this._refFieldConfig)||void 0===i?void 0:i.show(this._editIconRef))}renderFieldConfig(){if(this.onLayoutConfig&&this.dataUnit&&this.messagesBuilder)return s("field-config",{ref:i=>this._refFieldConfig=i,fieldConfig:this.fieldConfig,dataUnit:this.dataUnit,fieldDescriptor:this.fieldDescriptor,messagesBuilder:this.messagesBuilder,onFieldConfigChanged:()=>t(this)})}getMessage(i,e){return this.messagesBuilder.getMessage(i,e)}renderActions(){return this.onLayoutConfig?s("div",{class:"actions hiddeble"},s("ez-button",{mode:"icon",class:"ez-button--tertiary",onClick:()=>this.setFieldAsAvailable.emit(this.fieldConfig),size:"medium",iconName:"minus",title:this.getMessage("snkFieldConfig.titleRemove")}),s("ez-button",{ref:i=>this._editIconRef=i,mode:"icon",class:"ez-button--tertiary",onClick:this.showFieldConfig.bind(this),iconName:"edit",size:"medium",title:this.getMessage("snkFieldConfig.titleEdit")})):s("div",{class:"actions hiddeble"},s("ez-button",{mode:"icon",class:"ez-button--tertiary",onClick:()=>this.addFieldToGuide.emit(this.fieldConfig),iconName:"plus",size:"medium",title:this.getMessage("snkFieldConfig.titleAddToLayout")}))}loadFieldDescriptor(){this.dataUnit&&(this.fieldDescriptor=this.dataUnit.getField(this.fieldConfig.name))}renderRequiredMark(){if(this.isRequired())return s("span",{class:"required-mark"},"*")}componentWillLoad(){this.loadFieldDescriptor()}getFieldLabel(){var i,e;return(null===(i=this.fieldConfig)||void 0===i?void 0:i.label)?this.fieldConfig.label:null===(e=this.fieldDescriptor)||void 0===e?void 0:e.label}render(){var i;return s(l,{class:this.onLayoutConfig?"":"full-width"},s("div",{class:"icons"},s("ez-icon",{iconName:"drag-indicator"}),s("ez-icon",{iconName:g(null===(i=this.fieldDescriptor)||void 0===i?void 0:i.userInterface)})),s("span",{class:"label"},s("span",{class:"label-text",title:this.getFieldLabel()},this.getFieldLabel()),this.renderRequiredMark()),this.renderActions(),this.renderFieldConfig())}static get watchers(){return{dataUnit:["observeDataUnit"]}}};C.style=".sc-field-item-h{width:100%;display:flex;padding:12px 8px;border-radius:var(--border--radius-small, 4px);border:1px solid #dce0e8;cursor:grab;align-items:center;height:42px;max-height:42px;background:#FAFCFF}.full-width.sc-field-item-h{width:100%}ez-icon.sc-field-item{--ez-icon--color:#A2ABB9}.icons.sc-field-item{display:flex}.label.sc-field-item{display:flex;flex-grow:1;padding-left:8px;font-size:14px;align-items:center;gap:4px;height:22px}.label-text.sc-field-item{overflow:hidden;-webkit-hyphens:auto;-ms-hyphens:auto;hyphens:auto;height:auto;-webkit-box-orient:vertical;-webkit-line-clamp:2;line-clamp:2;display:-webkit-box;-o-text-overflow:ellipsis;text-overflow:ellipsis;word-break:break-word}.required-mark.sc-field-item{color:#cf3105;background:#F7E0E5;width:12px;height:12px;border-radius:50%;display:flex;align-items:center;justify-content:center;padding-top:5px;font-size:16px;align-self:self-start}.actions.sc-field-item{display:flex;flex-direction:row;align-content:center;gap:4px}ez-button.sc-field-item{width:24px;align-items:center;justify-content:center;display:flex}.sc-field-item-h .hiddeble.sc-field-item{transition:0.2s ease-in-out;visibility:hidden;opacity:0}.sc-field-item-h:hover .hiddeble.sc-field-item{visibility:visible;opacity:1}";export{m as field_config,C as field_item}
1
+ import{r as i,c as e,f as t,h as s,H as l}from"./p-82bb3eda.js";import{UserInterface as n,StringUtils as a,ObjectUtils as o,ApplicationContext as h}from"@sankhyalabs/core";import{b as d,D as r,c as u}from"./p-9019a32f.js";import{getConvertedValue as c}from"@sankhyalabs/core/dist/dataunit/metadata/DataType";import{CheckMode as f}from"@sankhyalabs/ezui/dist/collection/utils";import{h as p,i as v,j as b,k as g}from"./p-8b4d6719.js";const m=class{constructor(t){i(this,t),this.fieldConfigChanged=e(this,"fieldConfigChanged",7),this.fieldLabel=void 0,this.fieldLabelErrorMessage=void 0,this.fieldDefaultValue=void 0,this.fieldCleanOnCopy=void 0,this.fieldRequired=void 0,this.fieldReadOnly=void 0,this._defaultType=void 0,this.dataUnit=void 0,this.fieldConfig=void 0,this.fieldDescriptor=void 0,this.messagesBuilder=void 0}observeFieldLabel(){this.validateFieldLabel&&(this.fieldLabelErrorMessage=void 0)}async show(i){this._popoupElement.opened=!0,this.initializeValues(),t(this)}validateFieldLabel(){var i;return!!(null===(i=this.fieldLabel)||void 0===i?void 0:i.trim())||(this.applyErrorMessage(),!1)}getMessage(i,e){return this.messagesBuilder.getMessage(i,e)}isAllowDefault(){var i;const e=null===(i=this.fieldDescriptor.properties)||void 0===i?void 0:i.allowDefault;return null==e||"true"===e}enabledValueDefault(){var i,e,t;const s=null===(i=this.fieldDescriptor.properties)||void 0===i?void 0:i.allowDefault;return(d.UserInterface.hasOwnProperty(null===(e=this.fieldDescriptor)||void 0===e?void 0:e.userInterface)||(null===(t=this.fieldDescriptor)||void 0===t?void 0:t.userInterface)===n.SEARCH)&&(null==s||"true"===s)}getDefaultType(){var i,e;return null!==(e=null===(i=this.fieldDefaultValue)||void 0===i?void 0:i.type)&&void 0!==e?e:r.fixed}emitFieldChanged(){this.fieldConfigChanged.emit(this.fieldConfig)}handleLabelChanged({detail:i}){this.fieldLabel=i}handleDefaultTypeChanged({detail:i}){const e=i.value;null!=e&&(this._defaultType=e,this.fieldDefaultValue={type:this._defaultType})}handleDefaultValueChanged({detail:i}){this.fieldDefaultValue.value=null==i?void 0:i.value}onChangeDefaultValue(i){this.fieldDefaultValue.value=p(i,this.dataUnit,this.fieldConfig.name)}handleClearDuplicateChanged({detail:i}){this.fieldCleanOnCopy=i}handleRequiredChanged({detail:i}){this.fieldRequired=i}handleReadOnlyChanged({detail:i}){this.fieldReadOnly=i}loadDefaultValue(){var i;(null===(i=this.fieldConfig.defaultValue)||void 0===i?void 0:i.type)?this._defaultType=this.fieldConfig.defaultValue.type:(this._defaultType=r.fixed,this.fieldConfig.defaultValue={type:this._defaultType})}buildOptions(){let i=this.fieldDescriptor.userInterface;return i===n.SEARCH&&(i=n.INTEGERNUMBER),d.UserInterface[i]}renderDefaultValueEditor(){return this._defaultType===r.variable?s("ez-combo-box",{label:this.getMessage("snkConfigOptions.label.valueDefault"),enabled:this.isAllowDefault(),onEzChange:i=>this.handleDefaultValueChanged(i),value:this.fieldDefaultValue.value,options:this.buildOptions()}):this.fieldDescriptor.userInterface&&this.buildFieldDefaultValueElement()}buildFieldDefaultValueElement(){var i;const{userInterface:e,properties:t,dataType:s}=this.fieldDescriptor;let l,o=a.getBooleanValue(null==t?void 0:t.allowDefault,!this.fieldReadOnly);e===n.FILE&&(o=!1),o&&(l=null===(i=this.fieldDefaultValue)||void 0===i?void 0:i.value,null!=l&&(l=c(s,l)));const h={value:l,enabled:o,label:this.fieldConfig.label,name:this.fieldConfig.name,required:this.fieldRequired,userInterface:e};switch(e){case n.SWITCH:return this.buildInputDefault(h,void 0,f.SWITCH);case n.CHECKBOX:return this.buildInputDefault(h,void 0,f.REGULAR);case n.OPTIONSELECTOR:case n.DECIMALNUMBER:return this.buildInputDefault(h,t);default:return this.buildInputDefault(h)}}buildInputDefault({value:i,enabled:e,label:t,name:l,required:a,userInterface:h},d,r){let c,f=0,p=0;const v=null==h||null==u[h]?u.DEFAULT:u[h];if(h===n.OPTIONSELECTOR){const i=null==d?void 0:d.options;if("string"==typeof i){const e=o.stringToObject(i);c=Object.keys(e).map((i=>({value:i,label:e[i]})))}else c=i}else h===n.DECIMALNUMBER&&(f=Number((null==d?void 0:d.precision)||2),p=Number((null==d?void 0:d.prettyPrecision)||f));return s(v,Object.assign({value:i,enabled:e,label:t,"data-field-name":l,key:l,onEzChange:i=>this.onChangeDefaultValue(null==i?void 0:i.detail)},this.getConditionalAttributes(h,a,c,f,p,r)))}getConditionalAttributes(i,e,t,s,l,a){const o=i==n.SEARCHPLUS;switch(i){case n.SEARCH:case n.SEARCHPLUS:return{suppressEmptyOption:e,optionLoader:i=>this.onSearchDefaultValue(i,{useSearchPlus:o})};case n.OPTIONSELECTOR:return{suppressEmptyOption:e,options:t};case n.CHECKBOX:case n.SWITCH:return{mode:a};case n.INTEGERNUMBER:case n.DECIMALNUMBER:return{precision:s,prettyPrecision:l,onEzStartChange:i=>this.onChangeDefaultValue(null==i?void 0:i.detail)};case n.DATE:case n.DATETIME:case n.TIME:return{onEzStartChange:i=>this.onChangeDefaultValue(null==i?void 0:i.detail)};default:return{}}}onSearchDefaultValue(i,e){if(this._application&&this.fieldConfig)return this._application.executeSearch(i,this.fieldConfig.name,this.dataUnit,e)}initializeValues(){this.fieldLabel=this.fieldConfig.label,this.fieldDefaultValue=this.fieldConfig.defaultValue,this.fieldRequired=this.fieldConfig.required,this.fieldReadOnly=this.fieldConfig.readOnly,this.fieldCleanOnCopy=this.fieldConfig.cleanOnCopy}handleApplyChanges(){this.validateFieldLabel()&&(this.fieldConfig.label=this.fieldLabel,this.fieldConfig.defaultValue=this.fieldDefaultValue,this.fieldConfig.required=this.fieldRequired,this.fieldConfig.readOnly=this.fieldReadOnly,this.fieldConfig.cleanOnCopy=this.fieldCleanOnCopy,this.emitFieldChanged(),this._popoupElement.opened=!1)}applyErrorMessage(){this.fieldLabelErrorMessage=`${this.getMessage("snkConfigOptions.validation.requiredField")} ${this.getMessage("snkConfigOptions.label.nameField")}`}handleDiscardChanges(){this.initializeValues(),this._popoupElement.opened=!1}componentWillLoad(){this.loadDefaultValue(),this._application=h.getContextValue("__SNK__APPLICATION__")}render(){return s("ez-popup",{heightMode:"auto",size:"auto","ez-title":this.getMessage("snkConfigOptions.fieldConfig.title"),onEzClosePopup:()=>this.handleDiscardChanges(),ref:i=>this._popoupElement=i},s("div",{class:"field-config-container"},s("ez-text-input",{label:this.getMessage("snkConfigOptions.label.nameField"),value:this.fieldLabel,errorMessage:this.fieldLabelErrorMessage,hasInvalid:!!this.fieldLabelErrorMessage,onEzChange:i=>this.handleLabelChanged(i)}),s("ez-combo-box",{label:this.getMessage("snkConfigOptions.label.typeValueDefault"),suppressEmptyOption:!0,enabled:this.enabledValueDefault(),onEzChange:i=>this.handleDefaultTypeChanged(i),value:this.getDefaultType()},s("option",{value:r.fixed},this.getMessage("snkConfigOptions.options.valueFixed")),s("option",{value:r.variable},this.getMessage("snkConfigOptions.options.variable"))),this.renderDefaultValueEditor(),s("ez-check",{label:this.getMessage("snkConfigOptions.label.clearDuplicate"),value:this.fieldCleanOnCopy,onEzChange:i=>this.handleClearDuplicateChanged(i)}),s("ez-check",{label:this.getMessage("snkConfigOptions.label.requiredField"),enabled:v("required","systemRequired",this.fieldDescriptor),value:b("required",this.fieldDescriptor,this.fieldRequired),onEzChange:i=>this.handleRequiredChanged(i)}),s("ez-check",{label:this.getMessage("snkConfigOptions.label.protectedField"),enabled:v("readOnly","systemReadOnly",this.fieldDescriptor),value:b("readOnly",this.fieldDescriptor,this.fieldReadOnly),onEzChange:i=>this.handleReadOnlyChanged(i)}),s("div",{class:"actions"},s("ez-button",{label:this.getMessage("snkConfigOptions.fieldConfig.buttons.cancel"),onClick:()=>this.handleDiscardChanges()}),s("ez-button",{label:this.getMessage("snkConfigOptions.fieldConfig.buttons.confirm"),class:"ez-button--primary",onClick:()=>this.handleApplyChanges()}))))}static get watchers(){return{fieldLabel:["observeFieldLabel"]}}};m.style=".field-config-container.sc-field-config{font-family:'Roboto';color:#2b3a54;display:flex;flex-direction:column;gap:10px;width:330px;justify-content:space-between}.header.sc-field-config{display:flex;font-weight:500;font-size:16px}.actions.sc-field-config{display:flex;align-items:flex-end;gap:12px}";const C=class{constructor(t){i(this,t),this.setFieldAsAvailable=e(this,"setFieldAsAvailable",7),this.addFieldToGuide=e(this,"addFieldToGuide",7),this.fieldDescriptor=void 0,this.fieldConfig=void 0,this.onLayoutConfig=!1,this.dataUnit=void 0,this.messagesBuilder=void 0}observeDataUnit(){this.loadFieldDescriptor()}isRequired(){var i,e;const t=this.dataUnit&&this.dataUnit.getField(null===(i=this.fieldConfig)||void 0===i?void 0:i.name);return!0===(null==t?void 0:t.required)||!0===(null===(e=this.fieldConfig)||void 0===e?void 0:e.required)}async showFieldConfig(){var i;await(null===(i=this._refFieldConfig)||void 0===i?void 0:i.show(this._editIconRef))}renderFieldConfig(){if(this.onLayoutConfig&&this.dataUnit&&this.messagesBuilder)return s("field-config",{ref:i=>this._refFieldConfig=i,fieldConfig:this.fieldConfig,dataUnit:this.dataUnit,fieldDescriptor:this.fieldDescriptor,messagesBuilder:this.messagesBuilder,onFieldConfigChanged:()=>t(this)})}getMessage(i,e){return this.messagesBuilder.getMessage(i,e)}renderActions(){return this.onLayoutConfig?s("div",{class:"actions hiddeble"},s("ez-button",{mode:"icon",class:"ez-button--tertiary",onClick:()=>this.setFieldAsAvailable.emit(this.fieldConfig),size:"medium",iconName:"minus",title:this.getMessage("snkFieldConfig.titleRemove")}),s("ez-button",{ref:i=>this._editIconRef=i,mode:"icon",class:"ez-button--tertiary",onClick:this.showFieldConfig.bind(this),iconName:"edit",size:"medium",title:this.getMessage("snkFieldConfig.titleEdit")})):s("div",{class:"actions hiddeble"},s("ez-button",{mode:"icon",class:"ez-button--tertiary",onClick:()=>this.addFieldToGuide.emit(this.fieldConfig),iconName:"plus",size:"medium",title:this.getMessage("snkFieldConfig.titleAddToLayout")}))}loadFieldDescriptor(){this.dataUnit&&(this.fieldDescriptor=this.dataUnit.getField(this.fieldConfig.name))}renderRequiredMark(){if(this.isRequired())return s("span",{class:"required-mark"},"*")}componentWillLoad(){this.loadFieldDescriptor()}getFieldLabel(){var i,e;return(null===(i=this.fieldConfig)||void 0===i?void 0:i.label)?this.fieldConfig.label:null===(e=this.fieldDescriptor)||void 0===e?void 0:e.label}render(){var i;return s(l,{class:this.onLayoutConfig?"":"full-width"},s("div",{class:"icons"},s("ez-icon",{iconName:"drag-indicator"}),s("ez-icon",{iconName:g(null===(i=this.fieldDescriptor)||void 0===i?void 0:i.userInterface)})),s("span",{class:"label"},s("span",{class:"label-text",title:this.getFieldLabel()},this.getFieldLabel()),this.renderRequiredMark()),this.renderActions(),this.renderFieldConfig())}static get watchers(){return{dataUnit:["observeDataUnit"]}}};C.style=".sc-field-item-h{width:100%;display:flex;padding:12px 8px;border-radius:var(--border--radius-small, 4px);border:1px solid #dce0e8;cursor:grab;align-items:center;height:42px;max-height:42px;background:#FAFCFF}.full-width.sc-field-item-h{width:100%}ez-icon.sc-field-item{--ez-icon--color:#A2ABB9}.icons.sc-field-item{display:flex}.label.sc-field-item{display:flex;flex-grow:1;padding-left:8px;font-size:14px;align-items:center;gap:4px;height:22px}.label-text.sc-field-item{overflow:hidden;-webkit-hyphens:auto;-ms-hyphens:auto;hyphens:auto;height:auto;-webkit-box-orient:vertical;-webkit-line-clamp:2;line-clamp:2;display:-webkit-box;-o-text-overflow:ellipsis;text-overflow:ellipsis;word-break:break-word}.required-mark.sc-field-item{color:#cf3105;background:#F7E0E5;width:12px;height:12px;border-radius:50%;display:flex;align-items:center;justify-content:center;padding-top:5px;font-size:16px;align-self:self-start}.actions.sc-field-item{display:flex;flex-direction:row;align-content:center;gap:4px}ez-button.sc-field-item{width:24px;align-items:center;justify-content:center;display:flex}.sc-field-item-h .hiddeble.sc-field-item{transition:0.2s ease-in-out;visibility:hidden;opacity:0}.sc-field-item-h:hover .hiddeble.sc-field-item{visibility:visible;opacity:1}";export{m as field_config,C as field_item}
@@ -1 +1 @@
1
- import{h as e}from"./p-d8d8169b.js";import{P as a}from"./p-0f3698af.js";import{s as t}from"./p-55798617.js";var n,r,s;!function(e){e.PREVIOUS="PREVIOUS",e.NEXT="NEXT",e.REFRESH="REFRESH",e.UPDATE="UPDATE",e.CLONE="CLONE",e.REMOVE="REMOVE",e.INSERT="INSERT",e.CANCEL="CANCEL",e.SAVE="SAVE",e.GRID_MODE="GRID_MODE",e.FORM_MODE="FORM_MODE",e.MORE_OPTIONS="MORE_OPTIONS",e.DIVIDER="DIVIDER",e.CONFIGURATOR="CONFIGURATOR",e.DATA_EXPORTER="DATA_EXPORTER",e.ATTACH="ATTACH",e.ACTIONS_BUTTON="ACTIONS_BUTTON",e.UPDATE_MULTIPLE="UPDATE_MULTIPLE"}(n||(n={})),function(e){e.UPDATE="UPDATE",e.CLONE="CLONE",e.REMOVE="REMOVE",e.INSERT="INSERT",e.CONFIGURATOR="CONFIGURATOR"}(r||(r={})),function(e){e.CONFIGURATOR="CONFIGURATOR"}(s||(s={}));const i=(e,a,t,n,r)=>{const{hint:s,text:i,iconName:l}=e;return l?i?o(l,e.name,a,t,s,i,n,r):d(l,e.name,a,t,s,n,r):c(e.name,a,t,i,s,n,r)},l=(r,s,i,l,u,b,m,k,E)=>{var O;const T=l(r);switch(r){case n.PREVIOUS:return d("chevron-left",r,s,i,T,u,b);case n.NEXT:return d("chevron-right",r,s,i,T,u,b);case n.REFRESH:return d("sync",r,s,i,T,u,b);case n.UPDATE:return d("edit",r,s,i,T,u,b);case n.UPDATE_MULTIPLE:return d("edit-table",r,s,i,T,u,b);case n.CLONE:return d("copy",r,s,i,T,u,b);case n.REMOVE:return d("delete",r,s,i,T,u,b);case n.INSERT:return E===a.PRIMARY?o("plus",r,s,i,T,T,u,b):d("plus",r,s,i,T,u,b);case n.CANCEL:return c(r,s,i,T,T,u,b);case n.SAVE:return E===a.PRIMARY?o("save",r,s,i,T,T,u,b):d("save",r,s,i,T,u,b);case n.GRID_MODE:return d("table",r,s,i,T,u,b);case n.FORM_MODE:return d("list",r,s,i,T,u,b);case n.CONFIGURATOR:return(null==m?void 0:m.length)>0?function(a,t,n,r,s,i,l,c){return l&&l.length>0?e("taskbar-split-button",{iconName:a,class:n,key:s,"data-taskbar-icon":a,"data-taskbar-label":r,"data-taskbar-element":t,"data-element-id":s,enabled:i(t),actions:l,title:r,action:()=>c(t)}):void 0}("settings-inverted",r,s,T,i,b,m,u):d("settings-inverted",r,s,i,T,u,b);case n.MORE_OPTIONS:return function(a,t,n,r,s,i,l){return i&&i.length>0?e("taskbar-actions-button",{class:t,key:n,title:r,"data-taskbar-element":a,"data-element-id":n,enabled:s(a),actions:i,onTaskbarActionSelected:e=>l(e.detail.value)}):void 0}(r,s,i,T,b,m,u);case n.DIVIDER:return e("hr",{class:"ez-divider-vertical ez-divider--dark ez-margin--none ez-margin-left--medium","data-taskbar-divider":!0});case n.DATA_EXPORTER:const l=null===(O=t.get("exporterProviders"))||void 0===O?void 0:O[k];return e("snk-data-exporter",{class:s,provider:l,"data-element-id":i,"data-taskbar-element":r});case n.ATTACH:return d("anexo",r,s,i,T,u,b);case n.ACTIONS_BUTTON:return e("snk-actions-button",{"data-element-id":i,"data-taskbar-element":r})}};function c(a,t,n,r,s,i,l){return e("ez-button",{key:n,title:s,label:r,size:"small",class:t,"data-taskbar-label":r,"data-taskbar-element":a,"data-element-id":n,enabled:l(a),onClick:()=>i(a)})}function d(a,t,n,r,s,i,l){return e("ez-button",{key:r,title:s,mode:"icon",size:"small",class:n,"data-taskbar-label":s,"data-taskbar-element":t,"data-taskbar-icon":a,"data-element-id":r,iconName:a,enabled:l(t),onClick:()=>i(t)})}function o(a,t,n,r,s,i,l,c){return e("ez-button",{key:r,title:i,label:s,size:"small",class:n,"data-taskbar-label":s,"data-taskbar-icon":a,"data-taskbar-element":t,"data-element-id":r,enabled:c(t),onClick:()=>l(t)},e("ez-icon",{class:"ez-padding-right--small",slot:"leftIcon",iconName:a}))}export{r as A,n as T,s as V,i as a,l as b}
1
+ import{h as e}from"./p-82bb3eda.js";import{P as a}from"./p-0f3698af.js";import{s as t}from"./p-8336900b.js";var n,r,s;!function(e){e.PREVIOUS="PREVIOUS",e.NEXT="NEXT",e.REFRESH="REFRESH",e.UPDATE="UPDATE",e.CLONE="CLONE",e.REMOVE="REMOVE",e.INSERT="INSERT",e.CANCEL="CANCEL",e.SAVE="SAVE",e.GRID_MODE="GRID_MODE",e.FORM_MODE="FORM_MODE",e.MORE_OPTIONS="MORE_OPTIONS",e.DIVIDER="DIVIDER",e.CONFIGURATOR="CONFIGURATOR",e.DATA_EXPORTER="DATA_EXPORTER",e.ATTACH="ATTACH",e.ACTIONS_BUTTON="ACTIONS_BUTTON",e.UPDATE_MULTIPLE="UPDATE_MULTIPLE"}(n||(n={})),function(e){e.UPDATE="UPDATE",e.CLONE="CLONE",e.REMOVE="REMOVE",e.INSERT="INSERT",e.CONFIGURATOR="CONFIGURATOR"}(r||(r={})),function(e){e.CONFIGURATOR="CONFIGURATOR"}(s||(s={}));const i=(e,a,t,n,r)=>{const{hint:s,text:i,iconName:l}=e;return l?i?d(l,e.name,a,t,s,i,n,r):o(l,e.name,a,t,s,n,r):c(e.name,a,t,i,s,n,r)},l=(r,s,i,l,u,b,m,k,E)=>{var O;const T=l(r);switch(r){case n.PREVIOUS:return o("chevron-left",r,s,i,T,u,b);case n.NEXT:return o("chevron-right",r,s,i,T,u,b);case n.REFRESH:return o("sync",r,s,i,T,u,b);case n.UPDATE:return o("edit",r,s,i,T,u,b);case n.UPDATE_MULTIPLE:return o("edit-table",r,s,i,T,u,b);case n.CLONE:return o("copy",r,s,i,T,u,b);case n.REMOVE:return o("delete",r,s,i,T,u,b);case n.INSERT:return E===a.PRIMARY?d("plus",r,s,i,T,T,u,b):o("plus",r,s,i,T,u,b);case n.CANCEL:return c(r,s,i,T,T,u,b);case n.SAVE:return E===a.PRIMARY?d("save",r,s,i,T,T,u,b):o("save",r,s,i,T,u,b);case n.GRID_MODE:return o("table",r,s,i,T,u,b);case n.FORM_MODE:return o("list",r,s,i,T,u,b);case n.CONFIGURATOR:return(null==m?void 0:m.length)>0?function(a,t,n,r,s,i,l,c){return l&&l.length>0?e("taskbar-split-button",{iconName:a,class:n,key:s,"data-taskbar-icon":a,"data-taskbar-label":r,"data-taskbar-element":t,"data-element-id":s,enabled:i(t),actions:l,title:r,action:()=>c(t)}):void 0}("settings-inverted",r,s,T,i,b,m,u):o("settings-inverted",r,s,i,T,u,b);case n.MORE_OPTIONS:return function(a,t,n,r,s,i,l){return i&&i.length>0?e("taskbar-actions-button",{class:t,key:n,title:r,"data-taskbar-element":a,"data-element-id":n,enabled:s(a),actions:i,onTaskbarActionSelected:e=>l(e.detail.value)}):void 0}(r,s,i,T,b,m,u);case n.DIVIDER:return e("hr",{class:"ez-divider-vertical ez-divider--dark ez-margin--none ez-margin-left--medium","data-taskbar-divider":!0});case n.DATA_EXPORTER:const l=null===(O=t.get("exporterProviders"))||void 0===O?void 0:O[k];return e("snk-data-exporter",{class:s,provider:l,"data-element-id":i,"data-taskbar-element":r});case n.ATTACH:return o("anexo",r,s,i,T,u,b);case n.ACTIONS_BUTTON:return e("snk-actions-button",{"data-element-id":i,"data-taskbar-element":r})}};function c(a,t,n,r,s,i,l){return e("ez-button",{key:n,title:s,label:r,size:"small",class:t,"data-taskbar-label":r,"data-taskbar-element":a,"data-element-id":n,enabled:l(a),onClick:()=>i(a)})}function o(a,t,n,r,s,i,l){return e("ez-button",{key:r,title:s,mode:"icon",size:"small",class:n,"data-taskbar-label":s,"data-taskbar-element":t,"data-taskbar-icon":a,"data-element-id":r,iconName:a,enabled:l(t),onClick:()=>i(t)})}function d(a,t,n,r,s,i,l,c){return e("ez-button",{key:r,title:i,label:s,size:"small",class:n,"data-taskbar-label":s,"data-taskbar-icon":a,"data-taskbar-element":t,"data-element-id":r,enabled:c(t),onClick:()=>l(t)},e("ez-icon",{class:"ez-padding-right--small",slot:"leftIcon",iconName:a}))}export{r as A,n as T,s as V,i as a,l as b}
@@ -1 +1 @@
1
- import{r as t,c as i,h as s,g as e}from"./p-d8d8169b.js";import{ElementIDUtils as h}from"@sankhyalabs/core";import{F as a}from"./p-ff1990ad.js";import{E as n}from"./p-1a68fb59.js";const r=class{constructor(s){t(this,s),this.valueChanged=i(this,"valueChanged",7),this._startDateLabel="Inicial",this._endDateLabel="Final",this._toLabel="até",this._defaultEmptyValue={start:null,end:null},this.internalChange={start:!1,end:!1},this.config=void 0,this.getMessage=void 0,this.value=this._defaultEmptyValue,this.presentationMode=n.CHIP,this.errorMessage=void 0}configChanged(t,i){this.internalChange.end?this.internalChange.end=!1:this.internalChange.start?this.internalChange.start=!1:!t&&i||!(null==t?void 0:t.start)&&!(null==t?void 0:t.end)?this.clearValue():!t||t.start===(null==i?void 0:i.start)&&t.end===(null==i?void 0:i.end)||(this.valueStart=this.parseDate(t.start),this.valueEnd=this.parseDate(t.end))}ezChangeListener(t,i){this.errorMessage=void 0,this.internalChange[i]=!0,this.value=Object.assign(Object.assign({},this.value||{}),{[i]:t.detail?this.parseDate(t.detail):null}),this.valueChanged.emit(this.value)}async setFocus(){this._startDate.setFocus()}async clearValue(){this.value=this.config.value||this._defaultEmptyValue,this.valueStart=this.getDate("start"),this.valueEnd=this.getDate("end")}componentDidLoad(){this._element&&(h.addIDInfo(this._element,"filterContentEditor"),this._element.querySelectorAll("ez-date-input").forEach((t=>{t.shadowRoot.querySelector("ez-text-input").style.setProperty("--ez-text-input__min-width","120px")})))}parseDate(t){return t instanceof Date?t:"string"==typeof t?((t=new Date(t)).setMinutes(t.getMinutes()+t.getTimezoneOffset()),t):null}getDate(t){return this.parseDate(this.value?this.value[t]:null)}async show(){this._startDate.setFocus()}buildLabel(){if(this.presentationMode===n.CHIP)return s("label",{class:"ez-text ez-text--medium ez-text--primary ez-margin--medium"},this._toLabel)}componentWillLoad(){this.getMessage&&(this._startDateLabel=this.getMessage("snkFilterBar.labelStart"),this._endDateLabel=this.getMessage("snkFilterBar.labelEnd"),this._toLabel=this.getMessage("snkFilterBar.labelTo")),this.valueStart=this.getDate("start"),this.valueEnd=this.getDate("end")}render(){if(this.config&&this.config.type===a.PERIOD)return s("ez-tooltip",{active:!1===this.config.enabled,message:this.config.disabledMessage,type:"warning"},s("div",{class:"ez-col ez-col--nowrap"},s("ez-date-input",{id:`${this.config.id}_start`,class:this.presentationMode===n.MODAL?"ez-padding-right--medium":"",label:this._startDateLabel,ref:t=>this._startDate=t,enabled:this.config.enabled,value:this.valueStart,errorMessage:this.errorMessage,onEzChange:t=>this.ezChangeListener(t,"start")}),this.buildLabel(),s("ez-date-input",{id:`${this.config.id}_end`,label:this._endDateLabel,ref:t=>this._endDate=t,enabled:this.config.enabled,value:this.valueEnd,errorMessage:this.errorMessage,onEzChange:t=>this.ezChangeListener(t,"end")})))}get _element(){return e(this)}static get watchers(){return{value:["configChanged"]}}};export{r as snk_filter_period}
1
+ import{r as t,c as i,h as s,g as e}from"./p-82bb3eda.js";import{ElementIDUtils as h}from"@sankhyalabs/core";import{F as a}from"./p-ff1990ad.js";import{E as n}from"./p-1a68fb59.js";const r=class{constructor(s){t(this,s),this.valueChanged=i(this,"valueChanged",7),this._startDateLabel="Inicial",this._endDateLabel="Final",this._toLabel="até",this._defaultEmptyValue={start:null,end:null},this.internalChange={start:!1,end:!1},this.config=void 0,this.getMessage=void 0,this.value=this._defaultEmptyValue,this.presentationMode=n.CHIP,this.errorMessage=void 0}configChanged(t,i){this.internalChange.end?this.internalChange.end=!1:this.internalChange.start?this.internalChange.start=!1:!t&&i||!(null==t?void 0:t.start)&&!(null==t?void 0:t.end)?this.clearValue():!t||t.start===(null==i?void 0:i.start)&&t.end===(null==i?void 0:i.end)||(this.valueStart=this.parseDate(t.start),this.valueEnd=this.parseDate(t.end))}ezChangeListener(t,i){this.errorMessage=void 0,this.internalChange[i]=!0,this.value=Object.assign(Object.assign({},this.value||{}),{[i]:t.detail?this.parseDate(t.detail):null}),this.valueChanged.emit(this.value)}async setFocus(){this._startDate.setFocus()}async clearValue(){this.value=this.config.value||this._defaultEmptyValue,this.valueStart=this.getDate("start"),this.valueEnd=this.getDate("end")}componentDidLoad(){this._element&&(h.addIDInfo(this._element,"filterContentEditor"),this._element.querySelectorAll("ez-date-input").forEach((t=>{t.shadowRoot.querySelector("ez-text-input").style.setProperty("--ez-text-input__min-width","120px")})))}parseDate(t){return t instanceof Date?t:"string"==typeof t?((t=new Date(t)).setMinutes(t.getMinutes()+t.getTimezoneOffset()),t):null}getDate(t){return this.parseDate(this.value?this.value[t]:null)}async show(){this._startDate.setFocus()}buildLabel(){if(this.presentationMode===n.CHIP)return s("label",{class:"ez-text ez-text--medium ez-text--primary ez-margin--medium"},this._toLabel)}componentWillLoad(){this.getMessage&&(this._startDateLabel=this.getMessage("snkFilterBar.labelStart"),this._endDateLabel=this.getMessage("snkFilterBar.labelEnd"),this._toLabel=this.getMessage("snkFilterBar.labelTo")),this.valueStart=this.getDate("start"),this.valueEnd=this.getDate("end")}render(){if(this.config&&this.config.type===a.PERIOD)return s("ez-tooltip",{active:!1===this.config.enabled,message:this.config.disabledMessage,type:"warning"},s("div",{class:"ez-col ez-col--nowrap"},s("ez-date-input",{id:`${this.config.id}_start`,class:this.presentationMode===n.MODAL?"ez-padding-right--medium":"",label:this._startDateLabel,ref:t=>this._startDate=t,enabled:this.config.enabled,value:this.valueStart,errorMessage:this.errorMessage,onEzChange:t=>this.ezChangeListener(t,"start")}),this.buildLabel(),s("ez-date-input",{id:`${this.config.id}_end`,label:this._endDateLabel,ref:t=>this._endDate=t,enabled:this.config.enabled,value:this.valueEnd,errorMessage:this.errorMessage,onEzChange:t=>this.ezChangeListener(t,"end")})))}get _element(){return e(this)}static get watchers(){return{value:["configChanged"]}}};export{r as snk_filter_period}
@@ -1 +1 @@
1
- import{r as e,c as s,h as t,H as i}from"./p-d8d8169b.js";import{P as a}from"./p-988afe78.js";import"@sankhyalabs/core";import"./p-ff1990ad.js";import"./p-84345e7a.js";const r=class{constructor(t){e(this,t),this.ezExpressionChange=s(this,"ezExpressionChange",7),this.filterAssistent=void 0,this.application=void 0}getMessage(e,s){return this.application.messagesBuilder.getMessage(e,s)}render(){var e;return t(i,null,t("span",{class:"ez-title ez-title--small ez-padding-bottom--small snk-filter-advanced-mode__title"},this.getMessage("snkPersonalizedFilter.info.applyExpression")),t("ez-text-area",{rows:9,label:this.getMessage("snkPersonalizedFilter.info.labelExpression"),value:null===(e=this.filterAssistent)||void 0===e?void 0:e.expression,onEzChange:e=>this.ezExpressionChange.emit(e.detail)}))}};r.style=".sc-snk-filter-advanced-mode-h{display:block;--snk-personalized-filter--title--color:var(--title--primary, #2B3A54)}.snk-filter-advanced-mode__title.sc-snk-filter-advanced-mode{color:var(--snk-personalized-filter--title--color)}";const n=class{constructor(t){e(this,t),this.ezChangeFilter=s(this,"ezChangeFilter",7),this.filterAssistent=void 0,this.messagesBuilder=void 0,this.filterId=void 0,this.entityUri=void 0,this.application=void 0,this.isDefaultFilter=!1}getMessage(e,s){return this.application.messagesBuilder.getMessage(e,s)}async handleFilterGroupChange(){const e=await this._mainExpressionGroup.getExpressionGroup();this.filterAssistent=Object.assign(Object.assign({},this.filterAssistent),{assistent:e}),this.filterAssistent.parameters=a.buildVariableParameters(this.filterAssistent.assistent),this.filterAssistent.expression=a.buildGroupExpression(this.filterAssistent.assistent),this.ezChangeFilter.emit(this.filterAssistent)}render(){var e,s;return t(i,null,t("div",{class:"ez-padding-top--small snk-personalized-filter__group"},t("snk-expression-group",{ref:e=>this._mainExpressionGroup=e,group:null===(e=this.filterAssistent)||void 0===e?void 0:e.assistent,messagesBuilder:this.messagesBuilder,onEzFilterGroupChange:this.handleFilterGroupChange.bind(this),filterId:this.filterId,entityURI:this.entityUri,isDefaultFilter:this.isDefaultFilter})),t("div",{class:"ez-margin-top--auto"},t("div",{class:"snk-personalized-filter__expression-input--line"}),t("ez-collapsible-box",{label:this.getMessage("snkPersonalizedFilter.info.titleCollapsible"),headerSize:"medium",value:!0},t("div",{class:"ez-box"},t("div",{class:"ez-box__container--external"},t("div",{class:"ez-box__container--internal"},t("span",{class:"ez-box__container--title"},this.getMessage("snkPersonalizedFilter.info.labelExpression")),t("span",{class:"ez-box__container--expression"},null===(s=this.filterAssistent)||void 0===s?void 0:s.expression)))))))}};n.style=".sc-snk-filter-assistent-mode-h{display:flex;flex-direction:column;height:100%;--text-area--font-family:var(--font-pattern, Arial);--text-area__label--floating--top:var(--space--small, 6px);--snk-filter-assistent-mode__container--border-radius:var(--border--radius-medium, 12px);--snk-filter-assistent-mode__container--background:var(--background--medium, #f0f3f7);--snk-filter-assistent-mode__container--margin:var(--space--small, 6px) var(--space--medium, 12px)}.ez-box__container--external.sc-snk-filter-assistent-mode{height:100px;width:100%;overflow-y:auto;background-color:var(--snk-filter-assistent-mode__container--background);border-radius:var(--snk-filter-assistent-mode__container--border-radius)}.ez-box__container--internal.sc-snk-filter-assistent-mode{margin:var(--snk-filter-assistent-mode__container--margin)}.ez-box__container--title.sc-snk-filter-assistent-mode{display:block;user-select:none;font-family:var(--text-area--font-family);font-size:var(--text--extra-small);color:var(--title--primary);top:var(--text-area__label--floating--top)}.ez-box__container--expression.sc-snk-filter-assistent-mode{display:block;font-family:var(--text-area--font-family);font-size:var(--text--medium);color:var(--title--primary);top:var(--text-area__label--floating--top)}.snk-personalized-filter__expression-input--line.sc-snk-filter-assistent-mode{width:100%;height:2px;background-color:var(--snk-personalized-filter--background-color-line);margin-top:var(--snk-personalized-filter--margin-line);margin-bottom:var(--snk-personalized-filter--margin-line)}";export{r as snk_filter_advanced_mode,n as snk_filter_assistent_mode}
1
+ import{r as e,c as s,h as t,H as i}from"./p-82bb3eda.js";import{P as a}from"./p-988afe78.js";import"@sankhyalabs/core";import"./p-ff1990ad.js";import"./p-84345e7a.js";const r=class{constructor(t){e(this,t),this.ezExpressionChange=s(this,"ezExpressionChange",7),this.filterAssistent=void 0,this.application=void 0}getMessage(e,s){return this.application.messagesBuilder.getMessage(e,s)}render(){var e;return t(i,null,t("span",{class:"ez-title ez-title--small ez-padding-bottom--small snk-filter-advanced-mode__title"},this.getMessage("snkPersonalizedFilter.info.applyExpression")),t("ez-text-area",{rows:9,label:this.getMessage("snkPersonalizedFilter.info.labelExpression"),value:null===(e=this.filterAssistent)||void 0===e?void 0:e.expression,onEzChange:e=>this.ezExpressionChange.emit(e.detail)}))}};r.style=".sc-snk-filter-advanced-mode-h{display:block;--snk-personalized-filter--title--color:var(--title--primary, #2B3A54)}.snk-filter-advanced-mode__title.sc-snk-filter-advanced-mode{color:var(--snk-personalized-filter--title--color)}";const n=class{constructor(t){e(this,t),this.ezChangeFilter=s(this,"ezChangeFilter",7),this.filterAssistent=void 0,this.messagesBuilder=void 0,this.filterId=void 0,this.entityUri=void 0,this.application=void 0,this.isDefaultFilter=!1}getMessage(e,s){return this.application.messagesBuilder.getMessage(e,s)}async handleFilterGroupChange(){const e=await this._mainExpressionGroup.getExpressionGroup();this.filterAssistent=Object.assign(Object.assign({},this.filterAssistent),{assistent:e}),this.filterAssistent.parameters=a.buildVariableParameters(this.filterAssistent.assistent),this.filterAssistent.expression=a.buildGroupExpression(this.filterAssistent.assistent),this.ezChangeFilter.emit(this.filterAssistent)}render(){var e,s;return t(i,null,t("div",{class:"ez-padding-top--small snk-personalized-filter__group"},t("snk-expression-group",{ref:e=>this._mainExpressionGroup=e,group:null===(e=this.filterAssistent)||void 0===e?void 0:e.assistent,messagesBuilder:this.messagesBuilder,onEzFilterGroupChange:this.handleFilterGroupChange.bind(this),filterId:this.filterId,entityURI:this.entityUri,isDefaultFilter:this.isDefaultFilter})),t("div",{class:"ez-margin-top--auto"},t("div",{class:"snk-personalized-filter__expression-input--line"}),t("ez-collapsible-box",{label:this.getMessage("snkPersonalizedFilter.info.titleCollapsible"),headerSize:"medium",value:!0},t("div",{class:"ez-box"},t("div",{class:"ez-box__container--external"},t("div",{class:"ez-box__container--internal"},t("span",{class:"ez-box__container--title"},this.getMessage("snkPersonalizedFilter.info.labelExpression")),t("span",{class:"ez-box__container--expression"},null===(s=this.filterAssistent)||void 0===s?void 0:s.expression)))))))}};n.style=".sc-snk-filter-assistent-mode-h{display:flex;flex-direction:column;height:100%;--text-area--font-family:var(--font-pattern, Arial);--text-area__label--floating--top:var(--space--small, 6px);--snk-filter-assistent-mode__container--border-radius:var(--border--radius-medium, 12px);--snk-filter-assistent-mode__container--background:var(--background--medium, #f0f3f7);--snk-filter-assistent-mode__container--margin:var(--space--small, 6px) var(--space--medium, 12px)}.ez-box__container--external.sc-snk-filter-assistent-mode{height:100px;width:100%;overflow-y:auto;background-color:var(--snk-filter-assistent-mode__container--background);border-radius:var(--snk-filter-assistent-mode__container--border-radius)}.ez-box__container--internal.sc-snk-filter-assistent-mode{margin:var(--snk-filter-assistent-mode__container--margin)}.ez-box__container--title.sc-snk-filter-assistent-mode{display:block;user-select:none;font-family:var(--text-area--font-family);font-size:var(--text--extra-small);color:var(--title--primary);top:var(--text-area__label--floating--top)}.ez-box__container--expression.sc-snk-filter-assistent-mode{display:block;font-family:var(--text-area--font-family);font-size:var(--text--medium);color:var(--title--primary);top:var(--text-area__label--floating--top)}.snk-personalized-filter__expression-input--line.sc-snk-filter-assistent-mode{width:100%;height:2px;background-color:var(--snk-personalized-filter--background-color-line);margin-top:var(--snk-personalized-filter--margin-line);margin-bottom:var(--snk-personalized-filter--margin-line)}";export{r as snk_filter_advanced_mode,n as snk_filter_assistent_mode}
@@ -1,4 +1,4 @@
1
- import{R as e,F as t}from"./p-4db9dbf8.js";import{D as i,d as s}from"./p-1b1373b6.js";import{F as r}from"./p-ff1990ad.js";import{ObjectUtils as a}from"@sankhyalabs/core";var n;function l(e,t){if(null==e)return e;if(e instanceof Date)return e.toISOString();if("object"==typeof e){if(e instanceof Array)return e.map((e=>l(r.MULTI_LIST===t?function(e,t){var i={};for(var s in e)Object.prototype.hasOwnProperty.call(e,s)&&t.indexOf(s)<0&&(i[s]=e[s]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var r=0;for(s=Object.getOwnPropertySymbols(e);r<s.length;r++)t.indexOf(s[r])<0&&Object.prototype.propertyIsEnumerable.call(e,s[r])&&(i[s[r]]=e[s[r]])}return i}(e,["label"]):e)));{const i=Object.assign({},e);return Object.keys(e).forEach((s=>{void 0!==e[s]?i[s]=l(e[s],t):delete i[s]})),i}}return e}class o{constructor(){this.DEFAULT_RESOURCE="_default",this.templateByQuery=new Map,this.buildTemplates()}resolveURI(e,t,i){let s="filter-assistent-config://"+e;return t&&(s+="."+t),i&&(s+=this.DEFAULT_RESOURCE),s}resolveLegacyConfigName(e,t){if(!e)return"";let i=`?legacyResourceID=${e}`;return t&&(i+=this.DEFAULT_RESOURCE),i}buildTemplates(){this.templateByQuery.set("fetchFilterFields",s.gql`
1
+ import{R as e,F as t}from"./p-7ee6b1bf.js";import{D as i,d as s}from"./p-6768f176.js";import{F as r}from"./p-ff1990ad.js";import{ObjectUtils as a}from"@sankhyalabs/core";var n;function l(e,t){if(null==e)return e;if(e instanceof Date)return e.toISOString();if("object"==typeof e){if(e instanceof Array)return e.map((e=>l(r.MULTI_LIST===t?function(e,t){var i={};for(var s in e)Object.prototype.hasOwnProperty.call(e,s)&&t.indexOf(s)<0&&(i[s]=e[s]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var r=0;for(s=Object.getOwnPropertySymbols(e);r<s.length;r++)t.indexOf(s[r])<0&&Object.prototype.propertyIsEnumerable.call(e,s[r])&&(i[s[r]]=e[s[r]])}return i}(e,["label"]):e)));{const i=Object.assign({},e);return Object.keys(e).forEach((s=>{void 0!==e[s]?i[s]=l(e[s],t):delete i[s]})),i}}return e}class o{constructor(){this.DEFAULT_RESOURCE="_default",this.templateByQuery=new Map,this.buildTemplates()}resolveURI(e,t,i){let s="filter-assistent-config://"+e;return t&&(s+="."+t),i&&(s+=this.DEFAULT_RESOURCE),s}resolveLegacyConfigName(e,t){if(!e)return"";let i=`?legacyResourceID=${e}`;return t&&(i+=this.DEFAULT_RESOURCE),i}buildTemplates(){this.templateByQuery.set("fetchFilterFields",s.gql`
2
2
  query($name: String!) {
3
3
  $queryAlias$: fetchFilterFields(name: $name){
4
4
  currentLink {
@@ -1 +1 @@
1
- import{r as t,c as s,h as e,H as i,g as h}from"./p-d8d8169b.js";import{ElementIDUtils as l}from"@sankhyalabs/core";import{F as a}from"./p-ff1990ad.js";import{E as o}from"./p-1a68fb59.js";const r=class{constructor(e){t(this,e),this.valueChanged=s(this,"valueChanged",7),this._noOptionValue="NO_VALUE",this._radioButtonValue=void 0,this.value=void 0,this.config=void 0,this.presentationMode=o.CHIP,this.errorMessage=void 0}isSelected(t){return null==this.value||this.value===t}ezChangeListener(t){if(this.errorMessage=void 0,this.presentationMode===o.MODAL)return t.detail||this.assertCheckedOption(t.target),void this.updateValue();this.value=t.detail===this._noOptionValue?void 0:t.detail,this._radioButtonValue=t.detail}async resetValues(){this.ezChangeListener({detail:this._noOptionValue})}async clearValue(){this.value=this.config.value,this._radioButtonValue=this.value||this._noOptionValue}async setFocus(){this.presentationMode!==o.MODAL?this._element.querySelector("ez-radio-button").focus():this._checkOne.setFocus()}assertCheckedOption(t){t===this._checkOne?this._checkTwo.value=!0:this._checkOne.value=!0}updateValue(){if(this._checkOne.value&&this._checkTwo.value)this.value=void 0;else{const[t,s]=this.config.props.options;this.value=this._checkOne.value?t.name:s.name}this.valueChanged.emit(this.value)}setRadioValue(){this._radioButtonValue=this.value||this._noOptionValue}componentDidLoad(){this._element&&l.addIDInfo(this._element,"filterContentEditor")}componentWillLoad(){this.setRadioValue()}componentShouldUpdate(){this.setRadioValue()}disconnectedCallback(){this.value=this.config.value}render(){if(!this.config||this.config.type!==a.BINARY_SELECT)return;const[t,s]=this.config.props.options;return e(i,null,this.presentationMode===o.MODAL?e("div",{class:"ez-row ez-size-height--full"},e("label",{class:"ez-text ez-title--small ez-title--primary ez-size-height--full ez-flex ez-flex--row ez-flex--align-items-center ez-col ez-col--sd-4"},this.config.detailModal),e("div",{class:"ez-col ez-col--sd-4"},e("ez-check",{ref:t=>this._checkOne=t,id:`${this.config.id}_${t.name||"option1"}`,class:"sc-snk-filter-bar editor__ez-check",label:t.label,enabled:this.config.enabled,value:this.isSelected(t.name)})),e("div",{class:"ez-col ez-col--sd-4"},e("ez-check",{ref:t=>this._checkTwo=t,id:`${this.config.id}_${s.name||"option2"}`,class:"sc-snk-filter-bar editor__ez-check",label:s.label,enabled:this.config.enabled,value:this.isSelected(s.name)})),this.errorMessage&&e("span",{class:"ez-text ez-text--small ez-text--error ez-margin--small"},this.errorMessage)):e("ez-tooltip",{active:!1===this.config.enabled,message:this.config.disabledMessage,type:"warning"},e("ez-radio-button",{value:this._radioButtonValue},e("ez-radio-button-option",{id:`${this.config.id}_${t.name||"option1"}`,class:"sc-snk-filter-bar editor__ez-check",label:t.label,value:t.name}),e("ez-radio-button-option",{id:`${this.config.id}_${s.name||"option2"}`,class:"sc-snk-filter-bar editor__ez-check",label:s.label,value:s.name}),e("ez-radio-button-option",{id:`${this.config.id}_option3`,class:"sc-snk-filter-bar editor__ez-check",label:`${t.label} + ${s.label}`,value:this._noOptionValue})),this.errorMessage&&e("span",{class:"ez-text ez-text--small ez-text--error ez-margin--small"},this.errorMessage)))}get _element(){return h(this)}};export{r as snk_filter_binary_select}
1
+ import{r as t,c as s,h as e,H as i,g as h}from"./p-82bb3eda.js";import{ElementIDUtils as l}from"@sankhyalabs/core";import{F as a}from"./p-ff1990ad.js";import{E as o}from"./p-1a68fb59.js";const r=class{constructor(e){t(this,e),this.valueChanged=s(this,"valueChanged",7),this._noOptionValue="NO_VALUE",this._radioButtonValue=void 0,this.value=void 0,this.config=void 0,this.presentationMode=o.CHIP,this.errorMessage=void 0}isSelected(t){return null==this.value||this.value===t}ezChangeListener(t){if(this.errorMessage=void 0,this.presentationMode===o.MODAL)return t.detail||this.assertCheckedOption(t.target),void this.updateValue();this.value=t.detail===this._noOptionValue?void 0:t.detail,this._radioButtonValue=t.detail}async resetValues(){this.ezChangeListener({detail:this._noOptionValue})}async clearValue(){this.value=this.config.value,this._radioButtonValue=this.value||this._noOptionValue}async setFocus(){this.presentationMode!==o.MODAL?this._element.querySelector("ez-radio-button").focus():this._checkOne.setFocus()}assertCheckedOption(t){t===this._checkOne?this._checkTwo.value=!0:this._checkOne.value=!0}updateValue(){if(this._checkOne.value&&this._checkTwo.value)this.value=void 0;else{const[t,s]=this.config.props.options;this.value=this._checkOne.value?t.name:s.name}this.valueChanged.emit(this.value)}setRadioValue(){this._radioButtonValue=this.value||this._noOptionValue}componentDidLoad(){this._element&&l.addIDInfo(this._element,"filterContentEditor")}componentWillLoad(){this.setRadioValue()}componentShouldUpdate(){this.setRadioValue()}disconnectedCallback(){this.value=this.config.value}render(){if(!this.config||this.config.type!==a.BINARY_SELECT)return;const[t,s]=this.config.props.options;return e(i,null,this.presentationMode===o.MODAL?e("div",{class:"ez-row ez-size-height--full"},e("label",{class:"ez-text ez-title--small ez-title--primary ez-size-height--full ez-flex ez-flex--row ez-flex--align-items-center ez-col ez-col--sd-4"},this.config.detailModal),e("div",{class:"ez-col ez-col--sd-4"},e("ez-check",{ref:t=>this._checkOne=t,id:`${this.config.id}_${t.name||"option1"}`,class:"sc-snk-filter-bar editor__ez-check",label:t.label,enabled:this.config.enabled,value:this.isSelected(t.name)})),e("div",{class:"ez-col ez-col--sd-4"},e("ez-check",{ref:t=>this._checkTwo=t,id:`${this.config.id}_${s.name||"option2"}`,class:"sc-snk-filter-bar editor__ez-check",label:s.label,enabled:this.config.enabled,value:this.isSelected(s.name)})),this.errorMessage&&e("span",{class:"ez-text ez-text--small ez-text--error ez-margin--small"},this.errorMessage)):e("ez-tooltip",{active:!1===this.config.enabled,message:this.config.disabledMessage,type:"warning"},e("ez-radio-button",{value:this._radioButtonValue},e("ez-radio-button-option",{id:`${this.config.id}_${t.name||"option1"}`,class:"sc-snk-filter-bar editor__ez-check",label:t.label,value:t.name}),e("ez-radio-button-option",{id:`${this.config.id}_${s.name||"option2"}`,class:"sc-snk-filter-bar editor__ez-check",label:s.label,value:s.name}),e("ez-radio-button-option",{id:`${this.config.id}_option3`,class:"sc-snk-filter-bar editor__ez-check",label:`${t.label} + ${s.label}`,value:this._noOptionValue})),this.errorMessage&&e("span",{class:"ez-text ez-text--small ez-text--error ez-margin--small"},this.errorMessage)))}get _element(){return h(this)}};export{r as snk_filter_binary_select}
@@ -0,0 +1 @@
1
+ export{S as snk_guides_viewer}from"./p-907e96eb.js";import"./p-82bb3eda.js";import"@sankhyalabs/core";import"@sankhyalabs/core/dist/dataunit/DataUnit";import"@sankhyalabs/ezui/dist/collection/utils";import"@sankhyalabs/ezui/dist/collection/utils/form";import"./p-6768f176.js";import"./p-8d884fab.js";import"@sankhyalabs/core/dist/dataunit/metadata/UnitMetadata";import"./p-48a5c311.js";import"./p-0f3698af.js";import"@sankhyalabs/ezui/dist/collection/utils/constants";import"./p-9e4555ab.js";import"@sankhyalabs/ezui/dist/collection/components/ez-grid/utils";import"@sankhyalabs/core/dist/utils/SortingUtils";import"./p-688dcb4c.js";import"./p-ff1990ad.js";import"./p-7ee6b1bf.js";import"./p-9019a32f.js";import"./p-2ac55a5d.js";import"./p-1f310bc6.js";import"./p-1be69fd4.js";import"./p-8336900b.js";import"./p-1a0caadb.js";
@@ -1 +1 @@
1
- import{ObjectUtils as t,StringUtils as i}from"@sankhyalabs/core";import{C as e}from"./p-0e4f8b86.js";import{F as s}from"./p-4db9dbf8.js";import{a as r}from"./p-9019a32f.js";class n{constructor(t,i,e,s){this._resourceID=i,this._configName=t,this._onConfigChange=e,this._dataUnit=s}addFormLegacyConfig(t){this._configName&&e.addFormLegacyConfig(this._configName,t)}async loadConfig(){return new Promise((t=>{e.loadFormConfig(this._configName,this._resourceID).then((i=>{i=this.buildFormMetadataUITabs(i),this.setConfig(i),t(i)})).catch((t=>{console.warn(t)}))}))}getEmptyConfig(){return this.buildFormMetadataUITabs({fields:[],emptyConfig:!0},!0)}saveConfig(i){const s=t.copy(i);return new Promise((t=>{e.saveFormConfig(i,this._configName,this._resourceID).then((i=>{this.setConfig(Object.assign(Object.assign({},s),i)),t(Object.assign(Object.assign({},s),i))}))}))}saveCardState(t,i,s){return new Promise((r=>{var n;const l=(null===(n=this._config)||void 0===n?void 0:n.cardsState)||new Map,o=l.get(t);l.set(t,"fixed"===s?this.updateFixSequence(Object.assign(Object.assign({},o),{fixed:i.fixed}),l):Object.assign(Object.assign({},o),{[s]:i[s]})),e.saveCardState(l,this._configName,this._resourceID).then((t=>{this._config=Object.assign(Object.assign({},this._config),{cardsState:l}),r(t)}))}))}updateFixSequence(t,i){let e=-1;return Array.from(i.values()).forEach((i=>{i.fixed||delete t.fixSequence,null!=i.fixSequence&&(e=Math.max(e,i.fixSequence))})),t.fixed?t.fixSequence=e+1:delete t.fixSequence,t}hasConfig(t){var i;const e=null!=t?t:this._config;return!(!e||!(null===(i=e.fields)||void 0===i?void 0:i.length))}getFieldsList(t,i=!1){var e,s;const r=null===(e=this._config)||void 0===e?void 0:e.fields;return this.hasConfig()&&!i?r.map((({label:t,name:i,readOnly:e,visible:s,required:r,tab:n,group:l})=>{var o;if(null==t){const t=null===(o=this._dataUnit)||void 0===o?void 0:o.getField(i);if(!t)return;return Object.assign(Object.assign({},t),{name:null!=i?i:t.name,readOnly:null!=e?e:t.readOnly,visible:null!=s?s:t.visible,required:null!=r?r:t.required,tab:n,group:l})}return{name:i,label:t,readOnly:e,visible:s,required:r,tab:n,group:l}})).filter((i=>this.isFieldVisible(i,t))):this._dataUnit&&(null===(s=this._dataUnit.metadata)||void 0===s?void 0:s.fields)?this._dataUnit.metadata.fields.filter((i=>this.isFieldVisible(i,t))).map((({label:t,name:i,readOnly:e,visible:s,required:r,properties:n})=>({label:t,name:i,readOnly:e,visible:s,required:r,tab:null==n?void 0:n.UITabName}))):[]}isFieldVisible(t,e){if(void 0===t||!1===t.visible)return!1;if(null==e)return!0;const s=i.replaceAccentuatedCharsLower((t.label||t.name).toLocaleLowerCase()),r=i.replaceAccentuatedCharsLower(e.toLocaleLowerCase());return s.includes(r)}getFormConfig(t,i,e=!1){let s=this.getFieldsList(void 0,e);return i&&(s=s.filter((i=>{if(t){const e=t.getField(i.name);if(e&&e.readOnly)return!1}return!i.readOnly}))),Object.assign(Object.assign({},this._config),{fields:s})}setConfig(t){this.isLoaded=!0;const{cardsState:i,summary:e,defaultVars:s}=this._config||{};this._config=Object.assign({},t),i&&(this._config.cardsState=i),e&&(this._config.summary=e),s&&(this._config.defaultVars=s),this._onConfigChange&&this._onConfigChange(Object.assign({},this._config))}getConfig(t,i){return this.getFormConfig(t,i)}getFormConfigFetcher(){return null==this._formConfigFetcher&&(this._formConfigFetcher=new s),this._formConfigFetcher}async fetchUserAvailableConfigs(){return null!=this._configName?Promise.resolve(void 0):this.getFormConfigFetcher().fetchUserAvailableConfigs(this._configName,this._resourceID)}async fetchLegacyConfig(){return this.getFormConfigFetcher().fetchLegacyConfig(this._configName,this._resourceID)}async fetchDefaultConfig(){return this.getFormConfigFetcher().fetchDefaultConfig(this._configName,this._resourceID)}parseObjectList(t){return t?Array.isArray(t)?t:[t]:[]}buildFormMetadataUITabs(t,i=!1){var e,s,n;const l=this.hasConfig(t);if(!i&&(!this._dataUnit||l))return t;(t=this.getFormConfig(this._dataUnit,!1,!0)).tabs=this.parseObjectList(t.tabs),t.emptyConfig=!1,t.defaultConfiguration=!0;const o=null!==(s=null===(e=this._dataUnit.metadata)||void 0===e?void 0:e.fields)&&void 0!==s?s:[];for(const i of o){const e=t.fields.find((t=>t.name===i.name)),s=null===(n=i.properties)||void 0===n?void 0:n.UITabName;s&&s!==r.main&&(t.tabs.some((t=>t.label===s))||t.tabs.push({label:s,name:s,order:0,visible:!0}),e&&(e.tab=s))}return t}}export{n as S}
1
+ import{ObjectUtils as t,StringUtils as i}from"@sankhyalabs/core";import{C as e}from"./p-1f310bc6.js";import{F as s}from"./p-7ee6b1bf.js";import{a as r}from"./p-9019a32f.js";class n{constructor(t,i,e,s){this._resourceID=i,this._configName=t,this._onConfigChange=e,this._dataUnit=s}addFormLegacyConfig(t){this._configName&&e.addFormLegacyConfig(this._configName,t)}async loadConfig(){return new Promise((t=>{e.loadFormConfig(this._configName,this._resourceID).then((i=>{i=this.buildFormMetadataUITabs(i),this.setConfig(i),t(i)})).catch((t=>{console.warn(t)}))}))}getEmptyConfig(){return this.buildFormMetadataUITabs({fields:[],emptyConfig:!0},!0)}saveConfig(i){const s=t.copy(i);return new Promise((t=>{e.saveFormConfig(i,this._configName,this._resourceID).then((i=>{this.setConfig(Object.assign(Object.assign({},s),i)),t(Object.assign(Object.assign({},s),i))}))}))}saveCardState(t,i,s){return new Promise((r=>{var n;const l=(null===(n=this._config)||void 0===n?void 0:n.cardsState)||new Map,o=l.get(t);l.set(t,"fixed"===s?this.updateFixSequence(Object.assign(Object.assign({},o),{fixed:i.fixed}),l):Object.assign(Object.assign({},o),{[s]:i[s]})),e.saveCardState(l,this._configName,this._resourceID).then((t=>{this._config=Object.assign(Object.assign({},this._config),{cardsState:l}),r(t)}))}))}updateFixSequence(t,i){let e=-1;return Array.from(i.values()).forEach((i=>{i.fixed||delete t.fixSequence,null!=i.fixSequence&&(e=Math.max(e,i.fixSequence))})),t.fixed?t.fixSequence=e+1:delete t.fixSequence,t}hasConfig(t){var i;const e=null!=t?t:this._config;return!(!e||!(null===(i=e.fields)||void 0===i?void 0:i.length))}getFieldsList(t,i=!1){var e,s;const r=null===(e=this._config)||void 0===e?void 0:e.fields;return this.hasConfig()&&!i?r.map((({label:t,name:i,readOnly:e,visible:s,required:r,tab:n,group:l})=>{var o;if(null==t){const t=null===(o=this._dataUnit)||void 0===o?void 0:o.getField(i);if(!t)return;return Object.assign(Object.assign({},t),{name:null!=i?i:t.name,readOnly:null!=e?e:t.readOnly,visible:null!=s?s:t.visible,required:null!=r?r:t.required,tab:n,group:l})}return{name:i,label:t,readOnly:e,visible:s,required:r,tab:n,group:l}})).filter((i=>this.isFieldVisible(i,t))):this._dataUnit&&(null===(s=this._dataUnit.metadata)||void 0===s?void 0:s.fields)?this._dataUnit.metadata.fields.filter((i=>this.isFieldVisible(i,t))).map((({label:t,name:i,readOnly:e,visible:s,required:r,properties:n})=>({label:t,name:i,readOnly:e,visible:s,required:r,tab:null==n?void 0:n.UITabName}))):[]}isFieldVisible(t,e){if(void 0===t||!1===t.visible)return!1;if(null==e)return!0;const s=i.replaceAccentuatedCharsLower((t.label||t.name).toLocaleLowerCase()),r=i.replaceAccentuatedCharsLower(e.toLocaleLowerCase());return s.includes(r)}getFormConfig(t,i,e=!1){let s=this.getFieldsList(void 0,e);return i&&(s=s.filter((i=>{if(t){const e=t.getField(i.name);if(e&&e.readOnly)return!1}return!i.readOnly}))),Object.assign(Object.assign({},this._config),{fields:s})}setConfig(t){this.isLoaded=!0;const{cardsState:i,summary:e,defaultVars:s}=this._config||{};this._config=Object.assign({},t),i&&(this._config.cardsState=i),e&&(this._config.summary=e),s&&(this._config.defaultVars=s),this._onConfigChange&&this._onConfigChange(Object.assign({},this._config))}getConfig(t,i){return this.getFormConfig(t,i)}getFormConfigFetcher(){return null==this._formConfigFetcher&&(this._formConfigFetcher=new s),this._formConfigFetcher}async fetchUserAvailableConfigs(){return null!=this._configName?Promise.resolve(void 0):this.getFormConfigFetcher().fetchUserAvailableConfigs(this._configName,this._resourceID)}async fetchLegacyConfig(){return this.getFormConfigFetcher().fetchLegacyConfig(this._configName,this._resourceID)}async fetchDefaultConfig(){return this.getFormConfigFetcher().fetchDefaultConfig(this._configName,this._resourceID)}parseObjectList(t){return t?Array.isArray(t)?t:[t]:[]}buildFormMetadataUITabs(t,i=!1){var e,s,n;const l=this.hasConfig(t);if(!i&&(!this._dataUnit||l))return t;(t=this.getFormConfig(this._dataUnit,!1,!0)).tabs=this.parseObjectList(t.tabs),t.emptyConfig=!1,t.defaultConfiguration=!0;const o=null!==(s=null===(e=this._dataUnit.metadata)||void 0===e?void 0:e.fields)&&void 0!==s?s:[];for(const i of o){const e=t.fields.find((t=>t.name===i.name)),s=null===(n=i.properties)||void 0===n?void 0:n.UITabName;s&&s!==r.main&&(t.tabs.some((t=>t.label===s))||t.tabs.push({label:s,name:s,order:0,visible:!0}),e&&(e.tab=s))}return t}}export{n as S}
@@ -1 +1 @@
1
- import{r as i,c as t,h as s,g as e}from"./p-d8d8169b.js";import{ElementIDUtils as h}from"@sankhyalabs/core";import{F as a}from"./p-ff1990ad.js";import{F as l}from"./p-fa80e546.js";import{E as r}from"./p-1a68fb59.js";const n=class{constructor(s){i(this,s),this.valueChanged=t(this,"valueChanged",7),this._startIntervalLabel="Inicial",this._endIntervalLabel="Final",this._toLabel="até",this.config=void 0,this.getMessage=void 0,this.value=void 0,this.presentationMode=r.CHIP,this.errorMessage=void 0}ezChangeListener(i){if(this.errorMessage=void 0,this.getVariation()===l.INTERVAL){const i=this._startInterval.value,t=this._endInterval.value;return this.value=isNaN(i)&&isNaN(t)?void 0:{start:i,end:t},void this.valueChanged.emit(this.value)}this.value=i.detail,this.valueChanged.emit(this.value)}async show(){this.getVariation()!==l.INTERVAL?this._numberElement.setFocus():this._startInterval.setFocus()}async setFocus(){this.getVariation()!==l.INTERVAL?await this._numberElement.setFocus():await this._startInterval.setFocus()}async clearValue(){var i,t;if(this.value=this.config.value,this.getVariation()===l.INTERVAL){const s=this.config.value;this._startInterval&&(this._startInterval.value=null!==(i=null==s?void 0:s.start)&&void 0!==i?i:null),this._endInterval&&(this._endInterval.value=null!==(t=null==s?void 0:s.end)&&void 0!==t?t:null)}else this._numberElement&&(this._numberElement.value=this.config.value)}getIntervalValue(i){const t=this.value?this.value[i]:null;return null!=t?t:null}buildLabel(){if(this.presentationMode===r.CHIP)return s("label",{class:"ez-text ez-text--medium ez-text--primary ez-margin--medium"},this._toLabel)}getVariation(){var i,t;return null!==(t=null===(i=this.config.props)||void 0===i?void 0:i.variation)&&void 0!==t?t:l.DEFAULT}componentWillLoad(){this.getMessage&&(this._startIntervalLabel=this.getMessage("snkFilterBar.labelStart"),this._endIntervalLabel=this.getMessage("snkFilterBar.labelEnd"),this._toLabel=this.getMessage("snkFilterBar.labelTo"))}componentDidLoad(){this._element&&h.addIDInfo(this._element,"filterContentEditor")}render(){var i,t,e;if(this.config&&this.config.type===a.NUMBER)return this.getVariation()===l.INTERVAL?s("ez-tooltip",{active:!1===this.config.enabled,message:this.config.disabledMessage,type:"warning"},s("div",{class:"ez-col ez-col--nowrap"},s("ez-number-input",{id:`${this.config.id}_start`,class:this.presentationMode===r.MODAL?"ez-padding-right--medium":"",label:this._startIntervalLabel,ref:i=>this._startInterval=i,value:this.getIntervalValue("start"),enabled:this.config.enabled,precision:null===(i=this.config.props)||void 0===i?void 0:i.precision,errorMessage:this.errorMessage}),this.buildLabel(),s("ez-number-input",{id:`${this.config.id}_end`,label:this._endIntervalLabel,ref:i=>this._endInterval=i,value:this.getIntervalValue("end"),enabled:this.config.enabled,precision:null===(t=this.config.props)||void 0===t?void 0:t.precision,errorMessage:this.errorMessage}))):s("ez-tooltip",{active:!1===this.config.enabled,message:this.config.disabledMessage,type:"warning"},s("ez-number-input",{id:this.config.id,label:this.config.label,ref:i=>this._numberElement=i,value:this.config.value,precision:null===(e=this.config.props)||void 0===e?void 0:e.precision,enabled:this.config.enabled,errorMessage:this.errorMessage}))}get _element(){return e(this)}};export{n as snk_filter_number}
1
+ import{r as i,c as t,h as s,g as e}from"./p-82bb3eda.js";import{ElementIDUtils as h}from"@sankhyalabs/core";import{F as a}from"./p-ff1990ad.js";import{F as l}from"./p-fa80e546.js";import{E as r}from"./p-1a68fb59.js";const n=class{constructor(s){i(this,s),this.valueChanged=t(this,"valueChanged",7),this._startIntervalLabel="Inicial",this._endIntervalLabel="Final",this._toLabel="até",this.config=void 0,this.getMessage=void 0,this.value=void 0,this.presentationMode=r.CHIP,this.errorMessage=void 0}ezChangeListener(i){if(this.errorMessage=void 0,this.getVariation()===l.INTERVAL){const i=this._startInterval.value,t=this._endInterval.value;return this.value=isNaN(i)&&isNaN(t)?void 0:{start:i,end:t},void this.valueChanged.emit(this.value)}this.value=i.detail,this.valueChanged.emit(this.value)}async show(){this.getVariation()!==l.INTERVAL?this._numberElement.setFocus():this._startInterval.setFocus()}async setFocus(){this.getVariation()!==l.INTERVAL?await this._numberElement.setFocus():await this._startInterval.setFocus()}async clearValue(){var i,t;if(this.value=this.config.value,this.getVariation()===l.INTERVAL){const s=this.config.value;this._startInterval&&(this._startInterval.value=null!==(i=null==s?void 0:s.start)&&void 0!==i?i:null),this._endInterval&&(this._endInterval.value=null!==(t=null==s?void 0:s.end)&&void 0!==t?t:null)}else this._numberElement&&(this._numberElement.value=this.config.value)}getIntervalValue(i){const t=this.value?this.value[i]:null;return null!=t?t:null}buildLabel(){if(this.presentationMode===r.CHIP)return s("label",{class:"ez-text ez-text--medium ez-text--primary ez-margin--medium"},this._toLabel)}getVariation(){var i,t;return null!==(t=null===(i=this.config.props)||void 0===i?void 0:i.variation)&&void 0!==t?t:l.DEFAULT}componentWillLoad(){this.getMessage&&(this._startIntervalLabel=this.getMessage("snkFilterBar.labelStart"),this._endIntervalLabel=this.getMessage("snkFilterBar.labelEnd"),this._toLabel=this.getMessage("snkFilterBar.labelTo"))}componentDidLoad(){this._element&&h.addIDInfo(this._element,"filterContentEditor")}render(){var i,t,e;if(this.config&&this.config.type===a.NUMBER)return this.getVariation()===l.INTERVAL?s("ez-tooltip",{active:!1===this.config.enabled,message:this.config.disabledMessage,type:"warning"},s("div",{class:"ez-col ez-col--nowrap"},s("ez-number-input",{id:`${this.config.id}_start`,class:this.presentationMode===r.MODAL?"ez-padding-right--medium":"",label:this._startIntervalLabel,ref:i=>this._startInterval=i,value:this.getIntervalValue("start"),enabled:this.config.enabled,precision:null===(i=this.config.props)||void 0===i?void 0:i.precision,errorMessage:this.errorMessage}),this.buildLabel(),s("ez-number-input",{id:`${this.config.id}_end`,label:this._endIntervalLabel,ref:i=>this._endInterval=i,value:this.getIntervalValue("end"),enabled:this.config.enabled,precision:null===(t=this.config.props)||void 0===t?void 0:t.precision,errorMessage:this.errorMessage}))):s("ez-tooltip",{active:!1===this.config.enabled,message:this.config.disabledMessage,type:"warning"},s("ez-number-input",{id:this.config.id,label:this.config.label,ref:i=>this._numberElement=i,value:this.config.value,precision:null===(e=this.config.props)||void 0===e?void 0:e.precision,enabled:this.config.enabled,errorMessage:this.errorMessage}))}get _element(){return e(this)}};export{n as snk_filter_number}
@@ -1 +1 @@
1
- import{r as t,c as i,h as e}from"./p-d8d8169b.js";import{ApplicationContext as a,DataType as s,Action as n,UserInterface as o,StringUtils as r,DataUnitLoaderUtils as l,DataUnit as d}from"@sankhyalabs/core";import{D as h,S as c}from"./p-1b1373b6.js";import{S as v}from"./p-3c046287.js";import"./p-0f3698af.js";import{P as u,D as m,I as A}from"./p-9ab6ae1e.js";import"./p-ff1990ad.js";import"./p-4db9dbf8.js";import{V as O}from"./p-9019a32f.js";import{A as p}from"./p-b9699067.js";import{T as w}from"./p-b987e15d.js";import"./p-8d884fab.js";import"@sankhyalabs/core/dist/dataunit/metadata/UnitMetadata";import"@sankhyalabs/ezui/dist/collection/utils/constants";import"@sankhyalabs/ezui/dist/collection/components/ez-grid/utils";import"@sankhyalabs/core/dist/utils/SortingUtils";import"./p-688dcb4c.js";import"./p-55798617.js";class k{constructor(t){this.dataUnitName=t}async save({dataUnit:t,record:i,updatingFields:e,operation:a}){var s,n;const o="INSERT"==a,r=o?e:i;if(!o&&(null==e?void 0:e.DESCRICAO)&&(null==e?void 0:e.DESCRICAO)!==(null==i?void 0:i.DESCRICAO))throw new Error(v.DESCRIPTION_CANNOT_BE_CHANGED);const l={anexo:{codata:o?null==e?void 0:e.REGISTER_KEY:null==i?void 0:i.CODATA,sequencia:(null==r?void 0:r.SEQUENCIA)||"0",tipo:(null==r?void 0:r.TIPO)||"N",descricao:null==r?void 0:r.DESCRICAO,arquivo:null===(n=null===(s=e.CAMINHO_ARQUIVO)||void 0===s?void 0:s[0])||void 0===n?void 0:n.name,ehInclusao:o?"S":"N",ehArquivoRepositorio:"N"}};return new Promise(((i,a)=>{h.get().callServiceBroker("Attach.save",JSON.stringify(l)).then((a=>{var s;return i([Object.assign(Object.assign(Object.assign({},a),e),{__owner__dataunit__name__:null!==(s=this.dataUnitName)&&void 0!==s?s:t})])})).catch((t=>a(t)))}))}async edit(t){throw new Error("Method not implemented.")}async delete(t){var i={anexo:{codata:t.CODATA,tipo:t.TIPO,descricao:t.DESCRICAO}};const e=await h.get().callServiceBroker("Attach.remove",JSON.stringify(i));return Promise.resolve(e)}async getDownloadKey(t){var i,e,a;if("S"==t.EHARQUIVOREPOSITORIO){const a={config:{path:t.ARQUIVO,tipoconteudo:t.TIPOCONTEUDO}},s=await h.get().callServiceBroker("RepositorioArquivoSP.abreArquivo",JSON.stringify(a));return Promise.resolve({chave:{valor:null===(e=null===(i=null==s?void 0:s.responseBody)||void 0===i?void 0:i.chave)||void 0===e?void 0:e.valor}})}const s={anexo:{codata:t.CODATA,codemp:t.CODEMP,sequencia:t.SEQUENCIA,tipo:t.TIPO,descricao:t.DESCRICAO,tipoConteudo:t.TIPOCONTEUDO}},n=await h.get().callServiceBroker("Attach.view",JSON.stringify(s));return(null==n?void 0:n.chaveAnexo)?Promise.resolve({chave:{valor:null===(a=null==n?void 0:n.chaveAnexo)||void 0===a?void 0:a.idChaveAnexo}}):Promise.reject(new Error("File not found."))}}const S="AnexoSistemaSP.salvar",I="AnexoSistemaSP.excluir",f="AnexoSistemaSP.baixar";class y{constructor(t,i){var e;this.entityName=t,this.dataUnitName=i,this.validateFields=t=>{if(t.LINK&&t.NOMEARQUIVO)throw new Error(v.LINK_AND_FILE_AT_THE_SAME_TIME);if(!t.LINK&&!t.NOMEARQUIVO)throw new Error(v.ANY_LINK_OR_FILE_FILLED);if(!this._registerKey)throw new Error("Register key can not be null")},this.resourceID=window.resourceID||(null===(e=window.workspace)||void 0===e?void 0:e.resourceID)}set registerKey(t){this._registerKey=t}async save(t){var i,e;let{updatingFields:a}=t;a=Object.assign(Object.assign({},a),{NOMEARQUIVO:null===(i=a.NOMEARQUIVO)||void 0===i?void 0:i[0]});try{this.validateFields(a);const t=a.LINK?null:a.NOMEARQUIVO,i={serviceName:S,requestBody:{params:{resourceID:this.resourceID,description:a.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:a.LINK,nameEntity:this.entityName,pkEntity:this._registerKey,typeAcess:a.TIPOACESSO,typeApres:a.TIPOAPRES}}},s=await h.get().callServiceBroker(S,JSON.stringify(i));return Promise.resolve([Object.assign(Object.assign(Object.assign({},s),a),{ARQUIVOOULINK:a.LINK?a.LINK:null==t?void 0:t.name,__owner__dataunit__name__:this.dataUnitName})])}catch(t){return Promise.reject(t)}}async edit(t){var i,e,a;let{updatingFields:s,record:n}=t;const o=t=>void 0!==s[t]?s[t]:n[t],r=o("NOMEARQUIVO"),l=null===(e=null===(i=s.NOMEARQUIVO)||void 0===i?void 0:i[0])||void 0===e?void 0:e.downloadURL;s=Object.assign(Object.assign({},s),{DESCRICAO:o("DESCRICAO"),LINK:o("LINK"),TIPOACESSO:o("TIPOACESSO"),TIPOAPRES:o("TIPOAPRES"),CHAVEARQUIVO:n.CHAVEARQUIVO,NOMEARQUIVO:null==r?void 0:r[0]});const d=s.LINK?null:s.NOMEARQUIVO;try{this.validateFields(s);const t={serviceName:S,requestBody:{params:{resourceID:this.resourceID,nuAttach:null==n?void 0:n.NUATTACH,description:s.DESCRICAO,fileSelect:l?1:0,keySession:null===(a=null==d?void 0:d.properties)||void 0===a?void 0:a.fileNameTmp,keyAttach:s.CHAVEARQUIVO,nameAttach:null==d?void 0:d.name,link:s.LINK,nameEntity:this.entityName,pkEntity:this._registerKey,typeAcess:s.TIPOACESSO,typeApres:s.TIPOAPRES}}},i=await h.get().callServiceBroker(S,JSON.stringify(t));return Promise.resolve([Object.assign(Object.assign(Object.assign({},i),s),{ARQUIVOOULINK:s.LINK?s.LINK:null==d?void 0:d.name,__owner__dataunit__name__:this.dataUnitName})])}catch(t){return Promise.reject(t)}}delete(t){var i;const e=(null===(i=t.NOMEARQUIVO)||void 0===i?void 0:i[0])||{},a={serviceName:I,requestBody:{paramsDelete:{keyAttach:t.CHAVEARQUIVO,nameAttach:null==e?void 0:e.name,nameEntity:t.NOMEINSTANCIA,nuAttach:t.NUATTACH,pkEntity:t.PKREGISTRO}}};return new Promise(((t,i)=>{h.get().callServiceBroker(I,JSON.stringify(a)).then((i=>t(i))).catch((t=>i(t)))}))}getDownloadKey(t){var i;const e=(null===(i=t.NOMEARQUIVO)||void 0===i?void 0:i[0])||{},a={serviceName:f,requestBody:{paramsDown:{nameAttach:null==e?void 0:e.name,nameEntity:t.NOMEINSTANCIA,nuAttach:t.NUATTACH,pkEntity:t.PKREGISTRO,keyAttach:t.CHAVEARQUIVO}}};return new Promise(((t,i)=>{h.get().callServiceBroker(f,JSON.stringify(a)).then((i=>t(i))).catch((t=>i(t)))}))}}class b{constructor(t,i){this.entityName=t,this.getMessage=i,this._application=a.getContextValue("__SNK__APPLICATION__")}initLoaders(t,i,e){this.loader||(this.loader=t.dataLoader),t.dataLoader=(t,i)=>this.dataLoader(t,i),t.saveLoader=(t,a)=>this.saveLoader(a,i).then((t=>(t.length&&e(),t))),t.removeLoader=(t,a)=>this.removeLoader(t,a,i).then((t=>(t.length&&e(),t)))}metadataLoader(t){throw new Error("Method not implemented.")}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 a;const s=Array.isArray(t)?t[0]:{};((null===(a=null==s?void 0:s.record)||void 0===a?void 0:a.NUATTACH)>=0?i.edit.bind(i):i.save.bind(i))(s).then((t=>{e(t)})).catch((t=>t.message===v.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===v.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((a=>{const{records:s}=t.getSelectionInfo(),n=s[0];e.delete(n).then((()=>(u.removeRecords(t,[n]),a(i))))}))}getFilters(t){return[{name:"AttachmentsByPK",expression:"this.PKREGISTRO = :PKREGISTRO",params:[{name:"PKREGISTRO",dataType:s.TEXT,value:`${t}_${this.entityName}`}]}]}getInterceptions(t,i,e){return new Promise((a=>i.type===n.EDITION_CANCELED?t.isDirty()?this._application.confirm(this.getMessage("snkAttach.cancelConfirmation.title"),this.getMessage("snkAttach.cancelConfirmation.message")).then((t=>t?(e.goToView(O.GRID),a(i)):a(void 0))):a(i):i.type===n.DATA_SAVED?(t.loadData(),a(i)):void a(i)))}}let _;const g=t=>(_||(_=new c),_.getMessage(t)),N={grid:{columns:[{name:"CODATA",orderIndex:0,width:0},{name:"DESCRICAO",orderIndex:1,width:0},{name:"ARQUIVO",orderIndex:2,width:0},{name:"DTALTER",orderIndex:3,width:0},{name:"USUARIO",orderIndex:4,width:0}]},form:{emptyConfig:!1,fields:[{name:"DESCRICAO",label:g("snkAttach.attachMetadata.lblDescription"),visible:!0,readOnly:!1,required:!0},{name:"CAMINHO_ARQUIVO",label:g("snkAttach.attachMetadata.lblFile"),visible:!0,readOnly:!1,required:!0}]}},E={name:"Attach",label:"Attach List",fields:[{name:"CODATA",label:g("snkAttach.attachMetadata.lblCode"),dataType:s.TEXT},{name:"DESCRICAO",label:g("snkAttach.attachMetadata.lblDescription"),dataType:s.TEXT,readOnly:!1},{name:"ARQUIVO",label:g("snkAttach.attachMetadata.lblFileOrLink"),dataType:s.TEXT},{name:"USUARIO",label:g("snkAttach.attachMetadata.lblUser"),dataType:s.TEXT},{name:"DTALTER",label:g("snkAttach.attachMetadata.lblDate"),dataType:s.TEXT},{name:"CAMINHO_ARQUIVO",label:g("snkAttach.attachMetadata.lblFileUpload"),dataType:s.OBJECT,userInterface:o.FILE,readOnly:!1,required:!0,visible:!0,properties:{subTitle:g("snkAttach.attachMetadata.lblSubTitle"),MAX_FILES:1,STORAGESTRATEGY:"SESSION",INTERNAL_FILENAME:"Attach.upload"}}]};class C{constructor(t){this.getMessage=t,this._records=[],this._application=a.getContextValue("__SNK__APPLICATION__")}initLoaders(t,i,e){t.metadataLoader=t=>this.metadataLoader(t),t.dataLoader=(t,i)=>this.dataLoader(t,i),t.saveLoader=(t,a)=>this.saveLoader(a,i).then((t=>(t.length&&e(),t))),t.removeLoader=(t,a)=>this.removeLoader(t,a,i).then((t=>(t.length&&e(),t)))}metadataLoader(t){return Promise.resolve(E)}async dataLoader(t,i){if(!i.source)return Promise.resolve({records:this._records});if(!Number.isNaN(Number(i.source))){const t={criteria:{codata:i.source,tipoAnexo:"N"}},e=await this._application.getDataFetcher(),{anexos:{anexo:a=[]}}=await e.callServiceBroker("Attach.load",JSON.stringify(t)),s=[];a.forEach((t=>{s.push(Object.assign({__record__id__:r.generateUUID(),CAMINHO_ARQUIVO:[{name:null==t?void 0:t.ARQUIVO}]},t))})),this._records=s}return l.buildLoadDataResponse(this._records,t,i)}saveLoader(t,i){return new Promise((e=>{const a=Array.isArray(t)?t[0]:{};i.save(a).then(e).catch((t=>t.message===v.DESCRIPTION_CANNOT_BE_CHANGED?(this._application.alert(this.getMessage("snkAttach.alertValidation.descriptionCannotBeChanged.title"),this.getMessage("snkAttach.alertValidation.descriptionCannotBeChanged.message")),e([])):t.message===v.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===v.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((a=>{t.getSelectionInfo().records.forEach((async t=>{this._application.hasAccess(p.REMOVE).then((async s=>{s&&(await e.delete(t),a(i))}))}))}))}getFilters(){throw new Error("Method not implemented.")}getInterceptions(t,i,e){return new Promise((a=>{var s,o,r,l,d,h;switch(i.type){case n.EDITION_CANCELED:return t.isDirty()?this._application.confirm(this.getMessage("snkAttach.cancelConfirmation.title"),this.getMessage("snkAttach.cancelConfirmation.message")).then((t=>t?(e.goToView(O.GRID),a(i)):a(void 0))):a(i);case n.DATA_SAVED:return t.loadData(void 0,void 0,!1,null===(r=null===(o=null===(s=null==i?void 0:i.payload)||void 0===s?void 0:s.records)||void 0===o?void 0:o[0])||void 0===r?void 0:r.REGISTER_KEY),a(i);case n.RECORDS_REMOVED:return t.loadData(void 0,void 0,!1,null===(h=null===(d=null===(l=null==i?void 0:i.payload)||void 0===l?void 0:l.cachedRecords)||void 0===d?void 0:d[0])||void 0===h?void 0:h.CODATA),a(i)}a(i)}))}}let L;const R=t=>{var i;if(!L){const t=a.getContextValue("__SNK__APPLICATION__");L=null==t?void 0:t.messagesBuilder}return null===(i=null==L?void 0:L.getMessage)||void 0===i?void 0:i.call(L,t,null)},T={DOWNLOAD:{hint:R("snkAttach.taskbar.titleDownload"),name:"DOWNLOAD",iconName:"file-download"},LINK:{hint:R("snkAttach.taskbar.titleLink"),name:"LINK",iconName:"launch"}},x=()=>{const t=[w.REMOVE,"DOWNLOAD","LINK"];return{getButtons:(t,i,e)=>{const a=e.indexOf(w.REFRESH);if((null==i?void 0:i.insertionMode)||(null==i?void 0:i.isDirty))return e.reverse();-1!==a&&e.splice(a,1);const{selectedRecord:s}=i||{},n=(null==s?void 0:s.LINK)?T.LINK:T.DOWNLOAD;e.splice(e.indexOf(w.DIVIDER)+1,0,w.REMOVE,n,w.DIVIDER);const o=[w.CLONE,w.DATA_EXPORTER],r=Array.from(new Set(e.filter((t=>!o.includes(t)))));return r.splice(r.indexOf(n)+1,0,w.DIVIDER),r},isEnabled:(i,e,a)=>{const s=void 0!==(null==e?void 0:e.selectedRecord);return!(t.includes(a)&&!s)}}},P={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"}]}},D=class{constructor(e){t(this,e),this.back=i(this,"back",7),this.handleTaskbarClick=async({detail:t})=>{if(["DOWNLOAD","LINK"].includes(t))return this.downloadAttachment(this._currentDataUnit.getSelectedRecord());"Attach"===this.fetcherType&&["SAVE"].includes(t)&&this._currentDataUnit.isDirty()&&await this._currentDataUnit.setFieldValue("REGISTER_KEY",this.registerKey)},this.handleBack=()=>{this._currentDataUnit.cancelEdition().then((t=>{t&&this.back.emit()}))},this.handleFinish=()=>{if(!this._currentDataUnit.isDirty())return this.back.emit();this.validateAnexoSistema()&&this._currentDataUnit.saveData().then((()=>{this.showFinishedToast(),this.back.emit()}))},this.gridLegacyConfigName=void 0,this.fetcherType=void 0,this.fetcher=void 0,this.dataUnit=void 0,this.dataUnitBuilder=void 0,this.registerKey=void 0,this.entityName=void 0,this.messagesBuilder=void 0,this._currentFetcher=void 0,this._currentDataUnit=void 0,this.crudConfig=void 0}async registerKeyWatcher(t,i){var e;null==this._currentDataUnit&&this.loadAttachmentDataUnit(),i!==t&&(this._currentFetcher instanceof y&&(this._currentFetcher.registerKey=t),await(null===(e=this._currentDataUnit)||void 0===e?void 0:e.loadData()))}getAnexoSistemaFetcherInstance(){var t;const i=new y(this.entityName,null===(t=this._currentDataUnit)||void 0===t?void 0:t.name);return i.registerKey=this.registerKey,i}async initAttach(){var t,i,e,a,s;if(this.fetcherType||this.registerKey){if(this.fetcherType||(this.fetcherType="AnexoSistema"),this.returnToGridMode(),"AnexoSistema"===this.fetcherType)return this._currentFetcher=this.getAnexoSistemaFetcherInstance(),null===(t=this._currentDataUnitBuilder)||void 0===t||t.initLoaders(this._currentDataUnit,this._currentFetcher,this.returnToGridMode.bind(this)),void await(null===(i=this._currentDataUnit)||void 0===i?void 0:i.loadData());if("Attach"===this.fetcherType&&(null===(e=this.registerKey)||void 0===e?void 0:e.split("_").length)>1)return;await(null===(a=this._currentDataUnit)||void 0===a?void 0:a.loadMetadata()),await(null===(s=this._currentDataUnit)||void 0===s?void 0:s.loadData(void 0,void 0,!0,this.registerKey))}}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(this.getMessage("snkAttach.alertValidation.noRecordSelected.message"));t.LINK?window.open(`${t.LINK}`):this._currentFetcher.getDownloadKey(t).then((({chave:i})=>{var e;let a=!1;(null===(e=null==t?void 0:t.ARQUIVO)||void 0===e?void 0:e.endsWith(".pdf"))||(a=!0),window.open(`/mge/visualizadorArquivos.mge?chaveArquivo=${i.valor}${a?"&forcarDownload=S":""}`)}))}returnToGridMode(){var t;null===(t=this._currentDataUnit)||void 0===t||t.clearSelection(),this._crudElement&&this._crudElement.goToView(O.GRID)}async loadAttachmentDataUnit(){try{switch(this.fetcherType){case"AnexoSistema":await this.loadAnexoSistema();break;case"Attach":await this.loadAttach();break;default:this._currentFetcher=this.fetcher,this._currentDataUnit=this.dataUnit,this._currentDataUnitBuilder=this.dataUnitBuilder}}catch(t){throw new Error("There was an error while creating the data unit")}}async loadAnexoSistema(){var t,i;let e;this._currentDataUnit=(new m).getDataUnit("AnexoSistema","br.com.sankhya.core.v3.anexoSistema"),this._currentFetcher=this.getAnexoSistemaFetcherInstance(),this._currentDataUnit.metadata||(await(null===(t=this._currentDataUnit)||void 0===t?void 0:t.loadMetadata()),this.crudConfig=this.entityName?{form:null==P?void 0:P.form}:Object.assign({},P),e={grid:null==P?void 0:P.grid}),this.initDataUnitLoaders(),this._currentDataUnit.addFilterProvider({getFilter:()=>this._currentDataUnitBuilder.getFilters(this.registerKey)}),this._currentDataUnit.addInterceptor({interceptAction:t=>this._currentDataUnitBuilder.getInterceptions(this._currentDataUnit,t,this._crudElement)}),await(null===(i=this._currentDataUnit)||void 0===i?void 0:i.loadData()),this.disableEditFieldsNotInForm(e)}async loadAttach(){var t,i;let e;this._currentFetcher=new k,this._currentDataUnit=new d(A.IN_MEMORY_DATA_UNIT_NAME),this._currentDataUnit.pageSize=150,this.initDataUnitLoaders(),this._currentDataUnit.addInterceptor({interceptAction:t=>{var i;return t.type===n.METADATA_LOADED&&(this.crudConfig=this.entityName?{form:null==N?void 0:N.form}:Object.assign({},N),e={grid:null==N?void 0:N.grid},null===(i=this._crudElement)||void 0===i||i.updateConfig()),this._currentDataUnitBuilder.getInterceptions(this._currentDataUnit,t,this._crudElement)}}),this._currentDataUnit.metadata||(await(null===(t=this._currentDataUnit)||void 0===t?void 0:t.loadMetadata()),this.crudConfig=this.entityName?{form:null==N?void 0:N.form}:Object.assign({},N),e={grid:null==N?void 0:N.grid},await(null===(i=this._currentDataUnit)||void 0===i?void 0:i.loadData(void 0,void 0,!0,this.registerKey)),this.disableEditFieldsNotInForm(e))}initDataUnitLoaders(){var t,i;"AnexoSistema"===this.fetcherType&&(this._currentFetcher=this.getAnexoSistemaFetcherInstance(),this._currentDataUnitBuilder=new b(this.entityName,this.getMessage.bind(this)),null===(t=this._currentDataUnitBuilder)||void 0===t||t.initLoaders(this._currentDataUnit,this._currentFetcher,this.returnToGridMode.bind(this))),"Attach"===this.fetcherType&&(this._currentFetcher=new k,this._currentDataUnitBuilder=new C(this.getMessage.bind(this)),null===(i=this._currentDataUnitBuilder)||void 0===i||i.initLoaders(this._currentDataUnit,this._currentFetcher,(async()=>{this.returnToGridMode(),await this._currentDataUnit.loadData(void 0,void 0,!0,this.registerKey)})))}disableEditFieldsNotInForm(t){var i,e,a,s,n;const o=(null===(e=null===(i=this._crudElement)||void 0===i?void 0:i.gridConfig)||void 0===e?void 0:e.columns)||(null===(a=null==t?void 0:t.grid)||void 0===a?void 0:a.columns)||(null===(n=null===(s=this.crudConfig)||void 0===s?void 0:s.grid)||void 0===n?void 0:n.columns);this.getGridLegacyConfigName()&&this._currentDataUnit.disableField("ARQUIVOOULINK"),null==o||o.forEach((t=>{var i,e;const a=t.name;(null===(e=null===(i=this.crudConfig)||void 0===i?void 0:i.form)||void 0===e?void 0:e.fields.some((t=>(null==t?void 0:t.name)===a)))||this._currentDataUnit.disableField(a)}))}validateAnexoSistema(){var t;if(this._currentFetcher instanceof y)try{let i=this._currentDataUnit.getSelectedRecord();i=Object.assign(Object.assign({},i),{NOMEARQUIVO:null===(t=i.NOMEARQUIVO)||void 0===t?void 0:t[0]}),this._currentFetcher.validateFields(i)}catch(t){if(t.message===v.LINK_AND_FILE_AT_THE_SAME_TIME)return this._application.alert(this.getMessage("snkAttach.alertValidation.fileAndLinkAtTheSameTime.title"),this.getMessage("snkAttach.alertValidation.fileAndLinkAtTheSameTime.message")),!1;if(t.message===v.ANY_LINK_OR_FILE_FILLED)return this._application.alert(this.getMessage("snkAttach.alertValidation.anyLinkOrFileFilled.title"),this.getMessage("snkAttach.alertValidation.anyLinkOrFileFilled.message")),!1}return!0}async componentWillLoad(){this._application=a.getContextValue("__SNK__APPLICATION__"),await this.initAttach()}componentWillRender(){this.fetcherType||(this.fetcherType="AnexoSistema"),null==this._currentDataUnit&&this.loadAttachmentDataUnit()}async handleOnDataStateChange({detail:t}){"Attach"===this.fetcherType&&(t.insertionMode?this._currentDataUnit.enableField("DESCRICAO"):this._currentDataUnit.disableField("DESCRICAO"),await this._currentDataUnit.loadMetadata())}getGridLegacyConfigName(){return this.gridLegacyConfigName?this.gridLegacyConfigName:this.entityName?"GrdCfgHtml5:grdcfg.dynaform.anexo."+this.entityName:this.entityName}render(){var t,i;return this._currentDataUnit?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._currentDataUnit,taskbarManager:x(),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,onDataStateChange:this.handleOnDataStateChange.bind(this),multipleSelection:!0,configName:this.entityName,ignoreReadOnlyFormFields:!!this.entityName,gridLegacyConfigName:this.getGridLegacyConfigName()},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 ez-padding-bottom--medium"},this.getMessage("snkAttach.description")))))))):null}static get watchers(){return{registerKey:["registerKeyWatcher"]}}};D.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{D as snk_attach}
1
+ import{r as t,c as i,h as e}from"./p-82bb3eda.js";import{ApplicationContext as a,DataType as s,Action as n,UserInterface as o,StringUtils as r,DataUnitLoaderUtils as l,DataUnit as d}from"@sankhyalabs/core";import{D as h,S as c}from"./p-6768f176.js";import{S as v}from"./p-48a5c311.js";import"./p-0f3698af.js";import{P as u,D as m,I as A}from"./p-9e4555ab.js";import"./p-ff1990ad.js";import"./p-7ee6b1bf.js";import{V as O}from"./p-9019a32f.js";import{A as p}from"./p-52691b42.js";import{T as w}from"./p-1be69fd4.js";import"./p-8d884fab.js";import"@sankhyalabs/core/dist/dataunit/metadata/UnitMetadata";import"@sankhyalabs/ezui/dist/collection/utils/constants";import"@sankhyalabs/ezui/dist/collection/components/ez-grid/utils";import"@sankhyalabs/core/dist/utils/SortingUtils";import"./p-688dcb4c.js";import"./p-8336900b.js";class k{constructor(t){this.dataUnitName=t}async save({dataUnit:t,record:i,updatingFields:e,operation:a}){var s,n;const o="INSERT"==a,r=o?e:i;if(!o&&(null==e?void 0:e.DESCRICAO)&&(null==e?void 0:e.DESCRICAO)!==(null==i?void 0:i.DESCRICAO))throw new Error(v.DESCRIPTION_CANNOT_BE_CHANGED);const l={anexo:{codata:o?null==e?void 0:e.REGISTER_KEY:null==i?void 0:i.CODATA,sequencia:(null==r?void 0:r.SEQUENCIA)||"0",tipo:(null==r?void 0:r.TIPO)||"N",descricao:null==r?void 0:r.DESCRICAO,arquivo:null===(n=null===(s=e.CAMINHO_ARQUIVO)||void 0===s?void 0:s[0])||void 0===n?void 0:n.name,ehInclusao:o?"S":"N",ehArquivoRepositorio:"N"}};return new Promise(((i,a)=>{h.get().callServiceBroker("Attach.save",JSON.stringify(l)).then((a=>{var s;return i([Object.assign(Object.assign(Object.assign({},a),e),{__owner__dataunit__name__:null!==(s=this.dataUnitName)&&void 0!==s?s:t})])})).catch((t=>a(t)))}))}async edit(t){throw new Error("Method not implemented.")}async delete(t){var i={anexo:{codata:t.CODATA,tipo:t.TIPO,descricao:t.DESCRICAO}};const e=await h.get().callServiceBroker("Attach.remove",JSON.stringify(i));return Promise.resolve(e)}async getDownloadKey(t){var i,e,a;if("S"==t.EHARQUIVOREPOSITORIO){const a={config:{path:t.ARQUIVO,tipoconteudo:t.TIPOCONTEUDO}},s=await h.get().callServiceBroker("RepositorioArquivoSP.abreArquivo",JSON.stringify(a));return Promise.resolve({chave:{valor:null===(e=null===(i=null==s?void 0:s.responseBody)||void 0===i?void 0:i.chave)||void 0===e?void 0:e.valor}})}const s={anexo:{codata:t.CODATA,codemp:t.CODEMP,sequencia:t.SEQUENCIA,tipo:t.TIPO,descricao:t.DESCRICAO,tipoConteudo:t.TIPOCONTEUDO}},n=await h.get().callServiceBroker("Attach.view",JSON.stringify(s));return(null==n?void 0:n.chaveAnexo)?Promise.resolve({chave:{valor:null===(a=null==n?void 0:n.chaveAnexo)||void 0===a?void 0:a.idChaveAnexo}}):Promise.reject(new Error("File not found."))}}const S="AnexoSistemaSP.salvar",I="AnexoSistemaSP.excluir",f="AnexoSistemaSP.baixar";class y{constructor(t,i){var e;this.entityName=t,this.dataUnitName=i,this.validateFields=t=>{if(t.LINK&&t.NOMEARQUIVO)throw new Error(v.LINK_AND_FILE_AT_THE_SAME_TIME);if(!t.LINK&&!t.NOMEARQUIVO)throw new Error(v.ANY_LINK_OR_FILE_FILLED);if(!this._registerKey)throw new Error("Register key can not be null")},this.resourceID=window.resourceID||(null===(e=window.workspace)||void 0===e?void 0:e.resourceID)}set registerKey(t){this._registerKey=t}async save(t){var i,e;let{updatingFields:a}=t;a=Object.assign(Object.assign({},a),{NOMEARQUIVO:null===(i=a.NOMEARQUIVO)||void 0===i?void 0:i[0]});try{this.validateFields(a);const t=a.LINK?null:a.NOMEARQUIVO,i={serviceName:S,requestBody:{params:{resourceID:this.resourceID,description:a.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:a.LINK,nameEntity:this.entityName,pkEntity:this._registerKey,typeAcess:a.TIPOACESSO,typeApres:a.TIPOAPRES}}},s=await h.get().callServiceBroker(S,JSON.stringify(i));return Promise.resolve([Object.assign(Object.assign(Object.assign({},s),a),{ARQUIVOOULINK:a.LINK?a.LINK:null==t?void 0:t.name,__owner__dataunit__name__:this.dataUnitName})])}catch(t){return Promise.reject(t)}}async edit(t){var i,e,a;let{updatingFields:s,record:n}=t;const o=t=>void 0!==s[t]?s[t]:n[t],r=o("NOMEARQUIVO"),l=null===(e=null===(i=s.NOMEARQUIVO)||void 0===i?void 0:i[0])||void 0===e?void 0:e.downloadURL;s=Object.assign(Object.assign({},s),{DESCRICAO:o("DESCRICAO"),LINK:o("LINK"),TIPOACESSO:o("TIPOACESSO"),TIPOAPRES:o("TIPOAPRES"),CHAVEARQUIVO:n.CHAVEARQUIVO,NOMEARQUIVO:null==r?void 0:r[0]});const d=s.LINK?null:s.NOMEARQUIVO;try{this.validateFields(s);const t={serviceName:S,requestBody:{params:{resourceID:this.resourceID,nuAttach:null==n?void 0:n.NUATTACH,description:s.DESCRICAO,fileSelect:l?1:0,keySession:null===(a=null==d?void 0:d.properties)||void 0===a?void 0:a.fileNameTmp,keyAttach:s.CHAVEARQUIVO,nameAttach:null==d?void 0:d.name,link:s.LINK,nameEntity:this.entityName,pkEntity:this._registerKey,typeAcess:s.TIPOACESSO,typeApres:s.TIPOAPRES}}},i=await h.get().callServiceBroker(S,JSON.stringify(t));return Promise.resolve([Object.assign(Object.assign(Object.assign({},i),s),{ARQUIVOOULINK:s.LINK?s.LINK:null==d?void 0:d.name,__owner__dataunit__name__:this.dataUnitName})])}catch(t){return Promise.reject(t)}}delete(t){var i;const e=(null===(i=t.NOMEARQUIVO)||void 0===i?void 0:i[0])||{},a={serviceName:I,requestBody:{paramsDelete:{keyAttach:t.CHAVEARQUIVO,nameAttach:null==e?void 0:e.name,nameEntity:t.NOMEINSTANCIA,nuAttach:t.NUATTACH,pkEntity:t.PKREGISTRO}}};return new Promise(((t,i)=>{h.get().callServiceBroker(I,JSON.stringify(a)).then((i=>t(i))).catch((t=>i(t)))}))}getDownloadKey(t){var i;const e=(null===(i=t.NOMEARQUIVO)||void 0===i?void 0:i[0])||{},a={serviceName:f,requestBody:{paramsDown:{nameAttach:null==e?void 0:e.name,nameEntity:t.NOMEINSTANCIA,nuAttach:t.NUATTACH,pkEntity:t.PKREGISTRO,keyAttach:t.CHAVEARQUIVO}}};return new Promise(((t,i)=>{h.get().callServiceBroker(f,JSON.stringify(a)).then((i=>t(i))).catch((t=>i(t)))}))}}class b{constructor(t,i){this.entityName=t,this.getMessage=i,this._application=a.getContextValue("__SNK__APPLICATION__")}initLoaders(t,i,e){this.loader||(this.loader=t.dataLoader),t.dataLoader=(t,i)=>this.dataLoader(t,i),t.saveLoader=(t,a)=>this.saveLoader(a,i).then((t=>(t.length&&e(),t))),t.removeLoader=(t,a)=>this.removeLoader(t,a,i).then((t=>(t.length&&e(),t)))}metadataLoader(t){throw new Error("Method not implemented.")}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 a;const s=Array.isArray(t)?t[0]:{};((null===(a=null==s?void 0:s.record)||void 0===a?void 0:a.NUATTACH)>=0?i.edit.bind(i):i.save.bind(i))(s).then((t=>{e(t)})).catch((t=>t.message===v.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===v.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((a=>{const{records:s}=t.getSelectionInfo(),n=s[0];e.delete(n).then((()=>(u.removeRecords(t,[n]),a(i))))}))}getFilters(t){return[{name:"AttachmentsByPK",expression:"this.PKREGISTRO = :PKREGISTRO",params:[{name:"PKREGISTRO",dataType:s.TEXT,value:`${t}_${this.entityName}`}]}]}getInterceptions(t,i,e){return new Promise((a=>i.type===n.EDITION_CANCELED?t.isDirty()?this._application.confirm(this.getMessage("snkAttach.cancelConfirmation.title"),this.getMessage("snkAttach.cancelConfirmation.message")).then((t=>t?(e.goToView(O.GRID),a(i)):a(void 0))):a(i):i.type===n.DATA_SAVED?(t.loadData(),a(i)):void a(i)))}}let _;const g=t=>(_||(_=new c),_.getMessage(t)),N={grid:{columns:[{name:"CODATA",orderIndex:0,width:0},{name:"DESCRICAO",orderIndex:1,width:0},{name:"ARQUIVO",orderIndex:2,width:0},{name:"DTALTER",orderIndex:3,width:0},{name:"USUARIO",orderIndex:4,width:0}]},form:{emptyConfig:!1,fields:[{name:"DESCRICAO",label:g("snkAttach.attachMetadata.lblDescription"),visible:!0,readOnly:!1,required:!0},{name:"CAMINHO_ARQUIVO",label:g("snkAttach.attachMetadata.lblFile"),visible:!0,readOnly:!1,required:!0}]}},E={name:"Attach",label:"Attach List",fields:[{name:"CODATA",label:g("snkAttach.attachMetadata.lblCode"),dataType:s.TEXT},{name:"DESCRICAO",label:g("snkAttach.attachMetadata.lblDescription"),dataType:s.TEXT,readOnly:!1},{name:"ARQUIVO",label:g("snkAttach.attachMetadata.lblFileOrLink"),dataType:s.TEXT},{name:"USUARIO",label:g("snkAttach.attachMetadata.lblUser"),dataType:s.TEXT},{name:"DTALTER",label:g("snkAttach.attachMetadata.lblDate"),dataType:s.TEXT},{name:"CAMINHO_ARQUIVO",label:g("snkAttach.attachMetadata.lblFileUpload"),dataType:s.OBJECT,userInterface:o.FILE,readOnly:!1,required:!0,visible:!0,properties:{subTitle:g("snkAttach.attachMetadata.lblSubTitle"),MAX_FILES:1,STORAGESTRATEGY:"SESSION",INTERNAL_FILENAME:"Attach.upload"}}]};class C{constructor(t){this.getMessage=t,this._records=[],this._application=a.getContextValue("__SNK__APPLICATION__")}initLoaders(t,i,e){t.metadataLoader=t=>this.metadataLoader(t),t.dataLoader=(t,i)=>this.dataLoader(t,i),t.saveLoader=(t,a)=>this.saveLoader(a,i).then((t=>(t.length&&e(),t))),t.removeLoader=(t,a)=>this.removeLoader(t,a,i).then((t=>(t.length&&e(),t)))}metadataLoader(t){return Promise.resolve(E)}async dataLoader(t,i){if(!i.source)return Promise.resolve({records:this._records});if(!Number.isNaN(Number(i.source))){const t={criteria:{codata:i.source,tipoAnexo:"N"}},e=await this._application.getDataFetcher(),{anexos:{anexo:a=[]}}=await e.callServiceBroker("Attach.load",JSON.stringify(t)),s=[];a.forEach((t=>{s.push(Object.assign({__record__id__:r.generateUUID(),CAMINHO_ARQUIVO:[{name:null==t?void 0:t.ARQUIVO}]},t))})),this._records=s}return l.buildLoadDataResponse(this._records,t,i)}saveLoader(t,i){return new Promise((e=>{const a=Array.isArray(t)?t[0]:{};i.save(a).then(e).catch((t=>t.message===v.DESCRIPTION_CANNOT_BE_CHANGED?(this._application.alert(this.getMessage("snkAttach.alertValidation.descriptionCannotBeChanged.title"),this.getMessage("snkAttach.alertValidation.descriptionCannotBeChanged.message")),e([])):t.message===v.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===v.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((a=>{t.getSelectionInfo().records.forEach((async t=>{this._application.hasAccess(p.REMOVE).then((async s=>{s&&(await e.delete(t),a(i))}))}))}))}getFilters(){throw new Error("Method not implemented.")}getInterceptions(t,i,e){return new Promise((a=>{var s,o,r,l,d,h;switch(i.type){case n.EDITION_CANCELED:return t.isDirty()?this._application.confirm(this.getMessage("snkAttach.cancelConfirmation.title"),this.getMessage("snkAttach.cancelConfirmation.message")).then((t=>t?(e.goToView(O.GRID),a(i)):a(void 0))):a(i);case n.DATA_SAVED:return t.loadData(void 0,void 0,!1,null===(r=null===(o=null===(s=null==i?void 0:i.payload)||void 0===s?void 0:s.records)||void 0===o?void 0:o[0])||void 0===r?void 0:r.REGISTER_KEY),a(i);case n.RECORDS_REMOVED:return t.loadData(void 0,void 0,!1,null===(h=null===(d=null===(l=null==i?void 0:i.payload)||void 0===l?void 0:l.cachedRecords)||void 0===d?void 0:d[0])||void 0===h?void 0:h.CODATA),a(i)}a(i)}))}}let L;const R=t=>{var i;if(!L){const t=a.getContextValue("__SNK__APPLICATION__");L=null==t?void 0:t.messagesBuilder}return null===(i=null==L?void 0:L.getMessage)||void 0===i?void 0:i.call(L,t,null)},T={DOWNLOAD:{hint:R("snkAttach.taskbar.titleDownload"),name:"DOWNLOAD",iconName:"file-download"},LINK:{hint:R("snkAttach.taskbar.titleLink"),name:"LINK",iconName:"launch"}},x=()=>{const t=[w.REMOVE,"DOWNLOAD","LINK"];return{getButtons:(t,i,e)=>{const a=e.indexOf(w.REFRESH);if((null==i?void 0:i.insertionMode)||(null==i?void 0:i.isDirty))return e.reverse();-1!==a&&e.splice(a,1);const{selectedRecord:s}=i||{},n=(null==s?void 0:s.LINK)?T.LINK:T.DOWNLOAD;e.splice(e.indexOf(w.DIVIDER)+1,0,w.REMOVE,n,w.DIVIDER);const o=[w.CLONE,w.DATA_EXPORTER],r=Array.from(new Set(e.filter((t=>!o.includes(t)))));return r.splice(r.indexOf(n)+1,0,w.DIVIDER),r},isEnabled:(i,e,a)=>{const s=void 0!==(null==e?void 0:e.selectedRecord);return!(t.includes(a)&&!s)}}},P={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"}]}},D=class{constructor(e){t(this,e),this.back=i(this,"back",7),this.handleTaskbarClick=async({detail:t})=>{if(["DOWNLOAD","LINK"].includes(t))return this.downloadAttachment(this._currentDataUnit.getSelectedRecord());"Attach"===this.fetcherType&&["SAVE"].includes(t)&&this._currentDataUnit.isDirty()&&await this._currentDataUnit.setFieldValue("REGISTER_KEY",this.registerKey)},this.handleBack=()=>{this._currentDataUnit.cancelEdition().then((t=>{t&&this.back.emit()}))},this.handleFinish=()=>{if(!this._currentDataUnit.isDirty())return this.back.emit();this.validateAnexoSistema()&&this._currentDataUnit.saveData().then((()=>{this.showFinishedToast(),this.back.emit()}))},this.gridLegacyConfigName=void 0,this.fetcherType=void 0,this.fetcher=void 0,this.dataUnit=void 0,this.dataUnitBuilder=void 0,this.registerKey=void 0,this.entityName=void 0,this.messagesBuilder=void 0,this._currentFetcher=void 0,this._currentDataUnit=void 0,this.crudConfig=void 0}async registerKeyWatcher(t,i){var e;null==this._currentDataUnit&&this.loadAttachmentDataUnit(),i!==t&&(this._currentFetcher instanceof y&&(this._currentFetcher.registerKey=t),await(null===(e=this._currentDataUnit)||void 0===e?void 0:e.loadData()))}getAnexoSistemaFetcherInstance(){var t;const i=new y(this.entityName,null===(t=this._currentDataUnit)||void 0===t?void 0:t.name);return i.registerKey=this.registerKey,i}async initAttach(){var t,i,e,a,s;if(this.fetcherType||this.registerKey){if(this.fetcherType||(this.fetcherType="AnexoSistema"),this.returnToGridMode(),"AnexoSistema"===this.fetcherType)return this._currentFetcher=this.getAnexoSistemaFetcherInstance(),null===(t=this._currentDataUnitBuilder)||void 0===t||t.initLoaders(this._currentDataUnit,this._currentFetcher,this.returnToGridMode.bind(this)),void await(null===(i=this._currentDataUnit)||void 0===i?void 0:i.loadData());if("Attach"===this.fetcherType&&(null===(e=this.registerKey)||void 0===e?void 0:e.split("_").length)>1)return;await(null===(a=this._currentDataUnit)||void 0===a?void 0:a.loadMetadata()),await(null===(s=this._currentDataUnit)||void 0===s?void 0:s.loadData(void 0,void 0,!0,this.registerKey))}}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(this.getMessage("snkAttach.alertValidation.noRecordSelected.message"));t.LINK?window.open(`${t.LINK}`):this._currentFetcher.getDownloadKey(t).then((({chave:i})=>{var e;let a=!1;(null===(e=null==t?void 0:t.ARQUIVO)||void 0===e?void 0:e.endsWith(".pdf"))||(a=!0),window.open(`/mge/visualizadorArquivos.mge?chaveArquivo=${i.valor}${a?"&forcarDownload=S":""}`)}))}returnToGridMode(){var t;null===(t=this._currentDataUnit)||void 0===t||t.clearSelection(),this._crudElement&&this._crudElement.goToView(O.GRID)}async loadAttachmentDataUnit(){try{switch(this.fetcherType){case"AnexoSistema":await this.loadAnexoSistema();break;case"Attach":await this.loadAttach();break;default:this._currentFetcher=this.fetcher,this._currentDataUnit=this.dataUnit,this._currentDataUnitBuilder=this.dataUnitBuilder}}catch(t){throw new Error("There was an error while creating the data unit")}}async loadAnexoSistema(){var t,i;let e;this._currentDataUnit=(new m).getDataUnit("AnexoSistema","br.com.sankhya.core.v3.anexoSistema"),this._currentFetcher=this.getAnexoSistemaFetcherInstance(),this._currentDataUnit.metadata||(await(null===(t=this._currentDataUnit)||void 0===t?void 0:t.loadMetadata()),this.crudConfig=this.entityName?{form:null==P?void 0:P.form}:Object.assign({},P),e={grid:null==P?void 0:P.grid}),this.initDataUnitLoaders(),this._currentDataUnit.addFilterProvider({getFilter:()=>this._currentDataUnitBuilder.getFilters(this.registerKey)}),this._currentDataUnit.addInterceptor({interceptAction:t=>this._currentDataUnitBuilder.getInterceptions(this._currentDataUnit,t,this._crudElement)}),await(null===(i=this._currentDataUnit)||void 0===i?void 0:i.loadData()),this.disableEditFieldsNotInForm(e)}async loadAttach(){var t,i;let e;this._currentFetcher=new k,this._currentDataUnit=new d(A.IN_MEMORY_DATA_UNIT_NAME),this._currentDataUnit.pageSize=150,this.initDataUnitLoaders(),this._currentDataUnit.addInterceptor({interceptAction:t=>{var i;return t.type===n.METADATA_LOADED&&(this.crudConfig=this.entityName?{form:null==N?void 0:N.form}:Object.assign({},N),e={grid:null==N?void 0:N.grid},null===(i=this._crudElement)||void 0===i||i.updateConfig()),this._currentDataUnitBuilder.getInterceptions(this._currentDataUnit,t,this._crudElement)}}),this._currentDataUnit.metadata||(await(null===(t=this._currentDataUnit)||void 0===t?void 0:t.loadMetadata()),this.crudConfig=this.entityName?{form:null==N?void 0:N.form}:Object.assign({},N),e={grid:null==N?void 0:N.grid},await(null===(i=this._currentDataUnit)||void 0===i?void 0:i.loadData(void 0,void 0,!0,this.registerKey)),this.disableEditFieldsNotInForm(e))}initDataUnitLoaders(){var t,i;"AnexoSistema"===this.fetcherType&&(this._currentFetcher=this.getAnexoSistemaFetcherInstance(),this._currentDataUnitBuilder=new b(this.entityName,this.getMessage.bind(this)),null===(t=this._currentDataUnitBuilder)||void 0===t||t.initLoaders(this._currentDataUnit,this._currentFetcher,this.returnToGridMode.bind(this))),"Attach"===this.fetcherType&&(this._currentFetcher=new k,this._currentDataUnitBuilder=new C(this.getMessage.bind(this)),null===(i=this._currentDataUnitBuilder)||void 0===i||i.initLoaders(this._currentDataUnit,this._currentFetcher,(async()=>{this.returnToGridMode(),await this._currentDataUnit.loadData(void 0,void 0,!0,this.registerKey)})))}disableEditFieldsNotInForm(t){var i,e,a,s,n;const o=(null===(e=null===(i=this._crudElement)||void 0===i?void 0:i.gridConfig)||void 0===e?void 0:e.columns)||(null===(a=null==t?void 0:t.grid)||void 0===a?void 0:a.columns)||(null===(n=null===(s=this.crudConfig)||void 0===s?void 0:s.grid)||void 0===n?void 0:n.columns);this.getGridLegacyConfigName()&&this._currentDataUnit.disableField("ARQUIVOOULINK"),null==o||o.forEach((t=>{var i,e;const a=t.name;(null===(e=null===(i=this.crudConfig)||void 0===i?void 0:i.form)||void 0===e?void 0:e.fields.some((t=>(null==t?void 0:t.name)===a)))||this._currentDataUnit.disableField(a)}))}validateAnexoSistema(){var t;if(this._currentFetcher instanceof y)try{let i=this._currentDataUnit.getSelectedRecord();i=Object.assign(Object.assign({},i),{NOMEARQUIVO:null===(t=i.NOMEARQUIVO)||void 0===t?void 0:t[0]}),this._currentFetcher.validateFields(i)}catch(t){if(t.message===v.LINK_AND_FILE_AT_THE_SAME_TIME)return this._application.alert(this.getMessage("snkAttach.alertValidation.fileAndLinkAtTheSameTime.title"),this.getMessage("snkAttach.alertValidation.fileAndLinkAtTheSameTime.message")),!1;if(t.message===v.ANY_LINK_OR_FILE_FILLED)return this._application.alert(this.getMessage("snkAttach.alertValidation.anyLinkOrFileFilled.title"),this.getMessage("snkAttach.alertValidation.anyLinkOrFileFilled.message")),!1}return!0}async componentWillLoad(){this._application=a.getContextValue("__SNK__APPLICATION__"),await this.initAttach()}componentWillRender(){this.fetcherType||(this.fetcherType="AnexoSistema"),null==this._currentDataUnit&&this.loadAttachmentDataUnit()}async handleOnDataStateChange({detail:t}){"Attach"===this.fetcherType&&(t.insertionMode?this._currentDataUnit.enableField("DESCRICAO"):this._currentDataUnit.disableField("DESCRICAO"),await this._currentDataUnit.loadMetadata())}getGridLegacyConfigName(){return this.gridLegacyConfigName?this.gridLegacyConfigName:this.entityName?"GrdCfgHtml5:grdcfg.dynaform.anexo."+this.entityName:this.entityName}render(){var t,i;return this._currentDataUnit?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._currentDataUnit,taskbarManager:x(),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,onDataStateChange:this.handleOnDataStateChange.bind(this),multipleSelection:!0,configName:this.entityName,ignoreReadOnlyFormFields:!!this.entityName,gridLegacyConfigName:this.getGridLegacyConfigName()},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 ez-padding-bottom--medium"},this.getMessage("snkAttach.description")))))))):null}static get watchers(){return{registerKey:["registerKeyWatcher"]}}};D.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{D as snk_attach}
@@ -1 +1 @@
1
- import{r as s,c as t,h as i,H as o,g as n}from"./p-d8d8169b.js";const e=class{constructor(i){s(this,i),this.snkCustomSlotGuideLoaded=t(this,"snkCustomSlotGuideLoaded",7),this.slotName="CUSTOM_SLOT_GUIDE"}onGuideChange(s){this._element.style.setProperty("display",s.detail===this.slotName?"block":"none")}onFormConfigVisibilityChange(s){s.detail&&this._element.style.setProperty("display","none")}componentDidLoad(){this.snkCustomSlotGuideLoaded.emit(this.slotName)}render(){return i(o,{slot:this.slotName,id:this.slotName,class:"custom-slot-guide-container"},i("slot",null))}get _element(){return n(this)}};e.style=".sc-snk-custom-slot-guide-h{display:none}";export{e as snk_custom_slot_guide}
1
+ import{r as s,c as t,h as i,H as o,g as n}from"./p-82bb3eda.js";const e=class{constructor(i){s(this,i),this.snkCustomSlotGuideLoaded=t(this,"snkCustomSlotGuideLoaded",7),this.slotName="CUSTOM_SLOT_GUIDE"}onGuideChange(s){this._element.style.setProperty("display",s.detail===this.slotName?"block":"none")}onFormConfigVisibilityChange(s){s.detail&&this._element.style.setProperty("display","none")}componentDidLoad(){this.snkCustomSlotGuideLoaded.emit(this.slotName)}render(){return i(o,{slot:this.slotName,id:this.slotName,class:"custom-slot-guide-container"},i("slot",null))}get _element(){return n(this)}};e.style=".sc-snk-custom-slot-guide-h{display:none}";export{e as snk_custom_slot_guide}
@@ -1 +1 @@
1
- import{r as t,h as s}from"./p-d8d8169b.js";import{ApplicationContext as e}from"@sankhyalabs/core";const i=class{constructor(s){t(this,s),this.APLICAR="OK",this.CANCELAR="CANCEL",this.FECHAR="CLOSE",this.titleMessage=void 0,this.message=void 0,this.accept=void 0,this.cancel=void 0}async openPopup(){this._ezPopup.opened=!0}exitPopup(){this._ezPopup.opened=!1}handleModalAction(t){switch(t){case this.APLICAR:this.exitPopup(),this.accept();break;case this.CANCELAR:this.exitPopup(),this.cancel();break;case this.FECHAR:this.exitPopup()}}componentWillLoad(){this._application=e.getContextValue("__SNK__APPLICATION__")}render(){return s("ez-popup",{size:"small",heightMode:"auto",useHeader:!1,ref:t=>this._ezPopup=t},s("ez-modal-container",{modalTitle:this.titleMessage,okButtonLabel:this._application.messagesBuilder.getMessage("snkActionsButton.buttons.yes",void 0),cancelButtonLabel:this._application.messagesBuilder.getMessage("snkActionsButton.buttons.no",void 0),onEzModalAction:t=>this.handleModalAction(t.detail)},s("div",{class:"ez-margin-bottom--large ez-flex ez-flex--column"},s("label",{class:"ez-text ez-text--large ez-text--primary",innerHTML:this.message}),s("label",{class:"ez-text ez-text--large ez-text--primary"},s("br",null),this._application.messagesBuilder.getMessage("snkActionsButton.clientEvent.cancelMessage",void 0)))))}};export{i as snk_client_confirm}
1
+ import{r as t,h as s}from"./p-82bb3eda.js";import{ApplicationContext as e}from"@sankhyalabs/core";const i=class{constructor(s){t(this,s),this.APLICAR="OK",this.CANCELAR="CANCEL",this.FECHAR="CLOSE",this.titleMessage=void 0,this.message=void 0,this.accept=void 0,this.cancel=void 0}async openPopup(){this._ezPopup.opened=!0}exitPopup(){this._ezPopup.opened=!1}handleModalAction(t){switch(t){case this.APLICAR:this.exitPopup(),this.accept();break;case this.CANCELAR:this.exitPopup(),this.cancel();break;case this.FECHAR:this.exitPopup()}}componentWillLoad(){this._application=e.getContextValue("__SNK__APPLICATION__")}render(){return s("ez-popup",{size:"small",heightMode:"auto",useHeader:!1,ref:t=>this._ezPopup=t},s("ez-modal-container",{modalTitle:this.titleMessage,okButtonLabel:this._application.messagesBuilder.getMessage("snkActionsButton.buttons.yes",void 0),cancelButtonLabel:this._application.messagesBuilder.getMessage("snkActionsButton.buttons.no",void 0),onEzModalAction:t=>this.handleModalAction(t.detail)},s("div",{class:"ez-margin-bottom--large ez-flex ez-flex--column"},s("label",{class:"ez-text ez-text--large ez-text--primary",innerHTML:this.message}),s("label",{class:"ez-text ez-text--large ez-text--primary"},s("br",null),this._application.messagesBuilder.getMessage("snkActionsButton.clientEvent.cancelMessage",void 0)))))}};export{i as snk_client_confirm}
@@ -1 +1 @@
1
- import{r as a,h as e}from"./p-d8d8169b.js";import{DataUnit as r,DataType as o,UserInterface as i}from"@sankhyalabs/core";const s=class{constructor(e){a(this,e)}componentWillLoad(){this.dataUnit=new r("testes_com_formulario"),this.dataUnit.metadata={name:"dd://br.com.sankhya.fin.cad.movimentacaoFinanceira/Financeiro",label:"Parceiro",fields:[{name:"CODPARC",label:"Parceiro",dataType:o.NUMBER,userInterface:i.SEARCH,required:!0,properties:{ENTITYNAME:"Parceiro"}}]}}render(){return e("snk-application",null,e("ez-form",{dataUnit:this.dataUnit}))}};s.style=":host{display:block}";export{s as teste_pesquisa}
1
+ import{r as a,h as e}from"./p-82bb3eda.js";import{DataUnit as r,DataType as o,UserInterface as i}from"@sankhyalabs/core";const s=class{constructor(e){a(this,e)}componentWillLoad(){this.dataUnit=new r("testes_com_formulario"),this.dataUnit.metadata={name:"dd://br.com.sankhya.fin.cad.movimentacaoFinanceira/Financeiro",label:"Parceiro",fields:[{name:"CODPARC",label:"Parceiro",dataType:o.NUMBER,userInterface:i.SEARCH,required:!0,properties:{ENTITYNAME:"Parceiro"}}]}}render(){return e("snk-application",null,e("ez-form",{dataUnit:this.dataUnit}))}};s.style=":host{display:block}";export{s as teste_pesquisa}
@@ -1,6 +1,6 @@
1
- import{UserInterface as e,DataType as t,ApplicationContext as n,ErrorException as i}from"@sankhyalabs/core";import{d as o,D as r}from"./p-1b1373b6.js";function a(e){const t=(n=e.fieldsMetadata)&&n.length?n.map((e=>({name:e.fieldName,label:e.description,dataType:u(e.type),userInterface:l(e),properties:s(e)}))):[];var n;return{label:e.entityDescription,name:e.descriptionField,fields:t}}function s(e){const t={};return t.options=function(e){const t=e.options;if(!t)return;const n=[];return Object.keys(t).forEach((e=>{n.push({label:e,value:t[e]})})),n}(e),t.mask=function(e){const t=e.uiType;return t?String(t).toLowerCase():void 0}(e),t}function l(t){const n=t.options;return n&&Object.keys(n).length>0?e.OPTIONSELECTOR:"D"===t.type?e.DATE:"H"===t.type?e.DATETIME:"T"===t.type?e.TIME:"I"===t.type?e.INTEGERNUMBER:void 0}function u(e){switch(e){case"F":case"I":return t.NUMBER;case"D":case"H":return t.DATE;case"B":return t.OBJECT;default:return t.TEXT}}function c(e){return Object.assign({id:e.codigo,label:`${e.caminho} - ${e.descricao}`,bold:"N"===e.analitico,props:{analitico:"S"===e.analitico}},e.no&&{children:e.no.map(c)})}var d,v,f;!function(e){e[e.GRID=0]="GRID",e[e.CARDS=1]="CARDS",e[e.TREE=2]="TREE"}(d||(d={}));class m{constructor(){this._defaultPageSize=100,this._templateByQuery=new Map,this._searchListenersByDataUnit=new Map,this.buldTemplates()}buldTemplates(){this._templateByQuery.set("search",o.gql`query($entityName: String! $argument: String $criteria: InputSearchCriteria $options: InputSearchOptions) {
1
+ import{UserInterface as e,DataType as t,ApplicationContext as n,ErrorException as i}from"@sankhyalabs/core";import{d as o,D as r}from"./p-6768f176.js";function a(e){const t=(n=e.fieldsMetadata)&&n.length?n.map((e=>({name:e.fieldName,label:e.description,dataType:u(e.type),userInterface:l(e),properties:s(e)}))):[];var n;return{label:e.entityDescription,name:e.descriptionField,fields:t}}function s(e){const t={};return t.options=function(e){const t=e.options;if(!t)return;const n=[];return Object.keys(t).forEach((e=>{n.push({label:e,value:t[e]})})),n}(e),t.mask=function(e){const t=e.uiType;return t?String(t).toLowerCase():void 0}(e),t}function l(t){const n=t.options;return n&&Object.keys(n).length>0?e.OPTIONSELECTOR:"D"===t.type?e.DATE:"H"===t.type?e.DATETIME:"T"===t.type?e.TIME:"I"===t.type?e.INTEGERNUMBER:void 0}function u(e){switch(e){case"F":case"I":return t.NUMBER;case"D":case"H":return t.DATE;case"B":return t.OBJECT;default:return t.TEXT}}function c(e){return Object.assign({id:e.codigo,label:`${e.caminho} - ${e.descricao}`,bold:"N"===e.analitico,props:{analitico:"S"===e.analitico}},e.no&&{children:e.no.map(c)})}var d,v,f;!function(e){e[e.GRID=0]="GRID",e[e.CARDS=1]="CARDS",e[e.TREE=2]="TREE"}(d||(d={}));class m{constructor(){this._defaultPageSize=100,this._templateByQuery=new Map,this._searchListenersByDataUnit=new Map,this.buldTemplates()}buldTemplates(){this._templateByQuery.set("search",o.gql`query($entityName: String! $argument: String $criteria: InputSearchCriteria $options: InputSearchOptions) {
2
2
  $queryAlias$: search(entityName: $entityName argument: $argument criteria: $criteria options: $options){
3
3
  value
4
4
  label
5
5
  }
6
- }`)}loadSearchOptions(e,n,i,o){var a;const s=(null==n?void 0:n.toString().trim())||void 0;n=isNaN(Number(s))&&s?`%${s}`:s,null==i||i.params.forEach((e=>{e.dataType===t.OBJECT&&(e.value=JSON.stringify(e.value))}));const l=this.applySearchListener(v.beforeSearch,e,n,i,o),u={argument:(null==l?void 0:l.argument)||n,entityName:e,criteria:(null==l?void 0:l.criteria)||i,options:(null==l?void 0:l.searchOptions)||o};return u.options&&(null===(a=u.options)||void 0===a||delete a.dataUnitId),new Promise(((e,t)=>{r.get().callGraphQL({values:u,query:this._templateByQuery.get("search")}).then((t=>{e(t)})).catch((e=>{t(e)}))}))}buildDescriptionCacheKey(e,t){return`${e}__${t}`}async loadByCode(e,t,n,i){const o=this.buildDescriptionCacheKey(e,t),r=m.DESCRIPTIONS_BY_CODE[o];if(r)return Promise.resolve(r);const a=await this.loadAdvancedSearch(e,void 0,n,i,t);return m.DESCRIPTIONS_BY_CODE[o]=a,a}loadAdvancedSearch(e,o,a,s,l){var u,c,d,f,m,p;const h=this.applySearchListener(v.beforeSearch,e,o,a,s),N={argument:(null==h?void 0:h.argument)||o,criteria:(null==h?void 0:h.criteria)||a,searchOptions:Object.assign(Object.assign({},s),null==h?void 0:h.searchOptions)},S={query:{$:null===(u=N.criteria)||void 0===u?void 0:u.expression}};(null===(d=null===(c=N.criteria)||void 0===c?void 0:c.params)||void 0===d?void 0:d.length)>0&&(S.params={param:N.criteria.params.map((e=>{let o=e.value;if("string"==typeof o){const e=/CTX\{([^}]+)\}/.exec(o);e&&(o=n.getContextValue(`__SNK__APPLICATION__FILTER__CONTEXT(${e[1]})__`))}if(e.dataType===t.NUMBER&&void 0===o)throw new i("Falha detectada",`O campo ${e.name} deve ser informado.`);let r=e.dataType;return r===t.OBJECT?(o=o.value,r="S"):r=g(e.dataType),{$:o,type:r}}))});const y=null!=s?Object.assign(Object.assign({},null==N?void 0:N.searchOptions),{pkFieldName:s.codeFieldName,label:s.descriptionFieldName,fieldName:s.codeFieldName,useDescriptionOptions:!1,enableRowsCounter:!0,limit:s.limit}):void 0,O={serviceName:"PesquisaSP.getSuggestion",requestBody:{criteria:Object.assign({entityName:e,compacted:!1,ignoreEntityCriteria:null!==(f=null==y?void 0:y.ignoreEntityCriteria)&&void 0!==f&&f,limit:null!==(m=null==y?void 0:y.limit)&&void 0!==m?m:this._defaultPageSize,orderByDesc:!1,externalCriteria:S,localEntityName:null===(p=N.searchOptions)||void 0===p?void 0:p.rootEntity},{options:y}),clientEventList:{clientEvent:[]}}};null==l?O.requestBody.criteria.query={$:o}:O.requestBody.criteria.pk={$:l};const b={urlParams:{quietMode:!0}};return new Promise(((e,t)=>{r.get().callServiceBroker("PesquisaSP.getSuggestion",JSON.stringify(O),b).then((t=>e(t))).catch((e=>t(e)))}))}addSearchListener(e,t,n){var i;const o=this._searchListenersByDataUnit.get(t)||[],r=o.find((t=>t.entity===e));if(r){for(const e of Object.keys(n))if(e in r.listener){if((null===(i=r.listener[e])||void 0===i?void 0:i.toString())===n[e].toString())continue;r.listener[e]=n[e]}}else this._searchListenersByDataUnit.set(t,[...o,{entity:e,listener:n}]);return()=>{const n=o.filter((t=>t.entity!==e));n.length?this._searchListenersByDataUnit.set(t,n):this._searchListenersByDataUnit.delete(t)}}applySearchListener(e,t,n,i,o){var r;const a=null==o?void 0:o.dataUnitId;if(!a)return;const s=null===(r=this._searchListenersByDataUnit.get(a))||void 0===r?void 0:r.find((({entity:e})=>e===t));if(!s)return;const{listener:l}=s;return e in l?l[e]({argument:n,criteria:i,searchOptions:o}):void 0}async loadPresentationConfig(e){var t,n;let i=function(e){return{config:{chave:`PesquisaContent:${e}`,tipo:"T"}}}(e);const o=await r.get().callServiceBroker("SystemUtilsSP.getConf",JSON.stringify(i));return null!==(n=null===(t=null==o?void 0:o.config)||void 0===t?void 0:t.lastUsedMode)&&void 0!==n?n:"list"}async savePresentationConfig(e,t){let n=function(e,t){return{config:{lastUsedMode:t,chave:`PesquisaContent:${e}`,tipo:"T"}}}(e,t);await r.get().callServiceBroker("SystemUtilsSP.saveConf",JSON.stringify(n))}async loadPesquisaGridConfig(e){const t=function(e){return{gridConfig:{configName:`GrdCfgHtml5:grdcfg.dynaform.pesquisa.${e}`}}}(e);return function(e){var t,n;const i=[],o=null!==(n=null===(t=null==e?void 0:e.gridConfig)||void 0===t?void 0:t.field)&&void 0!==n?n:{};if(Object.keys(o).forEach((e=>i.push(o[e]))),i.length)return{columns:i}}(await r.get().callServiceBroker("GridConfig.getGridConfigFromJson",JSON.stringify(t)))}async savePesquisaGridConfig(e,t){const n=function(e,t){const n={};return null==t||t.forEach(((e,t)=>n[`field${t}`]=e)),{gridConfig:{compactMode:!0,configName:`GrdCfgHtml5:grdcfg.dynaform.pesquisa.${e}`,field:n}}}(e,t);await r.get().callServiceBroker("GridConfig.saveGridConfigFromJSON",JSON.stringify(n))}async loadTree(e,t,n,i){const o=this.buildLoadTreeRequestBody(e,t,n,i);return(null!==(s=null===(a=(await r.get().callServiceBroker("Pesquisa.getStructuredData",JSON.stringify(o))).arvore)||void 0===a?void 0:a.no)&&void 0!==s?s:[]).map(c);var a,s}buildLoadTreeRequestBody(e,t,n,i){var o,r;const a=this.applySearchListener(v.beforeSearch,e,t,n,i),s=null!==(o=null==a?void 0:a.searchOptions)&&void 0!==o?o:i,l=null==s?void 0:s.rootEntity,u=null==s?void 0:s.codeFieldName,c=null===(r=null==a?void 0:a.criteria)||void 0===r?void 0:r.expression,d=this.buildParams(a),f={nome:e,nomeInstanciaLocal:l,codeFieldName:u};return c&&(f.criterioLiteral={expressao:{$:c},parametro:d}),{instancia:f}}buildParams(e){var t,n;let i=null!==(n=null===(t=null==e?void 0:e.criteria)||void 0===t?void 0:t.params)&&void 0!==n?n:[];return i=i.map((e=>Object.assign(Object.assign({},e),{tipo:g(e.dataType),$:e.value}))),i}}function g(e){switch(e){case t.NUMBER:return"I";case t.DATE:return"D";default:return"S"}}m.DESCRIPTIONS_BY_CODE={},function(e){e.beforeSearch="beforeSearch"}(v||(v={})),function(e){e.LINK_AND_FILE_AT_THE_SAME_TIME="LINK_AND_FILE_AT_THE_SAME_TIME",e.ANY_LINK_OR_FILE_FILLED="ANY_LINK_OR_FILE_FILLED",e.UNKNOWN="UNKNOWN",e.DESCRIPTION_CANNOT_BE_CHANGED="DESCRIPTION_CANNOT_BE_CHANGED"}(f||(f={}));export{m as P,f as S,d as a,a as b}
6
+ }`)}loadSearchOptions(e,n,i,o){var a;const s=(null==n?void 0:n.toString().trim())||void 0;n=isNaN(Number(s))&&s?`%${s}`:s,null==i||i.params.forEach((e=>{e.dataType===t.OBJECT&&(e.value=JSON.stringify(e.value))}));const l=this.applySearchListener(v.beforeSearch,e,n,i,o),u={argument:(null==l?void 0:l.argument)||n,entityName:e,criteria:(null==l?void 0:l.criteria)||i,options:(null==l?void 0:l.searchOptions)||o};return u.options&&(null===(a=u.options)||void 0===a||delete a.dataUnitId),new Promise(((e,t)=>{r.get().callGraphQL({values:u,query:this._templateByQuery.get("search")}).then((t=>{e(t)})).catch((e=>{t(e)}))}))}buildDescriptionCacheKey(e,t){return`${e}__${t}`}async loadByCode(e,t,n,i){const o=this.buildDescriptionCacheKey(e,t),r=m.DESCRIPTIONS_BY_CODE[o];if(r)return Promise.resolve(r);const a=await this.loadAdvancedSearch(e,void 0,n,i,t);return m.DESCRIPTIONS_BY_CODE[o]=a,a}loadAdvancedSearch(e,o,a,s,l){var u,c,d,f,m,p;const h=this.applySearchListener(v.beforeSearch,e,o,a,s),N={argument:(null==h?void 0:h.argument)||o,criteria:(null==h?void 0:h.criteria)||a,searchOptions:Object.assign(Object.assign({},s),null==h?void 0:h.searchOptions)},S={query:{$:null===(u=N.criteria)||void 0===u?void 0:u.expression}};(null===(d=null===(c=N.criteria)||void 0===c?void 0:c.params)||void 0===d?void 0:d.length)>0&&(S.params={param:N.criteria.params.map((e=>{let o=e.value;if("string"==typeof o){const e=/CTX\{([^}]+)\}/.exec(o);e&&(o=n.getContextValue(`__SNK__APPLICATION__FILTER__CONTEXT(${e[1]})__`))}if(e.dataType===t.NUMBER&&void 0===o)throw new i("Falha detectada",`O campo ${e.name} deve ser informado.`);let r=e.dataType;return r===t.OBJECT?(o=o.value,r="S"):r=g(e.dataType),{$:o,type:r}}))});const y=null!=s?Object.assign(Object.assign({},null==N?void 0:N.searchOptions),{pkFieldName:s.codeFieldName,label:s.descriptionFieldName,fieldName:s.codeFieldName,useDescriptionOptions:!1,enableRowsCounter:!0,limit:s.limit}):void 0,O={serviceName:"PesquisaSP.getSuggestion",requestBody:{criteria:Object.assign({entityName:e,compacted:!1,ignoreEntityCriteria:null!==(f=null==y?void 0:y.ignoreEntityCriteria)&&void 0!==f&&f,limit:null!==(m=null==y?void 0:y.limit)&&void 0!==m?m:this._defaultPageSize,orderByDesc:!1,externalCriteria:S,localEntityName:null===(p=N.searchOptions)||void 0===p?void 0:p.rootEntity},{options:y}),clientEventList:{clientEvent:[]}}};null==l?O.requestBody.criteria.query={$:o}:O.requestBody.criteria.pk={$:l};const C={urlParams:{quietMode:!0}};return new Promise(((e,t)=>{r.get().callServiceBroker("PesquisaSP.getSuggestion",JSON.stringify(O),C).then((t=>e(t))).catch((e=>t(e)))}))}addSearchListener(e,t,n){var i;const o=this._searchListenersByDataUnit.get(t)||[],r=o.find((t=>t.entity===e));if(r){for(const e of Object.keys(n))if(e in r.listener){if((null===(i=r.listener[e])||void 0===i?void 0:i.toString())===n[e].toString())continue;r.listener[e]=n[e]}}else this._searchListenersByDataUnit.set(t,[...o,{entity:e,listener:n}]);return()=>{const n=o.filter((t=>t.entity!==e));n.length?this._searchListenersByDataUnit.set(t,n):this._searchListenersByDataUnit.delete(t)}}applySearchListener(e,t,n,i,o){var r;const a=null==o?void 0:o.dataUnitId;if(!a)return;const s=null===(r=this._searchListenersByDataUnit.get(a))||void 0===r?void 0:r.find((({entity:e})=>e===t));if(!s)return;const{listener:l}=s;return e in l?l[e]({argument:n,criteria:i,searchOptions:o}):void 0}async loadPresentationConfig(e){var t,n;let i=function(e){return{config:{chave:`PesquisaContent:${e}`,tipo:"T"}}}(e);const o=await r.get().callServiceBroker("SystemUtilsSP.getConf",JSON.stringify(i));return null!==(n=null===(t=null==o?void 0:o.config)||void 0===t?void 0:t.lastUsedMode)&&void 0!==n?n:"list"}async savePresentationConfig(e,t){let n=function(e,t){return{config:{lastUsedMode:t,chave:`PesquisaContent:${e}`,tipo:"T"}}}(e,t);await r.get().callServiceBroker("SystemUtilsSP.saveConf",JSON.stringify(n))}async loadPesquisaGridConfig(e){const t=function(e){return{gridConfig:{configName:`GrdCfgHtml5:grdcfg.dynaform.pesquisa.${e}`}}}(e);return function(e){var t,n;const i=[],o=null!==(n=null===(t=null==e?void 0:e.gridConfig)||void 0===t?void 0:t.field)&&void 0!==n?n:{};if(Object.keys(o).forEach((e=>i.push(o[e]))),i.length)return{columns:i}}(await r.get().callServiceBroker("GridConfig.getGridConfigFromJson",JSON.stringify(t)))}async savePesquisaGridConfig(e,t){const n=function(e,t){const n={};return null==t||t.forEach(((e,t)=>n[`field${t}`]=e)),{gridConfig:{compactMode:!0,configName:`GrdCfgHtml5:grdcfg.dynaform.pesquisa.${e}`,field:n}}}(e,t);await r.get().callServiceBroker("GridConfig.saveGridConfigFromJSON",JSON.stringify(n))}async loadTree(e,t,n,i){const o=this.buildLoadTreeRequestBody(e,t,n,i);return(null!==(s=null===(a=(await r.get().callServiceBroker("Pesquisa.getStructuredData",JSON.stringify(o))).arvore)||void 0===a?void 0:a.no)&&void 0!==s?s:[]).map(c);var a,s}buildLoadTreeRequestBody(e,t,n,i){var o,r;const a=this.applySearchListener(v.beforeSearch,e,t,n,i),s=null!==(o=null==a?void 0:a.searchOptions)&&void 0!==o?o:i,l=null==s?void 0:s.rootEntity,u=null==s?void 0:s.codeFieldName,c=null===(r=null==a?void 0:a.criteria)||void 0===r?void 0:r.expression,d=this.buildParams(a),f={nome:e,nomeInstanciaLocal:l,codeFieldName:u};return c&&(f.criterioLiteral={expressao:{$:c},parametro:d}),{instancia:f}}buildParams(e){var t,n;let i=null!==(n=null===(t=null==e?void 0:e.criteria)||void 0===t?void 0:t.params)&&void 0!==n?n:[];return i=i.map((e=>Object.assign(Object.assign({},e),{tipo:g(e.dataType),$:e.value}))),i}}function g(e){switch(e){case t.NUMBER:return"I";case t.DATE:return"D";default:return"S"}}m.DESCRIPTIONS_BY_CODE={},function(e){e.beforeSearch="beforeSearch"}(v||(v={})),function(e){e.LINK_AND_FILE_AT_THE_SAME_TIME="LINK_AND_FILE_AT_THE_SAME_TIME",e.ANY_LINK_OR_FILE_FILLED="ANY_LINK_OR_FILE_FILLED",e.UNKNOWN="UNKNOWN",e.DESCRIPTION_CANNOT_BE_CHANGED="DESCRIPTION_CANNOT_BE_CHANGED"}(f||(f={}));export{m as P,f as S,d as a,a as b}
@@ -1 +1 @@
1
- import{r as t,h as e,H as i,g as s}from"./p-d8d8169b.js";import{P as r}from"./p-8d884fab.js";import{ApplicationUtils as h}from"@sankhyalabs/ezui/dist/collection/utils";import{ElementIDUtils as l,ApplicationContext as n}from"@sankhyalabs/core";import a from"@sankhyalabs/ezui/dist/collection/components/ez-modal-container/modal-button-status";const o=class{constructor(e){t(this,e),this.APPLY="OK",this.CANCEL="CANCEL",this.CLOSE="CLOSE",this.REMOTE_PRINTERS_TAB="0",this.LOCAL_PRINTERS_TAB="1",this._hasRemotePrinters=!1,this._hasLocalPrinters=!1,this._localPrinters=[],this._isSingleJob=!1,this._saveSubstitute=!1,this.buildIdTabSelector=()=>{const t=[{label:this.getMessage("snkPrintSelector.title.localPrintersTab"),tabKey:this.LOCAL_PRINTERS_TAB,index:Number(this.LOCAL_PRINTERS_TAB)}];return this._printServerActive&&t.unshift({label:this.getMessage("snkPrintSelector.title.remotePrintersTab"),tabKey:this.REMOTE_PRINTERS_TAB,index:Number(this.REMOTE_PRINTERS_TAB)}),[...t]},this._printServerActive=!1,this._selectedPrinter=void 0,this._remotePrintersDataSource=[],this._localPrintersDataSource=[],this._printJobData=void 0}async openPrintSelector(t){return new Promise((e=>{this._printJobData=t,this._isSingleJob=1===this._printJobData.pendingPrinters.length,this._printServerActive=this._printJobData.printServerActive,this._printServerActive?this.buildRemotePrinters():(this.buildLocalPrinters(),this._viewStack.show(+this.LOCAL_PRINTERS_TAB)),this._ezPopup.opened=!0,this._printerResolver=e}))}closePrintSelector(){this._ezPopup.opened=!1,this.element.remove()}handleModalAction(t){switch(t){case this.APPLY:this.handleApply();break;case this.CANCEL:case this.CLOSE:this.handleCancel()}}async handleCancel(){await h.confirm(this.getMessage("snkPrintSelector.title.warning"),this.getMessage("snkPrintSelector.message.canceledPrint"))&&(this.closePrintSelector(),this._printerResolver({selectedPrinter:void 0,saveSubstitute:!1}))}handleApply(){this._printerResolver({selectedPrinter:this._selectedPrinter,saveSubstitute:this._saveSubstitute}),this.closePrintSelector()}onChangeTab(t){t.detail.tabKey===this.LOCAL_PRINTERS_TAB&&this.buildLocalPrinters(),this._viewStack.show(+t.detail.tabKey)}buildRemotePrinters(){const t=[];this._printJobData.printServers.forEach((e=>{t.push({group:e.printServerUri,items:e.printerList.map((t=>({label:t.printerName,group:e.printServerUri})))})})),this._remotePrintersDataSource=t,this._hasRemotePrinters=this._remotePrintersDataSource.length>0}buildLocalPrinters(){this._localPrintersDataSource.length>0||(this._localPrinters=r.getInstance().getLocalPrinters(),this._localPrintersDataSource=this._localPrinters.map((t=>({label:t.nome}))),this._hasLocalPrinters=this._localPrintersDataSource.length>0)}onSelectPrinter(t,e){if(e)return this._hasRemotePrinters&&this._remotePrintersList.removeSelection(),void(this._selectedPrinter=this._localPrinters.find((e=>e.nome===t.label)));this._hasLocalPrinters&&this._localPrintersList.removeSelection();const i=this._printJobData.printServers.find((e=>e.printServerUri===t.group));this._selectedPrinter=null==i?void 0:i.printerList.find((e=>e.printerName===t.label))}renderNoPrinters(){return e("div",{class:"ez-flex ez-flex--justify-center ez-flex--align-items-center ez-size-height--full ez-size-width--full"},e("span",{class:"ez-text ez-text--primary ez-text--medium"},this.getMessage("snkPrintSelector.message.noPrinters")))}buildPrinterIcon(){return e("ez-icon",{iconName:"print",style:{marginRight:"var(--space--small)"}})}getElementID(t){return{[l.DATA_ELEMENT_ID_ATTRIBUTE_NAME]:l.getInternalIDInfo(t)}}getMessage(t){return this._application.messagesBuilder.getMessage(t,void 0)}componentWillLoad(){this._application=n.getContextValue("__SNK__APPLICATION__")}componentDidLoad(){this.element&&l.addIDInfo(this.element)}render(){return e(i,null,e("ez-popup",Object.assign({size:"small",heightMode:"full",useHeader:!1,ref:t=>this._ezPopup=t},this.getElementID("snk-print-selector")),e("ez-modal-container",{modalTitle:this.getMessage("snkPrintSelector.title.printerSelection"),okButtonLabel:this.getMessage("snkPrintSelector.button.print"),okButtonStatus:this._selectedPrinter?a.ENABLED:a.DISABLED,cancelButtonLabel:this.getMessage("snkPrintSelector.button.cancel"),onEzModalAction:t=>this.handleModalAction(t.detail)},this._isSingleJob&&e("div",{class:"ez-flex ez-margin-bottom--large"},e("div",{class:"ez-flex ez-margin-right--large"},e("span",{class:"ez-text ez-text--bold ez-text--medium ez-padding-right--small"},this.getMessage("snkPrintSelector.subtitle.document")),e("span",{class:"ez-text ez-text--primary ez-text--medium"},this._printJobData.pendingPrinters[0].docTypeDescription)),e("div",{class:"ez-flex ez-margin-right--large"},e("span",{class:"ez-text ez-text--bold ez-text--medium ez-padding-right--small"},this.getMessage("snkPrintSelector.subtitle.jobs")),e("span",{class:"ez-text ez-text--primary ez-text--medium"},this._printJobData.pendingPrinters[0].printJobCount))),e("ez-tabselector",{tabs:this.buildIdTabSelector(),onEzChange:t=>this.onChangeTab(t),selectedTab:this._printServerActive?this.REMOTE_PRINTERS_TAB:this.LOCAL_PRINTERS_TAB}),e("ez-view-stack",{ref:t=>this._viewStack=t},e("stack-item",{hidePolicy:"hide"},this._printServerActive&&e("div",{class:"list-scroll ez-size-height--full "+(this._isSingleJob?"with-header":"without-header")},e("ez-list",{ref:t=>this._remotePrintersList=t,class:"ez-padding-top--medium "+(this._hasRemotePrinters?"":"hidden"),dataSource:this._remotePrintersDataSource,onEzSelectItem:t=>this.onSelectPrinter(t.detail,!1),itemLeftSlotBuilder:this.buildPrinterIcon,useGroups:!0,ezSelectable:!0,hoverFeedback:!0,"data-element-id":"remotePrintersList"}),!this._hasRemotePrinters&&this.renderNoPrinters())),e("stack-item",{hidePolicy:"hide"},e("div",{class:"list-scroll ez-size-height--full "+(this._isSingleJob?"with-header":"without-header")},e("ez-list",{ref:t=>this._localPrintersList=t,class:"ez-padding-top--medium "+(this._hasLocalPrinters?"":"hidden"),dataSource:this._localPrintersDataSource,onEzSelectItem:t=>this.onSelectPrinter(t.detail,!0),itemLeftSlotBuilder:this.buildPrinterIcon,ezSelectable:!0,hoverFeedback:!0}),!this._hasLocalPrinters&&this.renderNoPrinters()))),e("ez-check",{label:this.getMessage("snkPrintSelector.message.savePrinter"),onEzChange:t=>this._saveSubstitute=t.detail}))))}get element(){return s(this)}};o.style=".sc-snk-print-selector-h{max-height:100%}ez-modal-container.sc-snk-print-selector{--ez-modal-container-overflow-y:hidden}ez-list.sc-snk-print-selector{height:100%}.list-scroll.sc-snk-print-selector{height:100%;overflow-y:auto;padding-right:var(--snk-grid-config__main--padding-right)}.with-header.sc-snk-print-selector{max-height:calc(100% - 125px)}.without-header.sc-snk-print-selector{max-height:calc(100% - 85px)}.list-scroll.sc-snk-print-selector::-webkit-scrollbar{width:var(--space--small);min-width:var(--space--small);max-width:var(--space--small)}.hidden.sc-snk-print-selector{display:none}";export{o as snk_print_selector}
1
+ import{r as t,h as e,H as i,g as s}from"./p-82bb3eda.js";import{P as r}from"./p-8d884fab.js";import{ApplicationUtils as h}from"@sankhyalabs/ezui/dist/collection/utils";import{ElementIDUtils as l,ApplicationContext as n}from"@sankhyalabs/core";import a from"@sankhyalabs/ezui/dist/collection/components/ez-modal-container/modal-button-status";const o=class{constructor(e){t(this,e),this.APPLY="OK",this.CANCEL="CANCEL",this.CLOSE="CLOSE",this.REMOTE_PRINTERS_TAB="0",this.LOCAL_PRINTERS_TAB="1",this._hasRemotePrinters=!1,this._hasLocalPrinters=!1,this._localPrinters=[],this._isSingleJob=!1,this._saveSubstitute=!1,this.buildIdTabSelector=()=>{const t=[{label:this.getMessage("snkPrintSelector.title.localPrintersTab"),tabKey:this.LOCAL_PRINTERS_TAB,index:Number(this.LOCAL_PRINTERS_TAB)}];return this._printServerActive&&t.unshift({label:this.getMessage("snkPrintSelector.title.remotePrintersTab"),tabKey:this.REMOTE_PRINTERS_TAB,index:Number(this.REMOTE_PRINTERS_TAB)}),[...t]},this._printServerActive=!1,this._selectedPrinter=void 0,this._remotePrintersDataSource=[],this._localPrintersDataSource=[],this._printJobData=void 0}async openPrintSelector(t){return new Promise((e=>{this._printJobData=t,this._isSingleJob=1===this._printJobData.pendingPrinters.length,this._printServerActive=this._printJobData.printServerActive,this._printServerActive?this.buildRemotePrinters():(this.buildLocalPrinters(),this._viewStack.show(+this.LOCAL_PRINTERS_TAB)),this._ezPopup.opened=!0,this._printerResolver=e}))}closePrintSelector(){this._ezPopup.opened=!1,this.element.remove()}handleModalAction(t){switch(t){case this.APPLY:this.handleApply();break;case this.CANCEL:case this.CLOSE:this.handleCancel()}}async handleCancel(){await h.confirm(this.getMessage("snkPrintSelector.title.warning"),this.getMessage("snkPrintSelector.message.canceledPrint"))&&(this.closePrintSelector(),this._printerResolver({selectedPrinter:void 0,saveSubstitute:!1}))}handleApply(){this._printerResolver({selectedPrinter:this._selectedPrinter,saveSubstitute:this._saveSubstitute}),this.closePrintSelector()}onChangeTab(t){t.detail.tabKey===this.LOCAL_PRINTERS_TAB&&this.buildLocalPrinters(),this._viewStack.show(+t.detail.tabKey)}buildRemotePrinters(){const t=[];this._printJobData.printServers.forEach((e=>{t.push({group:e.printServerUri,items:e.printerList.map((t=>({label:t.printerName,group:e.printServerUri})))})})),this._remotePrintersDataSource=t,this._hasRemotePrinters=this._remotePrintersDataSource.length>0}buildLocalPrinters(){this._localPrintersDataSource.length>0||(this._localPrinters=r.getInstance().getLocalPrinters(),this._localPrintersDataSource=this._localPrinters.map((t=>({label:t.nome}))),this._hasLocalPrinters=this._localPrintersDataSource.length>0)}onSelectPrinter(t,e){if(e)return this._hasRemotePrinters&&this._remotePrintersList.removeSelection(),void(this._selectedPrinter=this._localPrinters.find((e=>e.nome===t.label)));this._hasLocalPrinters&&this._localPrintersList.removeSelection();const i=this._printJobData.printServers.find((e=>e.printServerUri===t.group));this._selectedPrinter=null==i?void 0:i.printerList.find((e=>e.printerName===t.label))}renderNoPrinters(){return e("div",{class:"ez-flex ez-flex--justify-center ez-flex--align-items-center ez-size-height--full ez-size-width--full"},e("span",{class:"ez-text ez-text--primary ez-text--medium"},this.getMessage("snkPrintSelector.message.noPrinters")))}buildPrinterIcon(){return e("ez-icon",{iconName:"print",style:{marginRight:"var(--space--small)"}})}getElementID(t){return{[l.DATA_ELEMENT_ID_ATTRIBUTE_NAME]:l.getInternalIDInfo(t)}}getMessage(t){return this._application.messagesBuilder.getMessage(t,void 0)}componentWillLoad(){this._application=n.getContextValue("__SNK__APPLICATION__")}componentDidLoad(){this.element&&l.addIDInfo(this.element)}render(){return e(i,null,e("ez-popup",Object.assign({size:"small",heightMode:"full",useHeader:!1,ref:t=>this._ezPopup=t},this.getElementID("snk-print-selector")),e("ez-modal-container",{modalTitle:this.getMessage("snkPrintSelector.title.printerSelection"),okButtonLabel:this.getMessage("snkPrintSelector.button.print"),okButtonStatus:this._selectedPrinter?a.ENABLED:a.DISABLED,cancelButtonLabel:this.getMessage("snkPrintSelector.button.cancel"),onEzModalAction:t=>this.handleModalAction(t.detail)},this._isSingleJob&&e("div",{class:"ez-flex ez-margin-bottom--large"},e("div",{class:"ez-flex ez-margin-right--large"},e("span",{class:"ez-text ez-text--bold ez-text--medium ez-padding-right--small"},this.getMessage("snkPrintSelector.subtitle.document")),e("span",{class:"ez-text ez-text--primary ez-text--medium"},this._printJobData.pendingPrinters[0].docTypeDescription)),e("div",{class:"ez-flex ez-margin-right--large"},e("span",{class:"ez-text ez-text--bold ez-text--medium ez-padding-right--small"},this.getMessage("snkPrintSelector.subtitle.jobs")),e("span",{class:"ez-text ez-text--primary ez-text--medium"},this._printJobData.pendingPrinters[0].printJobCount))),e("ez-tabselector",{tabs:this.buildIdTabSelector(),onEzChange:t=>this.onChangeTab(t),selectedTab:this._printServerActive?this.REMOTE_PRINTERS_TAB:this.LOCAL_PRINTERS_TAB}),e("ez-view-stack",{ref:t=>this._viewStack=t},e("stack-item",{hidePolicy:"hide"},this._printServerActive&&e("div",{class:"list-scroll ez-size-height--full "+(this._isSingleJob?"with-header":"without-header")},e("ez-list",{ref:t=>this._remotePrintersList=t,class:"ez-padding-top--medium "+(this._hasRemotePrinters?"":"hidden"),dataSource:this._remotePrintersDataSource,onEzSelectItem:t=>this.onSelectPrinter(t.detail,!1),itemLeftSlotBuilder:this.buildPrinterIcon,useGroups:!0,ezSelectable:!0,hoverFeedback:!0,"data-element-id":"remotePrintersList"}),!this._hasRemotePrinters&&this.renderNoPrinters())),e("stack-item",{hidePolicy:"hide"},e("div",{class:"list-scroll ez-size-height--full "+(this._isSingleJob?"with-header":"without-header")},e("ez-list",{ref:t=>this._localPrintersList=t,class:"ez-padding-top--medium "+(this._hasLocalPrinters?"":"hidden"),dataSource:this._localPrintersDataSource,onEzSelectItem:t=>this.onSelectPrinter(t.detail,!0),itemLeftSlotBuilder:this.buildPrinterIcon,ezSelectable:!0,hoverFeedback:!0}),!this._hasLocalPrinters&&this.renderNoPrinters()))),e("ez-check",{label:this.getMessage("snkPrintSelector.message.savePrinter"),onEzChange:t=>this._saveSubstitute=t.detail}))))}get element(){return s(this)}};o.style=".sc-snk-print-selector-h{max-height:100%}ez-modal-container.sc-snk-print-selector{--ez-modal-container-overflow-y:hidden}ez-list.sc-snk-print-selector{height:100%}.list-scroll.sc-snk-print-selector{height:100%;overflow-y:auto;padding-right:var(--snk-grid-config__main--padding-right)}.with-header.sc-snk-print-selector{max-height:calc(100% - 125px)}.without-header.sc-snk-print-selector{max-height:calc(100% - 85px)}.list-scroll.sc-snk-print-selector::-webkit-scrollbar{width:var(--space--small);min-width:var(--space--small);max-width:var(--space--small)}.hidden.sc-snk-print-selector{display:none}";export{o as snk_print_selector}