@sankhyalabs/sankhyablocks 8.16.0-dev.104 → 8.16.0-dev.106
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.
- package/dist/cjs/{ClientSideExporterProvider-8c219037.js → ClientSideExporterProvider-a2753c93.js} +3 -3
- package/dist/cjs/{SnkMessageBuilder-bae64d0d.js → SnkMessageBuilder-aecd7c18.js} +31 -24
- package/dist/cjs/{dataunit-fetcher-4a5d491a.js → dataunit-fetcher-a723f0dc.js} +5 -2
- package/dist/cjs/loader.cjs.js +1 -1
- package/dist/cjs/pesquisa-grid_2.cjs.entry.js +1 -1
- package/dist/cjs/sankhyablocks.cjs.js +1 -1
- package/dist/cjs/snk-actions-button_7.cjs.entry.js +1 -1
- package/dist/cjs/snk-application.cjs.entry.js +2 -2
- package/dist/cjs/snk-attach.cjs.entry.js +2 -2
- package/dist/cjs/snk-crud.cjs.entry.js +19 -11
- package/dist/cjs/snk-data-exporter.cjs.entry.js +3 -3
- package/dist/cjs/{snk-data-unit-4b510d6e.js → snk-data-unit-ebfdb9ba.js} +226 -12
- package/dist/cjs/snk-data-unit.cjs.entry.js +3 -3
- package/dist/cjs/snk-detail-view.cjs.entry.js +4 -4
- package/dist/cjs/snk-grid.cjs.entry.js +23 -9
- package/dist/cjs/{snk-guides-viewer-e8e5f7b4.js → snk-guides-viewer-fd39f437.js} +99 -44
- package/dist/cjs/snk-guides-viewer.cjs.entry.js +3 -3
- package/dist/cjs/snk-pesquisa.cjs.entry.js +1 -1
- package/dist/cjs/snk-simple-crud.cjs.entry.js +67 -24
- package/dist/cjs/snk-taskbar.cjs.entry.js +2 -1
- package/dist/cjs/{taskbar-elements-7e19882d.js → taskbar-elements-02379452.js} +3 -0
- package/dist/collection/components/snk-crud/snk-crud.js +35 -9
- package/dist/collection/components/snk-crud/subcomponents/snk-guides-viewer.js +117 -43
- package/dist/collection/components/snk-data-unit/MultipleUpdateHelper.js +128 -0
- package/dist/collection/components/snk-data-unit/snk-data-unit.js +107 -12
- package/dist/collection/components/snk-grid/filtercolumn/SnkMultiSelectionListDataSource.js +2 -2
- package/dist/collection/components/snk-grid/snk-grid.js +38 -6
- package/dist/collection/components/snk-simple-crud/snk-simple-crud.js +83 -22
- package/dist/collection/components/snk-taskbar/elements/taskbar-elements.js +3 -0
- package/dist/collection/components/snk-taskbar/snk-taskbar.js +2 -2
- package/dist/collection/lib/http/data-fetcher/fetchers/data-unit/cache/PreloadManager.js +5 -2
- package/dist/collection/lib/message/SnkMessageBuilder.js +1 -0
- package/dist/collection/lib/message/resources/snk-data-unit.msg.js +28 -23
- package/dist/collection/lib/message/resources/snk-taskbar.msg.js +1 -0
- package/dist/components/ContinuousInsertUtils.js +2 -2
- package/dist/components/SnkMessageBuilder.js +31 -24
- package/dist/components/dataunit-fetcher.js +5 -2
- package/dist/components/snk-crud.js +18 -9
- package/dist/components/snk-data-unit2.js +225 -11
- package/dist/components/snk-detail-view2.js +98 -43
- package/dist/components/snk-grid2.js +21 -6
- package/dist/components/snk-simple-crud2.js +66 -22
- package/dist/components/snk-taskbar2.js +4 -0
- package/dist/esm/{ClientSideExporterProvider-a37f890b.js → ClientSideExporterProvider-b3871edb.js} +3 -3
- package/dist/esm/{SnkMessageBuilder-6fff4a4c.js → SnkMessageBuilder-12f5fe1a.js} +31 -24
- package/dist/esm/{dataunit-fetcher-1d02ecfc.js → dataunit-fetcher-0e025732.js} +5 -2
- package/dist/esm/loader.js +1 -1
- package/dist/esm/pesquisa-grid_2.entry.js +1 -1
- package/dist/esm/sankhyablocks.js +1 -1
- package/dist/esm/snk-actions-button_7.entry.js +1 -1
- package/dist/esm/snk-application.entry.js +2 -2
- package/dist/esm/snk-attach.entry.js +2 -2
- package/dist/esm/snk-crud.entry.js +19 -11
- package/dist/esm/snk-data-exporter.entry.js +3 -3
- package/dist/esm/{snk-data-unit-7d0ce406.js → snk-data-unit-03654813.js} +226 -12
- package/dist/esm/snk-data-unit.entry.js +3 -3
- package/dist/esm/snk-detail-view.entry.js +4 -4
- package/dist/esm/snk-grid.entry.js +23 -9
- package/dist/esm/{snk-guides-viewer-c44b3839.js → snk-guides-viewer-75e06feb.js} +100 -45
- package/dist/esm/snk-guides-viewer.entry.js +3 -3
- package/dist/esm/snk-pesquisa.entry.js +1 -1
- package/dist/esm/snk-simple-crud.entry.js +68 -25
- package/dist/esm/snk-taskbar.entry.js +2 -1
- package/dist/esm/{taskbar-elements-d2353c64.js → taskbar-elements-c62b6c66.js} +3 -0
- package/dist/sankhyablocks/{p-35f85998.entry.js → p-1a51dfde.entry.js} +1 -1
- package/dist/sankhyablocks/{p-ef6f0a1b.entry.js → p-1c29409b.entry.js} +1 -1
- package/dist/sankhyablocks/{p-5503e89f.entry.js → p-271c86d3.entry.js} +1 -1
- package/dist/sankhyablocks/p-2d6df7e7.entry.js +1 -0
- package/dist/sankhyablocks/p-41da5310.js +1 -0
- package/dist/sankhyablocks/{p-b2a2a83e.entry.js → p-4a93daef.entry.js} +1 -1
- package/dist/sankhyablocks/p-65be98c5.entry.js +1 -0
- package/dist/sankhyablocks/{p-6541bb6d.entry.js → p-6a0c8ce0.entry.js} +1 -1
- package/dist/sankhyablocks/p-7993b2e3.js +60 -0
- package/dist/sankhyablocks/{p-754559b9.entry.js → p-7cd5c315.entry.js} +1 -1
- package/dist/sankhyablocks/p-80f8c22c.js +1 -0
- package/dist/sankhyablocks/p-885802c3.js +1 -0
- package/dist/sankhyablocks/p-ab0caed6.entry.js +1 -0
- package/dist/sankhyablocks/{p-38e3ffda.entry.js → p-ad07f0c5.entry.js} +1 -1
- package/dist/sankhyablocks/p-cc8c3bca.entry.js +1 -0
- package/dist/sankhyablocks/{p-3b190fb1.entry.js → p-d31a701e.entry.js} +1 -1
- package/dist/sankhyablocks/{p-00796b12.entry.js → p-dc6ad9a6.entry.js} +1 -1
- package/dist/sankhyablocks/p-f4d5bb7f.js +1 -0
- package/dist/sankhyablocks/p-fb0f0087.js +1 -0
- package/dist/sankhyablocks/sankhyablocks.esm.js +1 -1
- package/dist/types/components/snk-crud/snk-crud.d.ts +4 -0
- package/dist/types/components/snk-crud/subcomponents/snk-guides-viewer.d.ts +10 -1
- package/dist/types/components/snk-data-unit/MultipleUpdateHelper.d.ts +9 -0
- package/dist/types/components/snk-data-unit/snk-data-unit.d.ts +17 -0
- package/dist/types/components/snk-grid/filtercolumn/SnkMultiSelectionListDataSource.d.ts +2 -1
- package/dist/types/components/snk-grid/snk-grid.d.ts +5 -0
- package/dist/types/components/snk-simple-crud/snk-simple-crud.d.ts +9 -2
- package/dist/types/components/snk-taskbar/elements/taskbar-elements.d.ts +2 -1
- package/dist/types/components/snk-taskbar/snk-taskbar.d.ts +1 -0
- package/dist/types/components.d.ts +28 -0
- package/dist/types/lib/http/data-fetcher/fetchers/data-unit/cache/PreloadManager.d.ts +1 -1
- package/dist/types/lib/message/SnkMessageBuilder.d.ts +2 -1
- package/package.json +1 -1
- package/dist/sankhyablocks/p-17425c72.js +0 -1
- package/dist/sankhyablocks/p-3fc82614.js +0 -1
- package/dist/sankhyablocks/p-460f1827.entry.js +0 -1
- package/dist/sankhyablocks/p-6e0a5314.js +0 -1
- package/dist/sankhyablocks/p-835128f5.entry.js +0 -1
- package/dist/sankhyablocks/p-8fa828b5.js +0 -1
- package/dist/sankhyablocks/p-92778d5a.js +0 -1
- package/dist/sankhyablocks/p-a8be1d67.js +0 -60
- package/dist/sankhyablocks/p-a962a3e4.entry.js +0 -1
- package/dist/sankhyablocks/p-e35fe2bd.entry.js +0 -1
@@ -1,4 +1,4 @@
|
|
1
|
-
import { Action as DUAction, ElementIDUtils } from '@sankhyalabs/core';
|
1
|
+
import { Action as DUAction, ElementIDUtils, ObjectUtils } from '@sankhyalabs/core';
|
2
2
|
import { Fragment, h } from '@stencil/core';
|
3
3
|
import { SnkFormConfigManager } from '../../snk-form-config/SnkFormConfigManager';
|
4
4
|
import { buildFormMetadata, FormMetadata } from '@sankhyalabs/ezui/dist/collection/utils/form';
|
@@ -44,14 +44,16 @@ export class SnkGuidesViewer {
|
|
44
44
|
this.loadGuides(true);
|
45
45
|
}
|
46
46
|
observeDataState(newValue, oldValue) {
|
47
|
-
|
48
|
-
const
|
49
|
-
|
47
|
+
var _a, _b, _c, _d, _e, _f;
|
48
|
+
const newRecordsIds = (_b = (_a = newValue === null || newValue === void 0 ? void 0 : newValue.selectionInfo) === null || _a === void 0 ? void 0 : _a.recordIds) !== null && _b !== void 0 ? _b : (_c = newValue === null || newValue === void 0 ? void 0 : newValue.selectedRecord) === null || _c === void 0 ? void 0 : _c['__record__id__'];
|
49
|
+
const oldRecordsIds = (_e = (_d = oldValue === null || oldValue === void 0 ? void 0 : oldValue.selectionInfo) === null || _d === void 0 ? void 0 : _d.recordIds) !== null && _e !== void 0 ? _e : (_f = oldValue === null || oldValue === void 0 ? void 0 : oldValue.selectedRecord) === null || _f === void 0 ? void 0 : _f['__record__id__'];
|
50
|
+
if (!ObjectUtils.equals(newRecordsIds, oldRecordsIds)) {
|
50
51
|
this.loadGuides((oldValue === null || oldValue === void 0 ? void 0 : oldValue.insertionMode) != (newValue === null || newValue === void 0 ? void 0 : newValue.insertionMode));
|
51
52
|
}
|
52
53
|
}
|
53
54
|
observeMasterFormConfig() {
|
54
55
|
this.loadGuides(this.noGuideSelected());
|
56
|
+
this.snkMasterFormConfigChange.emit(this.masterFormConfig);
|
55
57
|
}
|
56
58
|
/**
|
57
59
|
* Abre o configurador do formulário
|
@@ -125,6 +127,11 @@ export class SnkGuidesViewer {
|
|
125
127
|
* Para conhecer os detalhes do módulo, vide o arquivo neste projeto "/src/lib/message/resources/snk-crud.msg.ts"
|
126
128
|
*/
|
127
129
|
getMessage(key) {
|
130
|
+
var _a, _b;
|
131
|
+
if (this.dataUnit.isMultipleEdition) {
|
132
|
+
const selectedRecords = (_b = (_a = this.dataUnit.getSelectionInfo()) === null || _a === void 0 ? void 0 : _a.records) !== null && _b !== void 0 ? _b : [];
|
133
|
+
return `Editando ${selectedRecords.length} registros`;
|
134
|
+
}
|
128
135
|
return this.messagesBuilder.getMessage(key, this.dataUnit.getSelectedRecord());
|
129
136
|
}
|
130
137
|
loadGuides(changeSelection) {
|
@@ -137,12 +144,12 @@ export class SnkGuidesViewer {
|
|
137
144
|
this._masterFormMetadata = buildFormMetadata(this.masterFormConfig, this.dataUnit, true);
|
138
145
|
const allSheets = this._masterFormMetadata.getAllSheets();
|
139
146
|
const currentRecord = this.dataUnit.getSelectedRecord();
|
140
|
-
const disableDetails =
|
147
|
+
const disableDetails = this.hasToDisableDetails(currentRecord);
|
141
148
|
const guides = [];
|
142
149
|
Array.from(allSheets.values()).forEach((sheet) => {
|
143
150
|
const item = { id: sheet.name, label: sheet.label };
|
144
151
|
if (this.isDetail(sheet.name) && disableDetails) {
|
145
|
-
item.tooltip = "Para alterar detalhes é necessário estar com um registro selecionado.";
|
152
|
+
item.tooltip = "Para alterar detalhes é necessário estar com um (e apenas um) registro selecionado.";
|
146
153
|
item.disabled = true;
|
147
154
|
}
|
148
155
|
guides.push(item);
|
@@ -155,6 +162,11 @@ export class SnkGuidesViewer {
|
|
155
162
|
this.selectedGuide = this._guides.length > 0 ? this._guides[0] : undefined;
|
156
163
|
}
|
157
164
|
}
|
165
|
+
hasToDisableDetails(currentRecord) {
|
166
|
+
return !currentRecord
|
167
|
+
|| this.dataUnit.isNewRecord(currentRecord.__record__id__)
|
168
|
+
|| this.dataUnit.isMultipleEdition;
|
169
|
+
}
|
158
170
|
isDetail(formId) {
|
159
171
|
return FormMetadata.getDetailName(formId) != undefined;
|
160
172
|
}
|
@@ -177,47 +189,59 @@ export class SnkGuidesViewer {
|
|
177
189
|
}
|
178
190
|
getTaskBarId() {
|
179
191
|
var _a;
|
180
|
-
|
181
|
-
|
182
|
-
loadTaskbarProcessor() {
|
183
|
-
var _a;
|
184
|
-
const taskbarId = this.getTaskBarId();
|
185
|
-
const disabledButtons = [];
|
186
|
-
if (!this.dataState || !this.dataState.hasPrevious) {
|
187
|
-
disabledButtons.push("PREVIOUS");
|
192
|
+
if ((_a = this.dataState) === null || _a === void 0 ? void 0 : _a.isDirty) {
|
193
|
+
return TASKBAR_ID.FINISH_EDITION;
|
188
194
|
}
|
189
|
-
if (
|
190
|
-
|
195
|
+
if (this.dataUnit.isMultipleEdition) {
|
196
|
+
return TASKBAR_ID.MUTIPLE_EDITION;
|
191
197
|
}
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
198
|
+
return TASKBAR_ID.REGULAR;
|
199
|
+
}
|
200
|
+
loadTaskbarProcessor() {
|
201
|
+
const taskbarIDs = {};
|
202
|
+
taskbarIDs[TASKBAR_ID.REGULAR] = this.buildBtnsRegularMode();
|
203
|
+
taskbarIDs[TASKBAR_ID.FINISH_EDITION] = [TaskbarElement.CANCEL, TaskbarElement.SAVE, this.handleAddGridMode()];
|
204
|
+
taskbarIDs[TASKBAR_ID.MUTIPLE_EDITION] = [TaskbarElement.CANCEL];
|
205
|
+
this._taskbarProcessor = new TaskbarProcessor(taskbarIDs);
|
206
|
+
this._taskbarProcessor.process(this.getTaskBarId(), this.taskbarManager, this.dataState, this.buildDisabledButtons(), this.buildInvisibleButtons());
|
207
|
+
}
|
208
|
+
buildBtnsRegularMode() {
|
209
|
+
var _a, _b;
|
210
|
+
const btnsRegularMode = [
|
211
|
+
TaskbarElement.ATTACH, TaskbarElement.CLONE, TaskbarElement.REMOVE, TaskbarElement.MORE_OPTIONS,
|
212
|
+
TaskbarElement.ACTIONS_BUTTON, TaskbarElement.DIVIDER, TaskbarElement.GRID_MODE, TaskbarElement.CONFIGURATOR,
|
213
|
+
];
|
214
|
+
if (((_b = (_a = this.dataState) === null || _a === void 0 ? void 0 : _a.selectionInfo) === null || _b === void 0 ? void 0 : _b.length) <= 1) {
|
215
|
+
btnsRegularMode.unshift(TaskbarElement.PREVIOUS, TaskbarElement.NEXT, TaskbarElement.DIVIDER);
|
199
216
|
}
|
200
|
-
const btnsRegularMode = ["PREVIOUS", "NEXT", "DIVIDER", "ATTACH", "CLONE", "REMOVE", "MORE_OPTIONS", "ACTIONS_BUTTON", "DIVIDER", "GRID_MODE", "CONFIGURATOR"];
|
201
217
|
if (this.presentationMode == PresentationMode.SECONDARY) {
|
202
|
-
btnsRegularMode.unshift(
|
218
|
+
btnsRegularMode.unshift(TaskbarElement.INSERT);
|
203
219
|
}
|
204
220
|
else {
|
205
|
-
btnsRegularMode.push(
|
221
|
+
btnsRegularMode.push(TaskbarElement.INSERT);
|
206
222
|
}
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
223
|
+
return btnsRegularMode;
|
224
|
+
}
|
225
|
+
buildDisabledButtons() {
|
226
|
+
var _a, _b, _c, _d, _e, _f;
|
227
|
+
const disabledButtons = [];
|
228
|
+
if (!((_a = this.dataState) === null || _a === void 0 ? void 0 : _a.hasPrevious))
|
229
|
+
disabledButtons.push(TaskbarElement.PREVIOUS);
|
230
|
+
if (!((_b = this.dataState) === null || _b === void 0 ? void 0 : _b.hasNext))
|
231
|
+
disabledButtons.push(TaskbarElement.NEXT);
|
232
|
+
if (((_d = (_c = this.dataState) === null || _c === void 0 ? void 0 : _c.selectionInfo) === null || _d === void 0 ? void 0 : _d.length) > 1)
|
233
|
+
disabledButtons.push(TaskbarElement.CLONE);
|
234
|
+
if ((_f = (_e = this.dataState) === null || _e === void 0 ? void 0 : _e.selectionInfo) === null || _f === void 0 ? void 0 : _f.isAllRecords())
|
235
|
+
disabledButtons.push(TaskbarElement.REMOVE);
|
236
|
+
return disabledButtons;
|
213
237
|
}
|
214
238
|
handleAddGridMode() {
|
215
239
|
return this.enableGridInsert ? TaskbarElement.GRID_MODE : "";
|
216
240
|
}
|
217
|
-
|
241
|
+
buildInvisibleButtons() {
|
218
242
|
const invisibleButtons = [];
|
219
243
|
if (this.dataState && this.dataState.selectionInfo.mode === SelectionMode.ALL_RECORDS)
|
220
|
-
invisibleButtons.push(
|
244
|
+
invisibleButtons.push(TaskbarElement.ACTIONS_BUTTON);
|
221
245
|
return invisibleButtons;
|
222
246
|
}
|
223
247
|
static updateContentCard(formName, cardConfig, propertyChanged, configManager) {
|
@@ -430,17 +454,27 @@ export class SnkGuidesViewer {
|
|
430
454
|
}
|
431
455
|
buildTaskBar() {
|
432
456
|
var _a;
|
433
|
-
return h("div", { class: `snk-guides-viewer__header-taskbar ${this.presentationMode != PresentationMode.SECONDARY ? 'ez-align--right' : 'ez-padding-bottom--medium'}` }, h("snk-taskbar", { key: "guideViewerTaskbar", "data-element-id": "guideViewer", configName: this.configName, buttons: this._taskbarProcessor.buttons, disabledButtons: this._taskbarProcessor.disabledButtons, customButtons: this._taskbarProcessor.customButtons, actionsList: this.getActionsList(), messagesBuilder: this.messagesBuilder, presentationMode: this.presentationMode, primaryButton: ((_a = this.dataState) === null || _a === void 0 ? void 0 : _a.isDirty) ?
|
457
|
+
return h("div", { class: `snk-guides-viewer__header-taskbar ${this.presentationMode != PresentationMode.SECONDARY ? 'ez-align--right' : 'ez-padding-bottom--medium'}` }, h("snk-taskbar", { key: "guideViewerTaskbar", "data-element-id": "guideViewer", configName: this.configName, buttons: this._taskbarProcessor.buttons, disabledButtons: this._taskbarProcessor.disabledButtons, customButtons: this._taskbarProcessor.customButtons, actionsList: this.getActionsList(), messagesBuilder: this.messagesBuilder, presentationMode: this.presentationMode, primaryButton: ((_a = this.dataState) === null || _a === void 0 ? void 0 : _a.isDirty) ? TaskbarElement.SAVE : TaskbarElement.INSERT, "data-taskbar-owner": "master", dataUnit: this.dataUnit, resourceID: this.resourceID, customSlotId: "GUIDES_VIEWER_TASKBAR_CUSTOM_ELEMENTS", alignRigth: true }, h("slot", { name: "GUIDES_VIEWER_TASKBAR_CUSTOM_ELEMENTS" })));
|
434
458
|
}
|
435
459
|
async dataUnitActionHandler(action) {
|
436
460
|
var _a;
|
437
|
-
|
438
|
-
|
439
|
-
|
440
|
-
|
441
|
-
|
442
|
-
|
443
|
-
|
461
|
+
switch (action.type) {
|
462
|
+
case DUAction.EDITION_CANCELED:
|
463
|
+
case DUAction.DATA_SAVED:
|
464
|
+
if (this.dataUnit.isMultipleEdition) {
|
465
|
+
this.exitViewer();
|
466
|
+
this.dataUnit.isMultipleEdition = false;
|
467
|
+
}
|
468
|
+
break;
|
469
|
+
case DUAction.FIELD_INVALIDATED:
|
470
|
+
const guideName = this.getGuideName((_a = action.payload) === null || _a === void 0 ? void 0 : _a.fieldName);
|
471
|
+
await this.addErrorBadgeToGuide(guideName);
|
472
|
+
await this.openGuideNavigator(guideName);
|
473
|
+
break;
|
474
|
+
case DUAction.METADATA_LOADED:
|
475
|
+
case DUAction.MULTIPLE_EDITION_CHANGED:
|
476
|
+
this.loadGuides(this.noGuideSelected());
|
477
|
+
break;
|
444
478
|
}
|
445
479
|
}
|
446
480
|
async addErrorBadgeToGuide(guideName) {
|
@@ -480,6 +514,20 @@ export class SnkGuidesViewer {
|
|
480
514
|
var _a, _b;
|
481
515
|
return (_b = (_a = this.getCustomTitle) === null || _a === void 0 ? void 0 : _a.call(this)) !== null && _b !== void 0 ? _b : this.getMessage("snkCrud.title");
|
482
516
|
}
|
517
|
+
getTitleTooltip() {
|
518
|
+
if (!this.dataUnit.isMultipleEdition)
|
519
|
+
return;
|
520
|
+
return this.buildRecordIdsArray();
|
521
|
+
}
|
522
|
+
buildRecordIdsArray() {
|
523
|
+
var _a, _b;
|
524
|
+
const selectedRecords = (_b = (_a = this.dataUnit.getSelectionInfo()) === null || _a === void 0 ? void 0 : _a.records) !== null && _b !== void 0 ? _b : [];
|
525
|
+
if (selectedRecords.length === 0) {
|
526
|
+
return "[]";
|
527
|
+
}
|
528
|
+
const labels = selectedRecords.map(record => this.messagesBuilder.getMessage("snkCrud.title", record));
|
529
|
+
return `[${labels.join(", ")}]`;
|
530
|
+
}
|
483
531
|
componentDidLoad() {
|
484
532
|
this.dataUnit.subscribe(this.dataUnitActionHandler.bind(this));
|
485
533
|
}
|
@@ -493,7 +541,7 @@ export class SnkGuidesViewer {
|
|
493
541
|
}
|
494
542
|
this.loadTaskbarProcessor();
|
495
543
|
const showGuides = this._guides && (this._guides.length > 1);
|
496
|
-
return (h("section", { class: "snk-guides-viewer", ref: ref => this._container = ref, tabindex: -1 }, h("div", { class: "ez-row snk-guides-viewer__header" }, h("div", { class: "snk-guides-viewer__header-breadcrumb ez-flex--align-items-center ez-flex-item--align-center ez-padding-left--large", key: "header" }, h("ez-button", { onClick: () => this.exitViewer(), title: this.getMessage("snkCrud.goBackTitle"), mode: "icon", iconName: "arrow_back", class: "ez-padding-right--medium", size: "small" }), h("div", { class: "ez-flex ez-flex--column ez-flex-item--auto" }, h("h1", { class: "ez-title ez-title--primary ez-title--xlarge" }, this.getTitle()), ((_a = this._breadcrumbItems) === null || _a === void 0 ? void 0 : _a.length) > 1 &&
|
544
|
+
return (h("section", { class: "snk-guides-viewer", ref: ref => this._container = ref, tabindex: -1 }, h("div", { class: "ez-row snk-guides-viewer__header" }, h("div", { class: "snk-guides-viewer__header-breadcrumb ez-flex--align-items-center ez-flex-item--align-center ez-padding-left--large", key: "header" }, h("ez-button", { onClick: () => this.exitViewer(), title: this.getMessage("snkCrud.goBackTitle"), mode: "icon", iconName: "arrow_back", class: "ez-padding-right--medium", size: "small" }), h("div", { class: "ez-flex ez-flex--column ez-flex-item--auto" }, h("h1", { class: "ez-title ez-title--primary ez-title--xlarge", title: this.getTitleTooltip() }, this.getTitle()), ((_a = this._breadcrumbItems) === null || _a === void 0 ? void 0 : _a.length) > 1 &&
|
497
545
|
h("div", { class: "ez-margin-top--extra-small" }, h("ez-breadcrumb", Object.assign({ items: this._breadcrumbItems, onSelectedItem: (evt) => this.onBreadcrumbClickHandler(evt === null || evt === void 0 ? void 0 : evt.detail) }, { [ElementIDUtils.DATA_ELEMENT_ID_ATTRIBUTE_NAME]: `${ElementIDUtils.getInternalIDInfo("breadcrumb")}` }))))), this.presentationMode != PresentationMode.SECONDARY && this.buildTaskBar()), h("div", { class: "snk-guides-viewer__container" }, showGuides ?
|
498
546
|
h("ez-guide-navigator", { ref: (ref) => this._guideNavigator = ref, class: "snk-guides-viewer__guide-navigator", items: this._guides, selectedId: this.selectedGuide ? this.selectedGuide.id : undefined, onEzSelectionChange: evt => this.updateSelectedGuideHandler(evt.detail) })
|
499
547
|
:
|
@@ -878,6 +926,26 @@ export class SnkGuidesViewer {
|
|
878
926
|
}
|
879
927
|
static get events() {
|
880
928
|
return [{
|
929
|
+
"method": "snkMasterFormConfigChange",
|
930
|
+
"name": "snkMasterFormConfigChange",
|
931
|
+
"bubbles": true,
|
932
|
+
"cancelable": true,
|
933
|
+
"composed": true,
|
934
|
+
"docs": {
|
935
|
+
"tags": [],
|
936
|
+
"text": "Emitido quando a configura\u00E7\u00E3o do formul\u00E1rio master \u00E9 definida."
|
937
|
+
},
|
938
|
+
"complexType": {
|
939
|
+
"original": "IFormConfig",
|
940
|
+
"resolved": "IFormConfig",
|
941
|
+
"references": {
|
942
|
+
"IFormConfig": {
|
943
|
+
"location": "import",
|
944
|
+
"path": "@sankhyalabs/ezui/dist/types/utils/form/interfaces"
|
945
|
+
}
|
946
|
+
}
|
947
|
+
}
|
948
|
+
}, {
|
881
949
|
"method": "exit",
|
882
950
|
"name": "exit",
|
883
951
|
"bubbles": true,
|
@@ -1097,3 +1165,9 @@ export class SnkGuidesViewer {
|
|
1097
1165
|
}];
|
1098
1166
|
}
|
1099
1167
|
}
|
1168
|
+
var TASKBAR_ID;
|
1169
|
+
(function (TASKBAR_ID) {
|
1170
|
+
TASKBAR_ID["FINISH_EDITION"] = "snkGuideViewer.finish_edition";
|
1171
|
+
TASKBAR_ID["MUTIPLE_EDITION"] = "snkGuideViewer.multiple_edition";
|
1172
|
+
TASKBAR_ID["REGULAR"] = "snkGuideViewer.regular";
|
1173
|
+
})(TASKBAR_ID || (TASKBAR_ID = {}));
|
@@ -0,0 +1,128 @@
|
|
1
|
+
const NO_TAB_NAME = "__NO_TAB_NAME__";
|
2
|
+
const MAIN_TAB_NAME = "__main";
|
3
|
+
export async function showConfirmMultipleUpdatePopup({ title, labelBtnConfirm, labelBtnCancel, message, changingFields, }) {
|
4
|
+
return new Promise((resolve) => {
|
5
|
+
const popup = builPopup(title, resolve);
|
6
|
+
const contentContainer = buildContentContainer();
|
7
|
+
contentContainer.appendChild(buildMessage(message));
|
8
|
+
contentContainer.appendChild(buildChangesContainer(changingFields));
|
9
|
+
const actionsContainer = buildActionsContainer();
|
10
|
+
actionsContainer.appendChild(buildCancelBtn(popup, labelBtnCancel, resolve));
|
11
|
+
actionsContainer.appendChild(buildConfirmBtn(popup, labelBtnConfirm, resolve));
|
12
|
+
contentContainer.appendChild(actionsContainer);
|
13
|
+
popup.appendChild(contentContainer);
|
14
|
+
document.body.appendChild(popup);
|
15
|
+
});
|
16
|
+
}
|
17
|
+
function groupChanges(changingFields) {
|
18
|
+
const changesMap = new Map();
|
19
|
+
changingFields.forEach(change => {
|
20
|
+
var _a;
|
21
|
+
const key = (_a = change.tabName) !== null && _a !== void 0 ? _a : NO_TAB_NAME;
|
22
|
+
if (!changesMap.has(key))
|
23
|
+
changesMap.set(key, []);
|
24
|
+
changesMap.get(key).push(change);
|
25
|
+
});
|
26
|
+
return changesMap;
|
27
|
+
}
|
28
|
+
function getTabName(tabName) {
|
29
|
+
switch (tabName) {
|
30
|
+
case NO_TAB_NAME:
|
31
|
+
return "";
|
32
|
+
case MAIN_TAB_NAME:
|
33
|
+
return "Principal";
|
34
|
+
default:
|
35
|
+
return tabName;
|
36
|
+
}
|
37
|
+
}
|
38
|
+
function buildChangesDiv(tabName, changes) {
|
39
|
+
const changeLabel = document.createElement('span');
|
40
|
+
changeLabel.innerText = getTabName(tabName);
|
41
|
+
changeLabel.style.display = 'block';
|
42
|
+
changeLabel.style.fontWeight = 'var(--text-weight--large, 500)';
|
43
|
+
changeLabel.style.fontSize = 'var(--text--medium, 14px)';
|
44
|
+
changeLabel.style.marginBottom = 'var(--space--small, 6px)';
|
45
|
+
const changeDiv = document.createElement('div');
|
46
|
+
changeDiv.style.padding = 'var(--space--medium, 12px) 0';
|
47
|
+
changeDiv.style.borderTop = '1px solid var(--color--disable-secondary, #f2f5f8)';
|
48
|
+
changeDiv.appendChild(changeLabel);
|
49
|
+
changes.forEach(change => {
|
50
|
+
const changeLine = document.createElement('span');
|
51
|
+
changeLine.innerHTML = `${change.label}: <span style="color: var(--text--primary, #626e82)">${change.value}</span>`;
|
52
|
+
changeLine.style.display = 'block';
|
53
|
+
changeLine.style.marginBottom = 'var(--space--extra-small, 3px)';
|
54
|
+
changeDiv.appendChild(changeLine);
|
55
|
+
});
|
56
|
+
return changeDiv;
|
57
|
+
}
|
58
|
+
function buildChangesContainer(changingFields) {
|
59
|
+
const changesContainer = document.createElement('div');
|
60
|
+
changesContainer.style.flexDirection = 'column';
|
61
|
+
changesContainer.style.display = 'flex';
|
62
|
+
changesContainer.style.overflow = 'auto';
|
63
|
+
changesContainer.style.maxHeight = '300px';
|
64
|
+
const changesMap = groupChanges(changingFields);
|
65
|
+
changesMap.forEach((changes, key) => {
|
66
|
+
changesContainer.appendChild(buildChangesDiv(key, changes));
|
67
|
+
});
|
68
|
+
return changesContainer;
|
69
|
+
}
|
70
|
+
function buildMessage(messageContent) {
|
71
|
+
const message = document.createElement('p');
|
72
|
+
message.textContent = messageContent;
|
73
|
+
message.style.fontSize = 'var(--text--medium, 14px)';
|
74
|
+
return message;
|
75
|
+
}
|
76
|
+
function buildContentContainer() {
|
77
|
+
const contentContainer = document.createElement('div');
|
78
|
+
contentContainer.style.display = 'flex';
|
79
|
+
contentContainer.style.flexDirection = 'column';
|
80
|
+
contentContainer.style.fontFamily = 'var(--font-pattern, Roboto)';
|
81
|
+
contentContainer.style.fontSize = 'var(--text--medium, 14px)';
|
82
|
+
return contentContainer;
|
83
|
+
}
|
84
|
+
function buildActionsContainer() {
|
85
|
+
const actionsContainer = document.createElement('div');
|
86
|
+
actionsContainer.style.display = 'flex';
|
87
|
+
actionsContainer.style.flexDirection = 'row';
|
88
|
+
actionsContainer.style.justifyContent = 'flex-end';
|
89
|
+
actionsContainer.style.gap = '5px';
|
90
|
+
return actionsContainer;
|
91
|
+
}
|
92
|
+
function builPopup(title, resolve) {
|
93
|
+
const popup = document.createElement('ez-popup');
|
94
|
+
popup.opened = true;
|
95
|
+
popup.size = 'small';
|
96
|
+
popup.ezTitle = title;
|
97
|
+
popup.heightMode = 'auto';
|
98
|
+
popup.addEventListener('ezClosePopup', () => {
|
99
|
+
document.body.removeChild(popup);
|
100
|
+
resolve(false);
|
101
|
+
}, { once: true });
|
102
|
+
popup.addEventListener('ezPopupAction', () => {
|
103
|
+
document.body.removeChild(popup);
|
104
|
+
resolve(false);
|
105
|
+
}, { once: true });
|
106
|
+
return popup;
|
107
|
+
}
|
108
|
+
function buildConfirmBtn(popup, confirmBtnLabel, resolve) {
|
109
|
+
const confirmBtn = document.createElement('ez-button');
|
110
|
+
confirmBtn.label = confirmBtnLabel;
|
111
|
+
confirmBtn.size = 'medium';
|
112
|
+
confirmBtn.classList.add('ez-button--primary');
|
113
|
+
confirmBtn.onclick = () => {
|
114
|
+
document.body.removeChild(popup);
|
115
|
+
resolve(true);
|
116
|
+
};
|
117
|
+
return confirmBtn;
|
118
|
+
}
|
119
|
+
function buildCancelBtn(popup, cancelBtnLabel, resolve) {
|
120
|
+
const cancelBtn = document.createElement('ez-button');
|
121
|
+
cancelBtn.label = cancelBtnLabel;
|
122
|
+
cancelBtn.size = 'medium';
|
123
|
+
cancelBtn.onclick = () => {
|
124
|
+
document.body.removeChild(popup);
|
125
|
+
resolve(false);
|
126
|
+
};
|
127
|
+
return cancelBtn;
|
128
|
+
}
|
@@ -1,11 +1,12 @@
|
|
1
|
-
import {
|
2
|
-
import { Action, ApplicationContext, DataUnitAction, ObjectUtils, StringUtils } from '@sankhyalabs/core';
|
1
|
+
import { h, Host } from '@stencil/core';
|
2
|
+
import { Action, ApplicationContext, DataUnitAction, ObjectUtils, StringUtils, } from '@sankhyalabs/core';
|
3
3
|
import { ApplicationUtils, DialogType } from '@sankhyalabs/ezui/dist/collection/utils';
|
4
4
|
import { OperationMap, SnkMessageBuilder } from '../../lib/message/SnkMessageBuilder';
|
5
5
|
import { DatasetStrategy } from '../../lib/http/data-fetcher/fetchers/data-unit/loadstrategy/DatasetStrategy';
|
6
6
|
import { getRecordValue } from '../../lib/dataUnit/ValueFormatter';
|
7
7
|
import { convertType } from '@sankhyalabs/core/dist/dataunit/metadata/DataType';
|
8
8
|
import { getSelectedRecordsIDsInfo } from '../../lib/utils/GetSelectedRecordsIDsInfo';
|
9
|
+
import { showConfirmMultipleUpdatePopup } from './MultipleUpdateHelper';
|
9
10
|
export class SnkDataUnit {
|
10
11
|
constructor() {
|
11
12
|
this._onDataUnitResolve = [];
|
@@ -14,6 +15,7 @@ export class SnkDataUnit {
|
|
14
15
|
this._fieldsWithRmPrecision = [];
|
15
16
|
this._metadataByRow = new Map();
|
16
17
|
this._rowMetadataCache = new Map();
|
18
|
+
this._formFieldsConfig = [];
|
17
19
|
this.REGEX_DATAUNIT_NAME = /dd:\/\/(.+?)\//;
|
18
20
|
this._dataUnitObserver = async (action) => {
|
19
21
|
const duState = await this.buildDataState(action.type);
|
@@ -92,6 +94,10 @@ export class SnkDataUnit {
|
|
92
94
|
this.messagesBuilderUpdated.emit(newValue);
|
93
95
|
}
|
94
96
|
}
|
97
|
+
onMasterFormConfigChange({ detail }) {
|
98
|
+
var _a;
|
99
|
+
this._formFieldsConfig = (_a = detail === null || detail === void 0 ? void 0 : detail.fields) !== null && _a !== void 0 ? _a : [];
|
100
|
+
}
|
95
101
|
/**
|
96
102
|
* Obtém o dataUnit.
|
97
103
|
*/
|
@@ -266,9 +272,13 @@ export class SnkDataUnit {
|
|
266
272
|
this._openedAlert = false;
|
267
273
|
}
|
268
274
|
async interceptSavingData(action) {
|
269
|
-
if (
|
270
|
-
|
275
|
+
if (this.dataUnit.isMultipleEdition) {
|
276
|
+
const confirm = await this.confirmMultipleSavingData();
|
277
|
+
if (!confirm)
|
278
|
+
return undefined;
|
271
279
|
}
|
280
|
+
if (!this.beforeSave)
|
281
|
+
return action;
|
272
282
|
const continueAction = this.beforeSave(this.dataUnit);
|
273
283
|
if (continueAction instanceof Promise) {
|
274
284
|
const result = await continueAction;
|
@@ -276,6 +286,46 @@ export class SnkDataUnit {
|
|
276
286
|
}
|
277
287
|
return continueAction ? action : undefined;
|
278
288
|
}
|
289
|
+
async confirmMultipleSavingData() {
|
290
|
+
const selectedRecords = this.dataUnit.getSelectionInfo().records;
|
291
|
+
const title = this.getMessage('snkDataUnit.multipleUpdateConfirmationTitle');
|
292
|
+
const message = this.getMessage('snkDataUnit.multipleUpdateConfirmationMessage', { size: selectedRecords.length });
|
293
|
+
const labelBtnCancel = this.getMessage('snkDataUnit.confirm.cancel');
|
294
|
+
const labelBtnConfirm = this.getMessage('snkDataUnit.confirm.updateMultipleConfirm');
|
295
|
+
return await showConfirmMultipleUpdatePopup({
|
296
|
+
title,
|
297
|
+
message,
|
298
|
+
labelBtnConfirm,
|
299
|
+
labelBtnCancel,
|
300
|
+
changingFields: this.getChangingFields(),
|
301
|
+
});
|
302
|
+
}
|
303
|
+
getChangingFields() {
|
304
|
+
const changes = this.dataUnit.buildChangesToSave();
|
305
|
+
if (!(changes === null || changes === void 0 ? void 0 : changes.length))
|
306
|
+
return [];
|
307
|
+
const change = changes[0];
|
308
|
+
const changingFields = Object.keys(change.updatingFields).map(key => this.buildChangingField(key, change[key]));
|
309
|
+
return changingFields;
|
310
|
+
}
|
311
|
+
buildChangingField(key, value) {
|
312
|
+
const fieldLabel = this.dataUnit.getField(key).label;
|
313
|
+
const formattedValue = this.dataUnit.getFormattedValue(key, value);
|
314
|
+
return {
|
315
|
+
label: fieldLabel,
|
316
|
+
value: formattedValue,
|
317
|
+
tabName: this.getFieldTabName(key),
|
318
|
+
};
|
319
|
+
}
|
320
|
+
getFieldTabName(fieldName) {
|
321
|
+
var _a;
|
322
|
+
const tab = (_a = this._formFieldsConfig.find(f => f.name === fieldName)) === null || _a === void 0 ? void 0 : _a.tab;
|
323
|
+
if (!tab)
|
324
|
+
return undefined;
|
325
|
+
if (typeof tab === 'string')
|
326
|
+
return tab;
|
327
|
+
return tab.label;
|
328
|
+
}
|
279
329
|
interceptDataSaved(action) {
|
280
330
|
if (this.afterSave) {
|
281
331
|
this.afterSave(this.dataUnit);
|
@@ -295,7 +345,17 @@ export class SnkDataUnit {
|
|
295
345
|
}
|
296
346
|
const cancelConfirmationTitle = this.getMessage("snkDataUnit.cancelConfirmationTitle");
|
297
347
|
const confirm = await ApplicationUtils.confirm(cancelConfirmationTitle, cancelConfirmation);
|
298
|
-
|
348
|
+
if (confirm) {
|
349
|
+
let editionCanceledMessage;
|
350
|
+
if (this.dataUnit.isMultipleEdition) {
|
351
|
+
const selectedRecords = this.dataUnit.getSelectionInfo().records;
|
352
|
+
editionCanceledMessage = this.buildMultipleUpdateMessage(selectedRecords, true);
|
353
|
+
}
|
354
|
+
else {
|
355
|
+
editionCanceledMessage = this.getMessage("snkDataUnit.cancelInfo");
|
356
|
+
}
|
357
|
+
this.showSuccessMessage(editionCanceledMessage);
|
358
|
+
}
|
299
359
|
return confirm ? action : undefined;
|
300
360
|
}
|
301
361
|
async interceptRemovingRecords(action) {
|
@@ -473,24 +533,50 @@ export class SnkDataUnit {
|
|
473
533
|
}
|
474
534
|
async handleDataSaved(action) {
|
475
535
|
var _a, _b, _c;
|
476
|
-
const
|
536
|
+
const changes = (_a = action === null || action === void 0 ? void 0 : action.payload) === null || _a === void 0 ? void 0 : _a.changes;
|
537
|
+
const affectedRecords = (_b = action === null || action === void 0 ? void 0 : action.payload) === null || _b === void 0 ? void 0 : _b.records;
|
538
|
+
const newRowMetadata = await this.handleLoadRowMetadata((_c = changes === null || changes === void 0 ? void 0 : changes[0]) === null || _c === void 0 ? void 0 : _c.record);
|
477
539
|
if (newRowMetadata) {
|
478
540
|
newRowMetadata.getProp = this.buildGetPropRowMetadata(newRowMetadata);
|
479
541
|
}
|
480
|
-
const recordId =
|
542
|
+
const recordId = affectedRecords[0].__record__id__;
|
481
543
|
this._metadataByRow.set(recordId, newRowMetadata);
|
482
544
|
this.dataState = await this.buildDataState();
|
483
|
-
let saveOperation =
|
484
|
-
if (saveOperation == 'copy')
|
545
|
+
let saveOperation = changes[0]._operation.toLowerCase();
|
546
|
+
if (saveOperation == 'copy') {
|
485
547
|
saveOperation = OperationMap.CLONE;
|
486
|
-
if (this.ignoreSaveMessage && ![OperationMap.CLONE, OperationMap.INSERT].includes(saveOperation)) {
|
487
|
-
return;
|
488
548
|
}
|
489
|
-
|
549
|
+
if (this.canIgnoreOperationMessage(saveOperation))
|
550
|
+
return;
|
551
|
+
let msg = this.buildOperationMessage(saveOperation, affectedRecords);
|
490
552
|
if (msg != undefined) {
|
491
553
|
this.showSuccessMessage(msg);
|
492
554
|
}
|
493
555
|
}
|
556
|
+
canIgnoreOperationMessage(saveOperation) {
|
557
|
+
return this.ignoreSaveMessage && !this.isCloneOrInsertOperation(saveOperation);
|
558
|
+
}
|
559
|
+
isCloneOrInsertOperation(saveOperation) {
|
560
|
+
return [OperationMap.CLONE, OperationMap.INSERT].includes(saveOperation);
|
561
|
+
}
|
562
|
+
buildOperationMessage(saveOperation, records) {
|
563
|
+
if (this.isMultiplesUpdate(saveOperation, records)) {
|
564
|
+
return this.buildMultipleUpdateMessage(records);
|
565
|
+
}
|
566
|
+
return this.getMessage('snkDataUnit.saveInfo', records[0], saveOperation);
|
567
|
+
}
|
568
|
+
buildMultipleUpdateMessage(records, isCancel) {
|
569
|
+
/**
|
570
|
+
* FIXME: No futuro, precisamos pensar em um mecanismo para deixar as mensagens de feedback mais dinâmicas.
|
571
|
+
* Podemo ocorrer cenários onde temos mais de um registro selecionado e também cenários onde a chave primária
|
572
|
+
* de um registro se trata de uma chave composta.
|
573
|
+
*/
|
574
|
+
const key = `snkDataUnit.${isCancel ? 'cancelInfo' : 'saveInfo'}`;
|
575
|
+
return this.getMessage(key, { records: records }, OperationMap.UPDATE_MULTIPLES);
|
576
|
+
}
|
577
|
+
isMultiplesUpdate(saveOperation, records) {
|
578
|
+
return saveOperation === OperationMap.UPDATE && records.length > 1;
|
579
|
+
}
|
494
580
|
handleRecordsRemoved(action) {
|
495
581
|
var _a, _b;
|
496
582
|
let removeFinishMsg = this.buildRemoveFinishMessage(action);
|
@@ -1156,6 +1242,15 @@ export class SnkDataUnit {
|
|
1156
1242
|
"methodName": "observeMessagesBuilder"
|
1157
1243
|
}];
|
1158
1244
|
}
|
1245
|
+
static get listeners() {
|
1246
|
+
return [{
|
1247
|
+
"name": "snkMasterFormConfigChange",
|
1248
|
+
"method": "onMasterFormConfigChange",
|
1249
|
+
"target": undefined,
|
1250
|
+
"capture": false,
|
1251
|
+
"passive": false
|
1252
|
+
}];
|
1253
|
+
}
|
1159
1254
|
}
|
1160
1255
|
class DataStateImpl {
|
1161
1256
|
constructor(datastate) {
|
@@ -15,11 +15,11 @@ export default class SnkMultiSelectionListDataSource {
|
|
15
15
|
}
|
16
16
|
return String(this._dataUnit.getFormattedValue(fieldName, value));
|
17
17
|
}
|
18
|
-
async getStaticOptions(fieldName) {
|
18
|
+
async getStaticOptions(fieldName, options) {
|
19
19
|
if (fieldName == undefined) {
|
20
20
|
return Promise.resolve(undefined);
|
21
21
|
}
|
22
|
-
return Promise.resolve(await PreloadManager.getDistinct(this._dataUnit, fieldName));
|
22
|
+
return Promise.resolve(await PreloadManager.getDistinct(this._dataUnit, fieldName, options === null || options === void 0 ? void 0 : options.onlyLabel));
|
23
23
|
}
|
24
24
|
fetchData(filterTerm, fieldName) {
|
25
25
|
return new Promise(resolve => {
|