@sankhyalabs/sankhyablocks 1.3.31-beta.2 → 1.3.31-beta.3
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-1133bc2a.js → index-e42cb45d.js} +448 -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 +105 -79
- package/dist/cjs/snk-data-unit.cjs.entry.js +144 -0
- package/dist/cjs/snk-form.cjs.entry.js +95 -0
- package/dist/cjs/snk-grid.cjs.entry.js +64 -0
- package/dist/cjs/snk-pesquisa.cjs.entry.js +1 -1
- package/dist/cjs/snk-taskbar.cjs.entry.js +159 -0
- package/dist/cjs/taskbar-elements-bfa647c7.js +68 -0
- package/dist/cjs/teste-pesquisa.cjs.entry.js +1 -1
- package/dist/collection/collection-manifest.json +4 -0
- package/dist/collection/components/snk-application/snk-application.js +52 -5
- package/dist/collection/components/snk-data-unit/snk-data-unit.css +6 -0
- package/dist/collection/components/snk-data-unit/snk-data-unit.js +325 -0
- package/dist/collection/components/snk-form/snk-form.css +3 -0
- package/dist/collection/components/snk-form/snk-form.js +194 -0
- package/dist/collection/components/snk-grid/snk-grid.css +5 -0
- package/dist/collection/components/snk-grid/snk-grid.js +128 -0
- package/dist/collection/components/snk-taskbar/component/snk-popup-button.js +7 -0
- package/dist/collection/components/snk-taskbar/elements/taskbar-elements.js +63 -0
- package/dist/collection/components/snk-taskbar/snk-taskbar.css +3 -0
- package/dist/collection/components/snk-taskbar/snk-taskbar.js +268 -0
- package/dist/collection/lib/http/data-fetcher/fetchers/dataunit-fetcher.js +32 -21
- package/dist/collection/lib/http/data-fetcher/fetchers/grid-config-fetcher.js +4 -3
- package/dist/components/snk-application2.js +105 -78
- package/dist/components/snk-data-unit.d.ts +11 -0
- package/dist/components/snk-data-unit.js +165 -0
- package/dist/components/snk-form.d.ts +11 -0
- package/dist/components/snk-form.js +121 -0
- package/dist/components/snk-grid.d.ts +11 -0
- package/dist/components/snk-grid.js +88 -0
- package/dist/components/snk-taskbar.d.ts +11 -0
- package/dist/components/snk-taskbar.js +6 -0
- package/dist/components/snk-taskbar2.js +239 -0
- package/dist/esm/{index-ffda6382.js → index-02c04e0f.js} +448 -10
- package/dist/esm/loader.js +2 -2
- package/dist/esm/sankhyablocks.js +2 -2
- package/dist/esm/snk-application.entry.js +105 -79
- package/dist/esm/snk-data-unit.entry.js +140 -0
- package/dist/esm/snk-form.entry.js +91 -0
- package/dist/esm/snk-grid.entry.js +60 -0
- package/dist/esm/snk-pesquisa.entry.js +1 -1
- package/dist/esm/snk-taskbar.entry.js +155 -0
- package/dist/esm/taskbar-elements-fe7cbf0e.js +66 -0
- package/dist/esm/teste-pesquisa.entry.js +1 -1
- package/dist/sankhyablocks/p-09e48ff8.entry.js +1 -0
- package/dist/sankhyablocks/{p-2a7b4cb3.entry.js → p-376004ef.entry.js} +1 -1
- package/dist/sankhyablocks/p-37b06977.entry.js +1 -0
- package/dist/sankhyablocks/p-64e2471c.js +1 -0
- package/dist/sankhyablocks/p-b80352ac.entry.js +69 -0
- package/dist/sankhyablocks/p-c156b1da.entry.js +1 -0
- package/dist/sankhyablocks/p-cc9c348a.entry.js +1 -0
- package/dist/sankhyablocks/p-db215c74.js +2 -0
- package/dist/sankhyablocks/{p-d62412bb.entry.js → p-e38386b1.entry.js} +1 -1
- package/dist/sankhyablocks/sankhyablocks.esm.js +1 -1
- package/dist/types/components/snk-application/snk-application.d.ts +3 -1
- package/dist/types/components/snk-taskbar/component/snk-popup-button.d.ts +12 -0
- package/dist/types/components/snk-taskbar/elements/taskbar-elements.d.ts +24 -0
- package/dist/types/components/snk-taskbar/snk-taskbar.d.ts +28 -0
- package/dist/types/components.d.ts +112 -1
- 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 +4 -0
- package/react/components.js +4 -0
- package/react/components.js.map +1 -1
- package/dist/sankhyablocks/p-e6e91d5f.entry.js +0 -69
- package/dist/sankhyablocks/p-edcb9d8e.js +0 -2
|
@@ -0,0 +1,325 @@
|
|
|
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
|
+
this._dataUnitObserver = (action) => {
|
|
8
|
+
let msg = this.getActionInfo(action.type);
|
|
9
|
+
if (msg) {
|
|
10
|
+
ApplicationUtils.info(msg);
|
|
11
|
+
}
|
|
12
|
+
const duState = {
|
|
13
|
+
insertionMode: false,
|
|
14
|
+
hasNext: this.dataUnit.hasNext(),
|
|
15
|
+
hasPrevious: this.dataUnit.hasPrevious(),
|
|
16
|
+
copyMode: false,
|
|
17
|
+
isDirty: this.dataUnit.isDirty(),
|
|
18
|
+
selectedRecords: this.dataUnit.getSelectedRecords()
|
|
19
|
+
};
|
|
20
|
+
this.dataUnit.records.forEach(r => {
|
|
21
|
+
if (r.__record__id__.startsWith('NEW_')) {
|
|
22
|
+
duState.insertionMode = true;
|
|
23
|
+
duState.copyMode || (duState.copyMode = r['__record__source__id__'] != undefined);
|
|
24
|
+
}
|
|
25
|
+
});
|
|
26
|
+
this.dataState = duState;
|
|
27
|
+
};
|
|
28
|
+
}
|
|
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
|
+
observePageSize() {
|
|
65
|
+
if (this.dataUnit) {
|
|
66
|
+
this.dataUnit.pageSize = this.pageSize;
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
observeDataUnitName(newValue, oldValue) {
|
|
70
|
+
if (oldValue != newValue) {
|
|
71
|
+
this.dataUnit = undefined;
|
|
72
|
+
this.dataUnitName = newValue;
|
|
73
|
+
this.loadDataUnit();
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
observeEntityName(newValue, oldValue) {
|
|
77
|
+
if (oldValue != newValue) {
|
|
78
|
+
this.dataUnit = undefined;
|
|
79
|
+
this.entityName = newValue;
|
|
80
|
+
this.loadDataUnit();
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
observeDataState(newValue, oldValue) {
|
|
84
|
+
if (oldValue != newValue) {
|
|
85
|
+
this.dataStateChange.emit(newValue);
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
observeDataUnit() {
|
|
89
|
+
this.dataUnitReady.emit(this.dataUnit);
|
|
90
|
+
}
|
|
91
|
+
async loadDataUnit() {
|
|
92
|
+
if (!this.dataUnit) {
|
|
93
|
+
const app = ApplicationContext.getContextValue("__SNK__APPLICATION__");
|
|
94
|
+
if (app && this.entityName) {
|
|
95
|
+
this.dataUnit = await app.getOrCreateDataUnit(this.entityName, this.dataUnitName);
|
|
96
|
+
this.dataUnit.pageSize = this.pageSize;
|
|
97
|
+
this.dataUnit.unsubscribe(this._dataUnitObserver);
|
|
98
|
+
this.dataUnit.addInterceptor(this);
|
|
99
|
+
this.dataUnit.subscribe(this._dataUnitObserver);
|
|
100
|
+
let resolver;
|
|
101
|
+
while (resolver = this._onDataUnitResolve.pop()) {
|
|
102
|
+
resolver(this.dataUnit);
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
i18n(key) {
|
|
108
|
+
const pt_br = {
|
|
109
|
+
"components.warning": "Aviso",
|
|
110
|
+
"components.delete": "Excluir",
|
|
111
|
+
"components.confirmRemoveRecord": "Deseja realmente excluir o registro atual?",
|
|
112
|
+
"components.confirmCancelEdition": "As alterações realizadas serão descartadas<br/><br/><b>Você realmente gostaria de sair?</b>",
|
|
113
|
+
"components.editionCanceled": "Todas as alterações foram descartadas.",
|
|
114
|
+
};
|
|
115
|
+
return pt_br[key];
|
|
116
|
+
}
|
|
117
|
+
componentDidRender() {
|
|
118
|
+
this.loadDataUnit();
|
|
119
|
+
}
|
|
120
|
+
render() {
|
|
121
|
+
return (h(Host, null));
|
|
122
|
+
}
|
|
123
|
+
static get is() { return "snk-data-unit"; }
|
|
124
|
+
static get encapsulation() { return "scoped"; }
|
|
125
|
+
static get originalStyleUrls() { return {
|
|
126
|
+
"$": ["snk-data-unit.css"]
|
|
127
|
+
}; }
|
|
128
|
+
static get styleUrls() { return {
|
|
129
|
+
"$": ["snk-data-unit.css"]
|
|
130
|
+
}; }
|
|
131
|
+
static get properties() { return {
|
|
132
|
+
"dataState": {
|
|
133
|
+
"type": "unknown",
|
|
134
|
+
"mutable": true,
|
|
135
|
+
"complexType": {
|
|
136
|
+
"original": "DataState",
|
|
137
|
+
"resolved": "DataState",
|
|
138
|
+
"references": {
|
|
139
|
+
"DataState": {
|
|
140
|
+
"location": "local"
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
},
|
|
144
|
+
"required": false,
|
|
145
|
+
"optional": false,
|
|
146
|
+
"docs": {
|
|
147
|
+
"tags": [],
|
|
148
|
+
"text": ""
|
|
149
|
+
}
|
|
150
|
+
},
|
|
151
|
+
"dataUnitName": {
|
|
152
|
+
"type": "string",
|
|
153
|
+
"mutable": false,
|
|
154
|
+
"complexType": {
|
|
155
|
+
"original": "string",
|
|
156
|
+
"resolved": "string",
|
|
157
|
+
"references": {}
|
|
158
|
+
},
|
|
159
|
+
"required": false,
|
|
160
|
+
"optional": false,
|
|
161
|
+
"docs": {
|
|
162
|
+
"tags": [],
|
|
163
|
+
"text": ""
|
|
164
|
+
},
|
|
165
|
+
"attribute": "data-unit-name",
|
|
166
|
+
"reflect": false
|
|
167
|
+
},
|
|
168
|
+
"entityName": {
|
|
169
|
+
"type": "string",
|
|
170
|
+
"mutable": false,
|
|
171
|
+
"complexType": {
|
|
172
|
+
"original": "string",
|
|
173
|
+
"resolved": "string",
|
|
174
|
+
"references": {}
|
|
175
|
+
},
|
|
176
|
+
"required": false,
|
|
177
|
+
"optional": false,
|
|
178
|
+
"docs": {
|
|
179
|
+
"tags": [],
|
|
180
|
+
"text": ""
|
|
181
|
+
},
|
|
182
|
+
"attribute": "entity-name",
|
|
183
|
+
"reflect": false
|
|
184
|
+
},
|
|
185
|
+
"pageSize": {
|
|
186
|
+
"type": "number",
|
|
187
|
+
"mutable": false,
|
|
188
|
+
"complexType": {
|
|
189
|
+
"original": "number",
|
|
190
|
+
"resolved": "number",
|
|
191
|
+
"references": {}
|
|
192
|
+
},
|
|
193
|
+
"required": false,
|
|
194
|
+
"optional": false,
|
|
195
|
+
"docs": {
|
|
196
|
+
"tags": [],
|
|
197
|
+
"text": ""
|
|
198
|
+
},
|
|
199
|
+
"attribute": "page-size",
|
|
200
|
+
"reflect": false
|
|
201
|
+
},
|
|
202
|
+
"dataUnit": {
|
|
203
|
+
"type": "unknown",
|
|
204
|
+
"mutable": true,
|
|
205
|
+
"complexType": {
|
|
206
|
+
"original": "DataUnit",
|
|
207
|
+
"resolved": "DataUnit",
|
|
208
|
+
"references": {
|
|
209
|
+
"DataUnit": {
|
|
210
|
+
"location": "import",
|
|
211
|
+
"path": "@sankhyalabs/core"
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
},
|
|
215
|
+
"required": false,
|
|
216
|
+
"optional": false,
|
|
217
|
+
"docs": {
|
|
218
|
+
"tags": [],
|
|
219
|
+
"text": ""
|
|
220
|
+
}
|
|
221
|
+
},
|
|
222
|
+
"messageBuilder": {
|
|
223
|
+
"type": "unknown",
|
|
224
|
+
"mutable": false,
|
|
225
|
+
"complexType": {
|
|
226
|
+
"original": "(messageKey: string, dataState: DataState, dataUnit: DataUnit) => string",
|
|
227
|
+
"resolved": "(messageKey: string, dataState: DataState, dataUnit: DataUnit) => string",
|
|
228
|
+
"references": {
|
|
229
|
+
"DataState": {
|
|
230
|
+
"location": "local"
|
|
231
|
+
},
|
|
232
|
+
"DataUnit": {
|
|
233
|
+
"location": "import",
|
|
234
|
+
"path": "@sankhyalabs/core"
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
},
|
|
238
|
+
"required": false,
|
|
239
|
+
"optional": false,
|
|
240
|
+
"docs": {
|
|
241
|
+
"tags": [],
|
|
242
|
+
"text": ""
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
}; }
|
|
246
|
+
static get events() { return [{
|
|
247
|
+
"method": "dataStateChange",
|
|
248
|
+
"name": "dataStateChange",
|
|
249
|
+
"bubbles": true,
|
|
250
|
+
"cancelable": true,
|
|
251
|
+
"composed": true,
|
|
252
|
+
"docs": {
|
|
253
|
+
"tags": [],
|
|
254
|
+
"text": ""
|
|
255
|
+
},
|
|
256
|
+
"complexType": {
|
|
257
|
+
"original": "DataState",
|
|
258
|
+
"resolved": "DataState",
|
|
259
|
+
"references": {
|
|
260
|
+
"DataState": {
|
|
261
|
+
"location": "local"
|
|
262
|
+
}
|
|
263
|
+
}
|
|
264
|
+
}
|
|
265
|
+
}, {
|
|
266
|
+
"method": "dataUnitReady",
|
|
267
|
+
"name": "dataUnitReady",
|
|
268
|
+
"bubbles": true,
|
|
269
|
+
"cancelable": true,
|
|
270
|
+
"composed": true,
|
|
271
|
+
"docs": {
|
|
272
|
+
"tags": [],
|
|
273
|
+
"text": ""
|
|
274
|
+
},
|
|
275
|
+
"complexType": {
|
|
276
|
+
"original": "DataUnit",
|
|
277
|
+
"resolved": "DataUnit",
|
|
278
|
+
"references": {
|
|
279
|
+
"DataUnit": {
|
|
280
|
+
"location": "import",
|
|
281
|
+
"path": "@sankhyalabs/core"
|
|
282
|
+
}
|
|
283
|
+
}
|
|
284
|
+
}
|
|
285
|
+
}]; }
|
|
286
|
+
static get methods() { return {
|
|
287
|
+
"getDataUnit": {
|
|
288
|
+
"complexType": {
|
|
289
|
+
"signature": "() => Promise<DataUnit>",
|
|
290
|
+
"parameters": [],
|
|
291
|
+
"references": {
|
|
292
|
+
"Promise": {
|
|
293
|
+
"location": "global"
|
|
294
|
+
},
|
|
295
|
+
"DataUnit": {
|
|
296
|
+
"location": "import",
|
|
297
|
+
"path": "@sankhyalabs/core"
|
|
298
|
+
}
|
|
299
|
+
},
|
|
300
|
+
"return": "Promise<DataUnit>"
|
|
301
|
+
},
|
|
302
|
+
"docs": {
|
|
303
|
+
"text": "",
|
|
304
|
+
"tags": []
|
|
305
|
+
}
|
|
306
|
+
}
|
|
307
|
+
}; }
|
|
308
|
+
static get elementRef() { return "element"; }
|
|
309
|
+
static get watchers() { return [{
|
|
310
|
+
"propName": "pageSize",
|
|
311
|
+
"methodName": "observePageSize"
|
|
312
|
+
}, {
|
|
313
|
+
"propName": "dataUnitName",
|
|
314
|
+
"methodName": "observeDataUnitName"
|
|
315
|
+
}, {
|
|
316
|
+
"propName": "entityName",
|
|
317
|
+
"methodName": "observeEntityName"
|
|
318
|
+
}, {
|
|
319
|
+
"propName": "dataState",
|
|
320
|
+
"methodName": "observeDataState"
|
|
321
|
+
}, {
|
|
322
|
+
"propName": "dataUnit",
|
|
323
|
+
"methodName": "observeDataUnit"
|
|
324
|
+
}]; }
|
|
325
|
+
}
|
|
@@ -0,0 +1,194 @@
|
|
|
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": ""
|
|
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": ""
|
|
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": ""
|
|
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": ""
|
|
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": ""
|
|
186
|
+
},
|
|
187
|
+
"complexType": {
|
|
188
|
+
"original": "string",
|
|
189
|
+
"resolved": "string",
|
|
190
|
+
"references": {}
|
|
191
|
+
}
|
|
192
|
+
}]; }
|
|
193
|
+
static get elementRef() { return "_element"; }
|
|
194
|
+
}
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
import { ApplicationContext } from '@sankhyalabs/core';
|
|
2
|
+
import { Component, Element, h, Prop, State, Event } from '@stencil/core';
|
|
3
|
+
import { TaskbarElement } from '../snk-taskbar/elements/taskbar-elements';
|
|
4
|
+
export class SnkGrid {
|
|
5
|
+
getHeaderButtons() {
|
|
6
|
+
return this._dataState && this._dataState.selectedRecords.length > 0 ? "UPDATE,CLONE,REMOVE,MORE_OPTIONS,DIVIDER,REFRESH" : "REFRESH";
|
|
7
|
+
}
|
|
8
|
+
actionClickHandler(evt) {
|
|
9
|
+
if (evt.detail === TaskbarElement.CONFIG_GRID && this._grid) {
|
|
10
|
+
this._grid.openGridConfig();
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
componentWillLoad() {
|
|
14
|
+
let parent = this._element.parentElement;
|
|
15
|
+
while (parent) {
|
|
16
|
+
if (parent.tagName.toUpperCase() === "SNK-DATA-UNIT") {
|
|
17
|
+
this._snkDataUnit = parent;
|
|
18
|
+
this._dataUnit = this._snkDataUnit.dataUnit;
|
|
19
|
+
if (!this._dataUnit) {
|
|
20
|
+
this._snkDataUnit.addEventListener("dataUnitReady", (evt) => {
|
|
21
|
+
this._dataUnit = evt.detail;
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
this._snkDataUnit.addEventListener("dataStateChange", (evt) => {
|
|
25
|
+
this._dataState = evt.detail;
|
|
26
|
+
});
|
|
27
|
+
break;
|
|
28
|
+
}
|
|
29
|
+
parent = parent.parentElement;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
componentWillRender() {
|
|
33
|
+
if (this._dataUnit && !this._configLoaded) {
|
|
34
|
+
const snkApplication = ApplicationContext.getContextValue("__SNK__APPLICATION__");
|
|
35
|
+
if (snkApplication) {
|
|
36
|
+
snkApplication.loadGridConfig(this.configName).then(cfg => {
|
|
37
|
+
this._gridConfig = cfg;
|
|
38
|
+
this._configLoaded = true;
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
render() {
|
|
44
|
+
if (!this._configLoaded || !this._dataUnit) {
|
|
45
|
+
return undefined;
|
|
46
|
+
}
|
|
47
|
+
return (h("div", { class: "ez-flex ez-flex--column ez-flex-item--auto ez-padding--large" },
|
|
48
|
+
h("div", { class: "ez-row ez-padding-bottom--medium ez-margin-bottom--medium" },
|
|
49
|
+
h("div", { class: "ez-col ez-col--sd-9 ez-col--tb-9 ez-align--bottom" },
|
|
50
|
+
h("slot", null)),
|
|
51
|
+
h("div", { class: "ez-col ez-col--sd-3 ez-col--tb-3 ez-align--right" },
|
|
52
|
+
h("snk-taskbar", { onActionClick: evt => this.actionClickHandler(evt), key: "topTaskbar", dataUnit: this._dataUnit, buttons: "FORM_MODE,CONFIG_GRID,INSERT", primaryButton: "INSERT" }))),
|
|
53
|
+
h("ez-grid", { ref: ref => this._grid = ref, dataUnit: this._dataUnit, key: "grid-" + this._snkDataUnit.entityName, config: this._gridConfig },
|
|
54
|
+
h("snk-taskbar", { dataUnit: this._dataUnit, buttons: this.getHeaderButtons(), slot: "leftButtons", actionsList: this.actionsList }))));
|
|
55
|
+
}
|
|
56
|
+
static get is() { return "snk-grid"; }
|
|
57
|
+
static get encapsulation() { return "scoped"; }
|
|
58
|
+
static get originalStyleUrls() { return {
|
|
59
|
+
"$": ["snk-grid.css"]
|
|
60
|
+
}; }
|
|
61
|
+
static get styleUrls() { return {
|
|
62
|
+
"$": ["snk-grid.css"]
|
|
63
|
+
}; }
|
|
64
|
+
static get properties() { return {
|
|
65
|
+
"configName": {
|
|
66
|
+
"type": "string",
|
|
67
|
+
"mutable": false,
|
|
68
|
+
"complexType": {
|
|
69
|
+
"original": "string",
|
|
70
|
+
"resolved": "string",
|
|
71
|
+
"references": {}
|
|
72
|
+
},
|
|
73
|
+
"required": false,
|
|
74
|
+
"optional": false,
|
|
75
|
+
"docs": {
|
|
76
|
+
"tags": [],
|
|
77
|
+
"text": ""
|
|
78
|
+
},
|
|
79
|
+
"attribute": "config-name",
|
|
80
|
+
"reflect": false
|
|
81
|
+
},
|
|
82
|
+
"actionsList": {
|
|
83
|
+
"type": "unknown",
|
|
84
|
+
"mutable": false,
|
|
85
|
+
"complexType": {
|
|
86
|
+
"original": "Array<Action>",
|
|
87
|
+
"resolved": "Action[]",
|
|
88
|
+
"references": {
|
|
89
|
+
"Array": {
|
|
90
|
+
"location": "global"
|
|
91
|
+
},
|
|
92
|
+
"Action": {
|
|
93
|
+
"location": "import",
|
|
94
|
+
"path": "../snk-taskbar/snk-taskbar"
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
},
|
|
98
|
+
"required": false,
|
|
99
|
+
"optional": false,
|
|
100
|
+
"docs": {
|
|
101
|
+
"tags": [],
|
|
102
|
+
"text": ""
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
}; }
|
|
106
|
+
static get states() { return {
|
|
107
|
+
"_dataUnit": {},
|
|
108
|
+
"_configLoaded": {},
|
|
109
|
+
"_dataState": {}
|
|
110
|
+
}; }
|
|
111
|
+
static get events() { return [{
|
|
112
|
+
"method": "actionClick",
|
|
113
|
+
"name": "actionClick",
|
|
114
|
+
"bubbles": true,
|
|
115
|
+
"cancelable": true,
|
|
116
|
+
"composed": true,
|
|
117
|
+
"docs": {
|
|
118
|
+
"tags": [],
|
|
119
|
+
"text": ""
|
|
120
|
+
},
|
|
121
|
+
"complexType": {
|
|
122
|
+
"original": "string",
|
|
123
|
+
"resolved": "string",
|
|
124
|
+
"references": {}
|
|
125
|
+
}
|
|
126
|
+
}]; }
|
|
127
|
+
static get elementRef() { return "_element"; }
|
|
128
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { h } from "@stencil/core";
|
|
2
|
+
export const SnkPopupButton = ({ className, title, source, opened, setOpened, actionClick }) => {
|
|
3
|
+
return (h("div", { class: "ez-flex " + className },
|
|
4
|
+
h("ez-button", { id: "moreOptionsButton", title: title, mode: "icon", iconName: "dots-vertical", size: "small", onClick: () => setOpened(true) }),
|
|
5
|
+
h("ez-popover", { opened: opened, autoClose: true, innerElement: ["moreOptionsButton", "moreOptionsDiv"], onEzVisibilityChange: (event) => setOpened(event.detail) },
|
|
6
|
+
h("div", { id: "moreOptionsDiv", class: "ez-padding--small" }, source.map((option, index) => h("ez-button", { className: "btn-options", size: "small", label: option.label, key: index, onClick: () => actionClick(option) }))))));
|
|
7
|
+
};
|