mirror of
https://github.com/home-assistant/frontend.git
synced 2025-07-16 22:06:34 +00:00
Move lovelace card edit dialog to mwc-dialog (#6130)
This commit is contained in:
parent
edc4601f8e
commit
168cc607aa
@ -13,7 +13,7 @@ export const createCloseHeading = (hass: HomeAssistant, title: string) => html`
|
|||||||
<mwc-icon-button
|
<mwc-icon-button
|
||||||
aria-label=${hass.localize("ui.dialogs.generic.close")}
|
aria-label=${hass.localize("ui.dialogs.generic.close")}
|
||||||
dialogAction="close"
|
dialogAction="close"
|
||||||
class="close_button"
|
class="header_button"
|
||||||
>
|
>
|
||||||
<ha-svg-icon path=${mdiClose}></ha-svg-icon>
|
<ha-svg-icon path=${mdiClose}></ha-svg-icon>
|
||||||
</mwc-icon-button>
|
</mwc-icon-button>
|
||||||
@ -35,10 +35,12 @@ export class HaDialog extends MwcDialog {
|
|||||||
display: block;
|
display: block;
|
||||||
height: 20px;
|
height: 20px;
|
||||||
}
|
}
|
||||||
.close_button {
|
.header_button {
|
||||||
position: absolute;
|
position: absolute;
|
||||||
right: 16px;
|
right: 16px;
|
||||||
top: 12px;
|
top: 12px;
|
||||||
|
text-decoration: none;
|
||||||
|
color: inherit;
|
||||||
}
|
}
|
||||||
`,
|
`,
|
||||||
];
|
];
|
||||||
|
@ -187,7 +187,6 @@ export class HuiCardEditor extends LitElement {
|
|||||||
// Refresh code editor when switching to yaml mode
|
// Refresh code editor when switching to yaml mode
|
||||||
this._refreshYamlEditor(true);
|
this._refreshYamlEditor(true);
|
||||||
}
|
}
|
||||||
fireEvent(this as HTMLElement, "iron-resize");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this._configElement && changedProperties.has("hass")) {
|
if (this._configElement && changedProperties.has("hass")) {
|
||||||
@ -207,7 +206,6 @@ export class HuiCardEditor extends LitElement {
|
|||||||
this._yamlEditor.codemirror.focus();
|
this._yamlEditor.codemirror.focus();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
fireEvent(this as HTMLElement, "iron-resize");
|
|
||||||
}, 1);
|
}, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -279,7 +277,6 @@ export class HuiCardEditor extends LitElement {
|
|||||||
this.GUImode = false;
|
this.GUImode = false;
|
||||||
} finally {
|
} finally {
|
||||||
this._loading = false;
|
this._loading = false;
|
||||||
fireEvent(this, "iron-resize");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,4 +1,3 @@
|
|||||||
import "@polymer/paper-dialog-scrollable/paper-dialog-scrollable";
|
|
||||||
import deepFreeze from "deep-freeze";
|
import deepFreeze from "deep-freeze";
|
||||||
import {
|
import {
|
||||||
css,
|
css,
|
||||||
@ -12,7 +11,7 @@ import {
|
|||||||
PropertyValues,
|
PropertyValues,
|
||||||
} from "lit-element";
|
} from "lit-element";
|
||||||
import type { HASSDomEvent } from "../../../../common/dom/fire_event";
|
import type { HASSDomEvent } from "../../../../common/dom/fire_event";
|
||||||
import "../../../../components/dialog/ha-paper-dialog";
|
import "../../../../components/ha-dialog";
|
||||||
import type {
|
import type {
|
||||||
LovelaceCardConfig,
|
LovelaceCardConfig,
|
||||||
LovelaceViewConfig,
|
LovelaceViewConfig,
|
||||||
@ -28,6 +27,7 @@ import "./hui-card-picker";
|
|||||||
import "./hui-card-preview";
|
import "./hui-card-preview";
|
||||||
import type { EditCardDialogParams } from "./show-edit-card-dialog";
|
import type { EditCardDialogParams } from "./show-edit-card-dialog";
|
||||||
import { getCardDocumentationURL } from "../get-card-documentation-url";
|
import { getCardDocumentationURL } from "../get-card-documentation-url";
|
||||||
|
import { mdiHelpCircle } from "@mdi/js";
|
||||||
|
|
||||||
declare global {
|
declare global {
|
||||||
// for fire event
|
// for fire event
|
||||||
@ -116,28 +116,29 @@ export class HuiDialogEditCard extends LitElement {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return html`
|
return html`
|
||||||
<ha-paper-dialog with-backdrop opened modal @keyup=${this._handleKeyUp}>
|
<ha-dialog
|
||||||
<div class="header">
|
open
|
||||||
<h2>
|
scrimClickAction
|
||||||
${heading}
|
escapeKeyAction
|
||||||
</h2>
|
@keyup=${this._handleKeyUp}
|
||||||
${this._documentationURL !== undefined
|
.heading=${html`${heading}
|
||||||
? html`
|
${this._documentationURL !== undefined
|
||||||
<a
|
? html`
|
||||||
class="help-icon"
|
<a
|
||||||
href=${this._documentationURL}
|
class="header_button"
|
||||||
target="_blank"
|
href=${this._documentationURL}
|
||||||
rel="noreferrer"
|
title=${this.hass!.localize("ui.panel.lovelace.menu.help")}
|
||||||
>
|
target="_blank"
|
||||||
<ha-icon-button
|
rel="noreferrer"
|
||||||
icon="hass:help-circle"
|
>
|
||||||
.title=${this.hass!.localize("ui.panel.lovelace.menu.help")}
|
<mwc-icon-button>
|
||||||
></ha-icon-button>
|
<ha-svg-icon path=${mdiHelpCircle}></ha-svg-icon>
|
||||||
</a>
|
</mwc-icon-button>
|
||||||
`
|
</a>
|
||||||
: ""}
|
`
|
||||||
</div>
|
: ""}`}
|
||||||
<paper-dialog-scrollable>
|
>
|
||||||
|
<div>
|
||||||
${this._cardConfig === undefined
|
${this._cardConfig === undefined
|
||||||
? html`
|
? html`
|
||||||
<hui-card-picker
|
<hui-card-picker
|
||||||
@ -174,42 +175,40 @@ export class HuiDialogEditCard extends LitElement {
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
`}
|
`}
|
||||||
</paper-dialog-scrollable>
|
|
||||||
<div class="paper-dialog-buttons">
|
|
||||||
${this._cardConfig !== undefined
|
|
||||||
? html`
|
|
||||||
<mwc-button
|
|
||||||
@click=${this._toggleMode}
|
|
||||||
.disabled=${!this._guiModeAvailable}
|
|
||||||
class="gui-mode-button"
|
|
||||||
>
|
|
||||||
${this.hass!.localize(
|
|
||||||
!this._cardEditorEl || this._GUImode
|
|
||||||
? "ui.panel.lovelace.editor.edit_card.show_code_editor"
|
|
||||||
: "ui.panel.lovelace.editor.edit_card.show_visual_editor"
|
|
||||||
)}
|
|
||||||
</mwc-button>
|
|
||||||
`
|
|
||||||
: ""}
|
|
||||||
<mwc-button @click=${this._close}>
|
|
||||||
${this.hass!.localize("ui.common.cancel")}
|
|
||||||
</mwc-button>
|
|
||||||
${this._cardConfig !== undefined
|
|
||||||
? html`
|
|
||||||
<mwc-button
|
|
||||||
?disabled=${!this._canSave || this._saving}
|
|
||||||
@click=${this._save}
|
|
||||||
>
|
|
||||||
${this._saving
|
|
||||||
? html`
|
|
||||||
<paper-spinner active alt="Saving"></paper-spinner>
|
|
||||||
`
|
|
||||||
: this.hass!.localize("ui.common.save")}
|
|
||||||
</mwc-button>
|
|
||||||
`
|
|
||||||
: ``}
|
|
||||||
</div>
|
</div>
|
||||||
</ha-paper-dialog>
|
${this._cardConfig !== undefined
|
||||||
|
? html`
|
||||||
|
<mwc-button
|
||||||
|
slot="secondaryAction"
|
||||||
|
@click=${this._toggleMode}
|
||||||
|
.disabled=${!this._guiModeAvailable}
|
||||||
|
class="gui-mode-button"
|
||||||
|
>
|
||||||
|
${this.hass!.localize(
|
||||||
|
!this._cardEditorEl || this._GUImode
|
||||||
|
? "ui.panel.lovelace.editor.edit_card.show_code_editor"
|
||||||
|
: "ui.panel.lovelace.editor.edit_card.show_visual_editor"
|
||||||
|
)}
|
||||||
|
</mwc-button>
|
||||||
|
`
|
||||||
|
: ""}
|
||||||
|
<mwc-button slot="primaryAction" @click=${this._close}>
|
||||||
|
${this.hass!.localize("ui.common.cancel")}
|
||||||
|
</mwc-button>
|
||||||
|
${this._cardConfig !== undefined
|
||||||
|
? html`
|
||||||
|
<mwc-button
|
||||||
|
slot="primaryAction"
|
||||||
|
?disabled=${!this._canSave || this._saving}
|
||||||
|
@click=${this._save}
|
||||||
|
>
|
||||||
|
${this._saving
|
||||||
|
? html` <paper-spinner active alt="Saving"></paper-spinner> `
|
||||||
|
: this.hass!.localize("ui.common.save")}
|
||||||
|
</mwc-button>
|
||||||
|
`
|
||||||
|
: ``}
|
||||||
|
</ha-dialog>
|
||||||
`;
|
`;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -223,20 +222,20 @@ export class HuiDialogEditCard extends LitElement {
|
|||||||
|
|
||||||
@media all and (max-width: 450px), all and (max-height: 500px) {
|
@media all and (max-width: 450px), all and (max-height: 500px) {
|
||||||
/* overrule the ha-style-dialog max-height on small screens */
|
/* overrule the ha-style-dialog max-height on small screens */
|
||||||
ha-paper-dialog {
|
ha-dialog {
|
||||||
max-height: 100%;
|
--mdc-dialog-max-height: 100%;
|
||||||
height: 100%;
|
height: 100%;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@media all and (min-width: 850px) {
|
@media all and (min-width: 850px) {
|
||||||
ha-paper-dialog {
|
ha-dialog {
|
||||||
width: 845px;
|
--mdc-dialog-min-width: 845px;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ha-paper-dialog {
|
ha-dialog {
|
||||||
max-width: 845px;
|
--mdc-dialog-max-width: 845px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.center {
|
.center {
|
||||||
@ -258,9 +257,9 @@ export class HuiDialogEditCard extends LitElement {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@media (min-width: 1200px) {
|
@media (min-width: 1200px) {
|
||||||
ha-paper-dialog {
|
ha-dialog {
|
||||||
max-width: none;
|
--mdc-dialog-max-width: calc(100% - 32px);
|
||||||
width: 1000px;
|
--mdc-dialog-min-width: 1000px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.content {
|
.content {
|
||||||
@ -317,10 +316,6 @@ export class HuiDialogEditCard extends LitElement {
|
|||||||
align-items: center;
|
align-items: center;
|
||||||
justify-content: space-between;
|
justify-content: space-between;
|
||||||
}
|
}
|
||||||
.help-icon {
|
|
||||||
text-decoration: none;
|
|
||||||
color: inherit;
|
|
||||||
}
|
|
||||||
`,
|
`,
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user