@sankhyalabs/sankhyablocks 1.4.0-beta.8 → 1.4.0-beta.9
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/{constants-aebcc2f5.js → constants-9056ca9e.js} +15 -0
- package/dist/cjs/{index-188190ee.js → index-20e8b68a.js} +48 -2
- package/dist/cjs/loader.cjs.js +1 -1
- package/dist/cjs/sankhyablocks.cjs.js +1 -1
- package/dist/cjs/snk-application.cjs.entry.js +1 -1
- package/dist/cjs/snk-config-modal.cjs.entry.js +2 -2
- package/dist/cjs/snk-config-options.cjs.entry.js +139 -72
- package/dist/cjs/snk-configurator_6.cjs.entry.js +4 -4
- package/dist/cjs/snk-crud.cjs.entry.js +3 -3
- package/dist/cjs/snk-data-unit.cjs.entry.js +1 -1
- package/dist/cjs/snk-field-config_2.cjs.entry.js +2 -2
- package/dist/cjs/snk-filter-binary-select.cjs.entry.js +1 -1
- package/dist/cjs/snk-filter-detail.cjs.entry.js +1 -1
- package/dist/cjs/snk-filter-multi-select.cjs.entry.js +1 -1
- package/dist/cjs/snk-filter-number.cjs.entry.js +1 -1
- package/dist/cjs/snk-filter-period.cjs.entry.js +1 -1
- package/dist/cjs/snk-filter-personalized.cjs.entry.js +3 -2
- package/dist/cjs/snk-filter-search.cjs.entry.js +1 -1
- package/dist/cjs/snk-filter-text.cjs.entry.js +1 -1
- package/dist/cjs/snk-form-config.cjs.entry.js +2 -2
- package/dist/cjs/snk-form.cjs.entry.js +1 -1
- package/dist/cjs/snk-pesquisa.cjs.entry.js +1 -1
- package/dist/cjs/snk-tab-config.cjs.entry.js +2 -2
- package/dist/cjs/{taskbar-elements-4c2c6704.js → taskbar-elements-9a4b1e19.js} +1 -1
- package/dist/cjs/teste-pesquisa.cjs.entry.js +1 -1
- package/dist/collection/components/snk-filter-bar/filter-item/editors/snk-filter-personalized.js +2 -1
- package/dist/collection/components/snk-filter-bar/filter-modal/snk-filter-modal.js +2 -1
- package/dist/collection/components/snk-form/subcomponents/snk-config-options/snk-config-options.js +139 -72
- package/dist/collection/lib/utils/constants.js +14 -0
- package/dist/components/constants.js +15 -1
- package/dist/components/snk-config-options2.js +139 -72
- package/dist/components/snk-filter-modal2.js +2 -1
- package/dist/components/snk-filter-personalized.js +2 -1
- package/dist/components/snk-form-config2.js +1 -1
- package/dist/components/snk-tab-config2.js +1 -1
- package/dist/esm/{constants-c4e3341e.js → constants-c6039d3d.js} +15 -1
- package/dist/esm/{index-bafb2cef.js → index-e4121713.js} +48 -2
- package/dist/esm/loader.js +1 -1
- package/dist/esm/sankhyablocks.js +1 -1
- package/dist/esm/snk-application.entry.js +1 -1
- package/dist/esm/snk-config-modal.entry.js +2 -2
- package/dist/esm/snk-config-options.entry.js +140 -73
- package/dist/esm/snk-configurator_6.entry.js +5 -5
- package/dist/esm/snk-crud.entry.js +3 -3
- package/dist/esm/snk-data-unit.entry.js +1 -1
- package/dist/esm/snk-field-config_2.entry.js +2 -2
- package/dist/esm/snk-filter-binary-select.entry.js +1 -1
- package/dist/esm/snk-filter-detail.entry.js +1 -1
- package/dist/esm/snk-filter-multi-select.entry.js +1 -1
- package/dist/esm/snk-filter-number.entry.js +1 -1
- package/dist/esm/snk-filter-period.entry.js +1 -1
- package/dist/esm/snk-filter-personalized.entry.js +3 -2
- package/dist/esm/snk-filter-search.entry.js +1 -1
- package/dist/esm/snk-filter-text.entry.js +1 -1
- package/dist/esm/snk-form-config.entry.js +2 -2
- package/dist/esm/snk-form.entry.js +1 -1
- package/dist/esm/snk-pesquisa.entry.js +1 -1
- package/dist/esm/snk-tab-config.entry.js +2 -2
- package/dist/esm/{taskbar-elements-2035b1c7.js → taskbar-elements-e2ed0536.js} +1 -1
- package/dist/esm/teste-pesquisa.entry.js +1 -1
- package/dist/sankhyablocks/{p-8cd8977c.entry.js → p-029ae4e4.entry.js} +1 -1
- package/dist/sankhyablocks/p-12ad2a19.entry.js +1 -0
- package/dist/sankhyablocks/{p-ce789145.entry.js → p-1feabfc7.entry.js} +1 -1
- package/dist/sankhyablocks/p-2284c850.entry.js +1 -0
- package/dist/sankhyablocks/{p-1963b46f.entry.js → p-2b891c4a.entry.js} +1 -1
- package/dist/sankhyablocks/{p-d1ae76ec.entry.js → p-2dc76d79.entry.js} +1 -1
- package/dist/sankhyablocks/p-366aa0f5.entry.js +1 -0
- package/dist/sankhyablocks/{p-ae302037.entry.js → p-36d2d9cf.entry.js} +1 -1
- package/dist/sankhyablocks/{p-916068ff.entry.js → p-3a276f3d.entry.js} +1 -1
- package/dist/sankhyablocks/{p-ccdf59eb.entry.js → p-44ce5b90.entry.js} +1 -1
- package/dist/sankhyablocks/{p-6c61416a.entry.js → p-6988f4a6.entry.js} +1 -1
- package/dist/sankhyablocks/{p-af306302.entry.js → p-776ff4d1.entry.js} +1 -1
- package/dist/sankhyablocks/{p-cf81e313.entry.js → p-7b4a4a50.entry.js} +1 -1
- package/dist/sankhyablocks/p-9ba3df4c.js +2 -0
- package/dist/sankhyablocks/{p-cc85ba53.entry.js → p-9dc4426d.entry.js} +1 -1
- package/dist/sankhyablocks/{p-ee906940.entry.js → p-a17a4fca.entry.js} +1 -1
- package/dist/sankhyablocks/p-a5b26df2.js +1 -0
- package/dist/sankhyablocks/{p-f9084ecb.entry.js → p-cc4bef9f.entry.js} +1 -1
- package/dist/sankhyablocks/{p-31631fb6.entry.js → p-d1ac09c9.entry.js} +1 -1
- package/dist/sankhyablocks/{p-ad658f44.js → p-d9fbb26f.js} +1 -1
- package/dist/sankhyablocks/{p-857c4735.entry.js → p-deb1f523.entry.js} +1 -1
- package/dist/sankhyablocks/p-e871aa92.entry.js +1 -0
- package/dist/sankhyablocks/{p-04ad681a.entry.js → p-e9beab79.entry.js} +1 -1
- package/dist/sankhyablocks/sankhyablocks.esm.js +1 -1
- package/dist/types/components/snk-form/subcomponents/snk-config-options/snk-config-options.d.ts +17 -7
- package/dist/types/lib/utils/constants.d.ts +14 -0
- package/package.json +2 -2
- package/dist/sankhyablocks/p-26c503a6.entry.js +0 -1
- package/dist/sankhyablocks/p-434e0dcf.entry.js +0 -1
- package/dist/sankhyablocks/p-9f2c5fac.entry.js +0 -1
- package/dist/sankhyablocks/p-af11b0e7.js +0 -1
- package/dist/sankhyablocks/p-ddb03141.js +0 -2
- package/dist/sankhyablocks/p-fa75fba5.entry.js +0 -1
|
@@ -2,10 +2,10 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
const index = require('./index-
|
|
5
|
+
const index = require('./index-20e8b68a.js');
|
|
6
6
|
const draggable_bundle = require('./draggable.bundle-82a25c06.js');
|
|
7
7
|
const core = require('@sankhyalabs/core');
|
|
8
|
-
const constants = require('./constants-
|
|
8
|
+
const constants = require('./constants-9056ca9e.js');
|
|
9
9
|
require('./_commonjsHelpers-537d719a.js');
|
|
10
10
|
|
|
11
11
|
const snkTabConfigCss = "@keyframes activate{0%{clip-path:inset(calc(100% - 3px) 50% 0px 50%)}100%{clip-path:inset(calc(100% - 3px) 0px 0px 0px)}}.sc-snk-tab-config-h{--snk-tab-config--backward-icon:url('data:image/svg+xml;utf8,<svg xmlns=\"http://www.w3.org/2000/svg\" version=\"1.1\" height=\"16px\" width=\"10px\"><path d=\"M 9.7808475,13.860393 3.9204526,8.0000004 9.7808475,2.0624965 7.9301965,0.28895552 0.21915255,8.0000004 7.9301965,15.711044 Z\"/></svg>');--snk-tab-config--forward-icon:url('data:image/svg+xml;utf8,<svg xmlns=\"http://www.w3.org/2000/svg\" version=\"1.1\" height=\"16px\" width=\"10px\"><path d=\"M 0.21915251,13.860393 6.0795475,8.0000007 0.21915251,2.0624968 2.0698036,0.28895588 9.7808475,8.0000007 2.0698036,15.711044 Z\"/></svg>');display:flex;position:relative;width:100%;overflow:hidden}.tab-config__scroll.sc-snk-tab-config{display:flex;width:100%;scroll-behavior:smooth;overflow-x:auto;scrollbar-width:none}.tab-config__scroll--start-hidden.sc-snk-tab-config{-webkit-mask-image:linear-gradient(90deg, transparent 20px, #000 48px)}.tab-config__scroll--middle.sc-snk-tab-config{-webkit-mask-image:linear-gradient(90deg, transparent 20px, #000 48px, #000 calc(100% - 48px), transparent calc(100% - 20px))}.tab-config__scroll--end-hidden.sc-snk-tab-config{-webkit-mask-image:linear-gradient(90deg, #000 calc(100% - 48px), transparent calc(100% - 20px))}.tab-config__lower-bar.sc-snk-tab-config{position:absolute;left:0%;right:0%;top:91%;bottom:0%;border-radius:2px;background:var(--color--disable-primary);border:2px solid var(--color--disable-primary)}.tab-config__tab.sc-snk-tab-config{display:flex;border:none;background-color:unset;cursor:pointer;align-items:center;justify-content:center;min-width:fit-content;color:var(--text--primary, #626e82);font-family:var(--font-pattern, \"Sora, Algerian\");font-size:var(--title--small, 14px);padding:var(--space--small, 6px) var(--space--medium, 12px)}.tab-config__tab.sc-snk-tab-config:focus,.tab-config__forward-button.sc-snk-tab-config,.tab-config__backward-button.sc-snk-tab-config{outline:none}.tab-config__tab--is-active.sc-snk-tab-config{position:relative;color:var(--color--primary, #008561)}.tab-config__tab.sc-snk-tab-config:hover{color:var(--color--secondary, #383c45)}.tab-config__tab--is-active.sc-snk-tab-config:hover{color:var(--color--primary, #008561)}.tab-config__tab--is-active.sc-snk-tab-config::after{content:\"\";position:absolute;width:100%;height:100%;background-color:var(--color--primary, #008561);clip-path:inset(calc(100% - 3px) 0px 0px 0px);animation:activate 0.25s ease-in-out}.tab-config__tab--is-focused.sc-snk-tab-config{border:1px dashed var(--color--primary, #000000c5)}.tab-config__tab-label.sc-snk-tab-config{overflow:hidden;white-space:nowrap;text-overflow:ellipsis;text-shadow:var(--text-shadow);margin-bottom:var(--space--extra-small, 3px)}.tab-config__forward-button.sc-snk-tab-config,.tab-config__backward-button.sc-snk-tab-config{position:absolute;z-index:1;display:flex;box-sizing:border-box;padding:0px;top:0px;right:0px;width:16px;height:100%;border:none;background-color:unset;cursor:pointer;justify-content:center;align-items:center}.tab-config__new-button.sc-snk-tab-config{position:absolute;z-index:1;display:flex;box-sizing:border-box;padding:0px;top:0px;right:0px;height:100%;border:none;background-color:unset;cursor:pointer;justify-content:center;align-items:center}.tab-config__new-button.sc-snk-tab-config ez-icon.sc-snk-tab-config{--ez-icon--color:var(--color--secondary-700, #1C1D22)}.tab-config__backward-button.sc-snk-tab-config{left:0px;box-shadow:10px 10px 5px 5px white;background:white}.tab-config__forward-button.sc-snk-tab-config{box-shadow:10px 10px 5px 20px white;background:white}.tab-config__forward-button.sc-snk-tab-config::after,.tab-config__backward-button.sc-snk-tab-config::after{content:'';display:flex;background-color:var(--text--primary, #008561);width:10px;height:16px}.tab-config__forward-button.sc-snk-tab-config::after{-webkit-mask-image:var(--snk-tab-config--forward-icon);mask-image:var(--snk-tab-config--forward-icon)}.tab-config__backward-button.sc-snk-tab-config::after{-webkit-mask-image:var(--snk-tab-config--backward-icon);mask-image:var(--snk-tab-config--backward-icon)}.tab-config__forward-button.sc-snk-tab-config:hover::after,.tab-config__backward-button.sc-snk-tab-config:hover::after{background-color:var(--color--primary, #4e4e4e)}.tab-config__new-button.sc-snk-tab-config:hover ez-icon.sc-snk-tab-config{--ez-icon--color:var(--color--primary, #4e4e4e)}.tab-config__hidden.sc-snk-tab-config{display:none}.tab-config__scroll.sc-snk-tab-config::-webkit-scrollbar{display:none}.tab-config__left-icon.sc-snk-tab-config{padding-right:var(--space--small);--ez-icon--color:var(--text--disable)}.tab-config__left-icon--eye-off.sc-snk-tab-config{--ez-icon--color:var(--text--disable, #AFB6C0)}.tab-config__right-icon.sc-snk-tab-config{visibility:hidden;padding-left:var(--space--small)}.tab-config__tab.sc-snk-tab-config:hover .tab-config__right-icon.sc-snk-tab-config{visibility:visible}.tab-config__tab--is-active.sc-snk-tab-config .tab-config__right-icon.sc-snk-tab-config{visibility:visible;--ez-icon--color:var(--color--primary)}.tab-config__tab.sc-snk-tab-config:hover .tab-config__right-icon.sc-snk-tab-config{--ez-icon--color:var(--color--secondary, #383c45)}.tab-config__tab--is-active.sc-snk-tab-config:hover .tab-config__right-icon.sc-snk-tab-config{--ez-icon--color:var(--color--primary)}.tab-config__actions-button.sc-snk-tab-config{--ez-actions-button__btn-action--min-width:100px;visibility:hidden;opacity:0;transition:visibility 1s linear,opacity 0.3s linear}.tab-config__tab.sc-snk-tab-config:hover .tab-config__actions-button.sc-snk-tab-config{visibility:visible;opacity:1;transition:visibility 0.2s linear, opacity 0.10s linear}[data-draggable-element].sc-snk-tab-config{cursor:grab}.tab-config__tab-label-disabled.sc-snk-tab-config{color:var(--text--disable, #AFB6C0)}.tab-config__slot.sc-snk-tab-config{margin-left:var(--space--small, 6px)}";
|
package/dist/collection/components/snk-filter-bar/filter-item/editors/snk-filter-personalized.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { ApplicationContext, UserInterface } from '@sankhyalabs/core';
|
|
2
2
|
import { convertType } from '@sankhyalabs/core/dist/dataunit/metadata/DataType';
|
|
3
3
|
import { h, Host } from '@stencil/core';
|
|
4
|
+
import { CheckMode } from "@sankhyalabs/ezui/dist/collection/utils";
|
|
4
5
|
import FilterItemType from '../filter-item-type.enum';
|
|
5
6
|
export class SnkFilterPersonalized {
|
|
6
7
|
getValue(param, index) {
|
|
@@ -47,7 +48,7 @@ export class SnkFilterPersonalized {
|
|
|
47
48
|
return h("ez-search", { id: elemId, suppressEmptyOption: true, value: this.getValue(param, index), onEzChange: evt => this.setValue(index, evt.detail), label: param.label, optionLoader: ({ mode, argument }) => this.doSearch(mode, argument, param) });
|
|
48
49
|
case UserInterface.SWITCH:
|
|
49
50
|
case UserInterface.CHECKBOX:
|
|
50
|
-
const mode = UserInterface.SWITCH === param.type ?
|
|
51
|
+
const mode = UserInterface.SWITCH === param.type ? CheckMode.SWITCH : CheckMode.REGULAR;
|
|
51
52
|
return h("ez-check", { id: elemId, class: "ez-padding-bottom--medium", mode: mode, value: this.getValue(param, index), label: param.label, onEzChange: evt => this.setValue(index, evt.detail) });
|
|
52
53
|
case UserInterface.DECIMALNUMBER:
|
|
53
54
|
case UserInterface.INTEGERNUMBER:
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { h } from '@stencil/core';
|
|
2
2
|
import { ModalAction, ModalButtonStatus } from "@sankhyalabs/ezui/dist/collection/components/ez-modal-container";
|
|
3
3
|
import { ArrayUtils } from '@sankhyalabs/core';
|
|
4
|
+
import { CheckMode } from "@sankhyalabs/ezui/dist/collection/utils";
|
|
4
5
|
export class SnkFilterModal {
|
|
5
6
|
updateValue(id, value = undefined) {
|
|
6
7
|
this.items = this.items.map(item => {
|
|
@@ -22,7 +23,7 @@ export class SnkFilterModal {
|
|
|
22
23
|
}
|
|
23
24
|
buildItems(list) {
|
|
24
25
|
return list.map(item => {
|
|
25
|
-
return (h("button", { onClick: () => this.updateValue(item.id), class: "ez-padding--medium sc-snk-filter-bar snk-filter-bar__filter-modal-item ez-align--middle ez-margin-bottom--small" }, h("ez-check", { id: `checkbox_${item.id}`, tabIndex: "-1", class: "sc-snk-filter-bar snk-filter-bar__filter-modal-item__check", onEzChange: evt => this.updateValue(item.id, evt.detail), enabled: item.enabled, value: item.active, mode:
|
|
26
|
+
return (h("button", { onClick: () => this.updateValue(item.id), class: "ez-padding--medium sc-snk-filter-bar snk-filter-bar__filter-modal-item ez-align--middle ez-margin-bottom--small" }, h("ez-check", { id: `checkbox_${item.id}`, tabIndex: "-1", class: "sc-snk-filter-bar snk-filter-bar__filter-modal-item__check", onEzChange: evt => this.updateValue(item.id, evt.detail), enabled: item.enabled, value: item.active, mode: CheckMode.SWITCH }), h("div", { class: "ez-text ez-title--primary ez-text--medium ez-margin-left--medium sc-snk-filter-bar snk-filter-bar__filter-modal-item__label" }, item.label)));
|
|
26
27
|
});
|
|
27
28
|
}
|
|
28
29
|
itemKeyBoardSelect(event, item) {
|
package/dist/collection/components/snk-form/subcomponents/snk-config-options/snk-config-options.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { h, Host } from "@stencil/core";
|
|
2
|
-
import { ApplicationContext } from '@sankhyalabs/core';
|
|
3
|
-
import { formFieldBuilder } from "@sankhyalabs/ezui/dist/collection/utils";
|
|
2
|
+
import { ApplicationContext, UserInterface, ObjectUtils } from '@sankhyalabs/core';
|
|
4
3
|
import { DataType, getConvertedValue } from "@sankhyalabs/core/dist/dataunit/metadata/DataType";
|
|
5
|
-
import {
|
|
4
|
+
import { CheckMode } from "@sankhyalabs/ezui/dist/collection/utils";
|
|
5
|
+
import { DEFAULT_TYPE, TAGS_BY_TYPE, VARS_BY_TYPE } from "../../../../lib/utils/constants";
|
|
6
6
|
export class SnkConfigOptions {
|
|
7
7
|
constructor() {
|
|
8
8
|
/**
|
|
@@ -27,71 +27,20 @@ export class SnkConfigOptions {
|
|
|
27
27
|
enabledValueDefault() {
|
|
28
28
|
var _a, _b, _c;
|
|
29
29
|
const field = (_a = this.dataUnit) === null || _a === void 0 ? void 0 : _a.getField((_b = this.fieldConfig) === null || _b === void 0 ? void 0 : _b.name);
|
|
30
|
-
|
|
30
|
+
const allowDefault = (_c = field === null || field === void 0 ? void 0 : field.properties) === null || _c === void 0 ? void 0 : _c.allowDefault;
|
|
31
|
+
const hasVariableVar = VARS_BY_TYPE.UserInterface.hasOwnProperty(field === null || field === void 0 ? void 0 : field.userInterface);
|
|
32
|
+
if ((allowDefault == undefined || allowDefault === "true") && hasVariableVar) {
|
|
31
33
|
return true;
|
|
32
34
|
}
|
|
33
35
|
return false;
|
|
34
36
|
}
|
|
35
|
-
|
|
36
|
-
var _a;
|
|
37
|
-
if (field != undefined) {
|
|
38
|
-
return (_a = this.dataUnit) === null || _a === void 0 ? void 0 : _a.getField(field);
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
getMessage(key, params) {
|
|
42
|
-
return this._application.messagesBuilder.getMessage(key, params);
|
|
43
|
-
}
|
|
44
|
-
getDefaultType() {
|
|
45
|
-
var _a;
|
|
46
|
-
return (_a = this.fieldConfig.defaultValue.type) !== null && _a !== void 0 ? _a : DEFAULT_TYPE.fixed;
|
|
47
|
-
}
|
|
48
|
-
getValidatedValue(fieldValue) {
|
|
37
|
+
isAllowDefault() {
|
|
49
38
|
var _a, _b;
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
const field = (_a = this.dataUnit) === null || _a === void 0 ? void 0 : _a.getField((_b = this.fieldConfig) === null || _b === void 0 ? void 0 : _b.name);
|
|
54
|
-
const dataType = field === null || field === void 0 ? void 0 : field.dataType;
|
|
55
|
-
if (dataType == undefined) {
|
|
56
|
-
return;
|
|
57
|
-
}
|
|
58
|
-
const value = dataType !== DataType.OBJECT && dataType !== DataType.DATE
|
|
59
|
-
&& typeof fieldValue === "object" && "value" in fieldValue
|
|
60
|
-
? fieldValue.value
|
|
61
|
-
: fieldValue;
|
|
62
|
-
return dataType === DataType.OBJECT ? JSON.stringify(value) : value;
|
|
63
|
-
}
|
|
64
|
-
onChange(evt) {
|
|
65
|
-
this.fieldConfig.defaultValue.value = this.getValidatedValue(evt === null || evt === void 0 ? void 0 : evt.detail);
|
|
66
|
-
this.configOptionsChanged.emit(this.fieldConfig);
|
|
67
|
-
}
|
|
68
|
-
onSearch(searchArgument) {
|
|
69
|
-
if (this._application != undefined && this.fieldConfig != undefined) {
|
|
70
|
-
return this._application.executeSearch(searchArgument, this.fieldConfig.name, this.dataUnit);
|
|
39
|
+
const allowDefault = (_b = (_a = this._fieldProperties) === null || _a === void 0 ? void 0 : _a.properties) === null || _b === void 0 ? void 0 : _b.allowDefault;
|
|
40
|
+
if (allowDefault == undefined) {
|
|
41
|
+
return true;
|
|
71
42
|
}
|
|
72
|
-
|
|
73
|
-
loadDataField() {
|
|
74
|
-
this._element.querySelectorAll("[data-field-name]")
|
|
75
|
-
.forEach((field) => {
|
|
76
|
-
var _a, _b, _c, _d;
|
|
77
|
-
field.enabled = ((_b = (_a = this._fieldProperties) === null || _a === void 0 ? void 0 : _a.properties) === null || _b === void 0 ? void 0 : _b.allowDefault) === "true";
|
|
78
|
-
if (field.enabled) {
|
|
79
|
-
const value = this.fieldConfig.defaultValue.value;
|
|
80
|
-
if (value != undefined) {
|
|
81
|
-
const fieldName = field.dataset.fieldName;
|
|
82
|
-
const dataType = (_d = (_c = this.dataUnit) === null || _c === void 0 ? void 0 : _c.getField(fieldName)) === null || _d === void 0 ? void 0 : _d.dataType;
|
|
83
|
-
field.value = getConvertedValue(dataType, value);
|
|
84
|
-
}
|
|
85
|
-
field.addEventListener(CONFIG_EVENTS.fieldChanged, (evt) => {
|
|
86
|
-
return this.onChange(evt);
|
|
87
|
-
});
|
|
88
|
-
if (field.tagName === "EZ-SEARCH") {
|
|
89
|
-
field.optionLoader = (searchArgument) => {
|
|
90
|
-
return this.onSearch(searchArgument);
|
|
91
|
-
};
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
});
|
|
43
|
+
return allowDefault === "true";
|
|
95
44
|
}
|
|
96
45
|
loadDefaultValue() {
|
|
97
46
|
var _a;
|
|
@@ -113,6 +62,19 @@ export class SnkConfigOptions {
|
|
|
113
62
|
this._defaultType = this.fieldConfig.defaultValue.type;
|
|
114
63
|
}
|
|
115
64
|
}
|
|
65
|
+
getFieldProperties(field) {
|
|
66
|
+
var _a;
|
|
67
|
+
if (field != undefined) {
|
|
68
|
+
return (_a = this.dataUnit) === null || _a === void 0 ? void 0 : _a.getField(field);
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
getMessage(key, params) {
|
|
72
|
+
return this._application.messagesBuilder.getMessage(key, params);
|
|
73
|
+
}
|
|
74
|
+
getDefaultType() {
|
|
75
|
+
var _a;
|
|
76
|
+
return (_a = this.fieldConfig.defaultValue.type) !== null && _a !== void 0 ? _a : DEFAULT_TYPE.fixed;
|
|
77
|
+
}
|
|
116
78
|
getEnabledByProperty(property) {
|
|
117
79
|
const properties = this._fieldProperties;
|
|
118
80
|
if (properties != undefined && properties[property] === true) {
|
|
@@ -127,25 +89,130 @@ export class SnkConfigOptions {
|
|
|
127
89
|
}
|
|
128
90
|
return this.fieldConfig[property];
|
|
129
91
|
}
|
|
92
|
+
getValidatedValue(fieldValue) {
|
|
93
|
+
var _a, _b;
|
|
94
|
+
if (fieldValue == undefined) {
|
|
95
|
+
return;
|
|
96
|
+
}
|
|
97
|
+
const field = (_a = this.dataUnit) === null || _a === void 0 ? void 0 : _a.getField((_b = this.fieldConfig) === null || _b === void 0 ? void 0 : _b.name);
|
|
98
|
+
const dataType = field === null || field === void 0 ? void 0 : field.dataType;
|
|
99
|
+
if (dataType == undefined) {
|
|
100
|
+
return;
|
|
101
|
+
}
|
|
102
|
+
const value = (fieldValue === null || fieldValue === void 0 ? void 0 : fieldValue.waitmessage) != undefined ? undefined :
|
|
103
|
+
dataType !== DataType.OBJECT && dataType !== DataType.DATE
|
|
104
|
+
&& typeof fieldValue === "object"
|
|
105
|
+
? fieldValue.value
|
|
106
|
+
: fieldValue;
|
|
107
|
+
return dataType === DataType.OBJECT ? JSON.stringify(value) : value;
|
|
108
|
+
}
|
|
109
|
+
buildInputDefault({ value, enabled, label, name, required, userInterface }, properties = undefined, mode = undefined) {
|
|
110
|
+
let options;
|
|
111
|
+
let precision = 0;
|
|
112
|
+
let prettyPrecision = 0;
|
|
113
|
+
const TagName = userInterface == undefined || TAGS_BY_TYPE[userInterface] == undefined
|
|
114
|
+
? TAGS_BY_TYPE.DEFAULT
|
|
115
|
+
: TAGS_BY_TYPE[userInterface];
|
|
116
|
+
if (userInterface === UserInterface.OPTIONSELECTOR) {
|
|
117
|
+
const prop = properties === null || properties === void 0 ? void 0 : properties.options;
|
|
118
|
+
if (typeof prop === "string") {
|
|
119
|
+
const parsed = ObjectUtils.stringToObject(prop);
|
|
120
|
+
options = Object.keys(parsed).map(key => { return { value: key, label: parsed[key] }; });
|
|
121
|
+
}
|
|
122
|
+
else {
|
|
123
|
+
options = prop;
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
else if (userInterface === UserInterface.DECIMALNUMBER) {
|
|
127
|
+
precision = Number((properties === null || properties === void 0 ? void 0 : properties.precision) || 2);
|
|
128
|
+
prettyPrecision = Number((properties === null || properties === void 0 ? void 0 : properties.prettyPrecision) || precision);
|
|
129
|
+
}
|
|
130
|
+
return h(TagName, Object.assign({ value: value, enabled: enabled, label: label, "data-field-name": name, key: name, onEzChange: (evt) => this.onChange(evt === null || evt === void 0 ? void 0 : evt.detail) }, (this.getConditionalAttributes(userInterface, required, options, precision, prettyPrecision, mode))));
|
|
131
|
+
}
|
|
132
|
+
getConditionalAttributes(userInterface, required, options, precision, prettyPrecision, mode) {
|
|
133
|
+
switch (userInterface) {
|
|
134
|
+
case UserInterface.SEARCH:
|
|
135
|
+
return {
|
|
136
|
+
suppressEmptyOption: required,
|
|
137
|
+
optionLoader: (searchArgument) => this.onSearch(searchArgument)
|
|
138
|
+
};
|
|
139
|
+
case UserInterface.OPTIONSELECTOR:
|
|
140
|
+
return {
|
|
141
|
+
suppressEmptyOption: required,
|
|
142
|
+
options
|
|
143
|
+
};
|
|
144
|
+
case UserInterface.CHECKBOX:
|
|
145
|
+
case UserInterface.SWITCH:
|
|
146
|
+
return {
|
|
147
|
+
mode
|
|
148
|
+
};
|
|
149
|
+
case UserInterface.INTEGERNUMBER:
|
|
150
|
+
case UserInterface.DECIMALNUMBER:
|
|
151
|
+
return {
|
|
152
|
+
precision,
|
|
153
|
+
prettyPrecision,
|
|
154
|
+
onEzStartChange: (evt) => this.onChange(evt === null || evt === void 0 ? void 0 : evt.detail)
|
|
155
|
+
};
|
|
156
|
+
case UserInterface.DATE:
|
|
157
|
+
case UserInterface.DATETIME:
|
|
158
|
+
case UserInterface.TIME:
|
|
159
|
+
return {
|
|
160
|
+
onEzStartChange: (evt) => this.onChange(evt === null || evt === void 0 ? void 0 : evt.detail)
|
|
161
|
+
};
|
|
162
|
+
default:
|
|
163
|
+
return {};
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
onChange(fieldValue) {
|
|
167
|
+
this.fieldConfig.defaultValue.value = this.getValidatedValue(fieldValue);
|
|
168
|
+
this.configOptionsChanged.emit(this.fieldConfig);
|
|
169
|
+
}
|
|
170
|
+
onSearch(searchArgument) {
|
|
171
|
+
if (this._application != undefined && this.fieldConfig != undefined) {
|
|
172
|
+
return this._application.executeSearch(searchArgument, this.fieldConfig.name, this.dataUnit);
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
buildField(field) {
|
|
176
|
+
const { config, descriptor } = field;
|
|
177
|
+
const { name, label, readOnly, required, defaultValue } = config;
|
|
178
|
+
const { userInterface, properties } = descriptor;
|
|
179
|
+
const enabled = (properties === null || properties === void 0 ? void 0 : properties.allowDefault) != undefined ? properties.allowDefault === "true" : !readOnly;
|
|
180
|
+
let value;
|
|
181
|
+
if (enabled) {
|
|
182
|
+
value = defaultValue === null || defaultValue === void 0 ? void 0 : defaultValue.value;
|
|
183
|
+
if (value != undefined) {
|
|
184
|
+
value = getConvertedValue(descriptor === null || descriptor === void 0 ? void 0 : descriptor.dataType, value);
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
const configField = { value, enabled, label, name, required, userInterface };
|
|
188
|
+
switch (userInterface) {
|
|
189
|
+
case UserInterface.SWITCH:
|
|
190
|
+
return this.buildInputDefault(configField, undefined, CheckMode.SWITCH);
|
|
191
|
+
case UserInterface.CHECKBOX:
|
|
192
|
+
return this.buildInputDefault(configField, undefined, CheckMode.REGULAR);
|
|
193
|
+
case UserInterface.OPTIONSELECTOR:
|
|
194
|
+
case UserInterface.DECIMALNUMBER:
|
|
195
|
+
return this.buildInputDefault(configField, properties);
|
|
196
|
+
default:
|
|
197
|
+
return this.buildInputDefault(configField);
|
|
198
|
+
}
|
|
199
|
+
}
|
|
130
200
|
componentWillLoad() {
|
|
131
201
|
var _a;
|
|
132
|
-
this._application = ApplicationContext.getContextValue("__SNK__APPLICATION__");
|
|
133
202
|
this.loadDefaultValue();
|
|
203
|
+
this._application = ApplicationContext.getContextValue("__SNK__APPLICATION__");
|
|
134
204
|
this._fieldProperties = this.getFieldProperties((_a = this.fieldConfig) === null || _a === void 0 ? void 0 : _a.name);
|
|
135
205
|
}
|
|
136
|
-
componentDidRender() {
|
|
137
|
-
this.loadDataField();
|
|
138
|
-
}
|
|
139
206
|
render() {
|
|
140
|
-
var _a, _b
|
|
141
|
-
return (h(Host, null, h("div", { id: this.idConfig }, h("div", { class: "ez-row ez-padding--medium" }, h("div", { class: "ez-col ez-col--sd-12 ez-col--tb-4 ez-padding--small" }, h("ez-text-input", { label: this.getMessage("snkConfigOptions.label.nameField"), value: (_a = this.fieldConfig) === null || _a === void 0 ? void 0 : _a.label, onEzChange: (evt) => { this.fieldConfig.label = evt.detail; this.configOptionsChanged.emit(this.fieldConfig); } })), h("div", { class: "ez-col ez-col--sd-12 ez-col--tb-4 ez-padding--small" }, h("ez-combo-box", { label: this.getMessage("snkConfigOptions.label.typeValueDefault"), suppressEmptyOption: true, enabled:
|
|
142
|
-
h("ez-combo-box", { label: this.getMessage("snkConfigOptions.label.valueDefault"), enabled: this.
|
|
207
|
+
var _a, _b;
|
|
208
|
+
return (h(Host, null, h("div", { id: this.idConfig }, h("div", { class: "ez-row ez-padding--medium" }, h("div", { class: "ez-col ez-col--sd-12 ez-col--tb-4 ez-padding--small" }, h("ez-text-input", { label: this.getMessage("snkConfigOptions.label.nameField"), value: (_a = this.fieldConfig) === null || _a === void 0 ? void 0 : _a.label, onEzChange: (evt) => { this.fieldConfig.label = evt.detail; this.configOptionsChanged.emit(this.fieldConfig); } })), h("div", { class: "ez-col ez-col--sd-12 ez-col--tb-4 ez-padding--small" }, h("ez-combo-box", { label: this.getMessage("snkConfigOptions.label.typeValueDefault"), suppressEmptyOption: true, enabled: this.enabledValueDefault(), onEzChange: (evt) => { var _a; return this.onConfigDefault((_a = evt.detail) === null || _a === void 0 ? void 0 : _a.value); }, value: this.getDefaultType() }, h("option", { value: DEFAULT_TYPE.fixed }, this.getMessage("snkConfigOptions.options.valueFixed")), h("option", { value: DEFAULT_TYPE.variable }, this.getMessage("snkConfigOptions.options.variable")))), h("div", { class: "ez-col ez-col--sd-12 ez-col--tb-4 ez-padding--small" }, this._defaultType === DEFAULT_TYPE.variable ?
|
|
209
|
+
h("ez-combo-box", { label: this.getMessage("snkConfigOptions.label.valueDefault"), enabled: this.isAllowDefault(), onEzChange: (evt) => { var _a; this.fieldConfig.defaultValue.value = (_a = evt.detail) === null || _a === void 0 ? void 0 : _a.value; this.configOptionsChanged.emit(this.fieldConfig); }, value: this.fieldConfig.defaultValue.value, options: this.buildOptions() })
|
|
143
210
|
:
|
|
144
|
-
((
|
|
145
|
-
|
|
211
|
+
((_b = this._fieldProperties) === null || _b === void 0 ? void 0 : _b.userInterface) &&
|
|
212
|
+
this.buildField({
|
|
146
213
|
descriptor: this._fieldProperties,
|
|
147
214
|
config: this.fieldConfig
|
|
148
|
-
})
|
|
215
|
+
}))), h("div", { class: "ez-row ez-padding--medium config-options__switch-row" }, h("div", { class: "ez-col ez-col--sd-12 ez-col--tb-4 ez-padding--small" }, h("ez-check", { mode: CheckMode.SWITCH, label: this.getMessage("snkConfigOptions.label.clearDuplicate"), value: this.fieldConfig.cleanOnCopy, onEzChange: (evt) => { this.fieldConfig.cleanOnCopy = evt.detail; this.configOptionsChanged.emit(this.fieldConfig); } })), h("div", { class: "ez-col ez-col--sd-12 ez-col--tb-4 ez-padding--small" }, h("ez-check", { mode: CheckMode.SWITCH, label: this.getMessage("snkConfigOptions.label.requiredField"), enabled: this.getEnabledByProperty("required"), value: this.getValueByProperty("required"), onEzChange: (evt) => { this.fieldConfig.required = evt.detail; this.configOptionsChanged.emit(this.fieldConfig); } })), h("div", { class: "ez-col ez-col--sd-12 ez-col--tb-4 ez-padding--small" }, h("ez-check", { mode: CheckMode.SWITCH, label: this.getMessage("snkConfigOptions.label.protectedField"), enabled: this.getEnabledByProperty("readOnly"), value: this.getValueByProperty("readOnly"), onEzChange: (evt) => { this.fieldConfig.readOnly = evt.detail; this.configOptionsChanged.emit(this.fieldConfig); } }))))));
|
|
149
216
|
}
|
|
150
217
|
static get is() { return "snk-config-options"; }
|
|
151
218
|
static get encapsulation() { return "scoped"; }
|
|
@@ -56,3 +56,17 @@ export const TYPE_ACTIONS = {
|
|
|
56
56
|
export const TAB_NAMES = {
|
|
57
57
|
main: "__main"
|
|
58
58
|
};
|
|
59
|
+
export const TAGS_BY_TYPE = {
|
|
60
|
+
LONGTEXT: "ez-text-area",
|
|
61
|
+
FILE: "ez-upload",
|
|
62
|
+
DATE: "ez-date-input",
|
|
63
|
+
TIME: "ez-time",
|
|
64
|
+
DATETIME: "ez-date-time-input",
|
|
65
|
+
DEFAULT: "ez-text-input",
|
|
66
|
+
SWITCH: "ez-check",
|
|
67
|
+
CHECKBOX: "ez-check",
|
|
68
|
+
OPTIONSELECTOR: "ez-combo-box",
|
|
69
|
+
SEARCH: "ez-search",
|
|
70
|
+
INTEGERNUMBER: "ez-number-input",
|
|
71
|
+
DECIMALNUMBER: "ez-number-input"
|
|
72
|
+
};
|
|
@@ -56,5 +56,19 @@ const TYPE_ACTIONS = {
|
|
|
56
56
|
const TAB_NAMES = {
|
|
57
57
|
main: "__main"
|
|
58
58
|
};
|
|
59
|
+
const TAGS_BY_TYPE = {
|
|
60
|
+
LONGTEXT: "ez-text-area",
|
|
61
|
+
FILE: "ez-upload",
|
|
62
|
+
DATE: "ez-date-input",
|
|
63
|
+
TIME: "ez-time",
|
|
64
|
+
DATETIME: "ez-date-time-input",
|
|
65
|
+
DEFAULT: "ez-text-input",
|
|
66
|
+
SWITCH: "ez-check",
|
|
67
|
+
CHECKBOX: "ez-check",
|
|
68
|
+
OPTIONSELECTOR: "ez-combo-box",
|
|
69
|
+
SEARCH: "ez-search",
|
|
70
|
+
INTEGERNUMBER: "ez-number-input",
|
|
71
|
+
DECIMALNUMBER: "ez-number-input"
|
|
72
|
+
};
|
|
59
73
|
|
|
60
|
-
export { ACTION_CONFIG as A, CONFIG_EVENTS as C, DEFAULT_TYPE as D, KEY_EVENTS as K,
|
|
74
|
+
export { ACTION_CONFIG as A, CONFIG_EVENTS as C, DEFAULT_TYPE as D, KEY_EVENTS as K, TAGS_BY_TYPE as T, VIEW_MODE as V, VARS_BY_TYPE as a, TAB_NAMES as b, TYPE_ACTIONS as c };
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { proxyCustomElement, HTMLElement, createEvent, h, Host } from '@stencil/core/internal/client';
|
|
2
|
-
import { ApplicationContext } from '@sankhyalabs/core';
|
|
3
|
-
import { formFieldBuilder } from '@sankhyalabs/ezui/dist/collection/utils';
|
|
2
|
+
import { UserInterface, ObjectUtils, ApplicationContext } from '@sankhyalabs/core';
|
|
4
3
|
import { DataType, getConvertedValue } from '@sankhyalabs/core/dist/dataunit/metadata/DataType';
|
|
5
|
-
import {
|
|
4
|
+
import { CheckMode } from '@sankhyalabs/ezui/dist/collection/utils';
|
|
5
|
+
import { a as VARS_BY_TYPE, D as DEFAULT_TYPE, T as TAGS_BY_TYPE } from './constants.js';
|
|
6
6
|
|
|
7
7
|
const snkConfigOptionsCss = ".sc-snk-config-options-h{width:100%;border:2px solid var(--color--secondary-200);border-radius:15px}.config-options__switch-row.sc-snk-config-options{margin-top:-30px}";
|
|
8
8
|
|
|
@@ -33,71 +33,20 @@ const SnkConfigOptions = /*@__PURE__*/ proxyCustomElement(class extends HTMLElem
|
|
|
33
33
|
enabledValueDefault() {
|
|
34
34
|
var _a, _b, _c;
|
|
35
35
|
const field = (_a = this.dataUnit) === null || _a === void 0 ? void 0 : _a.getField((_b = this.fieldConfig) === null || _b === void 0 ? void 0 : _b.name);
|
|
36
|
-
|
|
36
|
+
const allowDefault = (_c = field === null || field === void 0 ? void 0 : field.properties) === null || _c === void 0 ? void 0 : _c.allowDefault;
|
|
37
|
+
const hasVariableVar = VARS_BY_TYPE.UserInterface.hasOwnProperty(field === null || field === void 0 ? void 0 : field.userInterface);
|
|
38
|
+
if ((allowDefault == undefined || allowDefault === "true") && hasVariableVar) {
|
|
37
39
|
return true;
|
|
38
40
|
}
|
|
39
41
|
return false;
|
|
40
42
|
}
|
|
41
|
-
|
|
42
|
-
var _a;
|
|
43
|
-
if (field != undefined) {
|
|
44
|
-
return (_a = this.dataUnit) === null || _a === void 0 ? void 0 : _a.getField(field);
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
getMessage(key, params) {
|
|
48
|
-
return this._application.messagesBuilder.getMessage(key, params);
|
|
49
|
-
}
|
|
50
|
-
getDefaultType() {
|
|
51
|
-
var _a;
|
|
52
|
-
return (_a = this.fieldConfig.defaultValue.type) !== null && _a !== void 0 ? _a : DEFAULT_TYPE.fixed;
|
|
53
|
-
}
|
|
54
|
-
getValidatedValue(fieldValue) {
|
|
43
|
+
isAllowDefault() {
|
|
55
44
|
var _a, _b;
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
const field = (_a = this.dataUnit) === null || _a === void 0 ? void 0 : _a.getField((_b = this.fieldConfig) === null || _b === void 0 ? void 0 : _b.name);
|
|
60
|
-
const dataType = field === null || field === void 0 ? void 0 : field.dataType;
|
|
61
|
-
if (dataType == undefined) {
|
|
62
|
-
return;
|
|
63
|
-
}
|
|
64
|
-
const value = dataType !== DataType.OBJECT && dataType !== DataType.DATE
|
|
65
|
-
&& typeof fieldValue === "object" && "value" in fieldValue
|
|
66
|
-
? fieldValue.value
|
|
67
|
-
: fieldValue;
|
|
68
|
-
return dataType === DataType.OBJECT ? JSON.stringify(value) : value;
|
|
69
|
-
}
|
|
70
|
-
onChange(evt) {
|
|
71
|
-
this.fieldConfig.defaultValue.value = this.getValidatedValue(evt === null || evt === void 0 ? void 0 : evt.detail);
|
|
72
|
-
this.configOptionsChanged.emit(this.fieldConfig);
|
|
73
|
-
}
|
|
74
|
-
onSearch(searchArgument) {
|
|
75
|
-
if (this._application != undefined && this.fieldConfig != undefined) {
|
|
76
|
-
return this._application.executeSearch(searchArgument, this.fieldConfig.name, this.dataUnit);
|
|
45
|
+
const allowDefault = (_b = (_a = this._fieldProperties) === null || _a === void 0 ? void 0 : _a.properties) === null || _b === void 0 ? void 0 : _b.allowDefault;
|
|
46
|
+
if (allowDefault == undefined) {
|
|
47
|
+
return true;
|
|
77
48
|
}
|
|
78
|
-
|
|
79
|
-
loadDataField() {
|
|
80
|
-
this._element.querySelectorAll("[data-field-name]")
|
|
81
|
-
.forEach((field) => {
|
|
82
|
-
var _a, _b, _c, _d;
|
|
83
|
-
field.enabled = ((_b = (_a = this._fieldProperties) === null || _a === void 0 ? void 0 : _a.properties) === null || _b === void 0 ? void 0 : _b.allowDefault) === "true";
|
|
84
|
-
if (field.enabled) {
|
|
85
|
-
const value = this.fieldConfig.defaultValue.value;
|
|
86
|
-
if (value != undefined) {
|
|
87
|
-
const fieldName = field.dataset.fieldName;
|
|
88
|
-
const dataType = (_d = (_c = this.dataUnit) === null || _c === void 0 ? void 0 : _c.getField(fieldName)) === null || _d === void 0 ? void 0 : _d.dataType;
|
|
89
|
-
field.value = getConvertedValue(dataType, value);
|
|
90
|
-
}
|
|
91
|
-
field.addEventListener(CONFIG_EVENTS.fieldChanged, (evt) => {
|
|
92
|
-
return this.onChange(evt);
|
|
93
|
-
});
|
|
94
|
-
if (field.tagName === "EZ-SEARCH") {
|
|
95
|
-
field.optionLoader = (searchArgument) => {
|
|
96
|
-
return this.onSearch(searchArgument);
|
|
97
|
-
};
|
|
98
|
-
}
|
|
99
|
-
}
|
|
100
|
-
});
|
|
49
|
+
return allowDefault === "true";
|
|
101
50
|
}
|
|
102
51
|
loadDefaultValue() {
|
|
103
52
|
var _a;
|
|
@@ -119,6 +68,19 @@ const SnkConfigOptions = /*@__PURE__*/ proxyCustomElement(class extends HTMLElem
|
|
|
119
68
|
this._defaultType = this.fieldConfig.defaultValue.type;
|
|
120
69
|
}
|
|
121
70
|
}
|
|
71
|
+
getFieldProperties(field) {
|
|
72
|
+
var _a;
|
|
73
|
+
if (field != undefined) {
|
|
74
|
+
return (_a = this.dataUnit) === null || _a === void 0 ? void 0 : _a.getField(field);
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
getMessage(key, params) {
|
|
78
|
+
return this._application.messagesBuilder.getMessage(key, params);
|
|
79
|
+
}
|
|
80
|
+
getDefaultType() {
|
|
81
|
+
var _a;
|
|
82
|
+
return (_a = this.fieldConfig.defaultValue.type) !== null && _a !== void 0 ? _a : DEFAULT_TYPE.fixed;
|
|
83
|
+
}
|
|
122
84
|
getEnabledByProperty(property) {
|
|
123
85
|
const properties = this._fieldProperties;
|
|
124
86
|
if (properties != undefined && properties[property] === true) {
|
|
@@ -133,25 +95,130 @@ const SnkConfigOptions = /*@__PURE__*/ proxyCustomElement(class extends HTMLElem
|
|
|
133
95
|
}
|
|
134
96
|
return this.fieldConfig[property];
|
|
135
97
|
}
|
|
98
|
+
getValidatedValue(fieldValue) {
|
|
99
|
+
var _a, _b;
|
|
100
|
+
if (fieldValue == undefined) {
|
|
101
|
+
return;
|
|
102
|
+
}
|
|
103
|
+
const field = (_a = this.dataUnit) === null || _a === void 0 ? void 0 : _a.getField((_b = this.fieldConfig) === null || _b === void 0 ? void 0 : _b.name);
|
|
104
|
+
const dataType = field === null || field === void 0 ? void 0 : field.dataType;
|
|
105
|
+
if (dataType == undefined) {
|
|
106
|
+
return;
|
|
107
|
+
}
|
|
108
|
+
const value = (fieldValue === null || fieldValue === void 0 ? void 0 : fieldValue.waitmessage) != undefined ? undefined :
|
|
109
|
+
dataType !== DataType.OBJECT && dataType !== DataType.DATE
|
|
110
|
+
&& typeof fieldValue === "object"
|
|
111
|
+
? fieldValue.value
|
|
112
|
+
: fieldValue;
|
|
113
|
+
return dataType === DataType.OBJECT ? JSON.stringify(value) : value;
|
|
114
|
+
}
|
|
115
|
+
buildInputDefault({ value, enabled, label, name, required, userInterface }, properties = undefined, mode = undefined) {
|
|
116
|
+
let options;
|
|
117
|
+
let precision = 0;
|
|
118
|
+
let prettyPrecision = 0;
|
|
119
|
+
const TagName = userInterface == undefined || TAGS_BY_TYPE[userInterface] == undefined
|
|
120
|
+
? TAGS_BY_TYPE.DEFAULT
|
|
121
|
+
: TAGS_BY_TYPE[userInterface];
|
|
122
|
+
if (userInterface === UserInterface.OPTIONSELECTOR) {
|
|
123
|
+
const prop = properties === null || properties === void 0 ? void 0 : properties.options;
|
|
124
|
+
if (typeof prop === "string") {
|
|
125
|
+
const parsed = ObjectUtils.stringToObject(prop);
|
|
126
|
+
options = Object.keys(parsed).map(key => { return { value: key, label: parsed[key] }; });
|
|
127
|
+
}
|
|
128
|
+
else {
|
|
129
|
+
options = prop;
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
else if (userInterface === UserInterface.DECIMALNUMBER) {
|
|
133
|
+
precision = Number((properties === null || properties === void 0 ? void 0 : properties.precision) || 2);
|
|
134
|
+
prettyPrecision = Number((properties === null || properties === void 0 ? void 0 : properties.prettyPrecision) || precision);
|
|
135
|
+
}
|
|
136
|
+
return h(TagName, Object.assign({ value: value, enabled: enabled, label: label, "data-field-name": name, key: name, onEzChange: (evt) => this.onChange(evt === null || evt === void 0 ? void 0 : evt.detail) }, (this.getConditionalAttributes(userInterface, required, options, precision, prettyPrecision, mode))));
|
|
137
|
+
}
|
|
138
|
+
getConditionalAttributes(userInterface, required, options, precision, prettyPrecision, mode) {
|
|
139
|
+
switch (userInterface) {
|
|
140
|
+
case UserInterface.SEARCH:
|
|
141
|
+
return {
|
|
142
|
+
suppressEmptyOption: required,
|
|
143
|
+
optionLoader: (searchArgument) => this.onSearch(searchArgument)
|
|
144
|
+
};
|
|
145
|
+
case UserInterface.OPTIONSELECTOR:
|
|
146
|
+
return {
|
|
147
|
+
suppressEmptyOption: required,
|
|
148
|
+
options
|
|
149
|
+
};
|
|
150
|
+
case UserInterface.CHECKBOX:
|
|
151
|
+
case UserInterface.SWITCH:
|
|
152
|
+
return {
|
|
153
|
+
mode
|
|
154
|
+
};
|
|
155
|
+
case UserInterface.INTEGERNUMBER:
|
|
156
|
+
case UserInterface.DECIMALNUMBER:
|
|
157
|
+
return {
|
|
158
|
+
precision,
|
|
159
|
+
prettyPrecision,
|
|
160
|
+
onEzStartChange: (evt) => this.onChange(evt === null || evt === void 0 ? void 0 : evt.detail)
|
|
161
|
+
};
|
|
162
|
+
case UserInterface.DATE:
|
|
163
|
+
case UserInterface.DATETIME:
|
|
164
|
+
case UserInterface.TIME:
|
|
165
|
+
return {
|
|
166
|
+
onEzStartChange: (evt) => this.onChange(evt === null || evt === void 0 ? void 0 : evt.detail)
|
|
167
|
+
};
|
|
168
|
+
default:
|
|
169
|
+
return {};
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
onChange(fieldValue) {
|
|
173
|
+
this.fieldConfig.defaultValue.value = this.getValidatedValue(fieldValue);
|
|
174
|
+
this.configOptionsChanged.emit(this.fieldConfig);
|
|
175
|
+
}
|
|
176
|
+
onSearch(searchArgument) {
|
|
177
|
+
if (this._application != undefined && this.fieldConfig != undefined) {
|
|
178
|
+
return this._application.executeSearch(searchArgument, this.fieldConfig.name, this.dataUnit);
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
buildField(field) {
|
|
182
|
+
const { config, descriptor } = field;
|
|
183
|
+
const { name, label, readOnly, required, defaultValue } = config;
|
|
184
|
+
const { userInterface, properties } = descriptor;
|
|
185
|
+
const enabled = (properties === null || properties === void 0 ? void 0 : properties.allowDefault) != undefined ? properties.allowDefault === "true" : !readOnly;
|
|
186
|
+
let value;
|
|
187
|
+
if (enabled) {
|
|
188
|
+
value = defaultValue === null || defaultValue === void 0 ? void 0 : defaultValue.value;
|
|
189
|
+
if (value != undefined) {
|
|
190
|
+
value = getConvertedValue(descriptor === null || descriptor === void 0 ? void 0 : descriptor.dataType, value);
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
const configField = { value, enabled, label, name, required, userInterface };
|
|
194
|
+
switch (userInterface) {
|
|
195
|
+
case UserInterface.SWITCH:
|
|
196
|
+
return this.buildInputDefault(configField, undefined, CheckMode.SWITCH);
|
|
197
|
+
case UserInterface.CHECKBOX:
|
|
198
|
+
return this.buildInputDefault(configField, undefined, CheckMode.REGULAR);
|
|
199
|
+
case UserInterface.OPTIONSELECTOR:
|
|
200
|
+
case UserInterface.DECIMALNUMBER:
|
|
201
|
+
return this.buildInputDefault(configField, properties);
|
|
202
|
+
default:
|
|
203
|
+
return this.buildInputDefault(configField);
|
|
204
|
+
}
|
|
205
|
+
}
|
|
136
206
|
componentWillLoad() {
|
|
137
207
|
var _a;
|
|
138
|
-
this._application = ApplicationContext.getContextValue("__SNK__APPLICATION__");
|
|
139
208
|
this.loadDefaultValue();
|
|
209
|
+
this._application = ApplicationContext.getContextValue("__SNK__APPLICATION__");
|
|
140
210
|
this._fieldProperties = this.getFieldProperties((_a = this.fieldConfig) === null || _a === void 0 ? void 0 : _a.name);
|
|
141
211
|
}
|
|
142
|
-
componentDidRender() {
|
|
143
|
-
this.loadDataField();
|
|
144
|
-
}
|
|
145
212
|
render() {
|
|
146
|
-
var _a, _b
|
|
147
|
-
return (h(Host, null, h("div", { id: this.idConfig }, h("div", { class: "ez-row ez-padding--medium" }, h("div", { class: "ez-col ez-col--sd-12 ez-col--tb-4 ez-padding--small" }, h("ez-text-input", { label: this.getMessage("snkConfigOptions.label.nameField"), value: (_a = this.fieldConfig) === null || _a === void 0 ? void 0 : _a.label, onEzChange: (evt) => { this.fieldConfig.label = evt.detail; this.configOptionsChanged.emit(this.fieldConfig); } })), h("div", { class: "ez-col ez-col--sd-12 ez-col--tb-4 ez-padding--small" }, h("ez-combo-box", { label: this.getMessage("snkConfigOptions.label.typeValueDefault"), suppressEmptyOption: true, enabled:
|
|
148
|
-
h("ez-combo-box", { label: this.getMessage("snkConfigOptions.label.valueDefault"), enabled: this.
|
|
213
|
+
var _a, _b;
|
|
214
|
+
return (h(Host, null, h("div", { id: this.idConfig }, h("div", { class: "ez-row ez-padding--medium" }, h("div", { class: "ez-col ez-col--sd-12 ez-col--tb-4 ez-padding--small" }, h("ez-text-input", { label: this.getMessage("snkConfigOptions.label.nameField"), value: (_a = this.fieldConfig) === null || _a === void 0 ? void 0 : _a.label, onEzChange: (evt) => { this.fieldConfig.label = evt.detail; this.configOptionsChanged.emit(this.fieldConfig); } })), h("div", { class: "ez-col ez-col--sd-12 ez-col--tb-4 ez-padding--small" }, h("ez-combo-box", { label: this.getMessage("snkConfigOptions.label.typeValueDefault"), suppressEmptyOption: true, enabled: this.enabledValueDefault(), onEzChange: (evt) => { var _a; return this.onConfigDefault((_a = evt.detail) === null || _a === void 0 ? void 0 : _a.value); }, value: this.getDefaultType() }, h("option", { value: DEFAULT_TYPE.fixed }, this.getMessage("snkConfigOptions.options.valueFixed")), h("option", { value: DEFAULT_TYPE.variable }, this.getMessage("snkConfigOptions.options.variable")))), h("div", { class: "ez-col ez-col--sd-12 ez-col--tb-4 ez-padding--small" }, this._defaultType === DEFAULT_TYPE.variable ?
|
|
215
|
+
h("ez-combo-box", { label: this.getMessage("snkConfigOptions.label.valueDefault"), enabled: this.isAllowDefault(), onEzChange: (evt) => { var _a; this.fieldConfig.defaultValue.value = (_a = evt.detail) === null || _a === void 0 ? void 0 : _a.value; this.configOptionsChanged.emit(this.fieldConfig); }, value: this.fieldConfig.defaultValue.value, options: this.buildOptions() })
|
|
149
216
|
:
|
|
150
|
-
((
|
|
151
|
-
|
|
217
|
+
((_b = this._fieldProperties) === null || _b === void 0 ? void 0 : _b.userInterface) &&
|
|
218
|
+
this.buildField({
|
|
152
219
|
descriptor: this._fieldProperties,
|
|
153
220
|
config: this.fieldConfig
|
|
154
|
-
})
|
|
221
|
+
}))), h("div", { class: "ez-row ez-padding--medium config-options__switch-row" }, h("div", { class: "ez-col ez-col--sd-12 ez-col--tb-4 ez-padding--small" }, h("ez-check", { mode: CheckMode.SWITCH, label: this.getMessage("snkConfigOptions.label.clearDuplicate"), value: this.fieldConfig.cleanOnCopy, onEzChange: (evt) => { this.fieldConfig.cleanOnCopy = evt.detail; this.configOptionsChanged.emit(this.fieldConfig); } })), h("div", { class: "ez-col ez-col--sd-12 ez-col--tb-4 ez-padding--small" }, h("ez-check", { mode: CheckMode.SWITCH, label: this.getMessage("snkConfigOptions.label.requiredField"), enabled: this.getEnabledByProperty("required"), value: this.getValueByProperty("required"), onEzChange: (evt) => { this.fieldConfig.required = evt.detail; this.configOptionsChanged.emit(this.fieldConfig); } })), h("div", { class: "ez-col ez-col--sd-12 ez-col--tb-4 ez-padding--small" }, h("ez-check", { mode: CheckMode.SWITCH, label: this.getMessage("snkConfigOptions.label.protectedField"), enabled: this.getEnabledByProperty("readOnly"), value: this.getValueByProperty("readOnly"), onEzChange: (evt) => { this.fieldConfig.readOnly = evt.detail; this.configOptionsChanged.emit(this.fieldConfig); } }))))));
|
|
155
222
|
}
|
|
156
223
|
get _element() { return this; }
|
|
157
224
|
static get style() { return snkConfigOptionsCss; }
|