@sankhyalabs/ezui 1.1.130 → 1.1.133
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/ez-form.cjs.entry.js +14 -3
- package/dist/cjs/ez-grid.cjs.entry.js +215 -51
- package/dist/cjs/ez-list.cjs.entry.js +11 -0
- package/dist/cjs/ez-modal.cjs.entry.js +6 -0
- package/dist/cjs/ez-number-input.cjs.entry.js +1 -1
- package/dist/cjs/ez-text-input.cjs.entry.js +10 -8
- package/dist/cjs/ezui.cjs.js +1 -1
- package/dist/cjs/grid-config.cjs.entry.js +44 -2
- package/dist/cjs/loader.cjs.js +1 -1
- package/dist/collection/components/ez-form/DataBinder.js +13 -2
- package/dist/collection/components/ez-form/ez-form.js +1 -1
- package/dist/collection/components/ez-grid/controller/DataUnitBridge.js +10 -5
- package/dist/collection/components/ez-grid/controller/ag-grid/AgGridController.js +128 -36
- package/dist/collection/components/ez-grid/ez-grid.js +253 -15
- package/dist/collection/components/ez-grid/subcomponents/gridconfig/grid-config.js +44 -2
- package/dist/collection/components/ez-list/ez-list.js +27 -0
- package/dist/collection/components/ez-modal/ez-modal.js +20 -0
- package/dist/collection/components/ez-number-input/ez-number-input.js +1 -1
- package/dist/collection/components/ez-text-input/ez-text-input.js +10 -8
- package/dist/collection/utils/interfaces/PageableComponent.js +1 -0
- package/dist/custom-elements/index.js +302 -67
- package/dist/esm/ez-form.entry.js +14 -3
- package/dist/esm/ez-grid.entry.js +216 -52
- package/dist/esm/ez-list.entry.js +11 -0
- package/dist/esm/ez-modal.entry.js +6 -0
- package/dist/esm/ez-number-input.entry.js +1 -1
- package/dist/esm/ez-text-input.entry.js +10 -8
- package/dist/esm/ezui.js +1 -1
- package/dist/esm/grid-config.entry.js +44 -2
- package/dist/esm/loader.js +1 -1
- package/dist/ezui/ezui.esm.js +1 -1
- package/dist/ezui/p-48ba92b2.entry.js +1 -0
- package/dist/ezui/p-4ded39c2.entry.js +1 -0
- package/dist/ezui/{p-2d165ca8.entry.js → p-80d863c2.entry.js} +7 -7
- package/dist/ezui/p-c8f9b691.entry.js +1 -0
- package/dist/ezui/{p-47fe4273.entry.js → p-cfa7378a.entry.js} +1 -1
- package/dist/ezui/p-d5c93280.entry.js +1 -0
- package/dist/ezui/p-d9bb2a96.entry.js +1 -0
- package/dist/types/components/ez-grid/controller/EzGridController.d.ts +46 -0
- package/dist/types/components/ez-grid/controller/ag-grid/AgGridController.d.ts +12 -0
- package/dist/types/components/ez-grid/ez-grid.d.ts +45 -4
- package/dist/types/components/ez-grid/subcomponents/gridconfig/grid-config.d.ts +1 -0
- package/dist/types/components/ez-list/ez-list.d.ts +4 -0
- package/dist/types/components/ez-modal/ez-modal.d.ts +5 -0
- package/dist/types/components.d.ts +49 -0
- package/dist/types/utils/interfaces/PageableComponent.d.ts +12 -0
- package/package.json +1 -1
- package/dist/ezui/p-6d39b7ea.entry.js +0 -1
- package/dist/ezui/p-7d5b2ebf.entry.js +0 -1
- package/dist/ezui/p-c6b2b2e5.entry.js +0 -1
- package/dist/ezui/p-ef8f1275.entry.js +0 -1
- package/dist/ezui/p-f65302bb.entry.js +0 -1
|
@@ -5,6 +5,7 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
5
5
|
const index = require('./index-0e284e03.js');
|
|
6
6
|
const core = require('@sankhyalabs/core');
|
|
7
7
|
const AssetsUtils = require('./AssetsUtils-78164781.js');
|
|
8
|
+
const ApplicationUtils = require('./ApplicationUtils-4a223c7a.js');
|
|
8
9
|
|
|
9
10
|
const gridConfigCss = ".sc-grid-config-h{--ez-grid-config__footer--padding-top:var(--space--medium, 12px);--ez-grid-config__main--padding-right:var(--space--medium, 12px);--ez-grid-config__tabselector-container--padding:var(--space--medium, 12px);--ez-grid-config__button-close--padding-left:var(--space--medium, 12px);--ez-grid-config__subtitle--font-family:var(--font-pattern, \"Sora\");--ez-grid-config__title--font-family:var(--font-pattern, \"Sora\");--ez-grid-config__title--font-weight:var(--text-weight--large, 700);--ez-grid-config__subtitle--font-size:var(--text--medium, 14px);--ez-grid-config__scrollbar--width:var(--space--medium, 12px);--ez-grid-config__main__scrollbar--background-color:var(--text--primary, #626e82);--ez-grid-config__main__scrollbar--border-radius:var(--border--radius-medium, 12px);--ez-grid__group--font-family:var(--font-pattern, \"Sora\");--ez-grid__group--font-size:var(--text--medium, 14px);--ez-grid__group--font-weight:var(--text-weight--large, 600);--ez-grid__group--padding-bottom:var(--space-small, 6px);display:grid;grid-template-rows:auto 1fr auto;max-height:100%;width:100%}.padding-right--medium.sc-grid-config{padding-right:var(--space--medium)}ez-list.sc-grid-config{height:100%}.heigth-calc.sc-grid-config{max-height:calc(100% - 24px)}.grid-config__footer.sc-grid-config{padding-top:var(--ez-grid-config__footer--padding-top);display:flex;justify-content:flex-end;width:100%}.hidden.sc-grid-config{display:none}.grid-config__main.sc-grid-config{padding-right:var(--ez-grid-config__main--padding-right);overflow-y:auto}.tabselector-container.sc-grid-config{padding:var(--ez-grid-config__tabselector-container--padding) 0}.button-close.sc-grid-config{padding-left:var(--ez-grid-config__button-close--padding-left)}.title-container.sc-grid-config{display:flex;justify-content:space-between;align-items:center;width:359px}.subtitle.sc-grid-config{font-family:var(--ez-grid-config__subtitle--font-family);font-size:var(--ez-grid-config__subtitle--font-size);color:var(--text--primary)}.title.sc-grid-config{display:flex;margin:0;font-family:var(--ez-grid-config__title--font-family);font-size:var(--title--large);font-weight:var(--ez-grid-config__title--font-weight);line-height:normal;letter-spacing:0em;text-align:left;color:var(--title--primary)}.grid-config__main.sc-grid-config::-webkit-scrollbar-track{background-color:#f0f2f5}.grid-config__main.sc-grid-config::-webkit-scrollbar-thumb{background-color:var(--ez-grid-config__main__scrollbar--background-color);border-radius:var(--ez-grid-config__main__scrollbar--border-radius)}.grid-config__main.sc-grid-config::-webkit-scrollbar{background-color:#f0f2f5;width:var(--ez-grid-config__scrollbar--width);max-width:var(--ez-grid-config__scrollbar--width);min-width:var(--ez-grid-config__scrollbar--width)}.group-name.sc-grid-config{font-family:var(--ez-grid__group--font-family);font-size:var(--ez-grid__group--font-size);font-weight:var(--ez-grid__group--font-weight);padding-bottom:var(--ez-grid__group--padding-bottom)}";
|
|
10
11
|
|
|
@@ -17,6 +18,7 @@ let GridConfig = class {
|
|
|
17
18
|
this._orderPriorityList = [];
|
|
18
19
|
this._columListItems = [];
|
|
19
20
|
this._selectedIndex = -1;
|
|
21
|
+
this._dataChanged = false;
|
|
20
22
|
this.selectedTab = "Colunas";
|
|
21
23
|
}
|
|
22
24
|
/* Creation Methods */
|
|
@@ -92,6 +94,7 @@ let GridConfig = class {
|
|
|
92
94
|
}
|
|
93
95
|
updateOrder(sortOrder, updatedItemLabel) {
|
|
94
96
|
var _a;
|
|
97
|
+
this._dataChanged = true;
|
|
95
98
|
let newList = [...this.columns];
|
|
96
99
|
let newItem = newList.find(item => item.label === updatedItemLabel);
|
|
97
100
|
if (newItem) {
|
|
@@ -120,6 +123,7 @@ let GridConfig = class {
|
|
|
120
123
|
switchColumnGroup(ev, switchedItem) {
|
|
121
124
|
ev.stopPropagation();
|
|
122
125
|
let newList = [...this._columListItems];
|
|
126
|
+
this._dataChanged = true;
|
|
123
127
|
if (ev.detail === true) {
|
|
124
128
|
let hiddenGroup = newList.find(group => group.group === "Ocultas");
|
|
125
129
|
let index = hiddenGroup.items.findIndex(item => item.label === switchedItem.label);
|
|
@@ -159,6 +163,9 @@ let GridConfig = class {
|
|
|
159
163
|
});
|
|
160
164
|
});
|
|
161
165
|
this.columns = newColumnList;
|
|
166
|
+
this._dataChanged = false;
|
|
167
|
+
this.closeConfig();
|
|
168
|
+
ApplicationUtils.ApplicationUtils.info("As configurações foram salvas com sucesso!");
|
|
162
169
|
this.save();
|
|
163
170
|
}
|
|
164
171
|
save() {
|
|
@@ -341,13 +348,46 @@ let GridConfig = class {
|
|
|
341
348
|
return false;
|
|
342
349
|
}
|
|
343
350
|
closeConfig() {
|
|
344
|
-
this.
|
|
345
|
-
this.
|
|
351
|
+
this._orderList.scrollToTop();
|
|
352
|
+
this._columnList.scrollToTop();
|
|
353
|
+
this._searchElement.value = "";
|
|
354
|
+
if (this._dataChanged) {
|
|
355
|
+
let options = {
|
|
356
|
+
canClose: false,
|
|
357
|
+
labelCancel: "Descartar",
|
|
358
|
+
labelConfirm: "Salvar",
|
|
359
|
+
btnConfirmDanger: false
|
|
360
|
+
};
|
|
361
|
+
ApplicationUtils.ApplicationUtils.confirm("Aviso", "As alterações realizadas serão descartadas. Gostaria de salvar antes de sair?", null, false, options)
|
|
362
|
+
.then(response => {
|
|
363
|
+
if (!response) {
|
|
364
|
+
this._dataChanged = false;
|
|
365
|
+
this.configCancel.emit();
|
|
366
|
+
this._orderList.clearHistory();
|
|
367
|
+
}
|
|
368
|
+
else {
|
|
369
|
+
this.finish();
|
|
370
|
+
}
|
|
371
|
+
});
|
|
372
|
+
}
|
|
373
|
+
else {
|
|
374
|
+
this.configCancel.emit();
|
|
375
|
+
this._orderList.clearHistory();
|
|
376
|
+
}
|
|
346
377
|
}
|
|
347
378
|
/* Handlers */
|
|
348
379
|
handleTabChange(ev) {
|
|
349
380
|
var _a;
|
|
350
381
|
if ((_a = ev === null || ev === void 0 ? void 0 : ev.target) === null || _a === void 0 ? void 0 : _a.selectedTab) {
|
|
382
|
+
if (this.selectedTab !== ev.target.selectedTab) {
|
|
383
|
+
if (ev.target.selectedTab === "Colunas") {
|
|
384
|
+
this._orderList.scrollToTop();
|
|
385
|
+
}
|
|
386
|
+
else if (ev.target.selectedTab === "Ordenação das linhas") {
|
|
387
|
+
this._columnList.scrollToTop();
|
|
388
|
+
}
|
|
389
|
+
this._searchElement.value = "";
|
|
390
|
+
}
|
|
351
391
|
if (ev.target.selectedTab === "Ordenação das linhas") {
|
|
352
392
|
this.createOrderList();
|
|
353
393
|
}
|
|
@@ -359,6 +399,7 @@ let GridConfig = class {
|
|
|
359
399
|
if (ev.detail) {
|
|
360
400
|
let visibleItems = (_a = ev.detail.find(group => group.group === "Visíveis")) === null || _a === void 0 ? void 0 : _a.items;
|
|
361
401
|
if (visibleItems) {
|
|
402
|
+
this._dataChanged = true;
|
|
362
403
|
this._orderListItems = visibleItems;
|
|
363
404
|
}
|
|
364
405
|
}
|
|
@@ -367,6 +408,7 @@ let GridConfig = class {
|
|
|
367
408
|
if (ev.detail) {
|
|
368
409
|
let orderPriorityList = ev.detail;
|
|
369
410
|
if (orderPriorityList) {
|
|
411
|
+
this._dataChanged = true;
|
|
370
412
|
this._orderPriorityList = orderPriorityList;
|
|
371
413
|
}
|
|
372
414
|
}
|
package/dist/cjs/loader.cjs.js
CHANGED
|
@@ -14,7 +14,7 @@ const patchEsm = () => {
|
|
|
14
14
|
const defineCustomElements = (win, options) => {
|
|
15
15
|
if (typeof window === 'undefined') return Promise.resolve();
|
|
16
16
|
return patchEsm().then(() => {
|
|
17
|
-
return index.bootstrapLazy([["ez-grid.cjs",[[6,"ez-grid",{"multipleSelection":[4,"multiple-selection"],"config":[1040],"pageSize":[2,"page-size"],"serverUrl":[1,"server-url"],"dataUnit":[16],"_navigationHasPrevious":[32],"_navigationHasNext":[32],"_navigationFirstRow":[32],"_navigationLastRow":[32],"_navigationTotalRows":[32],"
|
|
17
|
+
return index.bootstrapLazy([["ez-grid.cjs",[[6,"ez-grid",{"multipleSelection":[4,"multiple-selection"],"config":[1040],"pageSize":[2,"page-size"],"serverUrl":[1,"server-url"],"dataUnit":[16],"_navigationHasPrevious":[32],"_navigationHasNext":[32],"_navigationFirstRow":[32],"_navigationLastRow":[32],"_navigationTotalRows":[32],"_popUpGridConfig":[32],"setColumnsDef":[64],"addColumnMenuItem":[64],"setColumnsState":[64],"setData":[64],"getSelection":[64],"getColumnsState":[64],"getColumns":[64],"refresh":[64],"quickFilter":[64],"nextPage":[64],"previousPage":[64],"hasNextPage":[64],"hasPreviousPage":[64],"isLastOfPage":[64],"isFirstOfPage":[64],"nextRecord":[64],"previousRecord":[64],"hasNextRecord":[64],"hasPreviousRecord":[64],"openGridConfig":[64]}]]],["ez-dialog.cjs",[[1,"ez-dialog",{"confirm":[1028],"critical":[1028],"message":[1025],"opened":[1540],"personalizedIconPath":[1025,"personalized-icon-path"],"ezTitle":[1025,"ez-title"],"handleButtonClick":[64],"show":[64]}]]],["ez-filter-input.cjs",[[1,"ez-filter-input",{"label":[1],"value":[1537],"enabled":[4],"loading":[516],"errorMessage":[1537,"error-message"],"restrict":[1],"mode":[513],"setFocus":[64],"setBlur":[64]}]]],["ez-action-chip.cjs",[[1,"ez-action-chip",{"label":[513],"enabled":[516]}]]],["ez-application.cjs",[[0,"ez-application"]]],["ez-label-chip.cjs",[[1,"ez-label-chip",{"label":[513],"enabled":[516],"removable":[516],"value":[1540],"setFocus":[64],"setBlur":[64]}]]],["ez-popover.cjs",[[1,"ez-popover",{"autoClose":[516,"auto-close"],"top":[1537],"left":[1537],"bottom":[1537],"right":[1537],"boxWidth":[513,"box-width"],"opened":[1540],"innerElement":[1537,"inner-element"],"updatePosition":[64],"show":[64],"hide":[64]}]]],["ez-popup.cjs",[[1,"ez-popup",{"size":[1],"opened":[1540],"useHeader":[1540,"use-header"],"ezTitle":[1,"ez-title"]}]]],["ez-toast.cjs",[[1,"ez-toast",{"message":[1025],"fadeTime":[1026,"fade-time"],"useIcon":[1028,"use-icon"],"canClose":[1028,"can-close"],"show":[64]}]]],["grid-config.cjs",[[2,"grid-config",{"selectedTab":[1025,"selected-tab"],"columns":[1040],"config":[1040]}]]],["ez-modal.cjs",[[1,"ez-modal",{"modalSize":[1,"modal-size"],"align":[1],"opened":[1028],"closeEsc":[4,"close-esc"],"closeOutsideClick":[4,"close-outside-click"]}]]],["ez-text-input.cjs",[[1,"ez-text-input",{"label":[513],"value":[1537],"enabled":[516],"loading":[516],"errorMessage":[1537,"error-message"],"mask":[1],"canShowError":[516,"can-show-error"],"restrict":[1],"mode":[513],"setFocus":[64],"setBlur":[64]}]]],["ez-search.cjs",[[1,"ez-search",{"value":[1537],"label":[1537],"enabled":[1540],"errorMessage":[1537,"error-message"],"optionLoader":[16],"showSelectedValue":[4,"show-selected-value"],"showOptionValue":[4,"show-option-value"],"suppressEmptyOption":[4,"suppress-empty-option"],"mode":[513],"setFocus":[64],"setBlur":[64]}]]],["select-box.cjs",[[1,"select-box",{"selectedOption":[1,"selected-option"]}]]],["ez-date-input.cjs",[[1,"ez-date-input",{"label":[513],"value":[1040],"enabled":[516],"errorMessage":[1537,"error-message"],"mode":[513],"setFocus":[64],"setBlur":[64]}]]],["ez-date-time-input.cjs",[[1,"ez-date-time-input",{"label":[513],"value":[1040],"enabled":[516],"errorMessage":[1537,"error-message"],"showSeconds":[516,"show-seconds"],"mode":[513],"setFocus":[64],"setBlur":[64]}]]],["ez-time-input.cjs",[[1,"ez-time-input",{"label":[513],"viewValue":[1537,"view-value"],"value":[1026],"enabled":[516],"errorMessage":[1537,"error-message"],"showSeconds":[516,"show-seconds"],"mode":[513],"setFocus":[64],"setBlur":[64]}]]],["ez-number-input.cjs",[[1,"ez-number-input",{"label":[1],"value":[1538],"enabled":[4],"errorMessage":[1537,"error-message"],"precision":[2],"prettyPrecision":[2,"pretty-precision"],"mode":[513],"setFocus":[64],"setBlur":[64]}]]],["ez-list.cjs",[[1,"ez-list",{"dataSource":[1040],"useGroups":[1540,"use-groups"],"ezDraggable":[1028,"ez-draggable"],"ezSelectable":[1028,"ez-selectable"],"itemSlotBuilder":[1040],"_listItems":[32],"_listGroupItems":[32],"clearHistory":[64],"scrollToTop":[64],"setSelection":[64],"getSelection":[64],"getList":[64]}]]],["ez-text-area.cjs",[[1,"ez-text-area",{"label":[513],"value":[1537],"enabled":[516],"loading":[516],"errorMessage":[1537,"error-message"],"rows":[1538],"canShowError":[516,"can-show-error"],"mode":[513],"setFocus":[64],"setBlur":[64]}]]],["ez-icon.cjs",[[1,"ez-icon",{"size":[513],"href":[513],"iconName":[513,"icon-name"]}]]],["ez-collapsible-box.cjs",[[1,"ez-collapsible-box",{"value":[1540],"label":[513],"headerSize":[513,"header-size"],"iconPlacement":[513,"icon-placement"],"stretchTitle":[516,"stretch-title"],"showHide":[64]}]]],["ez-upload.cjs",[[1,"ez-upload",{"label":[1],"enabled":[4],"maxFileSize":[2,"max-file-size"],"maxFiles":[2,"max-files"],"requestHeaders":[8,"request-headers"],"urlUpload":[1,"url-upload"],"urlDelete":[1,"url-delete"],"value":[1040],"addFiles":[64],"setFocus":[64],"setBlur":[64]}]]],["ez-button.cjs",[[1,"ez-button",{"label":[513],"enabled":[516],"mode":[513],"image":[513],"iconName":[513,"icon-name"],"size":[513],"setFocus":[64],"setBlur":[64]}]]],["ez-calendar.cjs",[[1,"ez-calendar",{"value":[1040],"floating":[516],"time":[516],"showSeconds":[516,"show-seconds"],"show":[64],"fitVertical":[64],"hide":[64]}]]],["ez-check.cjs",[[1,"ez-check",{"label":[513],"value":[1540],"enabled":[1540],"mode":[513],"getMode":[64],"setFocus":[64]}]]],["ez-tabselector.cjs",[[1,"ez-tabselector",{"selectedIndex":[1538,"selected-index"],"selectedTab":[1537,"selected-tab"],"tabs":[1]}]]],["ez-combo-box.cjs",[[1,"ez-combo-box",{"value":[1537],"label":[513],"enabled":[516],"options":[1040],"errorMessage":[1537,"error-message"],"searchMode":[4,"search-mode"],"showSelectedValue":[4,"show-selected-value"],"showOptionValue":[4,"show-option-value"],"suppressSearch":[4,"suppress-search"],"optionLoader":[16],"suppressEmptyOption":[4,"suppress-empty-option"],"canShowError":[516,"can-show-error"],"mode":[513],"_preSelection":[32],"_visibleOptions":[32],"setFocus":[64],"setBlur":[64]}]]],["ez-form.cjs",[[0,"ez-form",{"dataUnit":[1040],"config":[16],"submit":[64],"cancel":[64],"validate":[64]}]]],["test-du.cjs",[[0,"test-du",{"isDirty":[32]}]]]], options);
|
|
18
18
|
});
|
|
19
19
|
};
|
|
20
20
|
|
|
@@ -39,7 +39,12 @@ export default class DataBinder {
|
|
|
39
39
|
const oldValue = field["value"];
|
|
40
40
|
const newValue = this._dataUnit.getFieldValue(fieldName);
|
|
41
41
|
if (oldValue != newValue) {
|
|
42
|
-
|
|
42
|
+
if (newValue === undefined) {
|
|
43
|
+
field.removeAttribute("value");
|
|
44
|
+
}
|
|
45
|
+
else {
|
|
46
|
+
field["value"] = newValue;
|
|
47
|
+
}
|
|
43
48
|
}
|
|
44
49
|
}
|
|
45
50
|
updateBind(fieldName, field) {
|
|
@@ -47,7 +52,13 @@ export default class DataBinder {
|
|
|
47
52
|
if (oldBind) {
|
|
48
53
|
oldBind.destroy();
|
|
49
54
|
}
|
|
50
|
-
|
|
55
|
+
const value = this._dataUnit.getFieldValue(fieldName);
|
|
56
|
+
if (value === undefined) {
|
|
57
|
+
field.removeAttribute("value");
|
|
58
|
+
}
|
|
59
|
+
else {
|
|
60
|
+
field["value"] = value;
|
|
61
|
+
}
|
|
51
62
|
this._fields.set(fieldName, Bind.create(fieldName, field, (fieldName, waitingChange) => this.changeStarted(fieldName, waitingChange), (fieldName, newValue) => this.setFieldValue(fieldName, newValue)));
|
|
52
63
|
this.bindSearchOptionsLoader(fieldName, field);
|
|
53
64
|
this.applyEzUploadContext(fieldName, field);
|
|
@@ -27,7 +27,7 @@ export class EzForm {
|
|
|
27
27
|
.filter(f => f.dataset.required)
|
|
28
28
|
.map(f => f.dataset.fieldName)
|
|
29
29
|
.concat(metadata.getRequiredFields());
|
|
30
|
-
const records = this.dataUnit.
|
|
30
|
+
const records = this.dataUnit.getModifiedRecords();
|
|
31
31
|
for (let i = 0; i < records.length; i++) {
|
|
32
32
|
if (!this.validateRequired(requiredFields, records[i])) {
|
|
33
33
|
reject();
|
|
@@ -10,10 +10,6 @@ export default class DataUnitBridge {
|
|
|
10
10
|
const { records } = action.payload;
|
|
11
11
|
this._gridController.removeRows(records);
|
|
12
12
|
break;
|
|
13
|
-
case Action.RECORDS_ADDED:
|
|
14
|
-
case Action.RECORDS_COPIED:
|
|
15
|
-
this._gridController.addRows(action.payload);
|
|
16
|
-
break;
|
|
17
13
|
case Action.EDITION_CANCELED:
|
|
18
14
|
case Action.DATA_SAVED:
|
|
19
15
|
this._gridController.refresh();
|
|
@@ -22,6 +18,10 @@ export default class DataUnitBridge {
|
|
|
22
18
|
const { selection } = action.payload;
|
|
23
19
|
this._gridController.selectRows(selection);
|
|
24
20
|
break;
|
|
21
|
+
case Action.NEXT_SELECTED:
|
|
22
|
+
case Action.PREVIOUS_SELECTED:
|
|
23
|
+
this._gridController.selectRows(this._dataUnit.getSelection());
|
|
24
|
+
break;
|
|
25
25
|
case Action.DATA_CHANGED:
|
|
26
26
|
const changes = Object.assign({}, action.payload);
|
|
27
27
|
delete changes.records;
|
|
@@ -38,7 +38,12 @@ export default class DataUnitBridge {
|
|
|
38
38
|
this._dataUnit.metadata.fields.forEach(f => {
|
|
39
39
|
var _a;
|
|
40
40
|
if (f.visible !== false) {
|
|
41
|
-
|
|
41
|
+
const props = new Map();
|
|
42
|
+
const properties = this._dataUnit.getField(f.name).properties;
|
|
43
|
+
for (const value in properties) {
|
|
44
|
+
props.set(value, properties[value]);
|
|
45
|
+
}
|
|
46
|
+
columnDefs.push({ label: f.label, name: f.name, userInterface: f.userInterface, options: (_a = this._dataUnit.getField(f.name).properties) === null || _a === void 0 ? void 0 : _a.options, props });
|
|
42
47
|
}
|
|
43
48
|
});
|
|
44
49
|
}
|
|
@@ -5,10 +5,14 @@ import HeaderColumnTemplate from "./template/HeaderColumnTemplate.js";
|
|
|
5
5
|
import DataSource from "./DataSource";
|
|
6
6
|
import { DataType } from "@sankhyalabs/core";
|
|
7
7
|
import { SortMode, UserInterface } from "@sankhyalabs/core/dist/dataunit/metadata/UnitMetadata";
|
|
8
|
+
import { NumberUtils } from "@sankhyalabs/core";
|
|
8
9
|
export default class AgGridController {
|
|
9
10
|
constructor(enterprise) {
|
|
11
|
+
this.DEFAULT_ROW_HEIGHT = 25;
|
|
10
12
|
this._menuItems = [];
|
|
11
13
|
this._idAttribName = "__record__id__";
|
|
14
|
+
this._isFirstRecordOfPage = true;
|
|
15
|
+
this._isLastRecordOfPage = false;
|
|
12
16
|
this._enterprise = enterprise;
|
|
13
17
|
}
|
|
14
18
|
getSort() {
|
|
@@ -36,7 +40,9 @@ export default class AgGridController {
|
|
|
36
40
|
this._pageSize = options.pageSize;
|
|
37
41
|
this._serverURL = options.serverURL;
|
|
38
42
|
this._dataUnit = options.dataUnit;
|
|
39
|
-
this._dataUnit
|
|
43
|
+
if (this._dataUnit) {
|
|
44
|
+
this._dataUnit.sortingProvider = this;
|
|
45
|
+
}
|
|
40
46
|
this._dataSource = new DataSource(this._dataUnit, this._serverURL);
|
|
41
47
|
this._gridOptions = {
|
|
42
48
|
localeText: gridTerms,
|
|
@@ -45,7 +51,7 @@ export default class AgGridController {
|
|
|
45
51
|
rowSelection: this._multipleSelection ? "multiple" : "single",
|
|
46
52
|
serverSideDatasource: this._dataSource,
|
|
47
53
|
sortingOrder: ['desc', 'asc', null],
|
|
48
|
-
getRowNodeId: (params) => typeof params === "string" ? params : params[this._idAttribName],
|
|
54
|
+
getRowNodeId: this._dataUnit ? (params) => typeof params === "string" ? params : params[this._idAttribName] : undefined,
|
|
49
55
|
getMainMenuItems: (params) => {
|
|
50
56
|
const column = params.column;
|
|
51
57
|
const items = [column.isPinned() ? "clearPinned" : "pinLeft", "separator"];
|
|
@@ -55,14 +61,12 @@ export default class AgGridController {
|
|
|
55
61
|
}));
|
|
56
62
|
return items;
|
|
57
63
|
},
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
return 25;
|
|
65
|
-
}
|
|
64
|
+
//FIXME: Existe um bug no PartialStore.prototype.destroyAllBlocks do ag-grid, pois
|
|
65
|
+
//apesar de destruir os blocos, mantém a variável "blockHeights" com o tamanho antigo
|
|
66
|
+
//dos blocos, então, quando removemos uma linha, a altura do bloco não é recalculada.
|
|
67
|
+
//Descobri que setando manualmente a altura das linhas, apesar do bloco ficar com
|
|
68
|
+
//tamanho errado, isso afeta menos o componente.
|
|
69
|
+
rowHeight: this.DEFAULT_ROW_HEIGHT
|
|
66
70
|
};
|
|
67
71
|
this.setOptionsEvents(this._gridOptions);
|
|
68
72
|
this.setOptionsPagination(this._gridOptions);
|
|
@@ -85,16 +89,17 @@ export default class AgGridController {
|
|
|
85
89
|
opt.onPaginationChanged = () => this.onPaginationChange();
|
|
86
90
|
opt.onRowDoubleClicked = evt => this.onRowDoubleClick(evt);
|
|
87
91
|
opt.onDragStopped = evt => this.onCallStateChange("columnMovedEnd", evt);
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
}
|
|
92
|
+
}
|
|
93
|
+
syncSelection() {
|
|
94
|
+
if (this._dataUnit) {
|
|
95
|
+
this.selectRows(this._dataUnit.getSelection());
|
|
96
|
+
}
|
|
93
97
|
}
|
|
94
98
|
setOptionsPagination(opt) {
|
|
95
99
|
opt.pagination = (this._pageSize > -1);
|
|
96
100
|
opt.paginationPageSize = this._pageSize;
|
|
97
101
|
opt.cacheBlockSize = this._pageSize;
|
|
102
|
+
opt.maxBlocksInCache = 1;
|
|
98
103
|
}
|
|
99
104
|
setOptionsSupress(opt) {
|
|
100
105
|
opt.suppressDragLeaveHidesColumns = true;
|
|
@@ -130,7 +135,7 @@ export default class AgGridController {
|
|
|
130
135
|
if (this._grid === undefined) {
|
|
131
136
|
throw new Error("Erro interno: Grid ainda não inicializado.");
|
|
132
137
|
}
|
|
133
|
-
this._gridOptions.api.refreshServerSideStore({});
|
|
138
|
+
this._gridOptions.api.refreshServerSideStore({ purge: true });
|
|
134
139
|
}
|
|
135
140
|
changeValues(changes, rowIds) {
|
|
136
141
|
if (this._grid === undefined) {
|
|
@@ -267,6 +272,75 @@ export default class AgGridController {
|
|
|
267
272
|
this.goToPage(0);
|
|
268
273
|
this._gridOptions.api.refreshServerSideStore({ purge: true });
|
|
269
274
|
}
|
|
275
|
+
isLastOfPage() {
|
|
276
|
+
return this._isLastRecordOfPage;
|
|
277
|
+
}
|
|
278
|
+
isFirstOfPage() {
|
|
279
|
+
return this._isFirstRecordOfPage;
|
|
280
|
+
}
|
|
281
|
+
previousRecord() {
|
|
282
|
+
const pagination = this.getPaginationStatus();
|
|
283
|
+
if (this._isFirstRecordOfPage && pagination.hasPrevious) {
|
|
284
|
+
this.previousPage();
|
|
285
|
+
}
|
|
286
|
+
else {
|
|
287
|
+
if (this._dataUnit) {
|
|
288
|
+
this._dataUnit.previousRecord();
|
|
289
|
+
}
|
|
290
|
+
else {
|
|
291
|
+
const node = this._gridOptions.api.getSelectedNodes()[0];
|
|
292
|
+
this.setSelectedIndex(node.rowIndex - 1);
|
|
293
|
+
}
|
|
294
|
+
}
|
|
295
|
+
}
|
|
296
|
+
nextRecord() {
|
|
297
|
+
const pagination = this.getPaginationStatus();
|
|
298
|
+
if (this._isLastRecordOfPage && pagination.hasNext) {
|
|
299
|
+
this.nextPage();
|
|
300
|
+
}
|
|
301
|
+
else {
|
|
302
|
+
if (this._dataUnit) {
|
|
303
|
+
this._dataUnit.nextRecord();
|
|
304
|
+
}
|
|
305
|
+
else {
|
|
306
|
+
const node = this._gridOptions.api.getSelectedNodes()[0];
|
|
307
|
+
this.setSelectedIndex(node.rowIndex + 1);
|
|
308
|
+
}
|
|
309
|
+
}
|
|
310
|
+
}
|
|
311
|
+
setSelectedIndex(index) {
|
|
312
|
+
var _a;
|
|
313
|
+
(_a = this._gridOptions.api.getDisplayedRowAtIndex(index)) === null || _a === void 0 ? void 0 : _a.setSelected(true);
|
|
314
|
+
}
|
|
315
|
+
hasPreviousRecord() {
|
|
316
|
+
const pagination = this.getPaginationStatus();
|
|
317
|
+
if (this._isFirstRecordOfPage) {
|
|
318
|
+
return pagination.hasPrevious;
|
|
319
|
+
}
|
|
320
|
+
else {
|
|
321
|
+
if (this._dataUnit) {
|
|
322
|
+
return this._dataUnit.hasPrevious();
|
|
323
|
+
}
|
|
324
|
+
else {
|
|
325
|
+
return pagination.hasPrevious || this._gridOptions.api.getSelectedRows()[0].rowIndex > 0;
|
|
326
|
+
}
|
|
327
|
+
}
|
|
328
|
+
}
|
|
329
|
+
hasNextRecord() {
|
|
330
|
+
const pagination = this.getPaginationStatus();
|
|
331
|
+
if (this._isLastRecordOfPage) {
|
|
332
|
+
return pagination.hasNext;
|
|
333
|
+
}
|
|
334
|
+
else {
|
|
335
|
+
if (this._dataUnit) {
|
|
336
|
+
return this._dataUnit.hasNext() || this.getPaginationStatus().hasNext;
|
|
337
|
+
}
|
|
338
|
+
else {
|
|
339
|
+
const api = this._gridOptions.api;
|
|
340
|
+
return pagination.hasNext || api.getSelectedRows()[0].rowIndex < api.getDisplayedRowCount();
|
|
341
|
+
}
|
|
342
|
+
}
|
|
343
|
+
}
|
|
270
344
|
buildColDef(source) {
|
|
271
345
|
return {
|
|
272
346
|
headerName: source.label,
|
|
@@ -301,19 +375,24 @@ export default class AgGridController {
|
|
|
301
375
|
});
|
|
302
376
|
return optionSelected === null || optionSelected === void 0 ? void 0 : optionSelected.label;
|
|
303
377
|
}
|
|
304
|
-
if ((source === null || source === void 0 ? void 0 : source.userInterface) ===
|
|
305
|
-
if ((params === null || params === void 0 ? void 0 : params.value) === "S" || (params === null || params === void 0 ? void 0 : params.value) === true) {
|
|
378
|
+
if ((source === null || source === void 0 ? void 0 : source.userInterface) === UserInterface.SWITCH) {
|
|
379
|
+
if ((params === null || params === void 0 ? void 0 : params.value) === "S" || (params === null || params === void 0 ? void 0 : params.value) === true || (params === null || params === void 0 ? void 0 : params.value) === "true") {
|
|
306
380
|
return "Sim";
|
|
307
381
|
}
|
|
308
|
-
else if ((params === null || params === void 0 ? void 0 : params.value) === "N" || (params === null || params === void 0 ? void 0 : params.value) === false) {
|
|
382
|
+
else if ((params === null || params === void 0 ? void 0 : params.value) === "N" || (params === null || params === void 0 ? void 0 : params.value) === false || (params === null || params === void 0 ? void 0 : params.value) === "false") {
|
|
309
383
|
return "Não";
|
|
310
384
|
}
|
|
311
385
|
}
|
|
312
|
-
if ((source === null || source === void 0 ? void 0 : source.userInterface) ===
|
|
386
|
+
if ((source === null || source === void 0 ? void 0 : source.userInterface) === UserInterface.SEARCH) {
|
|
313
387
|
if (params.value !== undefined) {
|
|
314
388
|
return ((_a = params === null || params === void 0 ? void 0 : params.value) === null || _a === void 0 ? void 0 : _a.value) + " - " + ((_b = params === null || params === void 0 ? void 0 : params.value) === null || _b === void 0 ? void 0 : _b.label);
|
|
315
389
|
}
|
|
316
390
|
}
|
|
391
|
+
if ((source === null || source === void 0 ? void 0 : source.userInterface) === UserInterface.DECIMALNUMBER) {
|
|
392
|
+
if (params.value !== undefined) {
|
|
393
|
+
return NumberUtils.format(params.value.toString(), 2, 2);
|
|
394
|
+
}
|
|
395
|
+
}
|
|
317
396
|
if ((source === null || source === void 0 ? void 0 : source.userInterface) === UserInterface.DATE || (source === null || source === void 0 ? void 0 : source.userInterface) === UserInterface.DATETIME) {
|
|
318
397
|
if (params.value !== undefined) {
|
|
319
398
|
return params.value.toLocaleDateString();
|
|
@@ -343,31 +422,44 @@ export default class AgGridController {
|
|
|
343
422
|
return false;
|
|
344
423
|
}
|
|
345
424
|
onSelectionChange(e) {
|
|
425
|
+
const selectedNodes = e.api.getSelectedNodes();
|
|
426
|
+
if (selectedNodes.length > 0) {
|
|
427
|
+
this._isFirstRecordOfPage = selectedNodes[0].rowIndex === e.api.getFirstDisplayedRow();
|
|
428
|
+
this._isLastRecordOfPage = selectedNodes[0].rowIndex === e.api.getLastDisplayedRow();
|
|
429
|
+
}
|
|
346
430
|
if (this._selectionChangeCallback) {
|
|
347
|
-
this._selectionChangeCallback(
|
|
431
|
+
this._selectionChangeCallback({
|
|
432
|
+
selection: e.api.getSelectedRows(),
|
|
433
|
+
isFirstOfPage: this._isFirstRecordOfPage,
|
|
434
|
+
isLastOfPage: this._isLastRecordOfPage
|
|
435
|
+
});
|
|
348
436
|
}
|
|
349
437
|
}
|
|
350
438
|
onPaginationChange() {
|
|
439
|
+
this.syncSelection();
|
|
351
440
|
if (this._paginationChangeCallback) {
|
|
352
441
|
if (this._gridOptions.api) {
|
|
353
|
-
|
|
354
|
-
const currentPage = api.paginationGetCurrentPage();
|
|
355
|
-
const isLastPage = api.paginationGetTotalPages() === (currentPage + 1);
|
|
356
|
-
const pageSize = api.paginationGetPageSize();
|
|
357
|
-
const totalRows = api.paginationGetRowCount();
|
|
358
|
-
const pageStart = currentPage * pageSize + 1;
|
|
359
|
-
const pageEnd = Math.min(totalRows, (currentPage + 1) * pageSize);
|
|
360
|
-
this._paginationChangeCallback({
|
|
361
|
-
hasPrevious: currentPage > 0,
|
|
362
|
-
hasNext: !isLastPage,
|
|
363
|
-
currentPage: currentPage + 1,
|
|
364
|
-
pageStart,
|
|
365
|
-
pageEnd,
|
|
366
|
-
totalRows
|
|
367
|
-
});
|
|
442
|
+
this._paginationChangeCallback(this.getPaginationStatus());
|
|
368
443
|
}
|
|
369
444
|
}
|
|
370
445
|
}
|
|
446
|
+
getPaginationStatus() {
|
|
447
|
+
const api = this._gridOptions.api;
|
|
448
|
+
const currentPage = api.paginationGetCurrentPage();
|
|
449
|
+
const isLastPage = api.paginationGetTotalPages() === (currentPage + 1);
|
|
450
|
+
const pageSize = api.paginationGetPageSize();
|
|
451
|
+
const totalRows = api.paginationGetRowCount();
|
|
452
|
+
const pageStart = currentPage * pageSize + 1;
|
|
453
|
+
const pageEnd = Math.min(totalRows, (currentPage + 1) * pageSize);
|
|
454
|
+
return {
|
|
455
|
+
hasPrevious: currentPage > 0,
|
|
456
|
+
hasNext: !isLastPage,
|
|
457
|
+
currentPage: currentPage + 1,
|
|
458
|
+
pageStart,
|
|
459
|
+
pageEnd,
|
|
460
|
+
totalRows
|
|
461
|
+
};
|
|
462
|
+
}
|
|
371
463
|
onRowDoubleClick(evt) {
|
|
372
464
|
if (this._doubleClickCallBack) {
|
|
373
465
|
this._doubleClickCallBack(evt.data);
|