mirror of
https://github.com/home-assistant/frontend.git
synced 2025-07-19 07:16:39 +00:00
No longer fetch customui element (#414)
This commit is contained in:
parent
0508a6bf2e
commit
206f624fb6
@ -1,4 +1,4 @@
|
|||||||
<link rel="import" href="../../bower_components/polymer/polymer.html">
|
<link rel="import" href="../../bower_components/polymer/polymer-element.html">
|
||||||
|
|
||||||
<link rel="import" href="state-card-climate.html">
|
<link rel="import" href="state-card-climate.html">
|
||||||
<link rel="import" href="state-card-configurator.html">
|
<link rel="import" href="state-card-configurator.html">
|
||||||
@ -12,56 +12,49 @@
|
|||||||
<link rel="import" href="state-card-toggle.html">
|
<link rel="import" href="state-card-toggle.html">
|
||||||
<link rel="import" href="state-card-weblink.html">
|
<link rel="import" href="state-card-weblink.html">
|
||||||
|
|
||||||
|
<link rel="import" href="../util/hass-util.html">
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
Polymer({
|
class StateCardContent extends Polymer.Element {
|
||||||
is: 'state-card-content',
|
|
||||||
|
|
||||||
properties: {
|
static get is() { return 'state-card-content'; }
|
||||||
hass: {
|
|
||||||
type: Object,
|
|
||||||
},
|
|
||||||
|
|
||||||
inDialog: {
|
static get properties() {
|
||||||
type: Boolean,
|
return {
|
||||||
value: false,
|
hass: Object,
|
||||||
},
|
|
||||||
|
|
||||||
stateObj: {
|
inDialog: {
|
||||||
type: Object,
|
type: Boolean,
|
||||||
},
|
value: false,
|
||||||
},
|
},
|
||||||
|
|
||||||
observers: [
|
stateObj: Object,
|
||||||
'inputChanged(hass, inDialog, stateObj)',
|
};
|
||||||
],
|
}
|
||||||
|
|
||||||
_ensureCustomUILoaded: function (stateType) {
|
static get observers() {
|
||||||
this.importHref(
|
return [
|
||||||
'/local/custom_ui/state-card-' + stateType + '.html',
|
'inputChanged(hass, inDialog, stateObj)',
|
||||||
function () {},
|
];
|
||||||
/* eslint-disable no-console */
|
}
|
||||||
function () { console.error('Error loading %s from /local/custom_ui/state-card-%s.html', stateType, stateType); },
|
|
||||||
/* eslint-enable no-console */
|
|
||||||
true);
|
|
||||||
},
|
|
||||||
|
|
||||||
inputChanged: function (hass, inDialog, stateObj) {
|
inputChanged(hass, inDialog, stateObj) {
|
||||||
var stateCardType;
|
let stateCardType;
|
||||||
if (!stateObj || !hass) return;
|
if (!stateObj || !hass) return;
|
||||||
if (stateObj.attributes && 'custom_ui_state_card' in stateObj.attributes) {
|
if (stateObj.attributes && 'custom_ui_state_card' in stateObj.attributes) {
|
||||||
stateCardType = stateObj.attributes.custom_ui_state_card;
|
stateCardType = stateObj.attributes.custom_ui_state_card;
|
||||||
this._ensureCustomUILoaded(stateCardType);
|
|
||||||
} else {
|
} else {
|
||||||
stateCardType = window.hassUtil.stateCardType(hass, stateObj);
|
stateCardType = 'state-card-' + window.hassUtil.stateCardType(hass, stateObj);
|
||||||
}
|
}
|
||||||
window.hassUtil.dynamicContentUpdater(
|
window.hassUtil.dynamicContentUpdater(
|
||||||
this,
|
this,
|
||||||
('STATE-CARD-' + stateCardType.toUpperCase()),
|
stateCardType.toUpperCase(),
|
||||||
{
|
{
|
||||||
hass: hass,
|
hass: hass,
|
||||||
stateObj: stateObj,
|
stateObj: stateObj,
|
||||||
inDialog: inDialog,
|
inDialog: inDialog,
|
||||||
});
|
});
|
||||||
},
|
}
|
||||||
});
|
}
|
||||||
|
customElements.define(StateCardContent.is, StateCardContent);
|
||||||
</script>
|
</script>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user