Skip to content

Commit

Permalink
Correcting readonly flag for texts: #2656
Browse files Browse the repository at this point in the history
  • Loading branch information
GermanBluefox committed Sep 10, 2024
1 parent 34a827a commit d90725b
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 3 deletions.
32 changes: 32 additions & 0 deletions packages/admin/admin/jsonConfig.json5
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,38 @@
"md": 4,
"lg": 4,
"hidden": "!!data.auth"
},
"table2": {
"type": "table",
"newLine": true,
"sm": 12,
"md": 12,
"lg": 12,
"label": "",
"noDelete": true,
"items": [
{
"type": "checkbox",
"attr": "table2Chk",
"width": "5% ",
"title": "checkbox (changeable)",
"tooltip": "Click on it",
"filter": false,
"sort": false,
"default": true
},
{
"type": "text",
"attr": "table2Text1",
"width": "8% ",
"title": "Text (fixed, not changeable)",
"tooltip": "enter any text",
"filter": false,
"sort": false,
"readOnly": true,
"default": ""
}
]
}
}
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ class ConfigCheckbox extends ConfigGeneric<ConfigCheckboxProps, ConfigGenericSta
this.onChange(this.props.attr, e.target.checked);
}
}}
disabled={disabled}
disabled={disabled || this.props.schema.readOnly}
/>}
label={this.getText(this.props.schema.label)}
/>
Expand Down
2 changes: 1 addition & 1 deletion packages/jsonConfig/src/JsonConfigComponent/ConfigText.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ class ConfigText extends ConfigGeneric<ConfigTextProps, ConfigTextState> {
readOnly: this.props.schema.readOnly || false,
},
input: {
endAdornment: this.state.value && !this.props.schema.noClearButton ? <InputAdornment position="end">
endAdornment: !this.props.schema.readOnly && this.state.value && !this.props.schema.noClearButton ? <InputAdornment position="end">
<IconButton
size="small"
onClick={() => this.setState({ value: '', oldValue: this.state.value }, () =>
Expand Down
17 changes: 16 additions & 1 deletion packages/jsonConfig/src/types.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,20 +29,33 @@ export interface ConfigItemConfirmData {
}

export interface ConfigItem {
/** Type of the JSON config item */
type: ConfigItemType;
/** Width of the control on "extra small" displays */
xs?: 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12;
/** Width of the control on "small" displays */
sm?: 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12;
/** Width of the control on "medium" displays */
md?: 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12;
/** Width of the control on "large" displays */
lg?: 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12;
xs?: 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12;
/** Width of the control on "extra large" displays */
xl?: 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12;
/** If the control should be shown in a new line */
newLine?: boolean;
/** Label of the control */
label?: ioBroker.StringOrTranslated;
/** @deprecated use label */
text?: ioBroker.StringOrTranslated;
/** Formula or false to hide the control: "data.attr === 5" */
hidden?: string | boolean;
/** If true and the control is hidden, the place of the control will be still reserved for it */
hideOnlyControl?: boolean;
/** JS function to calculate if the control is disabled. You can write "true" too */
disabled?: string | boolean;
/** Help text of the control */
help?: ioBroker.StringOrTranslated;
/** Link that will be opened by clicking on the help text */
helpLink?: string;
style?: CustomCSSProperties;
darkStyle?: CustomCSSProperties;
Expand Down Expand Up @@ -193,6 +206,8 @@ export interface ConfigItemColor extends ConfigItem {

export interface ConfigItemCheckbox extends ConfigItem {
type: 'checkbox';
/** Same as disabled */
readOnly?: boolean;
}

export interface ConfigItemNumber extends ConfigItem {
Expand Down

0 comments on commit d90725b

Please sign in to comment.