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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (157) hide show
  1. package/dist/cjs/{ISave-d68ce3cd.js → ISave-e91b70a7.js} +1 -0
  2. package/dist/cjs/{SnkMessageBuilder-7293d0ad.js → SnkMessageBuilder-e7dcf408.js} +13 -0
  3. package/dist/cjs/loader.cjs.js +1 -1
  4. package/dist/cjs/{dataunit-fetcher-353e4af2.js → pesquisa-fetcher-e4a7c4c3.js} +215 -26
  5. package/dist/cjs/sankhyablocks.cjs.js +1 -1
  6. package/dist/cjs/snk-actions-button_2.cjs.entry.js +5 -4
  7. package/dist/cjs/snk-application.cjs.entry.js +12 -4
  8. package/dist/cjs/snk-attach.cjs.entry.js +388 -57
  9. package/dist/cjs/snk-crud.cjs.entry.js +2 -3
  10. package/dist/cjs/snk-data-exporter.cjs.entry.js +3 -3
  11. package/dist/cjs/{snk-data-unit-1bc69073.js → snk-data-unit-82c08a8c.js} +1 -1
  12. package/dist/cjs/snk-data-unit.cjs.entry.js +2 -2
  13. package/dist/cjs/snk-detail-view.cjs.entry.js +4 -5
  14. package/dist/cjs/snk-filter-bar.cjs.entry.js +8 -1
  15. package/dist/cjs/snk-filter-item.cjs.entry.js +4 -47
  16. package/dist/cjs/snk-filter-modal.cjs.entry.js +2 -1
  17. package/dist/cjs/snk-filter-multi-select.cjs.entry.js +2 -1
  18. package/dist/cjs/{snk-guides-viewer-e60ccc5e.js → snk-guides-viewer-d32c096f.js} +2 -3
  19. package/dist/cjs/snk-guides-viewer.cjs.entry.js +3 -4
  20. package/dist/cjs/snk-pesquisa.cjs.entry.js +1 -1
  21. package/dist/cjs/snk-simple-crud.cjs.entry.js +17 -6
  22. package/dist/collection/components/snk-application/snk-application.js +52 -9
  23. package/dist/collection/components/snk-attach/snk-attach.js +188 -39
  24. package/dist/collection/components/snk-attach/structure/{crud-config-builder.js → builder/anexo-sistema-crud-config.builder.js} +1 -1
  25. package/dist/collection/components/snk-attach/structure/builder/attach-crud-config.builder.js +62 -0
  26. package/dist/collection/components/snk-attach/structure/{taskbar-builder.js → builder/taskbar-builder.js} +1 -1
  27. package/dist/collection/components/snk-attach/structure/fetcher/facade/fetcher.facade.js +1 -0
  28. package/dist/collection/components/snk-attach/structure/{data-unit-builder.js → fetcher/factory/anexo-sistema-data-unit.factory.js} +14 -11
  29. package/dist/collection/components/snk-attach/structure/fetcher/factory/attach-fetcher-data-unit.factory.js +111 -0
  30. package/dist/collection/components/snk-attach/structure/index.js +6 -3
  31. package/dist/collection/components/snk-data-exporter/snk-data-exporter.js +1 -1
  32. package/dist/collection/components/snk-filter-bar/filter-item/editors/snk-filter-multi-select.js +2 -1
  33. package/dist/collection/components/snk-filter-bar/filter-item/snk-filter-item.js +4 -47
  34. package/dist/collection/components/snk-filter-bar/filter-modal/snk-filter-modal.js +19 -1
  35. package/dist/collection/components/snk-filter-bar/snk-filter-bar.js +22 -0
  36. package/dist/collection/components/snk-filter-bar/utils/SnkFilterModalFactory.js +3 -1
  37. package/dist/collection/components/snk-pesquisa/snk-pesquisa.css +2 -4
  38. package/dist/collection/components/snk-simple-crud/snk-simple-crud.js +53 -1
  39. package/dist/collection/components/snk-taskbar/elements/taskbar-actions-button/taskbar-actions-button.js +3 -1
  40. package/dist/collection/lib/dataUnit/InMemoryLoader.js +1 -1
  41. package/dist/collection/lib/http/data-fetcher/fetchers/{attach-fetcher.js → AttachFetcher/anexo-sistema-fetcher.js} +16 -15
  42. package/dist/collection/lib/http/data-fetcher/fetchers/AttachFetcher/attach-fetcher.js +90 -0
  43. package/dist/collection/lib/http/data-fetcher/fetchers/AttachFetcher/facade/attach-fetcher.facade.js +1 -0
  44. package/dist/collection/lib/http/data-fetcher/fetchers/AttachFetcher/index.js +2 -0
  45. package/dist/collection/lib/http/data-fetcher/fetchers/AttachFetcher/interfaces/IDelete.js +1 -0
  46. package/dist/collection/lib/http/data-fetcher/fetchers/AttachFetcher/interfaces/IDownloadKey.js +1 -0
  47. package/dist/collection/lib/http/data-fetcher/fetchers/{fecthAttach → AttachFetcher}/interfaces/ISave.js +1 -0
  48. package/dist/collection/lib/http/data-fetcher/fetchers/data-unit/dataunit-fetcher.js +17 -3
  49. package/dist/collection/lib/http/data-fetcher/fetchers/data-unit/loadstrategy/DatasetStrategy.js +29 -22
  50. package/dist/collection/lib/http/data-fetcher/fetchers/pesquisa-fetcher.js +7 -1
  51. package/dist/collection/lib/index.js +1 -1
  52. package/dist/collection/lib/message/resources/snk-attach.msg.js +13 -0
  53. package/dist/components/SnkMessageBuilder.js +13 -0
  54. package/dist/components/dataunit-fetcher.js +54 -27
  55. package/dist/components/snk-actions-button2.js +1 -0
  56. package/dist/components/snk-application2.js +11 -1
  57. package/dist/components/snk-attach2.js +394 -57
  58. package/dist/components/snk-data-exporter2.js +1 -1
  59. package/dist/components/snk-filter-bar2.js +9 -1
  60. package/dist/components/snk-filter-item2.js +4 -47
  61. package/dist/components/snk-filter-modal.js +4 -2
  62. package/dist/components/snk-filter-multi-select.js +2 -1
  63. package/dist/components/snk-pesquisa2.js +1 -1
  64. package/dist/components/snk-simple-crud2.js +15 -1
  65. package/dist/components/taskbar-actions-button2.js +3 -1
  66. package/dist/esm/{ISave-4412b20c.js → ISave-d8c8bc59.js} +1 -0
  67. package/dist/esm/{SnkMessageBuilder-ca843d1b.js → SnkMessageBuilder-0fb796b9.js} +13 -0
  68. package/dist/esm/loader.js +1 -1
  69. package/dist/esm/{dataunit-fetcher-0fc935a0.js → pesquisa-fetcher-fa0c2540.js} +215 -27
  70. package/dist/esm/sankhyablocks.js +1 -1
  71. package/dist/esm/snk-actions-button_2.entry.js +5 -4
  72. package/dist/esm/snk-application.entry.js +11 -3
  73. package/dist/esm/snk-attach.entry.js +389 -58
  74. package/dist/esm/snk-crud.entry.js +2 -3
  75. package/dist/esm/snk-data-exporter.entry.js +3 -3
  76. package/dist/esm/{snk-data-unit-6208ebf0.js → snk-data-unit-5d201fb3.js} +1 -1
  77. package/dist/esm/snk-data-unit.entry.js +2 -2
  78. package/dist/esm/snk-detail-view.entry.js +4 -5
  79. package/dist/esm/snk-filter-bar.entry.js +8 -1
  80. package/dist/esm/snk-filter-item.entry.js +4 -47
  81. package/dist/esm/snk-filter-modal.entry.js +2 -1
  82. package/dist/esm/snk-filter-multi-select.entry.js +2 -1
  83. package/dist/esm/{snk-guides-viewer-98a8e45e.js → snk-guides-viewer-f49613c6.js} +2 -3
  84. package/dist/esm/snk-guides-viewer.entry.js +3 -4
  85. package/dist/esm/snk-pesquisa.entry.js +1 -1
  86. package/dist/esm/snk-simple-crud.entry.js +15 -4
  87. package/dist/sankhyablocks/p-02e3a45b.entry.js +1 -0
  88. package/dist/sankhyablocks/{p-ff6064e7.js → p-05243555.js} +1 -1
  89. package/dist/sankhyablocks/p-0ec5b2e5.js +1 -0
  90. package/dist/sankhyablocks/{p-9e7d65a4.js → p-21749402.js} +1 -1
  91. package/dist/sankhyablocks/p-2582537c.entry.js +1 -0
  92. package/dist/sankhyablocks/p-282789a6.entry.js +1 -0
  93. package/dist/sankhyablocks/p-3b0e4e08.js +65 -0
  94. package/dist/sankhyablocks/{p-0874adb5.entry.js → p-40915359.entry.js} +1 -1
  95. package/dist/sankhyablocks/p-62896624.entry.js +1 -0
  96. package/dist/sankhyablocks/p-70a4af56.entry.js +1 -0
  97. package/dist/sankhyablocks/p-86801b08.entry.js +1 -0
  98. package/dist/sankhyablocks/p-9b5944a4.entry.js +1 -0
  99. package/dist/sankhyablocks/p-9bdbc7d8.entry.js +1 -0
  100. package/dist/sankhyablocks/p-ac384baf.entry.js +1 -0
  101. package/dist/sankhyablocks/p-bf2acf72.entry.js +1 -0
  102. package/dist/sankhyablocks/p-c4874327.entry.js +1 -0
  103. package/dist/sankhyablocks/{p-247a8b36.entry.js → p-d1791da2.entry.js} +1 -1
  104. package/dist/sankhyablocks/{p-90f9b4db.entry.js → p-e817f254.entry.js} +3 -3
  105. package/dist/sankhyablocks/{p-32f0935f.js → p-f3d1c48e.js} +1 -1
  106. package/dist/sankhyablocks/sankhyablocks.esm.js +1 -1
  107. package/dist/types/components/snk-actions-button/subcomponents/snk-actions-form.d.ts +1 -1
  108. package/dist/types/components/snk-application/snk-application.d.ts +7 -0
  109. package/dist/types/components/snk-attach/{structure/crud-config-builder.d.ts → interfaces/ICrudConfig.d.ts} +1 -2
  110. package/dist/types/components/snk-attach/interfaces/TFetcherType.d.ts +1 -0
  111. package/dist/types/components/snk-attach/snk-attach.d.ts +27 -6
  112. package/dist/types/components/snk-attach/structure/builder/anexo-sistema-crud-config.builder.d.ts +2 -0
  113. package/dist/types/components/snk-attach/structure/builder/attach-crud-config.builder.d.ts +31 -0
  114. package/dist/types/components/snk-attach/structure/{taskbar-builder.d.ts → builder/taskbar-builder.d.ts} +1 -1
  115. package/dist/types/components/snk-attach/structure/fetcher/facade/fetcher.facade.d.ts +11 -0
  116. package/dist/types/components/snk-attach/structure/fetcher/factory/anexo-sistema-data-unit.factory.d.ts +17 -0
  117. package/dist/types/components/snk-attach/structure/fetcher/factory/attach-fetcher-data-unit.factory.d.ts +15 -0
  118. package/dist/types/components/snk-attach/structure/index.d.ts +6 -3
  119. package/dist/types/components/snk-filter-bar/filter-item/snk-filter-item.d.ts +1 -2
  120. package/dist/types/components/snk-filter-bar/filter-modal/snk-filter-modal.d.ts +5 -0
  121. package/dist/types/components/snk-filter-bar/snk-filter-bar.d.ts +5 -0
  122. package/dist/types/components/snk-filter-bar/utils/SnkFilterModalFactory.d.ts +3 -1
  123. package/dist/types/components/snk-simple-crud/snk-simple-crud.d.ts +10 -1
  124. package/dist/types/components.d.ts +74 -2
  125. package/dist/types/lib/http/data-fetcher/DataFetcher.d.ts +1 -1
  126. package/dist/types/lib/http/data-fetcher/fetchers/{attach-fetcher.d.ts → AttachFetcher/anexo-sistema-fetcher.d.ts} +3 -2
  127. package/dist/types/lib/http/data-fetcher/fetchers/AttachFetcher/attach-fetcher.d.ts +11 -0
  128. package/dist/types/lib/http/data-fetcher/fetchers/AttachFetcher/facade/attach-fetcher.facade.d.ts +8 -0
  129. package/dist/types/lib/http/data-fetcher/fetchers/AttachFetcher/index.d.ts +3 -0
  130. package/dist/types/lib/http/data-fetcher/fetchers/{fecthAttach → AttachFetcher}/interfaces/ISave.d.ts +2 -1
  131. package/dist/types/lib/http/data-fetcher/fetchers/data-unit/dataunit-fetcher.d.ts +1 -0
  132. package/dist/types/lib/http/data-fetcher/fetchers/data-unit/loadstrategy/DatasetStrategy.d.ts +1 -0
  133. package/dist/types/lib/index.d.ts +1 -1
  134. package/package.json +5 -5
  135. package/dist/cjs/pesquisa-fetcher-ef050a47.js +0 -167
  136. package/dist/esm/pesquisa-fetcher-dd3ca0a5.js +0 -165
  137. package/dist/sankhyablocks/p-20726710.entry.js +0 -1
  138. package/dist/sankhyablocks/p-41560fd8.entry.js +0 -1
  139. package/dist/sankhyablocks/p-4775a293.entry.js +0 -1
  140. package/dist/sankhyablocks/p-6678d5d4.entry.js +0 -1
  141. package/dist/sankhyablocks/p-71439fd9.entry.js +0 -1
  142. package/dist/sankhyablocks/p-7d8d7fe9.entry.js +0 -1
  143. package/dist/sankhyablocks/p-a91bb13d.js +0 -1
  144. package/dist/sankhyablocks/p-a9e5b094.entry.js +0 -1
  145. package/dist/sankhyablocks/p-abfa8101.entry.js +0 -1
  146. package/dist/sankhyablocks/p-b3020263.entry.js +0 -1
  147. package/dist/sankhyablocks/p-bf93a748.js +0 -60
  148. package/dist/sankhyablocks/p-c6f89389.entry.js +0 -1
  149. package/dist/sankhyablocks/p-cebae710.entry.js +0 -1
  150. package/dist/sankhyablocks/p-d9bb09b3.js +0 -6
  151. package/dist/types/components/snk-attach/structure/data-unit-builder.d.ts +0 -15
  152. /package/dist/collection/{lib/http/data-fetcher/fetchers/fecthAttach/interfaces/IDelete.js → components/snk-attach/interfaces/ICrudConfig.js} +0 -0
  153. /package/dist/collection/{lib/http/data-fetcher/fetchers/fecthAttach/interfaces/IDownloadKey.js → components/snk-attach/interfaces/TFetcherType.js} +0 -0
  154. /package/dist/collection/lib/http/data-fetcher/fetchers/{fecthAttach → AttachFetcher}/interfaces/index.js +0 -0
  155. /package/dist/types/lib/http/data-fetcher/fetchers/{fecthAttach → AttachFetcher}/interfaces/IDelete.d.ts +0 -0
  156. /package/dist/types/lib/http/data-fetcher/fetchers/{fecthAttach → AttachFetcher}/interfaces/IDownloadKey.d.ts +0 -0
  157. /package/dist/types/lib/http/data-fetcher/fetchers/{fecthAttach → AttachFetcher}/interfaces/index.d.ts +0 -0
@@ -1,47 +1,66 @@
1
1
  import { h } from "@stencil/core";
2
- import { ApplicationContext } from "@sankhyalabs/core";
3
- import { AttachFetcher } from "../../lib/http/data-fetcher/fetchers/attach-fetcher";
2
+ import { DataUnit, ApplicationContext } from "@sankhyalabs/core";
3
+ import { AnexoSistemaFetcher, AttachFetcher, DataUnitFetcher } from "../../lib";
4
4
  import { VIEW_MODE } from "../../lib/utils/constants";
5
- import DataUnitFetcher from "../../lib/http/data-fetcher/fetchers/data-unit/dataunit-fetcher";
6
- import { AttachmentDataUnitBuilder, buildTaskBarManager, crudConfig } from "./structure";
5
+ import { AnexoSistemaDataUnitFactory, AttachFetcherDataUnitFactory, buildTaskBarManager, anexoSistemaCrudConfig, attachCrudConfig } from "./structure";
7
6
  const RESOURCE_ID = 'AnexoSistema';
8
7
  const DATA_UNIT_NAME = 'br.com.sankhya.core.v3.anexoSistema';
9
8
  export class SnkAttach {
10
9
  constructor() {
11
- this.handleTaskbarClick = ({ detail: taskbar }) => {
10
+ this.handleTaskbarClick = async ({ detail: taskbar }) => {
12
11
  if (["DOWNLOAD", "LINK"].includes(taskbar))
13
- return this.downloadAttachment(this.dataUnit.getSelectedRecord());
12
+ return this.downloadAttachment(this._currentDataUnit.getSelectedRecord());
13
+ if (this.fetcherType === "Attach" && ["SAVE"].includes(taskbar) && this._currentDataUnit.isDirty()) {
14
+ await this._currentDataUnit.setFieldValue("REGISTER_KEY", this.registerKey);
15
+ }
14
16
  };
15
17
  this.handleBack = () => {
16
- this.dataUnit.cancelEdition().then((cancelationConfirmed) => {
18
+ this._currentDataUnit.cancelEdition().then((cancelationConfirmed) => {
17
19
  if (cancelationConfirmed)
18
20
  this.back.emit();
19
21
  });
20
22
  };
21
23
  this.handleFinish = () => {
22
- if (!this.dataUnit.isDirty())
24
+ if (!this._currentDataUnit.isDirty())
23
25
  return this.back.emit();
24
- this.dataUnit.saveData().then(() => {
26
+ this._currentDataUnit.saveData().then(() => {
25
27
  this.showFinishedToast();
26
28
  this.back.emit();
27
29
  });
28
30
  };
31
+ this.fetcherType = "AnexoSistema";
32
+ this.fetcher = undefined;
33
+ this.dataUnit = undefined;
34
+ this.dataUnitBuilder = undefined;
29
35
  this.registerKey = undefined;
30
36
  this.entityName = undefined;
31
37
  this.messagesBuilder = undefined;
32
- this.dataUnit = undefined;
38
+ this._currentFetcher = undefined;
39
+ this._currentDataUnit = undefined;
33
40
  this.crudConfig = undefined;
34
41
  }
35
42
  registerKeyWatcher(newRegisterKey, oldRegisterKey) {
36
- var _a;
37
- if (this.dataUnit == null) {
43
+ var _a, _b, _c, _d;
44
+ if (this._currentDataUnit == null) {
38
45
  this.loadAttachmentDataUnit();
39
46
  }
40
47
  if (oldRegisterKey !== newRegisterKey) {
41
48
  this.returnToGridMode();
42
- this._attachFetcher = new AttachFetcher(this.entityName, this.registerKey, (_a = this.dataUnit) === null || _a === void 0 ? void 0 : _a.name);
43
- this._dataUnitBuilder.initLoaders(this.dataUnit, this._attachFetcher, () => { this.returnToGridMode(); });
44
- this.dataUnit.loadData();
49
+ if (this.fetcherType === "AnexoSistema") {
50
+ this._currentFetcher = new AnexoSistemaFetcher(this.entityName, this.registerKey, (_a = this._currentDataUnit) === null || _a === void 0 ? void 0 : _a.name);
51
+ (_b = this._currentDataUnitBuilder) === null || _b === void 0 ? void 0 : _b.initLoaders(this._currentDataUnit, this._currentFetcher, this.returnToGridMode.bind(this));
52
+ return (_c = this._currentDataUnit) === null || _c === void 0 ? void 0 : _c.loadData();
53
+ }
54
+ if (this.fetcherType === "Attach") {
55
+ const hasMoreOneItem = ((_d = this.registerKey) === null || _d === void 0 ? void 0 : _d.split("_").length) > 1;
56
+ if (hasMoreOneItem)
57
+ return;
58
+ }
59
+ return this._currentDataUnit
60
+ .loadMetadata()
61
+ .then(() => {
62
+ this._currentDataUnit.loadData(undefined, undefined, true, this.registerKey);
63
+ });
45
64
  }
46
65
  }
47
66
  /**
@@ -64,44 +83,90 @@ export class SnkAttach {
64
83
  window.open(`${selectedRecord.LINK}`);
65
84
  return;
66
85
  }
67
- this._attachFetcher.getDownloadKey(selectedRecord).then(({ chave }) => {
68
- window.open(`/mge/visualizadorArquivos.mge?chaveArquivo=${chave.valor}&forcarDownload=S`);
86
+ this._currentFetcher
87
+ .getDownloadKey(selectedRecord)
88
+ .then(({ chave }) => {
89
+ var _a;
90
+ let forceDownload = false;
91
+ if (!((_a = selectedRecord === null || selectedRecord === void 0 ? void 0 : selectedRecord.ARQUIVO) === null || _a === void 0 ? void 0 : _a.endsWith(".pdf"))) {
92
+ forceDownload = true;
93
+ }
94
+ window.open(`/mge/visualizadorArquivos.mge?chaveArquivo=${chave.valor}${forceDownload ? "&forcarDownload=S" : ""}`);
69
95
  });
70
96
  }
71
97
  returnToGridMode() {
72
- this.dataUnit.clearSelection();
98
+ var _a;
99
+ (_a = this._currentDataUnit) === null || _a === void 0 ? void 0 : _a.clearSelection();
73
100
  if (this._crudElement)
74
101
  this._crudElement.goToView(VIEW_MODE.GRID);
75
102
  }
76
103
  loadAttachmentDataUnit() {
77
- var _a;
78
104
  try {
79
- const dataUnit = this.dataUnit || new DataUnitFetcher().getDataUnit(RESOURCE_ID, DATA_UNIT_NAME);
80
- this._attachFetcher = new AttachFetcher(this.entityName, this.registerKey, (_a = this.dataUnit) === null || _a === void 0 ? void 0 : _a.name);
81
- if (!dataUnit.metadata)
82
- dataUnit.loadMetadata().then(() => {
83
- this.crudConfig = crudConfig;
84
- });
85
- this._dataUnitBuilder = new AttachmentDataUnitBuilder(this.entityName, this.getMessage.bind(this));
86
- dataUnit.addFilterProvider({ getFilter: () => this._dataUnitBuilder.getFilters(this.registerKey) });
87
- dataUnit.addInterceptor({ interceptAction: (action) => this._dataUnitBuilder.getInterceptions(dataUnit, action, this._crudElement) });
88
- this.dataUnit = dataUnit;
89
- this.dataUnit.loadData().then(() => {
90
- this.disableEditFieldsNotInForm();
91
- });
92
- return this.dataUnit;
105
+ switch (this.fetcherType) {
106
+ case "AnexoSistema":
107
+ this.loadAnexoSistema();
108
+ break;
109
+ case "Attach":
110
+ this.loadAttach();
111
+ break;
112
+ default:
113
+ this._currentFetcher = this.fetcher;
114
+ this._currentDataUnit = this.dataUnit;
115
+ this._currentDataUnitBuilder = this.dataUnitBuilder;
116
+ }
93
117
  }
94
118
  catch (error) {
95
119
  throw new Error('There was an error while creating the data unit');
96
120
  }
97
121
  }
122
+ loadAnexoSistema() {
123
+ var _a;
124
+ this._currentDataUnit = this._currentDataUnit || new DataUnitFetcher().getDataUnit(RESOURCE_ID, DATA_UNIT_NAME);
125
+ this._currentFetcher = new AnexoSistemaFetcher(this.entityName, this.registerKey, (_a = this._currentDataUnit) === null || _a === void 0 ? void 0 : _a.name);
126
+ if (!this._currentDataUnit.metadata) {
127
+ this._currentDataUnit
128
+ .loadMetadata()
129
+ .then(() => this.crudConfig = anexoSistemaCrudConfig);
130
+ }
131
+ this._currentDataUnitBuilder = new AnexoSistemaDataUnitFactory(this.entityName, this.getMessage.bind(this));
132
+ this._currentDataUnit.addFilterProvider({
133
+ getFilter: () => this._currentDataUnitBuilder.getFilters(this.registerKey)
134
+ });
135
+ this._currentDataUnit.addInterceptor({
136
+ interceptAction: (action) => this._currentDataUnitBuilder.getInterceptions(this._currentDataUnit, action, this._crudElement)
137
+ });
138
+ this._currentDataUnit.loadData().then(this.disableEditFieldsNotInForm.bind(this));
139
+ }
140
+ loadAttach() {
141
+ var _a;
142
+ this._currentFetcher = new AttachFetcher();
143
+ this._currentDataUnit = new DataUnit();
144
+ this._currentDataUnit.addInterceptor({
145
+ interceptAction: (action) => this._currentDataUnitBuilder.getInterceptions(this._currentDataUnit, action, this._crudElement)
146
+ });
147
+ this._currentDataUnitBuilder = new AttachFetcherDataUnitFactory(this.getMessage.bind(this));
148
+ (_a = this._currentDataUnitBuilder) === null || _a === void 0 ? void 0 : _a.initLoaders(this._currentDataUnit, this._currentFetcher, async () => {
149
+ await this._currentDataUnit.loadData(undefined, undefined, true, this.registerKey);
150
+ this.returnToGridMode();
151
+ });
152
+ if (!this._currentDataUnit.metadata) {
153
+ this._currentDataUnit
154
+ .loadMetadata()
155
+ .then(() => {
156
+ this.crudConfig = attachCrudConfig;
157
+ this._currentDataUnit
158
+ .loadData(undefined, undefined, true, this.registerKey)
159
+ .then(this.disableEditFieldsNotInForm.bind(this));
160
+ });
161
+ }
162
+ }
98
163
  disableEditFieldsNotInForm() {
99
164
  var _a;
100
165
  (_a = this.crudConfig) === null || _a === void 0 ? void 0 : _a.grid.columns.forEach(column => {
101
166
  var _a;
102
167
  const fieldName = column.name;
103
168
  if (!((_a = this.crudConfig) === null || _a === void 0 ? void 0 : _a.form.fields.some(field => field.name === fieldName))) {
104
- this.dataUnit.disableField(fieldName);
169
+ this._currentDataUnit.disableField(fieldName);
105
170
  }
106
171
  });
107
172
  }
@@ -109,15 +174,15 @@ export class SnkAttach {
109
174
  this._application = ApplicationContext.getContextValue("__SNK__APPLICATION__");
110
175
  }
111
176
  componentWillRender() {
112
- if (this.dataUnit == null) {
177
+ if (this._currentDataUnit == null) {
113
178
  this.loadAttachmentDataUnit();
114
179
  }
115
180
  }
116
181
  render() {
117
182
  var _a, _b;
118
- if (!this.dataUnit)
183
+ if (!this._currentDataUnit)
119
184
  return null;
120
- return (h("main", { class: "snk-attach__main" }, h("header", { class: "snk-attach__header" }, h("snk-simple-bar", { onExit: this.handleBack, messagesBuilder: this.messagesBuilder }, h("div", { slot: "rightSlot" }, h("ez-button", { class: "ez-button--primary", label: this.getMessage("snkAttach.finish"), onClick: this.handleFinish })))), h("div", { class: "snk-attach__crud-section ez-size-height--full ez-size-width--full ez-flex ez-flex--column" }, h("div", { class: "ez-box__container" }, h("snk-simple-crud", { ref: (el) => this._crudElement = el, dataUnit: this.dataUnit, taskbarManager: buildTaskBarManager(), gridConfig: (_a = this.crudConfig) === null || _a === void 0 ? void 0 : _a.grid, formConfig: (_b = this.crudConfig) === null || _b === void 0 ? void 0 : _b.form, useCancelConfirm: false, onActionClick: this.handleTaskbarClick, messagesBuilder: this.messagesBuilder }, h("div", { slot: "snkSimpleCrudHeader" }, h("div", { class: "ez-flex ez-flex--column" }, h("span", { class: "ez-title--primary ez-text ez-text--large ez-text--bold ez-padding-bottom--medium" }, this.getMessage("snkAttach.title")), h("span", { class: "ez-text ez-text--medium ez-text--secondary" }, this.getMessage("snkAttach.description")))))))));
185
+ return (h("main", { class: "snk-attach__main" }, h("header", { class: "snk-attach__header" }, h("snk-simple-bar", { onExit: this.handleBack, messagesBuilder: this.messagesBuilder }, h("div", { slot: "rightSlot" }, h("ez-button", { class: "ez-button--primary", label: this.getMessage("snkAttach.finish"), onClick: this.handleFinish })))), h("div", { class: "snk-attach__crud-section ez-size-height--full ez-size-width--full ez-flex ez-flex--column" }, h("div", { class: "ez-box__container" }, h("snk-simple-crud", { ref: (el) => this._crudElement = el, dataUnit: this._currentDataUnit, taskbarManager: buildTaskBarManager(), gridConfig: (_a = this.crudConfig) === null || _a === void 0 ? void 0 : _a.grid, formConfig: (_b = this.crudConfig) === null || _b === void 0 ? void 0 : _b.form, useCancelConfirm: false, onActionClick: this.handleTaskbarClick, messagesBuilder: this.messagesBuilder }, h("div", { slot: "snkSimpleCrudHeader" }, h("div", { class: "ez-flex ez-flex--column" }, h("span", { class: "ez-title--primary ez-text ez-text--large ez-text--bold ez-padding-bottom--medium" }, this.getMessage("snkAttach.title")), h("span", { class: "ez-text ez-text--medium ez-text--secondary" }, this.getMessage("snkAttach.description")))))))));
121
186
  }
122
187
  static get is() { return "snk-attach"; }
123
188
  static get encapsulation() { return "scoped"; }
@@ -133,6 +198,89 @@ export class SnkAttach {
133
198
  }
134
199
  static get properties() {
135
200
  return {
201
+ "fetcherType": {
202
+ "type": "string",
203
+ "mutable": false,
204
+ "complexType": {
205
+ "original": "TFetcherType",
206
+ "resolved": "\"AnexoSistema\" | \"Another\" | \"Attach\"",
207
+ "references": {
208
+ "TFetcherType": {
209
+ "location": "import",
210
+ "path": "./interfaces/TFetcherType"
211
+ }
212
+ }
213
+ },
214
+ "required": false,
215
+ "optional": false,
216
+ "docs": {
217
+ "tags": [],
218
+ "text": "FetcherType define o tipo de fetcher respons\u00E1vel por carregar os dados do DataUnit."
219
+ },
220
+ "attribute": "fetcher-type",
221
+ "reflect": false,
222
+ "defaultValue": "\"AnexoSistema\""
223
+ },
224
+ "fetcher": {
225
+ "type": "unknown",
226
+ "mutable": false,
227
+ "complexType": {
228
+ "original": "AttachFetcherFacadeInterface",
229
+ "resolved": "AttachFetcherFacadeInterface",
230
+ "references": {
231
+ "AttachFetcherFacadeInterface": {
232
+ "location": "import",
233
+ "path": "../../lib"
234
+ }
235
+ }
236
+ },
237
+ "required": false,
238
+ "optional": false,
239
+ "docs": {
240
+ "tags": [],
241
+ "text": "Fetcher respons\u00E1vel por carregar os dados do DataUnit."
242
+ }
243
+ },
244
+ "dataUnit": {
245
+ "type": "unknown",
246
+ "mutable": false,
247
+ "complexType": {
248
+ "original": "DataUnit",
249
+ "resolved": "DataUnit",
250
+ "references": {
251
+ "DataUnit": {
252
+ "location": "import",
253
+ "path": "@sankhyalabs/core"
254
+ }
255
+ }
256
+ },
257
+ "required": false,
258
+ "optional": false,
259
+ "docs": {
260
+ "tags": [],
261
+ "text": "DataUnit respons\u00E1vel por carregar os dados."
262
+ }
263
+ },
264
+ "dataUnitBuilder": {
265
+ "type": "unknown",
266
+ "mutable": false,
267
+ "complexType": {
268
+ "original": "FetcherFacade",
269
+ "resolved": "FetcherFacade",
270
+ "references": {
271
+ "FetcherFacade": {
272
+ "location": "import",
273
+ "path": "./structure"
274
+ }
275
+ }
276
+ },
277
+ "required": false,
278
+ "optional": false,
279
+ "docs": {
280
+ "tags": [],
281
+ "text": "DataUnitBuilder respons\u00E1vel por implementar dados a serem utilizados no DataUnit."
282
+ }
283
+ },
136
284
  "registerKey": {
137
285
  "type": "string",
138
286
  "mutable": false,
@@ -158,7 +306,7 @@ export class SnkAttach {
158
306
  "resolved": "string",
159
307
  "references": {}
160
308
  },
161
- "required": true,
309
+ "required": false,
162
310
  "optional": false,
163
311
  "docs": {
164
312
  "tags": [],
@@ -191,7 +339,8 @@ export class SnkAttach {
191
339
  }
192
340
  static get states() {
193
341
  return {
194
- "dataUnit": {},
342
+ "_currentFetcher": {},
343
+ "_currentDataUnit": {},
195
344
  "crudConfig": {}
196
345
  };
197
346
  }
@@ -1,4 +1,4 @@
1
- export const crudConfig = {
1
+ export const anexoSistemaCrudConfig = {
2
2
  grid: {
3
3
  columns: [
4
4
  { name: "ARQUIVOOULINK", orderIndex: 0, width: 0 },
@@ -0,0 +1,62 @@
1
+ import { ApplicationContext, DataType, UserInterface } from "@sankhyalabs/core";
2
+ const application = ApplicationContext.getContextValue("__SNK__APPLICATION__");
3
+ const getMessage = (key) => {
4
+ var _a, _b;
5
+ return (_b = (_a = application === null || application === void 0 ? void 0 : application.messagesBuilder) === null || _a === void 0 ? void 0 : _a.getMessage) === null || _b === void 0 ? void 0 : _b.call(_a, key, null);
6
+ };
7
+ export const attachCrudConfig = {
8
+ grid: {
9
+ columns: [
10
+ { name: "CODATA", orderIndex: 0, width: 0 },
11
+ { name: "DESCRICAO", orderIndex: 1, width: 0 },
12
+ { name: "ARQUIVO", orderIndex: 2, width: 0 },
13
+ { name: "DTALTER", orderIndex: 3, width: 0 },
14
+ { name: "USUARIO", orderIndex: 4, width: 0 },
15
+ ],
16
+ },
17
+ form: {
18
+ emptyConfig: false,
19
+ fields: [
20
+ {
21
+ name: "DESCRICAO",
22
+ label: getMessage("snkAttach.attachMetadata.lblDescription"),
23
+ visible: true,
24
+ readOnly: false,
25
+ required: true,
26
+ },
27
+ {
28
+ name: "CAMINHO_ARQUIVO",
29
+ label: getMessage("snkAttach.attachMetadata.lblFile"),
30
+ visible: true,
31
+ readOnly: false,
32
+ required: true,
33
+ },
34
+ ],
35
+ },
36
+ };
37
+ export const attachFetcherMetadataBuilder = {
38
+ name: "Attach",
39
+ label: "Attach List",
40
+ fields: [
41
+ { name: "CODATA", label: getMessage("snkAttach.attachMetadata.lblCode"), dataType: DataType.TEXT },
42
+ { name: "DESCRICAO", label: getMessage("snkAttach.attachMetadata.lblDescription"), dataType: DataType.TEXT },
43
+ { name: "ARQUIVO", label: getMessage("snkAttach.attachMetadata.lblFileOrLink"), dataType: DataType.TEXT },
44
+ { name: "USUARIO", label: getMessage("snkAttach.attachMetadata.lblUser"), dataType: DataType.TEXT },
45
+ { name: "DTALTER", label: getMessage("snkAttach.attachMetadata.lblDate"), dataType: DataType.TEXT },
46
+ {
47
+ name: "CAMINHO_ARQUIVO",
48
+ label: getMessage("snkAttach.attachMetadata.lblFileUpload"),
49
+ dataType: DataType.OBJECT,
50
+ userInterface: UserInterface.FILE,
51
+ readOnly: false,
52
+ required: true,
53
+ visible: true,
54
+ properties: {
55
+ subTitle: getMessage("snkAttach.attachMetadata.lblSubTitle"),
56
+ MAX_FILES: 1,
57
+ STORAGESTRATEGY: "SESSION",
58
+ INTERNAL_FILENAME: "Attach.upload",
59
+ }
60
+ },
61
+ ],
62
+ };
@@ -1,4 +1,4 @@
1
- import { TaskbarElement } from "../../snk-taskbar/elements/taskbar-elements";
1
+ import { TaskbarElement } from "../../../snk-taskbar/elements/taskbar-elements";
2
2
  import { ApplicationContext } from "@sankhyalabs/core";
3
3
  const application = ApplicationContext.getContextValue("__SNK__APPLICATION__");
4
4
  const getMessage = (key) => {
@@ -1,28 +1,31 @@
1
1
  import { Action, ApplicationContext, DataType } from "@sankhyalabs/core";
2
- import { SaveErrorsEnum } from "../../../lib/http/data-fetcher/fetchers/fecthAttach/interfaces";
3
- import { VIEW_MODE } from "../../../lib/utils/constants";
4
- import PreloadManager from '../../../lib/http/data-fetcher/fetchers/data-unit/cache/PreloadManager';
5
- export class AttachmentDataUnitBuilder {
2
+ import { SaveErrorsEnum } from "../../../../../lib/http/data-fetcher/fetchers/AttachFetcher/interfaces";
3
+ import { VIEW_MODE } from "../../../../../lib/utils/constants";
4
+ import PreloadManager from '../../../../../lib/http/data-fetcher/fetchers/data-unit/cache/PreloadManager';
5
+ export class AnexoSistemaDataUnitFactory {
6
6
  constructor(entityName, getMessage) {
7
7
  this.entityName = entityName;
8
8
  this.getMessage = getMessage;
9
9
  this._application = ApplicationContext.getContextValue("__SNK__APPLICATION__");
10
10
  }
11
- initLoaders(dataUnit, attachFetcher, onSuccess) {
11
+ initLoaders(dataUnit, fetcher, onSuccess) {
12
12
  if (!this.loader)
13
13
  this.loader = dataUnit.dataLoader;
14
14
  dataUnit.dataLoader = (dataUnit, request) => this.dataLoader(dataUnit, request);
15
- dataUnit.saveLoader = (_, changes) => this.saveLoader(changes, attachFetcher).then((recordIds) => {
15
+ dataUnit.saveLoader = (_, changes) => this.saveLoader(changes, fetcher).then((recordIds) => {
16
16
  if (recordIds.length)
17
17
  onSuccess();
18
18
  return recordIds;
19
19
  });
20
- dataUnit.removeLoader = (dataUnit, ids) => this.removeLoader(dataUnit, ids, attachFetcher).then((recordIds) => {
20
+ dataUnit.removeLoader = (dataUnit, ids) => this.removeLoader(dataUnit, ids, fetcher).then((recordIds) => {
21
21
  if (recordIds.length)
22
22
  onSuccess();
23
23
  return recordIds;
24
24
  });
25
25
  }
26
+ metadataLoader(dataUnit) {
27
+ throw new Error("Method not implemented.");
28
+ }
26
29
  dataLoader(dataUnit, request) {
27
30
  return new Promise(resolve => {
28
31
  this.loader(dataUnit, request).then(response => {
@@ -38,11 +41,11 @@ export class AttachmentDataUnitBuilder {
38
41
  });
39
42
  });
40
43
  }
41
- saveLoader(changes, attachFetcher) {
44
+ saveLoader(changes, fetcher) {
42
45
  return new Promise((resolve) => {
43
46
  var _a;
44
47
  const change = Array.isArray(changes) ? changes[0] : {};
45
- const savePromise = ((_a = change === null || change === void 0 ? void 0 : change.record) === null || _a === void 0 ? void 0 : _a.NUATTACH) >= 0 ? attachFetcher.edit.bind(attachFetcher) : attachFetcher.save.bind(attachFetcher);
48
+ const savePromise = ((_a = change === null || change === void 0 ? void 0 : change.record) === null || _a === void 0 ? void 0 : _a.NUATTACH) >= 0 ? fetcher.edit.bind(fetcher) : fetcher.save.bind(fetcher);
46
49
  savePromise(change).then((records) => {
47
50
  resolve(records);
48
51
  }).catch((error) => {
@@ -62,11 +65,11 @@ export class AttachmentDataUnitBuilder {
62
65
  });
63
66
  });
64
67
  }
65
- removeLoader(dataUnit, ids, attachFetcher) {
68
+ removeLoader(dataUnit, ids, fetcher) {
66
69
  return new Promise((resolve) => {
67
70
  const { records } = dataUnit.getSelectionInfo();
68
71
  const recordToDelete = records[0];
69
- attachFetcher.delete(recordToDelete).then(() => {
72
+ fetcher.delete(recordToDelete).then(() => {
70
73
  PreloadManager.removeRecords(dataUnit, [recordToDelete]);
71
74
  return resolve(ids);
72
75
  });
@@ -0,0 +1,111 @@
1
+ import { Action, ApplicationContext, StringUtils } from "@sankhyalabs/core";
2
+ import { SaveErrorsEnum } from "../../../../../lib/http/data-fetcher/fetchers/AttachFetcher/interfaces";
3
+ import { AutorizationType } from "../../../../../lib/http/data-fetcher/fetchers/auth-fetcher";
4
+ import { attachFetcherMetadataBuilder } from "../../builder/attach-crud-config.builder";
5
+ import { VIEW_MODE } from "../../../../../lib/utils/constants";
6
+ const SERVICE_LOAD = "Attach.load";
7
+ export class AttachFetcherDataUnitFactory {
8
+ constructor(getMessage) {
9
+ this.getMessage = getMessage;
10
+ this._application = ApplicationContext.getContextValue("__SNK__APPLICATION__");
11
+ }
12
+ initLoaders(dataUnit, fetcher, onSuccess) {
13
+ dataUnit.metadataLoader = (dataUnit) => this.metadataLoader(dataUnit);
14
+ dataUnit.dataLoader = (dataUnit, request) => this.dataLoader(dataUnit, request);
15
+ dataUnit.saveLoader = (_, changes) => this.saveLoader(changes, fetcher).then((recordIds) => {
16
+ if (recordIds.length)
17
+ onSuccess();
18
+ return recordIds;
19
+ });
20
+ dataUnit.removeLoader = (dataUnit, ids) => this.removeLoader(dataUnit, ids, fetcher).then((recordIds) => {
21
+ if (recordIds.length)
22
+ onSuccess();
23
+ return recordIds;
24
+ });
25
+ }
26
+ metadataLoader(_) {
27
+ return Promise.resolve(attachFetcherMetadataBuilder);
28
+ }
29
+ async dataLoader(_, request) {
30
+ if (!request.source) {
31
+ return Promise.resolve({ records: [] });
32
+ }
33
+ const criteria = {
34
+ criteria: {
35
+ codata: request.source,
36
+ tipoAnexo: "N"
37
+ }
38
+ };
39
+ const applicationDataFetcher = await this._application.getDataFetcher();
40
+ const { anexos: { anexo = [] } } = await applicationDataFetcher.callServiceBroker(SERVICE_LOAD, JSON.stringify(criteria));
41
+ const records = [];
42
+ anexo.forEach((param) => {
43
+ records.push(Object.assign({ __record__id__: StringUtils.generateUUID(), CAMINHO_ARQUIVO: [{
44
+ name: param === null || param === void 0 ? void 0 : param.ARQUIVO,
45
+ }] }, param));
46
+ });
47
+ return Promise.resolve({ records });
48
+ }
49
+ saveLoader(changes, fetcher) {
50
+ return new Promise((resolve) => {
51
+ const change = Array.isArray(changes) ? changes[0] : {};
52
+ fetcher.save(change)
53
+ .then(resolve)
54
+ .catch((error) => {
55
+ if (error.message === SaveErrorsEnum.DESCRIPTION_CANNOT_BE_CHANGED) {
56
+ this._application.alert(this.getMessage('snkAttach.alertValidation.descriptionCannotBeChanged.title'), this.getMessage('snkAttach.alertValidation.descriptionCannotBeChanged.message'));
57
+ return resolve([]);
58
+ }
59
+ if (error.message === SaveErrorsEnum.LINK_AND_FILE_AT_THE_SAME_TIME) {
60
+ this._application.alert(this.getMessage('snkAttach.alertValidation.fileAndLinkAtTheSameTime.title'), this.getMessage('snkAttach.alertValidation.fileAndLinkAtTheSameTime.message'));
61
+ return resolve([]);
62
+ }
63
+ if (error.message === SaveErrorsEnum.ANY_LINK_OR_FILE_FILLED) {
64
+ this._application.alert(this.getMessage('snkAttach.alertValidation.anyLinkOrFileFilled.title'), this.getMessage('snkAttach.alertValidation.anyLinkOrFileFilled.message'));
65
+ return resolve([]);
66
+ }
67
+ if (error.message) {
68
+ this._application.error((error.title || error.name), error.message);
69
+ return resolve([]);
70
+ }
71
+ resolve([]);
72
+ });
73
+ });
74
+ }
75
+ removeLoader(dataUnit, ids, fetcher) {
76
+ return new Promise((resolve) => {
77
+ dataUnit.getSelectionInfo().records.forEach(async (record) => {
78
+ this._application.hasAccess(AutorizationType.REMOVE)
79
+ .then(async (hasAccess) => {
80
+ if (hasAccess) {
81
+ await fetcher.delete(record);
82
+ resolve(ids);
83
+ }
84
+ });
85
+ });
86
+ });
87
+ }
88
+ getFilters() {
89
+ throw new Error('Method not implemented.');
90
+ }
91
+ getInterceptions(dataUnit, action, crudRef) {
92
+ return new Promise((resolve) => {
93
+ if (action.type === Action.EDITION_CANCELED) {
94
+ if (!dataUnit.isDirty())
95
+ return resolve(action);
96
+ return this._application.confirm(this.getMessage('snkAttach.cancelConfirmation.title'), this.getMessage('snkAttach.cancelConfirmation.message')).then((cancellationConfirmed) => {
97
+ if (cancellationConfirmed) {
98
+ crudRef.goToView(VIEW_MODE.GRID);
99
+ return resolve(action);
100
+ }
101
+ return resolve(undefined);
102
+ });
103
+ }
104
+ if (action.type === Action.DATA_SAVED) {
105
+ dataUnit.loadData();
106
+ return resolve(action);
107
+ }
108
+ resolve(action);
109
+ });
110
+ }
111
+ }
@@ -1,3 +1,6 @@
1
- export * from './data-unit-builder';
2
- export * from './taskbar-builder';
3
- export * from './crud-config-builder';
1
+ export * from './fetcher/facade/fetcher.facade';
2
+ export * from './fetcher/factory/anexo-sistema-data-unit.factory';
3
+ export * from './fetcher/factory/attach-fetcher-data-unit.factory';
4
+ export * from './builder/taskbar-builder';
5
+ export * from './builder/anexo-sistema-crud-config.builder';
6
+ export * from './builder/attach-crud-config.builder';
@@ -239,7 +239,7 @@ export class SnkDataExporter {
239
239
  pkObject[`PK_${name}`] = { type: this.parseDataType(type), value };
240
240
  pkObject['pks'] = [];
241
241
  }
242
- const dataFields = { nome: name, tipo: type, valor: value };
242
+ const dataFields = { nome: name, tipo: this.parseDataType(type), valor: value };
243
243
  fields['fields'].push(dataFields);
244
244
  pkObject['pks'].push(fields);
245
245
  });
@@ -10,7 +10,8 @@ export class SnkFilterMultiSelect {
10
10
  * Emitido quando acontece a alteração de valor do componente snk-filter-multi-select
11
11
  */
12
12
  ezChangeListener(evt) {
13
- this.value = evt.detail.value;
13
+ var _a;
14
+ this.value = (_a = evt.detail) === null || _a === void 0 ? void 0 : _a.value;
14
15
  this.valueChanged.emit(this.value);
15
16
  }
16
17
  /**