@sankhyalabs/sankhyablocks 8.11.1 → 8.12.0-dev.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/{SnkFormConfigManager-906ee5f7.js → SnkFormConfigManager-467907f6.js} +21 -4
- package/dist/cjs/{SnkMessageBuilder-fbc33123.js → SnkMessageBuilder-7293d0ad.js} +9 -1
- package/dist/cjs/{taskbar-processor-bce3f499.js → field-search-ca27041a.js} +7 -0
- package/dist/cjs/loader.cjs.js +1 -1
- package/dist/cjs/sankhyablocks.cjs.js +1 -1
- package/dist/cjs/snk-application.cjs.entry.js +1 -1
- package/dist/cjs/snk-attach.cjs.entry.js +1 -1
- package/dist/cjs/snk-crud.cjs.entry.js +24 -0
- package/dist/cjs/snk-data-exporter.cjs.entry.js +2 -2
- package/dist/cjs/{snk-data-unit-04d76538.js → snk-data-unit-1bc69073.js} +1 -1
- package/dist/cjs/snk-data-unit.cjs.entry.js +2 -2
- package/dist/cjs/snk-detail-view.cjs.entry.js +4 -4
- package/dist/cjs/snk-form-view.cjs.entry.js +14 -0
- package/dist/cjs/snk-form.cjs.entry.js +1 -1
- package/dist/cjs/snk-grid.cjs.entry.js +52 -6
- package/dist/cjs/{snk-guides-viewer-5b82abc4.js → snk-guides-viewer-f94f2113.js} +78 -13
- package/dist/cjs/snk-guides-viewer.cjs.entry.js +3 -3
- package/dist/cjs/snk-simple-crud.cjs.entry.js +133 -6
- package/dist/collection/components/snk-attach/snk-attach.js +1 -1
- package/dist/collection/components/snk-crud/snk-crud.js +25 -1
- package/dist/collection/components/snk-crud/subcomponents/snk-form-view.js +45 -0
- package/dist/collection/components/snk-crud/subcomponents/snk-guides-viewer.js +98 -11
- package/dist/collection/components/snk-form/SnkFormConfigManager.js +22 -5
- package/dist/collection/components/snk-grid/snk-grid.js +69 -4
- package/dist/collection/components/snk-simple-crud/snk-simple-crud.js +136 -6
- package/dist/collection/components/snk-taskbar/snk-taskbar.js +1 -0
- package/dist/collection/components/snk-taskbar/subcomponents/field-search.js +4 -0
- package/dist/collection/lib/message/SnkMessageBuilder.js +2 -0
- package/dist/collection/lib/message/resources/snk-crud.msg.js +1 -0
- package/dist/collection/lib/message/resources/snk-grid.msg.js +3 -1
- package/dist/collection/lib/message/resources/snk-simple-crud.msg.js +4 -0
- package/dist/components/SnkFormConfigManager.js +22 -5
- package/dist/components/SnkMessageBuilder.js +9 -1
- package/dist/components/{SnkMultiSelectionListDataSource.js → field-search.js} +6 -1
- package/dist/components/snk-attach2.js +1 -1
- package/dist/components/snk-crud.js +25 -1
- package/dist/components/snk-detail-view2.js +80 -12
- package/dist/components/snk-form-view2.js +15 -0
- package/dist/components/snk-grid2.js +52 -5
- package/dist/components/snk-simple-crud2.js +135 -6
- package/dist/esm/{SnkFormConfigManager-8aedc650.js → SnkFormConfigManager-587e9030.js} +22 -5
- package/dist/esm/{SnkMessageBuilder-f60c5443.js → SnkMessageBuilder-ca843d1b.js} +9 -1
- package/dist/esm/{taskbar-processor-94402e6e.js → field-search-c6938ee4.js} +7 -1
- package/dist/esm/loader.js +1 -1
- package/dist/esm/sankhyablocks.js +1 -1
- package/dist/esm/snk-application.entry.js +1 -1
- package/dist/esm/snk-attach.entry.js +1 -1
- package/dist/esm/snk-crud.entry.js +25 -1
- package/dist/esm/snk-data-exporter.entry.js +2 -2
- package/dist/esm/{snk-data-unit-ad5cf70c.js → snk-data-unit-6208ebf0.js} +1 -1
- package/dist/esm/snk-data-unit.entry.js +2 -2
- package/dist/esm/snk-detail-view.entry.js +4 -4
- package/dist/esm/snk-form-view.entry.js +14 -0
- package/dist/esm/snk-form.entry.js +1 -1
- package/dist/esm/snk-grid.entry.js +51 -5
- package/dist/esm/{snk-guides-viewer-f68589c4.js → snk-guides-viewer-86171cf4.js} +77 -12
- package/dist/esm/snk-guides-viewer.entry.js +3 -3
- package/dist/esm/snk-simple-crud.entry.js +133 -6
- package/dist/sankhyablocks/p-03dcc5ff.entry.js +1 -0
- package/dist/sankhyablocks/p-2028633c.js +1 -0
- package/dist/sankhyablocks/{p-c8b1ebf1.entry.js → p-257feef3.entry.js} +2 -2
- package/dist/sankhyablocks/{p-a2bd1825.entry.js → p-2e963486.entry.js} +1 -1
- package/dist/sankhyablocks/{p-cd2a285d.js → p-32f0935f.js} +1 -1
- package/dist/sankhyablocks/{p-dc7412bf.entry.js → p-35fe6e61.entry.js} +1 -1
- package/dist/sankhyablocks/p-3ecd72a4.js +1 -0
- package/dist/sankhyablocks/p-4775a293.entry.js +1 -0
- package/dist/sankhyablocks/{p-787edf13.entry.js → p-50734e76.entry.js} +1 -1
- package/dist/sankhyablocks/p-50e18dee.entry.js +1 -0
- package/dist/sankhyablocks/p-672380c5.js +1 -0
- package/dist/sankhyablocks/{p-5de077f3.entry.js → p-729f5f5b.entry.js} +1 -1
- package/dist/sankhyablocks/p-d2666ae0.entry.js +1 -0
- package/dist/sankhyablocks/p-de56f563.entry.js +1 -0
- package/dist/sankhyablocks/p-f5059aa8.entry.js +1 -0
- package/dist/sankhyablocks/p-ff6064e7.js +1 -0
- package/dist/sankhyablocks/sankhyablocks.esm.js +1 -1
- package/dist/types/components/snk-crud/snk-crud.d.ts +3 -0
- package/dist/types/components/snk-crud/subcomponents/snk-form-view.d.ts +10 -1
- package/dist/types/components/snk-crud/subcomponents/snk-guides-viewer.d.ts +25 -1
- package/dist/types/components/snk-form/SnkFormConfigManager.d.ts +6 -1
- package/dist/types/components/snk-grid/snk-grid.d.ts +7 -0
- package/dist/types/components/snk-simple-crud/snk-simple-crud.d.ts +23 -2
- package/dist/types/components/snk-taskbar/snk-taskbar.d.ts +2 -3
- package/dist/types/components/snk-taskbar/subcomponents/field-search.d.ts +2 -0
- package/dist/types/components.d.ts +20 -0
- package/dist/types/lib/message/resources/snk-simple-crud.msg.d.ts +2 -0
- package/package.json +1 -1
- package/dist/sankhyablocks/p-152f0949.entry.js +0 -1
- package/dist/sankhyablocks/p-16eaa54b.entry.js +0 -1
- package/dist/sankhyablocks/p-74545be0.js +0 -1
- package/dist/sankhyablocks/p-86b9846a.entry.js +0 -1
- package/dist/sankhyablocks/p-9be1dfd5.entry.js +0 -1
- package/dist/sankhyablocks/p-aa3b0d19.js +0 -1
- package/dist/sankhyablocks/p-bceed094.js +0 -1
- package/dist/sankhyablocks/p-c2beb95c.js +0 -1
- package/dist/sankhyablocks/p-c555075c.entry.js +0 -1
- package/dist/sankhyablocks/p-cea081b7.entry.js +0 -1
@@ -2,9 +2,9 @@
|
|
2
2
|
|
3
3
|
const index = require('./index-f9e81701.js');
|
4
4
|
const core = require('@sankhyalabs/core');
|
5
|
-
const SnkFormConfigManager = require('./SnkFormConfigManager-
|
5
|
+
const SnkFormConfigManager = require('./SnkFormConfigManager-467907f6.js');
|
6
6
|
const form = require('@sankhyalabs/ezui/dist/collection/utils/form');
|
7
|
-
const
|
7
|
+
const fieldSearch = require('./field-search-ca27041a.js');
|
8
8
|
const taskbarElements = require('./taskbar-elements-39949c7a.js');
|
9
9
|
const constants = require('./constants-35ddd366.js');
|
10
10
|
require('./DataFetcher-ba94ed5b.js');
|
@@ -43,10 +43,12 @@ const SnkGuidesViewer = class {
|
|
43
43
|
this.presentationMode = undefined;
|
44
44
|
this.resourceID = undefined;
|
45
45
|
this.detailTaskbarCustomContainerId = undefined;
|
46
|
+
this._hasToCreateFieldSearch = true;
|
46
47
|
this._breadcrumbItems = [];
|
47
48
|
this._guides = undefined;
|
48
49
|
this._formEditorConfigManager = undefined;
|
49
50
|
this._formEditorDataUnit = undefined;
|
51
|
+
this._fieldToGetFocus = undefined;
|
50
52
|
}
|
51
53
|
observeDataUnit() {
|
52
54
|
this.loadGuides(true);
|
@@ -71,6 +73,23 @@ const SnkGuidesViewer = class {
|
|
71
73
|
this._formEditorConfigManager = masterConfig ? this._configManager : this._currentDetail.formConfigManager;
|
72
74
|
this._formEditorDataUnit = masterConfig ? this.dataUnit : this._currentDetail.dataUnit;
|
73
75
|
}
|
76
|
+
/**
|
77
|
+
* Abre o localizador de campos
|
78
|
+
*/
|
79
|
+
async findField() {
|
80
|
+
if (!this._moreOptions) {
|
81
|
+
return;
|
82
|
+
}
|
83
|
+
if (!(await this._moreOptions.isOpened())) {
|
84
|
+
this._moreOptions.showActions();
|
85
|
+
return;
|
86
|
+
}
|
87
|
+
if (this._fieldSearch) {
|
88
|
+
const realElement = this._fieldSearch["$elm$"];
|
89
|
+
realElement.value = null;
|
90
|
+
requestAnimationFrame(() => realElement.setFocus());
|
91
|
+
}
|
92
|
+
}
|
74
93
|
exitViewer() {
|
75
94
|
if (this.dataUnit.isDirty()) {
|
76
95
|
this.dataUnit.cancelEdition({ after: () => this.exit.emit() });
|
@@ -179,7 +198,7 @@ const SnkGuidesViewer = class {
|
|
179
198
|
btnsRegularMode.push("INSERT");
|
180
199
|
}
|
181
200
|
const invisibleButtons = this.getInvisibleButtons();
|
182
|
-
this._taskbarProcessor = new
|
201
|
+
this._taskbarProcessor = new fieldSearch.TaskbarProcessor({
|
183
202
|
"snkGuideViewer.regular": btnsRegularMode,
|
184
203
|
"snkGuideViewer.finish_edition": ["CANCEL", "SAVE"],
|
185
204
|
});
|
@@ -194,25 +213,26 @@ const SnkGuidesViewer = class {
|
|
194
213
|
static updateContentCard(formName, cardConfig, propertyChanged, configManager) {
|
195
214
|
return configManager.saveCardState(formName, cardConfig, propertyChanged);
|
196
215
|
}
|
197
|
-
static buildFixedForms(
|
198
|
-
|
216
|
+
static buildFixedForms(params) {
|
217
|
+
var _a;
|
218
|
+
const cardsState = (_a = params.formConfig) === null || _a === void 0 ? void 0 : _a.cardsState;
|
199
219
|
if (cardsState == undefined) {
|
200
220
|
return;
|
201
221
|
}
|
202
222
|
return (index.h(index.Fragment, null, Array.from(cardsState.entries())
|
203
|
-
.filter(([formName, cardConfig]) => (cardConfig === null || cardConfig === void 0 ? void 0 : cardConfig.fixed) && formName != selectedForm)
|
223
|
+
.filter(([formName, cardConfig]) => (cardConfig === null || cardConfig === void 0 ? void 0 : cardConfig.fixed) && formName != params.selectedForm)
|
204
224
|
.sort(([, cardConfigA], [, cardConfigB]) => {
|
205
225
|
const indexA = (cardConfigA === null || cardConfigA === void 0 ? void 0 : cardConfigA.fixSequence) || 0;
|
206
226
|
const indexB = (cardConfigB === null || cardConfigB === void 0 ? void 0 : cardConfigB.fixSequence) || 0;
|
207
227
|
return indexA - indexB;
|
208
228
|
})
|
209
229
|
.map(([formName, cardConfig]) => {
|
210
|
-
var _a;
|
211
|
-
const sheet = formMetadata.getSheet(formName);
|
230
|
+
var _a, _b;
|
231
|
+
const sheet = params.formMetadata.getSheet(formName);
|
212
232
|
if (sheet == undefined) {
|
213
233
|
return;
|
214
234
|
}
|
215
|
-
return index.h("snk-form-view", { levelPath: levelPath, label: sheet.label, name: formName, fields: sheet.fields, formMetadata: formMetadata, dataUnit: dataUnit, recordsValidator: recordsValidator, contracted: (cardConfig === null || cardConfig === void 0 ? void 0 : cardConfig.presentation) === "CONTRACTED", fixed: cardConfig === null || cardConfig === void 0 ? void 0 : cardConfig.fixed, summaryFields: (_a = formConfig === null ||
|
235
|
+
return index.h("snk-form-view", { levelPath: params.levelPath, label: sheet.label, name: formName, fields: sheet.fields, formMetadata: params.formMetadata, dataUnit: params.dataUnit, recordsValidator: params.recordsValidator, contracted: (cardConfig === null || cardConfig === void 0 ? void 0 : cardConfig.presentation) === "CONTRACTED", fixed: cardConfig === null || cardConfig === void 0 ? void 0 : cardConfig.fixed, summaryFields: (_b = (_a = params.formConfig) === null || _a === void 0 ? void 0 : _a.summary) === null || _b === void 0 ? void 0 : _b.get(formName), fieldToFocus: params.fieldToFocus, key: formName, onSnkRequestClearFieldToFocus: _ => { var _a; return (_a = params.onRequestClearFieldToFocus) === null || _a === void 0 ? void 0 : _a.call(params); } });
|
216
236
|
})));
|
217
237
|
}
|
218
238
|
wrapDetail(levels, content) {
|
@@ -261,7 +281,7 @@ const SnkGuidesViewer = class {
|
|
261
281
|
const sheet = this._masterFormMetadata.getSheet(cardId);
|
262
282
|
if (sheet) {
|
263
283
|
const cardConfig = (_c = (_b = this.masterFormConfig) === null || _b === void 0 ? void 0 : _b.cardsState) === null || _c === void 0 ? void 0 : _c.get(cardId);
|
264
|
-
content = index.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 == index$1.PresentationMode.SECONDARY && this.buildTaskBar());
|
284
|
+
content = index.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, fieldToFocus: this._fieldToGetFocus, key: guideId, onSnkRequestClearFieldToFocus: _ => this.clearFieldToFocusHandler() }, this.presentationMode == index$1.PresentationMode.SECONDARY && this.buildTaskBar());
|
265
285
|
}
|
266
286
|
}
|
267
287
|
return content;
|
@@ -280,6 +300,13 @@ const SnkGuidesViewer = class {
|
|
280
300
|
});
|
281
301
|
this.resetGuideBadge(currentItem);
|
282
302
|
}
|
303
|
+
changeGuideHandler(guideName) {
|
304
|
+
var _a;
|
305
|
+
(_a = this._guideNavigator) === null || _a === void 0 ? void 0 : _a.selectGuide(guideName);
|
306
|
+
}
|
307
|
+
clearFieldToFocusHandler() {
|
308
|
+
this._fieldToGetFocus = undefined;
|
309
|
+
}
|
283
310
|
resetGuideBadge(selectedGuide) {
|
284
311
|
var _a;
|
285
312
|
this._guides = [...(_a = this._guides) === null || _a === void 0 ? void 0 : _a.map(guide => {
|
@@ -345,11 +372,41 @@ const SnkGuidesViewer = class {
|
|
345
372
|
}
|
346
373
|
this._guideHasChanged = false;
|
347
374
|
}
|
375
|
+
getFieldsSearch(actionButton, item) {
|
376
|
+
if (this._fieldSearch == undefined || this._hasToCreateFieldSearch) {
|
377
|
+
this._hasToCreateFieldSearch = false;
|
378
|
+
this._moreOptions = actionButton;
|
379
|
+
actionButton.addEventListener("ezPopoverOpen", () => this.findField());
|
380
|
+
actionButton.addEventListener("ezDisconnectedActionButtons", () => this._hasToCreateFieldSearch = true);
|
381
|
+
this._fieldSearch = fieldSearch.buildFieldSearch(item, ({ argument }) => this.fieldsOptionLoader(argument), (option) => this.onSelectField(option, actionButton));
|
382
|
+
}
|
383
|
+
return this._fieldSearch;
|
384
|
+
}
|
385
|
+
fieldsOptionLoader(argument) {
|
386
|
+
return Promise.resolve(this._configManager.getFieldsList(this.dataUnit, argument)
|
387
|
+
.map(field => ({ value: field.name, label: field.label })));
|
388
|
+
}
|
389
|
+
onSelectField(option, actionButton) {
|
390
|
+
if (option == undefined) {
|
391
|
+
return;
|
392
|
+
}
|
393
|
+
this._fieldToGetFocus = option.value;
|
394
|
+
const fieldGuideName = this.getGuideName(option.value);
|
395
|
+
if (fieldGuideName !== this.selectedGuide.id) {
|
396
|
+
this.changeGuideHandler(fieldGuideName);
|
397
|
+
}
|
398
|
+
actionButton.hideActions();
|
399
|
+
}
|
348
400
|
getActionsList() {
|
401
|
+
const hardList = [{
|
402
|
+
value: "",
|
403
|
+
label: this.getMessage("snkCrud.findColumn"),
|
404
|
+
itemBuilder: (actionButton, item) => this.getFieldsSearch(actionButton, item)
|
405
|
+
}];
|
349
406
|
if (this.taskbarManager != undefined && this.taskbarManager.getMoreOptions != undefined) {
|
350
|
-
return this.taskbarManager.getMoreOptions(this.getTaskBarId(), this.configName, this.dataState, this.actionsList);
|
407
|
+
return hardList.concat(this.taskbarManager.getMoreOptions(this.getTaskBarId(), this.configName, this.dataState, this.actionsList));
|
351
408
|
}
|
352
|
-
return this.actionsList;
|
409
|
+
return hardList.concat(this.actionsList);
|
353
410
|
}
|
354
411
|
buildTaskBar() {
|
355
412
|
var _a;
|
@@ -416,7 +473,15 @@ const SnkGuidesViewer = class {
|
|
416
473
|
index.h("div", { class: "ez-margin-top--extra-small" }, index.h("ez-breadcrumb", Object.assign({ items: this._breadcrumbItems, onSelectedItem: (evt) => this.onBreadcrumbClickHandler(evt === null || evt === void 0 ? void 0 : evt.detail) }, { [core.ElementIDUtils.DATA_ELEMENT_ID_ATTRIBUTE_NAME]: `${core.ElementIDUtils.getInternalIDInfo("breadcrumb")}` }))))), this.presentationMode != index$1.PresentationMode.SECONDARY && this.buildTaskBar()), index.h("div", { class: "snk-guides-viewer__container" }, showGuides ?
|
417
474
|
index.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) })
|
418
475
|
:
|
419
|
-
index.h("div", null), index.h("div", { class: "snk-guides-viewer__detail-container" }, SnkGuidesViewer.buildFixedForms(
|
476
|
+
index.h("div", null), index.h("div", { class: "snk-guides-viewer__detail-container" }, SnkGuidesViewer.buildFixedForms({
|
477
|
+
formConfig: this.masterFormConfig,
|
478
|
+
formMetadata: this._masterFormMetadata,
|
479
|
+
selectedForm: (_b = this.selectedGuide) === null || _b === void 0 ? void 0 : _b.id,
|
480
|
+
dataUnit: this.dataUnit,
|
481
|
+
recordsValidator: this.recordsValidator,
|
482
|
+
fieldToFocus: this._fieldToGetFocus,
|
483
|
+
onRequestClearFieldToFocus: this.clearFieldToFocusHandler.bind(this)
|
484
|
+
}), this.getContent())), index.h("snk-configurator", { ref: (ref) => this._snkConfigurator = ref, viewMode: this.getConfigViewMode(), onConfigSelected: (evt) => this.changeConfigViewMode(evt.detail), messagesBuilder: this.messagesBuilder, onOpenConfig: (evt) => this.openConfig(evt.detail), resourceID: this.resourceID })));
|
420
485
|
}
|
421
486
|
static get watchers() { return {
|
422
487
|
"dataUnit": ["observeDataUnit"],
|
@@ -2,10 +2,10 @@
|
|
2
2
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
4
4
|
|
5
|
-
const snkGuidesViewer = require('./snk-guides-viewer-
|
5
|
+
const snkGuidesViewer = require('./snk-guides-viewer-f94f2113.js');
|
6
6
|
require('./index-f9e81701.js');
|
7
7
|
require('@sankhyalabs/core');
|
8
|
-
require('./SnkFormConfigManager-
|
8
|
+
require('./SnkFormConfigManager-467907f6.js');
|
9
9
|
require('./ConfigStorage-0d507a8f.js');
|
10
10
|
require('./form-config-fetcher-df043d3d.js');
|
11
11
|
require('./DataFetcher-ba94ed5b.js');
|
@@ -13,7 +13,7 @@ require('./PrintUtils-bcaeb82f.js');
|
|
13
13
|
require('@sankhyalabs/core/dist/dataunit/metadata/UnitMetadata');
|
14
14
|
require('./filter-item-type.enum-a7ffdaa6.js');
|
15
15
|
require('@sankhyalabs/ezui/dist/collection/utils/form');
|
16
|
-
require('./
|
16
|
+
require('./field-search-ca27041a.js');
|
17
17
|
require('./taskbar-elements-39949c7a.js');
|
18
18
|
require('./index-0e663819.js');
|
19
19
|
require('./index-102ba62d.js');
|
@@ -16,7 +16,7 @@ const dataunitFetcher = require('./dataunit-fetcher-529a3866.js');
|
|
16
16
|
require('./PreloadManager-84466da6.js');
|
17
17
|
require('./filter-item-type.enum-a7ffdaa6.js');
|
18
18
|
require('./form-config-fetcher-df043d3d.js');
|
19
|
-
const
|
19
|
+
const fieldSearch = require('./field-search-ca27041a.js');
|
20
20
|
const SnkMultiSelectionListDataSource = require('./SnkMultiSelectionListDataSource-ba5838c2.js');
|
21
21
|
require('./index-102ba62d.js');
|
22
22
|
require('./PrintUtils-bcaeb82f.js');
|
@@ -33,10 +33,11 @@ const SnkSimpleCrud = class {
|
|
33
33
|
this.dataUnitReady = index.createEvent(this, "dataUnitReady", 3);
|
34
34
|
this.actionClick = index.createEvent(this, "actionClick", 7);
|
35
35
|
this.formItemsReady = index.createEvent(this, "formItemsReady", 7);
|
36
|
-
this.REGULAR_DEFAULT_BTNS = ["INSERT", "REFRESH", "PREVIOUS", "NEXT", "DIVIDER"];
|
37
|
-
this.REGULAR_SELECTED_BTNS = ["INSERT", "REFRESH", "PREVIOUS", "NEXT", "DIVIDER", "CLONE", "REMOVE", "DIVIDER"];
|
36
|
+
this.REGULAR_DEFAULT_BTNS = ["INSERT", "REFRESH", "PREVIOUS", "NEXT", "DIVIDER", "MORE_OPTIONS"];
|
37
|
+
this.REGULAR_SELECTED_BTNS = ["INSERT", "REFRESH", "PREVIOUS", "NEXT", "DIVIDER", "CLONE", "REMOVE", "DIVIDER", "MORE_OPTIONS"];
|
38
38
|
this._multiSelectionListDataSource = new SnkMultiSelectionListDataSource.SnkMultiSelectionListDataSource();
|
39
|
-
this.
|
39
|
+
this._keyDownHandler = (event) => this.keyDownListener(event);
|
40
|
+
this._taskbarProcessor = new fieldSearch.TaskbarProcessor({
|
40
41
|
"snkSimpleCrudTaskbar.form_regular": this.resolveInMemoryBtns(this.REGULAR_DEFAULT_BTNS).concat(taskbarElements.TaskbarElement.GRID_MODE),
|
41
42
|
"snkSimpleCrudTaskbar.grid_regular": this.resolveInMemoryBtns(this.REGULAR_DEFAULT_BTNS).concat(taskbarElements.TaskbarElement.FORM_MODE),
|
42
43
|
"snkSimpleCrudTaskbar.form_selected": this.resolveInMemoryBtns(this.REGULAR_SELECTED_BTNS).concat(taskbarElements.TaskbarElement.GRID_MODE),
|
@@ -45,11 +46,13 @@ const SnkSimpleCrud = class {
|
|
45
46
|
});
|
46
47
|
this._currentViewMode = constants.VIEW_MODE.GRID;
|
47
48
|
this._config = undefined;
|
49
|
+
this._fieldToGetFocus = undefined;
|
48
50
|
this.dataState = undefined;
|
49
51
|
this.dataUnit = undefined;
|
50
52
|
this.mode = constants.SIMPLE_CRUD_MODE.SERVER;
|
51
53
|
this.gridConfig = undefined;
|
52
54
|
this.formConfig = undefined;
|
55
|
+
this._formFields = [];
|
53
56
|
this.multipleSelection = undefined;
|
54
57
|
this.useCancelConfirm = true;
|
55
58
|
this.taskbarManager = undefined;
|
@@ -197,11 +200,135 @@ const SnkSimpleCrud = class {
|
|
197
200
|
this.dataUnit.clearSelection();
|
198
201
|
}
|
199
202
|
}
|
203
|
+
getColumnSearch(actionButton, item) {
|
204
|
+
if (this._columnSearch != undefined) {
|
205
|
+
return this._columnSearch;
|
206
|
+
}
|
207
|
+
actionButton.addEventListener("ezPopoverOpen", () => {
|
208
|
+
if (this._columnSearch) {
|
209
|
+
const realElement = this._columnSearch["$elm$"];
|
210
|
+
realElement.value = null;
|
211
|
+
}
|
212
|
+
});
|
213
|
+
this._moreOptions = actionButton;
|
214
|
+
this._columnSearch = fieldSearch.buildFieldSearch(item, ({ argument }) => new Promise(accept => {
|
215
|
+
this._grid.filterColumns(argument).then((columns) => {
|
216
|
+
accept(columns
|
217
|
+
.filter(column => !column.hidden)
|
218
|
+
.map(column => ({ label: column.label, value: column.name })));
|
219
|
+
});
|
220
|
+
}), (option) => {
|
221
|
+
if (option != undefined) {
|
222
|
+
this._grid.locateColumn(option.value);
|
223
|
+
actionButton.hideActions();
|
224
|
+
}
|
225
|
+
});
|
226
|
+
return this._columnSearch;
|
227
|
+
}
|
228
|
+
onSelectField(option, actionButton) {
|
229
|
+
if (option == undefined) {
|
230
|
+
return;
|
231
|
+
}
|
232
|
+
this._fieldToGetFocus = option.value;
|
233
|
+
actionButton.hideActions();
|
234
|
+
}
|
235
|
+
getFieldSearch(actionButton, item) {
|
236
|
+
if (this._fieldSearch != undefined) {
|
237
|
+
return this._fieldSearch;
|
238
|
+
}
|
239
|
+
this._moreOptions = actionButton;
|
240
|
+
actionButton.addEventListener("ezPopoverOpen", () => this.findField());
|
241
|
+
this._fieldSearch = fieldSearch.buildFieldSearch(item, ({ argument }) => this.fieldsOptionLoader(argument), (option) => this.onSelectField(option, actionButton));
|
242
|
+
return this._fieldSearch;
|
243
|
+
}
|
244
|
+
getFormFields() {
|
245
|
+
var _a, _b;
|
246
|
+
return (_b = (_a = this.formConfig) === null || _a === void 0 ? void 0 : _a.fields) !== null && _b !== void 0 ? _b : this._formFields;
|
247
|
+
}
|
248
|
+
handleFormSetFields(fields) {
|
249
|
+
this._formFields = fields !== null && fields !== void 0 ? fields : [];
|
250
|
+
}
|
251
|
+
fieldsOptionLoader(argument) {
|
252
|
+
const searchTerm = argument === null || argument === void 0 ? void 0 : argument.toLowerCase();
|
253
|
+
const allFields = this.getFormFields().map(field => { var _a; return (_a = this.dataUnit) === null || _a === void 0 ? void 0 : _a.getField(field.name); });
|
254
|
+
const filteredFields = allFields.filter(field => {
|
255
|
+
var _a, _b;
|
256
|
+
return ((_a = field.name) === null || _a === void 0 ? void 0 : _a.toLowerCase().includes(searchTerm)) ||
|
257
|
+
((_b = field.label) === null || _b === void 0 ? void 0 : _b.toLowerCase().includes(searchTerm));
|
258
|
+
});
|
259
|
+
const options = filteredFields.map(field => ({ value: field.name, label: field.label }));
|
260
|
+
return Promise.resolve(options);
|
261
|
+
}
|
262
|
+
getActionsList() {
|
263
|
+
var _a, _b;
|
264
|
+
return [{
|
265
|
+
value: "",
|
266
|
+
label: (_b = (_a = this.messagesBuilder) === null || _a === void 0 ? void 0 : _a.getMessage("snkSimpleCrud.findColumn", undefined)) !== null && _b !== void 0 ? _b : "Buscar",
|
267
|
+
itemBuilder: (actionButton, item) => (this._currentViewMode === constants.VIEW_MODE.GRID)
|
268
|
+
? this.getColumnSearch(actionButton, item)
|
269
|
+
: this.getFieldSearch(actionButton, item)
|
270
|
+
}];
|
271
|
+
}
|
272
|
+
keyDownListener(event) {
|
273
|
+
if (!event.ctrlKey || event.key == undefined || event.key.toUpperCase() !== "F") {
|
274
|
+
return;
|
275
|
+
}
|
276
|
+
if (this._element == undefined) {
|
277
|
+
return;
|
278
|
+
}
|
279
|
+
if (core.JSUtils.isHiddenElement(this._element)) {
|
280
|
+
return;
|
281
|
+
}
|
282
|
+
core.FloatingManager.closeAll();
|
283
|
+
if (this._currentViewMode === constants.VIEW_MODE.GRID) {
|
284
|
+
this.findColumn();
|
285
|
+
}
|
286
|
+
else {
|
287
|
+
this.findField();
|
288
|
+
}
|
289
|
+
event.preventDefault();
|
290
|
+
}
|
291
|
+
async findField() {
|
292
|
+
if (!this._moreOptions) {
|
293
|
+
return;
|
294
|
+
}
|
295
|
+
if (!(await this._moreOptions.isOpened())) {
|
296
|
+
this._moreOptions.showActions();
|
297
|
+
return;
|
298
|
+
}
|
299
|
+
if (this._fieldSearch) {
|
300
|
+
const realElement = this._fieldSearch["$elm$"];
|
301
|
+
realElement.value = null;
|
302
|
+
requestAnimationFrame(() => realElement.setFocus());
|
303
|
+
}
|
304
|
+
}
|
305
|
+
async findColumn() {
|
306
|
+
if (!this._moreOptions) {
|
307
|
+
return;
|
308
|
+
}
|
309
|
+
if (!(await this._moreOptions.isOpened())) {
|
310
|
+
this._moreOptions.showActions();
|
311
|
+
}
|
312
|
+
if (this._columnSearch) {
|
313
|
+
const realElement = this._columnSearch["$elm$"];
|
314
|
+
realElement.value = null;
|
315
|
+
requestAnimationFrame(() => realElement.setFocus());
|
316
|
+
}
|
317
|
+
}
|
318
|
+
clearFieldToFocusHandler() {
|
319
|
+
this._fieldToGetFocus = undefined;
|
320
|
+
}
|
321
|
+
connectedCallback() {
|
322
|
+
window.addEventListener("keydown", this._keyDownHandler, { capture: true });
|
323
|
+
}
|
324
|
+
disconnectedCallback() {
|
325
|
+
window.removeEventListener("keydown", this._keyDownHandler);
|
326
|
+
}
|
200
327
|
render() {
|
201
328
|
var _a;
|
202
|
-
return (index.h("snk-data-unit", { class: "simple-crud__container", dataUnit: this.dataUnit, useCancelConfirm: this.useCancelConfirm, onDataStateChange: evt => this.onDataStateChange(evt), onCancelEdition: this.handleCancelEdit.bind(this), onInsertionMode: () => this.goToView(constants.VIEW_MODE.FORM), onDataUnitReady: (evt) => this.dataUnitReady.emit(evt.detail), ignoreSaveMessage: this._currentViewMode === constants.VIEW_MODE.GRID, onMessagesBuilderUpdated: evt => this.messagesBuilder = evt.detail }, index.h("header", null, index.h("slot", { name: "snkSimpleCrudHeader" })), index.h("section", { class: "ez-box ez-box--shadow simple-crud__container-section" }, index.h("snk-taskbar", { class: "ez-box ez-box--shadow ez-padding--medium ez-margin-bottom--large", dataUnit: this.dataUnit, primaryButton: ((_a = this.dataState) === null || _a === void 0 ? void 0 : _a.isDirty) ? "SAVE" : "INSERT", "data-element-id": "grid_left", messagesBuilder: this.messagesBuilder, buttons: this._taskbarProcessor.buttons, disabledButtons: this._taskbarProcessor.disabledButtons, customButtons: this._taskbarProcessor.customButtons, slot: "leftButtons", presentationMode: index$1.PresentationMode.SECONDARY }, index.h("slot", { name: "TASKBAR_CUSTOM_ELEMENTS" })), index.h("ez-view-stack", { ref: (ref) => this._viewStack = ref, "data-element-id": "simple-crud" }, index.h("stack-item", null, index.h("ez-grid", { dataUnit: this.dataUnit, config: this.gridConfig, "no-header": true, multipleSelection: this.multipleSelection, onEzDoubleClick: () => this.goToView(constants.VIEW_MODE.FORM), columnfilterDataSource: this.dataUnit.name.includes(dataunitFetcher.InMemoryLoader.IN_MEMORY_DATA_UNIT_NAME)
|
329
|
+
return (index.h("snk-data-unit", { class: "simple-crud__container", dataUnit: this.dataUnit, useCancelConfirm: this.useCancelConfirm, onDataStateChange: evt => this.onDataStateChange(evt), onCancelEdition: this.handleCancelEdit.bind(this), onInsertionMode: () => this.goToView(constants.VIEW_MODE.FORM), onDataUnitReady: (evt) => this.dataUnitReady.emit(evt.detail), ignoreSaveMessage: this._currentViewMode === constants.VIEW_MODE.GRID, onMessagesBuilderUpdated: evt => this.messagesBuilder = evt.detail }, index.h("header", null, index.h("slot", { name: "snkSimpleCrudHeader" })), index.h("section", { class: "ez-box ez-box--shadow simple-crud__container-section" }, index.h("snk-taskbar", { class: "ez-box ez-box--shadow ez-padding--medium ez-margin-bottom--large", dataUnit: this.dataUnit, primaryButton: ((_a = this.dataState) === null || _a === void 0 ? void 0 : _a.isDirty) ? "SAVE" : "INSERT", "data-element-id": "grid_left", messagesBuilder: this.messagesBuilder, buttons: this._taskbarProcessor.buttons, actionsList: this.getActionsList(), disabledButtons: this._taskbarProcessor.disabledButtons, customButtons: this._taskbarProcessor.customButtons, slot: "leftButtons", presentationMode: index$1.PresentationMode.SECONDARY }, index.h("slot", { name: "TASKBAR_CUSTOM_ELEMENTS" })), index.h("ez-view-stack", { ref: (ref) => this._viewStack = ref, "data-element-id": "simple-crud" }, index.h("stack-item", null, index.h("ez-grid", { ref: ref => this._grid = ref, dataUnit: this.dataUnit, config: this.gridConfig, "no-header": true, multipleSelection: this.multipleSelection, onEzDoubleClick: () => this.goToView(constants.VIEW_MODE.FORM), columnfilterDataSource: this.dataUnit.name.includes(dataunitFetcher.InMemoryLoader.IN_MEMORY_DATA_UNIT_NAME)
|
203
330
|
? undefined
|
204
|
-
: this._multiSelectionListDataSource, useEnterLikeTab: this.useEnterLikeTab }, index.h("div", { slot: "footer" }, index.h("slot", { name: "snkSimpleCrudFooter" })))), index.h("stack-item", null, index.h("ez-form", { dataUnit: this.dataUnit, config: this.formConfig }))))));
|
331
|
+
: this._multiSelectionListDataSource, useEnterLikeTab: this.useEnterLikeTab }, index.h("div", { slot: "footer" }, index.h("slot", { name: "snkSimpleCrudFooter" })))), index.h("stack-item", null, index.h("ez-form", { dataUnit: this.dataUnit, config: this.formConfig, fieldToFocus: this._fieldToGetFocus, onEzFormSetFields: (evt) => this.handleFormSetFields(evt.detail), onEzFormRequestClearFieldToFocus: this.clearFieldToFocusHandler.bind(this) }))))));
|
205
332
|
}
|
206
333
|
get _element() { return index.getElement(this); }
|
207
334
|
static get watchers() { return {
|
@@ -110,7 +110,7 @@ export class SnkAttach {
|
|
110
110
|
var _a, _b;
|
111
111
|
if (!this.dataUnit)
|
112
112
|
return null;
|
113
|
-
return (h("main", { class: "snk-attach__main" }, h("header", { class: "snk-attach__header" }, h("snk-simple-bar", { onExit: this.handleBack, messagesBuilder: this.messagesBuilder }, h("div", { slot: "rightSlot" }, h("ez-button", { class: "ez-button--primary", label: this.getMessage("snkAttach.finish"), onClick: this.handleFinish })))), h("div", { class: "snk-attach__crud-section ez-size-height--full ez-size-width--full ez-flex ez-flex--column" }, h("div", { class: "ez-box__container" }, h("snk-simple-crud", { ref: (el) => this._crudElement = el, dataUnit: this.dataUnit, taskbarManager: buildTaskBarManager(), gridConfig: (_a = this.crudConfig) === null || _a === void 0 ? void 0 : _a.grid, formConfig: (_b = this.crudConfig) === null || _b === void 0 ? void 0 : _b.form, useCancelConfirm: false, onActionClick: this.handleTaskbarClick }, h("div", { slot: "snkSimpleCrudHeader" }, h("div", { class: "ez-flex ez-flex--column" }, h("span", { class: "ez-title--primary ez-text ez-text--large ez-text--bold ez-padding-bottom--medium" }, this.getMessage("snkAttach.title")), h("span", { class: "ez-text ez-text--medium ez-text--secondary" }, this.getMessage("snkAttach.description")))))))));
|
113
|
+
return (h("main", { class: "snk-attach__main" }, h("header", { class: "snk-attach__header" }, h("snk-simple-bar", { onExit: this.handleBack, messagesBuilder: this.messagesBuilder }, h("div", { slot: "rightSlot" }, h("ez-button", { class: "ez-button--primary", label: this.getMessage("snkAttach.finish"), onClick: this.handleFinish })))), h("div", { class: "snk-attach__crud-section ez-size-height--full ez-size-width--full ez-flex ez-flex--column" }, h("div", { class: "ez-box__container" }, h("snk-simple-crud", { ref: (el) => this._crudElement = el, dataUnit: this.dataUnit, taskbarManager: buildTaskBarManager(), gridConfig: (_a = this.crudConfig) === null || _a === void 0 ? void 0 : _a.grid, formConfig: (_b = this.crudConfig) === null || _b === void 0 ? void 0 : _b.form, useCancelConfirm: false, onActionClick: this.handleTaskbarClick, messagesBuilder: this.messagesBuilder }, h("div", { slot: "snkSimpleCrudHeader" }, h("div", { class: "ez-flex ez-flex--column" }, h("span", { class: "ez-title--primary ez-text ez-text--large ez-text--bold ez-padding-bottom--medium" }, this.getMessage("snkAttach.title")), h("span", { class: "ez-text ez-text--medium ez-text--secondary" }, this.getMessage("snkAttach.description")))))))));
|
114
114
|
}
|
115
115
|
static get is() { return "snk-attach"; }
|
116
116
|
static get encapsulation() { return "scoped"; }
|
@@ -1,5 +1,5 @@
|
|
1
1
|
import { h, Host } from '@stencil/core';
|
2
|
-
import { ApplicationContext, ElementIDUtils, StringUtils } from '@sankhyalabs/core';
|
2
|
+
import { ApplicationContext, ElementIDUtils, FloatingManager, StringUtils, JSUtils } from '@sankhyalabs/core';
|
3
3
|
import { TaskbarElement } from '../snk-taskbar/elements/taskbar-elements';
|
4
4
|
import { PresentationMode } from '../../lib';
|
5
5
|
import { VIEW_MODE } from '../../lib/utils/constants';
|
@@ -11,6 +11,7 @@ import { AutorizationType } from '../../lib/http/data-fetcher/fetchers/auth-fetc
|
|
11
11
|
*/
|
12
12
|
export class SnkCrud {
|
13
13
|
constructor() {
|
14
|
+
this._keyDownHandler = (event) => this.keyDownListener(event);
|
14
15
|
this._viewHistory = [];
|
15
16
|
this._dataUnit = undefined;
|
16
17
|
this._dataState = undefined;
|
@@ -158,6 +159,7 @@ export class SnkCrud {
|
|
158
159
|
}
|
159
160
|
disconnectedCallback() {
|
160
161
|
this.removeShortcuts();
|
162
|
+
window.removeEventListener("keydown", this._keyDownHandler);
|
161
163
|
}
|
162
164
|
async initKeyboardManager() {
|
163
165
|
const keyboardManager = await this._application.getKeyboardManager();
|
@@ -236,6 +238,28 @@ export class SnkCrud {
|
|
236
238
|
}
|
237
239
|
this.configuratorCancel.emit();
|
238
240
|
}
|
241
|
+
keyDownListener(event) {
|
242
|
+
if (!event.ctrlKey || event.key == undefined || event.key.toUpperCase() !== "F") {
|
243
|
+
return;
|
244
|
+
}
|
245
|
+
if (this._element == undefined) {
|
246
|
+
return;
|
247
|
+
}
|
248
|
+
if (JSUtils.isHiddenElement(this._element)) {
|
249
|
+
return;
|
250
|
+
}
|
251
|
+
FloatingManager.closeAll();
|
252
|
+
if (this._currentViewMode === VIEW_MODE.GRID) {
|
253
|
+
this._snkGrid.findColumn();
|
254
|
+
}
|
255
|
+
else {
|
256
|
+
this._guidesViewer.findField();
|
257
|
+
}
|
258
|
+
event.preventDefault();
|
259
|
+
}
|
260
|
+
connectedCallback() {
|
261
|
+
window.addEventListener("keydown", this._keyDownHandler, { capture: true });
|
262
|
+
}
|
239
263
|
render() {
|
240
264
|
if (this._resourceID == undefined) {
|
241
265
|
return;
|
@@ -15,6 +15,7 @@ export class SnkFormView {
|
|
15
15
|
this.canExpand = true;
|
16
16
|
this.canFix = true;
|
17
17
|
this.recordsValidator = undefined;
|
18
|
+
this.fieldToFocus = undefined;
|
18
19
|
}
|
19
20
|
async showUp() {
|
20
21
|
if (this._formView) {
|
@@ -79,6 +80,18 @@ export class SnkFormView {
|
|
79
80
|
this._dataBinder.onDisconnectedCallback();
|
80
81
|
}
|
81
82
|
}
|
83
|
+
componentDidRender() {
|
84
|
+
if (this.fieldToFocus == undefined) {
|
85
|
+
return;
|
86
|
+
}
|
87
|
+
if (!this.fields.some(item => item.name === this.fieldToFocus)) {
|
88
|
+
return;
|
89
|
+
}
|
90
|
+
requestAnimationFrame(() => {
|
91
|
+
this._dataBinder.setFocus(this.fieldToFocus);
|
92
|
+
this.snkRequestClearFieldToFocus.emit();
|
93
|
+
});
|
94
|
+
}
|
82
95
|
render() {
|
83
96
|
return (h(Host, { class: "ez-box__container" }, h("div", { class: "summary-header ez-flex ez-size-width--full" }, h("div", { class: "ez-flex ez-text ez-title--primary ez-text--bold ez-flex--justify-start ez-flex--align-items-center ez-col--sd-9" }, this.levelPath ? h("span", { class: "level-path" }, this.levelPath + " /") : undefined, this.label), h("div", { class: "ez-flex ez-flex--justify-end ez-col--sd-3" }, this.canFix &&
|
84
97
|
h("ez-button", { class: "ez-padding-left--medium", mode: "icon", size: "small", iconName: this.fixed ? "un-pin" : "push-pin", "data-element-id": ElementIDUtils.getInternalIDInfo("toggleFixed_ezFormCard"), onClick: () => this.changeFix(), title: this.fixed ? "Desafixar" : "Fixar" }), this.canExpand &&
|
@@ -331,6 +344,23 @@ export class SnkFormView {
|
|
331
344
|
"tags": [],
|
332
345
|
"text": "Validador respons\u00E1vel por checar a integridade das informa\u00E7\u00F5es do registro."
|
333
346
|
}
|
347
|
+
},
|
348
|
+
"fieldToFocus": {
|
349
|
+
"type": "string",
|
350
|
+
"mutable": false,
|
351
|
+
"complexType": {
|
352
|
+
"original": "string",
|
353
|
+
"resolved": "string",
|
354
|
+
"references": {}
|
355
|
+
},
|
356
|
+
"required": false,
|
357
|
+
"optional": false,
|
358
|
+
"docs": {
|
359
|
+
"tags": [],
|
360
|
+
"text": "Determina o campo que deve ficar em evid\u00EAncia."
|
361
|
+
},
|
362
|
+
"attribute": "field-to-focus",
|
363
|
+
"reflect": false
|
334
364
|
}
|
335
365
|
};
|
336
366
|
}
|
@@ -355,6 +385,21 @@ export class SnkFormView {
|
|
355
385
|
}
|
356
386
|
}
|
357
387
|
}
|
388
|
+
}, {
|
389
|
+
"method": "snkRequestClearFieldToFocus",
|
390
|
+
"name": "snkRequestClearFieldToFocus",
|
391
|
+
"bubbles": true,
|
392
|
+
"cancelable": true,
|
393
|
+
"composed": true,
|
394
|
+
"docs": {
|
395
|
+
"tags": [],
|
396
|
+
"text": "Emitido quando o campo recebe foco"
|
397
|
+
},
|
398
|
+
"complexType": {
|
399
|
+
"original": "void",
|
400
|
+
"resolved": "void",
|
401
|
+
"references": {}
|
402
|
+
}
|
358
403
|
}, {
|
359
404
|
"method": "formItemsReady",
|
360
405
|
"name": "formItemsReady",
|