@sankhyalabs/sankhyablocks 0.0.0-bugfix-dev-KB-33766.0 → 0.0.0-bugfix-dev-KB-38407.0

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 (147) 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-bd4c52da.js → pesquisa-fetcher-977c90b1.js} +221 -25
  5. package/dist/cjs/sankhyablocks.cjs.js +1 -1
  6. package/dist/cjs/snk-actions-button_2.cjs.entry.js +17 -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 +3 -4
  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 +5 -10
  15. package/dist/cjs/snk-filter-item.cjs.entry.js +3 -0
  16. package/dist/cjs/snk-grid.cjs.entry.js +1 -8
  17. package/dist/cjs/{snk-guides-viewer-dce60912.js → snk-guides-viewer-5803fe92.js} +2 -3
  18. package/dist/cjs/snk-guides-viewer.cjs.entry.js +3 -4
  19. package/dist/cjs/snk-pesquisa.cjs.entry.js +1 -1
  20. package/dist/cjs/snk-simple-crud.cjs.entry.js +4 -5
  21. package/dist/collection/collection-manifest.json +1 -1
  22. package/dist/collection/components/snk-application/snk-application.js +43 -0
  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-crud/snk-crud.js +1 -1
  32. package/dist/collection/components/snk-data-exporter/snk-data-exporter.js +1 -1
  33. package/dist/collection/components/snk-filter-bar/filter-item/snk-filter-item.js +3 -0
  34. package/dist/collection/components/snk-filter-bar/snk-filter-bar.js +5 -26
  35. package/dist/collection/components/snk-grid/snk-grid.js +2 -25
  36. package/dist/collection/components/snk-pesquisa/snk-pesquisa.css +2 -4
  37. package/dist/collection/components/snk-taskbar/elements/taskbar-actions-button/taskbar-actions-button.js +15 -1
  38. package/dist/collection/lib/http/data-fetcher/fetchers/{attach-fetcher.js → AttachFetcher/anexo-sistema-fetcher.js} +16 -15
  39. package/dist/collection/lib/http/data-fetcher/fetchers/AttachFetcher/attach-fetcher.js +90 -0
  40. package/dist/collection/lib/http/data-fetcher/fetchers/AttachFetcher/facade/attach-fetcher.facade.js +1 -0
  41. package/dist/collection/lib/http/data-fetcher/fetchers/AttachFetcher/index.js +2 -0
  42. package/dist/collection/lib/http/data-fetcher/fetchers/AttachFetcher/interfaces/IDelete.js +1 -0
  43. package/dist/collection/lib/http/data-fetcher/fetchers/AttachFetcher/interfaces/IDownloadKey.js +1 -0
  44. package/dist/collection/lib/http/data-fetcher/fetchers/{fecthAttach → AttachFetcher}/interfaces/ISave.js +1 -0
  45. package/dist/collection/lib/http/data-fetcher/fetchers/data-unit/dataunit-fetcher.js +16 -2
  46. package/dist/collection/lib/http/data-fetcher/fetchers/data-unit/loadstrategy/DatasetStrategy.js +37 -23
  47. package/dist/collection/lib/http/data-fetcher/fetchers/pesquisa-fetcher.js +7 -1
  48. package/dist/collection/lib/index.js +1 -1
  49. package/dist/collection/lib/message/resources/snk-attach.msg.js +13 -0
  50. package/dist/components/SnkMessageBuilder.js +13 -0
  51. package/dist/components/dataunit-fetcher.js +60 -26
  52. package/dist/components/snk-actions-button2.js +1 -0
  53. package/dist/components/snk-application2.js +11 -1
  54. package/dist/components/snk-attach2.js +394 -57
  55. package/dist/components/snk-crud.js +1 -1
  56. package/dist/components/snk-data-exporter2.js +1 -1
  57. package/dist/components/snk-filter-bar2.js +5 -11
  58. package/dist/components/snk-filter-item2.js +3 -0
  59. package/dist/components/snk-grid2.js +1 -9
  60. package/dist/components/snk-pesquisa2.js +1 -1
  61. package/dist/components/taskbar-actions-button2.js +15 -1
  62. package/dist/esm/{ISave-4412b20c.js → ISave-d8c8bc59.js} +1 -0
  63. package/dist/esm/{SnkMessageBuilder-ca843d1b.js → SnkMessageBuilder-0fb796b9.js} +13 -0
  64. package/dist/esm/loader.js +1 -1
  65. package/dist/esm/{dataunit-fetcher-65714f21.js → pesquisa-fetcher-5e228b5a.js} +221 -26
  66. package/dist/esm/sankhyablocks.js +1 -1
  67. package/dist/esm/snk-actions-button_2.entry.js +17 -4
  68. package/dist/esm/snk-application.entry.js +11 -3
  69. package/dist/esm/snk-attach.entry.js +389 -58
  70. package/dist/esm/snk-crud.entry.js +3 -4
  71. package/dist/esm/snk-data-exporter.entry.js +3 -3
  72. package/dist/esm/{snk-data-unit-6208ebf0.js → snk-data-unit-5d201fb3.js} +1 -1
  73. package/dist/esm/snk-data-unit.entry.js +2 -2
  74. package/dist/esm/snk-detail-view.entry.js +4 -5
  75. package/dist/esm/snk-filter-bar.entry.js +5 -10
  76. package/dist/esm/snk-filter-item.entry.js +3 -0
  77. package/dist/esm/snk-grid.entry.js +1 -8
  78. package/dist/esm/{snk-guides-viewer-8b9564bd.js → snk-guides-viewer-c77e1c8f.js} +2 -3
  79. package/dist/esm/snk-guides-viewer.entry.js +3 -4
  80. package/dist/esm/snk-pesquisa.entry.js +1 -1
  81. package/dist/esm/snk-simple-crud.entry.js +2 -3
  82. package/dist/sankhyablocks/{p-ff6064e7.js → p-05243555.js} +1 -1
  83. package/dist/sankhyablocks/{p-9e7d65a4.js → p-21749402.js} +1 -1
  84. package/dist/sankhyablocks/p-25c77ddb.js +65 -0
  85. package/dist/sankhyablocks/p-2dd38000.entry.js +1 -0
  86. package/dist/sankhyablocks/p-34156b41.entry.js +1 -0
  87. package/dist/sankhyablocks/p-3efca291.entry.js +1 -0
  88. package/dist/sankhyablocks/{p-0874adb5.entry.js → p-40915359.entry.js} +1 -1
  89. package/dist/sankhyablocks/p-59ce706a.entry.js +1 -0
  90. package/dist/sankhyablocks/p-7d8d7fe9.entry.js +1 -0
  91. package/dist/sankhyablocks/{p-c223b7b2.entry.js → p-86164061.entry.js} +3 -3
  92. package/dist/sankhyablocks/{p-6977a26c.entry.js → p-86801b08.entry.js} +1 -1
  93. package/dist/sankhyablocks/p-ab568a2e.entry.js +1 -0
  94. package/dist/sankhyablocks/p-b05ab13d.entry.js +1 -0
  95. package/dist/sankhyablocks/p-c4874327.entry.js +1 -0
  96. package/dist/sankhyablocks/p-ce4bca21.js +1 -0
  97. package/dist/sankhyablocks/{p-247a8b36.entry.js → p-d1791da2.entry.js} +1 -1
  98. package/dist/sankhyablocks/p-f39f48c2.entry.js +1 -0
  99. package/dist/sankhyablocks/{p-32f0935f.js → p-f3d1c48e.js} +1 -1
  100. package/dist/sankhyablocks/sankhyablocks.esm.js +1 -1
  101. package/dist/types/components/snk-application/snk-application.d.ts +7 -0
  102. package/dist/types/components/snk-attach/{structure/crud-config-builder.d.ts → interfaces/ICrudConfig.d.ts} +1 -2
  103. package/dist/types/components/snk-attach/interfaces/TFetcherType.d.ts +1 -0
  104. package/dist/types/components/snk-attach/snk-attach.d.ts +27 -6
  105. package/dist/types/components/snk-attach/structure/builder/anexo-sistema-crud-config.builder.d.ts +2 -0
  106. package/dist/types/components/snk-attach/structure/builder/attach-crud-config.builder.d.ts +31 -0
  107. package/dist/types/components/snk-attach/structure/{taskbar-builder.d.ts → builder/taskbar-builder.d.ts} +1 -1
  108. package/dist/types/components/snk-attach/structure/fetcher/facade/fetcher.facade.d.ts +11 -0
  109. package/dist/types/components/snk-attach/structure/fetcher/factory/anexo-sistema-data-unit.factory.d.ts +17 -0
  110. package/dist/types/components/snk-attach/structure/fetcher/factory/attach-fetcher-data-unit.factory.d.ts +15 -0
  111. package/dist/types/components/snk-attach/structure/index.d.ts +6 -3
  112. package/dist/types/components/snk-filter-bar/filter-item/snk-filter-item.d.ts +1 -1
  113. package/dist/types/components/snk-filter-bar/snk-filter-bar.d.ts +0 -4
  114. package/dist/types/components/snk-grid/snk-grid.d.ts +1 -5
  115. package/dist/types/components/snk-taskbar/elements/taskbar-actions-button/taskbar-actions-button.d.ts +1 -0
  116. package/dist/types/components.d.ts +43 -11
  117. package/dist/types/lib/http/data-fetcher/DataFetcher.d.ts +1 -1
  118. package/dist/types/lib/http/data-fetcher/fetchers/{attach-fetcher.d.ts → AttachFetcher/anexo-sistema-fetcher.d.ts} +3 -2
  119. package/dist/types/lib/http/data-fetcher/fetchers/AttachFetcher/attach-fetcher.d.ts +11 -0
  120. package/dist/types/lib/http/data-fetcher/fetchers/AttachFetcher/facade/attach-fetcher.facade.d.ts +8 -0
  121. package/dist/types/lib/http/data-fetcher/fetchers/AttachFetcher/index.d.ts +3 -0
  122. package/dist/types/lib/http/data-fetcher/fetchers/{fecthAttach → AttachFetcher}/interfaces/ISave.d.ts +2 -1
  123. package/dist/types/lib/http/data-fetcher/fetchers/data-unit/dataunit-fetcher.d.ts +1 -0
  124. package/dist/types/lib/http/data-fetcher/fetchers/data-unit/loadstrategy/DatasetStrategy.d.ts +1 -0
  125. package/dist/types/lib/index.d.ts +1 -1
  126. package/package.json +7 -5
  127. package/dist/cjs/pesquisa-fetcher-ef050a47.js +0 -167
  128. package/dist/esm/pesquisa-fetcher-dd3ca0a5.js +0 -165
  129. package/dist/sankhyablocks/p-28564b5e.entry.js +0 -1
  130. package/dist/sankhyablocks/p-29804fc5.js +0 -60
  131. package/dist/sankhyablocks/p-4775a293.entry.js +0 -1
  132. package/dist/sankhyablocks/p-4a6b0528.entry.js +0 -1
  133. package/dist/sankhyablocks/p-55930465.entry.js +0 -1
  134. package/dist/sankhyablocks/p-95a3778f.entry.js +0 -1
  135. package/dist/sankhyablocks/p-b146a9f0.entry.js +0 -1
  136. package/dist/sankhyablocks/p-bedb8ad6.entry.js +0 -1
  137. package/dist/sankhyablocks/p-cdd66657.entry.js +0 -1
  138. package/dist/sankhyablocks/p-d9bb09b3.js +0 -6
  139. package/dist/sankhyablocks/p-ebbc17c6.js +0 -1
  140. package/dist/sankhyablocks/p-f4d99023.entry.js +0 -1
  141. package/dist/types/components/snk-attach/structure/data-unit-builder.d.ts +0 -15
  142. /package/dist/collection/{lib/http/data-fetcher/fetchers/fecthAttach/interfaces/IDelete.js → components/snk-attach/interfaces/ICrudConfig.js} +0 -0
  143. /package/dist/collection/{lib/http/data-fetcher/fetchers/fecthAttach/interfaces/IDownloadKey.js → components/snk-attach/interfaces/TFetcherType.js} +0 -0
  144. /package/dist/collection/lib/http/data-fetcher/fetchers/{fecthAttach → AttachFetcher}/interfaces/index.js +0 -0
  145. /package/dist/types/lib/http/data-fetcher/fetchers/{fecthAttach → AttachFetcher}/interfaces/IDelete.d.ts +0 -0
  146. /package/dist/types/lib/http/data-fetcher/fetchers/{fecthAttach → AttachFetcher}/interfaces/IDownloadKey.d.ts +0 -0
  147. /package/dist/types/lib/http/data-fetcher/fetchers/{fecthAttach → AttachFetcher}/interfaces/index.d.ts +0 -0
@@ -74,15 +74,7 @@ export class SnkFilterBar {
74
74
  * Faz o recarregamento da filterbar buscando o state no servidor.
75
75
  */
76
76
  async reload() {
77
- this.loadConfigFromStorage();
78
- }
79
- /**
80
- * Limpa o cache e faz o recarregamento da filterbar, buscando state no servidor.
81
- */
82
- async clearCacheAndReload() {
83
- console.log("fui chamado [reloadUpdatingCache]");
84
- await ConfigStorage.deleteFilterBarConfigCache(this.configName, this.resourceID);
85
- await this.loadConfigFromStorage();
77
+ this.loadConfigFromStorage(true);
86
78
  }
87
79
  /**
88
80
  * Retorna um item de filtro pelo ID.
@@ -290,7 +282,10 @@ export class SnkFilterBar {
290
282
  loadPermitions() {
291
283
  this._application.isUserSup().then(value => this.allowDefault = value);
292
284
  }
293
- loadConfigFromStorage() {
285
+ async loadConfigFromStorage(clearCache) {
286
+ if (clearCache) {
287
+ await ConfigStorage.deleteFilterBarConfigCache(this.configName, this.resourceID);
288
+ }
294
289
  return new Promise(accept => {
295
290
  ConfigStorage.loadFilterBarConfig(this.configName, this.resourceID, { contextURI: this.dataUnit.name })
296
291
  .then((filters) => {
@@ -567,22 +562,6 @@ export class SnkFilterBar {
567
562
  "tags": []
568
563
  }
569
564
  },
570
- "clearCacheAndReload": {
571
- "complexType": {
572
- "signature": "() => Promise<void>",
573
- "parameters": [],
574
- "references": {
575
- "Promise": {
576
- "location": "global"
577
- }
578
- },
579
- "return": "Promise<void>"
580
- },
581
- "docs": {
582
- "text": "Limpa o cache e faz o recarregamento da filterbar, buscando state no servidor.",
583
- "tags": []
584
- }
585
- },
586
565
  "getFilterItem": {
587
566
  "complexType": {
588
567
  "signature": "(id: string) => Promise<SnkFilterItemConfig | undefined>",
@@ -78,19 +78,12 @@ export class SnkGrid {
78
78
  this.setGridConfig(config);
79
79
  }
80
80
  /**
81
- * Faz o recarregamento da filter-bar da grade buscando o state no cache e caso não exista, no servidor.
81
+ * Faz o recarregamento da filter-bar da grade buscando o state no servidor.
82
82
  */
83
83
  async reloadFilterBar() {
84
84
  var _a;
85
85
  (_a = this._snkFilterBar) === null || _a === void 0 ? void 0 : _a.reload();
86
86
  }
87
- /**
88
- * Limpa o cache e faz o recarregamento da filter-bar da grade, buscando o state no servidor.
89
- */
90
- async clearCacheAndReloadFilterBar() {
91
- var _a;
92
- (_a = this._snkFilterBar) === null || _a === void 0 ? void 0 : _a.clearCacheAndReload();
93
- }
94
87
  /**
95
88
  * Retorna o elemento da filter-bar da grade.
96
89
  */
@@ -863,23 +856,7 @@ export class SnkGrid {
863
856
  "return": "Promise<void>"
864
857
  },
865
858
  "docs": {
866
- "text": "Faz o recarregamento da filter-bar da grade buscando o state no cache e caso n\u00E3o exista, no servidor.",
867
- "tags": []
868
- }
869
- },
870
- "clearCacheAndReloadFilterBar": {
871
- "complexType": {
872
- "signature": "() => Promise<void>",
873
- "parameters": [],
874
- "references": {
875
- "Promise": {
876
- "location": "global"
877
- }
878
- },
879
- "return": "Promise<void>"
880
- },
881
- "docs": {
882
- "text": "Limpa o cache e faz o recarregamento da filter-bar da grade, buscando o state no servidor.",
859
+ "text": "Faz o recarregamento da filter-bar da grade buscando o state no servidor.",
883
860
  "tags": []
884
861
  }
885
862
  },
@@ -6,7 +6,7 @@
6
6
  --snk-pesquisa--font-family: var(--font-pattern, Arial);
7
7
  /*@doc Define o peso da fonte do componente.*/
8
8
  --snk-pesquisa--font-weight: var(--text-weight--medium, 400);
9
-
9
+
10
10
  /* records */
11
11
  /*@doc Define a cor da fonte do indicador de registros do componente.*/
12
12
  --snk-pesquisa__records--color: var(--text--primary, #626e82);
@@ -39,7 +39,6 @@
39
39
  /*@doc Define a largura da barra de rolagem do componente.*/
40
40
  --snk-pesquisa__scrollbar--width: var(--space--medium, 12px);
41
41
 
42
- max-height: 100%;
43
42
  height: 100%;
44
43
  display: flex;
45
44
  flex-direction: column;
@@ -70,7 +69,6 @@
70
69
  .snk-pesquisa__content {
71
70
  display: flex;
72
71
  flex-direction: column;
73
- height: 100%;
74
72
  overflow-y: auto;
75
73
  scrollbar-width: thin;
76
74
 
@@ -148,4 +146,4 @@
148
146
  .snk-pesquisa__btn:hover {
149
147
  /*public*/
150
148
  color: var(--snk-pesquisa__btn-hover--color);
151
- }
149
+ }
@@ -59,12 +59,26 @@ export class TaskbarActionsButton {
59
59
  return this._showDropdown && ((_a = this.actions) === null || _a === void 0 ? void 0 : _a.length) > 0;
60
60
  }
61
61
  onSelectAction(iAction) {
62
- const selectedAction = this.actions.find(action => action.value === iAction.id);
62
+ const actions = this.actions.map(action => (Object.assign(Object.assign({}, action), { id: action.value })));
63
+ const selectedAction = this.getSelectedAction(iAction.id, actions);
63
64
  this.taskbarActionSelected.emit(selectedAction);
64
65
  if (!selectedAction.disableCloseOnSelect) {
65
66
  this._showDropdown = false;
66
67
  }
67
68
  }
69
+ getSelectedAction(id, actions) {
70
+ let selectedItem;
71
+ for (const item of actions) {
72
+ if (item.id === id) {
73
+ selectedItem = item;
74
+ break;
75
+ }
76
+ if (!(item === null || item === void 0 ? void 0 : item.children))
77
+ continue;
78
+ selectedItem = this.getSelectedAction(id, item.children);
79
+ }
80
+ return selectedItem;
81
+ }
68
82
  dropdownItemBuilder(item, _level) {
69
83
  const itemAction = this.actions.find(action => action.value === item.id);
70
84
  if (!itemAction || !itemAction.itemBuilder) {
@@ -1,6 +1,11 @@
1
- import { DataFetcher } from "../DataFetcher";
2
- import { SaveErrorsEnum } from "./fecthAttach/interfaces";
3
- export class AttachFetcher {
1
+ import { SaveErrorsEnum } from "./interfaces";
2
+ import { DataFetcher } from "../../DataFetcher";
3
+ const SERVICE = {
4
+ save: "AnexoSistemaSP.salvar",
5
+ delete: "AnexoSistemaSP.excluir",
6
+ download: "AnexoSistemaSP.baixar",
7
+ };
8
+ export class AnexoSistemaFetcher {
4
9
  constructor(entityName, registerKey, dataUnitName) {
5
10
  var _a;
6
11
  this.entityName = entityName;
@@ -18,14 +23,13 @@ export class AttachFetcher {
18
23
  }
19
24
  async save(change) {
20
25
  var _a, _b;
21
- const serviceName = "AnexoSistemaSP.salvar";
22
26
  let { updatingFields: fields } = change;
23
27
  fields = Object.assign(Object.assign({}, fields), { NOMEARQUIVO: (_a = fields.NOMEARQUIVO) === null || _a === void 0 ? void 0 : _a[0] });
24
28
  try {
25
29
  this.validateFields(fields);
26
30
  const fileInfo = !fields.LINK ? fields.NOMEARQUIVO : null;
27
31
  const reqBody = {
28
- serviceName,
32
+ serviceName: SERVICE.save,
29
33
  requestBody: {
30
34
  params: {
31
35
  resourceID: this.resourceID,
@@ -41,7 +45,7 @@ export class AttachFetcher {
41
45
  }
42
46
  }
43
47
  };
44
- const result = await DataFetcher.get().callServiceBroker(serviceName, JSON.stringify(reqBody));
48
+ const result = await DataFetcher.get().callServiceBroker(SERVICE.save, JSON.stringify(reqBody));
45
49
  return Promise.resolve([Object.assign(Object.assign(Object.assign({}, result), fields), { ARQUIVOOULINK: !!fields.LINK ? fields.LINK : fileInfo === null || fileInfo === void 0 ? void 0 : fileInfo.name, __owner__dataunit__name__: this.dataUnitName })]);
46
50
  }
47
51
  catch (error) {
@@ -50,7 +54,6 @@ export class AttachFetcher {
50
54
  }
51
55
  async edit(change) {
52
56
  var _a, _b, _c;
53
- const serviceName = "AnexoSistemaSP.salvar";
54
57
  let { updatingFields: fields, record } = change;
55
58
  const getFieldValue = (fieldValue) => {
56
59
  if (fields[fieldValue] !== undefined)
@@ -64,7 +67,7 @@ export class AttachFetcher {
64
67
  try {
65
68
  this.validateFields(fields);
66
69
  const reqBody = {
67
- serviceName,
70
+ serviceName: SERVICE.save,
68
71
  requestBody: {
69
72
  params: {
70
73
  resourceID: this.resourceID,
@@ -82,7 +85,7 @@ export class AttachFetcher {
82
85
  }
83
86
  }
84
87
  };
85
- const result = await DataFetcher.get().callServiceBroker(serviceName, JSON.stringify(reqBody));
88
+ const result = await DataFetcher.get().callServiceBroker(SERVICE.save, JSON.stringify(reqBody));
86
89
  return Promise.resolve([Object.assign(Object.assign(Object.assign({}, result), fields), { ARQUIVOOULINK: !!fields.LINK ? fields.LINK : fileInfo === null || fileInfo === void 0 ? void 0 : fileInfo.name, __owner__dataunit__name__: this.dataUnitName })]);
87
90
  }
88
91
  catch (error) {
@@ -91,10 +94,9 @@ export class AttachFetcher {
91
94
  }
92
95
  delete(record) {
93
96
  var _a;
94
- const serviceName = "AnexoSistemaSP.excluir";
95
97
  const attachField = ((_a = record.NOMEARQUIVO) === null || _a === void 0 ? void 0 : _a[0]) || {};
96
98
  const reqBody = {
97
- serviceName,
99
+ serviceName: SERVICE.delete,
98
100
  requestBody: {
99
101
  paramsDelete: {
100
102
  keyAttach: record.CHAVEARQUIVO,
@@ -106,17 +108,16 @@ export class AttachFetcher {
106
108
  }
107
109
  };
108
110
  return new Promise((resolve, reject) => {
109
- DataFetcher.get().callServiceBroker(serviceName, JSON.stringify(reqBody))
111
+ DataFetcher.get().callServiceBroker(SERVICE.delete, JSON.stringify(reqBody))
110
112
  .then(result => resolve(result))
111
113
  .catch(error => reject(error));
112
114
  });
113
115
  }
114
116
  getDownloadKey(record) {
115
117
  var _a;
116
- const serviceName = "AnexoSistemaSP.baixar";
117
118
  const attachField = ((_a = record.NOMEARQUIVO) === null || _a === void 0 ? void 0 : _a[0]) || {};
118
119
  const reqBody = {
119
- serviceName,
120
+ serviceName: SERVICE.download,
120
121
  requestBody: {
121
122
  paramsDown: {
122
123
  nameAttach: attachField === null || attachField === void 0 ? void 0 : attachField.name,
@@ -128,7 +129,7 @@ export class AttachFetcher {
128
129
  }
129
130
  };
130
131
  return new Promise((resolve, reject) => {
131
- DataFetcher.get().callServiceBroker(serviceName, JSON.stringify(reqBody))
132
+ DataFetcher.get().callServiceBroker(SERVICE.download, JSON.stringify(reqBody))
132
133
  .then(result => resolve(result))
133
134
  .catch(error => reject(error));
134
135
  });
@@ -0,0 +1,90 @@
1
+ import { SaveErrorsEnum } from "./interfaces";
2
+ import { DataFetcher } from "../../DataFetcher";
3
+ const SERVICE = {
4
+ save: "Attach.save",
5
+ delete: "Attach.remove",
6
+ view: "Attach.view",
7
+ repository: "RepositorioArquivoSP.abreArquivo"
8
+ };
9
+ export class AttachFetcher {
10
+ constructor(dataUnitName) {
11
+ this.dataUnitName = dataUnitName;
12
+ }
13
+ async save({ dataUnit: dataUnitName, record, updatingFields: fields, operation }) {
14
+ var _a, _b;
15
+ const isInsert = operation == "INSERT";
16
+ const dataBody = isInsert ? fields : record;
17
+ if (!isInsert && (fields === null || fields === void 0 ? void 0 : fields.DESCRICAO) && (fields === null || fields === void 0 ? void 0 : fields.DESCRICAO) !== (record === null || record === void 0 ? void 0 : record.DESCRICAO)) {
18
+ throw new Error(SaveErrorsEnum.DESCRIPTION_CANNOT_BE_CHANGED);
19
+ }
20
+ const reqBody = {
21
+ "anexo": {
22
+ "codata": isInsert ? fields === null || fields === void 0 ? void 0 : fields.REGISTER_KEY : record === null || record === void 0 ? void 0 : record.CODATA,
23
+ "sequencia": (dataBody === null || dataBody === void 0 ? void 0 : dataBody.SEQUENCIA) || "0",
24
+ "tipo": (dataBody === null || dataBody === void 0 ? void 0 : dataBody.TIPO) || "N",
25
+ "descricao": dataBody === null || dataBody === void 0 ? void 0 : dataBody.DESCRICAO,
26
+ "arquivo": (_b = (_a = fields.CAMINHO_ARQUIVO) === null || _a === void 0 ? void 0 : _a[0]) === null || _b === void 0 ? void 0 : _b.name,
27
+ "ehInclusao": isInsert ? "S" : "N",
28
+ "ehArquivoRepositorio": "N"
29
+ }
30
+ };
31
+ return new Promise((resolve, reject) => {
32
+ DataFetcher.get().callServiceBroker(SERVICE.save, JSON.stringify(reqBody))
33
+ .then(result => {
34
+ var _a;
35
+ return resolve([Object.assign(Object.assign(Object.assign({}, result), fields), { __owner__dataunit__name__: (_a = this.dataUnitName) !== null && _a !== void 0 ? _a : dataUnitName })]);
36
+ })
37
+ .catch(error => reject(error));
38
+ });
39
+ }
40
+ async edit(change) {
41
+ throw new Error("Method not implemented.");
42
+ }
43
+ async delete(record) {
44
+ var request = {
45
+ anexo: {
46
+ codata: record.CODATA,
47
+ tipo: record.TIPO,
48
+ descricao: record.DESCRICAO,
49
+ }
50
+ };
51
+ const result = await DataFetcher.get().callServiceBroker(SERVICE.delete, JSON.stringify(request));
52
+ return Promise.resolve(result);
53
+ }
54
+ async getDownloadKey(record) {
55
+ var _a, _b, _c;
56
+ if (record.EHARQUIVOREPOSITORIO == 'S') {
57
+ const request = {
58
+ config: {
59
+ path: record.ARQUIVO,
60
+ tipoconteudo: record.TIPOCONTEUDO
61
+ }
62
+ };
63
+ const result = await DataFetcher.get().callServiceBroker(SERVICE.repository, JSON.stringify(request));
64
+ return Promise.resolve({
65
+ chave: {
66
+ valor: (_b = (_a = result === null || result === void 0 ? void 0 : result.responseBody) === null || _a === void 0 ? void 0 : _a.chave) === null || _b === void 0 ? void 0 : _b.valor
67
+ }
68
+ });
69
+ }
70
+ const criteria = {
71
+ anexo: {
72
+ codata: record.CODATA,
73
+ codemp: record.CODEMP,
74
+ sequencia: record.SEQUENCIA,
75
+ tipo: record.TIPO,
76
+ descricao: record.DESCRICAO,
77
+ tipoConteudo: record.TIPOCONTEUDO
78
+ }
79
+ };
80
+ const result = await DataFetcher.get().callServiceBroker(SERVICE.view, JSON.stringify(criteria));
81
+ if (result === null || result === void 0 ? void 0 : result.chaveAnexo) {
82
+ return Promise.resolve({
83
+ chave: {
84
+ valor: (_c = result === null || result === void 0 ? void 0 : result.chaveAnexo) === null || _c === void 0 ? void 0 : _c.idChaveAnexo
85
+ }
86
+ });
87
+ }
88
+ return Promise.reject(new Error("File not found."));
89
+ }
90
+ }
@@ -0,0 +1,2 @@
1
+ export { AttachFetcher } from "./attach-fetcher";
2
+ export { AnexoSistemaFetcher } from "./anexo-sistema-fetcher";
@@ -3,4 +3,5 @@ export var SaveErrorsEnum;
3
3
  SaveErrorsEnum["LINK_AND_FILE_AT_THE_SAME_TIME"] = "LINK_AND_FILE_AT_THE_SAME_TIME";
4
4
  SaveErrorsEnum["ANY_LINK_OR_FILE_FILLED"] = "ANY_LINK_OR_FILE_FILLED";
5
5
  SaveErrorsEnum["UNKNOWN"] = "UNKNOWN";
6
+ SaveErrorsEnum["DESCRIPTION_CANNOT_BE_CHANGED"] = "DESCRIPTION_CANNOT_BE_CHANGED";
6
7
  })(SaveErrorsEnum || (SaveErrorsEnum = {}));
@@ -171,6 +171,19 @@ export default class DataUnitFetcher {
171
171
  });
172
172
  });
173
173
  }
174
+ addTransientProperties(dataUnit, updatingFields) {
175
+ const loaderProps = dataUnit.getGlobalLoaderProps();
176
+ if (loaderProps == undefined || loaderProps.size === 0) {
177
+ return updatingFields;
178
+ }
179
+ if (updatingFields == undefined) {
180
+ updatingFields = {};
181
+ }
182
+ Array.from(loaderProps.entries()).forEach(([name, value]) => {
183
+ updatingFields[`transient.${name}`] = value;
184
+ });
185
+ return updatingFields;
186
+ }
174
187
  saveData(dataUnit, duChanges) {
175
188
  const updatedRecordsIds = [];
176
189
  const addedRecordsIds = [];
@@ -179,7 +192,7 @@ export default class DataUnitFetcher {
179
192
  const dataUnitInstance = DataUnitStorage.get(changeDU);
180
193
  let parsedUpdatingFields;
181
194
  if (updatingFields) {
182
- parsedUpdatingFields = Object.entries(updatingFields).map(([fieldName, value]) => {
195
+ parsedUpdatingFields = Object.entries(this.addTransientProperties(dataUnit, updatingFields)).map(([fieldName, value]) => {
183
196
  const descriptor = dataUnitInstance.getField(fieldName);
184
197
  const dataType = descriptor ? descriptor.dataType : DataType.TEXT;
185
198
  return { fieldName, dataType, value: dataUnitInstance.valueToString(fieldName, value) };
@@ -226,7 +239,8 @@ export default class DataUnitFetcher {
226
239
  }
227
240
  responseRecord.fields.forEach(({ name, value }) => {
228
241
  var _a;
229
- duRecord[name] = ((_a = dataUnitInstance === null || dataUnitInstance === void 0 ? void 0 : dataUnitInstance.valueFromString) === null || _a === void 0 ? void 0 : _a.call(dataUnitInstance, name, value)) || value;
242
+ const valueFromString = (_a = dataUnitInstance === null || dataUnitInstance === void 0 ? void 0 : dataUnitInstance.valueFromString) === null || _a === void 0 ? void 0 : _a.call(dataUnitInstance, name, value);
243
+ duRecord[name] = (valueFromString !== undefined) ? valueFromString : value;
230
244
  });
231
245
  dataUnitRecords.push(duRecord);
232
246
  });
@@ -6,30 +6,39 @@ export class DatasetStrategy {
6
6
  canSlice() {
7
7
  return false;
8
8
  }
9
+ processSortingSide(request, dataUnit, serverSideFilters) {
10
+ const localSorting = [];
11
+ const serverSorting = [];
12
+ if (request.sort != undefined) {
13
+ if (serverSideFilters.length === 0) {
14
+ return { localSorting: request.sort, serverSorting: [] };
15
+ }
16
+ for (const sort of request.sort) {
17
+ const descriptor = dataUnit.getField(sort.field);
18
+ const local = descriptor != undefined
19
+ && descriptor.properties != undefined
20
+ && descriptor.properties.calculated === "true";
21
+ if (local) {
22
+ localSorting.push(sort);
23
+ }
24
+ else {
25
+ serverSorting.push(sort);
26
+ }
27
+ }
28
+ }
29
+ return { localSorting, serverSorting };
30
+ }
9
31
  async load(dataUnit, request, loadingInfo) {
32
+ var _a, _b;
10
33
  if (dataUnit.metadata == undefined) {
11
34
  return Promise.resolve({ records: [], loadingInfo });
12
35
  }
13
36
  try {
14
- const localSorting = [];
15
- const serverSorting = [];
16
- if (request.sort != undefined) {
17
- for (const sort of request.sort) {
18
- const descriptor = dataUnit.getField(sort.field);
19
- const local = descriptor != undefined
20
- && descriptor.properties != undefined
21
- && descriptor.properties.calculated === "true";
22
- if (local) {
23
- localSorting.push(sort);
24
- }
25
- else {
26
- serverSorting.push(sort);
27
- }
28
- }
29
- }
37
+ const serverSideFilters = (_b = (_a = request.filters) === null || _a === void 0 ? void 0 : _a.filter(filter => !filter.name.startsWith("FILTRO_COLUNA_"))) !== null && _b !== void 0 ? _b : [];
38
+ const { localSorting, serverSorting } = this.processSortingSide(request, dataUnit, serverSideFilters);
30
39
  const fields = this.getFieldsList(dataUnit);
31
40
  const serviceName = "DatasetSP.loadRecords";
32
- const requestBody = this.buildRequestBody(serviceName, fields, dataUnit, request, loadingInfo, serverSorting);
41
+ const requestBody = this.buildRequestBody(serviceName, fields, dataUnit, request, loadingInfo, serverSorting, serverSideFilters);
33
42
  const params = loadingInfo.quiet ? { urlParams: { quietMode: "true" } } : undefined;
34
43
  const { result: responseRecords, pagerID: pagerId } = await DataFetcher.get().callServiceBroker(serviceName, requestBody, params);
35
44
  const records = this.processRecords(dataUnit, fields, responseRecords);
@@ -73,7 +82,7 @@ export class DatasetStrategy {
73
82
  }
74
83
  return [descriptor.name, descriptionField];
75
84
  }
76
- buildRequestBody(serviceName, fields, dataUnit, request, loadingInfo, sorting) {
85
+ buildRequestBody(serviceName, fields, dataUnit, request, loadingInfo, sorting, serverSideFilters) {
77
86
  const dataSetID = dataUnit.dataUnitId;
78
87
  const dataUnitName = dataUnit.name;
79
88
  const entityName = DataUnitFetcher.parseDataUnitName(dataUnitName).entityName;
@@ -92,7 +101,7 @@ export class DatasetStrategy {
92
101
  tryJoinedFields: true,
93
102
  parallelLoader: useParallelLoader,
94
103
  crudListener: `br.com.sankhya.bff.${this.getModuleName()}.BFFDataUnitDatasetAdapter`,
95
- txProperties: this.getTxProperties(dataUnitName, request, sorting),
104
+ txProperties: this.getTxProperties(dataUnit, request, sorting, serverSideFilters),
96
105
  useDefaultRowsLimit: false
97
106
  }
98
107
  };
@@ -103,12 +112,10 @@ export class DatasetStrategy {
103
112
  const moduleName = app.getModuleName();
104
113
  return moduleName.replace("-bff", "");
105
114
  }
106
- getTxProperties(dataUnitName, request, sorting) {
107
- var _a, _b;
115
+ getTxProperties(dataUnit, request, sorting, serverSideFilters) {
108
116
  const txProperties = {
109
- "__DATA_UNIT_ADAPTER__[dataUnitName]": dataUnitName
117
+ "__DATA_UNIT_ADAPTER__[dataUnitName]": dataUnit.name
110
118
  };
111
- const serverSideFilters = (_b = (_a = request.filters) === null || _a === void 0 ? void 0 : _a.filter(filter => !filter.name.startsWith("FILTRO_COLUNA_"))) !== null && _b !== void 0 ? _b : [];
112
119
  if (serverSideFilters.length !== 0) {
113
120
  txProperties["__DATA_UNIT_ADAPTER__[criteria]"] = JSON.stringify(serverSideFilters);
114
121
  }
@@ -118,6 +125,13 @@ export class DatasetStrategy {
118
125
  if (request.parentRecordId != undefined) {
119
126
  txProperties["__DATA_UNIT_ADAPTER__[parentRecordId]"] = request.parentRecordId;
120
127
  }
128
+ const loaderProps = dataUnit.getGlobalLoaderProps();
129
+ if (loaderProps == undefined || loaderProps.size === 0) {
130
+ return txProperties;
131
+ }
132
+ Array.from(loaderProps.entries()).forEach(([name, value]) => {
133
+ txProperties[name] = value;
134
+ });
121
135
  return txProperties;
122
136
  }
123
137
  processRecords(dataUnit, fields, responseRecords) {
@@ -1,4 +1,4 @@
1
- import { DataType } from "@sankhyalabs/core";
1
+ import { ApplicationContext, DataType } from "@sankhyalabs/core";
2
2
  import { gql } from "graphql-request";
3
3
  import { DataFetcher } from "../DataFetcher";
4
4
  export class PesquisaFetcher {
@@ -67,6 +67,12 @@ export class PesquisaFetcher {
67
67
  externalCriteria.params = {
68
68
  param: values.criteria.params.map(param => {
69
69
  let value = param.value;
70
+ if (typeof value === "string") {
71
+ const match = /CTX\{([^}]+)\}/.exec(value);
72
+ if (match) {
73
+ value = ApplicationContext.getContextValue(`__SNK__APPLICATION__FILTER__CONTEXT(${match[1]})__`);
74
+ }
75
+ }
70
76
  let type = param.dataType;
71
77
  if (type === DataType.OBJECT) {
72
78
  value = value.value;
@@ -4,7 +4,7 @@ export { CrudUtils } from './utils/CrudUtils';
4
4
  export { PresentationMode } from "./@types";
5
5
  export { TotalsFetcher } from './http/data-fetcher/fetchers/totals-fetcher';
6
6
  export { default as ApplicationConfigFetcher } from './http/data-fetcher/fetchers/application-config-fetcher';
7
- export { AttachFetcher } from './http/data-fetcher/fetchers/attach-fetcher';
7
+ export { AttachFetcher, AnexoSistemaFetcher } from './http/data-fetcher/fetchers/AttachFetcher';
8
8
  export { default as DataUnitFetcher } from './http/data-fetcher/fetchers/data-unit/dataunit-fetcher';
9
9
  export { default as FilterBarConfigFetcher } from './http/data-fetcher/fetchers/filter-bar-config-fetcher';
10
10
  export { FormConfigFetcher } from './http/data-fetcher/fetchers/form-config-fetcher';
@@ -17,11 +17,24 @@ export const snkAttachMessages = {
17
17
  anyLinkOrFileFilled: {
18
18
  title: "Atenção",
19
19
  message: `É necessário preencher o campo "Link" ou anexar um arquivo.`
20
+ },
21
+ descriptionCannotBeChanged: {
22
+ title: "Atenção",
23
+ message: "O campo 'Descrição' não pode ser alterado."
20
24
  }
21
25
  },
22
26
  taskbar: {
23
27
  titleDownload: "Fazer download",
24
28
  titleLink: "Abrir link",
29
+ },
30
+ attachMetadata: {
31
+ lblCode: "Código",
32
+ lblDescription: "Descrição",
33
+ lblFileOrLink: "Arquivo / Link",
34
+ lblUser: "Usuário",
35
+ lblDate: "Data de alteração",
36
+ lblFile: "Arquivo",
37
+ lblSubTitle: "Clique para selecionar um arquivo",
25
38
  }
26
39
  };
27
40
  export default snkAttachMessages;
@@ -351,11 +351,24 @@ const snkAttachMessages = {
351
351
  anyLinkOrFileFilled: {
352
352
  title: "Atenção",
353
353
  message: `É necessário preencher o campo "Link" ou anexar um arquivo.`
354
+ },
355
+ descriptionCannotBeChanged: {
356
+ title: "Atenção",
357
+ message: "O campo 'Descrição' não pode ser alterado."
354
358
  }
355
359
  },
356
360
  taskbar: {
357
361
  titleDownload: "Fazer download",
358
362
  titleLink: "Abrir link",
363
+ },
364
+ attachMetadata: {
365
+ lblCode: "Código",
366
+ lblDescription: "Descrição",
367
+ lblFileOrLink: "Arquivo / Link",
368
+ lblUser: "Usuário",
369
+ lblDate: "Data de alteração",
370
+ lblFile: "Arquivo",
371
+ lblSubTitle: "Clique para selecionar um arquivo",
359
372
  }
360
373
  };
361
374