@sankhyalabs/sankhyablocks 5.1.1 → 5.1.3

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 (69) hide show
  1. package/dist/cjs/{ConfigStorage-05b9b162.js → ConfigStorage-98c5108f.js} +1 -1
  2. package/dist/cjs/{DataFetcher-451b3e68.js → DataFetcher-4fbdb64a.js} +1 -1
  3. package/dist/cjs/{SnkFormConfigManager-18ed80a5.js → SnkFormConfigManager-88559b73.js} +2 -2
  4. package/dist/cjs/{form-config-fetcher-a93d6334.js → form-config-fetcher-6b19bf3b.js} +1 -1
  5. package/dist/cjs/loader.cjs.js +1 -1
  6. package/dist/cjs/{pesquisa-fetcher-19cdf486.js → pesquisa-fetcher-1b559332.js} +1 -1
  7. package/dist/cjs/sankhyablocks.cjs.js +1 -1
  8. package/dist/cjs/snk-application.cjs.entry.js +4 -4
  9. package/dist/cjs/snk-crud.cjs.entry.js +2 -2
  10. package/dist/cjs/snk-data-exporter.cjs.entry.js +1 -1
  11. package/dist/cjs/snk-detail-view.cjs.entry.js +57 -40
  12. package/dist/cjs/snk-filter-bar.cjs.entry.js +3 -3
  13. package/dist/cjs/snk-form-config.cjs.entry.js +2 -2
  14. package/dist/cjs/snk-form.cjs.entry.js +4 -4
  15. package/dist/cjs/snk-grid-config.cjs.entry.js +3 -3
  16. package/dist/cjs/snk-grid.cjs.entry.js +3 -3
  17. package/dist/cjs/{snk-guides-viewer-e992e9dc.js → snk-guides-viewer-6225bb73.js} +29 -44
  18. package/dist/cjs/snk-guides-viewer.cjs.entry.js +6 -6
  19. package/dist/cjs/snk-simple-crud.cjs.entry.js +2 -2
  20. package/dist/collection/components/snk-crud/subcomponents/GuideBuilder.js +43 -0
  21. package/dist/collection/components/snk-crud/subcomponents/snk-detail-view.js +34 -39
  22. package/dist/collection/components/snk-crud/subcomponents/snk-guides-viewer.js +50 -41
  23. package/dist/collection/lib/http/data-fetcher/DataFetcher.js +1 -1
  24. package/dist/components/DataFetcher.js +1 -1
  25. package/dist/components/snk-detail-view2.js +79 -75
  26. package/dist/esm/{ConfigStorage-34caac5c.js → ConfigStorage-479e3228.js} +1 -1
  27. package/dist/esm/{DataFetcher-00309101.js → DataFetcher-caa61f2c.js} +1 -1
  28. package/dist/esm/{SnkFormConfigManager-d3a8aaf4.js → SnkFormConfigManager-960d808d.js} +2 -2
  29. package/dist/esm/{form-config-fetcher-e58fc104.js → form-config-fetcher-74e3e14b.js} +1 -1
  30. package/dist/esm/loader.js +1 -1
  31. package/dist/esm/{pesquisa-fetcher-1b071e4e.js → pesquisa-fetcher-c86787c1.js} +1 -1
  32. package/dist/esm/sankhyablocks.js +1 -1
  33. package/dist/esm/snk-application.entry.js +4 -4
  34. package/dist/esm/snk-crud.entry.js +2 -2
  35. package/dist/esm/snk-data-exporter.entry.js +1 -1
  36. package/dist/esm/snk-detail-view.entry.js +57 -40
  37. package/dist/esm/snk-filter-bar.entry.js +3 -3
  38. package/dist/esm/snk-form-config.entry.js +2 -2
  39. package/dist/esm/snk-form.entry.js +4 -4
  40. package/dist/esm/snk-grid-config.entry.js +3 -3
  41. package/dist/esm/snk-grid.entry.js +3 -3
  42. package/dist/esm/{snk-guides-viewer-fd5aa685.js → snk-guides-viewer-73b9eb29.js} +29 -44
  43. package/dist/esm/snk-guides-viewer.entry.js +6 -6
  44. package/dist/esm/snk-simple-crud.entry.js +2 -2
  45. package/dist/sankhyablocks/p-10be1b2a.entry.js +1 -0
  46. package/dist/sankhyablocks/{p-8f359cbf.entry.js → p-12d2dccf.entry.js} +1 -1
  47. package/dist/sankhyablocks/{p-5a0ef952.entry.js → p-193b0fa5.entry.js} +1 -1
  48. package/dist/sankhyablocks/{p-25341d65.js → p-5fc11c5d.js} +1 -1
  49. package/dist/sankhyablocks/{p-70037212.js → p-664c1543.js} +1 -1
  50. package/dist/sankhyablocks/{p-3a426d45.entry.js → p-68507ace.entry.js} +1 -1
  51. package/dist/sankhyablocks/{p-89cf5a29.entry.js → p-6ad356c2.entry.js} +1 -1
  52. package/dist/sankhyablocks/{p-d49e5961.entry.js → p-72277163.entry.js} +1 -1
  53. package/dist/sankhyablocks/{p-7532ec0a.js → p-75a83156.js} +2 -2
  54. package/dist/sankhyablocks/{p-840494aa.entry.js → p-7d4bb27a.entry.js} +1 -1
  55. package/dist/sankhyablocks/{p-9cff8df2.js → p-7e475a6f.js} +1 -1
  56. package/dist/sankhyablocks/{p-9d4a25d2.js → p-86667fdf.js} +1 -1
  57. package/dist/sankhyablocks/{p-183a16d8.js → p-983fef8f.js} +1 -1
  58. package/dist/sankhyablocks/p-9ce550b7.entry.js +1 -0
  59. package/dist/sankhyablocks/{p-663ede3d.entry.js → p-b9fe5ed3.entry.js} +1 -1
  60. package/dist/sankhyablocks/{p-d5535cd6.entry.js → p-dd90bd52.entry.js} +1 -1
  61. package/dist/sankhyablocks/{p-8899a7ea.entry.js → p-ecd3cad5.entry.js} +1 -1
  62. package/dist/sankhyablocks/sankhyablocks.esm.js +1 -1
  63. package/dist/types/components/snk-crud/subcomponents/GuideBuilder.d.ts +11 -0
  64. package/dist/types/components/snk-crud/subcomponents/snk-detail-view.d.ts +6 -7
  65. package/dist/types/components/snk-crud/subcomponents/snk-guides-viewer.d.ts +2 -3
  66. package/dist/types/components.d.ts +12 -1
  67. package/package.json +1 -1
  68. package/dist/sankhyablocks/p-903078d2.entry.js +0 -1
  69. package/dist/sankhyablocks/p-e1aaf172.entry.js +0 -1
@@ -2,13 +2,13 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- const snkGuidesViewer = require('./snk-guides-viewer-e992e9dc.js');
5
+ const snkGuidesViewer = require('./snk-guides-viewer-6225bb73.js');
6
6
  require('./index-21bd01e1.js');
7
7
  require('@sankhyalabs/core');
8
- require('./SnkFormConfigManager-18ed80a5.js');
9
- require('./ConfigStorage-05b9b162.js');
10
- require('./form-config-fetcher-a93d6334.js');
11
- require('./DataFetcher-451b3e68.js');
8
+ require('./SnkFormConfigManager-88559b73.js');
9
+ require('./ConfigStorage-98c5108f.js');
10
+ require('./form-config-fetcher-6b19bf3b.js');
11
+ require('./DataFetcher-4fbdb64a.js');
12
12
  require('./_commonjsHelpers-537d719a.js');
13
13
  require('@sankhyalabs/ezui/dist/collection/utils/form');
14
14
  require('./taskbar-processor-bce3f499.js');
@@ -16,7 +16,7 @@ require('./taskbar-elements-5e87cf44.js');
16
16
  require('./index-f400b1d6.js');
17
17
  require('./index-fc7ca86c.js');
18
18
  require('./constants-ae0ed870.js');
19
- require('./pesquisa-fetcher-19cdf486.js');
19
+ require('./pesquisa-fetcher-1b559332.js');
20
20
 
21
21
 
22
22
 
@@ -6,8 +6,8 @@ const index = require('./index-21bd01e1.js');
6
6
  const core = require('@sankhyalabs/core');
7
7
  const constants = require('./constants-ae0ed870.js');
8
8
  const taskbarElements = require('./taskbar-elements-5e87cf44.js');
9
- require('./DataFetcher-451b3e68.js');
10
- require('./pesquisa-fetcher-19cdf486.js');
9
+ require('./DataFetcher-4fbdb64a.js');
10
+ require('./pesquisa-fetcher-1b559332.js');
11
11
  const index$1 = require('./index-f400b1d6.js');
12
12
  const taskbarProcessor = require('./taskbar-processor-bce3f499.js');
13
13
  require('./index-fc7ca86c.js');
@@ -0,0 +1,43 @@
1
+ import { FormMetadata } from "@sankhyalabs/ezui/dist/collection/utils/form";
2
+ export class GuideBuilder {
3
+ constructor(parentGuide, formMetadata, dataUnit) {
4
+ this._parentGuide = parentGuide;
5
+ this._formMetadata = formMetadata;
6
+ this._dataUnit = dataUnit;
7
+ }
8
+ get id() {
9
+ return this._parentGuide.id;
10
+ }
11
+ buildGuideItem(detailBuilders) {
12
+ const item = Object.assign({}, this._parentGuide);
13
+ delete item.expanded;
14
+ delete item.children;
15
+ const currentRecord = this._dataUnit.getSelectedRecord();
16
+ if (!currentRecord) {
17
+ return item;
18
+ }
19
+ const isNewRecord = this._dataUnit.isNewRecord(currentRecord.__record__id__);
20
+ const children = Array.from(this._formMetadata.getAllSheets().values()).map((sheet) => {
21
+ const { name, label } = sheet;
22
+ const isDetail = FormMetadata.getDetailName(name.split("::").pop()) != undefined;
23
+ const disabled = isDetail && isNewRecord;
24
+ const parentId = this._parentGuide.id;
25
+ const id = isDetail ? `${parentId}::${name}` : `${parentId}__FORM:${name}`;
26
+ if (isDetail && detailBuilders.has(id) && !disabled) {
27
+ const item = detailBuilders.get(id).buildGuideItem(detailBuilders);
28
+ return item;
29
+ }
30
+ return {
31
+ id,
32
+ label,
33
+ disabled,
34
+ tooltip: disabled ? "Finalize o cadastro para ter acesso a esta guia." : undefined
35
+ };
36
+ });
37
+ const newGuideItem = children.shift();
38
+ newGuideItem.label = isNewRecord ? "Novo Registro" : currentRecord.__record__label__;
39
+ newGuideItem.children = children;
40
+ item.children = [newGuideItem];
41
+ return item;
42
+ }
43
+ }
@@ -1,10 +1,11 @@
1
1
  import { Host, forceUpdate, h } from '@stencil/core';
2
2
  import { SnkFormConfigManager } from '../../snk-form/SnkFormConfigManager';
3
- import { FormMetadata, buildFormMetadata } from "@sankhyalabs/ezui/dist/collection/utils/form";
3
+ import { buildFormMetadata } from "@sankhyalabs/ezui/dist/collection/utils/form";
4
4
  import { PresentationMode } from '../../../lib';
5
5
  import { TaskbarElement } from '../../snk-taskbar/elements/taskbar-elements';
6
6
  import { VIEW_MODE } from '../../../lib/utils/constants';
7
7
  import { SnkGuidesViewer } from './snk-guides-viewer';
8
+ import { GuideBuilder } from './GuideBuilder';
8
9
  export class SnkDetailView {
9
10
  constructor() {
10
11
  this._disabledButtons = undefined;
@@ -16,9 +17,9 @@ export class SnkDetailView {
16
17
  this.dataUnit = undefined;
17
18
  this.selectedForm = undefined;
18
19
  this.dataState = undefined;
20
+ this.branchGuide = undefined;
19
21
  }
20
22
  observerDataState(newValue, oldValue) {
21
- var _a;
22
23
  const openInsertion = !(oldValue === null || oldValue === void 0 ? void 0 : oldValue.insertionMode) && (newValue === null || newValue === void 0 ? void 0 : newValue.insertionMode);
23
24
  const closeInsertion = (oldValue === null || oldValue === void 0 ? void 0 : oldValue.insertionMode) && !(newValue === null || newValue === void 0 ? void 0 : newValue.insertionMode);
24
25
  if (openInsertion || closeInsertion) {
@@ -27,9 +28,11 @@ export class SnkDetailView {
27
28
  if (this._formMetadata == undefined) {
28
29
  return;
29
30
  }
30
- const currentRecord = (_a = this.dataState) === null || _a === void 0 ? void 0 : _a.selectedRecord;
31
- const item = this.getNewGuideItem(currentRecord);
32
- this.snkDetailGuidesChange.emit({ item, recordId: currentRecord === null || currentRecord === void 0 ? void 0 : currentRecord.__record__id__ });
31
+ const newRecord = newValue === null || newValue === void 0 ? void 0 : newValue.selectedRecord;
32
+ const oldRecord = oldValue === null || oldValue === void 0 ? void 0 : oldValue.selectedRecord;
33
+ if ((newRecord === null || newRecord === void 0 ? void 0 : newRecord.__record__id__) !== (oldRecord === null || oldRecord === void 0 ? void 0 : oldRecord.__record__id__)) {
34
+ this.snkDetailGuidesChange.emit(new GuideBuilder(this.branchGuide, this._formMetadata, this.dataUnit));
35
+ }
33
36
  if (openInsertion) {
34
37
  setTimeout(() => {
35
38
  //FIXME: A necessidade de usar esse timeout é por causa da renderização
@@ -85,36 +88,11 @@ export class SnkDetailView {
85
88
  const labels = guideItemPathSize > 0 ? this.guideItemPath.map(item => item.label) : undefined;
86
89
  this.label = labels.pop();
87
90
  this._levelPath = labels.length > 0 ? labels.join(" / ") : undefined;
88
- this._guideId = this.guideItemPath[guideItemPathSize - 1].id;
89
91
  }
90
92
  else {
91
93
  this.label = "";
92
94
  this._levelPath = undefined;
93
- this._guideId = undefined;
94
- }
95
- }
96
- getNewGuideItem(currentRecord) {
97
- if (currentRecord == undefined) {
98
- return;
99
95
  }
100
- const isNewRecord = this.dataUnit.isNewRecord(currentRecord.__record__id__);
101
- const children = Array.from(this._formMetadata.getAllSheets().values()).map((sheet) => {
102
- const { name, label } = sheet;
103
- const isDetail = FormMetadata.getDetailName(name.split("::").pop()) != undefined;
104
- const disabled = isDetail && isNewRecord;
105
- const id = isDetail ? this.getChildGuideId(name) : this.getFormGuideId(name);
106
- return {
107
- id,
108
- label,
109
- disabled,
110
- tooltip: disabled ? "Finalize o cadastro para ter acesso a esta guia." : undefined
111
- };
112
- });
113
- const newGuideItem = children.shift();
114
- newGuideItem.label = isNewRecord ? "Novo Registro" : currentRecord.__record__label__;
115
- newGuideItem.children = children;
116
- newGuideItem.expanded = true;
117
- return newGuideItem;
118
96
  }
119
97
  getFormGuideId(formName) {
120
98
  var _a;
@@ -129,10 +107,7 @@ export class SnkDetailView {
129
107
  }
130
108
  formName = forms[0];
131
109
  }
132
- return `${this.stripFormPattern(this._guideId)}__FORM:${formName}`;
133
- }
134
- getChildGuideId(child) {
135
- return `${this.stripFormPattern(this._guideId)}::${child}`;
110
+ return `${this.stripFormPattern(this.branchGuide.id)}__FORM:${formName}`;
136
111
  }
137
112
  stripFormPattern(guideId) {
138
113
  return guideId.replace(SnkDetailView.REGEX_FORM_ID, "");
@@ -163,7 +138,7 @@ export class SnkDetailView {
163
138
  return [];
164
139
  }
165
140
  emitSwitchEvent(mode) {
166
- const guideId = mode === VIEW_MODE.GRID ? this.stripFormPattern(this._guideId) : this.getFormGuideId();
141
+ const guideId = mode === VIEW_MODE.GRID ? this.stripFormPattern(this.branchGuide.id) : this.getFormGuideId();
167
142
  if (guideId) {
168
143
  this.snkSwitchGuide.emit(guideId);
169
144
  }
@@ -352,6 +327,26 @@ export class SnkDetailView {
352
327
  "tags": [],
353
328
  "text": "Representa o estado do dataUnit detail."
354
329
  }
330
+ },
331
+ "branchGuide": {
332
+ "type": "unknown",
333
+ "mutable": false,
334
+ "complexType": {
335
+ "original": "IGuideItem",
336
+ "resolved": "IGuideItem",
337
+ "references": {
338
+ "IGuideItem": {
339
+ "location": "import",
340
+ "path": "@sankhyalabs/ezui/dist/types/components/ez-guide-navigator/interfaces"
341
+ }
342
+ }
343
+ },
344
+ "required": false,
345
+ "optional": false,
346
+ "docs": {
347
+ "tags": [],
348
+ "text": "Galho a partir do qual o detail est\u00E1 preso."
349
+ }
355
350
  }
356
351
  };
357
352
  }
@@ -372,12 +367,12 @@ export class SnkDetailView {
372
367
  "text": "Emitido quando h\u00E1 necessidade de atualizar a estrutura de guias."
373
368
  },
374
369
  "complexType": {
375
- "original": "{ item: IGuideItem, recordId: string }",
376
- "resolved": "{ item: IGuideItem; recordId: string; }",
370
+ "original": "GuideBuilder",
371
+ "resolved": "GuideBuilder",
377
372
  "references": {
378
- "IGuideItem": {
373
+ "GuideBuilder": {
379
374
  "location": "import",
380
- "path": "@sankhyalabs/ezui/dist/types/components/ez-guide-navigator/interfaces"
375
+ "path": "./GuideBuilder"
381
376
  }
382
377
  }
383
378
  }
@@ -9,7 +9,7 @@ import { PresentationMode } from "../../../lib";
9
9
  const FORM_NAME_PREFIX = "__FORM:";
10
10
  export class SnkGuidesViewer {
11
11
  constructor() {
12
- this._branchesCache = new Map();
12
+ this._guideBuilders = new Map();
13
13
  this.dataUnit = undefined;
14
14
  this.dataState = undefined;
15
15
  this.configName = undefined;
@@ -29,7 +29,11 @@ export class SnkGuidesViewer {
29
29
  this.loadGuides(true);
30
30
  }
31
31
  observeDataState(newValue, oldValue) {
32
- this.loadGuides((oldValue === null || oldValue === void 0 ? void 0 : oldValue.insertionMode) != (newValue === null || newValue === void 0 ? void 0 : newValue.insertionMode));
32
+ const newRecord = newValue === null || newValue === void 0 ? void 0 : newValue.selectedRecord;
33
+ const oldRecord = oldValue === null || oldValue === void 0 ? void 0 : oldValue.selectedRecord;
34
+ if ((newRecord === null || newRecord === void 0 ? void 0 : newRecord.__record__id__) !== (oldRecord === null || oldRecord === void 0 ? void 0 : oldRecord.__record__id__)) {
35
+ this.loadGuides((oldValue === null || oldValue === void 0 ? void 0 : oldValue.insertionMode) != (newValue === null || newValue === void 0 ? void 0 : newValue.insertionMode));
36
+ }
33
37
  }
34
38
  observeMasterFormConfig() {
35
39
  this.loadGuides(false);
@@ -95,6 +99,9 @@ export class SnkGuidesViewer {
95
99
  guides.push(item);
96
100
  });
97
101
  this._guides = guides;
102
+ if (this._guideNavigator) {
103
+ this._guideNavigator.updateItem(this._guides);
104
+ }
98
105
  if (changeSelection) {
99
106
  this.selectedGuide = this._guides.length > 0 ? this._guides[0] : undefined;
100
107
  }
@@ -102,42 +109,14 @@ export class SnkGuidesViewer {
102
109
  isDetail(formId) {
103
110
  return FormMetadata.getDetailName(formId) != undefined;
104
111
  }
105
- getChildrenMap(item) {
106
- if (!item || !Array.isArray(item.children)) {
107
- return;
108
- }
109
- return new Map(item.children.map(item => [item.id, item]));
110
- }
111
- restoreBranch(guide, recordId) {
112
- if (!recordId) {
113
- return;
114
- }
115
- const cacheChildrenMap = this.getChildrenMap(this._branchesCache.get(recordId));
116
- if (Array.isArray(guide.children) && cacheChildrenMap) {
117
- guide.children.forEach(child => {
118
- const currentItem = cacheChildrenMap.get(child.id);
119
- if (currentItem) {
120
- child.children = currentItem.children;
121
- child.expanded = currentItem.expanded;
122
- }
123
- });
124
- }
125
- this._branchesCache.set(recordId, guide);
126
- }
127
- updateGuide(parentId, { item: guide, recordId }) {
128
- if (guide) {
129
- this.restoreBranch(guide, recordId);
130
- }
112
+ updateGuide(guideBuilder) {
113
+ this._guideBuilders.set(guideBuilder.id, guideBuilder);
114
+ const guideItem = guideBuilder.buildGuideItem(this._guideBuilders);
131
115
  if (this._guideNavigator) {
132
- this._guideNavigator.getItem(parentId).then((parent) => {
133
- if (parent) {
134
- parent.children = guide ? [guide] : undefined;
135
- parent.expanded = true;
136
- this._guideNavigator.updateItem(parent);
137
- this._guideNavigator.getCurrentPath().then(breadcrumbs => {
138
- this._breadcrumbItems = breadcrumbs;
139
- });
140
- }
116
+ this._guideNavigator.updateItem(guideItem).then(() => {
117
+ this._guideNavigator.getCurrentPath().then(breadcrumbs => {
118
+ this._breadcrumbItems = breadcrumbs;
119
+ });
141
120
  });
142
121
  }
143
122
  }
@@ -214,7 +193,7 @@ export class SnkGuidesViewer {
214
193
  return `${this.entityPath}/${entityName}`;
215
194
  }
216
195
  getContent() {
217
- var _a, _b, _c, _d;
196
+ var _a, _b, _c, _d, _e;
218
197
  if (!this.selectedGuide) {
219
198
  return;
220
199
  }
@@ -226,17 +205,23 @@ export class SnkGuidesViewer {
226
205
  let detailId = guideId;
227
206
  if (childEntityName || levels.length > 0) {
228
207
  let formName;
208
+ let detailBranch;
229
209
  if (guideId.includes(FORM_NAME_PREFIX)) {
230
210
  [detailId, formName] = guideId.split(FORM_NAME_PREFIX);
211
+ const pathSize = ((_a = this._breadcrumbItems) === null || _a === void 0 ? void 0 : _a.length) || 0;
212
+ detailBranch = pathSize > 1 ? this._breadcrumbItems[pathSize - 2] : this.selectedGuide;
213
+ }
214
+ else {
215
+ detailBranch = this.selectedGuide;
231
216
  }
232
- content = this.wrapDetail(levels, h("snk-detail-view", { ref: (ref) => this._currentDetail = ref, dataUnitName: this.getDataUnitName(levels, childEntityName), onSnkDetailGuidesChange: (evt) => this.updateGuide(detailId, evt.detail), entityName: childEntityName, selectedForm: formName, guideItemPath: this._breadcrumbItems, key: `detail${detailId}`, onSnkSwitchGuide: evt => this._guideNavigator.selectGuide(evt.detail) }));
217
+ content = this.wrapDetail(levels, h("snk-detail-view", { ref: (ref) => this._currentDetail = ref, dataUnitName: this.getDataUnitName(levels, childEntityName), onSnkDetailGuidesChange: (evt) => this.updateGuide(evt.detail), entityName: childEntityName, selectedForm: formName, branchGuide: detailBranch, guideItemPath: this._breadcrumbItems, key: `detail${detailId}`, onSnkSwitchGuide: evt => this._guideNavigator.selectGuide(evt.detail) }));
233
218
  }
234
219
  else {
235
220
  const cardId = this.selectedGuide.id;
236
221
  const sheet = this._masterFormMetadata.getSheet(cardId);
237
222
  if (sheet) {
238
- const cardConfig = (_b = (_a = this.masterFormConfig) === null || _a === void 0 ? void 0 : _a.cardsState) === null || _b === void 0 ? void 0 : _b.get(cardId);
239
- content = h("snk-form-view", { ref: ref => this._mainForm = ref, fixed: cardConfig === null || cardConfig === void 0 ? void 0 : cardConfig.fixed, summaryFields: (_d = (_c = this.masterFormConfig) === null || _c === void 0 ? void 0 : _c.summary) === null || _d === void 0 ? void 0 : _d.get(cardId), name: cardId, label: sheet.label, fields: sheet.fields, dataUnit: this.dataUnit, formMetadata: this._masterFormMetadata, recordsValidator: this.recordsValidator, key: guideId }, this.presentationMode == PresentationMode.SECONDARY && this.buildTaskBar());
223
+ const cardConfig = (_c = (_b = this.masterFormConfig) === null || _b === void 0 ? void 0 : _b.cardsState) === null || _c === void 0 ? void 0 : _c.get(cardId);
224
+ content = h("snk-form-view", { ref: ref => this._mainForm = ref, fixed: cardConfig === null || cardConfig === void 0 ? void 0 : cardConfig.fixed, summaryFields: (_e = (_d = this.masterFormConfig) === null || _d === void 0 ? void 0 : _d.summary) === null || _e === void 0 ? void 0 : _e.get(cardId), name: cardId, label: sheet.label, fields: sheet.fields, dataUnit: this.dataUnit, formMetadata: this._masterFormMetadata, recordsValidator: this.recordsValidator, key: guideId }, this.presentationMode == PresentationMode.SECONDARY && this.buildTaskBar());
240
225
  }
241
226
  }
242
227
  return content;
@@ -326,6 +311,30 @@ export class SnkGuidesViewer {
326
311
  }
327
312
  static get properties() {
328
313
  return {
314
+ "_guideBuilders": {
315
+ "type": "unknown",
316
+ "mutable": false,
317
+ "complexType": {
318
+ "original": "Map<string, GuideBuilder>",
319
+ "resolved": "Map<string, GuideBuilder>",
320
+ "references": {
321
+ "Map": {
322
+ "location": "global"
323
+ },
324
+ "GuideBuilder": {
325
+ "location": "import",
326
+ "path": "./GuideBuilder"
327
+ }
328
+ }
329
+ },
330
+ "required": false,
331
+ "optional": false,
332
+ "docs": {
333
+ "tags": [],
334
+ "text": ""
335
+ },
336
+ "defaultValue": "new Map()"
337
+ },
329
338
  "dataUnit": {
330
339
  "type": "unknown",
331
340
  "mutable": false,
@@ -115,7 +115,7 @@ export class DataFetcher {
115
115
  return {
116
116
  baseUrl: `${this.resolveURL()}/${module}/service.sbr`,
117
117
  appName: "SankhyaBlocks",
118
- mgeSession: `${window['skw_session'] || urlParams.get("mgeSession")}`,
118
+ mgeSession: `${window['mgeSession'] || urlParams.get("mgeSession")}`,
119
119
  globalID: "85C0093DFA240EAB699B4E47A10215BD",
120
120
  resourceID: (window["resourceID"] || ((_a = window["workspace"]) === null || _a === void 0 ? void 0 : _a.resourceID))
121
121
  };
@@ -6575,7 +6575,7 @@ class DataFetcher {
6575
6575
  return {
6576
6576
  baseUrl: `${this.resolveURL()}/${module}/service.sbr`,
6577
6577
  appName: "SankhyaBlocks",
6578
- mgeSession: `${window['skw_session'] || urlParams.get("mgeSession")}`,
6578
+ mgeSession: `${window['mgeSession'] || urlParams.get("mgeSession")}`,
6579
6579
  globalID: "85C0093DFA240EAB699B4E47A10215BD",
6580
6580
  resourceID: (window["resourceID"] || ((_a = window["workspace"]) === null || _a === void 0 ? void 0 : _a.resourceID))
6581
6581
  };
@@ -36,7 +36,7 @@ const SnkGuidesViewer = /*@__PURE__*/ proxyCustomElement(class extends HTMLEleme
36
36
  this.__registerHost();
37
37
  this.exit = createEvent(this, "exit", 7);
38
38
  this.actionClick = createEvent(this, "actionClick", 7);
39
- this._branchesCache = new Map();
39
+ this._guideBuilders = new Map();
40
40
  this.dataUnit = undefined;
41
41
  this.dataState = undefined;
42
42
  this.configName = undefined;
@@ -56,7 +56,11 @@ const SnkGuidesViewer = /*@__PURE__*/ proxyCustomElement(class extends HTMLEleme
56
56
  this.loadGuides(true);
57
57
  }
58
58
  observeDataState(newValue, oldValue) {
59
- this.loadGuides((oldValue === null || oldValue === void 0 ? void 0 : oldValue.insertionMode) != (newValue === null || newValue === void 0 ? void 0 : newValue.insertionMode));
59
+ const newRecord = newValue === null || newValue === void 0 ? void 0 : newValue.selectedRecord;
60
+ const oldRecord = oldValue === null || oldValue === void 0 ? void 0 : oldValue.selectedRecord;
61
+ if ((newRecord === null || newRecord === void 0 ? void 0 : newRecord.__record__id__) !== (oldRecord === null || oldRecord === void 0 ? void 0 : oldRecord.__record__id__)) {
62
+ this.loadGuides((oldValue === null || oldValue === void 0 ? void 0 : oldValue.insertionMode) != (newValue === null || newValue === void 0 ? void 0 : newValue.insertionMode));
63
+ }
60
64
  }
61
65
  observeMasterFormConfig() {
62
66
  this.loadGuides(false);
@@ -122,6 +126,9 @@ const SnkGuidesViewer = /*@__PURE__*/ proxyCustomElement(class extends HTMLEleme
122
126
  guides.push(item);
123
127
  });
124
128
  this._guides = guides;
129
+ if (this._guideNavigator) {
130
+ this._guideNavigator.updateItem(this._guides);
131
+ }
125
132
  if (changeSelection) {
126
133
  this.selectedGuide = this._guides.length > 0 ? this._guides[0] : undefined;
127
134
  }
@@ -129,42 +136,14 @@ const SnkGuidesViewer = /*@__PURE__*/ proxyCustomElement(class extends HTMLEleme
129
136
  isDetail(formId) {
130
137
  return FormMetadata.getDetailName(formId) != undefined;
131
138
  }
132
- getChildrenMap(item) {
133
- if (!item || !Array.isArray(item.children)) {
134
- return;
135
- }
136
- return new Map(item.children.map(item => [item.id, item]));
137
- }
138
- restoreBranch(guide, recordId) {
139
- if (!recordId) {
140
- return;
141
- }
142
- const cacheChildrenMap = this.getChildrenMap(this._branchesCache.get(recordId));
143
- if (Array.isArray(guide.children) && cacheChildrenMap) {
144
- guide.children.forEach(child => {
145
- const currentItem = cacheChildrenMap.get(child.id);
146
- if (currentItem) {
147
- child.children = currentItem.children;
148
- child.expanded = currentItem.expanded;
149
- }
150
- });
151
- }
152
- this._branchesCache.set(recordId, guide);
153
- }
154
- updateGuide(parentId, { item: guide, recordId }) {
155
- if (guide) {
156
- this.restoreBranch(guide, recordId);
157
- }
139
+ updateGuide(guideBuilder) {
140
+ this._guideBuilders.set(guideBuilder.id, guideBuilder);
141
+ const guideItem = guideBuilder.buildGuideItem(this._guideBuilders);
158
142
  if (this._guideNavigator) {
159
- this._guideNavigator.getItem(parentId).then((parent) => {
160
- if (parent) {
161
- parent.children = guide ? [guide] : undefined;
162
- parent.expanded = true;
163
- this._guideNavigator.updateItem(parent);
164
- this._guideNavigator.getCurrentPath().then(breadcrumbs => {
165
- this._breadcrumbItems = breadcrumbs;
166
- });
167
- }
143
+ this._guideNavigator.updateItem(guideItem).then(() => {
144
+ this._guideNavigator.getCurrentPath().then(breadcrumbs => {
145
+ this._breadcrumbItems = breadcrumbs;
146
+ });
168
147
  });
169
148
  }
170
149
  }
@@ -241,7 +220,7 @@ const SnkGuidesViewer = /*@__PURE__*/ proxyCustomElement(class extends HTMLEleme
241
220
  return `${this.entityPath}/${entityName}`;
242
221
  }
243
222
  getContent() {
244
- var _a, _b, _c, _d;
223
+ var _a, _b, _c, _d, _e;
245
224
  if (!this.selectedGuide) {
246
225
  return;
247
226
  }
@@ -253,17 +232,23 @@ const SnkGuidesViewer = /*@__PURE__*/ proxyCustomElement(class extends HTMLEleme
253
232
  let detailId = guideId;
254
233
  if (childEntityName || levels.length > 0) {
255
234
  let formName;
235
+ let detailBranch;
256
236
  if (guideId.includes(FORM_NAME_PREFIX)) {
257
237
  [detailId, formName] = guideId.split(FORM_NAME_PREFIX);
238
+ const pathSize = ((_a = this._breadcrumbItems) === null || _a === void 0 ? void 0 : _a.length) || 0;
239
+ detailBranch = pathSize > 1 ? this._breadcrumbItems[pathSize - 2] : this.selectedGuide;
240
+ }
241
+ else {
242
+ detailBranch = this.selectedGuide;
258
243
  }
259
- content = this.wrapDetail(levels, h("snk-detail-view", { ref: (ref) => this._currentDetail = ref, dataUnitName: this.getDataUnitName(levels, childEntityName), onSnkDetailGuidesChange: (evt) => this.updateGuide(detailId, evt.detail), entityName: childEntityName, selectedForm: formName, guideItemPath: this._breadcrumbItems, key: `detail${detailId}`, onSnkSwitchGuide: evt => this._guideNavigator.selectGuide(evt.detail) }));
244
+ content = this.wrapDetail(levels, h("snk-detail-view", { ref: (ref) => this._currentDetail = ref, dataUnitName: this.getDataUnitName(levels, childEntityName), onSnkDetailGuidesChange: (evt) => this.updateGuide(evt.detail), entityName: childEntityName, selectedForm: formName, branchGuide: detailBranch, guideItemPath: this._breadcrumbItems, key: `detail${detailId}`, onSnkSwitchGuide: evt => this._guideNavigator.selectGuide(evt.detail) }));
260
245
  }
261
246
  else {
262
247
  const cardId = this.selectedGuide.id;
263
248
  const sheet = this._masterFormMetadata.getSheet(cardId);
264
249
  if (sheet) {
265
- const cardConfig = (_b = (_a = this.masterFormConfig) === null || _a === void 0 ? void 0 : _a.cardsState) === null || _b === void 0 ? void 0 : _b.get(cardId);
266
- content = h("snk-form-view", { ref: ref => this._mainForm = ref, fixed: cardConfig === null || cardConfig === void 0 ? void 0 : cardConfig.fixed, summaryFields: (_d = (_c = this.masterFormConfig) === null || _c === void 0 ? void 0 : _c.summary) === null || _d === void 0 ? void 0 : _d.get(cardId), name: cardId, label: sheet.label, fields: sheet.fields, dataUnit: this.dataUnit, formMetadata: this._masterFormMetadata, recordsValidator: this.recordsValidator, key: guideId }, this.presentationMode == PresentationMode.SECONDARY && this.buildTaskBar());
250
+ const cardConfig = (_c = (_b = this.masterFormConfig) === null || _b === void 0 ? void 0 : _b.cardsState) === null || _c === void 0 ? void 0 : _c.get(cardId);
251
+ content = h("snk-form-view", { ref: ref => this._mainForm = ref, fixed: cardConfig === null || cardConfig === void 0 ? void 0 : cardConfig.fixed, summaryFields: (_e = (_d = this.masterFormConfig) === null || _d === void 0 ? void 0 : _d.summary) === null || _e === void 0 ? void 0 : _e.get(cardId), name: cardId, label: sheet.label, fields: sheet.fields, dataUnit: this.dataUnit, formMetadata: this._masterFormMetadata, recordsValidator: this.recordsValidator, key: guideId }, this.presentationMode == PresentationMode.SECONDARY && this.buildTaskBar());
267
252
  }
268
253
  }
269
254
  return content;
@@ -346,6 +331,7 @@ const SnkGuidesViewer = /*@__PURE__*/ proxyCustomElement(class extends HTMLEleme
346
331
  }; }
347
332
  static get style() { return snkGuidesViewerCss; }
348
333
  }, [2, "snk-guides-viewer", {
334
+ "_guideBuilders": [16],
349
335
  "dataUnit": [16],
350
336
  "dataState": [16],
351
337
  "configName": [1, "config-name"],
@@ -476,6 +462,49 @@ function defineCustomElement$1() {
476
462
  } });
477
463
  }
478
464
 
465
+ class GuideBuilder {
466
+ constructor(parentGuide, formMetadata, dataUnit) {
467
+ this._parentGuide = parentGuide;
468
+ this._formMetadata = formMetadata;
469
+ this._dataUnit = dataUnit;
470
+ }
471
+ get id() {
472
+ return this._parentGuide.id;
473
+ }
474
+ buildGuideItem(detailBuilders) {
475
+ const item = Object.assign({}, this._parentGuide);
476
+ delete item.expanded;
477
+ delete item.children;
478
+ const currentRecord = this._dataUnit.getSelectedRecord();
479
+ if (!currentRecord) {
480
+ return item;
481
+ }
482
+ const isNewRecord = this._dataUnit.isNewRecord(currentRecord.__record__id__);
483
+ const children = Array.from(this._formMetadata.getAllSheets().values()).map((sheet) => {
484
+ const { name, label } = sheet;
485
+ const isDetail = FormMetadata.getDetailName(name.split("::").pop()) != undefined;
486
+ const disabled = isDetail && isNewRecord;
487
+ const parentId = this._parentGuide.id;
488
+ const id = isDetail ? `${parentId}::${name}` : `${parentId}__FORM:${name}`;
489
+ if (isDetail && detailBuilders.has(id) && !disabled) {
490
+ const item = detailBuilders.get(id).buildGuideItem(detailBuilders);
491
+ return item;
492
+ }
493
+ return {
494
+ id,
495
+ label,
496
+ disabled,
497
+ tooltip: disabled ? "Finalize o cadastro para ter acesso a esta guia." : undefined
498
+ };
499
+ });
500
+ const newGuideItem = children.shift();
501
+ newGuideItem.label = isNewRecord ? "Novo Registro" : currentRecord.__record__label__;
502
+ newGuideItem.children = children;
503
+ item.children = [newGuideItem];
504
+ return item;
505
+ }
506
+ }
507
+
479
508
  const snkDetailViewCss = ".sc-snk-detail-view-h{display:flex;row-gap:24px;flex-direction:column;width:100%;height:100%}.level-path.sc-snk-detail-view{color:var(--color--title-primary, #2B3A54);font-weight:var(--text-weight--medium, 400);padding-right:3px}.form-taskbar.sc-snk-detail-view{padding-bottom:var(--space--medium)}.grid-container.sc-snk-detail-view{background-color:#FFF;min-height:100px}.detail-header.sc-snk-detail-view{padding-bottom:0}";
480
509
 
481
510
  const SnkDetailView = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
@@ -493,9 +522,9 @@ const SnkDetailView = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement
493
522
  this.dataUnit = undefined;
494
523
  this.selectedForm = undefined;
495
524
  this.dataState = undefined;
525
+ this.branchGuide = undefined;
496
526
  }
497
527
  observerDataState(newValue, oldValue) {
498
- var _a;
499
528
  const openInsertion = !(oldValue === null || oldValue === void 0 ? void 0 : oldValue.insertionMode) && (newValue === null || newValue === void 0 ? void 0 : newValue.insertionMode);
500
529
  const closeInsertion = (oldValue === null || oldValue === void 0 ? void 0 : oldValue.insertionMode) && !(newValue === null || newValue === void 0 ? void 0 : newValue.insertionMode);
501
530
  if (openInsertion || closeInsertion) {
@@ -504,9 +533,11 @@ const SnkDetailView = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement
504
533
  if (this._formMetadata == undefined) {
505
534
  return;
506
535
  }
507
- const currentRecord = (_a = this.dataState) === null || _a === void 0 ? void 0 : _a.selectedRecord;
508
- const item = this.getNewGuideItem(currentRecord);
509
- this.snkDetailGuidesChange.emit({ item, recordId: currentRecord === null || currentRecord === void 0 ? void 0 : currentRecord.__record__id__ });
536
+ const newRecord = newValue === null || newValue === void 0 ? void 0 : newValue.selectedRecord;
537
+ const oldRecord = oldValue === null || oldValue === void 0 ? void 0 : oldValue.selectedRecord;
538
+ if ((newRecord === null || newRecord === void 0 ? void 0 : newRecord.__record__id__) !== (oldRecord === null || oldRecord === void 0 ? void 0 : oldRecord.__record__id__)) {
539
+ this.snkDetailGuidesChange.emit(new GuideBuilder(this.branchGuide, this._formMetadata, this.dataUnit));
540
+ }
510
541
  if (openInsertion) {
511
542
  setTimeout(() => {
512
543
  //FIXME: A necessidade de usar esse timeout é por causa da renderização
@@ -562,36 +593,11 @@ const SnkDetailView = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement
562
593
  const labels = guideItemPathSize > 0 ? this.guideItemPath.map(item => item.label) : undefined;
563
594
  this.label = labels.pop();
564
595
  this._levelPath = labels.length > 0 ? labels.join(" / ") : undefined;
565
- this._guideId = this.guideItemPath[guideItemPathSize - 1].id;
566
596
  }
567
597
  else {
568
598
  this.label = "";
569
599
  this._levelPath = undefined;
570
- this._guideId = undefined;
571
- }
572
- }
573
- getNewGuideItem(currentRecord) {
574
- if (currentRecord == undefined) {
575
- return;
576
600
  }
577
- const isNewRecord = this.dataUnit.isNewRecord(currentRecord.__record__id__);
578
- const children = Array.from(this._formMetadata.getAllSheets().values()).map((sheet) => {
579
- const { name, label } = sheet;
580
- const isDetail = FormMetadata.getDetailName(name.split("::").pop()) != undefined;
581
- const disabled = isDetail && isNewRecord;
582
- const id = isDetail ? this.getChildGuideId(name) : this.getFormGuideId(name);
583
- return {
584
- id,
585
- label,
586
- disabled,
587
- tooltip: disabled ? "Finalize o cadastro para ter acesso a esta guia." : undefined
588
- };
589
- });
590
- const newGuideItem = children.shift();
591
- newGuideItem.label = isNewRecord ? "Novo Registro" : currentRecord.__record__label__;
592
- newGuideItem.children = children;
593
- newGuideItem.expanded = true;
594
- return newGuideItem;
595
601
  }
596
602
  getFormGuideId(formName) {
597
603
  var _a;
@@ -606,10 +612,7 @@ const SnkDetailView = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement
606
612
  }
607
613
  formName = forms[0];
608
614
  }
609
- return `${this.stripFormPattern(this._guideId)}__FORM:${formName}`;
610
- }
611
- getChildGuideId(child) {
612
- return `${this.stripFormPattern(this._guideId)}::${child}`;
615
+ return `${this.stripFormPattern(this.branchGuide.id)}__FORM:${formName}`;
613
616
  }
614
617
  stripFormPattern(guideId) {
615
618
  return guideId.replace(SnkDetailView.REGEX_FORM_ID, "");
@@ -640,7 +643,7 @@ const SnkDetailView = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement
640
643
  return [];
641
644
  }
642
645
  emitSwitchEvent(mode) {
643
- const guideId = mode === VIEW_MODE.GRID ? this.stripFormPattern(this._guideId) : this.getFormGuideId();
646
+ const guideId = mode === VIEW_MODE.GRID ? this.stripFormPattern(this.branchGuide.id) : this.getFormGuideId();
644
647
  if (guideId) {
645
648
  this.snkSwitchGuide.emit(guideId);
646
649
  }
@@ -678,6 +681,7 @@ const SnkDetailView = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement
678
681
  "dataUnit": [1040],
679
682
  "selectedForm": [1025, "selected-form"],
680
683
  "dataState": [1040],
684
+ "branchGuide": [16],
681
685
  "_disabledButtons": [32],
682
686
  "changeViewMode": [64],
683
687
  "configGrid": [64],
@@ -1,5 +1,5 @@
1
1
  import { ApplicationContext } from '@sankhyalabs/core';
2
- import { R as ResourceFetcher, F as FormConfigFetcher } from './form-config-fetcher-e58fc104.js';
2
+ import { R as ResourceFetcher, F as FormConfigFetcher } from './form-config-fetcher-74e3e14b.js';
3
3
 
4
4
  class GridConfigFetcher extends ResourceFetcher {
5
5
  constructor() {