Fix error when creating new automation (#683)

* Import correct computeStateDomain

* ha-service-picker to not crash when no hass

* Fix routing be less active

* Fix combo box value sync
This commit is contained in:
Paulus Schoutsen 2017-11-25 21:43:52 -08:00 committed by GitHub
parent 69eb10c6dd
commit 3ba15cb7b5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
9 changed files with 58 additions and 54 deletions

View File

@ -2,10 +2,10 @@ import { h, Component } from 'preact';
import { onChangeEvent } from '../../common/util/event.js';
import { hasLocation } from '../../common/util/location.js';
import computeDomain from '../../common/util/compute_domain.js';
import computeStateDomain from '../../common/util/compute_state_domain.js';
function zoneAndLocationFilter(stateObj) {
return hasLocation(stateObj) && computeDomain(stateObj) !== 'zone';
return hasLocation(stateObj) && computeStateDomain(stateObj) !== 'zone';
}
export default class ZoneTrigger extends Component {

View File

@ -2,10 +2,10 @@ import { h, Component } from 'preact';
import { onChangeEvent } from '../../util/event.js';
import { hasLocation } from '../../util/location.js';
import computeDomain from '../../util/compute_domain.js';
import computeStateDomain from '../../util/compute_state_domain.js';
function zoneAndLocationFilter(stateObj) {
return hasLocation(stateObj) && computeDomain(stateObj) !== 'zone';
return hasLocation(stateObj) && computeStateDomain(stateObj) !== 'zone';
}
export default class ZoneCondition extends Component {

View File

@ -14,13 +14,13 @@
</style>
<app-route
route='[[route]]'
pattern='/edit/:automation'
pattern='/automation/edit/:automation'
data="{{_routeData}}"
active="{{_edittingAutomation}}"
></app-route>
<app-route
route='[[route]]'
pattern='/new'
pattern='/automation/new'
active="{{_creatingNew}}"
></app-route>

View File

@ -18,7 +18,7 @@
</style>
<app-route
route='[[route]]'
pattern='/:page'
pattern='/cloud/:page'
data="{{_routeData}}"
tail="{{_routeTail}}"
></app-route>
@ -32,7 +32,7 @@
</template>
<template is='dom-if' if='[[!account]]' restamp>
<template is='dom-if' if='[[_isLoginPage(_routeData.page)]]' restamp>
<template is='dom-if' if='[[_equals(_routeData.page, "login")]]' restamp>
<ha-config-cloud-login
page-name='login'
hass='[[hass]]'
@ -41,7 +41,7 @@
></ha-config-cloud-login>
</template>
<template is='dom-if' if='[[_isRegisterPage(_routeData.page)]]' restamp>
<template is='dom-if' if='[[_equals(_routeData.page, "register")]]' restamp>
<ha-config-cloud-register
page-name='register'
hass='[[hass]]'
@ -50,7 +50,7 @@
></ha-config-cloud-register>
</template>
<template is='dom-if' if='[[_isForgotPasswordPage(_routeData.page)]]' restamp>
<template is='dom-if' if='[[_equals(_routeData.page, "forgot-password")]]' restamp>
<ha-config-cloud-forgot-password
page-name='forgot-password'
hass='[[hass]]'
@ -63,6 +63,7 @@
</dom-module>
<script>
{
class HaConfigCloud extends window.hassMixins.NavigateMixin(Polymer.Element) {
static get is() { return 'ha-config-cloud'; }
@ -94,20 +95,21 @@ class HaConfigCloud extends window.hassMixins.NavigateMixin(Polymer.Element) {
}
_checkRoute(route, account) {
if (!route || route.prefix !== '/config/cloud') return;
if (!route || route.path.substr(0, 6) !== '/cloud') return;
if (!account && ['/forgot-password', '/register'].indexOf(route.path) === -1) {
if (!account && ['/cloud/forgot-password', '/cloud/register'].indexOf(route.path) === -1) {
this.navigate('/config/cloud/login', true);
} else if (account &&
['/login', '/register', '/forgot-password'].indexOf(route.path) !== -1) {
['/cloud/login', '/cloud/register', '/cloud/forgot-password'].indexOf(route.path) !== -1) {
this.navigate('/config/cloud/account', true);
}
}
_isRegisterPage(page) { return page === 'register'; }
_isForgotPasswordPage(page) { return page === 'forgot-password'; }
_isLoginPage(page) { return page === 'login'; }
_equals(a, b) {
return a === b;
}
}
customElements.define(HaConfigCloud.is, HaConfigCloud);
}
</script>

View File

@ -25,7 +25,6 @@
route='[[route]]'
pattern='/:page'
data="{{_routeData}}"
tail="{{_routeTail}}"
></app-route>
<iron-media-query query="(min-width: 1040px)" query-matches="{{wide}}">
@ -47,7 +46,7 @@
<ha-config-cloud
page-name='cloud'
route='[[_routeTail]]'
route='[[route]]'
hass='[[hass]]'
is-wide='[[isWide]]'
account='[[account]]'
@ -64,14 +63,14 @@
<ha-config-automation
page-name='automation'
route='[[_routeTail]]'
route='[[route]]'
hass='[[hass]]'
is-wide='[[isWide]]'
></ha-config-automation>
<ha-config-script
page-name='script'
route='[[_routeTail]]'
route='[[route]]'
hass='[[hass]]'
is-wide='[[isWide]]'
></ha-config-script>
@ -117,7 +116,6 @@ class HaPanelConfig extends window.hassMixins.EventsMixin(Polymer.Element) {
},
_routeData: Object,
_routeTail: Object,
wide: Boolean,
wideSidebar: Boolean,

View File

@ -14,13 +14,13 @@
</style>
<app-route
route='[[route]]'
pattern='/edit/:script'
pattern='/script/edit/:script'
data="{{_routeData}}"
active="{{_edittingScript}}"
></app-route>
<app-route
route='[[route]]'
pattern='/new'
pattern='/script/new'
active="{{_creatingNew}}"
></app-route>

View File

@ -30,6 +30,7 @@
autofocus="[[autofocus]]"
label="[[label]]"
class="input"
value='[[value]]'
disabled='[[disabled]]'
>
<paper-icon-button

View File

@ -27,6 +27,7 @@
autofocus="[[autofocus]]"
label="[[label]]"
class="input"
value='[[value]]'
>
<paper-icon-button
slot="suffix"

View File

@ -30,6 +30,8 @@ class HaServicePicker extends Polymer.Element {
_computeServices(hass) {
const result = [];
if (!hass) return result;
Object.keys(hass.config.services).sort().forEach((domain) => {
const services = Object.keys(hass.config.services[domain]).sort();