Polymer 1.0: More info dialog bug fixes

This commit is contained in:
Paulus Schoutsen 2015-05-27 22:02:58 -07:00
parent 8b1d3c7658
commit a7f9a5c4ad

View File

@ -2,9 +2,9 @@
<link rel="import" href="../bower_components/paper-dialog/paper-dialog.html"> <link rel="import" href="../bower_components/paper-dialog/paper-dialog.html">
<link rel="import" href="../bower_components/paper-dialog-scrollable/paper-dialog-scrollable.html"> <link rel="import" href="../bower_components/paper-dialog-scrollable/paper-dialog-scrollable.html">
<!-- <link rel="import" href="../bower_components/neon-animation/animations/slide-up-animation.html">
<!-- <link rel="import" href="ha-dialog.html"> --> <link rel="import" href="../bower_components/neon-animation/animations/slide-down-animation.html">
-->
<link rel="import" href="../cards/state-card-content.html"> <link rel="import" href="../cards/state-card-content.html">
<link rel="import" href="../components/state-history-charts.html"> <link rel="import" href="../components/state-history-charts.html">
<link rel="import" href="../more-infos/more-info-content.html"> <link rel="import" href="../more-infos/more-info-content.html">
@ -16,9 +16,10 @@
} }
</style> </style>
<template> <template>
<paper-dialog id="dialog" on-core-overlay-open="dialogOpenChanged" with-backdrop> <!-- entry-animation='slide-up-animation' exit-animation='slide-down-animation' -->
<paper-dialog id="dialog" with-backdrop>
<h2><state-card-content state-obj="[[stateObj]]"></state-card-content></h2>
<div> <div>
<state-card-content state-obj="[[stateObj]]"></state-card-content>
<template is='dom-if' if="[[hasHistoryComponent]]"> <template is='dom-if' if="[[hasHistoryComponent]]">
<state-history-charts state-history="[[stateHistory]]" <state-history-charts state-history="[[stateHistory]]"
is-loading-data="[[isLoadingHistoryData]]"></state-history-charts> is-loading-data="[[isLoadingHistoryData]]"></state-history-charts>
@ -50,7 +51,6 @@
stateObj: { stateObj: {
type: Object, type: Object,
observer: 'reposition',
}, },
stateHistory: { stateHistory: {
@ -73,6 +73,11 @@
}, },
}, },
listeners: {
'iron-overlay-opened': 'onIronOverlayOpened',
'iron-overlay-closed': 'onIronOverlayClosed'
},
componentStoreChanged: function(componentStore) { componentStoreChanged: function(componentStore) {
this.hasHistoryComponent = componentStore.isLoaded('history'); this.hasHistoryComponent = componentStore.isLoaded('history');
}, },
@ -101,12 +106,12 @@
} }
}, },
dialogOpenChanged: function(ev) { onIronOverlayOpened: function() {
// we get CustomEvent, undefined and true/false from polymer… this.dialogOpen = true;
console.log('debug', ev); },
if (typeof ev === 'object') {
this.dialogOpen = ev.detail; onIronOverlayClosed: function() {
} this.dialogOpen = false;
}, },
changeEntityId: function(entityId) { changeEntityId: function(entityId) {
@ -121,19 +126,6 @@
} }
}, },
/**
* Whenever the attributes change, the more info component can
* hide or show elements. We will reposition the dialog.
*/
reposition: function(newVal, oldVal) {
// Only resize if already open
if(this.dialogOpen) {
this.debounce('resizeAfterLayoutChange', function() {
this.$.dialog.resizeHandler();
}.bind(this), 1000);
}
},
show: function(entityId) { show: function(entityId) {
this.changeEntityId(entityId); this.changeEntityId(entityId);