mirror of
https://github.com/home-assistant/frontend.git
synced 2025-07-15 05:16:34 +00:00
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:
parent
69eb10c6dd
commit
3ba15cb7b5
@ -2,10 +2,10 @@ import { h, Component } from 'preact';
|
|||||||
|
|
||||||
import { onChangeEvent } from '../../common/util/event.js';
|
import { onChangeEvent } from '../../common/util/event.js';
|
||||||
import { hasLocation } from '../../common/util/location.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) {
|
function zoneAndLocationFilter(stateObj) {
|
||||||
return hasLocation(stateObj) && computeDomain(stateObj) !== 'zone';
|
return hasLocation(stateObj) && computeStateDomain(stateObj) !== 'zone';
|
||||||
}
|
}
|
||||||
|
|
||||||
export default class ZoneTrigger extends Component {
|
export default class ZoneTrigger extends Component {
|
||||||
|
@ -2,10 +2,10 @@ import { h, Component } from 'preact';
|
|||||||
|
|
||||||
import { onChangeEvent } from '../../util/event.js';
|
import { onChangeEvent } from '../../util/event.js';
|
||||||
import { hasLocation } from '../../util/location.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) {
|
function zoneAndLocationFilter(stateObj) {
|
||||||
return hasLocation(stateObj) && computeDomain(stateObj) !== 'zone';
|
return hasLocation(stateObj) && computeStateDomain(stateObj) !== 'zone';
|
||||||
}
|
}
|
||||||
|
|
||||||
export default class ZoneCondition extends Component {
|
export default class ZoneCondition extends Component {
|
||||||
|
@ -14,13 +14,13 @@
|
|||||||
</style>
|
</style>
|
||||||
<app-route
|
<app-route
|
||||||
route='[[route]]'
|
route='[[route]]'
|
||||||
pattern='/edit/:automation'
|
pattern='/automation/edit/:automation'
|
||||||
data="{{_routeData}}"
|
data="{{_routeData}}"
|
||||||
active="{{_edittingAutomation}}"
|
active="{{_edittingAutomation}}"
|
||||||
></app-route>
|
></app-route>
|
||||||
<app-route
|
<app-route
|
||||||
route='[[route]]'
|
route='[[route]]'
|
||||||
pattern='/new'
|
pattern='/automation/new'
|
||||||
active="{{_creatingNew}}"
|
active="{{_creatingNew}}"
|
||||||
></app-route>
|
></app-route>
|
||||||
|
|
||||||
|
@ -18,7 +18,7 @@
|
|||||||
</style>
|
</style>
|
||||||
<app-route
|
<app-route
|
||||||
route='[[route]]'
|
route='[[route]]'
|
||||||
pattern='/:page'
|
pattern='/cloud/:page'
|
||||||
data="{{_routeData}}"
|
data="{{_routeData}}"
|
||||||
tail="{{_routeTail}}"
|
tail="{{_routeTail}}"
|
||||||
></app-route>
|
></app-route>
|
||||||
@ -32,7 +32,7 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<template is='dom-if' if='[[!account]]' restamp>
|
<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
|
<ha-config-cloud-login
|
||||||
page-name='login'
|
page-name='login'
|
||||||
hass='[[hass]]'
|
hass='[[hass]]'
|
||||||
@ -41,7 +41,7 @@
|
|||||||
></ha-config-cloud-login>
|
></ha-config-cloud-login>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<template is='dom-if' if='[[_isRegisterPage(_routeData.page)]]' restamp>
|
<template is='dom-if' if='[[_equals(_routeData.page, "register")]]' restamp>
|
||||||
<ha-config-cloud-register
|
<ha-config-cloud-register
|
||||||
page-name='register'
|
page-name='register'
|
||||||
hass='[[hass]]'
|
hass='[[hass]]'
|
||||||
@ -50,7 +50,7 @@
|
|||||||
></ha-config-cloud-register>
|
></ha-config-cloud-register>
|
||||||
</template>
|
</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
|
<ha-config-cloud-forgot-password
|
||||||
page-name='forgot-password'
|
page-name='forgot-password'
|
||||||
hass='[[hass]]'
|
hass='[[hass]]'
|
||||||
@ -63,51 +63,53 @@
|
|||||||
</dom-module>
|
</dom-module>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
class HaConfigCloud extends window.hassMixins.NavigateMixin(Polymer.Element) {
|
{
|
||||||
static get is() { return 'ha-config-cloud'; }
|
class HaConfigCloud extends window.hassMixins.NavigateMixin(Polymer.Element) {
|
||||||
|
static get is() { return 'ha-config-cloud'; }
|
||||||
|
|
||||||
static get properties() {
|
static get properties() {
|
||||||
return {
|
return {
|
||||||
hass: Object,
|
hass: Object,
|
||||||
isWide: Boolean,
|
isWide: Boolean,
|
||||||
loadingAccount: {
|
loadingAccount: {
|
||||||
type: Boolean,
|
type: Boolean,
|
||||||
value: false
|
value: false
|
||||||
},
|
},
|
||||||
account: {
|
account: {
|
||||||
type: Object,
|
type: Object,
|
||||||
value: null,
|
value: null,
|
||||||
},
|
},
|
||||||
|
|
||||||
route: Object,
|
route: Object,
|
||||||
|
|
||||||
_routeData: Object,
|
_routeData: Object,
|
||||||
_routeTail: Object,
|
_routeTail: Object,
|
||||||
_loginEmail: String,
|
_loginEmail: String,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
static get observers() {
|
static get observers() {
|
||||||
return [
|
return [
|
||||||
'_checkRoute(route, account)'
|
'_checkRoute(route, account)'
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
_checkRoute(route, account) {
|
_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);
|
this.navigate('/config/cloud/login', true);
|
||||||
} else if (account &&
|
} 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);
|
this.navigate('/config/cloud/account', true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
_equals(a, b) {
|
||||||
|
return a === b;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
_isRegisterPage(page) { return page === 'register'; }
|
customElements.define(HaConfigCloud.is, HaConfigCloud);
|
||||||
_isForgotPasswordPage(page) { return page === 'forgot-password'; }
|
|
||||||
_isLoginPage(page) { return page === 'login'; }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
customElements.define(HaConfigCloud.is, HaConfigCloud);
|
|
||||||
</script>
|
</script>
|
||||||
|
@ -25,7 +25,6 @@
|
|||||||
route='[[route]]'
|
route='[[route]]'
|
||||||
pattern='/:page'
|
pattern='/:page'
|
||||||
data="{{_routeData}}"
|
data="{{_routeData}}"
|
||||||
tail="{{_routeTail}}"
|
|
||||||
></app-route>
|
></app-route>
|
||||||
|
|
||||||
<iron-media-query query="(min-width: 1040px)" query-matches="{{wide}}">
|
<iron-media-query query="(min-width: 1040px)" query-matches="{{wide}}">
|
||||||
@ -47,7 +46,7 @@
|
|||||||
|
|
||||||
<ha-config-cloud
|
<ha-config-cloud
|
||||||
page-name='cloud'
|
page-name='cloud'
|
||||||
route='[[_routeTail]]'
|
route='[[route]]'
|
||||||
hass='[[hass]]'
|
hass='[[hass]]'
|
||||||
is-wide='[[isWide]]'
|
is-wide='[[isWide]]'
|
||||||
account='[[account]]'
|
account='[[account]]'
|
||||||
@ -64,14 +63,14 @@
|
|||||||
|
|
||||||
<ha-config-automation
|
<ha-config-automation
|
||||||
page-name='automation'
|
page-name='automation'
|
||||||
route='[[_routeTail]]'
|
route='[[route]]'
|
||||||
hass='[[hass]]'
|
hass='[[hass]]'
|
||||||
is-wide='[[isWide]]'
|
is-wide='[[isWide]]'
|
||||||
></ha-config-automation>
|
></ha-config-automation>
|
||||||
|
|
||||||
<ha-config-script
|
<ha-config-script
|
||||||
page-name='script'
|
page-name='script'
|
||||||
route='[[_routeTail]]'
|
route='[[route]]'
|
||||||
hass='[[hass]]'
|
hass='[[hass]]'
|
||||||
is-wide='[[isWide]]'
|
is-wide='[[isWide]]'
|
||||||
></ha-config-script>
|
></ha-config-script>
|
||||||
@ -117,7 +116,6 @@ class HaPanelConfig extends window.hassMixins.EventsMixin(Polymer.Element) {
|
|||||||
},
|
},
|
||||||
|
|
||||||
_routeData: Object,
|
_routeData: Object,
|
||||||
_routeTail: Object,
|
|
||||||
|
|
||||||
wide: Boolean,
|
wide: Boolean,
|
||||||
wideSidebar: Boolean,
|
wideSidebar: Boolean,
|
||||||
|
@ -14,13 +14,13 @@
|
|||||||
</style>
|
</style>
|
||||||
<app-route
|
<app-route
|
||||||
route='[[route]]'
|
route='[[route]]'
|
||||||
pattern='/edit/:script'
|
pattern='/script/edit/:script'
|
||||||
data="{{_routeData}}"
|
data="{{_routeData}}"
|
||||||
active="{{_edittingScript}}"
|
active="{{_edittingScript}}"
|
||||||
></app-route>
|
></app-route>
|
||||||
<app-route
|
<app-route
|
||||||
route='[[route]]'
|
route='[[route]]'
|
||||||
pattern='/new'
|
pattern='/script/new'
|
||||||
active="{{_creatingNew}}"
|
active="{{_creatingNew}}"
|
||||||
></app-route>
|
></app-route>
|
||||||
|
|
||||||
|
@ -30,6 +30,7 @@
|
|||||||
autofocus="[[autofocus]]"
|
autofocus="[[autofocus]]"
|
||||||
label="[[label]]"
|
label="[[label]]"
|
||||||
class="input"
|
class="input"
|
||||||
|
value='[[value]]'
|
||||||
disabled='[[disabled]]'
|
disabled='[[disabled]]'
|
||||||
>
|
>
|
||||||
<paper-icon-button
|
<paper-icon-button
|
||||||
|
@ -27,6 +27,7 @@
|
|||||||
autofocus="[[autofocus]]"
|
autofocus="[[autofocus]]"
|
||||||
label="[[label]]"
|
label="[[label]]"
|
||||||
class="input"
|
class="input"
|
||||||
|
value='[[value]]'
|
||||||
>
|
>
|
||||||
<paper-icon-button
|
<paper-icon-button
|
||||||
slot="suffix"
|
slot="suffix"
|
||||||
|
@ -30,6 +30,8 @@ class HaServicePicker extends Polymer.Element {
|
|||||||
_computeServices(hass) {
|
_computeServices(hass) {
|
||||||
const result = [];
|
const result = [];
|
||||||
|
|
||||||
|
if (!hass) return result;
|
||||||
|
|
||||||
Object.keys(hass.config.services).sort().forEach((domain) => {
|
Object.keys(hass.config.services).sort().forEach((domain) => {
|
||||||
const services = Object.keys(hass.config.services[domain]).sort();
|
const services = Object.keys(hass.config.services[domain]).sort();
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user