mirror of
https://github.com/home-assistant/core.git
synced 2025-04-23 16:57:53 +00:00
Make more info dialog more store dependent
This commit is contained in:
parent
faddb5d57e
commit
4047bf0775
@ -1,2 +1,2 @@
|
||||
""" DO NOT MODIFY. Auto-generated by build_frontend script """
|
||||
VERSION = "8a29fbc60ac02a7b0ac05fcc2f69c1fd"
|
||||
VERSION = "3822abfa5abb0a8d60ddf434a2f341d5"
|
||||
|
File diff suppressed because one or more lines are too long
@ -25,9 +25,13 @@
|
||||
</template>
|
||||
<script>
|
||||
var storeListenerMixIn = window.hass.storeListenerMixIn;
|
||||
var stateStore = window.hass.stateStore;
|
||||
var stateHistoryStore = window.hass.stateHistoryStore;
|
||||
var stateHistoryActions = window.hass.stateHistoryActions;
|
||||
|
||||
Polymer(Polymer.mixin({
|
||||
stateObj: {},
|
||||
entityId: false,
|
||||
stateObj: null,
|
||||
stateHistory: null,
|
||||
hasHistoryComponent: false,
|
||||
|
||||
@ -36,7 +40,7 @@ Polymer(Polymer.mixin({
|
||||
},
|
||||
|
||||
ready: function() {
|
||||
this.listenToStores(true);
|
||||
this.listenToStores();
|
||||
},
|
||||
|
||||
detached: function() {
|
||||
@ -47,22 +51,51 @@ Polymer(Polymer.mixin({
|
||||
this.hasHistoryComponent = componentStore.isLoaded('history');
|
||||
},
|
||||
|
||||
stateHistoryStoreChanged: function(stateHistoryStore) {
|
||||
if (this.hasHistoryComponent && this.stateObj && this.stateObj.entityId) {
|
||||
this.stateHistory = stateHistoryStore.get(this.stateObj.entityId);
|
||||
stateStoreChanged: function() {
|
||||
var newState;
|
||||
|
||||
if (!this.entityId) {
|
||||
newState = null;
|
||||
} else {
|
||||
this.stateHistory = null;
|
||||
newState = stateStore.get(this.entityId);
|
||||
}
|
||||
|
||||
console.log('state store changed');
|
||||
|
||||
if (newState !== this.stateObj) {
|
||||
console.log("Setting new stateobj");
|
||||
this.stateObj = newState;
|
||||
}
|
||||
},
|
||||
|
||||
stateObjChanged: function() {
|
||||
if (this.hasHistoryComponent) {
|
||||
if (this.stateObj && this.stateObj.entityId &&
|
||||
window.hass.stateHistoryStore.isStale(this.stateObj.entityId)) {
|
||||
window.hass.stateHistoryActions.fetch(this.stateObj.entityId);
|
||||
}
|
||||
stateHistoryStoreChanged: function() {
|
||||
var newHistory;
|
||||
|
||||
this.stateHistoryStoreChanged();
|
||||
if (this.hasHistoryComponent && this.entityId) {
|
||||
newHistory = stateHistoryStore.get(this.entityId);
|
||||
} else {
|
||||
newHistory = null;
|
||||
}
|
||||
|
||||
if (newHistory !== this.stateHistory) {
|
||||
this.stateHistory = newHistory;
|
||||
}
|
||||
},
|
||||
|
||||
changeEntityId: function(entityId) {
|
||||
this.entityId = entityId;
|
||||
|
||||
if (!entityId) {
|
||||
this.stateObj = null;
|
||||
this.stateHistory = null;
|
||||
return;
|
||||
}
|
||||
|
||||
this.stateStoreChanged();
|
||||
this.stateHistoryStoreChanged();
|
||||
|
||||
if (this.hasHistoryComponent && stateHistoryStore.isStale(entityId)) {
|
||||
stateHistoryActions.fetch(entityId);
|
||||
}
|
||||
},
|
||||
|
||||
@ -79,8 +112,9 @@ Polymer(Polymer.mixin({
|
||||
}
|
||||
},
|
||||
|
||||
show: function(stateObj) {
|
||||
this.stateObj = stateObj;
|
||||
show: function(entityId) {
|
||||
this.changeEntityId(entityId);
|
||||
|
||||
this.job('showDialogAfterRender', function() {
|
||||
this.$.dialog.toggle();
|
||||
}.bind(this));
|
||||
|
@ -83,14 +83,10 @@
|
||||
<script>
|
||||
Polymer({
|
||||
ready: function() {
|
||||
var getState = window.hass.stateStore.get;
|
||||
|
||||
dispatcher.register(function(payload) {
|
||||
switch (payload.actionType) {
|
||||
case uiActions.ACTION_SHOW_DIALOG_MORE_INFO:
|
||||
state = getState(payload.entityId);
|
||||
|
||||
this.$.moreInfoDialog.show(state);
|
||||
this.$.moreInfoDialog.show(payload.entityId);
|
||||
break;
|
||||
}
|
||||
}.bind(this));
|
||||
|
@ -1 +1 @@
|
||||
Subproject commit 229e3bfc12ca0270c45003cf3189530c0e9a0875
|
||||
Subproject commit ccd60be0610acdebf9256b0ff0be5d0e41f3cfda
|
Loading…
x
Reference in New Issue
Block a user