@@ -72,7 +72,8 @@
@@ -87,11 +88,14 @@
return {
hass: Object,
- flowId: {
+ _flowId: {
type: String,
value: null,
},
- userCreatedFlow: Boolean,
+ /*
+ * The step of the current selected flow, if available.
+ */
+ _flowStep: Object,
/**
* Existing entries.
@@ -104,7 +108,7 @@
*/
_progress: Array,
- handlers: Array,
+ _handlers: Array,
};
}
@@ -116,13 +120,20 @@
_createFlow(ev) {
this.hass.callApi('post', 'config/config_entries/flow', { domain: ev.model.item })
.then((flow) => {
- this.userCreatedFlow = true;
- this.flowId = flow.flow_id;
+ this._userCreatedFlow = true;
+ this.setProperties({
+ _flowStep: flow,
+ _flowId: flow.flow_id,
+ });
});
}
_continueFlow(ev) {
- this.flowId = ev.model.item.flow_id;
+ this._userCreatedFlow = false;
+ this.setProperties({
+ _flowId: ev.model.item.flow_id,
+ _flowStep: null,
+ });
}
_removeEntry(ev) {
@@ -145,18 +156,18 @@
this._loadData();
// Remove a flow if it was not finished and was started by the user
- } else if (this.userCreatedFlow) {
- this.hass.callApi('delete', `config/config_entries/flow/${this.flowId}`);
+ } else if (this._userCreatedFlow) {
+ this.hass.callApi('delete', `config/config_entries/flow/${this._flowId}`);
}
- this.flowId = null;
- this.userCreatedFlow = false;
+
+ this._flowId = null;
}
_loadData() {
this._loadEntries();
this._loadDiscovery();
this.hass.callApi('get', 'config/config_entries/flow_handlers')
- .then((handlers) => { this.handlers = handlers; });
+ .then((handlers) => { this._handlers = handlers; });
}
_loadEntries() {
diff --git a/panels/config/config-entries/ha-config-flow.html b/panels/config/config-entries/ha-config-flow.html
index fd94400949..82060d10ce 100644
--- a/panels/config/config-entries/ha-config-flow.html
+++ b/panels/config/config-entries/ha-config-flow.html
@@ -25,7 +25,7 @@
@@ -91,11 +91,17 @@ class HaConfigFlow extends window.hassMixins.EventsMixin(Polymer.Element) {
static get properties() {
return {
hass: Object,
- step: Object,
+ step: {
+ type: Object,
+ notify: true,
+ },
flowId: {
type: String,
observer: '_flowIdChanged'
},
+ /*
+ * Store user entered data.
+ */
stepData: Object,
};
}
@@ -107,10 +113,28 @@ class HaConfigFlow extends window.hassMixins.EventsMixin(Polymer.Element) {
this._submitStep();
}
});
+ // Fix for overlay showing on top of dialog.
+ this.$.dialog.addEventListener('iron-overlay-opened', (ev) => {
+ if (ev.target.withBackdrop) {
+ ev.target.parentNode.insertBefore(ev.target.backdropElement, ev.target);
+ }
+ });
}
_flowIdChanged(flowId) {
- if (!flowId) return;
+ if (!flowId) {
+ this.setProperties({
+ step: null,
+ stepData: {},
+ });
+ return;
+
+ // Check if parent passed in step data to use.
+ } else if (this.step) {
+ this._processStep(this.step);
+ return;
+ }
+
this.hass.callApi('get', `config/config_entries/flow/${flowId}`)
.then((step) => {
this._processStep(step);
@@ -146,7 +170,7 @@ class HaConfigFlow extends window.hassMixins.EventsMixin(Polymer.Element) {
_openedChanged(ev) {
// Closed dialog by clicking on the overlay
- if (!ev.detail.value) {
+ if (this.step && !ev.detail.value) {
this.fire('flow-closed', {
flowFinished: ['success', 'abort'].includes(this.step.type)
});
diff --git a/panels/config/config-entries/ha-form.html b/panels/config/config-entries/ha-form.html
index 71f26d6a52..04bc85080c 100644
--- a/panels/config/config-entries/ha-form.html
+++ b/panels/config/config-entries/ha-form.html
@@ -3,6 +3,9 @@
+
+
+
@@ -69,11 +72,18 @@
-
-
+
+
+
+ [[item]]
+
+
+