@sankhyalabs/sankhyablocks 1.3.31-beta.6 → 1.3.32
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/{index-532bcc28.js → index-1133bc2a.js} +9 -419
- package/dist/cjs/loader.cjs.js +2 -2
- package/dist/cjs/sankhyablocks.cjs.js +2 -2
- package/dist/cjs/snk-application.cjs.entry.js +99 -213
- package/dist/cjs/snk-pesquisa.cjs.entry.js +6 -3
- package/dist/cjs/teste-pesquisa.cjs.entry.js +1 -1
- package/dist/collection/collection-manifest.json +0 -4
- package/dist/collection/components/snk-application/snk-application.js +48 -165
- package/dist/collection/components/snk-pesquisa/snk-pesquisa.css +49 -10
- package/dist/collection/components/snk-pesquisa/snk-pesquisa.js +5 -1
- package/dist/collection/lib/http/data-fetcher/fetchers/dataunit-fetcher.js +21 -52
- package/dist/collection/lib/http/data-fetcher/fetchers/grid-config-fetcher.js +3 -4
- package/dist/collection/lib/http/data-fetcher/fetchers/pesquisa-fetcher.js +2 -0
- package/dist/components/snk-application2.js +98 -213
- package/dist/components/snk-pesquisa2.js +5 -2
- package/dist/esm/{index-0b078db7.js → index-ffda6382.js} +10 -419
- package/dist/esm/loader.js +2 -2
- package/dist/esm/sankhyablocks.js +2 -2
- package/dist/esm/snk-application.entry.js +99 -213
- package/dist/esm/snk-pesquisa.entry.js +6 -3
- package/dist/esm/teste-pesquisa.entry.js +1 -1
- package/dist/sankhyablocks/p-24238a55.entry.js +1 -0
- package/dist/sankhyablocks/{p-a8305c35.entry.js → p-2a7b4cb3.entry.js} +1 -1
- package/dist/sankhyablocks/p-bd1b31db.entry.js +69 -0
- package/dist/sankhyablocks/p-edcb9d8e.js +2 -0
- package/dist/sankhyablocks/sankhyablocks.esm.js +1 -1
- package/dist/types/components/snk-application/snk-application.d.ts +13 -90
- package/dist/types/components.d.ts +2 -334
- package/dist/types/lib/http/data-fetcher/fetchers/dataunit-fetcher.d.ts +0 -2
- package/dist/types/lib/http/data-fetcher/fetchers/grid-config-fetcher.d.ts +1 -1
- package/package.json +5 -5
- package/react/components.d.ts +0 -4
- package/react/components.js +0 -4
- package/react/components.js.map +1 -1
- package/dist/cjs/snk-data-unit.cjs.entry.js +0 -189
- package/dist/cjs/snk-form.cjs.entry.js +0 -95
- package/dist/cjs/snk-grid.cjs.entry.js +0 -64
- package/dist/cjs/snk-taskbar.cjs.entry.js +0 -140
- package/dist/cjs/taskbar-elements-9d47b416.js +0 -70
- package/dist/collection/components/snk-data-unit/snk-data-unit.css +0 -6
- package/dist/collection/components/snk-data-unit/snk-data-unit.js +0 -449
- package/dist/collection/components/snk-form/snk-form.css +0 -3
- package/dist/collection/components/snk-form/snk-form.js +0 -194
- package/dist/collection/components/snk-grid/snk-grid.css +0 -5
- package/dist/collection/components/snk-grid/snk-grid.js +0 -128
- package/dist/collection/components/snk-taskbar/elements/taskbar-elements.js +0 -65
- package/dist/collection/components/snk-taskbar/snk-taskbar.css +0 -3
- package/dist/collection/components/snk-taskbar/snk-taskbar.js +0 -252
- package/dist/components/snk-data-unit.d.ts +0 -11
- package/dist/components/snk-data-unit.js +0 -213
- package/dist/components/snk-form.d.ts +0 -11
- package/dist/components/snk-form.js +0 -121
- package/dist/components/snk-grid.d.ts +0 -11
- package/dist/components/snk-grid.js +0 -88
- package/dist/components/snk-taskbar.d.ts +0 -11
- package/dist/components/snk-taskbar.js +0 -6
- package/dist/components/snk-taskbar2.js +0 -221
- package/dist/esm/snk-data-unit.entry.js +0 -185
- package/dist/esm/snk-form.entry.js +0 -91
- package/dist/esm/snk-grid.entry.js +0 -60
- package/dist/esm/snk-taskbar.entry.js +0 -136
- package/dist/esm/taskbar-elements-3ba30bf4.js +0 -68
- package/dist/sankhyablocks/p-3cb106f7.entry.js +0 -69
- package/dist/sankhyablocks/p-3fce3190.entry.js +0 -1
- package/dist/sankhyablocks/p-560fdf54.entry.js +0 -1
- package/dist/sankhyablocks/p-574764bf.js +0 -1
- package/dist/sankhyablocks/p-8f7b9a85.entry.js +0 -1
- package/dist/sankhyablocks/p-9c225717.entry.js +0 -1
- package/dist/sankhyablocks/p-a45dba1a.js +0 -2
- package/dist/sankhyablocks/p-a670853c.entry.js +0 -1
- package/dist/types/components/snk-taskbar/elements/taskbar-elements.d.ts +0 -25
- package/dist/types/components/snk-taskbar/snk-taskbar.d.ts +0 -45
|
@@ -1,449 +0,0 @@
|
|
|
1
|
-
import { Component, Host, h, Event, Element, Prop, Watch, Method } from '@stencil/core';
|
|
2
|
-
import { Action, ApplicationContext } from '@sankhyalabs/core';
|
|
3
|
-
import { ApplicationUtils } from '@sankhyalabs/ezui/dist/collection/utils';
|
|
4
|
-
export class SnkDataUnit {
|
|
5
|
-
constructor() {
|
|
6
|
-
this._onDataUnitResolve = [];
|
|
7
|
-
/**
|
|
8
|
-
* Determina quantas linhas são retornadas por página
|
|
9
|
-
*/
|
|
10
|
-
this.pageSize = 150;
|
|
11
|
-
/**
|
|
12
|
-
* Quando ativada essa propriedade faz com que haja uma carga imediata no DataUnit
|
|
13
|
-
*/
|
|
14
|
-
this.autoLoad = true;
|
|
15
|
-
this._dataUnitObserver = (action) => {
|
|
16
|
-
let msg = this.getActionInfo(action.type);
|
|
17
|
-
if (msg) {
|
|
18
|
-
ApplicationUtils.info(msg);
|
|
19
|
-
}
|
|
20
|
-
if (action.type === Action.RECORDS_ADDED || action.type === Action.RECORDS_COPIED) {
|
|
21
|
-
this.insertionMode.emit();
|
|
22
|
-
}
|
|
23
|
-
const duState = {
|
|
24
|
-
insertionMode: false,
|
|
25
|
-
hasNext: this.dataUnit.hasNext(),
|
|
26
|
-
hasPrevious: this.dataUnit.hasPrevious(),
|
|
27
|
-
copyMode: false,
|
|
28
|
-
isDirty: this.dataUnit.isDirty(),
|
|
29
|
-
selectedRecords: this.dataUnit.getSelectedRecords()
|
|
30
|
-
};
|
|
31
|
-
this.dataUnit.records.forEach(r => {
|
|
32
|
-
if (r.__record__id__.startsWith('NEW_')) {
|
|
33
|
-
duState.insertionMode = true;
|
|
34
|
-
duState.copyMode || (duState.copyMode = r['__record__source__id__'] != undefined);
|
|
35
|
-
}
|
|
36
|
-
});
|
|
37
|
-
this.dataState = duState;
|
|
38
|
-
};
|
|
39
|
-
}
|
|
40
|
-
observePageSize() {
|
|
41
|
-
if (this.dataUnit) {
|
|
42
|
-
this.dataUnit.pageSize = this.pageSize;
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
observeDataUnitName(newValue, oldValue) {
|
|
46
|
-
if (oldValue != newValue) {
|
|
47
|
-
this.dataUnit = undefined;
|
|
48
|
-
this.dataUnitName = newValue;
|
|
49
|
-
this.loadDataUnit();
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
observeEntityName(newValue, oldValue) {
|
|
53
|
-
if (oldValue != newValue) {
|
|
54
|
-
this.dataUnit = undefined;
|
|
55
|
-
this.entityName = newValue;
|
|
56
|
-
this.loadDataUnit();
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
observeDataState(newValue, oldValue) {
|
|
60
|
-
if (oldValue != newValue) {
|
|
61
|
-
this.dataStateChange.emit(newValue);
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
observeDataUnit() {
|
|
65
|
-
this.dataUnitReady.emit(this.dataUnit);
|
|
66
|
-
}
|
|
67
|
-
/**
|
|
68
|
-
* Pode-se obter o dataUnit através desse método. Outra forma, é ouvir o evento de
|
|
69
|
-
*
|
|
70
|
-
* @returns dataUnit
|
|
71
|
-
*/
|
|
72
|
-
async getDataUnit() {
|
|
73
|
-
return new Promise((resolve) => {
|
|
74
|
-
if (this.dataUnit) {
|
|
75
|
-
resolve(this.dataUnit);
|
|
76
|
-
}
|
|
77
|
-
else {
|
|
78
|
-
this._onDataUnitResolve.push(resolve);
|
|
79
|
-
}
|
|
80
|
-
});
|
|
81
|
-
}
|
|
82
|
-
async interceptAction(action) {
|
|
83
|
-
return new Promise(resolve => {
|
|
84
|
-
switch (action.type) {
|
|
85
|
-
case Action.SAVING_DATA:
|
|
86
|
-
if (this.beforeSave) {
|
|
87
|
-
const continueAction = this.beforeSave(this.dataUnit);
|
|
88
|
-
if (continueAction instanceof Promise) {
|
|
89
|
-
continueAction.then(result => resolve(result ? action : undefined));
|
|
90
|
-
}
|
|
91
|
-
else {
|
|
92
|
-
resolve(continueAction ? action : undefined);
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
else {
|
|
96
|
-
resolve(action);
|
|
97
|
-
}
|
|
98
|
-
break;
|
|
99
|
-
case Action.DATA_SAVED:
|
|
100
|
-
if (this.afterSave) {
|
|
101
|
-
this.afterSave(this.dataUnit);
|
|
102
|
-
}
|
|
103
|
-
else {
|
|
104
|
-
resolve(action);
|
|
105
|
-
}
|
|
106
|
-
break;
|
|
107
|
-
case Action.EDITION_CANCELED:
|
|
108
|
-
ApplicationUtils.confirm(this.i18n("components.warning"), this.i18n("components.confirmCancelEdition"))
|
|
109
|
-
.then((result) => resolve(result ? action : undefined));
|
|
110
|
-
break;
|
|
111
|
-
case Action.REMOVING_RECORDS:
|
|
112
|
-
ApplicationUtils.confirm(this.i18n("components.delete"), this.i18n("components.confirmRemoveRecord"), "delete", true, { btnConfirmDanger: true })
|
|
113
|
-
.then((result) => resolve(result ? action : undefined));
|
|
114
|
-
break;
|
|
115
|
-
default:
|
|
116
|
-
resolve(action);
|
|
117
|
-
}
|
|
118
|
-
});
|
|
119
|
-
}
|
|
120
|
-
getActionInfo(action) {
|
|
121
|
-
if (this.messageBuilder) {
|
|
122
|
-
return this.messageBuilder(action, this.dataState, this.dataUnit);
|
|
123
|
-
}
|
|
124
|
-
if (action === Action.EDITION_CANCELED) {
|
|
125
|
-
return this.i18n("components.editionCanceled");
|
|
126
|
-
}
|
|
127
|
-
}
|
|
128
|
-
async loadDataUnit() {
|
|
129
|
-
if (!this.dataUnit) {
|
|
130
|
-
const app = ApplicationContext.getContextValue("__SNK__APPLICATION__");
|
|
131
|
-
if (app && this.entityName) {
|
|
132
|
-
const cacheName = this.dataUnitName ? this.dataUnitName : this.entityName;
|
|
133
|
-
this.dataUnit = await app.getDataUnit(this.entityName, cacheName);
|
|
134
|
-
this.dataUnit.pageSize = this.pageSize;
|
|
135
|
-
this.dataUnit.unsubscribe(this._dataUnitObserver);
|
|
136
|
-
this.dataUnit.addInterceptor(this);
|
|
137
|
-
this.dataUnit.subscribe(this._dataUnitObserver);
|
|
138
|
-
let resolver;
|
|
139
|
-
while (resolver = this._onDataUnitResolve.pop()) {
|
|
140
|
-
resolver(this.dataUnit);
|
|
141
|
-
}
|
|
142
|
-
if (this.autoLoad) {
|
|
143
|
-
this.dataUnit.loadData();
|
|
144
|
-
}
|
|
145
|
-
}
|
|
146
|
-
}
|
|
147
|
-
}
|
|
148
|
-
i18n(key) {
|
|
149
|
-
const pt_br = {
|
|
150
|
-
"components.warning": "Aviso",
|
|
151
|
-
"components.delete": "Excluir",
|
|
152
|
-
"components.confirmRemoveRecord": "Deseja realmente excluir o registro atual?",
|
|
153
|
-
"components.confirmCancelEdition": "As alterações realizadas serão descartadas<br/><br/><b>Você realmente gostaria de sair?</b>",
|
|
154
|
-
"components.editionCanceled": "Todas as alterações foram descartadas.",
|
|
155
|
-
};
|
|
156
|
-
return pt_br[key];
|
|
157
|
-
}
|
|
158
|
-
//---------------------------------------------
|
|
159
|
-
// Lifecycle web component
|
|
160
|
-
//---------------------------------------------
|
|
161
|
-
componentDidRender() {
|
|
162
|
-
this.loadDataUnit();
|
|
163
|
-
}
|
|
164
|
-
render() {
|
|
165
|
-
return (h(Host, null));
|
|
166
|
-
}
|
|
167
|
-
static get is() { return "snk-data-unit"; }
|
|
168
|
-
static get encapsulation() { return "scoped"; }
|
|
169
|
-
static get originalStyleUrls() { return {
|
|
170
|
-
"$": ["snk-data-unit.css"]
|
|
171
|
-
}; }
|
|
172
|
-
static get styleUrls() { return {
|
|
173
|
-
"$": ["snk-data-unit.css"]
|
|
174
|
-
}; }
|
|
175
|
-
static get properties() { return {
|
|
176
|
-
"dataState": {
|
|
177
|
-
"type": "unknown",
|
|
178
|
-
"mutable": true,
|
|
179
|
-
"complexType": {
|
|
180
|
-
"original": "DataState",
|
|
181
|
-
"resolved": "DataState",
|
|
182
|
-
"references": {
|
|
183
|
-
"DataState": {
|
|
184
|
-
"location": "local"
|
|
185
|
-
}
|
|
186
|
-
}
|
|
187
|
-
},
|
|
188
|
-
"required": false,
|
|
189
|
-
"optional": false,
|
|
190
|
-
"docs": {
|
|
191
|
-
"tags": [],
|
|
192
|
-
"text": "O estato atual dos dados, isto \u00E9 se h\u00E1 altera\u00E7\u00E3o, insers\u00E3o, as linhas selecionadas, etc."
|
|
193
|
-
}
|
|
194
|
-
},
|
|
195
|
-
"dataUnitName": {
|
|
196
|
-
"type": "string",
|
|
197
|
-
"mutable": false,
|
|
198
|
-
"complexType": {
|
|
199
|
-
"original": "string",
|
|
200
|
-
"resolved": "string",
|
|
201
|
-
"references": {}
|
|
202
|
-
},
|
|
203
|
-
"required": false,
|
|
204
|
-
"optional": false,
|
|
205
|
-
"docs": {
|
|
206
|
-
"tags": [],
|
|
207
|
-
"text": "Este atributo \u00E9 usado para criar o dataUnit uma \u00FAnica vez. Se omitido ser\u00E1 usado o pr\u00F3prio nome\nda entidade."
|
|
208
|
-
},
|
|
209
|
-
"attribute": "data-unit-name",
|
|
210
|
-
"reflect": false
|
|
211
|
-
},
|
|
212
|
-
"entityName": {
|
|
213
|
-
"type": "string",
|
|
214
|
-
"mutable": false,
|
|
215
|
-
"complexType": {
|
|
216
|
-
"original": "string",
|
|
217
|
-
"resolved": "string",
|
|
218
|
-
"references": {}
|
|
219
|
-
},
|
|
220
|
-
"required": false,
|
|
221
|
-
"optional": false,
|
|
222
|
-
"docs": {
|
|
223
|
-
"tags": [],
|
|
224
|
-
"text": "Determina qual a entidade representa os dados em quest\u00E3o."
|
|
225
|
-
},
|
|
226
|
-
"attribute": "entity-name",
|
|
227
|
-
"reflect": false
|
|
228
|
-
},
|
|
229
|
-
"pageSize": {
|
|
230
|
-
"type": "number",
|
|
231
|
-
"mutable": false,
|
|
232
|
-
"complexType": {
|
|
233
|
-
"original": "number",
|
|
234
|
-
"resolved": "number",
|
|
235
|
-
"references": {}
|
|
236
|
-
},
|
|
237
|
-
"required": false,
|
|
238
|
-
"optional": false,
|
|
239
|
-
"docs": {
|
|
240
|
-
"tags": [],
|
|
241
|
-
"text": "Determina quantas linhas s\u00E3o retornadas por p\u00E1gina"
|
|
242
|
-
},
|
|
243
|
-
"attribute": "page-size",
|
|
244
|
-
"reflect": false,
|
|
245
|
-
"defaultValue": "150"
|
|
246
|
-
},
|
|
247
|
-
"dataUnit": {
|
|
248
|
-
"type": "unknown",
|
|
249
|
-
"mutable": true,
|
|
250
|
-
"complexType": {
|
|
251
|
-
"original": "DataUnit",
|
|
252
|
-
"resolved": "DataUnit",
|
|
253
|
-
"references": {
|
|
254
|
-
"DataUnit": {
|
|
255
|
-
"location": "import",
|
|
256
|
-
"path": "@sankhyalabs/core"
|
|
257
|
-
}
|
|
258
|
-
}
|
|
259
|
-
},
|
|
260
|
-
"required": false,
|
|
261
|
-
"optional": false,
|
|
262
|
-
"docs": {
|
|
263
|
-
"tags": [],
|
|
264
|
-
"text": "Uma vez instanciado, pode-se obter o dataUnit por esta propriedade"
|
|
265
|
-
}
|
|
266
|
-
},
|
|
267
|
-
"messageBuilder": {
|
|
268
|
-
"type": "unknown",
|
|
269
|
-
"mutable": false,
|
|
270
|
-
"complexType": {
|
|
271
|
-
"original": "(messageKey: string, dataState: DataState, dataUnit: DataUnit) => string",
|
|
272
|
-
"resolved": "(messageKey: string, dataState: DataState, dataUnit: DataUnit) => string",
|
|
273
|
-
"references": {
|
|
274
|
-
"DataState": {
|
|
275
|
-
"location": "local"
|
|
276
|
-
},
|
|
277
|
-
"DataUnit": {
|
|
278
|
-
"location": "import",
|
|
279
|
-
"path": "@sankhyalabs/core"
|
|
280
|
-
}
|
|
281
|
-
}
|
|
282
|
-
},
|
|
283
|
-
"required": false,
|
|
284
|
-
"optional": false,
|
|
285
|
-
"docs": {
|
|
286
|
-
"tags": [],
|
|
287
|
-
"text": "Abstra\u00E7\u00E3o para obter-se mensagens de acordo com o estado dos dados."
|
|
288
|
-
}
|
|
289
|
-
},
|
|
290
|
-
"beforeSave": {
|
|
291
|
-
"type": "unknown",
|
|
292
|
-
"mutable": false,
|
|
293
|
-
"complexType": {
|
|
294
|
-
"original": "(dataUnit: DataUnit) => boolean | Promise<boolean>",
|
|
295
|
-
"resolved": "(dataUnit: DataUnit) => boolean | Promise<boolean>",
|
|
296
|
-
"references": {
|
|
297
|
-
"DataUnit": {
|
|
298
|
-
"location": "import",
|
|
299
|
-
"path": "@sankhyalabs/core"
|
|
300
|
-
},
|
|
301
|
-
"Promise": {
|
|
302
|
-
"location": "global"
|
|
303
|
-
}
|
|
304
|
-
}
|
|
305
|
-
},
|
|
306
|
-
"required": false,
|
|
307
|
-
"optional": false,
|
|
308
|
-
"docs": {
|
|
309
|
-
"tags": [],
|
|
310
|
-
"text": "Executado imediatamente antes da a\u00E7\u00E3o de salvar as altera\u00E7\u00F5es. \u00DAtil no caso de valida\u00E7\u00F5es por exemplo.\nCaso retorne \"false\" (ou a promessa se resolva como false), cancela a a\u00E7\u00E3o."
|
|
311
|
-
}
|
|
312
|
-
},
|
|
313
|
-
"afterSave": {
|
|
314
|
-
"type": "unknown",
|
|
315
|
-
"mutable": false,
|
|
316
|
-
"complexType": {
|
|
317
|
-
"original": "(dataUnit: DataUnit) => void",
|
|
318
|
-
"resolved": "(dataUnit: DataUnit) => void",
|
|
319
|
-
"references": {
|
|
320
|
-
"DataUnit": {
|
|
321
|
-
"location": "import",
|
|
322
|
-
"path": "@sankhyalabs/core"
|
|
323
|
-
}
|
|
324
|
-
}
|
|
325
|
-
},
|
|
326
|
-
"required": false,
|
|
327
|
-
"optional": false,
|
|
328
|
-
"docs": {
|
|
329
|
-
"tags": [],
|
|
330
|
-
"text": "Executado ap\u00F3s a a\u00E7\u00E3o de salvar"
|
|
331
|
-
}
|
|
332
|
-
},
|
|
333
|
-
"autoLoad": {
|
|
334
|
-
"type": "boolean",
|
|
335
|
-
"mutable": false,
|
|
336
|
-
"complexType": {
|
|
337
|
-
"original": "boolean",
|
|
338
|
-
"resolved": "boolean",
|
|
339
|
-
"references": {}
|
|
340
|
-
},
|
|
341
|
-
"required": false,
|
|
342
|
-
"optional": false,
|
|
343
|
-
"docs": {
|
|
344
|
-
"tags": [],
|
|
345
|
-
"text": "Quando ativada essa propriedade faz com que haja uma carga imediata no DataUnit"
|
|
346
|
-
},
|
|
347
|
-
"attribute": "auto-load",
|
|
348
|
-
"reflect": false,
|
|
349
|
-
"defaultValue": "true"
|
|
350
|
-
}
|
|
351
|
-
}; }
|
|
352
|
-
static get events() { return [{
|
|
353
|
-
"method": "dataStateChange",
|
|
354
|
-
"name": "dataStateChange",
|
|
355
|
-
"bubbles": true,
|
|
356
|
-
"cancelable": true,
|
|
357
|
-
"composed": true,
|
|
358
|
-
"docs": {
|
|
359
|
-
"tags": [],
|
|
360
|
-
"text": "Disparado quando o h\u00E1 qualquer mudan\u00E7a de estado no DataUnit"
|
|
361
|
-
},
|
|
362
|
-
"complexType": {
|
|
363
|
-
"original": "DataState",
|
|
364
|
-
"resolved": "DataState",
|
|
365
|
-
"references": {
|
|
366
|
-
"DataState": {
|
|
367
|
-
"location": "local"
|
|
368
|
-
}
|
|
369
|
-
}
|
|
370
|
-
}
|
|
371
|
-
}, {
|
|
372
|
-
"method": "dataUnitReady",
|
|
373
|
-
"name": "dataUnitReady",
|
|
374
|
-
"bubbles": true,
|
|
375
|
-
"cancelable": true,
|
|
376
|
-
"composed": true,
|
|
377
|
-
"docs": {
|
|
378
|
-
"tags": [],
|
|
379
|
-
"text": "Disparado quando o DataUnit est\u00E1 pronto"
|
|
380
|
-
},
|
|
381
|
-
"complexType": {
|
|
382
|
-
"original": "DataUnit",
|
|
383
|
-
"resolved": "DataUnit",
|
|
384
|
-
"references": {
|
|
385
|
-
"DataUnit": {
|
|
386
|
-
"location": "import",
|
|
387
|
-
"path": "@sankhyalabs/core"
|
|
388
|
-
}
|
|
389
|
-
}
|
|
390
|
-
}
|
|
391
|
-
}, {
|
|
392
|
-
"method": "insertionMode",
|
|
393
|
-
"name": "insertionMode",
|
|
394
|
-
"bubbles": true,
|
|
395
|
-
"cancelable": true,
|
|
396
|
-
"composed": true,
|
|
397
|
-
"docs": {
|
|
398
|
-
"tags": [],
|
|
399
|
-
"text": "Disparado quando um registro \u00E9 adicionado ou copiado"
|
|
400
|
-
},
|
|
401
|
-
"complexType": {
|
|
402
|
-
"original": "void",
|
|
403
|
-
"resolved": "void",
|
|
404
|
-
"references": {}
|
|
405
|
-
}
|
|
406
|
-
}]; }
|
|
407
|
-
static get methods() { return {
|
|
408
|
-
"getDataUnit": {
|
|
409
|
-
"complexType": {
|
|
410
|
-
"signature": "() => Promise<DataUnit>",
|
|
411
|
-
"parameters": [],
|
|
412
|
-
"references": {
|
|
413
|
-
"Promise": {
|
|
414
|
-
"location": "global"
|
|
415
|
-
},
|
|
416
|
-
"DataUnit": {
|
|
417
|
-
"location": "import",
|
|
418
|
-
"path": "@sankhyalabs/core"
|
|
419
|
-
}
|
|
420
|
-
},
|
|
421
|
-
"return": "Promise<DataUnit>"
|
|
422
|
-
},
|
|
423
|
-
"docs": {
|
|
424
|
-
"text": "Pode-se obter o dataUnit atrav\u00E9s desse m\u00E9todo. Outra forma, \u00E9 ouvir o evento de",
|
|
425
|
-
"tags": [{
|
|
426
|
-
"name": "returns",
|
|
427
|
-
"text": "dataUnit"
|
|
428
|
-
}]
|
|
429
|
-
}
|
|
430
|
-
}
|
|
431
|
-
}; }
|
|
432
|
-
static get elementRef() { return "element"; }
|
|
433
|
-
static get watchers() { return [{
|
|
434
|
-
"propName": "pageSize",
|
|
435
|
-
"methodName": "observePageSize"
|
|
436
|
-
}, {
|
|
437
|
-
"propName": "dataUnitName",
|
|
438
|
-
"methodName": "observeDataUnitName"
|
|
439
|
-
}, {
|
|
440
|
-
"propName": "entityName",
|
|
441
|
-
"methodName": "observeEntityName"
|
|
442
|
-
}, {
|
|
443
|
-
"propName": "dataState",
|
|
444
|
-
"methodName": "observeDataState"
|
|
445
|
-
}, {
|
|
446
|
-
"propName": "dataUnit",
|
|
447
|
-
"methodName": "observeDataUnit"
|
|
448
|
-
}]; }
|
|
449
|
-
}
|
|
@@ -1,194 +0,0 @@
|
|
|
1
|
-
import { ApplicationContext } from '@sankhyalabs/core';
|
|
2
|
-
import { Component, Element, Event, h, Prop, State } from '@stencil/core';
|
|
3
|
-
export class SnkForm {
|
|
4
|
-
getFormConfig() {
|
|
5
|
-
return (this._dataState && this._dataState.insertionMode ? this._insertionFormConfig : this._editionFormConfig);
|
|
6
|
-
}
|
|
7
|
-
getInsertionHiddenFields(formConfig) {
|
|
8
|
-
const hiddenFields = [];
|
|
9
|
-
formConfig === null || formConfig === void 0 ? void 0 : formConfig.forEach(cfg => {
|
|
10
|
-
const def = this._dataUnit.getField(cfg.name);
|
|
11
|
-
if (def === null || def === void 0 ? void 0 : def.readOnly) {
|
|
12
|
-
hiddenFields.push(cfg.name);
|
|
13
|
-
}
|
|
14
|
-
});
|
|
15
|
-
return hiddenFields;
|
|
16
|
-
}
|
|
17
|
-
exitForm() {
|
|
18
|
-
if (this._dataUnit.isDirty()) {
|
|
19
|
-
this._dataUnit.cancelEdition({ after: () => this.exit.emit() });
|
|
20
|
-
}
|
|
21
|
-
else {
|
|
22
|
-
this.exit.emit();
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
getDisabledButtons() {
|
|
26
|
-
const disabled = [];
|
|
27
|
-
if (!this._dataState.hasPrevious) {
|
|
28
|
-
disabled.push("PREVIOUS");
|
|
29
|
-
}
|
|
30
|
-
if (!this._dataState.hasNext) {
|
|
31
|
-
disabled.push("NEXT");
|
|
32
|
-
}
|
|
33
|
-
return disabled;
|
|
34
|
-
}
|
|
35
|
-
componentWillLoad() {
|
|
36
|
-
let parent = this._element.parentElement;
|
|
37
|
-
while (parent) {
|
|
38
|
-
if (parent.tagName.toUpperCase() === "SNK-DATA-UNIT") {
|
|
39
|
-
this._snkDataUnit = parent;
|
|
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
|
-
}
|
|
55
|
-
componentWillRender() {
|
|
56
|
-
if (this._dataUnit && !this._configLoaded) {
|
|
57
|
-
const snkApplication = ApplicationContext.getContextValue("__SNK__APPLICATION__");
|
|
58
|
-
if (snkApplication) {
|
|
59
|
-
snkApplication.loadFormConfig(this.configName).then(cfg => {
|
|
60
|
-
this._configLoaded = true;
|
|
61
|
-
this._editionFormConfig = cfg;
|
|
62
|
-
this._insertionFormConfig = cfg.filter(fieldCfg => {
|
|
63
|
-
const def = this._dataUnit.getField(fieldCfg.name);
|
|
64
|
-
if (def === null || def === void 0 ? void 0 : def.readOnly) {
|
|
65
|
-
return false;
|
|
66
|
-
}
|
|
67
|
-
return true;
|
|
68
|
-
});
|
|
69
|
-
});
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
render() {
|
|
74
|
-
if (!this._configLoaded || !this._dataUnit || !this._dataState) {
|
|
75
|
-
return undefined;
|
|
76
|
-
}
|
|
77
|
-
return (h("section", { class: "ez-padding--large" },
|
|
78
|
-
h("div", { class: "ez-row ez-padding-bottom--medium" },
|
|
79
|
-
h("div", { class: "ez-col ez-col--sd-6 ez-col--tb-6", key: "formHeader" },
|
|
80
|
-
h("ez-button", { mode: "icon", iconName: "arrow_back", class: "ez-padding-right--medium", size: "small", onClick: () => this.exitForm() }),
|
|
81
|
-
h("h1", { class: "ez-title ez-title--primary ez-title--xlarge ez-align--middle" }, this.formTitle)),
|
|
82
|
-
h("div", { class: "ez-col ez-col--sd-6 ez-col--tb-6 ez-align--right" },
|
|
83
|
-
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 }))),
|
|
84
|
-
h("div", { class: "ez-padding--small" }),
|
|
85
|
-
h("section", null,
|
|
86
|
-
h("div", { class: "ez-row" },
|
|
87
|
-
h("div", { class: "ez-col ez-col--sd-12" },
|
|
88
|
-
h("ez-form", { key: "ezForm" + this._snkDataUnit.entityName, dataUnit: this._dataUnit, config: this.getFormConfig() }))))));
|
|
89
|
-
}
|
|
90
|
-
static get is() { return "snk-form"; }
|
|
91
|
-
static get encapsulation() { return "scoped"; }
|
|
92
|
-
static get originalStyleUrls() { return {
|
|
93
|
-
"$": ["snk-form.css"]
|
|
94
|
-
}; }
|
|
95
|
-
static get styleUrls() { return {
|
|
96
|
-
"$": ["snk-form.css"]
|
|
97
|
-
}; }
|
|
98
|
-
static get properties() { return {
|
|
99
|
-
"formTitle": {
|
|
100
|
-
"type": "string",
|
|
101
|
-
"mutable": false,
|
|
102
|
-
"complexType": {
|
|
103
|
-
"original": "string",
|
|
104
|
-
"resolved": "string",
|
|
105
|
-
"references": {}
|
|
106
|
-
},
|
|
107
|
-
"required": false,
|
|
108
|
-
"optional": false,
|
|
109
|
-
"docs": {
|
|
110
|
-
"tags": [],
|
|
111
|
-
"text": "Texto que aparece de forma descritiva no cabe\u00E7alho do form"
|
|
112
|
-
},
|
|
113
|
-
"attribute": "form-title",
|
|
114
|
-
"reflect": false
|
|
115
|
-
},
|
|
116
|
-
"configName": {
|
|
117
|
-
"type": "string",
|
|
118
|
-
"mutable": false,
|
|
119
|
-
"complexType": {
|
|
120
|
-
"original": "string",
|
|
121
|
-
"resolved": "string",
|
|
122
|
-
"references": {}
|
|
123
|
-
},
|
|
124
|
-
"required": false,
|
|
125
|
-
"optional": false,
|
|
126
|
-
"docs": {
|
|
127
|
-
"tags": [],
|
|
128
|
-
"text": "Nome usado para guardar/recuperar as configura\u00E7\u00F5es do formul\u00E1rio"
|
|
129
|
-
},
|
|
130
|
-
"attribute": "config-name",
|
|
131
|
-
"reflect": false
|
|
132
|
-
},
|
|
133
|
-
"actionsList": {
|
|
134
|
-
"type": "unknown",
|
|
135
|
-
"mutable": false,
|
|
136
|
-
"complexType": {
|
|
137
|
-
"original": "Array<Action>",
|
|
138
|
-
"resolved": "Action[]",
|
|
139
|
-
"references": {
|
|
140
|
-
"Array": {
|
|
141
|
-
"location": "global"
|
|
142
|
-
},
|
|
143
|
-
"Action": {
|
|
144
|
-
"location": "import",
|
|
145
|
-
"path": "../snk-taskbar/snk-taskbar"
|
|
146
|
-
}
|
|
147
|
-
}
|
|
148
|
-
},
|
|
149
|
-
"required": false,
|
|
150
|
-
"optional": false,
|
|
151
|
-
"docs": {
|
|
152
|
-
"tags": [],
|
|
153
|
-
"text": "Lista de a\u00E7\u00F5es que devem ser usadas no bot\u00E3o \"Mais op\u00E7\u00F5es\""
|
|
154
|
-
}
|
|
155
|
-
}
|
|
156
|
-
}; }
|
|
157
|
-
static get states() { return {
|
|
158
|
-
"_dataUnit": {},
|
|
159
|
-
"_configLoaded": {},
|
|
160
|
-
"_dataState": {}
|
|
161
|
-
}; }
|
|
162
|
-
static get events() { return [{
|
|
163
|
-
"method": "exit",
|
|
164
|
-
"name": "exit",
|
|
165
|
-
"bubbles": true,
|
|
166
|
-
"cancelable": true,
|
|
167
|
-
"composed": true,
|
|
168
|
-
"docs": {
|
|
169
|
-
"tags": [],
|
|
170
|
-
"text": "Emitido quando o bot\u00E3o de voltar \u00E9 acionado"
|
|
171
|
-
},
|
|
172
|
-
"complexType": {
|
|
173
|
-
"original": "void",
|
|
174
|
-
"resolved": "void",
|
|
175
|
-
"references": {}
|
|
176
|
-
}
|
|
177
|
-
}, {
|
|
178
|
-
"method": "actionClick",
|
|
179
|
-
"name": "actionClick",
|
|
180
|
-
"bubbles": true,
|
|
181
|
-
"cancelable": true,
|
|
182
|
-
"composed": true,
|
|
183
|
-
"docs": {
|
|
184
|
-
"tags": [],
|
|
185
|
-
"text": "Emitido sempre que houver click de bot\u00E3o ou a\u00E7\u00E3o"
|
|
186
|
-
},
|
|
187
|
-
"complexType": {
|
|
188
|
-
"original": "string",
|
|
189
|
-
"resolved": "string",
|
|
190
|
-
"references": {}
|
|
191
|
-
}
|
|
192
|
-
}]; }
|
|
193
|
-
static get elementRef() { return "_element"; }
|
|
194
|
-
}
|