@iobroker/json-config 8.4.14 → 8.5.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/README.md +7 -1
- package/build/JsonConfig.d.ts +3 -3
- package/build/JsonConfig.js +11 -7
- package/build/JsonConfig.js.map +1 -1
- package/build/JsonConfigComponent/ChipInput.js +3 -3
- package/build/JsonConfigComponent/ChipInput.js.map +1 -1
- package/build/JsonConfigComponent/ConfigAccordion.d.ts +1 -1
- package/build/JsonConfigComponent/ConfigAccordion.js +28 -18
- package/build/JsonConfigComponent/ConfigAccordion.js.map +1 -1
- package/build/JsonConfigComponent/ConfigAlive.js +8 -4
- package/build/JsonConfigComponent/ConfigAlive.js.map +1 -1
- package/build/JsonConfigComponent/ConfigAutocomplete.d.ts +2 -2
- package/build/JsonConfigComponent/ConfigAutocomplete.js +6 -6
- package/build/JsonConfigComponent/ConfigAutocomplete.js.map +1 -1
- package/build/JsonConfigComponent/ConfigAutocompleteSendTo.js +5 -5
- package/build/JsonConfigComponent/ConfigAutocompleteSendTo.js.map +1 -1
- package/build/JsonConfigComponent/ConfigCRON.d.ts +1 -0
- package/build/JsonConfigComponent/ConfigCRON.js.map +1 -1
- package/build/JsonConfigComponent/ConfigCertCollection.d.ts +1 -1
- package/build/JsonConfigComponent/ConfigCertCollection.js.map +1 -1
- package/build/JsonConfigComponent/ConfigCertificateSelect.d.ts +1 -0
- package/build/JsonConfigComponent/ConfigCertificateSelect.js.map +1 -1
- package/build/JsonConfigComponent/ConfigCertificates.d.ts +1 -1
- package/build/JsonConfigComponent/ConfigCertificates.js +1 -1
- package/build/JsonConfigComponent/ConfigCertificates.js.map +1 -1
- package/build/JsonConfigComponent/ConfigCheckDocker.js +4 -2
- package/build/JsonConfigComponent/ConfigCheckDocker.js.map +1 -1
- package/build/JsonConfigComponent/ConfigCheckLicense.d.ts +1 -1
- package/build/JsonConfigComponent/ConfigCheckLicense.js +14 -11
- package/build/JsonConfigComponent/ConfigCheckLicense.js.map +1 -1
- package/build/JsonConfigComponent/ConfigCheckbox.js +12 -10
- package/build/JsonConfigComponent/ConfigCheckbox.js.map +1 -1
- package/build/JsonConfigComponent/ConfigChip.js +22 -18
- package/build/JsonConfigComponent/ConfigChip.js.map +1 -1
- package/build/JsonConfigComponent/ConfigColor.js +5 -8
- package/build/JsonConfigComponent/ConfigColor.js.map +1 -1
- package/build/JsonConfigComponent/ConfigCoordinates.js +1 -1
- package/build/JsonConfigComponent/ConfigCoordinates.js.map +1 -1
- package/build/JsonConfigComponent/ConfigCredentialSelect.d.ts +2 -0
- package/build/JsonConfigComponent/ConfigCredentialSelect.js +85 -9
- package/build/JsonConfigComponent/ConfigCredentialSelect.js.map +1 -1
- package/build/JsonConfigComponent/ConfigCustom.d.ts +1 -1
- package/build/JsonConfigComponent/ConfigCustom.js +1 -1
- package/build/JsonConfigComponent/ConfigCustom.js.map +1 -1
- package/build/JsonConfigComponent/ConfigDatePicker.js +4 -2
- package/build/JsonConfigComponent/ConfigDatePicker.js.map +1 -1
- package/build/JsonConfigComponent/ConfigFile.js +4 -2
- package/build/JsonConfigComponent/ConfigFile.js.map +1 -1
- package/build/JsonConfigComponent/ConfigFileSelector.d.ts +3 -2
- package/build/JsonConfigComponent/ConfigFileSelector.js +10 -8
- package/build/JsonConfigComponent/ConfigFileSelector.js.map +1 -1
- package/build/JsonConfigComponent/ConfigFunc.js +1 -1
- package/build/JsonConfigComponent/ConfigFunc.js.map +1 -1
- package/build/JsonConfigComponent/ConfigGeneric.d.ts +16 -13
- package/build/JsonConfigComponent/ConfigGeneric.js +68 -46
- package/build/JsonConfigComponent/ConfigGeneric.js.map +1 -1
- package/build/JsonConfigComponent/ConfigIFrameSendTo.d.ts +1 -1
- package/build/JsonConfigComponent/ConfigIFrameSendTo.js +1 -3
- package/build/JsonConfigComponent/ConfigIFrameSendTo.js.map +1 -1
- package/build/JsonConfigComponent/ConfigIP.js +4 -1
- package/build/JsonConfigComponent/ConfigIP.js.map +1 -1
- package/build/JsonConfigComponent/ConfigImageSendTo.d.ts +1 -1
- package/build/JsonConfigComponent/ConfigImageSendTo.js +1 -3
- package/build/JsonConfigComponent/ConfigImageSendTo.js.map +1 -1
- package/build/JsonConfigComponent/ConfigImageUpload.js +26 -22
- package/build/JsonConfigComponent/ConfigImageUpload.js.map +1 -1
- package/build/JsonConfigComponent/ConfigInstanceSelect.d.ts +1 -1
- package/build/JsonConfigComponent/ConfigInstanceSelect.js +5 -5
- package/build/JsonConfigComponent/ConfigInstanceSelect.js.map +1 -1
- package/build/JsonConfigComponent/ConfigInterface.js +16 -12
- package/build/JsonConfigComponent/ConfigInterface.js.map +1 -1
- package/build/JsonConfigComponent/ConfigJsonEditor.js +1 -1
- package/build/JsonConfigComponent/ConfigJsonEditor.js.map +1 -1
- package/build/JsonConfigComponent/ConfigLanguage.js +7 -9
- package/build/JsonConfigComponent/ConfigLanguage.js.map +1 -1
- package/build/JsonConfigComponent/ConfigLicense.js +5 -3
- package/build/JsonConfigComponent/ConfigLicense.js.map +1 -1
- package/build/JsonConfigComponent/ConfigNumber.js +7 -5
- package/build/JsonConfigComponent/ConfigNumber.js.map +1 -1
- package/build/JsonConfigComponent/ConfigOAuth2.js +2 -2
- package/build/JsonConfigComponent/ConfigOAuth2.js.map +1 -1
- package/build/JsonConfigComponent/ConfigObjectId.d.ts +2 -2
- package/build/JsonConfigComponent/ConfigObjectId.js +12 -10
- package/build/JsonConfigComponent/ConfigObjectId.js.map +1 -1
- package/build/JsonConfigComponent/ConfigPanel.d.ts +1 -1
- package/build/JsonConfigComponent/ConfigPanel.js +5 -4
- package/build/JsonConfigComponent/ConfigPanel.js.map +1 -1
- package/build/JsonConfigComponent/ConfigPassword.d.ts +1 -1
- package/build/JsonConfigComponent/ConfigPassword.js.map +1 -1
- package/build/JsonConfigComponent/ConfigQrCodeSendTo.js +1 -3
- package/build/JsonConfigComponent/ConfigQrCodeSendTo.js.map +1 -1
- package/build/JsonConfigComponent/ConfigRoom.d.ts +1 -1
- package/build/JsonConfigComponent/ConfigRoom.js.map +1 -1
- package/build/JsonConfigComponent/ConfigSelect.d.ts +1 -1
- package/build/JsonConfigComponent/ConfigSelect.js +4 -4
- package/build/JsonConfigComponent/ConfigSelect.js.map +1 -1
- package/build/JsonConfigComponent/ConfigSelectSendTo.d.ts +1 -1
- package/build/JsonConfigComponent/ConfigSelectSendTo.js +14 -16
- package/build/JsonConfigComponent/ConfigSelectSendTo.js.map +1 -1
- package/build/JsonConfigComponent/ConfigSendto.d.ts +1 -1
- package/build/JsonConfigComponent/ConfigSendto.js +6 -5
- package/build/JsonConfigComponent/ConfigSendto.js.map +1 -1
- package/build/JsonConfigComponent/ConfigSetState.js +4 -1
- package/build/JsonConfigComponent/ConfigSetState.js.map +1 -1
- package/build/JsonConfigComponent/ConfigState.d.ts +1 -1
- package/build/JsonConfigComponent/ConfigState.js +33 -22
- package/build/JsonConfigComponent/ConfigState.js.map +1 -1
- package/build/JsonConfigComponent/ConfigStaticImage.js +1 -1
- package/build/JsonConfigComponent/ConfigStaticImage.js.map +1 -1
- package/build/JsonConfigComponent/ConfigStaticInfo.js +2 -2
- package/build/JsonConfigComponent/ConfigStaticInfo.js.map +1 -1
- package/build/JsonConfigComponent/ConfigStaticText.js +2 -2
- package/build/JsonConfigComponent/ConfigStaticText.js.map +1 -1
- package/build/JsonConfigComponent/ConfigTable.d.ts +4 -4
- package/build/JsonConfigComponent/ConfigTable.js +80 -75
- package/build/JsonConfigComponent/ConfigTable.js.map +1 -1
- package/build/JsonConfigComponent/ConfigTabs.d.ts +7 -7
- package/build/JsonConfigComponent/ConfigTabs.js +61 -57
- package/build/JsonConfigComponent/ConfigTabs.js.map +1 -1
- package/build/JsonConfigComponent/ConfigText.js +6 -6
- package/build/JsonConfigComponent/ConfigText.js.map +1 -1
- package/build/JsonConfigComponent/ConfigTextSendTo.d.ts +1 -1
- package/build/JsonConfigComponent/ConfigTextSendTo.js +1 -1
- package/build/JsonConfigComponent/ConfigTextSendTo.js.map +1 -1
- package/build/JsonConfigComponent/ConfigTimePicker.js +2 -5
- package/build/JsonConfigComponent/ConfigTimePicker.js.map +1 -1
- package/build/JsonConfigComponent/ConfigUUID.js +1 -1
- package/build/JsonConfigComponent/ConfigUUID.js.map +1 -1
- package/build/JsonConfigComponent/ConfigUser.js +2 -2
- package/build/JsonConfigComponent/ConfigUser.js.map +1 -1
- package/build/JsonConfigComponent/ConfigYamlEditor.js +2 -2
- package/build/JsonConfigComponent/ConfigYamlEditor.js.map +1 -1
- package/build/JsonConfigComponent/Icons.d.ts +1 -1
- package/build/JsonConfigComponent/Icons.js.map +1 -1
- package/build/JsonConfigComponent/index.d.ts +4 -4
- package/build/JsonConfigComponent/index.js +21 -16
- package/build/JsonConfigComponent/index.js.map +1 -1
- package/build/JsonConfigComponent/wrapper/Components/CustomModal.d.ts +2 -3
- package/build/JsonConfigComponent/wrapper/Components/CustomModal.js +2 -7
- package/build/JsonConfigComponent/wrapper/Components/CustomModal.js.map +1 -1
- package/package.json +3 -2
|
@@ -33,7 +33,7 @@ export interface ConfigGenericProps {
|
|
|
33
33
|
className?: string;
|
|
34
34
|
expertMode?: boolean;
|
|
35
35
|
commandRunning?: boolean;
|
|
36
|
-
common
|
|
36
|
+
common?: Record<string, any>;
|
|
37
37
|
custom?: boolean;
|
|
38
38
|
customObj?: Record<string, any>;
|
|
39
39
|
data: Record<string, any>;
|
|
@@ -41,8 +41,8 @@ export interface ConfigGenericProps {
|
|
|
41
41
|
globalData?: Record<string, any>;
|
|
42
42
|
index?: number;
|
|
43
43
|
isParentTab?: boolean;
|
|
44
|
-
onChange: (attrOrData: string | Record<string, any
|
|
45
|
-
onError: (attr: string, error?: string) => void;
|
|
44
|
+
onChange: (attrOrData: string | Record<string, any> | undefined, val?: any, cb?: () => void, saveConfig?: boolean) => void;
|
|
45
|
+
onError: (attr: string | undefined, error?: string) => void;
|
|
46
46
|
onHiddenChanged?: (attr: string, hidden?: boolean) => void;
|
|
47
47
|
/** Filled only by table: components with value/label options report their label mappings for table filtering */
|
|
48
48
|
onFilterLabelUpdate?: (attr: string, valueToLabel: Record<string, string>) => void;
|
|
@@ -93,15 +93,18 @@ export default class ConfigGeneric<Props extends ConfigGenericProps = ConfigGene
|
|
|
93
93
|
constructor(props: Props);
|
|
94
94
|
protected getCachedObject(id: string): Promise<ioBroker.Object | null>;
|
|
95
95
|
componentDidMount(): Promise<void>;
|
|
96
|
-
|
|
96
|
+
private defaultSendTo;
|
|
97
97
|
componentWillUnmount(): void;
|
|
98
98
|
onUpdate: (data: Record<string, any>) => void;
|
|
99
99
|
/**
|
|
100
100
|
* Extract attribute out of data
|
|
101
101
|
*/
|
|
102
|
-
static getValue(data: Record<string, any>, attr: string | string[]): any;
|
|
103
|
-
static setValue(data: Record<string, any>, attr: string | string[], value: any): void;
|
|
104
|
-
getText(text: ioBroker.StringOrTranslated
|
|
102
|
+
static getValue(data: Record<string, any>, attr: string | string[] | undefined): any;
|
|
103
|
+
static setValue(data: Record<string, any>, attr: string | string[] | undefined, value: any): void;
|
|
104
|
+
getText(text: ioBroker.StringOrTranslated | undefined | null | {
|
|
105
|
+
/** @deprecated */
|
|
106
|
+
func: ioBroker.StringOrTranslated;
|
|
107
|
+
}, noTranslation?: boolean): string;
|
|
105
108
|
getTextAsync(text: ioBroker.StringOrTranslated, noTranslation?: boolean): Promise<string>;
|
|
106
109
|
renderDialogConfirm(): JSX.Element | null;
|
|
107
110
|
getIcon(iconSettings?: ConfigIconType | null): JSX.Element | null;
|
|
@@ -119,7 +122,7 @@ export default class ConfigGeneric<Props extends ConfigGenericProps = ConfigGene
|
|
|
119
122
|
* @param newValue new value of the attribute
|
|
120
123
|
* @param cb optional callback function, else returns a Promise
|
|
121
124
|
*/
|
|
122
|
-
onChange(attr: string, newValue: unknown, cb?: () => void): Promise<void>;
|
|
125
|
+
onChange(attr: string | undefined, newValue: unknown, cb?: () => void): Promise<void>;
|
|
123
126
|
/** Ensure that every bare getObject( call is preceded by "await". */
|
|
124
127
|
static ensureAwaitGetObject(code: string): string;
|
|
125
128
|
/**
|
|
@@ -132,24 +135,24 @@ export default class ConfigGeneric<Props extends ConfigGenericProps = ConfigGene
|
|
|
132
135
|
* @param data the data object the function was executed against
|
|
133
136
|
*/
|
|
134
137
|
protected debugLog(funcName: string, func: string, result: unknown, data?: Record<string, any>): void;
|
|
135
|
-
execute(func: string | boolean | Record<string, string
|
|
136
|
-
executeCustom(func: string | boolean | Record<string, string
|
|
138
|
+
execute(func: string | boolean | Record<string, string> | undefined, defaultValue: string | number | boolean | undefined, data: Record<string, any> | undefined, arrayIndex: number | undefined, globalData: Record<string, any> | undefined, funcName?: string): Promise<string | number | boolean | undefined>;
|
|
139
|
+
executeCustom(func: string | boolean | Record<string, string> | undefined, data: Record<string, any>, customObj: Record<string, any> | undefined, instanceObj: ioBroker.InstanceObject | undefined, arrayIndex: number | undefined, globalData: Record<string, any> | undefined, funcName?: string): Promise<string | boolean | number | null | undefined>;
|
|
137
140
|
calculate(schema: Record<string, any>): Promise<{
|
|
138
141
|
error: boolean;
|
|
139
142
|
disabled: boolean;
|
|
140
143
|
hidden: boolean;
|
|
141
144
|
defaultValue: null | string | number | boolean;
|
|
142
145
|
}>;
|
|
143
|
-
onError(attr: string, error?: string): void;
|
|
146
|
+
onError(attr: string | undefined, error?: string): void;
|
|
144
147
|
renderItem(_error: unknown, _disabled: boolean, _defaultValue?: unknown): JSX.Element | string | null;
|
|
145
|
-
renderHelp(text: ioBroker.StringOrTranslated, link
|
|
148
|
+
renderHelp(text: ioBroker.StringOrTranslated | undefined | null, link?: string | null, noTranslation?: boolean): JSX.Element | JSX.Element[] | string;
|
|
146
149
|
renderHelpAsync(text: ioBroker.StringOrTranslated, link: string, noTranslation: boolean): Promise<JSX.Element | JSX.Element[] | string>;
|
|
147
150
|
static escapeString(str: string, data: Record<string, any>): string;
|
|
148
151
|
/** This function is used in pattern */
|
|
149
152
|
getObject: (id: string) => Promise<ioBroker.Object | null>;
|
|
150
153
|
getPatternAsync(pattern: string | {
|
|
151
154
|
func: string;
|
|
152
|
-
}, data?: Record<string, any
|
|
155
|
+
}, data?: Record<string, any> | null, noTranslation?: boolean): Promise<string>;
|
|
153
156
|
getPattern(pattern: string | {
|
|
154
157
|
func: string;
|
|
155
158
|
}, data?: Record<string, any>, noTranslation?: boolean): string;
|
|
@@ -68,30 +68,36 @@ export default class ConfigGeneric extends Component {
|
|
|
68
68
|
this.defaultValue = await this.execute(this.props.schema.defaultFunc, this.props.schema.default, this.props.data, this.props.arrayIndex, this.props.globalData, 'defaultFunc');
|
|
69
69
|
}
|
|
70
70
|
}
|
|
71
|
-
|
|
71
|
+
if (this.props.attr) {
|
|
72
|
+
this.props.oContext.registerOnForceUpdate?.(this.props.attr, this.onUpdate);
|
|
73
|
+
}
|
|
72
74
|
const LIKE_SELECT = ['select', 'autocomplete', 'autocompleteSendTo'];
|
|
73
75
|
// init default value
|
|
74
|
-
if (this.defaultValue !== undefined) {
|
|
76
|
+
if (this.defaultValue !== undefined && this.props.attr) {
|
|
75
77
|
const value = ConfigGeneric.getValue(this.props.data, this.props.attr);
|
|
76
78
|
if (value === undefined ||
|
|
77
79
|
(LIKE_SELECT.includes(this.props.schema.type) && (value === '' || value === null))) {
|
|
78
80
|
setTimeout(() => {
|
|
81
|
+
if (!this.props.attr) {
|
|
82
|
+
return;
|
|
83
|
+
}
|
|
79
84
|
if (this.props.custom) {
|
|
80
|
-
this.props.onChange(this.props.attr, this.defaultValue, () => setTimeout(() => this.props.
|
|
85
|
+
this.props.onChange(this.props.attr, this.defaultValue, () => setTimeout(() => this.props.attr &&
|
|
86
|
+
this.props.oContext.forceUpdate([this.props.attr], this.props.data), 100));
|
|
81
87
|
}
|
|
82
88
|
else {
|
|
83
89
|
ConfigGeneric.setValue(this.props.data, this.props.attr, this.defaultValue);
|
|
84
|
-
this.props.onChange(this.props.data, undefined, () => this.props.oContext.forceUpdate([this.props.attr], this.props.data));
|
|
90
|
+
this.props.onChange(this.props.data, undefined, () => this.props.attr && this.props.oContext.forceUpdate([this.props.attr], this.props.data));
|
|
85
91
|
}
|
|
86
92
|
}, 100);
|
|
87
93
|
}
|
|
88
94
|
}
|
|
89
95
|
else if (this.props.schema.defaultSendTo) {
|
|
90
|
-
this.
|
|
96
|
+
this.defaultSendTo().catch(e => console.error(e));
|
|
91
97
|
}
|
|
92
98
|
}
|
|
93
|
-
async
|
|
94
|
-
if (this.props.alive) {
|
|
99
|
+
async defaultSendTo() {
|
|
100
|
+
if (this.props.alive && this.props.schema.defaultSendTo) {
|
|
95
101
|
this.defaultSendToDone = true;
|
|
96
102
|
let data = this.props.schema.data;
|
|
97
103
|
if (data === undefined && this.props.schema.jsonData) {
|
|
@@ -122,19 +128,21 @@ export default class ConfigGeneric extends Component {
|
|
|
122
128
|
return;
|
|
123
129
|
}
|
|
124
130
|
}
|
|
125
|
-
|
|
126
|
-
.sendTo(instance, this.props.schema.defaultSendTo, data)
|
|
127
|
-
|
|
128
|
-
if (value !== null && value !== undefined) {
|
|
131
|
+
try {
|
|
132
|
+
const value = await this.props.oContext.socket.sendTo(instance, this.props.schema.defaultSendTo, data);
|
|
133
|
+
if (value !== null && value !== undefined && this.props.attr) {
|
|
129
134
|
if (this.props.custom) {
|
|
130
|
-
this.props.onChange(this.props.attr, value, () => this.props.oContext.forceUpdate([this.props.attr], this.props.data));
|
|
135
|
+
this.props.onChange(this.props.attr, value, () => this.props.attr && this.props.oContext.forceUpdate([this.props.attr], this.props.data));
|
|
131
136
|
}
|
|
132
137
|
else {
|
|
133
138
|
ConfigGeneric.setValue(this.props.data, this.props.attr, value);
|
|
134
|
-
this.props.onChange(this.props.data, undefined, () => this.props.oContext.forceUpdate([this.props.attr], this.props.data));
|
|
139
|
+
this.props.onChange(this.props.data, undefined, () => this.props.attr && this.props.oContext.forceUpdate([this.props.attr], this.props.data));
|
|
135
140
|
}
|
|
136
141
|
}
|
|
137
|
-
}
|
|
142
|
+
}
|
|
143
|
+
catch (e) {
|
|
144
|
+
console.error(e);
|
|
145
|
+
}
|
|
138
146
|
}
|
|
139
147
|
else {
|
|
140
148
|
this.defaultSendToDone = false;
|
|
@@ -145,8 +153,8 @@ export default class ConfigGeneric extends Component {
|
|
|
145
153
|
}
|
|
146
154
|
}
|
|
147
155
|
componentWillUnmount() {
|
|
148
|
-
if (this.props.
|
|
149
|
-
this.props.oContext.registerOnForceUpdate(this.props.attr);
|
|
156
|
+
if (this.props.attr) {
|
|
157
|
+
this.props.oContext.registerOnForceUpdate?.(this.props.attr);
|
|
150
158
|
}
|
|
151
159
|
if (this.sendToTimeout) {
|
|
152
160
|
clearTimeout(this.sendToTimeout);
|
|
@@ -170,6 +178,9 @@ export default class ConfigGeneric extends Component {
|
|
|
170
178
|
* Extract attribute out of data
|
|
171
179
|
*/
|
|
172
180
|
static getValue(data, attr) {
|
|
181
|
+
if (!attr) {
|
|
182
|
+
return undefined;
|
|
183
|
+
}
|
|
173
184
|
if (typeof attr === 'string') {
|
|
174
185
|
return ConfigGeneric.getValue(data, attr.split('.'));
|
|
175
186
|
}
|
|
@@ -183,6 +194,9 @@ export default class ConfigGeneric extends Component {
|
|
|
183
194
|
return undefined;
|
|
184
195
|
}
|
|
185
196
|
static setValue(data, attr, value) {
|
|
197
|
+
if (!attr) {
|
|
198
|
+
return;
|
|
199
|
+
}
|
|
186
200
|
if (typeof attr === 'string') {
|
|
187
201
|
ConfigGeneric.setValue(data, attr.split('.'), value);
|
|
188
202
|
return;
|
|
@@ -213,18 +227,20 @@ export default class ConfigGeneric extends Component {
|
|
|
213
227
|
if (typeof text === 'string') {
|
|
214
228
|
const strText = noTranslation ? text : I18n.t(text);
|
|
215
229
|
if (strText.includes('${')) {
|
|
216
|
-
return this.getPattern(strText,
|
|
230
|
+
return this.getPattern(strText, undefined, noTranslation);
|
|
217
231
|
}
|
|
218
232
|
return strText;
|
|
219
233
|
}
|
|
220
|
-
if (
|
|
221
|
-
|
|
222
|
-
if (
|
|
234
|
+
if (text && typeof text === 'object') {
|
|
235
|
+
const funcText = text;
|
|
236
|
+
if (funcText.func) {
|
|
223
237
|
// calculate pattern
|
|
224
|
-
if (typeof
|
|
225
|
-
return this.getPattern(
|
|
238
|
+
if (typeof funcText.func === 'object') {
|
|
239
|
+
return this.getPattern(funcText.func[this.lang] ||
|
|
240
|
+
funcText.func.en ||
|
|
241
|
+
'', undefined, true);
|
|
226
242
|
}
|
|
227
|
-
return this.getPattern(
|
|
243
|
+
return this.getPattern(funcText.func, undefined, noTranslation);
|
|
228
244
|
}
|
|
229
245
|
return text[this.lang] || text.en || '';
|
|
230
246
|
}
|
|
@@ -259,6 +275,9 @@ export default class ConfigGeneric extends Component {
|
|
|
259
275
|
return null;
|
|
260
276
|
}
|
|
261
277
|
const confirm = this.state.confirmData || this.props.schema.confirm;
|
|
278
|
+
if (!confirm) {
|
|
279
|
+
return null;
|
|
280
|
+
}
|
|
262
281
|
let icon = null;
|
|
263
282
|
if (confirm.type === 'warning') {
|
|
264
283
|
icon = React.createElement(IconWarning, null);
|
|
@@ -435,6 +454,9 @@ export default class ConfigGeneric extends Component {
|
|
|
435
454
|
const val = ConfigGeneric.getValue(data, dep.attr);
|
|
436
455
|
if (await this.execute(dep.confirm.condition, false, data, this.props.arrayIndex, this.props.globalData, 'confirm.condition')) {
|
|
437
456
|
return new Promise(resolve => {
|
|
457
|
+
if (!dep.confirm) {
|
|
458
|
+
throw new Error(`Cannot set value: confirm is not defined for ${dep.attr}`);
|
|
459
|
+
}
|
|
438
460
|
this.setState({
|
|
439
461
|
confirmDialog: true,
|
|
440
462
|
confirmNewValue: newValue,
|
|
@@ -468,7 +490,7 @@ export default class ConfigGeneric extends Component {
|
|
|
468
490
|
else {
|
|
469
491
|
_newValue = await this.execute(dep.onChange.calculateFunc, val, data, this.props.arrayIndex, this.props.globalData, 'onChange.calculateFunc');
|
|
470
492
|
}
|
|
471
|
-
if (_newValue !== val) {
|
|
493
|
+
if (_newValue !== val && dep.attr) {
|
|
472
494
|
ConfigGeneric.setValue(data, dep.attr, _newValue);
|
|
473
495
|
changed.push(dep.attr);
|
|
474
496
|
}
|
|
@@ -478,7 +500,7 @@ export default class ConfigGeneric extends Component {
|
|
|
478
500
|
if (this.props.schema.hiddenDependsOn) {
|
|
479
501
|
for (let z = 0; z < this.props.schema.hiddenDependsOn.length; z++) {
|
|
480
502
|
const dep = this.props.schema.hiddenDependsOn[z];
|
|
481
|
-
if (dep.hidden) {
|
|
503
|
+
if (dep.hidden && dep.attr) {
|
|
482
504
|
changed.push(dep.attr);
|
|
483
505
|
}
|
|
484
506
|
}
|
|
@@ -486,7 +508,7 @@ export default class ConfigGeneric extends Component {
|
|
|
486
508
|
if (this.props.schema.labelDependsOn) {
|
|
487
509
|
for (let z = 0; z < this.props.schema.labelDependsOn.length; z++) {
|
|
488
510
|
const dep = this.props.schema.labelDependsOn[z];
|
|
489
|
-
if (dep.hidden) {
|
|
511
|
+
if (dep.hidden && dep.attr) {
|
|
490
512
|
changed.push(dep.attr);
|
|
491
513
|
}
|
|
492
514
|
}
|
|
@@ -494,7 +516,7 @@ export default class ConfigGeneric extends Component {
|
|
|
494
516
|
if (this.props.schema.helpDependsOn) {
|
|
495
517
|
for (let z = 0; z < this.props.schema.helpDependsOn.length; z++) {
|
|
496
518
|
const dep = this.props.schema.helpDependsOn[z];
|
|
497
|
-
if (dep.hidden) {
|
|
519
|
+
if (dep.hidden && dep.attr) {
|
|
498
520
|
changed.push(dep.attr);
|
|
499
521
|
}
|
|
500
522
|
}
|
|
@@ -509,7 +531,7 @@ export default class ConfigGeneric extends Component {
|
|
|
509
531
|
}
|
|
510
532
|
}
|
|
511
533
|
if (this.props.custom) {
|
|
512
|
-
this.props.onChange(attr, newValue, () => cb
|
|
534
|
+
this.props.onChange(attr, newValue, () => cb?.());
|
|
513
535
|
if (changed?.length) {
|
|
514
536
|
changed.forEach((_attr, i) => setTimeout(() => this.props.onChange(_attr, ConfigGeneric.getValue(data, _attr)), i * 50));
|
|
515
537
|
}
|
|
@@ -582,7 +604,7 @@ export default class ConfigGeneric extends Component {
|
|
|
582
604
|
}
|
|
583
605
|
try {
|
|
584
606
|
const f = new this.AsyncFunction('data', 'originalData', '_system', '_alive', '_common', '_socket', '_instance', 'arrayIndex', 'globalData', '_changed', '_href', 'getObject', fun.includes('return') ? fun : `return ${fun}`);
|
|
585
|
-
const result = await f(data || this.props.data, this.props.originalData, this.props.oContext.systemConfig, this.props.alive, this.props.common, this.props.oContext.socket, this.props.oContext.instance, arrayIndex, globalData, this.props.changed, window.location.href, this.getObject);
|
|
607
|
+
const result = await f(data || this.props.data || {}, this.props.originalData, this.props.oContext.systemConfig, this.props.alive, this.props.common, this.props.oContext.socket, this.props.oContext.instance, arrayIndex, globalData || {}, this.props.changed, window.location.href, this.getObject);
|
|
586
608
|
this.debugLog(funcName || 'JS function', fun, result, data);
|
|
587
609
|
return result;
|
|
588
610
|
}
|
|
@@ -612,7 +634,7 @@ export default class ConfigGeneric extends Component {
|
|
|
612
634
|
}
|
|
613
635
|
try {
|
|
614
636
|
const f = new this.AsyncFunction('data', 'originalData', '_system', 'instanceObj', 'customObj', '_socket', 'arrayIndex', 'globalData', '_changed', '_href', 'getObject', fun.includes('return') ? fun : `return ${fun}`);
|
|
615
|
-
const result = await f(data || this.props.data, this.props.originalData, this.props.oContext.systemConfig, instanceObj, customObj, this.props.oContext.socket, arrayIndex, globalData, this.props.changed, window.location.href, this.getObject);
|
|
637
|
+
const result = await f(data || this.props.data, this.props.originalData, this.props.oContext.systemConfig, instanceObj || {}, customObj || {}, this.props.oContext.socket, arrayIndex, globalData || {}, this.props.changed, window.location.href, this.getObject);
|
|
616
638
|
this.debugLog(funcName || 'JS function', fun, result, data);
|
|
617
639
|
return result;
|
|
618
640
|
}
|
|
@@ -683,15 +705,15 @@ export default class ConfigGeneric extends Component {
|
|
|
683
705
|
};
|
|
684
706
|
}
|
|
685
707
|
onError(attr, error) {
|
|
686
|
-
if (
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
this.props.onError(attr, error);
|
|
708
|
+
if (attr) {
|
|
709
|
+
if (!error) {
|
|
710
|
+
delete this.isError[attr];
|
|
711
|
+
}
|
|
712
|
+
else {
|
|
713
|
+
this.isError[attr] = error;
|
|
714
|
+
}
|
|
694
715
|
}
|
|
716
|
+
this.props.onError?.(attr, error);
|
|
695
717
|
}
|
|
696
718
|
renderItem(_error, _disabled, _defaultValue) {
|
|
697
719
|
return this.getText(this.props.schema.label) || this.getText(this.props.schema.text);
|
|
@@ -751,7 +773,7 @@ export default class ConfigGeneric extends Component {
|
|
|
751
773
|
/** This function is used in pattern */
|
|
752
774
|
getObject = async (id) => {
|
|
753
775
|
try {
|
|
754
|
-
const obj = await this.props.oContext.getCachedObject(id);
|
|
776
|
+
const obj = await this.props.oContext.getCachedObject?.(id);
|
|
755
777
|
return obj || null;
|
|
756
778
|
}
|
|
757
779
|
catch (e) {
|
|
@@ -853,7 +875,7 @@ export default class ConfigGeneric extends Component {
|
|
|
853
875
|
this.calculateTimeout = null;
|
|
854
876
|
const schema = this.props.schema;
|
|
855
877
|
if (!schema) {
|
|
856
|
-
return
|
|
878
|
+
return;
|
|
857
879
|
}
|
|
858
880
|
const { error, disabled, hidden, defaultValue } = await this.calculate(schema);
|
|
859
881
|
if (!this.state.calculatedValues ||
|
|
@@ -879,7 +901,7 @@ export default class ConfigGeneric extends Component {
|
|
|
879
901
|
if (this.props.alive && this.defaultSendToDone === false) {
|
|
880
902
|
this.sendToTimeout = setTimeout(async () => {
|
|
881
903
|
this.sendToTimeout = null;
|
|
882
|
-
await this.
|
|
904
|
+
await this.defaultSendTo();
|
|
883
905
|
}, 200);
|
|
884
906
|
}
|
|
885
907
|
this.updateCalculatedValues();
|
|
@@ -915,16 +937,16 @@ export default class ConfigGeneric extends Component {
|
|
|
915
937
|
// Used in table to not render hidden elements at all, so we need to inform about it
|
|
916
938
|
if (this.props.onHiddenChanged && !this.reportedHidden) {
|
|
917
939
|
this.reportedHidden = true;
|
|
918
|
-
setTimeout(() => this.props.onHiddenChanged(this.props.attr, true), 10);
|
|
940
|
+
setTimeout(() => this.props.attr && this.props.onHiddenChanged?.(this.props.attr, true), 10);
|
|
919
941
|
}
|
|
920
942
|
return null;
|
|
921
943
|
}
|
|
922
944
|
if (this.props.onHiddenChanged && this.reportedHidden) {
|
|
923
945
|
this.reportedHidden = false;
|
|
924
|
-
setTimeout(() => this.props.onHiddenChanged(this.props.attr, false), 10);
|
|
946
|
+
setTimeout(() => this.props.attr && this.props.onHiddenChanged?.(this.props.attr, false), 10);
|
|
925
947
|
}
|
|
926
948
|
// Add error
|
|
927
|
-
if (schema.validatorNoSaveOnError) {
|
|
949
|
+
if (schema.validatorNoSaveOnError && this.props.attr) {
|
|
928
950
|
if (this.state.calculatedValues.error && !Object.keys(this.isError).length) {
|
|
929
951
|
this.isError = {
|
|
930
952
|
[this.props.attr]: schema.validatorErrorText ? I18n.t(schema.validatorErrorText) : true,
|
|
@@ -936,7 +958,7 @@ export default class ConfigGeneric extends Component {
|
|
|
936
958
|
this.isError = {};
|
|
937
959
|
}
|
|
938
960
|
}
|
|
939
|
-
const renderedItem = this.renderItem(this.state.calculatedValues.error, this.state.calculatedValues.disabled || this.props.commandRunning || this.props.disabled, this.state.calculatedValues.defaultValue);
|
|
961
|
+
const renderedItem = this.renderItem(this.state.calculatedValues.error, this.state.calculatedValues.disabled || this.props.commandRunning || this.props.disabled || false, this.state.calculatedValues.defaultValue);
|
|
940
962
|
if (this.noPlaceRequired) {
|
|
941
963
|
return renderedItem;
|
|
942
964
|
}
|
|
@@ -955,7 +977,7 @@ export default class ConfigGeneric extends Component {
|
|
|
955
977
|
} }, this.props.schema.defaultSendTo && this.props.schema.button ? (React.createElement(Grid2, { container: true, style: { width: '100%' } },
|
|
956
978
|
React.createElement(Grid2, { flex: 1 }, renderedItem),
|
|
957
979
|
React.createElement(Grid2, null,
|
|
958
|
-
React.createElement(Button, { disabled: this.state.calculatedValues.disabled, variant: "outlined", onClick: () => this.
|
|
980
|
+
React.createElement(Button, { disabled: this.state.calculatedValues.disabled, variant: "outlined", onClick: () => this.defaultSendTo(), title: this.props.schema.buttonTooltip
|
|
959
981
|
? this.getText(this.props.schema.buttonTooltip, this.props.schema.buttonTooltipNoTranslation)
|
|
960
982
|
: I18n.t('jc_Request data by instance') }, this.getText(this.props.schema.button))))) : (renderedItem)));
|
|
961
983
|
if (schema.newLine) {
|