@sankhyalabs/sankhyablocks 1.3.31-beta.3 → 1.3.31-beta.6
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-e42cb45d.js → index-532bcc28.js} +5 -34
- package/dist/cjs/loader.cjs.js +2 -2
- package/dist/cjs/sankhyablocks.cjs.js +2 -2
- package/dist/cjs/snk-application.cjs.entry.js +111 -15
- package/dist/cjs/snk-data-unit.cjs.entry.js +82 -37
- package/dist/cjs/snk-form.cjs.entry.js +1 -1
- package/dist/cjs/snk-grid.cjs.entry.js +2 -2
- package/dist/cjs/snk-pesquisa.cjs.entry.js +1 -1
- package/dist/cjs/snk-taskbar.cjs.entry.js +15 -34
- package/dist/cjs/{taskbar-elements-bfa647c7.js → taskbar-elements-9d47b416.js} +4 -2
- package/dist/cjs/teste-pesquisa.cjs.entry.js +1 -1
- package/dist/collection/components/snk-application/snk-application.js +107 -31
- package/dist/collection/components/snk-data-unit/snk-data-unit.js +171 -47
- package/dist/collection/components/snk-form/snk-form.js +5 -5
- package/dist/collection/components/snk-grid/snk-grid.js +3 -3
- package/dist/collection/components/snk-taskbar/elements/taskbar-elements.js +3 -1
- package/dist/collection/components/snk-taskbar/snk-taskbar.js +17 -33
- package/dist/collection/lib/http/data-fetcher/fetchers/dataunit-fetcher.js +30 -10
- package/dist/components/snk-application2.js +111 -15
- package/dist/components/snk-data-unit.js +84 -36
- package/dist/components/snk-taskbar2.js +14 -32
- package/dist/esm/{index-02c04e0f.js → index-0b078db7.js} +5 -34
- package/dist/esm/loader.js +2 -2
- package/dist/esm/sankhyablocks.js +2 -2
- package/dist/esm/snk-application.entry.js +111 -15
- package/dist/esm/snk-data-unit.entry.js +82 -37
- package/dist/esm/snk-form.entry.js +1 -1
- package/dist/esm/snk-grid.entry.js +2 -2
- package/dist/esm/snk-pesquisa.entry.js +1 -1
- package/dist/esm/snk-taskbar.entry.js +13 -32
- package/dist/esm/{taskbar-elements-fe7cbf0e.js → taskbar-elements-3ba30bf4.js} +4 -2
- package/dist/esm/teste-pesquisa.entry.js +1 -1
- package/dist/sankhyablocks/{p-b80352ac.entry.js → p-3cb106f7.entry.js} +3 -3
- package/dist/sankhyablocks/p-3fce3190.entry.js +1 -0
- package/dist/sankhyablocks/{p-37b06977.entry.js → p-560fdf54.entry.js} +1 -1
- package/dist/sankhyablocks/p-574764bf.js +1 -0
- package/dist/sankhyablocks/p-8f7b9a85.entry.js +1 -0
- package/dist/sankhyablocks/{p-c156b1da.entry.js → p-9c225717.entry.js} +1 -1
- package/dist/sankhyablocks/p-a45dba1a.js +2 -0
- package/dist/sankhyablocks/{p-e38386b1.entry.js → p-a670853c.entry.js} +1 -1
- package/dist/sankhyablocks/{p-376004ef.entry.js → p-a8305c35.entry.js} +1 -1
- package/dist/sankhyablocks/sankhyablocks.esm.js +1 -1
- package/dist/types/components/snk-application/snk-application.d.ts +85 -9
- package/dist/types/components/snk-taskbar/elements/taskbar-elements.d.ts +2 -1
- package/dist/types/components/snk-taskbar/snk-taskbar.d.ts +20 -3
- package/dist/types/components.d.ts +223 -2
- package/dist/types/lib/http/data-fetcher/fetchers/dataunit-fetcher.d.ts +2 -0
- package/package.json +1 -1
- package/dist/collection/components/snk-taskbar/component/snk-popup-button.js +0 -7
- package/dist/sankhyablocks/p-09e48ff8.entry.js +0 -1
- package/dist/sankhyablocks/p-64e2471c.js +0 -1
- package/dist/sankhyablocks/p-cc9c348a.entry.js +0 -1
- package/dist/sankhyablocks/p-db215c74.js +0 -2
- package/dist/types/components/snk-taskbar/component/snk-popup-button.d.ts +0 -12
|
@@ -4,11 +4,22 @@ import { ApplicationUtils } from '@sankhyalabs/ezui/dist/collection/utils';
|
|
|
4
4
|
export class SnkDataUnit {
|
|
5
5
|
constructor() {
|
|
6
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;
|
|
7
15
|
this._dataUnitObserver = (action) => {
|
|
8
16
|
let msg = this.getActionInfo(action.type);
|
|
9
17
|
if (msg) {
|
|
10
18
|
ApplicationUtils.info(msg);
|
|
11
19
|
}
|
|
20
|
+
if (action.type === Action.RECORDS_ADDED || action.type === Action.RECORDS_COPIED) {
|
|
21
|
+
this.insertionMode.emit();
|
|
22
|
+
}
|
|
12
23
|
const duState = {
|
|
13
24
|
insertionMode: false,
|
|
14
25
|
hasNext: this.dataUnit.hasNext(),
|
|
@@ -26,41 +37,6 @@ export class SnkDataUnit {
|
|
|
26
37
|
this.dataState = duState;
|
|
27
38
|
};
|
|
28
39
|
}
|
|
29
|
-
async getDataUnit() {
|
|
30
|
-
return new Promise((resolve) => {
|
|
31
|
-
if (this.dataUnit) {
|
|
32
|
-
resolve(this.dataUnit);
|
|
33
|
-
}
|
|
34
|
-
else {
|
|
35
|
-
this._onDataUnitResolve.push(resolve);
|
|
36
|
-
}
|
|
37
|
-
});
|
|
38
|
-
}
|
|
39
|
-
async interceptAction(action) {
|
|
40
|
-
return new Promise(resolve => {
|
|
41
|
-
if (action.type === Action.EDITION_CANCELED) {
|
|
42
|
-
ApplicationUtils.confirm(this.i18n("components.warning"), this.i18n("components.confirmCancelEdition"))
|
|
43
|
-
.then((result) => resolve(result ? action : undefined));
|
|
44
|
-
}
|
|
45
|
-
else if (action.type === Action.REMOVING_RECORDS) {
|
|
46
|
-
ApplicationUtils.confirm(this.i18n("components.delete"), this.i18n("components.confirmRemoveRecord"), "delete", true, { btnConfirmDanger: true })
|
|
47
|
-
.then((result) => resolve(result ? action : undefined));
|
|
48
|
-
}
|
|
49
|
-
else {
|
|
50
|
-
resolve(action);
|
|
51
|
-
}
|
|
52
|
-
});
|
|
53
|
-
}
|
|
54
|
-
getActionInfo(action) {
|
|
55
|
-
if (this.messageBuilder) {
|
|
56
|
-
return this.messageBuilder(action, this.dataState, this.dataUnit);
|
|
57
|
-
}
|
|
58
|
-
else {
|
|
59
|
-
if (action === Action.EDITION_CANCELED) {
|
|
60
|
-
return this.i18n("components.editionCanceled");
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
40
|
observePageSize() {
|
|
65
41
|
if (this.dataUnit) {
|
|
66
42
|
this.dataUnit.pageSize = this.pageSize;
|
|
@@ -88,11 +64,73 @@ export class SnkDataUnit {
|
|
|
88
64
|
observeDataUnit() {
|
|
89
65
|
this.dataUnitReady.emit(this.dataUnit);
|
|
90
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
|
+
}
|
|
91
128
|
async loadDataUnit() {
|
|
92
129
|
if (!this.dataUnit) {
|
|
93
130
|
const app = ApplicationContext.getContextValue("__SNK__APPLICATION__");
|
|
94
131
|
if (app && this.entityName) {
|
|
95
|
-
this.
|
|
132
|
+
const cacheName = this.dataUnitName ? this.dataUnitName : this.entityName;
|
|
133
|
+
this.dataUnit = await app.getDataUnit(this.entityName, cacheName);
|
|
96
134
|
this.dataUnit.pageSize = this.pageSize;
|
|
97
135
|
this.dataUnit.unsubscribe(this._dataUnitObserver);
|
|
98
136
|
this.dataUnit.addInterceptor(this);
|
|
@@ -101,6 +139,9 @@ export class SnkDataUnit {
|
|
|
101
139
|
while (resolver = this._onDataUnitResolve.pop()) {
|
|
102
140
|
resolver(this.dataUnit);
|
|
103
141
|
}
|
|
142
|
+
if (this.autoLoad) {
|
|
143
|
+
this.dataUnit.loadData();
|
|
144
|
+
}
|
|
104
145
|
}
|
|
105
146
|
}
|
|
106
147
|
}
|
|
@@ -114,6 +155,9 @@ export class SnkDataUnit {
|
|
|
114
155
|
};
|
|
115
156
|
return pt_br[key];
|
|
116
157
|
}
|
|
158
|
+
//---------------------------------------------
|
|
159
|
+
// Lifecycle web component
|
|
160
|
+
//---------------------------------------------
|
|
117
161
|
componentDidRender() {
|
|
118
162
|
this.loadDataUnit();
|
|
119
163
|
}
|
|
@@ -145,7 +189,7 @@ export class SnkDataUnit {
|
|
|
145
189
|
"optional": false,
|
|
146
190
|
"docs": {
|
|
147
191
|
"tags": [],
|
|
148
|
-
"text": ""
|
|
192
|
+
"text": "O estato atual dos dados, isto \u00E9 se h\u00E1 altera\u00E7\u00E3o, insers\u00E3o, as linhas selecionadas, etc."
|
|
149
193
|
}
|
|
150
194
|
},
|
|
151
195
|
"dataUnitName": {
|
|
@@ -160,7 +204,7 @@ export class SnkDataUnit {
|
|
|
160
204
|
"optional": false,
|
|
161
205
|
"docs": {
|
|
162
206
|
"tags": [],
|
|
163
|
-
"text": ""
|
|
207
|
+
"text": "Este atributo \u00E9 usado para criar o dataUnit uma \u00FAnica vez. Se omitido ser\u00E1 usado o pr\u00F3prio nome\nda entidade."
|
|
164
208
|
},
|
|
165
209
|
"attribute": "data-unit-name",
|
|
166
210
|
"reflect": false
|
|
@@ -177,7 +221,7 @@ export class SnkDataUnit {
|
|
|
177
221
|
"optional": false,
|
|
178
222
|
"docs": {
|
|
179
223
|
"tags": [],
|
|
180
|
-
"text": ""
|
|
224
|
+
"text": "Determina qual a entidade representa os dados em quest\u00E3o."
|
|
181
225
|
},
|
|
182
226
|
"attribute": "entity-name",
|
|
183
227
|
"reflect": false
|
|
@@ -194,10 +238,11 @@ export class SnkDataUnit {
|
|
|
194
238
|
"optional": false,
|
|
195
239
|
"docs": {
|
|
196
240
|
"tags": [],
|
|
197
|
-
"text": ""
|
|
241
|
+
"text": "Determina quantas linhas s\u00E3o retornadas por p\u00E1gina"
|
|
198
242
|
},
|
|
199
243
|
"attribute": "page-size",
|
|
200
|
-
"reflect": false
|
|
244
|
+
"reflect": false,
|
|
245
|
+
"defaultValue": "150"
|
|
201
246
|
},
|
|
202
247
|
"dataUnit": {
|
|
203
248
|
"type": "unknown",
|
|
@@ -216,7 +261,7 @@ export class SnkDataUnit {
|
|
|
216
261
|
"optional": false,
|
|
217
262
|
"docs": {
|
|
218
263
|
"tags": [],
|
|
219
|
-
"text": ""
|
|
264
|
+
"text": "Uma vez instanciado, pode-se obter o dataUnit por esta propriedade"
|
|
220
265
|
}
|
|
221
266
|
},
|
|
222
267
|
"messageBuilder": {
|
|
@@ -239,8 +284,69 @@ export class SnkDataUnit {
|
|
|
239
284
|
"optional": false,
|
|
240
285
|
"docs": {
|
|
241
286
|
"tags": [],
|
|
242
|
-
"text": ""
|
|
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"
|
|
243
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"
|
|
244
350
|
}
|
|
245
351
|
}; }
|
|
246
352
|
static get events() { return [{
|
|
@@ -251,7 +357,7 @@ export class SnkDataUnit {
|
|
|
251
357
|
"composed": true,
|
|
252
358
|
"docs": {
|
|
253
359
|
"tags": [],
|
|
254
|
-
"text": ""
|
|
360
|
+
"text": "Disparado quando o h\u00E1 qualquer mudan\u00E7a de estado no DataUnit"
|
|
255
361
|
},
|
|
256
362
|
"complexType": {
|
|
257
363
|
"original": "DataState",
|
|
@@ -270,7 +376,7 @@ export class SnkDataUnit {
|
|
|
270
376
|
"composed": true,
|
|
271
377
|
"docs": {
|
|
272
378
|
"tags": [],
|
|
273
|
-
"text": ""
|
|
379
|
+
"text": "Disparado quando o DataUnit est\u00E1 pronto"
|
|
274
380
|
},
|
|
275
381
|
"complexType": {
|
|
276
382
|
"original": "DataUnit",
|
|
@@ -282,6 +388,21 @@ export class SnkDataUnit {
|
|
|
282
388
|
}
|
|
283
389
|
}
|
|
284
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
|
+
}
|
|
285
406
|
}]; }
|
|
286
407
|
static get methods() { return {
|
|
287
408
|
"getDataUnit": {
|
|
@@ -300,8 +421,11 @@ export class SnkDataUnit {
|
|
|
300
421
|
"return": "Promise<DataUnit>"
|
|
301
422
|
},
|
|
302
423
|
"docs": {
|
|
303
|
-
"text": "",
|
|
304
|
-
"tags": [
|
|
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
|
+
}]
|
|
305
429
|
}
|
|
306
430
|
}
|
|
307
431
|
}; }
|
|
@@ -108,7 +108,7 @@ export class SnkForm {
|
|
|
108
108
|
"optional": false,
|
|
109
109
|
"docs": {
|
|
110
110
|
"tags": [],
|
|
111
|
-
"text": ""
|
|
111
|
+
"text": "Texto que aparece de forma descritiva no cabe\u00E7alho do form"
|
|
112
112
|
},
|
|
113
113
|
"attribute": "form-title",
|
|
114
114
|
"reflect": false
|
|
@@ -125,7 +125,7 @@ export class SnkForm {
|
|
|
125
125
|
"optional": false,
|
|
126
126
|
"docs": {
|
|
127
127
|
"tags": [],
|
|
128
|
-
"text": ""
|
|
128
|
+
"text": "Nome usado para guardar/recuperar as configura\u00E7\u00F5es do formul\u00E1rio"
|
|
129
129
|
},
|
|
130
130
|
"attribute": "config-name",
|
|
131
131
|
"reflect": false
|
|
@@ -150,7 +150,7 @@ export class SnkForm {
|
|
|
150
150
|
"optional": false,
|
|
151
151
|
"docs": {
|
|
152
152
|
"tags": [],
|
|
153
|
-
"text": ""
|
|
153
|
+
"text": "Lista de a\u00E7\u00F5es que devem ser usadas no bot\u00E3o \"Mais op\u00E7\u00F5es\""
|
|
154
154
|
}
|
|
155
155
|
}
|
|
156
156
|
}; }
|
|
@@ -167,7 +167,7 @@ export class SnkForm {
|
|
|
167
167
|
"composed": true,
|
|
168
168
|
"docs": {
|
|
169
169
|
"tags": [],
|
|
170
|
-
"text": ""
|
|
170
|
+
"text": "Emitido quando o bot\u00E3o de voltar \u00E9 acionado"
|
|
171
171
|
},
|
|
172
172
|
"complexType": {
|
|
173
173
|
"original": "void",
|
|
@@ -182,7 +182,7 @@ export class SnkForm {
|
|
|
182
182
|
"composed": true,
|
|
183
183
|
"docs": {
|
|
184
184
|
"tags": [],
|
|
185
|
-
"text": ""
|
|
185
|
+
"text": "Emitido sempre que houver click de bot\u00E3o ou a\u00E7\u00E3o"
|
|
186
186
|
},
|
|
187
187
|
"complexType": {
|
|
188
188
|
"original": "string",
|
|
@@ -74,7 +74,7 @@ export class SnkGrid {
|
|
|
74
74
|
"optional": false,
|
|
75
75
|
"docs": {
|
|
76
76
|
"tags": [],
|
|
77
|
-
"text": ""
|
|
77
|
+
"text": "Nome usado para salvar/recuperar a configura\u00E7\u00E3o"
|
|
78
78
|
},
|
|
79
79
|
"attribute": "config-name",
|
|
80
80
|
"reflect": false
|
|
@@ -99,7 +99,7 @@ export class SnkGrid {
|
|
|
99
99
|
"optional": false,
|
|
100
100
|
"docs": {
|
|
101
101
|
"tags": [],
|
|
102
|
-
"text": ""
|
|
102
|
+
"text": "Lista de a\u00E7\u00F5es que devem ser usadas no bot\u00E3o \"Mais op\u00E7\u00F5es\""
|
|
103
103
|
}
|
|
104
104
|
}
|
|
105
105
|
}; }
|
|
@@ -116,7 +116,7 @@ export class SnkGrid {
|
|
|
116
116
|
"composed": true,
|
|
117
117
|
"docs": {
|
|
118
118
|
"tags": [],
|
|
119
|
-
"text": ""
|
|
119
|
+
"text": "Emitido sempre que houver click de bot\u00E3o ou a\u00E7\u00E3o"
|
|
120
120
|
},
|
|
121
121
|
"complexType": {
|
|
122
122
|
"original": "string",
|
|
@@ -24,7 +24,7 @@ export var AuthorizationElements;
|
|
|
24
24
|
AuthorizationElements["INSERT"] = "INSERT";
|
|
25
25
|
AuthorizationElements["CONFIG_GRID"] = "CONFIG_GRID";
|
|
26
26
|
})(AuthorizationElements || (AuthorizationElements = {}));
|
|
27
|
-
export const buildElem = (element, className, getTitle, action, isEnabled) => {
|
|
27
|
+
export const buildElem = (element, className, getTitle, action, isEnabled, actions) => {
|
|
28
28
|
switch (element) {
|
|
29
29
|
case TaskbarElement.PREVIOUS:
|
|
30
30
|
return iconButton("chevron-left", element, className, getTitle, action, isEnabled);
|
|
@@ -50,6 +50,8 @@ export const buildElem = (element, className, getTitle, action, isEnabled) => {
|
|
|
50
50
|
return iconButton("list", element, className, getTitle, action, isEnabled);
|
|
51
51
|
case TaskbarElement.CONFIG_GRID:
|
|
52
52
|
return iconButton("settings-inverted", element, className, getTitle, action, isEnabled);
|
|
53
|
+
case TaskbarElement.MORE_OPTIONS:
|
|
54
|
+
return h("ez-actions-button", { size: "small", class: className, enabled: isEnabled(element), onEzAction: (evt) => action(evt.detail.value), actions: actions });
|
|
53
55
|
case TaskbarElement.DIVIDER:
|
|
54
56
|
return h("hr", { class: "ez-divider-vertical ez-divider--dark ez-margin-horizontal--medium" });
|
|
55
57
|
}
|
|
@@ -1,11 +1,7 @@
|
|
|
1
1
|
import { ApplicationContext } from '@sankhyalabs/core';
|
|
2
2
|
import { Component, Event, h, Host, Prop, State, Watch } from '@stencil/core';
|
|
3
|
-
import { SnkPopupButton } from './component/snk-popup-button';
|
|
4
3
|
import { TaskbarElement, buildElem, AuthorizationElements } from './elements/taskbar-elements';
|
|
5
4
|
export class SnkTaskbar {
|
|
6
|
-
constructor() {
|
|
7
|
-
this._moreOptionsOpened = false;
|
|
8
|
-
}
|
|
9
5
|
observeButtons() {
|
|
10
6
|
this._definitions = undefined;
|
|
11
7
|
}
|
|
@@ -77,10 +73,6 @@ export class SnkTaskbar {
|
|
|
77
73
|
}
|
|
78
74
|
this.actionClick.emit(elem);
|
|
79
75
|
}
|
|
80
|
-
actionClickHandler(act) {
|
|
81
|
-
this._moreOptionsOpened = false;
|
|
82
|
-
this.actionClick.emit(act.key);
|
|
83
|
-
}
|
|
84
76
|
isEnabled(elem) {
|
|
85
77
|
return !(this.disabledButtons && this.disabledButtons.includes(elem));
|
|
86
78
|
}
|
|
@@ -90,29 +82,22 @@ export class SnkTaskbar {
|
|
|
90
82
|
if (index > 1) {
|
|
91
83
|
className += "ez-padding-left--medium";
|
|
92
84
|
}
|
|
93
|
-
|
|
94
|
-
element = this.actionsList ? h(SnkPopupButton, { className: className, title: this.getTitle(def), source: this.actionsList, opened: this._moreOptionsOpened, setOpened: opened => this._moreOptionsOpened = opened, actionClick: act => this.actionClickHandler(act) }) : undefined;
|
|
95
|
-
}
|
|
96
|
-
else {
|
|
97
|
-
element = buildElem(def, className, elem => this.getTitle(elem), elem => this.elementClick(elem), elem => this.isEnabled(elem));
|
|
98
|
-
}
|
|
85
|
+
element = buildElem(def, className, elem => this.getTitle(elem), elem => this.elementClick(elem), elem => this.isEnabled(elem), this.actionsList);
|
|
99
86
|
return element;
|
|
100
87
|
}
|
|
101
88
|
// Lifecycle
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
snkApplication.getAllAccess().then(access => this._permissions = access);
|
|
107
|
-
}
|
|
108
|
-
else {
|
|
109
|
-
this._permissions = {};
|
|
110
|
-
}
|
|
89
|
+
componentWillLoad() {
|
|
90
|
+
const snkApplication = ApplicationContext.getContextValue("__SNK__APPLICATION__");
|
|
91
|
+
if (snkApplication) {
|
|
92
|
+
snkApplication.getAllAccess().then(access => this._permissions = access);
|
|
111
93
|
}
|
|
112
94
|
else {
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
95
|
+
this._permissions = {};
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
componentWillRender() {
|
|
99
|
+
if (this._definitions == undefined && this._permissions) {
|
|
100
|
+
this._definitions = this.elementsFromString(this.buttons);
|
|
116
101
|
}
|
|
117
102
|
}
|
|
118
103
|
render() {
|
|
@@ -157,7 +142,7 @@ export class SnkTaskbar {
|
|
|
157
142
|
"optional": false,
|
|
158
143
|
"docs": {
|
|
159
144
|
"tags": [],
|
|
160
|
-
"text": ""
|
|
145
|
+
"text": "Lista separada por virgula, contendo todos os elementos a serem criados"
|
|
161
146
|
},
|
|
162
147
|
"attribute": "buttons",
|
|
163
148
|
"reflect": false
|
|
@@ -181,7 +166,7 @@ export class SnkTaskbar {
|
|
|
181
166
|
"optional": false,
|
|
182
167
|
"docs": {
|
|
183
168
|
"tags": [],
|
|
184
|
-
"text": ""
|
|
169
|
+
"text": "Lista de a\u00E7\u00F5es que devem ser usadas no bot\u00E3o \"Mais op\u00E7\u00F5es\""
|
|
185
170
|
}
|
|
186
171
|
},
|
|
187
172
|
"primaryButton": {
|
|
@@ -196,7 +181,7 @@ export class SnkTaskbar {
|
|
|
196
181
|
"optional": false,
|
|
197
182
|
"docs": {
|
|
198
183
|
"tags": [],
|
|
199
|
-
"text": ""
|
|
184
|
+
"text": "Qual bot\u00E3o deve ter apar\u00EAncia prim\u00E1ria"
|
|
200
185
|
},
|
|
201
186
|
"attribute": "primary-button",
|
|
202
187
|
"reflect": false
|
|
@@ -217,7 +202,7 @@ export class SnkTaskbar {
|
|
|
217
202
|
"optional": false,
|
|
218
203
|
"docs": {
|
|
219
204
|
"tags": [],
|
|
220
|
-
"text": ""
|
|
205
|
+
"text": "Array contendo todos os bot\u00F5es a serem desabilitados"
|
|
221
206
|
}
|
|
222
207
|
},
|
|
223
208
|
"dataUnit": {
|
|
@@ -237,12 +222,11 @@ export class SnkTaskbar {
|
|
|
237
222
|
"optional": false,
|
|
238
223
|
"docs": {
|
|
239
224
|
"tags": [],
|
|
240
|
-
"text": ""
|
|
225
|
+
"text": "Inst\u00E2ncia do DataUnit"
|
|
241
226
|
}
|
|
242
227
|
}
|
|
243
228
|
}; }
|
|
244
229
|
static get states() { return {
|
|
245
|
-
"_moreOptionsOpened": {},
|
|
246
230
|
"_permissions": {}
|
|
247
231
|
}; }
|
|
248
232
|
static get events() { return [{
|
|
@@ -253,7 +237,7 @@ export class SnkTaskbar {
|
|
|
253
237
|
"composed": true,
|
|
254
238
|
"docs": {
|
|
255
239
|
"tags": [],
|
|
256
|
-
"text": ""
|
|
240
|
+
"text": "Emitido sempre que houver click de bot\u00E3o ou a\u00E7\u00E3o"
|
|
257
241
|
},
|
|
258
242
|
"complexType": {
|
|
259
243
|
"original": "string",
|
|
@@ -4,6 +4,7 @@ import { DataFetcher } from "../DataFetcher";
|
|
|
4
4
|
export default class DataUnitFetcher {
|
|
5
5
|
constructor() {
|
|
6
6
|
this.templateByQuery = new Map();
|
|
7
|
+
this._loadDataTimeout = {};
|
|
7
8
|
this.buldTemplates();
|
|
8
9
|
}
|
|
9
10
|
buldTemplates() {
|
|
@@ -101,6 +102,21 @@ export default class DataUnitFetcher {
|
|
|
101
102
|
});
|
|
102
103
|
}
|
|
103
104
|
loadData(dataUnit, request) {
|
|
105
|
+
const duName = dataUnit.name;
|
|
106
|
+
if (this._loadDataTimeout[duName]) {
|
|
107
|
+
clearTimeout(this._loadDataTimeout[duName]);
|
|
108
|
+
delete this._loadDataTimeout[duName];
|
|
109
|
+
}
|
|
110
|
+
return new Promise((resolve, reject) => {
|
|
111
|
+
this._loadDataTimeout[duName] = setTimeout(() => {
|
|
112
|
+
delete this._loadDataTimeout[duName];
|
|
113
|
+
this.doLoadData(dataUnit, request)
|
|
114
|
+
.then(result => resolve(result))
|
|
115
|
+
.catch(reason => reject(reason));
|
|
116
|
+
}, 200);
|
|
117
|
+
});
|
|
118
|
+
}
|
|
119
|
+
doLoadData(dataUnit, request) {
|
|
104
120
|
return new Promise((resolve, reject) => {
|
|
105
121
|
var _a;
|
|
106
122
|
const { sort, filters, limit, offset, quickFilter } = request;
|
|
@@ -128,9 +144,19 @@ export default class DataUnitFetcher {
|
|
|
128
144
|
})
|
|
129
145
|
.then((resp) => {
|
|
130
146
|
const { limit, offset, total, hasMore, records } = resp.data;
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
147
|
+
let paginationInfo;
|
|
148
|
+
if (limit) {
|
|
149
|
+
const firstRecord = offset + 1;
|
|
150
|
+
const lastRecord = offset + Math.min(records.length, limit);
|
|
151
|
+
const currentPage = offset / limit;
|
|
152
|
+
paginationInfo = {
|
|
153
|
+
firstRecord,
|
|
154
|
+
lastRecord,
|
|
155
|
+
total,
|
|
156
|
+
currentPage,
|
|
157
|
+
hasMore
|
|
158
|
+
};
|
|
159
|
+
}
|
|
134
160
|
const processedRecords = [];
|
|
135
161
|
records.forEach((responseRecord) => {
|
|
136
162
|
const duRecord = { __record__id__: responseRecord.id };
|
|
@@ -140,13 +166,7 @@ export default class DataUnitFetcher {
|
|
|
140
166
|
processedRecords.push(duRecord);
|
|
141
167
|
});
|
|
142
168
|
resolve({
|
|
143
|
-
paginationInfo
|
|
144
|
-
firstRecord,
|
|
145
|
-
lastRecord,
|
|
146
|
-
total,
|
|
147
|
-
currentPage,
|
|
148
|
-
hasMore
|
|
149
|
-
},
|
|
169
|
+
paginationInfo,
|
|
150
170
|
records: processedRecords
|
|
151
171
|
});
|
|
152
172
|
})
|