Only use toggle mode in card editor

This commit is contained in:
Paul Bottein 2024-09-09 18:32:16 +02:00
parent 4f2652abd2
commit c8b7f373c3
No known key found for this signature in database
3 changed files with 15 additions and 4 deletions

View File

@ -49,6 +49,7 @@ class HuiCardEditor extends LitElement {
.hass=${this.hass}
.lovelace=${this.lovelace}
.value=${this.config}
show-toggle-mode-button
></hui-card-element-editor>
`;
}

View File

@ -74,6 +74,9 @@ export abstract class HuiElementEditor<T, C = any> extends LitElement {
@property({ attribute: false }) public context?: C;
@property({ type: Boolean, attribute: "show-toggle-mode-button" })
public showToggleModeButton = false;
@state() private _yaml?: string;
@state() private _config?: T;
@ -217,9 +220,16 @@ export abstract class HuiElementEditor<T, C = any> extends LitElement {
return html`
<div class="wrapper">
<ha-button @click=${this.toggleMode} .disabled=${!guiModeAvailable}>
${guiModeAvailable && this._guiMode ? "Show yaml" : "Show UI"}
</ha-button>
${this.showToggleModeButton
? html`
<ha-button
@click=${this.toggleMode}
.disabled=${!guiModeAvailable}
>
${guiModeAvailable && this._guiMode ? "Show yaml" : "Show UI"}
</ha-button>
`
: nothing}
${this.GUImode
? html`
<div class="gui-editor">

View File

@ -1803,7 +1803,7 @@
"editor_not_supported": "Visual editor not supported",
"editor_not_supported_details": "The visual editor is not supported for type ''{type}''.",
"warning_details": "The configuration contains the following warnings:",
"edit_in_yaml_supported": "You can still edit your config in YAML.",
"edit_in_yaml_supported": "You can still edit the configuration in YAML.",
"key_missing": "Required key ''{key}'' is missing.",
"key_not_expected": "Key ''{key}'' is not expected or not supported by the visual editor.",
"key_wrong_type": "The provided value for ''{key}'' is not supported by the visual editor. We support ({type_correct}) but received ({type_wrong}).",