@sankhyalabs/sankhyablocks 1.3.34 → 1.4.0-beta.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/SnkMessageBuilder-7717f1e4.js +326 -0
- package/dist/cjs/app-globals-3a1e7e63.js +5 -0
- package/dist/cjs/css-shim-b8158822.js +6 -0
- package/dist/cjs/dom-36862b77.js +75 -0
- package/dist/cjs/filter-item-type.enum-e2e1bc5b.js +14 -0
- package/dist/cjs/index-02201bc9.js +2397 -0
- package/dist/cjs/index-b0b676c5.js +3298 -0
- package/dist/cjs/loader.cjs.js +19 -3
- package/dist/cjs/sankhyablocks.cjs.js +117 -5
- package/dist/cjs/shadow-css-346c0795.js +389 -0
- package/dist/cjs/snk-application.cjs.entry.js +720 -168
- package/dist/cjs/snk-crud.cjs.entry.js +70 -0
- package/dist/cjs/snk-data-unit.cjs.entry.js +280 -0
- package/dist/cjs/snk-filter-bar.cjs.entry.js +278 -0
- package/dist/cjs/snk-filter-binary-select.cjs.entry.js +47 -0
- package/dist/cjs/snk-filter-detail.cjs.entry.js +49 -0
- package/dist/cjs/snk-filter-item.cjs.entry.js +154 -0
- package/dist/cjs/snk-filter-list.cjs.entry.js +91 -0
- package/dist/cjs/snk-filter-multi-select.cjs.entry.js +23 -0
- package/dist/cjs/snk-filter-number.cjs.entry.js +24 -0
- package/dist/cjs/snk-filter-period.cjs.entry.js +37 -0
- package/dist/cjs/snk-filter-search.cjs.entry.js +44 -0
- package/dist/cjs/snk-filter-text.cjs.entry.js +22 -0
- package/dist/cjs/snk-form.cjs.entry.js +133 -0
- package/dist/cjs/snk-grid.cjs.entry.js +79 -0
- package/dist/cjs/snk-pesquisa.cjs.entry.js +5 -5
- package/dist/cjs/snk-taskbar.cjs.entry.js +160 -0
- package/dist/cjs/taskbar-elements-283c737e.js +93 -0
- package/dist/cjs/taskbar-processor-6bd0d35c.js +47 -0
- package/dist/cjs/teste-pesquisa.cjs.entry.js +5 -5
- package/dist/collection/collection-manifest.json +17 -2
- package/dist/collection/components/snk-application/errorhandler/snk-error-handler.js +9 -2
- package/dist/collection/components/snk-application/snk-application.js +1126 -621
- package/dist/collection/components/snk-crud/snk-crud.css +6 -0
- package/dist/collection/components/snk-crud/snk-crud.js +203 -0
- package/dist/collection/components/snk-data-unit/snk-data-unit.css +6 -0
- package/dist/collection/components/snk-data-unit/snk-data-unit.js +544 -0
- package/dist/collection/components/snk-filter-bar/filter-item/editors/snk-filter-binary-select.js +88 -0
- package/dist/collection/components/snk-filter-bar/filter-item/editors/snk-filter-multi-select.js +64 -0
- package/dist/collection/components/snk-filter-bar/filter-item/editors/snk-filter-number.js +65 -0
- package/dist/collection/components/snk-filter-bar/filter-item/editors/snk-filter-period.js +78 -0
- package/dist/collection/components/snk-filter-bar/filter-item/editors/snk-filter-search.js +118 -0
- package/dist/collection/components/snk-filter-bar/filter-item/editors/snk-filter-text.js +63 -0
- package/dist/collection/components/snk-filter-bar/filter-item/filter-item-type.enum.js +10 -0
- package/dist/collection/components/snk-filter-bar/filter-item/snk-filter-detail.js +118 -0
- package/dist/collection/components/snk-filter-bar/filter-item/snk-filter-item.js +255 -0
- package/dist/collection/components/snk-filter-bar/filter-list/snk-filter-list.js +233 -0
- package/dist/collection/components/snk-filter-bar/snk-filter-bar.css +114 -0
- package/dist/collection/components/snk-filter-bar/snk-filter-bar.js +353 -0
- package/dist/collection/components/snk-form/snk-form.css +34 -0
- package/dist/collection/components/snk-form/snk-form.js +258 -0
- package/dist/collection/components/snk-grid/snk-grid.css +18 -0
- package/dist/collection/components/snk-grid/snk-grid.js +205 -0
- package/dist/collection/components/snk-pesquisa/snk-pesquisa.js +80 -79
- package/dist/collection/components/snk-taskbar/elements/taskbar-elements.js +86 -0
- package/dist/collection/components/snk-taskbar/processor/taskbar-processor.js +43 -0
- package/dist/collection/components/snk-taskbar/snk-taskbar.css +3 -0
- package/dist/collection/components/snk-taskbar/snk-taskbar.js +307 -0
- package/dist/collection/components/teste-pesquisa/teste-pesquisa.js +12 -9
- package/dist/collection/lib/http/data-fetcher/DataFetcher.js +37 -12
- package/dist/collection/lib/http/data-fetcher/fetchers/dataunit-fetcher.js +52 -21
- package/dist/collection/lib/http/data-fetcher/fetchers/filter-bar-config-fetcher.js +54 -0
- package/dist/collection/lib/http/data-fetcher/fetchers/grid-config-fetcher.js +4 -3
- package/dist/collection/lib/http/data-fetcher/fetchers/totals-fetcher.js +47 -0
- package/dist/collection/lib/index.js +1 -0
- package/dist/collection/lib/message/SnkMessageBuilder.js +121 -0
- package/dist/collection/lib/message/resources/snk-data-unit.msg.js +23 -0
- package/dist/collection/lib/message/resources/snk-filter-bar.msg.js +18 -0
- package/dist/collection/lib/message/resources/snk-form.msg.js +10 -0
- package/dist/collection/lib/message/resources/snk-taskbar.msg.js +17 -0
- package/dist/components/SnkMessageBuilder.js +303 -0
- package/dist/components/filter-item-type.enum.js +12 -0
- package/dist/components/index.d.ts +18 -5
- package/dist/components/index.js +22 -0
- package/dist/components/index2.js +2384 -0
- package/dist/components/snk-application2.js +700 -139
- package/dist/components/snk-crud.d.ts +11 -0
- package/dist/components/snk-crud.js +133 -0
- package/dist/components/snk-data-unit.d.ts +11 -0
- package/dist/components/snk-data-unit.js +303 -0
- package/dist/components/snk-filter-bar.d.ts +11 -0
- package/dist/components/snk-filter-bar.js +6 -0
- package/dist/components/snk-filter-bar2.js +310 -0
- package/dist/components/snk-filter-binary-select.d.ts +11 -0
- package/dist/components/snk-filter-binary-select.js +63 -0
- package/dist/components/snk-filter-detail.d.ts +11 -0
- package/dist/components/snk-filter-detail.js +6 -0
- package/dist/components/snk-filter-detail2.js +63 -0
- package/dist/components/snk-filter-item.d.ts +11 -0
- package/dist/components/snk-filter-item.js +6 -0
- package/dist/components/snk-filter-item2.js +175 -0
- package/dist/components/snk-filter-list.d.ts +11 -0
- package/dist/components/snk-filter-list.js +6 -0
- package/dist/components/snk-filter-list2.js +111 -0
- package/dist/components/snk-filter-multi-select.d.ts +11 -0
- package/dist/components/snk-filter-multi-select.js +39 -0
- package/dist/components/snk-filter-number.d.ts +11 -0
- package/dist/components/snk-filter-number.js +40 -0
- package/dist/components/snk-filter-period.d.ts +11 -0
- package/dist/components/snk-filter-period.js +53 -0
- package/dist/components/snk-filter-search.d.ts +11 -0
- package/dist/components/snk-filter-search.js +62 -0
- package/dist/components/snk-filter-text.d.ts +11 -0
- package/dist/components/snk-filter-text.js +38 -0
- package/dist/components/snk-form.d.ts +11 -0
- package/dist/components/snk-form.js +6 -0
- package/dist/components/snk-form2.js +159 -0
- package/dist/components/snk-grid.d.ts +11 -0
- package/dist/components/snk-grid.js +6 -0
- package/dist/components/snk-grid2.js +127 -0
- package/dist/components/snk-pesquisa2.js +1 -1
- package/dist/components/snk-taskbar.d.ts +11 -0
- package/dist/components/snk-taskbar.js +6 -0
- package/dist/components/snk-taskbar2.js +264 -0
- package/dist/components/taskbar-processor.js +45 -0
- package/dist/components/teste-pesquisa.js +1 -1
- package/dist/esm/SnkMessageBuilder-a7da466b.js +303 -0
- package/dist/esm/app-globals-0f993ce5.js +3 -0
- package/dist/esm/css-shim-b3f2ee8d.js +4 -0
- package/dist/esm/dom-665d6011.js +73 -0
- package/dist/esm/filter-item-type.enum-61fbf80a.js +12 -0
- package/dist/esm/index-2b4d2d14.js +3262 -0
- package/dist/esm/index-f1d3e4da.js +2384 -0
- package/dist/esm/loader.js +19 -3
- package/dist/esm/polyfills/css-shim.js +1 -1
- package/dist/esm/sankhyablocks.js +117 -5
- package/dist/esm/shadow-css-b18e99d7.js +387 -0
- package/dist/esm/snk-application.entry.js +692 -140
- package/dist/esm/snk-crud.entry.js +66 -0
- package/dist/esm/snk-data-unit.entry.js +276 -0
- package/dist/esm/snk-filter-bar.entry.js +274 -0
- package/dist/esm/snk-filter-binary-select.entry.js +43 -0
- package/dist/esm/snk-filter-detail.entry.js +45 -0
- package/dist/esm/snk-filter-item.entry.js +150 -0
- package/dist/esm/snk-filter-list.entry.js +87 -0
- package/dist/esm/snk-filter-multi-select.entry.js +19 -0
- package/dist/esm/snk-filter-number.entry.js +20 -0
- package/dist/esm/snk-filter-period.entry.js +33 -0
- package/dist/esm/snk-filter-search.entry.js +40 -0
- package/dist/esm/snk-filter-text.entry.js +18 -0
- package/dist/esm/snk-form.entry.js +129 -0
- package/dist/esm/snk-grid.entry.js +75 -0
- package/dist/esm/snk-pesquisa.entry.js +2 -2
- package/dist/esm/snk-taskbar.entry.js +156 -0
- package/dist/esm/taskbar-elements-35d64ff9.js +90 -0
- package/dist/esm/taskbar-processor-aa6772c9.js +45 -0
- package/dist/esm/teste-pesquisa.entry.js +2 -2
- package/dist/sankhyablocks/SnkMessageBuilder-a7da466b.js +303 -0
- package/dist/sankhyablocks/app-globals-0f993ce5.js +3 -0
- package/dist/sankhyablocks/css-shim-b3f2ee8d.js +4 -0
- package/dist/sankhyablocks/dom-665d6011.js +73 -0
- package/dist/sankhyablocks/filter-item-type.enum-61fbf80a.js +12 -0
- package/dist/sankhyablocks/index-2b4d2d14.js +3262 -0
- package/dist/sankhyablocks/index-f1d3e4da.js +2384 -0
- package/dist/sankhyablocks/index.esm.js +1 -0
- package/dist/sankhyablocks/sankhyablocks.esm.js +129 -1
- package/dist/sankhyablocks/shadow-css-b18e99d7.js +387 -0
- package/dist/sankhyablocks/snk-application.entry.js +8148 -0
- package/dist/sankhyablocks/snk-crud.entry.js +66 -0
- package/dist/sankhyablocks/snk-data-unit.entry.js +276 -0
- package/dist/sankhyablocks/snk-filter-bar.entry.js +274 -0
- package/dist/sankhyablocks/snk-filter-binary-select.entry.js +43 -0
- package/dist/sankhyablocks/snk-filter-detail.entry.js +45 -0
- package/dist/sankhyablocks/snk-filter-item.entry.js +150 -0
- package/dist/sankhyablocks/snk-filter-list.entry.js +87 -0
- package/dist/sankhyablocks/snk-filter-multi-select.entry.js +19 -0
- package/dist/sankhyablocks/snk-filter-number.entry.js +20 -0
- package/dist/sankhyablocks/snk-filter-period.entry.js +33 -0
- package/dist/sankhyablocks/snk-filter-search.entry.js +40 -0
- package/dist/sankhyablocks/snk-filter-text.entry.js +18 -0
- package/dist/sankhyablocks/snk-form.entry.js +129 -0
- package/dist/sankhyablocks/snk-grid.entry.js +75 -0
- package/dist/sankhyablocks/snk-pesquisa.entry.js +311 -0
- package/dist/sankhyablocks/snk-taskbar.entry.js +156 -0
- package/dist/sankhyablocks/taskbar-elements-35d64ff9.js +90 -0
- package/dist/sankhyablocks/taskbar-processor-aa6772c9.js +45 -0
- package/dist/sankhyablocks/teste-pesquisa.entry.js +33 -0
- package/dist/types/components/snk-application/errorhandler/snk-error-handler.d.ts +1 -0
- package/dist/types/components/snk-application/snk-application.d.ts +145 -15
- package/dist/types/components/snk-filter-bar/filter-item/editors/snk-filter-binary-select.d.ts +12 -0
- package/dist/types/components/snk-filter-bar/filter-item/editors/snk-filter-multi-select.d.ts +7 -0
- package/dist/types/components/snk-filter-bar/filter-item/editors/snk-filter-number.d.ts +7 -0
- package/dist/types/components/snk-filter-bar/filter-item/editors/snk-filter-period.d.ts +14 -0
- package/dist/types/components/snk-filter-bar/filter-item/editors/snk-filter-search.d.ts +12 -0
- package/dist/types/components/snk-filter-bar/filter-item/editors/snk-filter-text.d.ts +7 -0
- package/dist/types/components/snk-filter-bar/filter-item/filter-item-type.enum.d.ts +9 -0
- package/dist/types/components/snk-filter-bar/filter-item/snk-filter-detail.d.ts +14 -0
- package/dist/types/components/snk-filter-bar/filter-list/snk-filter-list.d.ts +40 -0
- package/dist/types/components/snk-filter-bar/snk-filter-bar.d.ts +51 -0
- package/dist/types/components/snk-taskbar/elements/taskbar-elements.d.ts +29 -0
- package/dist/types/components/snk-taskbar/processor/taskbar-processor.d.ts +12 -0
- package/dist/types/components/snk-taskbar/snk-taskbar.d.ts +84 -0
- package/dist/types/components.d.ts +696 -8
- package/dist/types/lib/http/data-fetcher/DataFetcher.d.ts +7 -6
- package/dist/types/lib/http/data-fetcher/fetchers/dataunit-fetcher.d.ts +2 -0
- package/dist/types/lib/http/data-fetcher/fetchers/filter-bar-config-fetcher.d.ts +6 -0
- package/dist/types/lib/http/data-fetcher/fetchers/grid-config-fetcher.d.ts +1 -1
- package/dist/types/lib/http/data-fetcher/fetchers/totals-fetcher.d.ts +8 -0
- package/dist/types/lib/index.d.ts +1 -0
- package/dist/types/lib/message/SnkMessageBuilder.d.ts +42 -0
- package/dist/types/lib/message/resources/snk-data-unit.msg.d.ts +2 -0
- package/dist/types/lib/message/resources/snk-filter-bar.msg.d.ts +2 -0
- package/dist/types/lib/message/resources/snk-form.msg.d.ts +2 -0
- package/dist/types/lib/message/resources/snk-taskbar.msg.d.ts +2 -0
- package/dist/types/stencil-public-runtime.d.ts +15 -4
- package/loader/package.json +1 -0
- package/package.json +5 -5
- package/react/components.d.ts +0 -2
- package/react/components.js +0 -2
- package/react/components.js.map +1 -1
- package/dist/cjs/index-1133bc2a.js +0 -1235
- package/dist/esm/index-ffda6382.js +0 -1208
- package/dist/sankhyablocks/p-2a7b4cb3.entry.js +0 -1
- package/dist/sankhyablocks/p-9520d78a.entry.js +0 -1
- package/dist/sankhyablocks/p-98e8490d.entry.js +0 -69
- package/dist/sankhyablocks/p-edcb9d8e.js +0 -2
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { r as registerInstance, e as createEvent, h, g as getElement } from './index-2b4d2d14.js';
|
|
2
|
+
import { A as ApplicationContext } from './index-f1d3e4da.js';
|
|
3
|
+
|
|
4
|
+
const snkCrudCss = ".sc-snk-crud-h{display:flex;flex-direction:column;height:100%;width:100%}";
|
|
5
|
+
|
|
6
|
+
const GRID_MODE = 0;
|
|
7
|
+
const FORM_MODE = 1;
|
|
8
|
+
const SnkCrud = class {
|
|
9
|
+
constructor(hostRef) {
|
|
10
|
+
registerInstance(this, hostRef);
|
|
11
|
+
this.actionClick = createEvent(this, "actionClick", 7);
|
|
12
|
+
}
|
|
13
|
+
async gridToForm(keepFormMode = false) {
|
|
14
|
+
this._backToGrid = !keepFormMode && await this._viewStack.getSelectedIndex() === GRID_MODE;
|
|
15
|
+
this._viewStack.show(FORM_MODE);
|
|
16
|
+
}
|
|
17
|
+
async executeAction(act) {
|
|
18
|
+
if (act === "GRID_MODE") {
|
|
19
|
+
this._viewStack.show(GRID_MODE);
|
|
20
|
+
}
|
|
21
|
+
else if (act === "FORM_MODE" || act === "UPDATE") {
|
|
22
|
+
this.gridToForm(act !== "UPDATE");
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
insertionModeHandler() {
|
|
26
|
+
this.gridToForm();
|
|
27
|
+
}
|
|
28
|
+
cancelHandler() {
|
|
29
|
+
if (this._backToGrid) {
|
|
30
|
+
this._viewStack.show(GRID_MODE);
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
componentWillLoad() {
|
|
34
|
+
let parent = this._element.parentElement;
|
|
35
|
+
while (parent) {
|
|
36
|
+
if (parent.tagName.toUpperCase() === "SNK-DATA-UNIT") {
|
|
37
|
+
this._snkDataUnit = parent;
|
|
38
|
+
this._snkDataUnit.addEventListener("insertionMode", () => this.insertionModeHandler());
|
|
39
|
+
this._snkDataUnit.addEventListener("cancelEdition", () => this.cancelHandler());
|
|
40
|
+
this._dataUnit = this._snkDataUnit.dataUnit;
|
|
41
|
+
this._dataState = this._snkDataUnit.dataState;
|
|
42
|
+
if (!this._dataUnit) {
|
|
43
|
+
this._snkDataUnit.addEventListener("dataUnitReady", (evt) => {
|
|
44
|
+
this._dataUnit = evt.detail;
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
this._snkDataUnit.addEventListener("dataStateChange", (evt) => {
|
|
48
|
+
this._dataState = evt.detail;
|
|
49
|
+
});
|
|
50
|
+
break;
|
|
51
|
+
}
|
|
52
|
+
parent = parent.parentElement;
|
|
53
|
+
}
|
|
54
|
+
if (!this.configName) {
|
|
55
|
+
const application = ApplicationContext.getContextValue("__SNK__APPLICATION__");
|
|
56
|
+
this.configName = application.configName;
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
render() {
|
|
60
|
+
return (h("ez-view-stack", { ref: (ref) => this._viewStack = ref }, h("stack-item", null, h("snk-grid", { configName: this.configName, onGridDoubleClick: () => this.gridToForm(true), taskbarManager: this.taskbarManager, onActionClick: evt => this.executeAction(evt.detail), actionsList: this.actionsList, statusResolver: this.statusResolver }, h("slot", { name: "SnkGridHeader" }), h("slot", { name: "SnkGridFooter" }), h("slot", { name: "SnkGridTaskBar" }))), h("stack-item", null, h("snk-form", { configName: this.configName, actionsList: this.actionsList, onExit: () => this._viewStack.show(GRID_MODE), recordsValidator: this.recordsValidator, taskbarManager: this.taskbarManager, onActionClick: evt => this.executeAction(evt.detail) }, h("slot", { name: "SnkFormTaskBar" })))));
|
|
61
|
+
}
|
|
62
|
+
get _element() { return getElement(this); }
|
|
63
|
+
};
|
|
64
|
+
SnkCrud.style = snkCrudCss;
|
|
65
|
+
|
|
66
|
+
export { SnkCrud as snk_crud };
|
|
@@ -0,0 +1,276 @@
|
|
|
1
|
+
import { r as registerInstance, e as createEvent, h, f as Host, g as getElement } from './index-2b4d2d14.js';
|
|
2
|
+
import { a as Action, A as ApplicationContext } from './index-f1d3e4da.js';
|
|
3
|
+
import { A as ApplicationUtils, D as DialogType, O as OperationMap } from './SnkMessageBuilder-a7da466b.js';
|
|
4
|
+
|
|
5
|
+
const snkDataUnitCss = ".sc-snk-data-unit-h{display:flex;flex-direction:column;height:100%}";
|
|
6
|
+
|
|
7
|
+
const SnkDataUnit = class {
|
|
8
|
+
constructor(hostRef) {
|
|
9
|
+
registerInstance(this, hostRef);
|
|
10
|
+
this.dataStateChange = createEvent(this, "dataStateChange", 7);
|
|
11
|
+
this.dataUnitReady = createEvent(this, "dataUnitReady", 7);
|
|
12
|
+
this.insertionMode = createEvent(this, "insertionMode", 7);
|
|
13
|
+
this.cancelEdition = createEvent(this, "cancelEdition", 7);
|
|
14
|
+
this._onDataUnitResolve = [];
|
|
15
|
+
/**
|
|
16
|
+
* Determina quantas linhas são retornadas por página
|
|
17
|
+
*/
|
|
18
|
+
this.pageSize = 150;
|
|
19
|
+
/**
|
|
20
|
+
* Quando ativada essa propriedade faz com que haja uma carga imediata no DataUnit
|
|
21
|
+
*/
|
|
22
|
+
this.autoLoad = true;
|
|
23
|
+
this._dataUnitObserver = (action) => {
|
|
24
|
+
const duState = {
|
|
25
|
+
insertionMode: false,
|
|
26
|
+
hasNext: this.dataUnit.hasNext(),
|
|
27
|
+
hasPrevious: this.dataUnit.hasPrevious(),
|
|
28
|
+
copyMode: false,
|
|
29
|
+
isDirty: this.dataUnit.isDirty(),
|
|
30
|
+
hasDirtyRecords: this.dataUnit.hasDirtyRecords(),
|
|
31
|
+
selectedRecords: this.dataUnit.getSelectedRecords()
|
|
32
|
+
};
|
|
33
|
+
this.dataUnit.records.forEach(r => {
|
|
34
|
+
if (r.__record__id__.startsWith('NEW_')) {
|
|
35
|
+
duState.insertionMode = true;
|
|
36
|
+
duState.copyMode || (duState.copyMode = r['__record__source__id__'] != undefined);
|
|
37
|
+
}
|
|
38
|
+
});
|
|
39
|
+
this.dataState = duState;
|
|
40
|
+
if (action.type === Action.DATA_SAVED) {
|
|
41
|
+
const msg = this.getMessage("snkDataUnit.saveInfo", action.payload.records[0]);
|
|
42
|
+
if (msg != undefined) {
|
|
43
|
+
this.showSuccessMessage(msg);
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
if (action.type === Action.RECORDS_ADDED || action.type === Action.RECORDS_COPIED) {
|
|
47
|
+
this.insertionMode.emit();
|
|
48
|
+
}
|
|
49
|
+
if (action.type === Action.EDITION_CANCELED) {
|
|
50
|
+
this.cancelEdition.emit();
|
|
51
|
+
const cancelFinishMsg = this.getMessage("snkDataUnit.cancelInfo");
|
|
52
|
+
if (cancelFinishMsg != undefined) {
|
|
53
|
+
this.showSuccessMessage(cancelFinishMsg);
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
if (action.type === Action.RECORDS_REMOVED) {
|
|
57
|
+
const removeFinishMsg = this.getMessage("snkDataUnit.removeInfo", action.payload.cachedRecords[0]);
|
|
58
|
+
if (removeFinishMsg != undefined) {
|
|
59
|
+
this.showSuccessMessage(removeFinishMsg);
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
this._application.messagesBuilder.currentOperation = this.getMessageOperation();
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
observePageSize() {
|
|
66
|
+
if (this.dataUnit) {
|
|
67
|
+
this.dataUnit.pageSize = this.pageSize;
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
observeDataUnitName(newValue, oldValue) {
|
|
71
|
+
if (oldValue != newValue) {
|
|
72
|
+
this.dataUnit = undefined;
|
|
73
|
+
this.dataUnitName = newValue;
|
|
74
|
+
this.loadDataUnit();
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
observeEntityName(newValue, oldValue) {
|
|
78
|
+
if (oldValue != newValue) {
|
|
79
|
+
this.dataUnit = undefined;
|
|
80
|
+
this.entityName = newValue;
|
|
81
|
+
this.loadDataUnit();
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
observeDataState(newValue, oldValue) {
|
|
85
|
+
if (oldValue != newValue) {
|
|
86
|
+
this.dataStateChange.emit(newValue);
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
observeDataUnit() {
|
|
90
|
+
this.dataUnitReady.emit(this.dataUnit);
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* Pode-se obter o dataUnit através desse método. Outra forma, é ouvir o evento de
|
|
94
|
+
*
|
|
95
|
+
* @returns dataUnit
|
|
96
|
+
*/
|
|
97
|
+
async getDataUnit() {
|
|
98
|
+
return new Promise((resolve) => {
|
|
99
|
+
if (this.dataUnit) {
|
|
100
|
+
resolve(this.dataUnit);
|
|
101
|
+
}
|
|
102
|
+
else {
|
|
103
|
+
this._onDataUnitResolve.push(resolve);
|
|
104
|
+
}
|
|
105
|
+
});
|
|
106
|
+
}
|
|
107
|
+
async interceptAction(action) {
|
|
108
|
+
return new Promise(resolve => {
|
|
109
|
+
switch (action.type) {
|
|
110
|
+
case Action.RECORDS_ADDED:
|
|
111
|
+
if (this.isAllowed("INSERT")) {
|
|
112
|
+
resolve(action);
|
|
113
|
+
}
|
|
114
|
+
else {
|
|
115
|
+
ApplicationUtils.info(this.getMessage("snkDataUnit.forbiddenInsert"));
|
|
116
|
+
}
|
|
117
|
+
break;
|
|
118
|
+
case Action.RECORDS_COPIED:
|
|
119
|
+
if (this.isAllowed("CLONE")) {
|
|
120
|
+
resolve(action);
|
|
121
|
+
}
|
|
122
|
+
else {
|
|
123
|
+
ApplicationUtils.info(this.getMessage("snkDataUnit.forbiddenClone"));
|
|
124
|
+
}
|
|
125
|
+
break;
|
|
126
|
+
case Action.DATA_CHANGED:
|
|
127
|
+
case Action.CHANGING_DATA:
|
|
128
|
+
if (this.isAllowed("UPDATE")) {
|
|
129
|
+
resolve(action);
|
|
130
|
+
}
|
|
131
|
+
else {
|
|
132
|
+
this.dataUnit.cancelEdition();
|
|
133
|
+
ApplicationUtils.alert(this.getMessage("snkDataUnit.forbidden"), this.getMessage("snkDataUnit.forbiddenUpdate"));
|
|
134
|
+
}
|
|
135
|
+
break;
|
|
136
|
+
case Action.SAVING_DATA:
|
|
137
|
+
if (this.beforeSave) {
|
|
138
|
+
const continueAction = this.beforeSave(this.dataUnit);
|
|
139
|
+
if (continueAction instanceof Promise) {
|
|
140
|
+
continueAction.then(result => resolve(result ? action : undefined));
|
|
141
|
+
}
|
|
142
|
+
else {
|
|
143
|
+
resolve(continueAction ? action : undefined);
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
else {
|
|
147
|
+
resolve(action);
|
|
148
|
+
}
|
|
149
|
+
break;
|
|
150
|
+
case Action.DATA_SAVED:
|
|
151
|
+
if (this.afterSave) {
|
|
152
|
+
this.afterSave(this.dataUnit);
|
|
153
|
+
}
|
|
154
|
+
else {
|
|
155
|
+
resolve(action);
|
|
156
|
+
}
|
|
157
|
+
break;
|
|
158
|
+
case Action.EDITION_CANCELED:
|
|
159
|
+
if (this.dataState.hasDirtyRecords) {
|
|
160
|
+
const cancelConfirmation = this.getMessage("snkDataUnit.cancelConfirmation");
|
|
161
|
+
if (cancelConfirmation == undefined) {
|
|
162
|
+
resolve(action);
|
|
163
|
+
}
|
|
164
|
+
else {
|
|
165
|
+
const cancelConfirmationTitle = this.getMessage("snkDataUnit.cancelConfirmationTitle");
|
|
166
|
+
ApplicationUtils.confirm(cancelConfirmationTitle, cancelConfirmation)
|
|
167
|
+
.then((result) => resolve(result ? action : undefined));
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
else {
|
|
171
|
+
resolve(action);
|
|
172
|
+
}
|
|
173
|
+
break;
|
|
174
|
+
case Action.REMOVING_RECORDS:
|
|
175
|
+
if (this.isAllowed("REMOVE")) {
|
|
176
|
+
const removeConfirmation = this.getMessage("snkDataUnit.removeConfirmation");
|
|
177
|
+
if (removeConfirmation == undefined) {
|
|
178
|
+
resolve(action);
|
|
179
|
+
}
|
|
180
|
+
else {
|
|
181
|
+
const removeConfirmationTitle = this.getMessage("snkDataUnit.removeConfirmationTitle");
|
|
182
|
+
ApplicationUtils.confirm(removeConfirmationTitle, removeConfirmation, "delete", DialogType.CRITICAL, { btnConfirmDanger: true })
|
|
183
|
+
.then((result) => resolve(result ? action : undefined));
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
else {
|
|
187
|
+
ApplicationUtils.info(this.getMessage("snkDataUnit.forbiddenRemove"));
|
|
188
|
+
}
|
|
189
|
+
break;
|
|
190
|
+
default:
|
|
191
|
+
resolve(action);
|
|
192
|
+
}
|
|
193
|
+
});
|
|
194
|
+
}
|
|
195
|
+
showSuccessMessage(message) {
|
|
196
|
+
ApplicationUtils.info(message, { iconName: "check" });
|
|
197
|
+
}
|
|
198
|
+
isAllowed(flag) {
|
|
199
|
+
return this._permissions ? this._permissions.isSup || this._permissions[flag] : false;
|
|
200
|
+
}
|
|
201
|
+
/**
|
|
202
|
+
* Conforme mecanismo de mensagens, é possível customizar as mensagens dos blocos de construção
|
|
203
|
+
* através de um pequeno modulo na estrutura da aplicação:
|
|
204
|
+
* - Criar um arquivo no seguinte caminho: /messages/appmessages.msg.js.
|
|
205
|
+
* Para conhecer os detalhes do módulo, vide o arquivo neste projeto "/src/lib/message/resources/snk-data-unit.msg.ts"
|
|
206
|
+
*/
|
|
207
|
+
getMessage(key, params = undefined) {
|
|
208
|
+
if (!params) {
|
|
209
|
+
params = this.getMessageParams();
|
|
210
|
+
}
|
|
211
|
+
return this._application.messagesBuilder.getMessage(key, params);
|
|
212
|
+
}
|
|
213
|
+
getMessageParams() {
|
|
214
|
+
//TODO: Atualmente ainda não usamos o recurso de multiseleção do dataunit, mas no futuro
|
|
215
|
+
//precisaremos criar um mecanismo para oferecer todos os registros selecionados para a
|
|
216
|
+
//mensagem
|
|
217
|
+
return this.dataState.selectedRecords ? this.dataState.selectedRecords[0] : undefined;
|
|
218
|
+
}
|
|
219
|
+
getMessageOperation() {
|
|
220
|
+
if (this.dataState.copyMode) {
|
|
221
|
+
return OperationMap.CLONE;
|
|
222
|
+
}
|
|
223
|
+
if (this.dataState.insertionMode) {
|
|
224
|
+
return OperationMap.INSERT;
|
|
225
|
+
}
|
|
226
|
+
if (this.dataState.isDirty) {
|
|
227
|
+
return OperationMap.UPDATE;
|
|
228
|
+
}
|
|
229
|
+
return OperationMap.CLEAN;
|
|
230
|
+
}
|
|
231
|
+
async loadDataUnit() {
|
|
232
|
+
if (!this.dataUnit) {
|
|
233
|
+
if (this._application && this.entityName) {
|
|
234
|
+
const cacheName = this.dataUnitName ? this.dataUnitName : this.entityName;
|
|
235
|
+
this.dataUnit = await this._application.getDataUnit(this.entityName, cacheName);
|
|
236
|
+
this.dataUnit.pageSize = this.pageSize;
|
|
237
|
+
this.dataUnit.unsubscribe(this._dataUnitObserver);
|
|
238
|
+
this.dataUnit.addInterceptor(this);
|
|
239
|
+
this.dataUnit.subscribe(this._dataUnitObserver);
|
|
240
|
+
let resolver;
|
|
241
|
+
while (resolver = this._onDataUnitResolve.pop()) {
|
|
242
|
+
resolver(this.dataUnit);
|
|
243
|
+
}
|
|
244
|
+
if (this.autoLoad) {
|
|
245
|
+
setTimeout(() => {
|
|
246
|
+
this.dataUnit.loadData();
|
|
247
|
+
}, 500); //TODO: Ajustar para aguardar filterProvider do dataunit estar pronto.
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
//---------------------------------------------
|
|
253
|
+
// Lifecycle web component
|
|
254
|
+
//---------------------------------------------
|
|
255
|
+
componentWillLoad() {
|
|
256
|
+
this._application = ApplicationContext.getContextValue("__SNK__APPLICATION__");
|
|
257
|
+
this._application.getAllAccess().then(access => this._permissions = access);
|
|
258
|
+
}
|
|
259
|
+
componentDidLoad() {
|
|
260
|
+
this.loadDataUnit();
|
|
261
|
+
}
|
|
262
|
+
render() {
|
|
263
|
+
return (h(Host, null));
|
|
264
|
+
}
|
|
265
|
+
get element() { return getElement(this); }
|
|
266
|
+
static get watchers() { return {
|
|
267
|
+
"pageSize": ["observePageSize"],
|
|
268
|
+
"dataUnitName": ["observeDataUnitName"],
|
|
269
|
+
"entityName": ["observeEntityName"],
|
|
270
|
+
"dataState": ["observeDataState"],
|
|
271
|
+
"dataUnit": ["observeDataUnit"]
|
|
272
|
+
}; }
|
|
273
|
+
};
|
|
274
|
+
SnkDataUnit.style = snkDataUnitCss;
|
|
275
|
+
|
|
276
|
+
export { SnkDataUnit as snk_data_unit };
|
|
@@ -0,0 +1,274 @@
|
|
|
1
|
+
import { r as registerInstance, h, f as Host, g as getElement } from './index-2b4d2d14.js';
|
|
2
|
+
import { b as DataType, t as toString, A as ApplicationContext, E as ErrorException, O as ObjectUtils } from './index-f1d3e4da.js';
|
|
3
|
+
import { F as FilterItemType } from './filter-item-type.enum-61fbf80a.js';
|
|
4
|
+
|
|
5
|
+
const snkFilterBarCss = ".sc-snk-filter-bar-h{display:grid;grid-template-columns:minmax(100px, 100%) 1fr 1fr}.snk-filter__popover-container.sc-snk-filter-bar{display:flex;cursor:auto}.snk-filter__popover.sc-snk-filter-bar{display:flex;flex-direction:column;position:absolute;width:fit-content;height:fit-content;min-width:265px;z-index:var(--more-visible, 1);background-color:var(--background--xlight, #fff);border-radius:var(--border--radius-medium, 12px);box-shadow:var(--shadow, 0px 0px 16px 0px #000)}.snk-filter-item__editor-header.sc-snk-filter-bar{flex-grow:1;font-weight:var(--text-weight--medium, 400);color:var(--color--title-primary, #2B3A54)}.snk-filter__popover-rule.sc-snk-filter-bar{border-style:solid;border-color:var(--color--disable-secondary, #F2F5F8);border-radius:1px;border-width:1px;width:100%}.editor__ez-check.sc-snk-filter-bar{--ez-check__label--padding-left:0}.snk-filter-item__editor-header-button.sc-snk-filter-bar{cursor:pointer;flex-grow:0}.snk-filter-bar__divider.sc-snk-filter-bar{margin-bottom:var(--space--small)}.snk-filter-bar__filter-list-items-container.sc-snk-filter-bar{overflow-y:auto;max-height:360px;margin-top:var(--space--small, 6px)}.snk-filter-bar__filter-list-item.sc-snk-filter-bar{cursor:pointer;border-radius:var(--border--radius-small, 6px)}.snk-filter-bar__filter-list-item__label.sc-snk-filter-bar{color:var(--title--primary)}.snk-filter-bar__filter-list-item__label--secondary.sc-snk-filter-bar{color:var(--text--primary)}.snk-filter-bar__filter-list-item__icon.sc-snk-filter-bar{--ez-icon--color:var(--title--primary)}.snk-filter-bar__filter-list-item__icon--secondary.sc-snk-filter-bar{--ez-icon--color:var(--text--secondary)}.snk-filter-bar__filter-list-item.preselected.sc-snk-filter-bar{background-color:var(--background--medium)}.snk-filter-bar__filter-list-item.sc-snk-filter-bar:hover{background-color:var(--background--medium)}.snk-filter-bar__filter-list-items-container--empty.sc-snk-filter-bar{width:100%;height:100px;display:flex;justify-content:center;align-self:center;align-items:center}.snk-filter-bar__filter-list-items-button--active.sc-snk-filter-bar{position:relative}.snk-filter-bar__filter-list-items-button--active.sc-snk-filter-bar::after{display:flex;position:absolute;content:\"\";width:8px;height:8px;top:7px;left:17px;background-color:var(--icon--alert--color, #008561);border-radius:50%}";
|
|
6
|
+
|
|
7
|
+
const PERSONALIZED_FILTER = "PERSONALIZED_FILTER";
|
|
8
|
+
const DEFAULT_FILTER = "DEFAULT_FILTER";
|
|
9
|
+
const CLEAR_ALL_FILTERS = "CLEAR_ALL_FILTERS";
|
|
10
|
+
const SnkFilterBar = class {
|
|
11
|
+
constructor(hostRef) {
|
|
12
|
+
registerInstance(this, hostRef);
|
|
13
|
+
this._updateSequence = [];
|
|
14
|
+
this._calculateSortIndex = (item) => {
|
|
15
|
+
let index = item.hardFixed ? 1000000 : 0;
|
|
16
|
+
//campos Hard Fixed não variam a ordem
|
|
17
|
+
if (!item.hardFixed) {
|
|
18
|
+
index += item.fixed ? 100000 : 0;
|
|
19
|
+
index += item.value == undefined ? 0 : 10000;
|
|
20
|
+
index += this._updateSequence.lastIndexOf(item.id) + 1;
|
|
21
|
+
}
|
|
22
|
+
return index;
|
|
23
|
+
};
|
|
24
|
+
this._filtersComparator = (a, b) => {
|
|
25
|
+
return this._calculateSortIndex(b) - this._calculateSortIndex(a);
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Conforme mecanismo de mensagens, é possível customizar as mensagens dos blocos de construção
|
|
30
|
+
* através de um pequeno modulo na estrutura da aplicação:
|
|
31
|
+
* - Criar um arquivo no seguinte caminho: /messages/appmessages.msg.js.
|
|
32
|
+
* Para conhecer os detalhes do módulo, vide o arquivo neste projeto "/src/lib/message/resources/snk-filter-bar.msg.ts"
|
|
33
|
+
*/
|
|
34
|
+
getMessage(key, params) {
|
|
35
|
+
return this._application.messagesBuilder.getMessage(key, params);
|
|
36
|
+
}
|
|
37
|
+
getFilter(_dataUnit) {
|
|
38
|
+
var _a;
|
|
39
|
+
const filters = [];
|
|
40
|
+
(_a = this.filterConfig) === null || _a === void 0 ? void 0 : _a.filter(item => item.value).forEach(item => {
|
|
41
|
+
const filter = this.buildDUFilter(item);
|
|
42
|
+
if (filter) {
|
|
43
|
+
filters.push(filter);
|
|
44
|
+
}
|
|
45
|
+
});
|
|
46
|
+
return filters;
|
|
47
|
+
}
|
|
48
|
+
buildDUFilter(item) {
|
|
49
|
+
const { id, value, type, props, visible } = item;
|
|
50
|
+
if (value && visible) {
|
|
51
|
+
if (type === FilterItemType.BINARY_SELECT) {
|
|
52
|
+
const options = props.options;
|
|
53
|
+
const selectedOption = options.find(opt => opt.name === value);
|
|
54
|
+
//FIXME: ajustar o backend para não exigir parametros
|
|
55
|
+
return { name: id, expression: selectedOption.expression, params: [] };
|
|
56
|
+
}
|
|
57
|
+
if (type === FilterItemType.MULTI_SELECT) {
|
|
58
|
+
return { name: id, expression: props.expression, params: [{ name: id, dataType: DataType.TEXT, value }] };
|
|
59
|
+
}
|
|
60
|
+
if (type === FilterItemType.PERIOD) {
|
|
61
|
+
let { end, start } = value;
|
|
62
|
+
if (typeof end === "string") {
|
|
63
|
+
end = new Date(end);
|
|
64
|
+
}
|
|
65
|
+
if (typeof start === "string") {
|
|
66
|
+
start = new Date(start);
|
|
67
|
+
}
|
|
68
|
+
const params = [];
|
|
69
|
+
let expression;
|
|
70
|
+
if (end && start) {
|
|
71
|
+
expression = props.expression.fullfill;
|
|
72
|
+
params.push({ name: `${id}.START`, dataType: DataType.DATE, value: toString(DataType.DATE, start) }, { name: `${id}.END`, dataType: DataType.DATE, value: toString(DataType.DATE, end) });
|
|
73
|
+
}
|
|
74
|
+
else {
|
|
75
|
+
if (start) {
|
|
76
|
+
expression = props.expression.onlystart;
|
|
77
|
+
params.push({ name: id, dataType: DataType.DATE, value: toString(DataType.DATE, start) });
|
|
78
|
+
}
|
|
79
|
+
else {
|
|
80
|
+
expression = props.expression.onlyend;
|
|
81
|
+
params.push({ name: id, dataType: DataType.DATE, value: toString(DataType.DATE, end) });
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
return { name: id, expression, params };
|
|
85
|
+
}
|
|
86
|
+
if (type === FilterItemType.SEARCH) {
|
|
87
|
+
const expression = props.expression;
|
|
88
|
+
return { name: id, expression, params: [{ name: id, dataType: DataType.TEXT, value: toString(DataType.TEXT, value.value) }] };
|
|
89
|
+
}
|
|
90
|
+
if (type === FilterItemType.TEXT) {
|
|
91
|
+
const expression = props.expression;
|
|
92
|
+
return { name: id, expression, params: [{ name: id, dataType: DataType.TEXT, value: toString(DataType.TEXT, value) }] };
|
|
93
|
+
}
|
|
94
|
+
if (type === FilterItemType.NUMBER) {
|
|
95
|
+
const expression = props.expression;
|
|
96
|
+
return { name: id, expression, params: [{ name: id, dataType: DataType.NUMBER, value: toString(DataType.NUMBER, value) }] };
|
|
97
|
+
}
|
|
98
|
+
//No mapeamento dos outros tipos precisamos saber o tipo de dado.
|
|
99
|
+
}
|
|
100
|
+
return undefined;
|
|
101
|
+
}
|
|
102
|
+
componentWillLoad() {
|
|
103
|
+
this._application = ApplicationContext.getContextValue("__SNK__APPLICATION__");
|
|
104
|
+
if (this._application) {
|
|
105
|
+
this._application.getFilterBarConfig(this.configName)
|
|
106
|
+
.then((filters) => {
|
|
107
|
+
this.filterConfig = filters;
|
|
108
|
+
})
|
|
109
|
+
.catch(reason => {
|
|
110
|
+
throw new ErrorException(this.getMessage("snkFilterBar.failToLoadConfig"), reason);
|
|
111
|
+
});
|
|
112
|
+
}
|
|
113
|
+
if (this.dataUnit == undefined) {
|
|
114
|
+
let parent = this._element.parentElement;
|
|
115
|
+
while (parent) {
|
|
116
|
+
if (parent.tagName.toUpperCase() === "SNK-DATA-UNIT") {
|
|
117
|
+
const snkDataUnit = parent;
|
|
118
|
+
this.dataUnit = snkDataUnit.dataUnit;
|
|
119
|
+
if (this.dataUnit) {
|
|
120
|
+
this.dataUnit.addFilterProvider(this);
|
|
121
|
+
}
|
|
122
|
+
else {
|
|
123
|
+
snkDataUnit.addEventListener("dataUnitReady", (evt) => {
|
|
124
|
+
this.dataUnit = evt.detail;
|
|
125
|
+
this.dataUnit.addFilterProvider(this);
|
|
126
|
+
});
|
|
127
|
+
}
|
|
128
|
+
break;
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
parent = parent.parentElement;
|
|
132
|
+
}
|
|
133
|
+
else {
|
|
134
|
+
this.dataUnit.addFilterProvider(this);
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
getFilterItems() {
|
|
138
|
+
const pinnedItems = [];
|
|
139
|
+
const unpinnedItems = [];
|
|
140
|
+
this.filterConfig
|
|
141
|
+
.filter(item => item.visible)
|
|
142
|
+
.sort((a, b) => this._filtersComparator(a, b))
|
|
143
|
+
.forEach((item, index) => {
|
|
144
|
+
const filterItem = (h("snk-filter-item", { id: `filter-${item.id}`, config: this.normalizeItem(item), class: index > 0 ? "ez-padding-left--medium" : "", getMessage: (key, props) => this.getMessage(key, props), key: item.id }));
|
|
145
|
+
if (item.fixed || item.hardFixed) {
|
|
146
|
+
pinnedItems.push(filterItem);
|
|
147
|
+
}
|
|
148
|
+
else {
|
|
149
|
+
unpinnedItems.push(filterItem);
|
|
150
|
+
}
|
|
151
|
+
return filterItem;
|
|
152
|
+
});
|
|
153
|
+
const elements = [];
|
|
154
|
+
elements.push(...pinnedItems);
|
|
155
|
+
if (pinnedItems.length > 0 && unpinnedItems.length > 0) {
|
|
156
|
+
elements.push(h("hr", { class: "ez-divider-vertical ez-divider--dark ez-margin-left--medium snk-filter-bar__divider" }));
|
|
157
|
+
}
|
|
158
|
+
elements.push(...unpinnedItems);
|
|
159
|
+
return elements;
|
|
160
|
+
}
|
|
161
|
+
calculateUpdateSequence(item) {
|
|
162
|
+
if (item) {
|
|
163
|
+
this._updateSequence = this._updateSequence.filter(itemId => item.id !== itemId);
|
|
164
|
+
this._updateSequence.push(item.id);
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
filterChangeListener(evt) {
|
|
168
|
+
this.updateFilter(evt.detail);
|
|
169
|
+
}
|
|
170
|
+
normalizeItem(item) {
|
|
171
|
+
const normalized = Object.assign({}, item);
|
|
172
|
+
const optionals = ["props", "value", "hardFixed", "fixed"];
|
|
173
|
+
optionals.forEach(prop => {
|
|
174
|
+
if (normalized[prop] == undefined) {
|
|
175
|
+
delete normalized[prop];
|
|
176
|
+
}
|
|
177
|
+
});
|
|
178
|
+
if (item.value === "") {
|
|
179
|
+
delete item.value;
|
|
180
|
+
}
|
|
181
|
+
return normalized;
|
|
182
|
+
}
|
|
183
|
+
updateFilter(newItem, clear = false) {
|
|
184
|
+
let needLoad = false;
|
|
185
|
+
let updated = false;
|
|
186
|
+
this.filterConfig = this.filterConfig.map(item => {
|
|
187
|
+
if (clear) {
|
|
188
|
+
if (item.value != undefined) {
|
|
189
|
+
updated = true;
|
|
190
|
+
needLoad = true;
|
|
191
|
+
}
|
|
192
|
+
return Object.assign(Object.assign({}, item), { value: undefined });
|
|
193
|
+
}
|
|
194
|
+
else {
|
|
195
|
+
if (item.id === newItem.id) {
|
|
196
|
+
const normalizedOne = this.normalizeItem(item);
|
|
197
|
+
const normalizedTwo = this.normalizeItem(newItem);
|
|
198
|
+
updated = ObjectUtils.objectToString(normalizedOne) != ObjectUtils.objectToString(normalizedTwo);
|
|
199
|
+
needLoad = ObjectUtils.objectToString(normalizedOne.value) !== ObjectUtils.objectToString(normalizedTwo.value);
|
|
200
|
+
return newItem;
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
return item;
|
|
204
|
+
});
|
|
205
|
+
if (needLoad) {
|
|
206
|
+
this.dataUnit.loadData();
|
|
207
|
+
}
|
|
208
|
+
if (updated) {
|
|
209
|
+
this.calculateUpdateSequence(newItem);
|
|
210
|
+
this._application.saveFilterBarConfig(this.filterConfig, this.configName);
|
|
211
|
+
}
|
|
212
|
+
return needLoad;
|
|
213
|
+
}
|
|
214
|
+
getAddListItems() {
|
|
215
|
+
const hiddenItems = this.filterConfig
|
|
216
|
+
.filter(item => !item.visible)
|
|
217
|
+
.sort(this._filtersComparator);
|
|
218
|
+
return hiddenItems.map(filter => {
|
|
219
|
+
return { name: filter.id, label: filter.label, kind: "FILTER", iconName: null };
|
|
220
|
+
}).concat([
|
|
221
|
+
{ name: PERSONALIZED_FILTER, label: this.getMessage("snkFilterBar.customFilter"), iconName: "tune", kind: "FOOTER" },
|
|
222
|
+
{ name: DEFAULT_FILTER, label: this.getMessage("snkFilterBar.defaultFilter"), iconName: "configuration", kind: "FOOTER" }
|
|
223
|
+
]);
|
|
224
|
+
}
|
|
225
|
+
getActiveClass() {
|
|
226
|
+
const filterApplied = this.filterConfig.filter(item => item.value != undefined).length > 0;
|
|
227
|
+
return filterApplied ? "sc-snk-filter-bar snk-filter-bar__filter-list-items-button--active" : "";
|
|
228
|
+
}
|
|
229
|
+
getAppliedListItems() {
|
|
230
|
+
const appliedItems = this.filterConfig
|
|
231
|
+
.filter(item => item.value != undefined)
|
|
232
|
+
.sort(this._filtersComparator);
|
|
233
|
+
return appliedItems.map(filter => {
|
|
234
|
+
return { name: filter.id, label: filter.label, kind: "FILTER", iconName: null };
|
|
235
|
+
}).concat([
|
|
236
|
+
{ name: CLEAR_ALL_FILTERS, label: this.getMessage("snkFilterBar.clearAllFilters"), iconName: "cleaning", kind: "FOOTER" }
|
|
237
|
+
]);
|
|
238
|
+
}
|
|
239
|
+
addFilterHandler(itemName) {
|
|
240
|
+
const filterItem = this.filterConfig.find(currentFilter => currentFilter.id === itemName);
|
|
241
|
+
if (filterItem) {
|
|
242
|
+
this.updateFilter(Object.assign(Object.assign({}, filterItem), { visible: true }));
|
|
243
|
+
window.requestAnimationFrame(() => {
|
|
244
|
+
const itemElement = this._element.querySelector("#filter-" + itemName);
|
|
245
|
+
if (itemElement) {
|
|
246
|
+
itemElement.showUp();
|
|
247
|
+
}
|
|
248
|
+
});
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
appliedFilterHandler(itemName) {
|
|
252
|
+
if (itemName === CLEAR_ALL_FILTERS) {
|
|
253
|
+
if (this.updateFilter(null, true)) {
|
|
254
|
+
this._application.info(this.getMessage("snkFilterBar.successfullyCleaned"), { iconName: "check" });
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
else {
|
|
258
|
+
const itemElement = this._element.querySelector("#filter-" + itemName);
|
|
259
|
+
if (itemElement) {
|
|
260
|
+
itemElement.showUp(true);
|
|
261
|
+
}
|
|
262
|
+
}
|
|
263
|
+
}
|
|
264
|
+
render() {
|
|
265
|
+
if (!this.dataUnit || !this.filterConfig || this.filterConfig.length === 0) {
|
|
266
|
+
return undefined;
|
|
267
|
+
}
|
|
268
|
+
return (h(Host, null, h("ez-scroller", { direction: "horizontal" }, this.getFilterItems()), h("snk-filter-list", { items: this.getAppliedListItems(), getMessage: (key, params) => this.getMessage(key, params), emptyText: this.getMessage("snkFilterBar.emptyAppliedFiltersList"), findFilterText: this.getMessage("snkFilterBar.findFilter"), iconName: "filter", class: "ez-padding-left--medium", buttonClass: this.getActiveClass(), onSnkItemSelected: evt => this.appliedFilterHandler(evt.detail) }), h("snk-filter-list", { items: this.getAddListItems(), label: this.getMessage("snkFilterBar.addFilter"), getMessage: (key, params) => this.getMessage(key, params), emptyText: this.getMessage("snkFilterBar.emptyFiltersList"), findFilterText: this.getMessage("snkFilterBar.findField"), class: "ez-padding-left--medium", onSnkItemSelected: evt => this.addFilterHandler(evt.detail) }, h("ez-icon", { slot: "leftIcon", class: "ez-padding-right--small", iconName: "plus" }))));
|
|
269
|
+
}
|
|
270
|
+
get _element() { return getElement(this); }
|
|
271
|
+
};
|
|
272
|
+
SnkFilterBar.style = snkFilterBarCss;
|
|
273
|
+
|
|
274
|
+
export { SnkFilterBar as snk_filter_bar };
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { r as registerInstance, h, f as Host } from './index-2b4d2d14.js';
|
|
2
|
+
import { F as FilterItemType } from './filter-item-type.enum-61fbf80a.js';
|
|
3
|
+
|
|
4
|
+
const SnkFilterBinarySelect = class {
|
|
5
|
+
constructor(hostRef) {
|
|
6
|
+
registerInstance(this, hostRef);
|
|
7
|
+
}
|
|
8
|
+
isSelected(option) {
|
|
9
|
+
return this.value == undefined || this.value === option;
|
|
10
|
+
}
|
|
11
|
+
ezChangeListener(evt) {
|
|
12
|
+
if (!evt.detail) {
|
|
13
|
+
this.assertCheckedOption(evt.target);
|
|
14
|
+
}
|
|
15
|
+
this.updateValue();
|
|
16
|
+
}
|
|
17
|
+
assertCheckedOption(updatingCheck) {
|
|
18
|
+
if (updatingCheck === this._checkOne) {
|
|
19
|
+
this._checkTwo.value = true;
|
|
20
|
+
}
|
|
21
|
+
else {
|
|
22
|
+
this._checkOne.value = true;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
updateValue() {
|
|
26
|
+
if (!this._checkOne.value || !this._checkTwo.value) {
|
|
27
|
+
const [optOne, optTwo] = this.config.props.options;
|
|
28
|
+
this.value = this._checkOne.value ? optOne.name : optTwo.name;
|
|
29
|
+
}
|
|
30
|
+
else {
|
|
31
|
+
this.value = undefined;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
render() {
|
|
35
|
+
if (!this.config || this.config.type !== FilterItemType.BINARY_SELECT) {
|
|
36
|
+
return undefined;
|
|
37
|
+
}
|
|
38
|
+
const [optOne, optTwo] = this.config.props.options;
|
|
39
|
+
return (h(Host, null, h("ez-check", { label: optOne.label, class: "sc-snk-filter-bar editor__ez-check", ref: (ref) => this._checkOne = ref, value: this.isSelected(optOne.name) }), h("ez-check", { label: optTwo.label, class: "sc-snk-filter-bar editor__ez-check", ref: (ref) => this._checkTwo = ref, value: this.isSelected(optTwo.name) })));
|
|
40
|
+
}
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
export { SnkFilterBinarySelect as snk_filter_binary_select };
|