Skip to content

Commit

Permalink
No longer fetch customui element (#414)
Browse files Browse the repository at this point in the history
  • Loading branch information
andrey-git authored and balloob committed Aug 29, 2017
1 parent 0508a6b commit 206f624
Showing 1 changed file with 27 additions and 34 deletions.
61 changes: 27 additions & 34 deletions src/state-summary/state-card-content.html
Original file line number Diff line number Diff line change
@@ -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-configurator.html">
Expand All @@ -12,56 +12,49 @@
<link rel="import" href="state-card-toggle.html">
<link rel="import" href="state-card-weblink.html">

<link rel="import" href="../util/hass-util.html">

<script>
Polymer({
is: 'state-card-content',
class StateCardContent extends Polymer.Element {

properties: {
hass: {
type: Object,
},
static get is() { return 'state-card-content'; }

inDialog: {
type: Boolean,
value: false,
},
static get properties() {
return {
hass: Object,

stateObj: {
type: Object,
},
},
inDialog: {
type: Boolean,
value: false,
},

observers: [
'inputChanged(hass, inDialog, stateObj)',
],
stateObj: Object,
};
}

_ensureCustomUILoaded: function (stateType) {
this.importHref(
'/local/custom_ui/state-card-' + stateType + '.html',
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);
},
static get observers() {
return [
'inputChanged(hass, inDialog, stateObj)',
];
}

inputChanged: function (hass, inDialog, stateObj) {
var stateCardType;
inputChanged(hass, inDialog, stateObj) {
let stateCardType;
if (!stateObj || !hass) return;
if (stateObj.attributes && 'custom_ui_state_card' in stateObj.attributes) {
stateCardType = stateObj.attributes.custom_ui_state_card;
this._ensureCustomUILoaded(stateCardType);
} else {
stateCardType = window.hassUtil.stateCardType(hass, stateObj);
stateCardType = 'state-card-' + window.hassUtil.stateCardType(hass, stateObj);
}
window.hassUtil.dynamicContentUpdater(
this,
('STATE-CARD-' + stateCardType.toUpperCase()),
stateCardType.toUpperCase(),
{
hass: hass,
stateObj: stateObj,
inDialog: inDialog,
});
},
});
}
}
customElements.define(StateCardContent.is, StateCardContent);
</script>

0 comments on commit 206f624

Please sign in to comment.