mirror of
https://github.com/home-assistant/frontend.git
synced 2025-11-08 02:19:43 +00:00
Enable drag and drop on mobile for automations (#26805)
This commit is contained in:
@@ -6,7 +6,6 @@ import { customElement, property, queryAll, state } from "lit/decorators";
|
|||||||
import { repeat } from "lit/directives/repeat";
|
import { repeat } from "lit/directives/repeat";
|
||||||
import { storage } from "../../../../common/decorators/storage";
|
import { storage } from "../../../../common/decorators/storage";
|
||||||
import { fireEvent } from "../../../../common/dom/fire_event";
|
import { fireEvent } from "../../../../common/dom/fire_event";
|
||||||
import { listenMediaQuery } from "../../../../common/dom/media_query";
|
|
||||||
import { nextRender } from "../../../../common/util/render-status";
|
import { nextRender } from "../../../../common/util/render-status";
|
||||||
import "../../../../components/ha-button";
|
import "../../../../components/ha-button";
|
||||||
import "../../../../components/ha-sortable";
|
import "../../../../components/ha-sortable";
|
||||||
@@ -46,8 +45,6 @@ export default class HaAutomationAction extends LitElement {
|
|||||||
@property({ type: Boolean, attribute: "sidebar" }) public optionsInSidebar =
|
@property({ type: Boolean, attribute: "sidebar" }) public optionsInSidebar =
|
||||||
false;
|
false;
|
||||||
|
|
||||||
@state() private _showReorder = false;
|
|
||||||
|
|
||||||
@state() private _rowSortSelected?: number;
|
@state() private _rowSortSelected?: number;
|
||||||
|
|
||||||
@state()
|
@state()
|
||||||
@@ -68,27 +65,12 @@ export default class HaAutomationAction extends LitElement {
|
|||||||
|
|
||||||
private _actionKeys = new WeakMap<Action, string>();
|
private _actionKeys = new WeakMap<Action, string>();
|
||||||
|
|
||||||
private _unsubMql?: () => void;
|
|
||||||
|
|
||||||
public connectedCallback() {
|
|
||||||
super.connectedCallback();
|
|
||||||
this._unsubMql = listenMediaQuery("(min-width: 600px)", (matches) => {
|
|
||||||
this._showReorder = matches;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
public disconnectedCallback() {
|
|
||||||
super.disconnectedCallback();
|
|
||||||
this._unsubMql?.();
|
|
||||||
this._unsubMql = undefined;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected render() {
|
protected render() {
|
||||||
return html`
|
return html`
|
||||||
<ha-sortable
|
<ha-sortable
|
||||||
handle-selector=".handle"
|
handle-selector=".handle"
|
||||||
draggable-selector="ha-automation-action-row"
|
draggable-selector="ha-automation-action-row"
|
||||||
.disabled=${!this._showReorder || this.disabled}
|
.disabled=${this.disabled}
|
||||||
group="actions"
|
group="actions"
|
||||||
invert-swap
|
invert-swap
|
||||||
@item-moved=${this._actionMoved}
|
@item-moved=${this._actionMoved}
|
||||||
@@ -120,7 +102,7 @@ export default class HaAutomationAction extends LitElement {
|
|||||||
.sortSelected=${this._rowSortSelected === idx}
|
.sortSelected=${this._rowSortSelected === idx}
|
||||||
@stop-sort-selection=${this._stopSortSelection}
|
@stop-sort-selection=${this._stopSortSelection}
|
||||||
>
|
>
|
||||||
${this._showReorder && !this.disabled
|
${!this.disabled
|
||||||
? html`
|
? html`
|
||||||
<div
|
<div
|
||||||
tabindex="0"
|
tabindex="0"
|
||||||
|
|||||||
@@ -6,7 +6,6 @@ import { customElement, property, queryAll, state } from "lit/decorators";
|
|||||||
import { repeat } from "lit/directives/repeat";
|
import { repeat } from "lit/directives/repeat";
|
||||||
import { storage } from "../../../../common/decorators/storage";
|
import { storage } from "../../../../common/decorators/storage";
|
||||||
import { fireEvent } from "../../../../common/dom/fire_event";
|
import { fireEvent } from "../../../../common/dom/fire_event";
|
||||||
import { listenMediaQuery } from "../../../../common/dom/media_query";
|
|
||||||
import { nextRender } from "../../../../common/util/render-status";
|
import { nextRender } from "../../../../common/util/render-status";
|
||||||
import "../../../../components/ha-button";
|
import "../../../../components/ha-button";
|
||||||
import "../../../../components/ha-button-menu";
|
import "../../../../components/ha-button-menu";
|
||||||
@@ -44,8 +43,6 @@ export default class HaAutomationCondition extends LitElement {
|
|||||||
@property({ type: Boolean, attribute: "sidebar" }) public optionsInSidebar =
|
@property({ type: Boolean, attribute: "sidebar" }) public optionsInSidebar =
|
||||||
false;
|
false;
|
||||||
|
|
||||||
@state() private _showReorder = false;
|
|
||||||
|
|
||||||
@state() private _rowSortSelected?: number;
|
@state() private _rowSortSelected?: number;
|
||||||
|
|
||||||
@state()
|
@state()
|
||||||
@@ -66,21 +63,6 @@ export default class HaAutomationCondition extends LitElement {
|
|||||||
|
|
||||||
private _conditionKeys = new WeakMap<Condition, string>();
|
private _conditionKeys = new WeakMap<Condition, string>();
|
||||||
|
|
||||||
private _unsubMql?: () => void;
|
|
||||||
|
|
||||||
public connectedCallback() {
|
|
||||||
super.connectedCallback();
|
|
||||||
this._unsubMql = listenMediaQuery("(min-width: 600px)", (matches) => {
|
|
||||||
this._showReorder = matches;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
public disconnectedCallback() {
|
|
||||||
super.disconnectedCallback();
|
|
||||||
this._unsubMql?.();
|
|
||||||
this._unsubMql = undefined;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected updated(changedProperties: PropertyValues) {
|
protected updated(changedProperties: PropertyValues) {
|
||||||
if (!changedProperties.has("conditions")) {
|
if (!changedProperties.has("conditions")) {
|
||||||
return;
|
return;
|
||||||
@@ -165,7 +147,7 @@ export default class HaAutomationCondition extends LitElement {
|
|||||||
<ha-sortable
|
<ha-sortable
|
||||||
handle-selector=".handle"
|
handle-selector=".handle"
|
||||||
draggable-selector="ha-automation-condition-row"
|
draggable-selector="ha-automation-condition-row"
|
||||||
.disabled=${!this._showReorder || this.disabled}
|
.disabled=${this.disabled}
|
||||||
group="conditions"
|
group="conditions"
|
||||||
invert-swap
|
invert-swap
|
||||||
@item-moved=${this._conditionMoved}
|
@item-moved=${this._conditionMoved}
|
||||||
@@ -198,7 +180,7 @@ export default class HaAutomationCondition extends LitElement {
|
|||||||
.sortSelected=${this._rowSortSelected === idx}
|
.sortSelected=${this._rowSortSelected === idx}
|
||||||
@stop-sort-selection=${this._stopSortSelection}
|
@stop-sort-selection=${this._stopSortSelection}
|
||||||
>
|
>
|
||||||
${this._showReorder && !this.disabled
|
${!this.disabled
|
||||||
? html`
|
? html`
|
||||||
<div
|
<div
|
||||||
tabindex="0"
|
tabindex="0"
|
||||||
|
|||||||
@@ -6,7 +6,6 @@ import { customElement, property, queryAll, state } from "lit/decorators";
|
|||||||
import { repeat } from "lit/directives/repeat";
|
import { repeat } from "lit/directives/repeat";
|
||||||
import { storage } from "../../../../common/decorators/storage";
|
import { storage } from "../../../../common/decorators/storage";
|
||||||
import { fireEvent } from "../../../../common/dom/fire_event";
|
import { fireEvent } from "../../../../common/dom/fire_event";
|
||||||
import { listenMediaQuery } from "../../../../common/dom/media_query";
|
|
||||||
import { nextRender } from "../../../../common/util/render-status";
|
import { nextRender } from "../../../../common/util/render-status";
|
||||||
import "../../../../components/ha-button";
|
import "../../../../components/ha-button";
|
||||||
import "../../../../components/ha-sortable";
|
import "../../../../components/ha-sortable";
|
||||||
@@ -35,8 +34,6 @@ export default class HaAutomationOption extends LitElement {
|
|||||||
@property({ type: Boolean, attribute: "show-default" })
|
@property({ type: Boolean, attribute: "show-default" })
|
||||||
public showDefaultActions = false;
|
public showDefaultActions = false;
|
||||||
|
|
||||||
@state() private _showReorder = false;
|
|
||||||
|
|
||||||
@state() private _rowSortSelected?: number;
|
@state() private _rowSortSelected?: number;
|
||||||
|
|
||||||
@state()
|
@state()
|
||||||
@@ -57,27 +54,12 @@ export default class HaAutomationOption extends LitElement {
|
|||||||
|
|
||||||
private _optionsKeys = new WeakMap<Option, string>();
|
private _optionsKeys = new WeakMap<Option, string>();
|
||||||
|
|
||||||
private _unsubMql?: () => void;
|
|
||||||
|
|
||||||
public connectedCallback() {
|
|
||||||
super.connectedCallback();
|
|
||||||
this._unsubMql = listenMediaQuery("(min-width: 600px)", (matches) => {
|
|
||||||
this._showReorder = matches;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
public disconnectedCallback() {
|
|
||||||
super.disconnectedCallback();
|
|
||||||
this._unsubMql?.();
|
|
||||||
this._unsubMql = undefined;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected render() {
|
protected render() {
|
||||||
return html`
|
return html`
|
||||||
<ha-sortable
|
<ha-sortable
|
||||||
handle-selector=".handle"
|
handle-selector=".handle"
|
||||||
draggable-selector="ha-automation-option-row"
|
draggable-selector="ha-automation-option-row"
|
||||||
.disabled=${!this._showReorder || this.disabled}
|
.disabled=${this.disabled}
|
||||||
group="options"
|
group="options"
|
||||||
invert-swap
|
invert-swap
|
||||||
@item-moved=${this._optionMoved}
|
@item-moved=${this._optionMoved}
|
||||||
@@ -107,7 +89,7 @@ export default class HaAutomationOption extends LitElement {
|
|||||||
.sortSelected=${this._rowSortSelected === idx}
|
.sortSelected=${this._rowSortSelected === idx}
|
||||||
@stop-sort-selection=${this._stopSortSelection}
|
@stop-sort-selection=${this._stopSortSelection}
|
||||||
>
|
>
|
||||||
${this._showReorder && !this.disabled
|
${!this.disabled
|
||||||
? html`
|
? html`
|
||||||
<div
|
<div
|
||||||
tabindex="0"
|
tabindex="0"
|
||||||
|
|||||||
@@ -1,11 +1,12 @@
|
|||||||
import { customElement, property, state } from "lit/decorators";
|
|
||||||
import { css, type CSSResultGroup, html, LitElement, nothing } from "lit";
|
import { css, type CSSResultGroup, html, LitElement, nothing } from "lit";
|
||||||
import type { HassDialog } from "../../../../dialogs/make-dialog-manager";
|
import { customElement, property, state } from "lit/decorators";
|
||||||
import type { HomeAssistant } from "../../../../types";
|
|
||||||
import { fireEvent } from "../../../../common/dom/fire_event";
|
import { fireEvent } from "../../../../common/dom/fire_event";
|
||||||
import { haStyle, haStyleDialog } from "../../../../resources/styles";
|
import "../../../../components/ha-button";
|
||||||
import { createCloseHeading } from "../../../../components/ha-dialog";
|
import { createCloseHeading } from "../../../../components/ha-dialog";
|
||||||
import "../trigger/ha-automation-trigger-row";
|
import "../../../../components/ha-yaml-editor";
|
||||||
|
import type { HassDialog } from "../../../../dialogs/make-dialog-manager";
|
||||||
|
import { haStyle, haStyleDialog } from "../../../../resources/styles";
|
||||||
|
import type { HomeAssistant } from "../../../../types";
|
||||||
import type { PasteReplaceDialogParams } from "./show-dialog-paste-replace";
|
import type { PasteReplaceDialogParams } from "./show-dialog-paste-replace";
|
||||||
|
|
||||||
@customElement("ha-dialog-paste-replace")
|
@customElement("ha-dialog-paste-replace")
|
||||||
|
|||||||
@@ -6,7 +6,6 @@ import { customElement, property, state } from "lit/decorators";
|
|||||||
import { repeat } from "lit/directives/repeat";
|
import { repeat } from "lit/directives/repeat";
|
||||||
import { storage } from "../../../../common/decorators/storage";
|
import { storage } from "../../../../common/decorators/storage";
|
||||||
import { fireEvent } from "../../../../common/dom/fire_event";
|
import { fireEvent } from "../../../../common/dom/fire_event";
|
||||||
import { listenMediaQuery } from "../../../../common/dom/media_query";
|
|
||||||
import { nextRender } from "../../../../common/util/render-status";
|
import { nextRender } from "../../../../common/util/render-status";
|
||||||
import "../../../../components/ha-button";
|
import "../../../../components/ha-button";
|
||||||
import "../../../../components/ha-button-menu";
|
import "../../../../components/ha-button-menu";
|
||||||
@@ -45,8 +44,6 @@ export default class HaAutomationTrigger extends LitElement {
|
|||||||
|
|
||||||
@property({ type: Boolean }) public root = false;
|
@property({ type: Boolean }) public root = false;
|
||||||
|
|
||||||
@state() private _showReorder = false;
|
|
||||||
|
|
||||||
@state() private _rowSortSelected?: number;
|
@state() private _rowSortSelected?: number;
|
||||||
|
|
||||||
@state()
|
@state()
|
||||||
@@ -64,27 +61,12 @@ export default class HaAutomationTrigger extends LitElement {
|
|||||||
|
|
||||||
private _triggerKeys = new WeakMap<Trigger, string>();
|
private _triggerKeys = new WeakMap<Trigger, string>();
|
||||||
|
|
||||||
private _unsubMql?: () => void;
|
|
||||||
|
|
||||||
public connectedCallback() {
|
|
||||||
super.connectedCallback();
|
|
||||||
this._unsubMql = listenMediaQuery("(min-width: 600px)", (matches) => {
|
|
||||||
this._showReorder = matches;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
public disconnectedCallback() {
|
|
||||||
super.disconnectedCallback();
|
|
||||||
this._unsubMql?.();
|
|
||||||
this._unsubMql = undefined;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected render() {
|
protected render() {
|
||||||
return html`
|
return html`
|
||||||
<ha-sortable
|
<ha-sortable
|
||||||
handle-selector=".handle"
|
handle-selector=".handle"
|
||||||
draggable-selector="ha-automation-trigger-row"
|
draggable-selector="ha-automation-trigger-row"
|
||||||
.disabled=${!this._showReorder || this.disabled}
|
.disabled=${this.disabled}
|
||||||
group="triggers"
|
group="triggers"
|
||||||
invert-swap
|
invert-swap
|
||||||
@item-moved=${this._triggerMoved}
|
@item-moved=${this._triggerMoved}
|
||||||
@@ -115,7 +97,7 @@ export default class HaAutomationTrigger extends LitElement {
|
|||||||
.sortSelected=${this._rowSortSelected === idx}
|
.sortSelected=${this._rowSortSelected === idx}
|
||||||
@stop-sort-selection=${this._stopSortSelection}
|
@stop-sort-selection=${this._stopSortSelection}
|
||||||
>
|
>
|
||||||
${this._showReorder && !this.disabled
|
${!this.disabled
|
||||||
? html`
|
? html`
|
||||||
<div
|
<div
|
||||||
tabindex="0"
|
tabindex="0"
|
||||||
|
|||||||
Reference in New Issue
Block a user