@sankhyalabs/sankhyablocks 4.5.0 → 4.5.2
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/snk-simple-crud.cjs.entry.js +11 -3
- package/dist/collection/components/snk-simple-crud/snk-simple-crud.js +52 -3
- package/dist/components/snk-simple-crud.js +12 -4
- package/dist/esm/snk-simple-crud.entry.js +12 -4
- package/dist/sankhyablocks/p-4a12a1ae.entry.js +1 -0
- package/dist/sankhyablocks/sankhyablocks.esm.js +1 -1
- package/dist/types/components/snk-simple-crud/snk-simple-crud.d.ts +10 -0
- package/dist/types/components.d.ts +12 -0
- package/package.json +1 -1
- package/dist/sankhyablocks/p-330813ff.entry.js +0 -1
@@ -129,6 +129,8 @@ const snkSimpleCrudCss = ".sc-snk-simple-crud-h{display:flex;height:100%;width:1
|
|
129
129
|
const SnkSimpleCrud = class {
|
130
130
|
constructor(hostRef) {
|
131
131
|
index.registerInstance(this, hostRef);
|
132
|
+
this.dataStateChange = index.createEvent(this, "dataStateChange", 3);
|
133
|
+
this.dataUnitReady = index.createEvent(this, "dataUnitReady", 3);
|
132
134
|
this.REGULAR_DEFAULT_BTNS = ["INSERT", "PREVIOUS", "NEXT", "DIVIDER"];
|
133
135
|
this.REGULAR_SELECTED_BTNS = ["INSERT", "PREVIOUS", "NEXT", "DIVIDER", "CLONE", "REMOVE", "DIVIDER"];
|
134
136
|
this._taskbarProcessor = new taskbarProcessor.TaskbarProcessor({
|
@@ -189,6 +191,7 @@ const SnkSimpleCrud = class {
|
|
189
191
|
initInMemoryDataUnit() {
|
190
192
|
this._inMemoryLoader = new InMemoryLoader(this._metadata);
|
191
193
|
this.dataUnit = this._inMemoryLoader.dataUnit;
|
194
|
+
this.dataUnitReady.emit(this.dataUnit);
|
192
195
|
}
|
193
196
|
setMetadata(metadata) {
|
194
197
|
if (this._inMemoryLoader) {
|
@@ -223,9 +226,10 @@ const SnkSimpleCrud = class {
|
|
223
226
|
userInterface: core.UserInterface[fieldElem.getAttribute("userInterface")] || core.UserInterface.SHORTTEXT,
|
224
227
|
readOnly: fieldElem.getAttribute("readOnly") == "true",
|
225
228
|
required: fieldElem.getAttribute("required") == "true",
|
226
|
-
tab: fieldElem.getAttribute("tab") || undefined
|
229
|
+
tab: fieldElem.getAttribute("tab") || undefined,
|
230
|
+
visible: fieldElem.getAttribute("visible") != "false"
|
227
231
|
};
|
228
|
-
const fieldConfig = { name: field.name, tab: field.tab };
|
232
|
+
const fieldConfig = { name: field.name, tab: field.tab, visible: field.visible };
|
229
233
|
formConfig.fields.push(fieldConfig);
|
230
234
|
fieldMetadata.push(field);
|
231
235
|
});
|
@@ -238,9 +242,13 @@ const SnkSimpleCrud = class {
|
|
238
242
|
};
|
239
243
|
}
|
240
244
|
}
|
245
|
+
onDataStateChange(evt) {
|
246
|
+
this.dataStateChange.emit(evt.detail);
|
247
|
+
this.dataState = evt.detail;
|
248
|
+
}
|
241
249
|
render() {
|
242
250
|
var _a;
|
243
|
-
return (index.h("snk-data-unit", { class: "simple-crud__container", dataUnit: this.dataUnit, onDataStateChange: evt => this.
|
251
|
+
return (index.h("snk-data-unit", { class: "simple-crud__container", dataUnit: this.dataUnit, onDataStateChange: evt => this.onDataStateChange(evt), onInsertionMode: () => this.goToView(constants.VIEW_MODE.FORM), onDataUnitReady: (evt) => this.dataUnitReady.emit(evt.detail) }, index.h("header", null, index.h("slot", { name: "snkSimpleCrudHeader" })), index.h("section", { class: "ez-flex ez-box ez-box--shadow" }, index.h("snk-taskbar", { class: "simple-crud__taskbar ez-box ez-box--shadow ez-padding--medium", dataUnit: this.dataUnit, primaryButton: ((_a = this.dataState) === null || _a === void 0 ? void 0 : _a.isDirty) ? "SAVE" : "INSERT", "data-element-id": "grid_left", buttons: this._taskbarProcessor.buttons, disabledButtons: this._taskbarProcessor.disabledButtons, customButtons: this._taskbarProcessor.customButtons, slot: "leftButtons", presentationMode: index$1.PresentationMode.SECONDARY }), index.h("ez-view-stack", { class: "ez-flex ez-flex--column", ref: (ref) => this._viewStack = ref, "data-element-id": "simple-crud" }, index.h("stack-item", null, index.h("ez-grid", { dataUnit: this.dataUnit, onEzDoubleClick: () => this.goToView(constants.VIEW_MODE.FORM), "no-header": true }, index.h("div", { slot: "footer" }, index.h("slot", { name: "snkSimpleCrudFooter" })))), index.h("stack-item", null, index.h("ez-form", { dataUnit: this.dataUnit, config: this._config }))))));
|
244
252
|
}
|
245
253
|
get _element() { return index.getElement(this); }
|
246
254
|
static get watchers() { return {
|
@@ -67,6 +67,7 @@ export class SnkSimpleCrud {
|
|
67
67
|
initInMemoryDataUnit() {
|
68
68
|
this._inMemoryLoader = new InMemoryLoader(this._metadata);
|
69
69
|
this.dataUnit = this._inMemoryLoader.dataUnit;
|
70
|
+
this.dataUnitReady.emit(this.dataUnit);
|
70
71
|
}
|
71
72
|
setMetadata(metadata) {
|
72
73
|
if (this._inMemoryLoader) {
|
@@ -101,9 +102,10 @@ export class SnkSimpleCrud {
|
|
101
102
|
userInterface: UserInterface[fieldElem.getAttribute("userInterface")] || UserInterface.SHORTTEXT,
|
102
103
|
readOnly: fieldElem.getAttribute("readOnly") == "true",
|
103
104
|
required: fieldElem.getAttribute("required") == "true",
|
104
|
-
tab: fieldElem.getAttribute("tab") || undefined
|
105
|
+
tab: fieldElem.getAttribute("tab") || undefined,
|
106
|
+
visible: fieldElem.getAttribute("visible") != "false"
|
105
107
|
};
|
106
|
-
const fieldConfig = { name: field.name, tab: field.tab };
|
108
|
+
const fieldConfig = { name: field.name, tab: field.tab, visible: field.visible };
|
107
109
|
formConfig.fields.push(fieldConfig);
|
108
110
|
fieldMetadata.push(field);
|
109
111
|
});
|
@@ -116,9 +118,13 @@ export class SnkSimpleCrud {
|
|
116
118
|
};
|
117
119
|
}
|
118
120
|
}
|
121
|
+
onDataStateChange(evt) {
|
122
|
+
this.dataStateChange.emit(evt.detail);
|
123
|
+
this.dataState = evt.detail;
|
124
|
+
}
|
119
125
|
render() {
|
120
126
|
var _a;
|
121
|
-
return (h("snk-data-unit", { class: "simple-crud__container", dataUnit: this.dataUnit, onDataStateChange: evt => this.
|
127
|
+
return (h("snk-data-unit", { class: "simple-crud__container", dataUnit: this.dataUnit, onDataStateChange: evt => this.onDataStateChange(evt), onInsertionMode: () => this.goToView(VIEW_MODE.FORM), onDataUnitReady: (evt) => this.dataUnitReady.emit(evt.detail) }, h("header", null, h("slot", { name: "snkSimpleCrudHeader" })), h("section", { class: "ez-flex ez-box ez-box--shadow" }, h("snk-taskbar", { class: "simple-crud__taskbar ez-box ez-box--shadow ez-padding--medium", dataUnit: this.dataUnit, primaryButton: ((_a = this.dataState) === null || _a === void 0 ? void 0 : _a.isDirty) ? "SAVE" : "INSERT", "data-element-id": "grid_left", buttons: this._taskbarProcessor.buttons, disabledButtons: this._taskbarProcessor.disabledButtons, customButtons: this._taskbarProcessor.customButtons, slot: "leftButtons", presentationMode: PresentationMode.SECONDARY }), h("ez-view-stack", { class: "ez-flex ez-flex--column", ref: (ref) => this._viewStack = ref, "data-element-id": "simple-crud" }, h("stack-item", null, h("ez-grid", { dataUnit: this.dataUnit, onEzDoubleClick: () => this.goToView(VIEW_MODE.FORM), "no-header": true }, h("div", { slot: "footer" }, h("slot", { name: "snkSimpleCrudFooter" })))), h("stack-item", null, h("ez-form", { dataUnit: this.dataUnit, config: this._config }))))));
|
122
128
|
}
|
123
129
|
static get is() { return "snk-simple-crud"; }
|
124
130
|
static get encapsulation() { return "scoped"; }
|
@@ -225,6 +231,49 @@ export class SnkSimpleCrud {
|
|
225
231
|
"_config": {}
|
226
232
|
};
|
227
233
|
}
|
234
|
+
static get events() {
|
235
|
+
return [{
|
236
|
+
"method": "dataStateChange",
|
237
|
+
"name": "dataStateChange",
|
238
|
+
"bubbles": false,
|
239
|
+
"cancelable": true,
|
240
|
+
"composed": true,
|
241
|
+
"docs": {
|
242
|
+
"tags": [],
|
243
|
+
"text": "Emitido quando h\u00E1 qualquer mudan\u00E7a de estado no DataUnit."
|
244
|
+
},
|
245
|
+
"complexType": {
|
246
|
+
"original": "DataState",
|
247
|
+
"resolved": "DataState",
|
248
|
+
"references": {
|
249
|
+
"DataState": {
|
250
|
+
"location": "import",
|
251
|
+
"path": "../snk-data-unit/snk-data-unit"
|
252
|
+
}
|
253
|
+
}
|
254
|
+
}
|
255
|
+
}, {
|
256
|
+
"method": "dataUnitReady",
|
257
|
+
"name": "dataUnitReady",
|
258
|
+
"bubbles": false,
|
259
|
+
"cancelable": true,
|
260
|
+
"composed": true,
|
261
|
+
"docs": {
|
262
|
+
"tags": [],
|
263
|
+
"text": "Emitido quando o DataUnit est\u00E1 pronto."
|
264
|
+
},
|
265
|
+
"complexType": {
|
266
|
+
"original": "DataUnit",
|
267
|
+
"resolved": "DataUnit",
|
268
|
+
"references": {
|
269
|
+
"DataUnit": {
|
270
|
+
"location": "import",
|
271
|
+
"path": "@sankhyalabs/core"
|
272
|
+
}
|
273
|
+
}
|
274
|
+
}
|
275
|
+
}];
|
276
|
+
}
|
228
277
|
static get methods() {
|
229
278
|
return {
|
230
279
|
"goToView": {
|
@@ -1,4 +1,4 @@
|
|
1
|
-
import { proxyCustomElement, HTMLElement, h } from '@stencil/core/internal/client';
|
1
|
+
import { proxyCustomElement, HTMLElement, createEvent, h } from '@stencil/core/internal/client';
|
2
2
|
import { DataUnit, StringUtils, SortMode, DataType, ChangeOperation, UserInterface } from '@sankhyalabs/core';
|
3
3
|
import { V as VIEW_MODE, S as SIMPLE_CRUD_MODE } from './constants.js';
|
4
4
|
import { T as TaskbarElement, d as defineCustomElement$2 } from './snk-taskbar2.js';
|
@@ -127,6 +127,8 @@ const SnkSimpleCrud$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLEleme
|
|
127
127
|
constructor() {
|
128
128
|
super();
|
129
129
|
this.__registerHost();
|
130
|
+
this.dataStateChange = createEvent(this, "dataStateChange", 3);
|
131
|
+
this.dataUnitReady = createEvent(this, "dataUnitReady", 3);
|
130
132
|
this.REGULAR_DEFAULT_BTNS = ["INSERT", "PREVIOUS", "NEXT", "DIVIDER"];
|
131
133
|
this.REGULAR_SELECTED_BTNS = ["INSERT", "PREVIOUS", "NEXT", "DIVIDER", "CLONE", "REMOVE", "DIVIDER"];
|
132
134
|
this._taskbarProcessor = new TaskbarProcessor({
|
@@ -187,6 +189,7 @@ const SnkSimpleCrud$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLEleme
|
|
187
189
|
initInMemoryDataUnit() {
|
188
190
|
this._inMemoryLoader = new InMemoryLoader(this._metadata);
|
189
191
|
this.dataUnit = this._inMemoryLoader.dataUnit;
|
192
|
+
this.dataUnitReady.emit(this.dataUnit);
|
190
193
|
}
|
191
194
|
setMetadata(metadata) {
|
192
195
|
if (this._inMemoryLoader) {
|
@@ -221,9 +224,10 @@ const SnkSimpleCrud$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLEleme
|
|
221
224
|
userInterface: UserInterface[fieldElem.getAttribute("userInterface")] || UserInterface.SHORTTEXT,
|
222
225
|
readOnly: fieldElem.getAttribute("readOnly") == "true",
|
223
226
|
required: fieldElem.getAttribute("required") == "true",
|
224
|
-
tab: fieldElem.getAttribute("tab") || undefined
|
227
|
+
tab: fieldElem.getAttribute("tab") || undefined,
|
228
|
+
visible: fieldElem.getAttribute("visible") != "false"
|
225
229
|
};
|
226
|
-
const fieldConfig = { name: field.name, tab: field.tab };
|
230
|
+
const fieldConfig = { name: field.name, tab: field.tab, visible: field.visible };
|
227
231
|
formConfig.fields.push(fieldConfig);
|
228
232
|
fieldMetadata.push(field);
|
229
233
|
});
|
@@ -236,9 +240,13 @@ const SnkSimpleCrud$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLEleme
|
|
236
240
|
};
|
237
241
|
}
|
238
242
|
}
|
243
|
+
onDataStateChange(evt) {
|
244
|
+
this.dataStateChange.emit(evt.detail);
|
245
|
+
this.dataState = evt.detail;
|
246
|
+
}
|
239
247
|
render() {
|
240
248
|
var _a;
|
241
|
-
return (h("snk-data-unit", { class: "simple-crud__container", dataUnit: this.dataUnit, onDataStateChange: evt => this.
|
249
|
+
return (h("snk-data-unit", { class: "simple-crud__container", dataUnit: this.dataUnit, onDataStateChange: evt => this.onDataStateChange(evt), onInsertionMode: () => this.goToView(VIEW_MODE.FORM), onDataUnitReady: (evt) => this.dataUnitReady.emit(evt.detail) }, h("header", null, h("slot", { name: "snkSimpleCrudHeader" })), h("section", { class: "ez-flex ez-box ez-box--shadow" }, h("snk-taskbar", { class: "simple-crud__taskbar ez-box ez-box--shadow ez-padding--medium", dataUnit: this.dataUnit, primaryButton: ((_a = this.dataState) === null || _a === void 0 ? void 0 : _a.isDirty) ? "SAVE" : "INSERT", "data-element-id": "grid_left", buttons: this._taskbarProcessor.buttons, disabledButtons: this._taskbarProcessor.disabledButtons, customButtons: this._taskbarProcessor.customButtons, slot: "leftButtons", presentationMode: PresentationMode.SECONDARY }), h("ez-view-stack", { class: "ez-flex ez-flex--column", ref: (ref) => this._viewStack = ref, "data-element-id": "simple-crud" }, h("stack-item", null, h("ez-grid", { dataUnit: this.dataUnit, onEzDoubleClick: () => this.goToView(VIEW_MODE.FORM), "no-header": true }, h("div", { slot: "footer" }, h("slot", { name: "snkSimpleCrudFooter" })))), h("stack-item", null, h("ez-form", { dataUnit: this.dataUnit, config: this._config }))))));
|
242
250
|
}
|
243
251
|
get _element() { return this; }
|
244
252
|
static get watchers() { return {
|
@@ -1,4 +1,4 @@
|
|
1
|
-
import { r as registerInstance, h, g as getElement } from './index-cfd4bb13.js';
|
1
|
+
import { r as registerInstance, c as createEvent, h, g as getElement } from './index-cfd4bb13.js';
|
2
2
|
import { DataUnit, StringUtils, SortMode, DataType, ChangeOperation, UserInterface } from '@sankhyalabs/core';
|
3
3
|
import { c as VIEW_MODE, S as SIMPLE_CRUD_MODE } from './constants-9560e54f.js';
|
4
4
|
import { T as TaskbarElement } from './taskbar-elements-10d80c79.js';
|
@@ -125,6 +125,8 @@ const snkSimpleCrudCss = ".sc-snk-simple-crud-h{display:flex;height:100%;width:1
|
|
125
125
|
const SnkSimpleCrud = class {
|
126
126
|
constructor(hostRef) {
|
127
127
|
registerInstance(this, hostRef);
|
128
|
+
this.dataStateChange = createEvent(this, "dataStateChange", 3);
|
129
|
+
this.dataUnitReady = createEvent(this, "dataUnitReady", 3);
|
128
130
|
this.REGULAR_DEFAULT_BTNS = ["INSERT", "PREVIOUS", "NEXT", "DIVIDER"];
|
129
131
|
this.REGULAR_SELECTED_BTNS = ["INSERT", "PREVIOUS", "NEXT", "DIVIDER", "CLONE", "REMOVE", "DIVIDER"];
|
130
132
|
this._taskbarProcessor = new TaskbarProcessor({
|
@@ -185,6 +187,7 @@ const SnkSimpleCrud = class {
|
|
185
187
|
initInMemoryDataUnit() {
|
186
188
|
this._inMemoryLoader = new InMemoryLoader(this._metadata);
|
187
189
|
this.dataUnit = this._inMemoryLoader.dataUnit;
|
190
|
+
this.dataUnitReady.emit(this.dataUnit);
|
188
191
|
}
|
189
192
|
setMetadata(metadata) {
|
190
193
|
if (this._inMemoryLoader) {
|
@@ -219,9 +222,10 @@ const SnkSimpleCrud = class {
|
|
219
222
|
userInterface: UserInterface[fieldElem.getAttribute("userInterface")] || UserInterface.SHORTTEXT,
|
220
223
|
readOnly: fieldElem.getAttribute("readOnly") == "true",
|
221
224
|
required: fieldElem.getAttribute("required") == "true",
|
222
|
-
tab: fieldElem.getAttribute("tab") || undefined
|
225
|
+
tab: fieldElem.getAttribute("tab") || undefined,
|
226
|
+
visible: fieldElem.getAttribute("visible") != "false"
|
223
227
|
};
|
224
|
-
const fieldConfig = { name: field.name, tab: field.tab };
|
228
|
+
const fieldConfig = { name: field.name, tab: field.tab, visible: field.visible };
|
225
229
|
formConfig.fields.push(fieldConfig);
|
226
230
|
fieldMetadata.push(field);
|
227
231
|
});
|
@@ -234,9 +238,13 @@ const SnkSimpleCrud = class {
|
|
234
238
|
};
|
235
239
|
}
|
236
240
|
}
|
241
|
+
onDataStateChange(evt) {
|
242
|
+
this.dataStateChange.emit(evt.detail);
|
243
|
+
this.dataState = evt.detail;
|
244
|
+
}
|
237
245
|
render() {
|
238
246
|
var _a;
|
239
|
-
return (h("snk-data-unit", { class: "simple-crud__container", dataUnit: this.dataUnit, onDataStateChange: evt => this.
|
247
|
+
return (h("snk-data-unit", { class: "simple-crud__container", dataUnit: this.dataUnit, onDataStateChange: evt => this.onDataStateChange(evt), onInsertionMode: () => this.goToView(VIEW_MODE.FORM), onDataUnitReady: (evt) => this.dataUnitReady.emit(evt.detail) }, h("header", null, h("slot", { name: "snkSimpleCrudHeader" })), h("section", { class: "ez-flex ez-box ez-box--shadow" }, h("snk-taskbar", { class: "simple-crud__taskbar ez-box ez-box--shadow ez-padding--medium", dataUnit: this.dataUnit, primaryButton: ((_a = this.dataState) === null || _a === void 0 ? void 0 : _a.isDirty) ? "SAVE" : "INSERT", "data-element-id": "grid_left", buttons: this._taskbarProcessor.buttons, disabledButtons: this._taskbarProcessor.disabledButtons, customButtons: this._taskbarProcessor.customButtons, slot: "leftButtons", presentationMode: PresentationMode.SECONDARY }), h("ez-view-stack", { class: "ez-flex ez-flex--column", ref: (ref) => this._viewStack = ref, "data-element-id": "simple-crud" }, h("stack-item", null, h("ez-grid", { dataUnit: this.dataUnit, onEzDoubleClick: () => this.goToView(VIEW_MODE.FORM), "no-header": true }, h("div", { slot: "footer" }, h("slot", { name: "snkSimpleCrudFooter" })))), h("stack-item", null, h("ez-form", { dataUnit: this.dataUnit, config: this._config }))))));
|
240
248
|
}
|
241
249
|
get _element() { return getElement(this); }
|
242
250
|
static get watchers() { return {
|
@@ -0,0 +1 @@
|
|
1
|
+
import{r as t,c as s,h as e,g as i}from"./p-b9667fbe.js";import{DataUnit as r,StringUtils as a,SortMode as n,DataType as o,ChangeOperation as h,UserInterface as d}from"@sankhyalabs/core";import{c as l,S as m}from"./p-ecbfbb4a.js";import{T as u}from"./p-74724fa7.js";import"./p-0c11c980.js";import{P as c}from"./p-f132e371.js";import{T as p}from"./p-5a3e0eb6.js";import"./p-98f7f796.js";import"./p-112455b1.js";class b{constructor(t,s){this.records=s||[],this.metadata=t,this._dataUnit=new r("InMemoryDataUnit"),this._dataUnit.metadataLoader=()=>this.metadaLoader(),this._dataUnit.dataLoader=(t,s)=>this.dataLoader(t,s),this._dataUnit.saveLoader=(t,s)=>this.saveLoader(t,s),this._dataUnit.removeLoader=(t,s)=>this.removeLoader(t,s),this.dataUnit.loadMetadata().then((()=>this.dataUnit.loadData()))}get dataUnit(){return this._dataUnit}get records(){return this._records}set records(t){this._records=null==t?void 0:t.map((t=>(t.__record__id__||(t.__record__id__=this.generateUniqueId()),t))),this._dataUnit&&(this._dataUnit.records=[...this._records])}get metadata(){return this._metadata}set metadata(t){this._metadata=t,this._dataUnit&&(this._dataUnit.metadata=this._metadata)}generateUniqueId(){return a.generateUUID()}metadaLoader(){return Promise.resolve(this._metadata)}dataLoader(t,s){let e=[...this._records];return s.sort&&s.sort.forEach((t=>{e=e.sort(((s,e)=>{const i=s[t.field],r=e[t.field];return this.getSortFn(t.dataType)(i,r)*(t.mode==n.ASC?1:-1)}))})),Promise.resolve({records:e})}getSortFn(t){switch(t){case o.NUMBER:return this.sortNumber;case o.DATE:return this.sortDate;case o.OBJECT:return this.sortObject;default:return a.compare}}sortObject(t,s){return a.compare(t.label,s.label)}sortNumber(t,s){return t-s}sortDate(t,s){let e=t.getTime(),i=s.getTime();return e===i?0:e<i?-1:1}saveLoader(t,s){return new Promise((t=>{let e=[];s.forEach((t=>{let{record:s,updatingFields:i,operation:r}=t,a=!1;r!==h.INSERT&&r!==h.COPY||(s.__old__id__=s.__record__id__,s.__record__id__=this.generateUniqueId(),a=!0);const n=Object.assign(Object.assign({},s),i);if(a)this.records.push(n);else{const t=this.records.findIndex((t=>t.__record__id__==n.__record__id__));this.records[t]=n}e.push(n)})),t(e)}))}removeLoader(t,s){return new Promise((t=>{this._records=this._records.filter((t=>!s.includes(t.__record__id__))),t(s)}))}}const k=class{constructor(e){t(this,e),this.dataStateChange=s(this,"dataStateChange",3),this.dataUnitReady=s(this,"dataUnitReady",3),this.REGULAR_DEFAULT_BTNS=["INSERT","PREVIOUS","NEXT","DIVIDER"],this.REGULAR_SELECTED_BTNS=["INSERT","PREVIOUS","NEXT","DIVIDER","CLONE","REMOVE","DIVIDER"],this._taskbarProcessor=new p({"snkSimpleCrudTaskbar.form_regular":this.REGULAR_DEFAULT_BTNS.concat(u.GRID_MODE),"snkSimpleCrudTaskbar.grid_regular":this.REGULAR_DEFAULT_BTNS.concat(u.FORM_MODE),"snkSimpleCrudTaskbar.form_selected":this.REGULAR_SELECTED_BTNS.concat(u.GRID_MODE),"snkSimpleCrudTaskbar.grid_selected":this.REGULAR_SELECTED_BTNS.concat(u.FORM_MODE),"snkSimpleCrudTaskbar.finish_edition":["CANCEL","SAVE"]}),this._currentViewMode=l.GRID,this._config=void 0,this.dataState=void 0,this.dataUnit=void 0,this.mode=m.SERVER,this.taskbarManager=void 0}async goToView(t){this._currentViewMode=t,this._viewStack&&this._viewStack.show(t)}actionClickListener(t){const s=t.detail;s===u.GRID_MODE?this.goToView(l.GRID):s===u.FORM_MODE&&this.goToView(l.FORM),t.stopPropagation()}onModeChange(){this.mode==m.IN_MEMORY&&this.initInMemoryDataUnit()}componentWillRender(){this._taskbarProcessor.process(this.getTaskBarId(),this.taskbarManager,this.dataState,void 0)}componentWillLoad(){this.processMetadata(),this.onModeChange()}getTaskBarId(){var t,s;return(null===(t=this.dataState)||void 0===t?void 0:t.isDirty)?"snkSimpleCrudTaskbar.finish_edition":(null===(s=this.dataState)||void 0===s?void 0:s.selectedRecords.length)>0?this._currentViewMode===l.GRID?"snkSimpleCrudTaskbar.grid_selected":"snkSimpleCrudTaskbar.form_selected":this._currentViewMode===l.GRID?"snkSimpleCrudTaskbar.grid_regular":"snkSimpleCrudTaskbar.form_regular"}initInMemoryDataUnit(){this._inMemoryLoader=new b(this._metadata),this.dataUnit=this._inMemoryLoader.dataUnit,this.dataUnitReady.emit(this.dataUnit)}setMetadata(t){return this._inMemoryLoader?this._inMemoryLoader.metadata=t:this.dataUnit&&(this.dataUnit.metadata=t),Promise.resolve()}setRecords(t){return this._inMemoryLoader?this._inMemoryLoader.records=t:this.dataUnit&&(this.dataUnit.records=t),Promise.resolve()}getRecords(){return Promise.resolve(this.dataUnit.records)}processMetadata(){const t=this._element.querySelectorAll("snk-field-metadata"),s=[],e={fields:[],emptyConfig:!1};t.forEach((t=>{const i={name:t.getAttribute("name")||t.getAttribute("label"),label:t.getAttribute("label"),dataType:o[t.getAttribute("dataType")]||o.TEXT,userInterface:d[t.getAttribute("userInterface")]||d.SHORTTEXT,readOnly:"true"==t.getAttribute("readOnly"),required:"true"==t.getAttribute("required"),tab:t.getAttribute("tab")||void 0,visible:"false"!=t.getAttribute("visible")};e.fields.push({name:i.name,tab:i.tab,visible:i.visible}),s.push(i)})),s.length>0&&(this._config=e,this._metadata={name:"SimpleCrud",label:"SimpleCrud",fields:s})}onDataStateChange(t){this.dataStateChange.emit(t.detail),this.dataState=t.detail}render(){var t;return e("snk-data-unit",{class:"simple-crud__container",dataUnit:this.dataUnit,onDataStateChange:t=>this.onDataStateChange(t),onInsertionMode:()=>this.goToView(l.FORM),onDataUnitReady:t=>this.dataUnitReady.emit(t.detail)},e("header",null,e("slot",{name:"snkSimpleCrudHeader"})),e("section",{class:"ez-flex ez-box ez-box--shadow"},e("snk-taskbar",{class:"simple-crud__taskbar ez-box ez-box--shadow ez-padding--medium",dataUnit:this.dataUnit,primaryButton:(null===(t=this.dataState)||void 0===t?void 0:t.isDirty)?"SAVE":"INSERT","data-element-id":"grid_left",buttons:this._taskbarProcessor.buttons,disabledButtons:this._taskbarProcessor.disabledButtons,customButtons:this._taskbarProcessor.customButtons,slot:"leftButtons",presentationMode:c.SECONDARY}),e("ez-view-stack",{class:"ez-flex ez-flex--column",ref:t=>this._viewStack=t,"data-element-id":"simple-crud"},e("stack-item",null,e("ez-grid",{dataUnit:this.dataUnit,onEzDoubleClick:()=>this.goToView(l.FORM),"no-header":!0},e("div",{slot:"footer"},e("slot",{name:"snkSimpleCrudFooter"})))),e("stack-item",null,e("ez-form",{dataUnit:this.dataUnit,config:this._config})))))}get _element(){return i(this)}static get watchers(){return{mode:["onModeChange"]}}};k.style=".sc-snk-simple-crud-h{display:flex;height:100%;width:100%}.simple-crud__container.sc-snk-simple-crud{display:grid;grid-template-rows:auto;row-gap:12px;height:100%;width:100%}.simple-crud__taskbar.sc-snk-simple-crud{z-index:var(--more-visible, 2);margin-bottom:var(--space--medium)}ez-grid.sc-snk-simple-crud{--ez-grid__container--shadow:none;min-height:300px}ez-form.sc-snk-simple-crud{min-height:300px}";export{k as snk_simple_crud}
|
@@ -1 +1 @@
|
|
1
|
-
import{p as e,b as t}from"./p-b9667fbe.js";export{s as setNonce}from"./p-b9667fbe.js";(()=>{const t=import.meta.url,a={};return""!==t&&(a.resourcesUrl=new URL(".",t).href),e(a)})().then((e=>t([["p-
|
1
|
+
import{p as e,b as t}from"./p-b9667fbe.js";export{s as setNonce}from"./p-b9667fbe.js";(()=>{const t=import.meta.url,a={};return""!==t&&(a.resourcesUrl=new URL(".",t).href),e(a)})().then((e=>t([["p-4a12a1ae",[[6,"snk-simple-crud",{dataState:[16],dataUnit:[16],mode:[2],taskbarManager:[16],_currentViewMode:[32],_config:[32],goToView:[64],setMetadata:[64],setRecords:[64],getRecords:[64]},[[0,"actionClick","actionClickListener"]]]]],["p-e551b19a",[[1,"teste-pesquisa"]]],["p-86d29b6f",[[0,"snk-filter-binary-select",{value:[1544],config:[16],show:[64]},[[0,"ezChange","ezChangeListener"]]]]],["p-79d22df0",[[2,"snk-filter-field-search",{searchable:[4],breadcrumbItems:[32],linkItems:[32],fieldItems:[32],setDataSource:[64],filterDataSource:[64]}]]],["p-ee82c157",[[0,"snk-filter-multi-select",{value:[1544],config:[16],show:[64]},[[0,"ezChange","ezChangeListener"]]]]],["p-ad51bf1c",[[0,"snk-filter-number",{config:[16],value:[2],show:[64]},[[0,"ezChange","ezChangeListener"]]]]],["p-0154ae58",[[2,"snk-filter-param-config",{_opened:[32],_configType:[32],_expressionItem:[32],_informedInstance:[32],_canSave:[32],open:[64],close:[64]}]]],["p-5fc55684",[[0,"snk-filter-period",{config:[16],value:[8],show:[64]},[[0,"ezChange","ezChangeListener"]]]]],["p-d5c9c1f8",[[0,"snk-filter-personalized",{config:[16],value:[1040],fix:[16],unfix:[16],show:[64]}]]],["p-5e62a17b",[[0,"snk-filter-search",{config:[16],value:[16],show:[64]},[[0,"ezChange","ezChangeListener"]]]]],["p-c336170d",[[0,"snk-filter-text",{config:[16],value:[1]},[[0,"ezChange","ezChangeListener"]]]]],["p-4bd183ba",[[2,"snk-detail-view",{formConfigManager:[1040],dataUnitName:[1,"data-unit-name"],guideItemPath:[16],entityName:[1,"entity-name"],label:[1],dataUnit:[1040],selectedForm:[1025,"selected-form"],dataState:[1040],changeViewMode:[64],configGrid:[64],showUp:[64]},[[0,"snkContentCardChanged","onContentCardChanged"]]]]],["p-9f2306ba",[[2,"snk-configurator",{configName:[1,"config-name"],viewMode:[2,"view-mode"],_opened:[32],_permissions:[32],open:[64],close:[64]}]]],["p-e701646c",[[2,"snk-pesquisa",{searchLoader:[16],selectItem:[16],argument:[1025],_itemList:[32],_startLoading:[32]}]]],["p-a056d61f",[[2,"snk-filter-bar",{dataUnit:[1040],configName:[1,"config-name"],filterConfig:[1040],allowDefault:[32],scrollerLocked:[32]},[[0,"filterChange","filterChangeListener"]]]]],["p-b318cec6",[[2,"snk-grid-config",{selectedIndex:[1026,"selected-index"],application:[16],columns:[1040],config:[1040],configName:[1,"config-name"]}]]],["p-869d6616",[[2,"snk-config-options",{fieldConfig:[16],idConfig:[513,"id-config"],dataUnit:[16],_defaultType:[32]}]]],["p-7889d481",[[2,"snk-data-unit",{dataState:[1040],dataUnitName:[1,"data-unit-name"],entityName:[1,"entity-name"],pageSize:[2,"page-size"],dataUnit:[1040],beforeSave:[16],afterSave:[16],getDataUnit:[64],getSelectedRecordsIDsInfo:[64]}]]],["p-f83e3219",[[2,"snk-field-config",{isConfigActive:[16],fieldConfig:[16],modeInsertion:[516,"mode-insertion"],dataUnit:[16]}]]],["p-86efa17d",[[6,"snk-tab-config",{selectedIndex:[1538,"selected-index"],selectedTab:[1537,"selected-tab"],tabs:[1],_processedTabs:[32],_activeEditText:[32],_activeEditTextIndex:[32],_actionsHide:[32],_actionsShow:[32]}]]],["p-8b0e8deb",[[2,"snk-form-config",{dataUnit:[16],configManager:[16],_formConfigOptions:[32],_fieldConfigSelected:[32],_layoutFormConfig:[32],_fieldsAvailable:[32],_formConfig:[32],_formConfigChanged:[32],_optionFormConfigSelected:[32],_optionFormConfigChanged:[32],_tempGroups:[32]}]]],["p-eb7b2496",[[6,"snk-taskbar",{configName:[1,"config-name"],buttons:[1],customButtons:[16],actionsList:[16],primaryButton:[1,"primary-button"],disabledButtons:[16],dataUnit:[16],presentationMode:[1537,"presentation-mode"],_permissions:[32]}]]],["p-3a2ce158",[[0,"snk-filter-item",{config:[1040],getMessage:[16],detailIsVisible:[32],showUp:[64],hideDetail:[64]},[[2,"click","clickListener"],[2,"mousedown","mouseDownListener"],[0,"filterChange","filterChangeListener"]]]]],["p-093febff",[[4,"snk-filter-list",{label:[1],iconName:[1,"icon-name"],items:[16],getMessage:[16],emptyText:[1,"empty-text"],findFilterText:[1,"find-filter-text"],buttonClass:[1,"button-class"],_filterArgument:[32],_showAll:[32],hideDetail:[64]},[[2,"keydown","keyDownHandler"]]]]],["p-dbeac5db",[[1,"snk-select-box",{selectedOption:[1,"selected-option"]}]]],["p-22e44b9d",[[0,"snk-exporter-email-sender",{getMessage:[16],_config:[32],_opened:[32],_currentStep:[32],open:[64],close:[64]}]]],["p-cf9d1b55",[[2,"snk-data-exporter",{provider:[16],_items:[32],_showDropdown:[32],_releasedToExport:[32]}]]],["p-c0bfafcb",[[2,"snk-guides-viewer",{dataUnit:[16],dataState:[16],configName:[1,"config-name"],entityPath:[1,"entity-path"],actionsList:[16],recordsValidator:[16],masterFormConfig:[1040],selectedGuide:[16],taskbarManager:[16],presentationMode:[1,"presentation-mode"],_breadcrumbItems:[32],_guides:[32],_formEditorConfigManager:[32],_formEditorDataUnit:[32],showFormConfig:[64]},[[2,"actionClick","onActionClick"],[0,"snkContentCardChanged","onContentCardChanged"]]]]],["p-2a3996b0",[[6,"snk-crud",{configName:[1025,"config-name"],actionsList:[16],taskbarManager:[16],recordsValidator:[16],statusResolver:[16],multipleSelection:[4,"multiple-selection"],presentationMode:[1,"presentation-mode"],_dataUnit:[32],_dataState:[32],_currentViewMode:[32],goToView:[64]}]]],["p-d3199c18",[[2,"snk-form",{configName:[1,"config-name"],recordsValidator:[16],_dataUnit:[32],_dataState:[32],_showFormConfig:[32],_configManager:[32],showConfig:[64],hideConfig:[64]}]]],["p-9f00c061",[[2,"snk-application",{messagesBuilder:[1040],configName:[1,"config-name"],isUserSup:[64],hasAccess:[64],getAllAccess:[64],getStringParam:[64],getIntParam:[64],getFloatParam:[64],getBooleanParam:[64],getDateParam:[64],showPopUp:[64],showModal:[64],closeModal:[64],closePopUp:[64],temOpcional:[64],getConfig:[64],saveConfig:[64],getAttributeFromHTMLWrapper:[64],openApp:[64],webConnection:[64],createDataunit:[64],updateDataunitCache:[64],getDataUnit:[64],addClientEvent:[64],removeClientEvent:[64],hasClientEvent:[64],getResourceID:[64],getUserID:[64],alert:[64],error:[64],success:[64],message:[64],confirm:[64],info:[64],loadGridConfig:[64],loadTotals:[64],executeSearch:[64],executePreparedSearch:[64],isDebugMode:[64],getAppLabel:[64]}]]],["p-afba9bbe",[[0,"snk-filter-detail",{config:[1040],getMessage:[16],show:[64]}]]],["p-268ab84f",[[6,"snk-grid",{configName:[1,"config-name"],actionsList:[16],taskbarManager:[16],statusResolver:[16],multipleSelection:[4,"multiple-selection"],presentationMode:[1,"presentation-mode"],_dataUnit:[32],_dataState:[32],_gridConfig:[32],_popUpGridConfig:[32],showConfig:[64],hideConfig:[64],setConfig:[64]}]]],["p-900b2889",[[2,"snk-form-summary",{fixed:[1540],contracted:[1540],summary:[16]}]]],["p-9ebb164d",[[6,"snk-form-view",{levelPath:[1,"level-path"],label:[1],name:[1],fields:[16],formMetadata:[8,"form-metadata"],dataUnit:[16],contracted:[4],fixed:[1540],summaryFields:[16],canExpand:[4,"can-expand"],canFix:[4,"can-fix"],recordsValidator:[16],showUp:[64]}]]],["p-73e830cf",[[0,"snk-filter-modal",{getMessage:[16],items:[1040],modalTitle:[1,"modal-title"],modalSubTitle:[1,"modal-sub-title"],cancelButtonLabel:[1,"cancel-button-label"],okButtonLabel:[1,"ok-button-label"],infoText:[1,"info-text"],useSearch:[4,"use-search"],processModalAction:[16],_filterArgument:[32]}]]]],e)));
|
@@ -1,4 +1,5 @@
|
|
1
1
|
import { DataUnit, Record, UnitMetadata } from '@sankhyalabs/core';
|
2
|
+
import { EventEmitter } from '../../stencil-public-runtime';
|
2
3
|
import { VIEW_MODE, SIMPLE_CRUD_MODE } from '../../lib/utils/constants';
|
3
4
|
import { DataState } from '../snk-data-unit/snk-data-unit';
|
4
5
|
import TaskbarProcessor from '../snk-taskbar/processor/taskbar-processor';
|
@@ -17,6 +18,14 @@ export declare class SnkSimpleCrud {
|
|
17
18
|
dataState: DataState;
|
18
19
|
dataUnit: DataUnit;
|
19
20
|
mode: SIMPLE_CRUD_MODE;
|
21
|
+
/**
|
22
|
+
* Emitido quando há qualquer mudança de estado no DataUnit.
|
23
|
+
*/
|
24
|
+
dataStateChange: EventEmitter<DataState>;
|
25
|
+
/**
|
26
|
+
* Emitido quando o DataUnit está pronto.
|
27
|
+
*/
|
28
|
+
dataUnitReady: EventEmitter<DataUnit>;
|
20
29
|
/**
|
21
30
|
* Gerenciador das barras de tarefas. É possível determinar botões específicos
|
22
31
|
* ou mesmo gerenciar o estado dos botões.
|
@@ -37,5 +46,6 @@ export declare class SnkSimpleCrud {
|
|
37
46
|
setRecords(records: Array<Record>): Promise<void>;
|
38
47
|
getRecords(): Promise<Array<Record>>;
|
39
48
|
processMetadata(): void;
|
49
|
+
onDataStateChange(evt: any): void;
|
40
50
|
render(): any;
|
41
51
|
}
|
@@ -985,6 +985,10 @@ export interface SnkSelectBoxCustomEvent<T> extends CustomEvent<T> {
|
|
985
985
|
detail: T;
|
986
986
|
target: HTMLSnkSelectBoxElement;
|
987
987
|
}
|
988
|
+
export interface SnkSimpleCrudCustomEvent<T> extends CustomEvent<T> {
|
989
|
+
detail: T;
|
990
|
+
target: HTMLSnkSimpleCrudElement;
|
991
|
+
}
|
988
992
|
export interface SnkTabConfigCustomEvent<T> extends CustomEvent<T> {
|
989
993
|
detail: T;
|
990
994
|
target: HTMLSnkTabConfigElement;
|
@@ -1903,6 +1907,14 @@ declare namespace LocalJSX {
|
|
1903
1907
|
"dataState"?: DataState1;
|
1904
1908
|
"dataUnit"?: DataUnit;
|
1905
1909
|
"mode"?: SIMPLE_CRUD_MODE;
|
1910
|
+
/**
|
1911
|
+
* Emitido quando há qualquer mudança de estado no DataUnit.
|
1912
|
+
*/
|
1913
|
+
"onDataStateChange"?: (event: SnkSimpleCrudCustomEvent<DataState1>) => void;
|
1914
|
+
/**
|
1915
|
+
* Emitido quando o DataUnit está pronto.
|
1916
|
+
*/
|
1917
|
+
"onDataUnitReady"?: (event: SnkSimpleCrudCustomEvent<DataUnit>) => void;
|
1906
1918
|
/**
|
1907
1919
|
* Gerenciador das barras de tarefas. É possível determinar botões específicos ou mesmo gerenciar o estado dos botões.
|
1908
1920
|
*/
|
package/package.json
CHANGED
@@ -1 +0,0 @@
|
|
1
|
-
import{r as t,h as s,g as e}from"./p-b9667fbe.js";import{DataUnit as i,StringUtils as r,SortMode as a,DataType as n,ChangeOperation as o,UserInterface as h}from"@sankhyalabs/core";import{c as d,S as l}from"./p-ecbfbb4a.js";import{T as m}from"./p-74724fa7.js";import"./p-0c11c980.js";import{P as u}from"./p-f132e371.js";import{T as c}from"./p-5a3e0eb6.js";import"./p-98f7f796.js";import"./p-112455b1.js";class p{constructor(t,s){this.records=s||[],this.metadata=t,this._dataUnit=new i("InMemoryDataUnit"),this._dataUnit.metadataLoader=()=>this.metadaLoader(),this._dataUnit.dataLoader=(t,s)=>this.dataLoader(t,s),this._dataUnit.saveLoader=(t,s)=>this.saveLoader(t,s),this._dataUnit.removeLoader=(t,s)=>this.removeLoader(t,s),this.dataUnit.loadMetadata().then((()=>this.dataUnit.loadData()))}get dataUnit(){return this._dataUnit}get records(){return this._records}set records(t){this._records=null==t?void 0:t.map((t=>(t.__record__id__||(t.__record__id__=this.generateUniqueId()),t))),this._dataUnit&&(this._dataUnit.records=[...this._records])}get metadata(){return this._metadata}set metadata(t){this._metadata=t,this._dataUnit&&(this._dataUnit.metadata=this._metadata)}generateUniqueId(){return r.generateUUID()}metadaLoader(){return Promise.resolve(this._metadata)}dataLoader(t,s){let e=[...this._records];return s.sort&&s.sort.forEach((t=>{e=e.sort(((s,e)=>{const i=s[t.field],r=e[t.field];return this.getSortFn(t.dataType)(i,r)*(t.mode==a.ASC?1:-1)}))})),Promise.resolve({records:e})}getSortFn(t){switch(t){case n.NUMBER:return this.sortNumber;case n.DATE:return this.sortDate;case n.OBJECT:return this.sortObject;default:return r.compare}}sortObject(t,s){return r.compare(t.label,s.label)}sortNumber(t,s){return t-s}sortDate(t,s){let e=t.getTime(),i=s.getTime();return e===i?0:e<i?-1:1}saveLoader(t,s){return new Promise((t=>{let e=[];s.forEach((t=>{let{record:s,updatingFields:i,operation:r}=t,a=!1;r!==o.INSERT&&r!==o.COPY||(s.__old__id__=s.__record__id__,s.__record__id__=this.generateUniqueId(),a=!0);const n=Object.assign(Object.assign({},s),i);if(a)this.records.push(n);else{const t=this.records.findIndex((t=>t.__record__id__==n.__record__id__));this.records[t]=n}e.push(n)})),t(e)}))}removeLoader(t,s){return new Promise((t=>{this._records=this._records.filter((t=>!s.includes(t.__record__id__))),t(s)}))}}const b=class{constructor(s){t(this,s),this.REGULAR_DEFAULT_BTNS=["INSERT","PREVIOUS","NEXT","DIVIDER"],this.REGULAR_SELECTED_BTNS=["INSERT","PREVIOUS","NEXT","DIVIDER","CLONE","REMOVE","DIVIDER"],this._taskbarProcessor=new c({"snkSimpleCrudTaskbar.form_regular":this.REGULAR_DEFAULT_BTNS.concat(m.GRID_MODE),"snkSimpleCrudTaskbar.grid_regular":this.REGULAR_DEFAULT_BTNS.concat(m.FORM_MODE),"snkSimpleCrudTaskbar.form_selected":this.REGULAR_SELECTED_BTNS.concat(m.GRID_MODE),"snkSimpleCrudTaskbar.grid_selected":this.REGULAR_SELECTED_BTNS.concat(m.FORM_MODE),"snkSimpleCrudTaskbar.finish_edition":["CANCEL","SAVE"]}),this._currentViewMode=d.GRID,this._config=void 0,this.dataState=void 0,this.dataUnit=void 0,this.mode=l.SERVER,this.taskbarManager=void 0}async goToView(t){this._currentViewMode=t,this._viewStack&&this._viewStack.show(t)}actionClickListener(t){const s=t.detail;s===m.GRID_MODE?this.goToView(d.GRID):s===m.FORM_MODE&&this.goToView(d.FORM),t.stopPropagation()}onModeChange(){this.mode==l.IN_MEMORY&&this.initInMemoryDataUnit()}componentWillRender(){this._taskbarProcessor.process(this.getTaskBarId(),this.taskbarManager,this.dataState,void 0)}componentWillLoad(){this.processMetadata(),this.onModeChange()}getTaskBarId(){var t,s;return(null===(t=this.dataState)||void 0===t?void 0:t.isDirty)?"snkSimpleCrudTaskbar.finish_edition":(null===(s=this.dataState)||void 0===s?void 0:s.selectedRecords.length)>0?this._currentViewMode===d.GRID?"snkSimpleCrudTaskbar.grid_selected":"snkSimpleCrudTaskbar.form_selected":this._currentViewMode===d.GRID?"snkSimpleCrudTaskbar.grid_regular":"snkSimpleCrudTaskbar.form_regular"}initInMemoryDataUnit(){this._inMemoryLoader=new p(this._metadata),this.dataUnit=this._inMemoryLoader.dataUnit}setMetadata(t){return this._inMemoryLoader?this._inMemoryLoader.metadata=t:this.dataUnit&&(this.dataUnit.metadata=t),Promise.resolve()}setRecords(t){return this._inMemoryLoader?this._inMemoryLoader.records=t:this.dataUnit&&(this.dataUnit.records=t),Promise.resolve()}getRecords(){return Promise.resolve(this.dataUnit.records)}processMetadata(){const t=this._element.querySelectorAll("snk-field-metadata"),s=[],e={fields:[],emptyConfig:!1};t.forEach((t=>{const i={name:t.getAttribute("name")||t.getAttribute("label"),label:t.getAttribute("label"),dataType:n[t.getAttribute("dataType")]||n.TEXT,userInterface:h[t.getAttribute("userInterface")]||h.SHORTTEXT,readOnly:"true"==t.getAttribute("readOnly"),required:"true"==t.getAttribute("required"),tab:t.getAttribute("tab")||void 0};e.fields.push({name:i.name,tab:i.tab}),s.push(i)})),s.length>0&&(this._config=e,this._metadata={name:"SimpleCrud",label:"SimpleCrud",fields:s})}render(){var t;return s("snk-data-unit",{class:"simple-crud__container",dataUnit:this.dataUnit,onDataStateChange:t=>this.dataState=t.detail,onInsertionMode:()=>this.goToView(d.FORM)},s("header",null,s("slot",{name:"snkSimpleCrudHeader"})),s("section",{class:"ez-flex ez-box ez-box--shadow"},s("snk-taskbar",{class:"simple-crud__taskbar ez-box ez-box--shadow ez-padding--medium",dataUnit:this.dataUnit,primaryButton:(null===(t=this.dataState)||void 0===t?void 0:t.isDirty)?"SAVE":"INSERT","data-element-id":"grid_left",buttons:this._taskbarProcessor.buttons,disabledButtons:this._taskbarProcessor.disabledButtons,customButtons:this._taskbarProcessor.customButtons,slot:"leftButtons",presentationMode:u.SECONDARY}),s("ez-view-stack",{class:"ez-flex ez-flex--column",ref:t=>this._viewStack=t,"data-element-id":"simple-crud"},s("stack-item",null,s("ez-grid",{dataUnit:this.dataUnit,onEzDoubleClick:()=>this.goToView(d.FORM),"no-header":!0},s("div",{slot:"footer"},s("slot",{name:"snkSimpleCrudFooter"})))),s("stack-item",null,s("ez-form",{dataUnit:this.dataUnit,config:this._config})))))}get _element(){return e(this)}static get watchers(){return{mode:["onModeChange"]}}};b.style=".sc-snk-simple-crud-h{display:flex;height:100%;width:100%}.simple-crud__container.sc-snk-simple-crud{display:grid;grid-template-rows:auto;row-gap:12px;height:100%;width:100%}.simple-crud__taskbar.sc-snk-simple-crud{z-index:var(--more-visible, 2);margin-bottom:var(--space--medium)}ez-grid.sc-snk-simple-crud{--ez-grid__container--shadow:none;min-height:300px}ez-form.sc-snk-simple-crud{min-height:300px}";export{b as snk_simple_crud}
|