@sankhyalabs/sankhyablocks 1.3.31-beta.1 → 1.3.31-beta.11
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-13239761.js +188 -0
- package/dist/cjs/{index-1133bc2a.js → index-c6671817.js} +416 -9
- package/dist/cjs/loader.cjs.js +2 -2
- package/dist/cjs/sankhyablocks.cjs.js +2 -2
- package/dist/cjs/snk-application.cjs.entry.js +283 -108
- package/dist/cjs/snk-crud.cjs.entry.js +64 -0
- package/dist/cjs/snk-data-unit.cjs.entry.js +277 -0
- package/dist/cjs/snk-form_2.cjs.entry.js +177 -0
- package/dist/cjs/snk-pesquisa.cjs.entry.js +6 -3
- package/dist/cjs/snk-taskbar.cjs.entry.js +159 -0
- package/dist/cjs/taskbar-elements-73d524e5.js +70 -0
- package/dist/cjs/teste-pesquisa.cjs.entry.js +1 -1
- package/dist/collection/collection-manifest.json +5 -0
- package/dist/collection/components/snk-application/errorhandler/snk-error-handler.js +2 -2
- package/dist/collection/components/snk-application/snk-application.js +267 -63
- package/dist/collection/components/snk-crud/snk-crud.css +5 -0
- package/dist/collection/components/snk-crud/snk-crud.js +137 -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 +528 -0
- package/dist/collection/components/snk-form/snk-form.css +34 -0
- package/dist/collection/components/snk-form/snk-form.js +220 -0
- package/dist/collection/components/snk-grid/snk-grid.css +5 -0
- package/dist/collection/components/snk-grid/snk-grid.js +148 -0
- package/dist/collection/components/snk-pesquisa/snk-pesquisa.css +56 -13
- package/dist/collection/components/snk-pesquisa/snk-pesquisa.js +5 -1
- package/dist/collection/components/snk-taskbar/elements/taskbar-elements.js +65 -0
- package/dist/collection/components/snk-taskbar/snk-taskbar.css +3 -0
- package/dist/collection/components/snk-taskbar/snk-taskbar.js +271 -0
- package/dist/collection/lib/http/data-fetcher/DataFetcher.js +1 -1
- package/dist/collection/lib/http/data-fetcher/fetchers/dataunit-fetcher.js +52 -21
- package/dist/collection/lib/http/data-fetcher/fetchers/grid-config-fetcher.js +4 -3
- package/dist/collection/lib/http/data-fetcher/fetchers/pesquisa-fetcher.js +2 -0
- package/dist/collection/lib/message/SnkMessageBuilder.js +119 -0
- package/dist/collection/lib/message/resources/snk-data-unit.msg.js +22 -0
- package/dist/collection/lib/message/resources/snk-form.msg.js +10 -0
- package/dist/collection/lib/message/resources/snk-taskbar.msg.js +16 -0
- package/dist/components/SnkMessageBuilder.js +166 -0
- package/dist/components/snk-application2.js +284 -107
- package/dist/components/snk-crud.d.ts +11 -0
- package/dist/components/snk-crud.js +101 -0
- package/dist/components/snk-data-unit.d.ts +11 -0
- package/dist/components/snk-data-unit.js +300 -0
- package/dist/components/snk-form.d.ts +11 -0
- package/dist/components/snk-form.js +6 -0
- package/dist/components/snk-form2.js +140 -0
- package/dist/components/snk-grid.d.ts +11 -0
- package/dist/components/snk-grid.js +6 -0
- package/dist/components/snk-grid2.js +91 -0
- package/dist/components/snk-pesquisa2.js +5 -2
- package/dist/components/snk-taskbar.d.ts +11 -0
- package/dist/components/snk-taskbar.js +6 -0
- package/dist/components/snk-taskbar2.js +240 -0
- package/dist/esm/SnkMessageBuilder-3835f9d8.js +166 -0
- package/dist/esm/{index-ffda6382.js → index-6a83ac96.js} +416 -10
- package/dist/esm/loader.js +2 -2
- package/dist/esm/sankhyablocks.js +2 -2
- package/dist/esm/snk-application.entry.js +283 -108
- package/dist/esm/snk-crud.entry.js +60 -0
- package/dist/esm/snk-data-unit.entry.js +273 -0
- package/dist/esm/snk-form_2.entry.js +172 -0
- package/dist/esm/snk-pesquisa.entry.js +6 -3
- package/dist/esm/snk-taskbar.entry.js +155 -0
- package/dist/esm/taskbar-elements-6d01a640.js +68 -0
- package/dist/esm/teste-pesquisa.entry.js +1 -1
- package/dist/sankhyablocks/p-4c7b32d6.entry.js +1 -0
- package/dist/sankhyablocks/p-5e1b7e51.entry.js +1 -0
- package/dist/sankhyablocks/p-72bccbb6.js +1 -0
- package/dist/sankhyablocks/p-8c74d163.entry.js +1 -0
- package/dist/sankhyablocks/p-bab507ad.entry.js +1 -0
- package/dist/sankhyablocks/p-cd1dc099.js +2 -0
- package/dist/sankhyablocks/{p-2a7b4cb3.entry.js → p-d25637c9.entry.js} +1 -1
- package/dist/sankhyablocks/p-dd10a5e3.js +1 -0
- package/dist/sankhyablocks/p-e942c604.entry.js +69 -0
- package/dist/sankhyablocks/p-f4d0394b.entry.js +1 -0
- package/dist/sankhyablocks/sankhyablocks.esm.js +1 -1
- package/dist/types/components/snk-application/snk-application.d.ts +109 -15
- package/dist/types/components/snk-taskbar/elements/taskbar-elements.d.ts +25 -0
- package/dist/types/components/snk-taskbar/snk-taskbar.d.ts +53 -0
- package/dist/types/components.d.ts +372 -6
- package/dist/types/lib/http/data-fetcher/fetchers/dataunit-fetcher.d.ts +2 -0
- package/dist/types/lib/http/data-fetcher/fetchers/grid-config-fetcher.d.ts +3 -3
- 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-form.msg.d.ts +2 -0
- package/dist/types/lib/message/resources/snk-taskbar.msg.d.ts +2 -0
- package/package.json +5 -5
- package/react/components.d.ts +5 -0
- package/react/components.js +5 -0
- package/react/components.js.map +1 -1
- package/dist/sankhyablocks/p-d62412bb.entry.js +0 -1
- package/dist/sankhyablocks/p-e6e91d5f.entry.js +0 -69
- package/dist/sankhyablocks/p-edcb9d8e.js +0 -2
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { r as registerInstance, h, g as getElement } from './index-6a83ac96.js';
|
|
2
|
+
|
|
3
|
+
const snkCrudCss = ".sc-snk-crud-h{display:flex;height:100%;width:100%}";
|
|
4
|
+
|
|
5
|
+
const GRID_MODE = 0;
|
|
6
|
+
const FORM_MODE = 1;
|
|
7
|
+
const SnkCrud = class {
|
|
8
|
+
constructor(hostRef) {
|
|
9
|
+
registerInstance(this, hostRef);
|
|
10
|
+
}
|
|
11
|
+
async gridToForm(keepFormMode = false) {
|
|
12
|
+
this._backToGrid = !keepFormMode && await this._viewStack.getSelectedIndex() === GRID_MODE;
|
|
13
|
+
this._viewStack.show(FORM_MODE);
|
|
14
|
+
}
|
|
15
|
+
async executeAction(act) {
|
|
16
|
+
if (act === "GRID_MODE") {
|
|
17
|
+
this._viewStack.show(GRID_MODE);
|
|
18
|
+
}
|
|
19
|
+
else if (act === "FORM_MODE" || act === "UPDATE") {
|
|
20
|
+
this.gridToForm(act !== "UPDATE");
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
insertionModeHandler() {
|
|
24
|
+
this.gridToForm();
|
|
25
|
+
}
|
|
26
|
+
cancelHandler() {
|
|
27
|
+
if (this._backToGrid) {
|
|
28
|
+
this._viewStack.show(GRID_MODE);
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
componentWillLoad() {
|
|
32
|
+
let parent = this._element.parentElement;
|
|
33
|
+
while (parent) {
|
|
34
|
+
if (parent.tagName.toUpperCase() === "SNK-DATA-UNIT") {
|
|
35
|
+
this._snkDataUnit = parent;
|
|
36
|
+
this._snkDataUnit.addEventListener("insertionMode", () => this.insertionModeHandler());
|
|
37
|
+
this._snkDataUnit.addEventListener("cancelEdition", () => this.cancelHandler());
|
|
38
|
+
this._dataUnit = this._snkDataUnit.dataUnit;
|
|
39
|
+
this._dataState = this._snkDataUnit.dataState;
|
|
40
|
+
if (!this._dataUnit) {
|
|
41
|
+
this._snkDataUnit.addEventListener("dataUnitReady", (evt) => {
|
|
42
|
+
this._dataUnit = evt.detail;
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
this._snkDataUnit.addEventListener("dataStateChange", (evt) => {
|
|
46
|
+
this._dataState = evt.detail;
|
|
47
|
+
});
|
|
48
|
+
break;
|
|
49
|
+
}
|
|
50
|
+
parent = parent.parentElement;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
render() {
|
|
54
|
+
return (h("ez-view-stack", { ref: (ref) => this._viewStack = ref }, h("stack-item", null, h("snk-grid", { configName: this.configName, onGridDoubleClick: () => this.gridToForm(true), onActionClick: evt => this.executeAction(evt.detail), actionsList: this.actionsList }, h("slot", null))), h("stack-item", null, h("snk-form", { configName: this.configName, actionsList: this.actionsList, onExit: () => this._viewStack.show(GRID_MODE), recordsValidator: this.recordsValidator, onActionClick: evt => this.executeAction(evt.detail) }))));
|
|
55
|
+
}
|
|
56
|
+
get _element() { return getElement(this); }
|
|
57
|
+
};
|
|
58
|
+
SnkCrud.style = snkCrudCss;
|
|
59
|
+
|
|
60
|
+
export { SnkCrud as snk_crud };
|
|
@@ -0,0 +1,273 @@
|
|
|
1
|
+
import { r as registerInstance, c as createEvent, h, g as getElement, H as Host } from './index-6a83ac96.js';
|
|
2
|
+
import { Action, ApplicationContext } from '@sankhyalabs/core';
|
|
3
|
+
import { ApplicationUtils } from '@sankhyalabs/ezui/dist/collection/utils';
|
|
4
|
+
import { O as OperationMap } from './SnkMessageBuilder-3835f9d8.js';
|
|
5
|
+
|
|
6
|
+
const snkDataUnitCss = ".sc-snk-data-unit-h{display:flex;flex-direction:column;height:100%}";
|
|
7
|
+
|
|
8
|
+
const SnkDataUnit = class {
|
|
9
|
+
constructor(hostRef) {
|
|
10
|
+
registerInstance(this, hostRef);
|
|
11
|
+
this.dataStateChange = createEvent(this, "dataStateChange", 7);
|
|
12
|
+
this.dataUnitReady = createEvent(this, "dataUnitReady", 7);
|
|
13
|
+
this.insertionMode = createEvent(this, "insertionMode", 7);
|
|
14
|
+
this.cancelEdition = createEvent(this, "cancelEdition", 7);
|
|
15
|
+
this._onDataUnitResolve = [];
|
|
16
|
+
/**
|
|
17
|
+
* Determina quantas linhas são retornadas por página
|
|
18
|
+
*/
|
|
19
|
+
this.pageSize = 150;
|
|
20
|
+
/**
|
|
21
|
+
* Quando ativada essa propriedade faz com que haja uma carga imediata no DataUnit
|
|
22
|
+
*/
|
|
23
|
+
this.autoLoad = true;
|
|
24
|
+
this._dataUnitObserver = (action) => {
|
|
25
|
+
const duState = {
|
|
26
|
+
insertionMode: false,
|
|
27
|
+
hasNext: this.dataUnit.hasNext(),
|
|
28
|
+
hasPrevious: this.dataUnit.hasPrevious(),
|
|
29
|
+
copyMode: false,
|
|
30
|
+
isDirty: this.dataUnit.isDirty(),
|
|
31
|
+
hasDirtyRecords: this.dataUnit.hasDirtyRecords(),
|
|
32
|
+
selectedRecords: this.dataUnit.getSelectedRecords()
|
|
33
|
+
};
|
|
34
|
+
this.dataUnit.records.forEach(r => {
|
|
35
|
+
if (r.__record__id__.startsWith('NEW_')) {
|
|
36
|
+
duState.insertionMode = true;
|
|
37
|
+
duState.copyMode || (duState.copyMode = r['__record__source__id__'] != undefined);
|
|
38
|
+
}
|
|
39
|
+
});
|
|
40
|
+
this.dataState = duState;
|
|
41
|
+
if (action.type === Action.DATA_SAVED) {
|
|
42
|
+
const msg = this.getMessage("snkDataUnit.saveInfo", action.payload.records[0]);
|
|
43
|
+
if (msg != undefined) {
|
|
44
|
+
this.showSuccessMessage(msg);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
if (action.type === Action.RECORDS_ADDED || action.type === Action.RECORDS_COPIED) {
|
|
48
|
+
this.insertionMode.emit();
|
|
49
|
+
}
|
|
50
|
+
if (action.type === Action.EDITION_CANCELED) {
|
|
51
|
+
this.cancelEdition.emit();
|
|
52
|
+
const cancelFinishMsg = this.getMessage("snkDataUnit.cancelInfo");
|
|
53
|
+
if (cancelFinishMsg != undefined) {
|
|
54
|
+
this.showSuccessMessage(cancelFinishMsg);
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
if (action.type === Action.RECORDS_REMOVED) {
|
|
58
|
+
const removeFinishMsg = this.getMessage("snkDataUnit.removeInfo", action.payload.cachedRecords[0]);
|
|
59
|
+
if (removeFinishMsg != undefined) {
|
|
60
|
+
this.showSuccessMessage(removeFinishMsg);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
this._application.messagesBuilder.currentOperation = this.getMessageOperation();
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
observePageSize() {
|
|
67
|
+
if (this.dataUnit) {
|
|
68
|
+
this.dataUnit.pageSize = this.pageSize;
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
observeDataUnitName(newValue, oldValue) {
|
|
72
|
+
if (oldValue != newValue) {
|
|
73
|
+
this.dataUnit = undefined;
|
|
74
|
+
this.dataUnitName = newValue;
|
|
75
|
+
this.loadDataUnit();
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
observeEntityName(newValue, oldValue) {
|
|
79
|
+
if (oldValue != newValue) {
|
|
80
|
+
this.dataUnit = undefined;
|
|
81
|
+
this.entityName = newValue;
|
|
82
|
+
this.loadDataUnit();
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
observeDataState(newValue, oldValue) {
|
|
86
|
+
if (oldValue != newValue) {
|
|
87
|
+
this.dataStateChange.emit(newValue);
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
observeDataUnit() {
|
|
91
|
+
this.dataUnitReady.emit(this.dataUnit);
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* Pode-se obter o dataUnit através desse método. Outra forma, é ouvir o evento de
|
|
95
|
+
*
|
|
96
|
+
* @returns dataUnit
|
|
97
|
+
*/
|
|
98
|
+
async getDataUnit() {
|
|
99
|
+
return new Promise((resolve) => {
|
|
100
|
+
if (this.dataUnit) {
|
|
101
|
+
resolve(this.dataUnit);
|
|
102
|
+
}
|
|
103
|
+
else {
|
|
104
|
+
this._onDataUnitResolve.push(resolve);
|
|
105
|
+
}
|
|
106
|
+
});
|
|
107
|
+
}
|
|
108
|
+
async interceptAction(action) {
|
|
109
|
+
return new Promise(resolve => {
|
|
110
|
+
switch (action.type) {
|
|
111
|
+
case Action.RECORDS_ADDED:
|
|
112
|
+
if (this.isAllowed("INSERT")) {
|
|
113
|
+
resolve(action);
|
|
114
|
+
}
|
|
115
|
+
else {
|
|
116
|
+
ApplicationUtils.info(this.getMessage("snkDataUnit.forbiddenInsert"));
|
|
117
|
+
}
|
|
118
|
+
break;
|
|
119
|
+
case Action.RECORDS_COPIED:
|
|
120
|
+
if (this.isAllowed("CLONE")) {
|
|
121
|
+
resolve(action);
|
|
122
|
+
}
|
|
123
|
+
else {
|
|
124
|
+
ApplicationUtils.info(this.getMessage("snkDataUnit.forbiddenClone"));
|
|
125
|
+
}
|
|
126
|
+
break;
|
|
127
|
+
case Action.DATA_CHANGED:
|
|
128
|
+
case Action.CHANGING_DATA:
|
|
129
|
+
if (this.isAllowed("UPDATE")) {
|
|
130
|
+
resolve(action);
|
|
131
|
+
}
|
|
132
|
+
else {
|
|
133
|
+
this.dataUnit.cancelEdition();
|
|
134
|
+
ApplicationUtils.info(this.getMessage("snkDataUnit.forbiddenUpdate"));
|
|
135
|
+
}
|
|
136
|
+
break;
|
|
137
|
+
case Action.SAVING_DATA:
|
|
138
|
+
if (this.beforeSave) {
|
|
139
|
+
const continueAction = this.beforeSave(this.dataUnit);
|
|
140
|
+
if (continueAction instanceof Promise) {
|
|
141
|
+
continueAction.then(result => resolve(result ? action : undefined));
|
|
142
|
+
}
|
|
143
|
+
else {
|
|
144
|
+
resolve(continueAction ? action : undefined);
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
else {
|
|
148
|
+
resolve(action);
|
|
149
|
+
}
|
|
150
|
+
break;
|
|
151
|
+
case Action.DATA_SAVED:
|
|
152
|
+
if (this.afterSave) {
|
|
153
|
+
this.afterSave(this.dataUnit);
|
|
154
|
+
}
|
|
155
|
+
else {
|
|
156
|
+
resolve(action);
|
|
157
|
+
}
|
|
158
|
+
break;
|
|
159
|
+
case Action.EDITION_CANCELED:
|
|
160
|
+
if (this.dataState.hasDirtyRecords) {
|
|
161
|
+
const cancelConfirmation = this.getMessage("snkDataUnit.cancelConfirmation");
|
|
162
|
+
if (cancelConfirmation == undefined) {
|
|
163
|
+
resolve(action);
|
|
164
|
+
}
|
|
165
|
+
else {
|
|
166
|
+
const cancelConfirmationTitle = this.getMessage("snkDataUnit.cancelConfirmationTitle");
|
|
167
|
+
ApplicationUtils.confirm(cancelConfirmationTitle, cancelConfirmation)
|
|
168
|
+
.then((result) => resolve(result ? action : undefined));
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
else {
|
|
172
|
+
resolve(action);
|
|
173
|
+
}
|
|
174
|
+
break;
|
|
175
|
+
case Action.REMOVING_RECORDS:
|
|
176
|
+
if (this.isAllowed("REMOVE")) {
|
|
177
|
+
const removeConfirmation = this.getMessage("snkDataUnit.removeConfirmation");
|
|
178
|
+
if (removeConfirmation == undefined) {
|
|
179
|
+
resolve(action);
|
|
180
|
+
}
|
|
181
|
+
else {
|
|
182
|
+
const removeConfirmationTitle = this.getMessage("snkDataUnit.removeConfirmationTitle");
|
|
183
|
+
ApplicationUtils.confirm(removeConfirmationTitle, removeConfirmation, "delete", true, { btnConfirmDanger: true })
|
|
184
|
+
.then((result) => resolve(result ? action : undefined));
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
else {
|
|
188
|
+
ApplicationUtils.info(this.getMessage("snkDataUnit.forbiddenRemove"));
|
|
189
|
+
}
|
|
190
|
+
break;
|
|
191
|
+
default:
|
|
192
|
+
resolve(action);
|
|
193
|
+
}
|
|
194
|
+
});
|
|
195
|
+
}
|
|
196
|
+
showSuccessMessage(message) {
|
|
197
|
+
ApplicationUtils.info(message, { iconName: "check" });
|
|
198
|
+
}
|
|
199
|
+
isAllowed(flag) {
|
|
200
|
+
return this._permissions ? this._permissions.isSup || this._permissions[flag] : false;
|
|
201
|
+
}
|
|
202
|
+
/**
|
|
203
|
+
* Conforme mecanismo de mensagens, é possível customizar as mensagens dos blocos de construção
|
|
204
|
+
* através de um pequeno modulo na estrutura da aplicação:
|
|
205
|
+
* - Criar um arquivo no seguinte caminho: /messages/appmessages.msg.js.
|
|
206
|
+
* Para conhecer os detalhes do módulo, vide o arquivo neste projeto "/src/lib/message/resources/snk-data-unit.msg.ts"
|
|
207
|
+
*/
|
|
208
|
+
getMessage(key, params = undefined) {
|
|
209
|
+
if (!params) {
|
|
210
|
+
params = this.getMessageParams();
|
|
211
|
+
}
|
|
212
|
+
return this._application.messagesBuilder.getMessage(key, params);
|
|
213
|
+
}
|
|
214
|
+
getMessageParams() {
|
|
215
|
+
//TODO: Atualmente ainda não usamos o recurso de multiseleção do dataunit, mas no futuro
|
|
216
|
+
//precisaremos criar um mecanismo para oferecer todos os registros selecionados para a
|
|
217
|
+
//mensagem
|
|
218
|
+
return this.dataState.selectedRecords ? this.dataState.selectedRecords[0] : undefined;
|
|
219
|
+
}
|
|
220
|
+
getMessageOperation() {
|
|
221
|
+
if (this.dataState.copyMode) {
|
|
222
|
+
return OperationMap.CLONE;
|
|
223
|
+
}
|
|
224
|
+
if (this.dataState.insertionMode) {
|
|
225
|
+
return OperationMap.INSERT;
|
|
226
|
+
}
|
|
227
|
+
if (this.dataState.isDirty) {
|
|
228
|
+
return OperationMap.UPDATE;
|
|
229
|
+
}
|
|
230
|
+
return OperationMap.CLEAN;
|
|
231
|
+
}
|
|
232
|
+
async loadDataUnit() {
|
|
233
|
+
if (!this.dataUnit) {
|
|
234
|
+
if (this._application && this.entityName) {
|
|
235
|
+
const cacheName = this.dataUnitName ? this.dataUnitName : this.entityName;
|
|
236
|
+
this.dataUnit = await this._application.getDataUnit(this.entityName, cacheName);
|
|
237
|
+
this.dataUnit.pageSize = this.pageSize;
|
|
238
|
+
this.dataUnit.unsubscribe(this._dataUnitObserver);
|
|
239
|
+
this.dataUnit.addInterceptor(this);
|
|
240
|
+
this.dataUnit.subscribe(this._dataUnitObserver);
|
|
241
|
+
let resolver;
|
|
242
|
+
while (resolver = this._onDataUnitResolve.pop()) {
|
|
243
|
+
resolver(this.dataUnit);
|
|
244
|
+
}
|
|
245
|
+
if (this.autoLoad) {
|
|
246
|
+
this.dataUnit.loadData();
|
|
247
|
+
}
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
//---------------------------------------------
|
|
252
|
+
// Lifecycle web component
|
|
253
|
+
//---------------------------------------------
|
|
254
|
+
componentWillLoad() {
|
|
255
|
+
this._application = ApplicationContext.getContextValue("__SNK__APPLICATION__");
|
|
256
|
+
this._application.getAllAccess().then(access => this._permissions = access);
|
|
257
|
+
this.loadDataUnit();
|
|
258
|
+
}
|
|
259
|
+
render() {
|
|
260
|
+
return (h(Host, null));
|
|
261
|
+
}
|
|
262
|
+
get element() { return getElement(this); }
|
|
263
|
+
static get watchers() { return {
|
|
264
|
+
"pageSize": ["observePageSize"],
|
|
265
|
+
"dataUnitName": ["observeDataUnitName"],
|
|
266
|
+
"entityName": ["observeEntityName"],
|
|
267
|
+
"dataState": ["observeDataState"],
|
|
268
|
+
"dataUnit": ["observeDataUnit"]
|
|
269
|
+
}; }
|
|
270
|
+
};
|
|
271
|
+
SnkDataUnit.style = snkDataUnitCss;
|
|
272
|
+
|
|
273
|
+
export { SnkDataUnit as snk_data_unit };
|
|
@@ -0,0 +1,172 @@
|
|
|
1
|
+
import { r as registerInstance, c as createEvent, h, g as getElement } from './index-6a83ac96.js';
|
|
2
|
+
import { ApplicationContext } from '@sankhyalabs/core';
|
|
3
|
+
import { T as TaskbarElement } from './taskbar-elements-6d01a640.js';
|
|
4
|
+
|
|
5
|
+
const snkFormCss = ".sc-snk-form-h{display:block}.snk-form.sc-snk-form{position:relative;padding:var(--space--large);padding-top:var(--space--medium)}.snk-form__header.sc-snk-form{position:relative;padding-top:var(--space--medium);padding-bottom:var(--space--medium);margin-bottom:var(--space--medium)}.snk-form__header--fixed.sc-snk-form{position:sticky;top:0;background:var(--background--body);z-index:var(--more-visible, 2);padding-left:var(--space--large);padding-right:var(--space--large);margin-left:calc(var(--space--large) * -1);margin-right:calc(var(--space--large) * -1);width:calc(100% + (var(--space--large) * 2))}";
|
|
6
|
+
|
|
7
|
+
const SnkForm = class {
|
|
8
|
+
constructor(hostRef) {
|
|
9
|
+
registerInstance(this, hostRef);
|
|
10
|
+
this.exit = createEvent(this, "exit", 7);
|
|
11
|
+
this.actionClick = createEvent(this, "actionClick", 7);
|
|
12
|
+
}
|
|
13
|
+
getFormConfig() {
|
|
14
|
+
return (this._dataState && this._dataState.insertionMode ? this._insertionFormConfig : this._editionFormConfig);
|
|
15
|
+
}
|
|
16
|
+
getInsertionHiddenFields(formConfig) {
|
|
17
|
+
const hiddenFields = [];
|
|
18
|
+
formConfig === null || formConfig === void 0 ? void 0 : formConfig.forEach(cfg => {
|
|
19
|
+
const def = this._dataUnit.getField(cfg.name);
|
|
20
|
+
if (def === null || def === void 0 ? void 0 : def.readOnly) {
|
|
21
|
+
hiddenFields.push(cfg.name);
|
|
22
|
+
}
|
|
23
|
+
});
|
|
24
|
+
return hiddenFields;
|
|
25
|
+
}
|
|
26
|
+
exitForm() {
|
|
27
|
+
if (this._dataUnit.isDirty()) {
|
|
28
|
+
this._dataUnit.cancelEdition({ after: () => this.exit.emit() });
|
|
29
|
+
}
|
|
30
|
+
else {
|
|
31
|
+
this.exit.emit();
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
getDisabledButtons() {
|
|
35
|
+
const disabled = [];
|
|
36
|
+
if (!this._dataState.hasPrevious) {
|
|
37
|
+
disabled.push("PREVIOUS");
|
|
38
|
+
}
|
|
39
|
+
if (!this._dataState.hasNext) {
|
|
40
|
+
disabled.push("NEXT");
|
|
41
|
+
}
|
|
42
|
+
return disabled;
|
|
43
|
+
}
|
|
44
|
+
loadInsertionConfig() {
|
|
45
|
+
if (this._dataUnit && this._configLoaded) {
|
|
46
|
+
this._insertionFormConfig = this._editionFormConfig.filter(fieldCfg => {
|
|
47
|
+
const def = this._dataUnit.getField(fieldCfg.name);
|
|
48
|
+
if (def === null || def === void 0 ? void 0 : def.readOnly) {
|
|
49
|
+
return false;
|
|
50
|
+
}
|
|
51
|
+
return true;
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Conforme mecanismo de mensagens, é possível customizar as mensagens dos blocos de construção
|
|
57
|
+
* através de um pequeno modulo na estrutura da aplicação:
|
|
58
|
+
* - Criar um arquivo no seguinte caminho: /messages/appmessages.msg.js.
|
|
59
|
+
* Para conhecer os detalhes do módulo, vide o arquivo neste projeto "/src/lib/message/resources/snk-form.msg.ts"
|
|
60
|
+
*/
|
|
61
|
+
getMessage(key) {
|
|
62
|
+
return this._application.messagesBuilder.getMessage(key, this.getMessageParams());
|
|
63
|
+
}
|
|
64
|
+
getMessageParams() {
|
|
65
|
+
var _a;
|
|
66
|
+
return ((_a = this._dataState) === null || _a === void 0 ? void 0 : _a.selectedRecords) ? this._dataState.selectedRecords[0] : undefined;
|
|
67
|
+
}
|
|
68
|
+
componentWillLoad() {
|
|
69
|
+
this._application = ApplicationContext.getContextValue("__SNK__APPLICATION__");
|
|
70
|
+
if (this._application) {
|
|
71
|
+
this._application.loadFormConfig(this.configName).then(cfg => {
|
|
72
|
+
this._configLoaded = true;
|
|
73
|
+
this._editionFormConfig = cfg;
|
|
74
|
+
this.loadInsertionConfig();
|
|
75
|
+
});
|
|
76
|
+
//Forçamos a carga dos acessos pra aproveitar a request inicial.
|
|
77
|
+
this._application.getAllAccess();
|
|
78
|
+
}
|
|
79
|
+
let parent = this._element.parentElement;
|
|
80
|
+
while (parent) {
|
|
81
|
+
if (parent.tagName.toUpperCase() === "SNK-DATA-UNIT") {
|
|
82
|
+
this._snkDataUnit = parent;
|
|
83
|
+
this._dataUnit = this._snkDataUnit.dataUnit;
|
|
84
|
+
this._dataState = this._snkDataUnit.dataState;
|
|
85
|
+
if (this._dataUnit) {
|
|
86
|
+
this.loadInsertionConfig();
|
|
87
|
+
}
|
|
88
|
+
else {
|
|
89
|
+
this._snkDataUnit.addEventListener("dataUnitReady", (evt) => {
|
|
90
|
+
this._dataUnit = evt.detail;
|
|
91
|
+
this.loadInsertionConfig();
|
|
92
|
+
});
|
|
93
|
+
}
|
|
94
|
+
this._snkDataUnit.addEventListener("dataStateChange", (evt) => {
|
|
95
|
+
this._dataState = evt.detail;
|
|
96
|
+
});
|
|
97
|
+
break;
|
|
98
|
+
}
|
|
99
|
+
parent = parent.parentElement;
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
render() {
|
|
103
|
+
if (!this._configLoaded || !this._dataUnit || !this._dataState) {
|
|
104
|
+
return undefined;
|
|
105
|
+
}
|
|
106
|
+
return (h("section", { class: "snk-form" }, h("div", { class: "snk-form__header snk-form__header--fixed ez-row" }, h("div", { class: "ez-col ez-col--sd-6 ez-col--tb-6", key: "formHeader" }, h("ez-button", { title: this.getMessage("snkForm.goBackTitle"), mode: "icon", iconName: "arrow_back", class: "ez-padding-right--medium", size: "small", onClick: () => this.exitForm() }), h("h1", { class: "ez-title ez-title--primary ez-title--xlarge ez-align--middle" }, this.getMessage("snkForm.title"))), h("div", { class: "ez-col ez-col--sd-6 ez-col--tb-6 ez-align--right" }, h("snk-taskbar", { key: "formTaskbar", buttons: this._dataState.isDirty ? "CANCEL,SAVE" : "PREVIOUS,NEXT,DIVIDER,CLONE,REMOVE,MORE_OPTIONS,DIVIDER,GRID_MODE,INSERT", primaryButton: this._dataState.isDirty ? "SAVE" : "INSERT", disabledButtons: this.getDisabledButtons(), actionsList: this.actionsList, dataUnit: this._dataUnit }))), h("section", null, h("div", { class: "ez-row" }, h("div", { class: "ez-col ez-col--sd-12" }, h("ez-form", { key: "ezForm" + this._snkDataUnit.entityName, dataUnit: this._dataUnit, config: this.getFormConfig(), recordsValidator: this.recordsValidator }))))));
|
|
107
|
+
}
|
|
108
|
+
get _element() { return getElement(this); }
|
|
109
|
+
};
|
|
110
|
+
SnkForm.style = snkFormCss;
|
|
111
|
+
|
|
112
|
+
const snkGridCss = ".sc-snk-grid-h{display:flex;height:100%;width:100%}";
|
|
113
|
+
|
|
114
|
+
const SnkGrid = class {
|
|
115
|
+
constructor(hostRef) {
|
|
116
|
+
registerInstance(this, hostRef);
|
|
117
|
+
this.actionClick = createEvent(this, "actionClick", 7);
|
|
118
|
+
this.gridDoubleClick = createEvent(this, "gridDoubleClick", 7);
|
|
119
|
+
}
|
|
120
|
+
getHeaderButtons() {
|
|
121
|
+
return this._dataState && this._dataState.selectedRecords.length > 0 ? "UPDATE,CLONE,REMOVE,MORE_OPTIONS,DIVIDER,REFRESH" : "REFRESH";
|
|
122
|
+
}
|
|
123
|
+
actionClickHandler(evt) {
|
|
124
|
+
if (evt.detail === TaskbarElement.CONFIG_GRID && this._grid) {
|
|
125
|
+
this._grid.openGridConfig();
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
saveConfig(config) {
|
|
129
|
+
const snkApplication = ApplicationContext.getContextValue("__SNK__APPLICATION__");
|
|
130
|
+
if (snkApplication) {
|
|
131
|
+
snkApplication.saveGridConfig(config);
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
componentWillLoad() {
|
|
135
|
+
const snkApplication = ApplicationContext.getContextValue("__SNK__APPLICATION__");
|
|
136
|
+
if (snkApplication) {
|
|
137
|
+
snkApplication.loadGridConfig(this.configName).then(cfg => {
|
|
138
|
+
this._gridConfig = cfg;
|
|
139
|
+
this._configLoaded = true;
|
|
140
|
+
});
|
|
141
|
+
//Forçamos a carga dos acessos pra aproveitar a request inicial.
|
|
142
|
+
snkApplication.getAllAccess();
|
|
143
|
+
}
|
|
144
|
+
let parent = this._element.parentElement;
|
|
145
|
+
while (parent) {
|
|
146
|
+
if (parent.tagName.toUpperCase() === "SNK-DATA-UNIT") {
|
|
147
|
+
this._snkDataUnit = parent;
|
|
148
|
+
this._dataUnit = this._snkDataUnit.dataUnit;
|
|
149
|
+
if (!this._dataUnit) {
|
|
150
|
+
this._snkDataUnit.addEventListener("dataUnitReady", (evt) => {
|
|
151
|
+
this._dataUnit = evt.detail;
|
|
152
|
+
});
|
|
153
|
+
}
|
|
154
|
+
this._snkDataUnit.addEventListener("dataStateChange", (evt) => {
|
|
155
|
+
this._dataState = evt.detail;
|
|
156
|
+
});
|
|
157
|
+
break;
|
|
158
|
+
}
|
|
159
|
+
parent = parent.parentElement;
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
render() {
|
|
163
|
+
if (!this._configLoaded || !this._dataUnit) {
|
|
164
|
+
return undefined;
|
|
165
|
+
}
|
|
166
|
+
return (h("div", { class: "ez-flex ez-flex--column ez-flex-item--auto ez-padding--large" }, h("div", { class: "ez-row ez-padding-bottom--medium ez-margin-bottom--medium" }, h("div", { class: "ez-col ez-col--sd-9 ez-col--tb-9 ez-align--bottom" }, h("slot", null)), h("div", { class: "ez-col ez-col--sd-3 ez-col--tb-3 ez-align--right" }, h("snk-taskbar", { onActionClick: evt => this.actionClickHandler(evt), key: "topTaskbar", dataUnit: this._dataUnit, buttons: "FORM_MODE,CONFIG_GRID,INSERT", primaryButton: "INSERT" }))), h("ez-grid", { ref: ref => this._grid = ref, dataUnit: this._dataUnit, key: "grid-" + this._snkDataUnit.entityName, config: this._gridConfig, onConfigChange: evt => { this.saveConfig(evt.detail); }, onEzDoubleClick: () => this.gridDoubleClick.emit() }, h("snk-taskbar", { dataUnit: this._dataUnit, buttons: this.getHeaderButtons(), slot: "leftButtons", actionsList: this.actionsList }))));
|
|
167
|
+
}
|
|
168
|
+
get _element() { return getElement(this); }
|
|
169
|
+
};
|
|
170
|
+
SnkGrid.style = snkGridCss;
|
|
171
|
+
|
|
172
|
+
export { SnkForm as snk_form, SnkGrid as snk_grid };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { r as registerInstance, h, H as Host } from './index-
|
|
1
|
+
import { r as registerInstance, h, H as Host } from './index-6a83ac96.js';
|
|
2
2
|
import { ObjectUtils, StringUtils } from '@sankhyalabs/core';
|
|
3
3
|
|
|
4
|
-
const snkPesquisaCss = ".sc-snk-pesquisa-h{--snk-pesquisa--font-size:var(--text--medium, 14px);--snk-pesquisa--font-family:var(--font-pattern, Arial);--snk-pesquisa--font-weight:var(--text-weight--medium, 400);--snk-pesquisa__records--color:var(--text--primary, #626e82);--snk-pesquisa__records--padding-vertical:var(--space--medium, 12px);--snk-pesquisa__content--padding-right:var(--space--small, 6px);--snk-pesquisa__content-scrollbar--background-color:var(--
|
|
4
|
+
const snkPesquisaCss = ".sc-snk-pesquisa-h{--snk-pesquisa--font-size:var(--text--medium, 14px);--snk-pesquisa--font-family:var(--font-pattern, Arial);--snk-pesquisa--font-weight:var(--text-weight--medium, 400);--snk-pesquisa__records--color:var(--text--primary, #626e82);--snk-pesquisa__records--padding-vertical:var(--space--medium, 12px);--snk-pesquisa__content--padding-right:var(--space--small, 6px);--snk-pesquisa__content-scrollbar--background-color-primary:var(--scrollbar--primary, #2B3A54);--snk-pesquisa__content-scrollbar--background-color-secondary:var(--scrollbar--secondary, #E5EAF0);--snk-pesquisa__content-scrollbar--border-radius:var(--border--radius-small, 6px);--snk-pesquisa__content-scrollbar--width:var(--space--medium, 12px);--snk-pesquisa__btn--color:var(--title--primary, #2B3A54);--snk-pesquisa__btn-disabled--color:var(--text--disable, #AFB6C0);--snk-pesquisa__btn-hover--color:var(--color--primary, #4e4e4e);max-height:100%;height:100%;display:flex;flex-direction:column;overflow-y:auto}.snk-pesquisa.sc-snk-pesquisa{display:flex;flex-direction:column;height:100%}.snk-pesquisa__input.sc-snk-pesquisa{display:flex;width:100%;box-sizing:border-box;padding-top:4px;padding-right:4px}.snk-pesquisa__input.sc-snk-pesquisa ez-icon.sc-snk-pesquisa{--ez-icon--color:inherit;font-weight:var(--text-weight--large, 600)}.snk-pesquisa__content.sc-snk-pesquisa{display:flex;flex-direction:column;height:100%;overflow-y:auto;scrollbar-width:thin;scrollbar-color:var(--snk-pesquisa__content-scrollbar--background-color-primary) var(--snk-pesquisa__content-scrollbar--background-color-secondary);padding-right:var(--snk-pesquisa__content--padding-right)}.snk-pesquisa__content.sc-snk-pesquisa::-webkit-scrollbar-track{background-color:var(--snk-pesquisa__content-scrollbar--background-color-secondary);border-radius:var(--snk-pesquisa__content-scrollbar--border-radius)}.snk-pesquisa__content.sc-snk-pesquisa::-webkit-scrollbar-thumb{background-color:var(--snk-pesquisa__content-scrollbar--background-color-primary);border-radius:var(--snk-pesquisa__content-scrollbar--border-radius)}.snk-pesquisa__content.sc-snk-pesquisa::-webkit-scrollbar{background-color:var(--snk-pesquisa__content-scrollbar--background-color-secondary);width:var(--snk-pesquisa__content-scrollbar--width);max-width:var(--snk-pesquisa__content-scrollbar--width);min-width:var(--snk-pesquisa__content-scrollbar--width)}.snk-pesquisa__records.sc-snk-pesquisa{font-family:var(--snk-pesquisa--font-family);font-weight:var(--snk-pesquisa--font-weight);font-size:var(--snk-pesquisa--font-size);color:var(--snk-pesquisa__records--color);padding-bottom:var(--snk-pesquisa__records--padding-vertical);padding-top:var(--snk-pesquisa__records--padding-vertical)}.snk-pesquisa__btn.sc-snk-pesquisa{outline:none;border:none;background:none;cursor:pointer;color:var(--snk-pesquisa__btn--color)}.snk-pesquisa__btn.sc-snk-pesquisa:disabled{cursor:unset;color:var(--snk-pesquisa__btn-disabled--color)}.snk-pesquisa__btn.sc-snk-pesquisa:disabled:hover{cursor:unset;color:var(--snk-pesquisa__btn-disabled--color)}.snk-pesquisa__btn.sc-snk-pesquisa:hover{color:var(--snk-pesquisa__btn-hover--color)}";
|
|
5
5
|
|
|
6
6
|
const SnkPesquisa = class {
|
|
7
7
|
constructor(hostRef) {
|
|
@@ -295,7 +295,10 @@ const SnkPesquisa = class {
|
|
|
295
295
|
: 'Os resultados de sua pesquisa aparecerão aqui...';
|
|
296
296
|
}
|
|
297
297
|
render() {
|
|
298
|
-
|
|
298
|
+
var _a;
|
|
299
|
+
return (h(Host, null, h("div", { class: "snk-pesquisa" }, h("div", { class: "snk-pesquisa__input" }, h("ez-text-input", { label: "Buscar", class: "ez-margin-right--medium", canShowError: false, ref: (ref) => this._textInput = ref, onEzChange: (event) => this.onChangeValue(event), value: this.argument }, h("ez-icon", { slot: "leftIcon", iconName: "search" }), this.argument && ((_a = this._textInput) === null || _a === void 0 ? void 0 : _a.value)
|
|
300
|
+
? h("button", { slot: "rightIcon", class: "snk-pesquisa__btn", onClick: () => this.clearSearch() }, h("ez-icon", { iconName: "close" }))
|
|
301
|
+
: undefined), h("ez-button", { class: "ez-button--primary", label: "Pesquisar", onClick: () => this.onClickSearch() })), h("label", { class: "snk-pesquisa__records" }, this.getMessageView()), h("div", { class: "snk-pesquisa__content" }, this._itemList && this._itemList.map((item) => {
|
|
299
302
|
return (h("ez-card-item", { onEzClick: (event) => this.createOption(event.detail), item: item }));
|
|
300
303
|
})))));
|
|
301
304
|
}
|