Expose to more info content if dialog is open

This commit is contained in:
Paulus Schoutsen 2015-03-28 13:41:07 -07:00
parent 5a0251c3cd
commit 522bbfb716
2 changed files with 28 additions and 3 deletions

View File

@ -7,12 +7,14 @@
<polymer-element name="more-info-dialog">
<template>
<ha-dialog id="dialog">
<ha-dialog id="dialog" on-core-overlay-open="{{dialogOpenChanged}}">
<div>
<state-card-content stateObj="{{stateObj}}" style='margin-bottom: 24px;'>
</state-card-content>
<state-timeline stateHistory="{{stateHistory}}"></state-timeline>
<more-info-content stateObj="{{stateObj}}"></more-info-content>
<more-info-content
stateObj="{{stateObj}}"
dialogOpen="{{dialogOpen}}"></more-info-content>
</div>
</ha-dialog>
</template>
@ -27,11 +29,16 @@ Polymer(Polymer.mixin({
stateObj: null,
stateHistory: null,
hasHistoryComponent: false,
dialogOpen: false,
observe: {
'stateObj.attributes': 'reposition'
},
created: function() {
this.dialogOpenChanged = this.dialogOpenChanged.bind(this);
},
attached: function() {
this.listenToStores(true);
},
@ -66,6 +73,13 @@ Polymer(Polymer.mixin({
}
},
dialogOpenChanged: function(ev) {
// we get CustomEvent, undefined and true/false from polymer…
if (typeof ev === 'object') {
this.dialogOpen = ev.detail;
}
},
changeEntityId: function(entityId) {
this.entityId = entityId;

View File

@ -8,7 +8,7 @@
<link rel="import" href="more-info-thermostat.html">
<link rel="import" href="more-info-script.html">
<polymer-element name="more-info-content" attributes="stateObj">
<polymer-element name="more-info-content" attributes="stateObj dialogOpen">
<template>
<style>
:host {
@ -20,11 +20,20 @@
<script>
Polymer({
classNames: '',
dialogOpen: false,
observe: {
'stateObj.attributes': 'stateAttributesChanged',
},
dialogOpenChanged: function(oldVal, newVal) {
var moreInfoContainer = this.$.moreInfoContainer;
if (moreInfoContainer.lastChild) {
moreInfoContainer.lastChild.dialogOpen = newVal;
}
},
stateObjChanged: function(oldVal, newVal) {
var moreInfoContainer = this.$.moreInfoContainer;
@ -42,10 +51,12 @@ Polymer({
var moreInfo = document.createElement("more-info-" + newVal.moreInfoType);
moreInfo.stateObj = newVal;
moreInfo.dialogOpen = this.dialogOpen;
moreInfoContainer.appendChild(moreInfo);
} else {
moreInfoContainer.lastChild.dialogOpen = this.dialogOpen;
moreInfoContainer.lastChild.stateObj = newVal;
}