;
} else {
const label = this.getText(this.props.schema.label, this.props.schema.noTranslation);
- const unit = this.getText(this.props.schema.unit, this.props.schema.noTranslation) || this.obj.common.unit;
- content =
+ const unit = this.getText(this.props.schema.unit, this.props.schema.noTranslation) || this.state.obj.common.unit;
+ content =
{label}
{label ? : : null}
{this.state.stateValue}
diff --git a/packages/jsonConfig/src/JsonConfigComponent/index.tsx b/packages/jsonConfig/src/JsonConfigComponent/index.tsx
index 9b77eb9cc..e9099df4c 100644
--- a/packages/jsonConfig/src/JsonConfigComponent/index.tsx
+++ b/packages/jsonConfig/src/JsonConfigComponent/index.tsx
@@ -58,7 +58,6 @@ interface JsonConfigComponentState {
alive: boolean;
commandRunning: boolean;
schema: ConfigItemTabs | ConfigItemPanel;
- data: Record | null;
}
export class JsonConfigComponent extends Component {
@@ -73,7 +72,6 @@ export class JsonConfigComponent extends Component this.setState({ commandRunning });
- async readSettings() : Promise {
- if ((this.props.custom || this.props.common) && this.props.data) {
- return;
- }
- const obj = await this.props.socket.getObject(`system.adapter.${this.props.adapterName}.${this.props.instance}`);
- // eslint-disable-next-line react/no-unused-state
- this.setState({ data: this.props.data || obj.native });
- }
-
readData() {
- this.readSettings()
- .then(() => this.props.socket.getCompactSystemConfig())
+ this.props.socket.getCompactSystemConfig()
.then(systemConfig =>
this.props.socket.getState(`system.adapter.${this.props.adapterName}.${this.props.instance}.alive`)
.then(state => {
@@ -192,15 +179,19 @@ export class JsonConfigComponent extends Component, value: any, cb?: () => void, saveConfig?: boolean) => {
if (this.props.onValueChange) {
this.props.onValueChange(attrOrData as string, value, saveConfig);
- cb && cb();
+ if (cb) {
+ cb();
+ }
} else if (attrOrData && this.props.onChange) {
- const newState: Partial = { data: attrOrData as Record };
-
- newState.changed = JSON.stringify(attrOrData) !== this.state.originalData;
+ const newState: Partial = {
+ changed: JSON.stringify(attrOrData) !== this.state.originalData,
+ };
this.setState(newState as JsonConfigComponentState, () => {
this.props.onChange(attrOrData as Record, newState.changed, saveConfig);
- cb && cb();
+ if (cb) {
+ cb();
+ }
});
} else if (saveConfig) {
this.props.onChange(null, null, saveConfig);
@@ -216,7 +207,9 @@ export class JsonConfigComponent extends Component
this.setState({ errors: this.errorCached }, () => {
diff --git a/packages/jsonConfig/src/types.d.ts b/packages/jsonConfig/src/types.d.ts
index 5e40d72fd..18987738f 100644
--- a/packages/jsonConfig/src/types.d.ts
+++ b/packages/jsonConfig/src/types.d.ts
@@ -536,6 +536,8 @@ export interface ConfigItemState extends ConfigItem {
step?: number;
/** delay in ms for slider or number */
controlDelay?: number;
+ /** Variant of button */
+ variant?: 'contained' | 'outlined' | 'text';
}
export interface ConfigItemTextSendTo extends Omit {