diff --git a/panels/automation/ha-automation-editor.html b/panels/automation/ha-automation-editor.html index 69e2f02ffa..c6eb04579a 100644 --- a/panels/automation/ha-automation-editor.html +++ b/panels/automation/ha-automation-editor.html @@ -228,7 +228,8 @@ Polymer({ !confirm('You have unsaved changes. Are you sure you want to leave?')) { return; } - this.fire('hass-automation-picked', { id: null }); + history.pushState(null, null, '/automation'); + this.fire('location-changed'); }, _updateComponent: function () { @@ -247,9 +248,8 @@ Polymer({ this.dirty = false; if (this.creatingNew) { - this.fire('hass-automation-picked', { - id: id, - }); + history.pushState(null, null, '/automation/edit/' + id); + this.fire('location-changed'); } }.bind(this), function (errors) { this.errors = errors.body.message; diff --git a/panels/automation/ha-automation-picker.html b/panels/automation/ha-automation-picker.html index f1669f4eac..e7f20ae4b3 100644 --- a/panels/automation/ha-automation-picker.html +++ b/panels/automation/ha-automation-picker.html @@ -125,13 +125,14 @@ Polymer({ }, automationTapped: function (ev) { - this.fire('hass-automation-picked', { - id: this.automations[ev.model.index].attributes.id, - }); + history.pushState( + null, null, '/automation/edit/' + this.automations[ev.model.index].attributes.id); + this.fire('location-changed'); }, addAutomation: function () { - this.fire('hass-create-automation'); + history.pushState(null, null, '/automation/new'); + this.fire('location-changed'); }, computeName: function (automation) { diff --git a/panels/automation/ha-panel-automation.html b/panels/automation/ha-panel-automation.html index e565ef2b9c..84240f7aac 100644 --- a/panels/automation/ha-panel-automation.html +++ b/panels/automation/ha-panel-automation.html @@ -1,5 +1,6 @@ + @@ -12,6 +13,17 @@ height: 100%; } + + @@ -30,7 +42,7 @@ hass='[[hass]]' automation='[[automation]]' is-wide='[[isWide]]' - creating-new='[[creatingNew]]' + creating-new='[[_creatingNew]]' > @@ -41,73 +53,49 @@ Polymer({ is: 'ha-panel-automation', properties: { - hass: { - type: Object, - }, - - narrow: { - type: Boolean, - }, - - showMenu: { - type: Boolean, - value: false, - }, + hass: Object, + narrow: Boolean, + showMenu: Boolean, + route: Object, + _routeData: Object, + _routeMatches: Boolean, + _creatingNew: Boolean, + _edittingAddon: Boolean, automations: { type: Array, computed: 'computeAutomations(hass)', }, - automationId: { - type: String, - value: null, - }, - automation: { type: Object, - computed: 'computeAutomation(automations, automationId, creatingNew)', + computed: 'computeAutomation(automations, _edittingAddon, _routeData)', }, - wide: { - type: Boolean, - }, - - wideSidebar: { - type: Boolean, - }, + wide: Boolean, + wideSidebar: Boolean, isWide: { type: Boolean, computed: 'computeIsWide(showMenu, wideSidebar, wide)' }, - creatingNew: { - type: Boolean, - value: false, - }, - showEditor: { type: Boolean, - computed: 'computeShowEditor(automation, creatingNew)', + computed: 'computeShowEditor(_edittingAddon, _creatingNew)', } }, - listeners: { - 'hass-automation-picked': 'automationPicked', - 'hass-create-automation': 'createAutomation', - }, - computeIsWide: function (showMenu, wideSidebar, wide) { return showMenu ? wideSidebar : wide; }, - computeAutomation: function (automations, automationId, creatingNew) { - if (creatingNew || !automations) { + computeAutomation: function (automations, edittingAddon, routeData) { + if (!automations || !edittingAddon) { return null; } for (var i = 0; i < automations.length; i++) { - if (automations[i].attributes.id === automationId) { + if (automations[i].attributes.id === routeData.automation) { return automations[i]; } } @@ -142,19 +130,8 @@ Polymer({ }); }, - computeShowEditor: function (automation, creatingNew) { - return creatingNew || automation; - }, - - automationPicked: function (ev) { - this.automationId = ev.detail.id; - if (this.creatingNew) { - this.creatingNew = false; - } - }, - - createAutomation: function () { - this.creatingNew = true; + computeShowEditor: function (_edittingAddon, _creatingNew) { + return _creatingNew || _edittingAddon; }, }); diff --git a/panels/hassio/addon-store/hassio-addon-repository.html b/panels/hassio/addon-store/hassio-addon-repository.html index 520b5f465a..920e0c0f50 100644 --- a/panels/hassio/addon-store/hassio-addon-repository.html +++ b/panels/hassio/addon-store/hassio-addon-repository.html @@ -52,12 +52,6 @@ Polymer({ addons: { type: Array, }, - - selectedAddon: { - type: String, - value: null, - notify: true, - }, }, computeShowIntro: function (repo) { @@ -74,8 +68,8 @@ Polymer({ }, addonTapped: function (ev) { - this.selectedAddon = this.addons[ev.model.index].slug; - ev.target.blur(); + history.pushState(null, null, '/hassio/store/' + this.addons[ev.model.index].slug); + this.fire('location-changed'); }, }); diff --git a/panels/hassio/addon-store/hassio-addon-store-overview.html b/panels/hassio/addon-store/hassio-addon-store-overview.html index 1343e49bcb..4df3c2a0b8 100644 --- a/panels/hassio/addon-store/hassio-addon-store-overview.html +++ b/panels/hassio/addon-store/hassio-addon-store-overview.html @@ -98,8 +98,7 @@ Polymer({ }, backTapped: function () { - // Closes the store. Needs to be done with app-route. - this.fire('hassio-select-addon', { addon: null }); + history.back(); }, }); diff --git a/panels/hassio/addon-store/hassio-addon-store-view.html b/panels/hassio/addon-store/hassio-addon-store-view.html index 992c50f9a0..f74754da80 100644 --- a/panels/hassio/addon-store/hassio-addon-store-view.html +++ b/panels/hassio/addon-store/hassio-addon-store-view.html @@ -128,11 +128,12 @@ Polymer({ }, openAddon: function () { - this.fire('hassio-select-addon', { addon: this.addon.slug }); + history.pushState(null, null, '/hassio/addon/' + this.addon.slug); + this.fire('location-changed'); }, backTapped: function () { - this.selectedAddon = null; + history.back(); }, }); diff --git a/panels/hassio/addon-store/hassio-addon-store.html b/panels/hassio/addon-store/hassio-addon-store.html index e693f66c4d..afe5defebc 100644 --- a/panels/hassio/addon-store/hassio-addon-store.html +++ b/panels/hassio/addon-store/hassio-addon-store.html @@ -3,6 +3,7 @@ + @@ -13,19 +14,23 @@