From 873ca9b0ff293ed2ff3bca09fa7f2115848c786a Mon Sep 17 00:00:00 2001 From: ludeeus Date: Sat, 28 Dec 2019 23:49:53 +0000 Subject: [PATCH 1/5] Adds confirmation handling --- src/components/buttons/ha-call-api-button.js | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/src/components/buttons/ha-call-api-button.js b/src/components/buttons/ha-call-api-button.js index 59c7c8e748f5..7e147fdc8996 100644 --- a/src/components/buttons/ha-call-api-button.js +++ b/src/components/buttons/ha-call-api-button.js @@ -2,6 +2,7 @@ import { LitElement, html } from "lit-element"; import "./ha-progress-button"; import { fireEvent } from "../../common/dom/fire_event"; +import { showConfirmationDialog } from "../../dialogs/confirmation/show-dialog-confirmation"; class HaCallApiButton extends LitElement { render() { @@ -31,6 +32,7 @@ class HaCallApiButton extends LitElement { method: String, data: {}, disabled: Boolean, + confirmation: String, }; } @@ -38,7 +40,7 @@ class HaCallApiButton extends LitElement { return this.renderRoot.querySelector("ha-progress-button"); } - async _buttonTapped() { + async callApi() { this.progress = true; const eventData = { method: this.method, @@ -61,6 +63,17 @@ class HaCallApiButton extends LitElement { fireEvent(this, "hass-api-called", eventData); } + + async _buttonTapped() { + if (this.confirmation) { + showConfirmationDialog(this, { + text: this.confirmation, + confirm: async () => await this.callApi(), + }); + } else { + await this.callApi(); + } + } } customElements.define("ha-call-api-button", HaCallApiButton); From bc68f02de97ead4d0509feac74c301abb4ace250 Mon Sep 17 00:00:00 2001 From: ludeeus Date: Sat, 28 Dec 2019 23:50:19 +0000 Subject: [PATCH 2/5] Adds confirm dialog to reset configuration button --- hassio/src/addon-view/hassio-addon-config.js | 1 + 1 file changed, 1 insertion(+) diff --git a/hassio/src/addon-view/hassio-addon-config.js b/hassio/src/addon-view/hassio-addon-config.js index a4061b88997d..ee016a16deec 100644 --- a/hassio/src/addon-view/hassio-addon-config.js +++ b/hassio/src/addon-view/hassio-addon-config.js @@ -45,6 +45,7 @@ class HassioAddonConfig extends PolymerElement {
Date: Thu, 2 Jan 2020 16:02:44 +0100 Subject: [PATCH 3/5] Update src/components/buttons/ha-call-api-button.js Co-Authored-By: Bram Kragten --- src/components/buttons/ha-call-api-button.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/buttons/ha-call-api-button.js b/src/components/buttons/ha-call-api-button.js index 7e147fdc8996..cb84a63a6c53 100644 --- a/src/components/buttons/ha-call-api-button.js +++ b/src/components/buttons/ha-call-api-button.js @@ -68,7 +68,7 @@ class HaCallApiButton extends LitElement { if (this.confirmation) { showConfirmationDialog(this, { text: this.confirmation, - confirm: async () => await this.callApi(), + confirm: async () => await this._callApi(), }); } else { await this.callApi(); From cee6b8debba3480fc7066098710cd35e60b8aab4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Joakim=20S=C3=B8rensen?= Date: Thu, 2 Jan 2020 16:02:55 +0100 Subject: [PATCH 4/5] Update src/components/buttons/ha-call-api-button.js Co-Authored-By: Bram Kragten --- src/components/buttons/ha-call-api-button.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/buttons/ha-call-api-button.js b/src/components/buttons/ha-call-api-button.js index cb84a63a6c53..6cab29dcde40 100644 --- a/src/components/buttons/ha-call-api-button.js +++ b/src/components/buttons/ha-call-api-button.js @@ -71,7 +71,7 @@ class HaCallApiButton extends LitElement { confirm: async () => await this._callApi(), }); } else { - await this.callApi(); + await this._callApi(); } } } From 94ac6135e6d0e35b2981249c4c1fa14bc4d2f643 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Joakim=20S=C3=B8rensen?= Date: Thu, 2 Jan 2020 16:03:08 +0100 Subject: [PATCH 5/5] Update src/components/buttons/ha-call-api-button.js Co-Authored-By: Bram Kragten --- src/components/buttons/ha-call-api-button.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/buttons/ha-call-api-button.js b/src/components/buttons/ha-call-api-button.js index 6cab29dcde40..c4473b603a5b 100644 --- a/src/components/buttons/ha-call-api-button.js +++ b/src/components/buttons/ha-call-api-button.js @@ -40,7 +40,7 @@ class HaCallApiButton extends LitElement { return this.renderRoot.querySelector("ha-progress-button"); } - async callApi() { + async _callApi() { this.progress = true; const eventData = { method: this.method,