mirror of
https://github.com/home-assistant/frontend.git
synced 2025-07-24 09:46:36 +00:00
Move re-order button at triggers/conditions/actions level. (#14185)
This commit is contained in:
parent
16bd1f5883
commit
d445bf2505
@ -18,11 +18,13 @@ export class HaActionSelector extends LitElement {
|
||||
@property({ type: Boolean, reflect: true }) public disabled = false;
|
||||
|
||||
protected render() {
|
||||
return html`<ha-automation-action
|
||||
.disabled=${this.disabled}
|
||||
.actions=${this.value || []}
|
||||
.hass=${this.hass}
|
||||
></ha-automation-action>`;
|
||||
return html`
|
||||
<ha-automation-action
|
||||
.disabled=${this.disabled}
|
||||
.actions=${this.value || []}
|
||||
.hass=${this.hass}
|
||||
></ha-automation-action>
|
||||
`;
|
||||
}
|
||||
|
||||
static get styles(): CSSResultGroup {
|
||||
|
@ -9,6 +9,7 @@ import {
|
||||
mdiPlayCircleOutline,
|
||||
mdiRenameBox,
|
||||
mdiStopCircleOutline,
|
||||
mdiSort,
|
||||
} from "@mdi/js";
|
||||
import { css, CSSResultGroup, html, LitElement, PropertyValues } from "lit";
|
||||
import { customElement, property, query, state } from "lit/decorators";
|
||||
@ -190,6 +191,12 @@ export default class HaAutomationActionRow extends LitElement {
|
||||
.path=${mdiRenameBox}
|
||||
></ha-svg-icon>
|
||||
</mwc-list-item>
|
||||
<mwc-list-item graphic="icon" .disabled=${this.disabled}>
|
||||
${this.hass.localize(
|
||||
"ui.panel.config.automation.editor.actions.re_order"
|
||||
)}
|
||||
<ha-svg-icon slot="graphic" .path=${mdiSort}></ha-svg-icon>
|
||||
</mwc-list-item>
|
||||
<mwc-list-item graphic="icon" .disabled=${this.disabled}>
|
||||
${this.hass.localize(
|
||||
"ui.panel.config.automation.editor.actions.duplicate"
|
||||
@ -348,20 +355,23 @@ export default class HaAutomationActionRow extends LitElement {
|
||||
await this._renameAction();
|
||||
break;
|
||||
case 2:
|
||||
fireEvent(this, "duplicate");
|
||||
fireEvent(this, "re-order");
|
||||
break;
|
||||
case 3:
|
||||
fireEvent(this, "duplicate");
|
||||
break;
|
||||
case 4:
|
||||
this._switchUiMode();
|
||||
this.expand();
|
||||
break;
|
||||
case 4:
|
||||
case 5:
|
||||
this._switchYamlMode();
|
||||
this.expand();
|
||||
break;
|
||||
case 5:
|
||||
case 6:
|
||||
this._onDisable();
|
||||
break;
|
||||
case 6:
|
||||
case 7:
|
||||
this._onDelete();
|
||||
break;
|
||||
}
|
||||
|
@ -46,6 +46,8 @@ export default class HaAutomationAction extends LitElement {
|
||||
|
||||
@property({ type: Boolean }) public disabled = false;
|
||||
|
||||
@property({ type: Boolean }) public nested = false;
|
||||
|
||||
@property() public actions!: Action[];
|
||||
|
||||
@property({ type: Boolean }) public reOrderMode = false;
|
||||
@ -58,6 +60,25 @@ export default class HaAutomationAction extends LitElement {
|
||||
|
||||
protected render() {
|
||||
return html`
|
||||
${this.reOrderMode && !this.nested
|
||||
? html`
|
||||
<ha-alert
|
||||
alert-type="info"
|
||||
.title=${this.hass.localize(
|
||||
"ui.panel.config.automation.editor.re_order_mode.title"
|
||||
)}
|
||||
>
|
||||
${this.hass.localize(
|
||||
"ui.panel.config.automation.editor.re_order_mode.description_actions"
|
||||
)}
|
||||
<mwc-button slot="action" @click=${this._exitReOrderMode}>
|
||||
${this.hass.localize(
|
||||
"ui.panel.config.automation.editor.re_order_mode.exit"
|
||||
)}
|
||||
</mwc-button>
|
||||
</ha-alert>
|
||||
`
|
||||
: null}
|
||||
<div class="actions">
|
||||
${repeat(
|
||||
this.actions,
|
||||
@ -72,6 +93,7 @@ export default class HaAutomationAction extends LitElement {
|
||||
.reOrderMode=${this.reOrderMode}
|
||||
@duplicate=${this._duplicateAction}
|
||||
@value-changed=${this._actionChanged}
|
||||
@re-order=${this._enterReOrderMode}
|
||||
.hass=${this.hass}
|
||||
>
|
||||
${this.reOrderMode
|
||||
@ -155,6 +177,16 @@ export default class HaAutomationAction extends LitElement {
|
||||
}
|
||||
}
|
||||
|
||||
private async _enterReOrderMode(ev: CustomEvent) {
|
||||
if (this.nested) return;
|
||||
ev.stopPropagation();
|
||||
this.reOrderMode = true;
|
||||
}
|
||||
|
||||
private async _exitReOrderMode() {
|
||||
this.reOrderMode = false;
|
||||
}
|
||||
|
||||
private async _createSortable() {
|
||||
const Sortable = await loadSortable();
|
||||
this._sortable = new Sortable(this.shadowRoot!.querySelector(".actions")!, {
|
||||
@ -282,6 +314,12 @@ export default class HaAutomationAction extends LitElement {
|
||||
ha-svg-icon {
|
||||
height: 20px;
|
||||
}
|
||||
ha-alert {
|
||||
display: block;
|
||||
margin-bottom: 16px;
|
||||
border-radius: var(--ha-card-border-radius, 16px);
|
||||
overflow: hidden;
|
||||
}
|
||||
.handle {
|
||||
cursor: move;
|
||||
padding: 12px;
|
||||
|
@ -55,6 +55,7 @@ export class HaChooseAction extends LitElement implements ActionElement {
|
||||
)}:
|
||||
</h3>
|
||||
<ha-automation-condition
|
||||
nested
|
||||
.conditions=${ensureArray<string | Condition>(option.conditions)}
|
||||
.reOrderMode=${this.reOrderMode}
|
||||
.disabled=${this.disabled}
|
||||
@ -68,6 +69,7 @@ export class HaChooseAction extends LitElement implements ActionElement {
|
||||
)}:
|
||||
</h3>
|
||||
<ha-automation-action
|
||||
nested
|
||||
.actions=${ensureArray(option.sequence) || []}
|
||||
.reOrderMode=${this.reOrderMode}
|
||||
.disabled=${this.disabled}
|
||||
@ -96,6 +98,7 @@ export class HaChooseAction extends LitElement implements ActionElement {
|
||||
)}:
|
||||
</h2>
|
||||
<ha-automation-action
|
||||
nested
|
||||
.actions=${ensureArray(action.default) || []}
|
||||
.reOrderMode=${this.reOrderMode}
|
||||
.disabled=${this.disabled}
|
||||
|
@ -38,6 +38,7 @@ export class HaIfAction extends LitElement implements ActionElement {
|
||||
)}*:
|
||||
</h3>
|
||||
<ha-automation-condition
|
||||
nested
|
||||
.conditions=${action.if}
|
||||
.reOrderMode=${this.reOrderMode}
|
||||
.disabled=${this.disabled}
|
||||
@ -51,6 +52,7 @@ export class HaIfAction extends LitElement implements ActionElement {
|
||||
)}*:
|
||||
</h3>
|
||||
<ha-automation-action
|
||||
nested
|
||||
.actions=${action.then}
|
||||
.reOrderMode=${this.reOrderMode}
|
||||
.disabled=${this.disabled}
|
||||
@ -65,6 +67,7 @@ export class HaIfAction extends LitElement implements ActionElement {
|
||||
)}:
|
||||
</h3>
|
||||
<ha-automation-action
|
||||
nested
|
||||
.actions=${action.else || []}
|
||||
.reOrderMode=${this.reOrderMode}
|
||||
.disabled=${this.disabled}
|
||||
|
@ -29,6 +29,7 @@ export class HaParallelAction extends LitElement implements ActionElement {
|
||||
|
||||
return html`
|
||||
<ha-automation-action
|
||||
nested
|
||||
.actions=${action.parallel}
|
||||
.reOrderMode=${this.reOrderMode}
|
||||
.disabled=${this.disabled}
|
||||
|
@ -77,6 +77,7 @@ export class HaRepeatAction extends LitElement implements ActionElement {
|
||||
)}:
|
||||
</h3>
|
||||
<ha-automation-condition
|
||||
nested
|
||||
.conditions=${(action as WhileRepeat).while || []}
|
||||
.hass=${this.hass}
|
||||
.disabled=${this.disabled}
|
||||
@ -89,6 +90,7 @@ export class HaRepeatAction extends LitElement implements ActionElement {
|
||||
)}:
|
||||
</h3>
|
||||
<ha-automation-condition
|
||||
nested
|
||||
.conditions=${(action as UntilRepeat).until || []}
|
||||
.hass=${this.hass}
|
||||
.disabled=${this.disabled}
|
||||
@ -102,6 +104,7 @@ export class HaRepeatAction extends LitElement implements ActionElement {
|
||||
)}:
|
||||
</h3>
|
||||
<ha-automation-action
|
||||
nested
|
||||
.actions=${action.sequence}
|
||||
.reOrderMode=${this.reOrderMode}
|
||||
.disabled=${this.disabled}
|
||||
|
@ -23,6 +23,8 @@ export class HaWaitForTriggerAction
|
||||
|
||||
@property({ type: Boolean }) public disabled = false;
|
||||
|
||||
@property({ type: Boolean }) public reOrderMode = false;
|
||||
|
||||
public static get defaultConfig() {
|
||||
return { wait_for_trigger: [] };
|
||||
}
|
||||
@ -53,10 +55,12 @@ export class HaWaitForTriggerAction
|
||||
></ha-switch>
|
||||
</ha-formfield>
|
||||
<ha-automation-trigger
|
||||
nested
|
||||
.triggers=${ensureArray(this.action.wait_for_trigger)}
|
||||
.hass=${this.hass}
|
||||
.disabled=${this.disabled}
|
||||
.name=${"wait_for_trigger"}
|
||||
.reOrderMode=${this.reOrderMode}
|
||||
@value-changed=${this._valueChanged}
|
||||
></ha-automation-trigger>
|
||||
`;
|
||||
|
@ -8,6 +8,7 @@ import {
|
||||
mdiFlask,
|
||||
mdiPlayCircleOutline,
|
||||
mdiRenameBox,
|
||||
mdiSort,
|
||||
mdiStopCircleOutline,
|
||||
} from "@mdi/js";
|
||||
import { css, CSSResultGroup, html, LitElement } from "lit";
|
||||
@ -142,6 +143,14 @@ export default class HaAutomationConditionRow extends LitElement {
|
||||
.path=${mdiRenameBox}
|
||||
></ha-svg-icon>
|
||||
</mwc-list-item>
|
||||
|
||||
<mwc-list-item graphic="icon" .disabled=${this.disabled}>
|
||||
${this.hass.localize(
|
||||
"ui.panel.config.automation.editor.conditions.re_order"
|
||||
)}
|
||||
<ha-svg-icon slot="graphic" .path=${mdiSort}></ha-svg-icon>
|
||||
</mwc-list-item>
|
||||
|
||||
<mwc-list-item graphic="icon" .disabled=${this.disabled}>
|
||||
${this.hass.localize(
|
||||
"ui.panel.config.automation.editor.actions.duplicate"
|
||||
@ -294,20 +303,23 @@ export default class HaAutomationConditionRow extends LitElement {
|
||||
await this._renameCondition();
|
||||
break;
|
||||
case 2:
|
||||
fireEvent(this, "duplicate");
|
||||
fireEvent(this, "re-order");
|
||||
break;
|
||||
case 3:
|
||||
fireEvent(this, "duplicate");
|
||||
break;
|
||||
case 4:
|
||||
this._switchUiMode();
|
||||
this.expand();
|
||||
break;
|
||||
case 4:
|
||||
case 5:
|
||||
this._switchYamlMode();
|
||||
this.expand();
|
||||
break;
|
||||
case 5:
|
||||
case 6:
|
||||
this._onDisable();
|
||||
break;
|
||||
case 6:
|
||||
case 7:
|
||||
this._onDelete();
|
||||
break;
|
||||
}
|
||||
|
@ -44,6 +44,8 @@ export default class HaAutomationCondition extends LitElement {
|
||||
|
||||
@property({ type: Boolean }) public disabled = false;
|
||||
|
||||
@property({ type: Boolean }) public nested = false;
|
||||
|
||||
@property({ type: Boolean }) public reOrderMode = false;
|
||||
|
||||
private _focusLastConditionOnChange = false;
|
||||
@ -102,6 +104,25 @@ export default class HaAutomationCondition extends LitElement {
|
||||
return html``;
|
||||
}
|
||||
return html`
|
||||
${this.reOrderMode && !this.nested
|
||||
? html`
|
||||
<ha-alert
|
||||
alert-type="info"
|
||||
.title=${this.hass.localize(
|
||||
"ui.panel.config.automation.editor.re_order_mode.title"
|
||||
)}
|
||||
>
|
||||
${this.hass.localize(
|
||||
"ui.panel.config.automation.editor.re_order_mode.description_conditions"
|
||||
)}
|
||||
<mwc-button slot="action" @click=${this._exitReOrderMode}>
|
||||
${this.hass.localize(
|
||||
"ui.panel.config.automation.editor.re_order_mode.exit"
|
||||
)}
|
||||
</mwc-button>
|
||||
</ha-alert>
|
||||
`
|
||||
: null}
|
||||
<div class="conditions">
|
||||
${repeat(
|
||||
this.conditions,
|
||||
@ -117,6 +138,7 @@ export default class HaAutomationCondition extends LitElement {
|
||||
@duplicate=${this._duplicateCondition}
|
||||
@move-condition=${this._move}
|
||||
@value-changed=${this._conditionChanged}
|
||||
@re-order=${this._enterReOrderMode}
|
||||
.hass=${this.hass}
|
||||
>
|
||||
${this.reOrderMode
|
||||
@ -176,6 +198,16 @@ export default class HaAutomationCondition extends LitElement {
|
||||
`;
|
||||
}
|
||||
|
||||
private async _enterReOrderMode(ev: CustomEvent) {
|
||||
if (this.nested) return;
|
||||
ev.stopPropagation();
|
||||
this.reOrderMode = true;
|
||||
}
|
||||
|
||||
private async _exitReOrderMode() {
|
||||
this.reOrderMode = false;
|
||||
}
|
||||
|
||||
private async _createSortable() {
|
||||
const Sortable = await loadSortable();
|
||||
this._sortable = new Sortable(
|
||||
@ -311,6 +343,12 @@ export default class HaAutomationCondition extends LitElement {
|
||||
ha-svg-icon {
|
||||
height: 20px;
|
||||
}
|
||||
ha-alert {
|
||||
display: block;
|
||||
margin-bottom: 16px;
|
||||
border-radius: var(--ha-card-border-radius, 16px);
|
||||
overflow: hidden;
|
||||
}
|
||||
.handle {
|
||||
cursor: move;
|
||||
padding: 12px;
|
||||
|
@ -25,6 +25,7 @@ export class HaLogicalCondition extends LitElement implements ConditionElement {
|
||||
protected render() {
|
||||
return html`
|
||||
<ha-automation-condition
|
||||
nested
|
||||
.conditions=${this.condition.conditions || []}
|
||||
@value-changed=${this._valueChanged}
|
||||
.hass=${this.hass}
|
||||
|
@ -11,7 +11,6 @@ import {
|
||||
mdiPlay,
|
||||
mdiPlayCircleOutline,
|
||||
mdiRenameBox,
|
||||
mdiSort,
|
||||
mdiStopCircleOutline,
|
||||
mdiTransitConnection,
|
||||
} from "@mdi/js";
|
||||
@ -43,9 +42,9 @@ import {
|
||||
AutomationConfig,
|
||||
AutomationEntity,
|
||||
deleteAutomation,
|
||||
getAutomationStateConfig,
|
||||
fetchAutomationFileConfig,
|
||||
getAutomationEditorInitData,
|
||||
getAutomationStateConfig,
|
||||
saveAutomationConfig,
|
||||
showAutomationEditor,
|
||||
triggerAutomationActions,
|
||||
@ -65,7 +64,6 @@ import { showAutomationModeDialog } from "./automation-mode-dialog/show-dialog-a
|
||||
import { showAutomationRenameDialog } from "./automation-rename-dialog/show-dialog-automation-rename";
|
||||
import "./blueprint-automation-editor";
|
||||
import "./manual-automation-editor";
|
||||
import type { HaManualAutomationEditor } from "./manual-automation-editor";
|
||||
|
||||
declare global {
|
||||
interface HTMLElementTagNameMap {
|
||||
@ -79,6 +77,7 @@ declare global {
|
||||
};
|
||||
"ui-mode-not-available": Error;
|
||||
duplicate: undefined;
|
||||
"re-order": undefined;
|
||||
}
|
||||
}
|
||||
|
||||
@ -111,9 +110,6 @@ export class HaAutomationEditor extends KeyboardShortcutMixin(LitElement) {
|
||||
|
||||
@query("ha-yaml-editor", true) private _yamlEditor?: HaYamlEditor;
|
||||
|
||||
@query("manual-automation-editor")
|
||||
private _manualEditor?: HaManualAutomationEditor;
|
||||
|
||||
private _configSubscriptions: Record<
|
||||
string,
|
||||
(config?: AutomationConfig) => void
|
||||
@ -215,18 +211,6 @@ export class HaAutomationEditor extends KeyboardShortcutMixin(LitElement) {
|
||||
</mwc-list-item>
|
||||
`
|
||||
: ""}
|
||||
${this._config && !("use_blueprint" in this._config)
|
||||
? html`<mwc-list-item
|
||||
graphic="icon"
|
||||
@click=${this._toggleReOrderMode}
|
||||
.disabled=${this._readOnly || this._mode === "yaml"}
|
||||
>
|
||||
${this.hass.localize(
|
||||
"ui.panel.config.automation.editor.re_order"
|
||||
)}
|
||||
<ha-svg-icon slot="graphic" .path=${mdiSort}></ha-svg-icon>
|
||||
</mwc-list-item>`
|
||||
: ""}
|
||||
|
||||
<mwc-list-item
|
||||
.disabled=${!this._readOnly && !this.automationId}
|
||||
@ -667,12 +651,6 @@ export class HaAutomationEditor extends KeyboardShortcutMixin(LitElement) {
|
||||
this._mode = "yaml";
|
||||
}
|
||||
|
||||
private _toggleReOrderMode() {
|
||||
if (this._manualEditor) {
|
||||
this._manualEditor.reOrderMode = !this._manualEditor.reOrderMode;
|
||||
}
|
||||
}
|
||||
|
||||
private async _promptAutomationAlias(): Promise<void> {
|
||||
return new Promise((resolve) => {
|
||||
showAutomationRenameDialog(this, {
|
||||
|
@ -6,7 +6,6 @@ import { customElement, property } from "lit/decorators";
|
||||
import { fireEvent } from "../../../common/dom/fire_event";
|
||||
import "../../../components/ha-card";
|
||||
import "../../../components/ha-icon-button";
|
||||
import "../../../components/ha-alert";
|
||||
import {
|
||||
Condition,
|
||||
ManualAutomationConfig,
|
||||
@ -34,9 +33,6 @@ export class HaManualAutomationEditor extends LitElement {
|
||||
|
||||
@property({ attribute: false }) public stateObj?: HassEntity;
|
||||
|
||||
@property({ type: Boolean, reflect: true, attribute: "re-order-mode" })
|
||||
public reOrderMode = false;
|
||||
|
||||
protected render() {
|
||||
return html`
|
||||
${this.disabled
|
||||
@ -61,25 +57,6 @@ export class HaManualAutomationEditor extends LitElement {
|
||||
</ha-alert>
|
||||
`
|
||||
: ""}
|
||||
${this.reOrderMode
|
||||
? html`
|
||||
<ha-alert
|
||||
alert-type="info"
|
||||
.title=${this.hass.localize(
|
||||
"ui.panel.config.automation.editor.re_order_mode.title"
|
||||
)}
|
||||
>
|
||||
${this.hass.localize(
|
||||
"ui.panel.config.automation.editor.re_order_mode.description"
|
||||
)}
|
||||
<mwc-button slot="action" @click=${this._exitReOrderMode}>
|
||||
${this.hass.localize(
|
||||
"ui.panel.config.automation.editor.re_order_mode.exit"
|
||||
)}
|
||||
</mwc-button>
|
||||
</ha-alert>
|
||||
`
|
||||
: ""}
|
||||
${this.config.description
|
||||
? html`<ha-markdown
|
||||
class="description"
|
||||
@ -113,7 +90,6 @@ export class HaManualAutomationEditor extends LitElement {
|
||||
.triggers=${this.config.trigger}
|
||||
@value-changed=${this._triggerChanged}
|
||||
.hass=${this.hass}
|
||||
.reOrderMode=${this.reOrderMode}
|
||||
.disabled=${this.disabled}
|
||||
></ha-automation-trigger>
|
||||
|
||||
@ -143,7 +119,6 @@ export class HaManualAutomationEditor extends LitElement {
|
||||
.conditions=${this.config.condition || []}
|
||||
@value-changed=${this._conditionChanged}
|
||||
.hass=${this.hass}
|
||||
.reOrderMode=${this.reOrderMode}
|
||||
.disabled=${this.disabled}
|
||||
></ha-automation-condition>
|
||||
|
||||
@ -176,16 +151,11 @@ export class HaManualAutomationEditor extends LitElement {
|
||||
@value-changed=${this._actionChanged}
|
||||
.hass=${this.hass}
|
||||
.narrow=${this.narrow}
|
||||
.reOrderMode=${this.reOrderMode}
|
||||
.disabled=${this.disabled}
|
||||
></ha-automation-action>
|
||||
`;
|
||||
}
|
||||
|
||||
private _exitReOrderMode() {
|
||||
this.reOrderMode = !this.reOrderMode;
|
||||
}
|
||||
|
||||
private _triggerChanged(ev: CustomEvent): void {
|
||||
ev.stopPropagation();
|
||||
fireEvent(this, "value-changed", {
|
||||
@ -254,10 +224,6 @@ export class HaManualAutomationEditor extends LitElement {
|
||||
.header a {
|
||||
color: var(--secondary-text-color);
|
||||
}
|
||||
ha-alert {
|
||||
display: block;
|
||||
margin-bottom: 16px;
|
||||
}
|
||||
`,
|
||||
];
|
||||
}
|
||||
|
@ -8,6 +8,7 @@ import {
|
||||
mdiIdentifier,
|
||||
mdiPlayCircleOutline,
|
||||
mdiRenameBox,
|
||||
mdiSort,
|
||||
mdiStopCircleOutline,
|
||||
} from "@mdi/js";
|
||||
import type { UnsubscribeFunc } from "home-assistant-js-websocket";
|
||||
@ -159,9 +160,17 @@ export default class HaAutomationTriggerRow extends LitElement {
|
||||
.path=${mdiRenameBox}
|
||||
></ha-svg-icon>
|
||||
</mwc-list-item>
|
||||
|
||||
<mwc-list-item graphic="icon" .disabled=${this.disabled}>
|
||||
${this.hass.localize(
|
||||
"ui.panel.config.automation.editor.actions.duplicate"
|
||||
"ui.panel.config.automation.editor.triggers.re_order"
|
||||
)}
|
||||
<ha-svg-icon slot="graphic" .path=${mdiSort}></ha-svg-icon>
|
||||
</mwc-list-item>
|
||||
|
||||
<mwc-list-item graphic="icon" .disabled=${this.disabled}>
|
||||
${this.hass.localize(
|
||||
"ui.panel.config.automation.editor.triggers.duplicate"
|
||||
)}
|
||||
<ha-svg-icon
|
||||
slot="graphic"
|
||||
@ -417,24 +426,27 @@ export default class HaAutomationTriggerRow extends LitElement {
|
||||
await this._renameTrigger();
|
||||
break;
|
||||
case 1:
|
||||
fireEvent(this, "duplicate");
|
||||
fireEvent(this, "re-order");
|
||||
break;
|
||||
case 2:
|
||||
fireEvent(this, "duplicate");
|
||||
break;
|
||||
case 3:
|
||||
this._requestShowId = true;
|
||||
this.expand();
|
||||
break;
|
||||
case 3:
|
||||
case 4:
|
||||
this._switchUiMode();
|
||||
this.expand();
|
||||
break;
|
||||
case 4:
|
||||
case 5:
|
||||
this._switchYamlMode();
|
||||
this.expand();
|
||||
break;
|
||||
case 5:
|
||||
case 6:
|
||||
this._onDisable();
|
||||
break;
|
||||
case 6:
|
||||
case 7:
|
||||
this._onDelete();
|
||||
break;
|
||||
}
|
||||
|
@ -43,10 +43,12 @@ export default class HaAutomationTrigger extends LitElement {
|
||||
|
||||
@property() public triggers!: Trigger[];
|
||||
|
||||
@property({ type: Boolean }) public reOrderMode = false;
|
||||
|
||||
@property({ type: Boolean }) public disabled = false;
|
||||
|
||||
@property({ type: Boolean }) public nested = false;
|
||||
|
||||
@property({ type: Boolean }) public reOrderMode = false;
|
||||
|
||||
private _focusLastTriggerOnChange = false;
|
||||
|
||||
private _triggerKeys = new WeakMap<Trigger, string>();
|
||||
@ -55,6 +57,27 @@ export default class HaAutomationTrigger extends LitElement {
|
||||
|
||||
protected render() {
|
||||
return html`
|
||||
${
|
||||
this.reOrderMode && !this.nested
|
||||
? html`
|
||||
<ha-alert
|
||||
alert-type="info"
|
||||
.title=${this.hass.localize(
|
||||
"ui.panel.config.automation.editor.re_order_mode.title"
|
||||
)}
|
||||
>
|
||||
${this.hass.localize(
|
||||
"ui.panel.config.automation.editor.re_order_mode.description_triggers"
|
||||
)}
|
||||
<mwc-button slot="action" @click=${this._exitReOrderMode}>
|
||||
${this.hass.localize(
|
||||
"ui.panel.config.automation.editor.re_order_mode.exit"
|
||||
)}
|
||||
</mwc-button>
|
||||
</ha-alert>
|
||||
`
|
||||
: null
|
||||
}
|
||||
<div class="triggers">
|
||||
${repeat(
|
||||
this.triggers,
|
||||
@ -68,6 +91,7 @@ export default class HaAutomationTrigger extends LitElement {
|
||||
@value-changed=${this._triggerChanged}
|
||||
.hass=${this.hass}
|
||||
.disabled=${this.disabled}
|
||||
@re-order=${this._enterReOrderMode}
|
||||
>
|
||||
${this.reOrderMode
|
||||
? html`
|
||||
@ -148,6 +172,16 @@ export default class HaAutomationTrigger extends LitElement {
|
||||
}
|
||||
}
|
||||
|
||||
private async _enterReOrderMode(ev: CustomEvent) {
|
||||
if (this.nested) return;
|
||||
ev.stopPropagation();
|
||||
this.reOrderMode = true;
|
||||
}
|
||||
|
||||
private async _exitReOrderMode() {
|
||||
this.reOrderMode = false;
|
||||
}
|
||||
|
||||
private async _createSortable() {
|
||||
const Sortable = await loadSortable();
|
||||
this._sortable = new Sortable(
|
||||
@ -283,6 +317,12 @@ export default class HaAutomationTrigger extends LitElement {
|
||||
ha-svg-icon {
|
||||
height: 20px;
|
||||
}
|
||||
ha-alert {
|
||||
display: block;
|
||||
margin-bottom: 16px;
|
||||
border-radius: var(--ha-card-border-radius, 16px);
|
||||
overflow: hidden;
|
||||
}
|
||||
.handle {
|
||||
cursor: move;
|
||||
padding: 12px;
|
||||
|
@ -7,7 +7,6 @@ import {
|
||||
mdiDotsVertical,
|
||||
mdiInformationOutline,
|
||||
mdiPlay,
|
||||
mdiSort,
|
||||
mdiTransitConnection,
|
||||
} from "@mdi/js";
|
||||
import "@polymer/app-layout/app-header/app-header";
|
||||
@ -62,7 +61,6 @@ import { documentationUrl } from "../../../util/documentation-url";
|
||||
import { showToast } from "../../../util/toast";
|
||||
import "./blueprint-script-editor";
|
||||
import "./manual-script-editor";
|
||||
import type { HaManualScriptEditor } from "./manual-script-editor";
|
||||
|
||||
export class HaScriptEditor extends KeyboardShortcutMixin(LitElement) {
|
||||
@property({ attribute: false }) public hass!: HomeAssistant;
|
||||
@ -93,9 +91,6 @@ export class HaScriptEditor extends KeyboardShortcutMixin(LitElement) {
|
||||
|
||||
@query("ha-yaml-editor", true) private _yamlEditor?: HaYamlEditor;
|
||||
|
||||
@query("manual-script-editor")
|
||||
private _manualEditor?: HaManualScriptEditor;
|
||||
|
||||
private _schema = memoizeOne(
|
||||
(
|
||||
hasID: boolean,
|
||||
@ -238,23 +233,6 @@ export class HaScriptEditor extends KeyboardShortcutMixin(LitElement) {
|
||||
</a>
|
||||
`
|
||||
: ""}
|
||||
${this._config && !("use_blueprint" in this._config)
|
||||
? html`
|
||||
<mwc-list-item
|
||||
aria-label=${this.hass.localize(
|
||||
"ui.panel.config.automation.editor.re_order"
|
||||
)}
|
||||
graphic="icon"
|
||||
.disabled=${this._readOnly || this._mode !== "gui"}
|
||||
@click=${this._toggleReOrderMode}
|
||||
>
|
||||
${this.hass.localize(
|
||||
"ui.panel.config.automation.editor.re_order"
|
||||
)}
|
||||
<ha-svg-icon slot="graphic" .path=${mdiSort}></ha-svg-icon>
|
||||
</mwc-list-item>
|
||||
`
|
||||
: ""}
|
||||
|
||||
<li divider role="separator"></li>
|
||||
|
||||
@ -801,12 +779,6 @@ export class HaScriptEditor extends KeyboardShortcutMixin(LitElement) {
|
||||
this._mode = "yaml";
|
||||
}
|
||||
|
||||
private _toggleReOrderMode() {
|
||||
if (this._manualEditor) {
|
||||
this._manualEditor.reOrderMode = !this._manualEditor.reOrderMode;
|
||||
}
|
||||
}
|
||||
|
||||
private async _saveScript(): Promise<void> {
|
||||
if (this._idError) {
|
||||
showToast(this, {
|
||||
|
@ -3,7 +3,6 @@ import { mdiHelpCircle } from "@mdi/js";
|
||||
import { css, CSSResultGroup, html, LitElement } from "lit";
|
||||
import { customElement, property } from "lit/decorators";
|
||||
import { fireEvent } from "../../../common/dom/fire_event";
|
||||
import "../../../components/ha-alert";
|
||||
import "../../../components/ha-card";
|
||||
import "../../../components/ha-icon-button";
|
||||
import { Action, ScriptConfig } from "../../../data/script";
|
||||
@ -24,9 +23,6 @@ export class HaManualScriptEditor extends LitElement {
|
||||
|
||||
@property({ attribute: false }) public config!: ScriptConfig;
|
||||
|
||||
@property({ type: Boolean, reflect: true, attribute: "re-order-mode" })
|
||||
public reOrderMode = false;
|
||||
|
||||
protected render() {
|
||||
return html`
|
||||
${this.disabled
|
||||
@ -37,26 +33,6 @@ export class HaManualScriptEditor extends LitElement {
|
||||
</mwc-button>
|
||||
</ha-alert>`
|
||||
: ""}
|
||||
${this.reOrderMode
|
||||
? html`
|
||||
<ha-alert
|
||||
alert-type="info"
|
||||
.title=${this.hass.localize(
|
||||
"ui.panel.config.automation.editor.re_order_mode.title"
|
||||
)}
|
||||
>
|
||||
${this.hass.localize(
|
||||
"ui.panel.config.automation.editor.re_order_mode.description"
|
||||
)}
|
||||
<mwc-button slot="action" @click=${this._exitReOrderMode}>
|
||||
${this.hass.localize(
|
||||
"ui.panel.config.automation.editor.re_order_mode.exit"
|
||||
)}
|
||||
</mwc-button>
|
||||
</ha-alert>
|
||||
`
|
||||
: ""}
|
||||
|
||||
<div class="header">
|
||||
<h2 id="sequence-heading" class="name">
|
||||
${this.hass.localize("ui.panel.config.script.editor.sequence")}
|
||||
@ -83,7 +59,6 @@ export class HaManualScriptEditor extends LitElement {
|
||||
.hass=${this.hass}
|
||||
.narrow=${this.narrow}
|
||||
.disabled=${this.disabled}
|
||||
.reOrderMode=${this.reOrderMode}
|
||||
></ha-automation-action>
|
||||
`;
|
||||
}
|
||||
@ -95,10 +70,6 @@ export class HaManualScriptEditor extends LitElement {
|
||||
});
|
||||
}
|
||||
|
||||
private _exitReOrderMode() {
|
||||
this.reOrderMode = !this.reOrderMode;
|
||||
}
|
||||
|
||||
private _duplicate() {
|
||||
fireEvent(this, "duplicate");
|
||||
}
|
||||
@ -134,10 +105,6 @@ export class HaManualScriptEditor extends LitElement {
|
||||
.header a {
|
||||
color: var(--secondary-text-color);
|
||||
}
|
||||
ha-alert {
|
||||
display: block;
|
||||
margin-bottom: 16px;
|
||||
}
|
||||
`,
|
||||
];
|
||||
}
|
||||
|
@ -1884,7 +1884,9 @@
|
||||
"re_order": "Re-order",
|
||||
"re_order_mode": {
|
||||
"title": "Re-order mode",
|
||||
"description": "You are in re-order mode, you can re-order your triggers, conditions and actions.",
|
||||
"description_triggers": "You are in re-order mode, you can re-order your triggers.",
|
||||
"description_conditions": "You are in re-order mode, you can re-order your conditions.",
|
||||
"description_actions": "You are in re-order mode, you can re-order your actions.",
|
||||
"exit": "Exit"
|
||||
},
|
||||
"description": {
|
||||
@ -1922,6 +1924,7 @@
|
||||
"id": "Trigger ID",
|
||||
"edit_id": "Edit ID",
|
||||
"duplicate": "[%key:ui::common::duplicate%]",
|
||||
"re_order": "Re-order",
|
||||
"rename": "Rename",
|
||||
"change_alias": "Rename trigger",
|
||||
"alias": "Trigger name",
|
||||
@ -2043,6 +2046,7 @@
|
||||
"invalid_condition": "Invalid condition configuration",
|
||||
"test_failed": "Error occurred while testing condition",
|
||||
"duplicate": "[%key:ui::common::duplicate%]",
|
||||
"re_order": "[%key:ui::panel::config::automation::editor::triggers::re_order%]",
|
||||
"rename": "[%key:ui::panel::config::automation::editor::triggers::rename%]",
|
||||
"change_alias": "Rename condition",
|
||||
"alias": "Condition name",
|
||||
@ -2135,6 +2139,7 @@
|
||||
"run_action_error": "Error running action",
|
||||
"run_action_success": "Action run successfully",
|
||||
"duplicate": "[%key:ui::common::duplicate%]",
|
||||
"re_order": "[%key:ui::panel::config::automation::editor::triggers::re_order%]",
|
||||
"rename": "[%key:ui::panel::config::automation::editor::triggers::rename%]",
|
||||
"change_alias": "Rename action",
|
||||
"alias": "Action name",
|
||||
|
Loading…
x
Reference in New Issue
Block a user