mirror of
https://github.com/home-assistant/frontend.git
synced 2025-07-17 06:16:33 +00:00
Don't add more-info-card if hidden (#549)
* Don't add more-info-card if hidden * Fix c&p * Use itemForElement * Fix travis * Update ha-entities-card.html * Update ha-entities-card.html * Remove brackets
This commit is contained in:
parent
b7d2b2fcfd
commit
f106767eae
@ -16,7 +16,6 @@
|
|||||||
}
|
}
|
||||||
.state {
|
.state {
|
||||||
padding: 4px 16px;
|
padding: 4px 16px;
|
||||||
cursor: pointer;
|
|
||||||
}
|
}
|
||||||
.header {
|
.header {
|
||||||
@apply(--paper-font-headline);
|
@apply(--paper-font-headline);
|
||||||
@ -36,7 +35,7 @@
|
|||||||
ha-entity-toggle {
|
ha-entity-toggle {
|
||||||
margin-left: 16px;
|
margin-left: 16px;
|
||||||
}
|
}
|
||||||
.header-more-info {
|
.more-info {
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
@ -51,12 +50,12 @@
|
|||||||
</template>
|
</template>
|
||||||
</div>
|
</div>
|
||||||
<div class='states'>
|
<div class='states'>
|
||||||
<template is='dom-repeat' items="[[states]]">
|
<template is='dom-repeat' items='[[states]]' on-dom-change='addTapEvents'>
|
||||||
<div class='state' on-tap='entityTapped'>
|
<div class$='[[computeStateClass(item)]]'>
|
||||||
<state-card-content
|
<state-card-content
|
||||||
hass='[[hass]]'
|
hass='[[hass]]'
|
||||||
class="state-card"
|
class='state-card'
|
||||||
state-obj="[[item]]"></state-card-content>
|
state-obj='[[item]]'></state-card-content>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
</div>
|
</div>
|
||||||
@ -84,23 +83,34 @@ class HaEntitiesCard extends window.hassMixins.EventsMixin(Polymer.Element) {
|
|||||||
computeTitleClass(groupEntity) {
|
computeTitleClass(groupEntity) {
|
||||||
var classes = 'header horizontal layout center ';
|
var classes = 'header horizontal layout center ';
|
||||||
if (groupEntity) {
|
if (groupEntity) {
|
||||||
classes += 'header-more-info';
|
classes += 'more-info';
|
||||||
} else {
|
} else {
|
||||||
classes += 'domain';
|
classes += 'domain';
|
||||||
}
|
}
|
||||||
return classes;
|
return classes;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
computeStateClass(stateObj) {
|
||||||
|
return window.hassUtil.stateMoreInfoType(stateObj) !== 'hidden' ? 'state more-info' : 'state';
|
||||||
|
}
|
||||||
|
|
||||||
|
addTapEvents() {
|
||||||
|
var cards = this.root.querySelectorAll('.state.more-info');
|
||||||
|
for (let i = 0; i < cards.length; i++) {
|
||||||
|
cards[i].addEventListener('tap', this.entityTapped.bind(this));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
entityTapped(ev) {
|
entityTapped(ev) {
|
||||||
|
var item = this.root.querySelector('dom-repeat').itemForElement(ev.target);
|
||||||
var entityId;
|
var entityId;
|
||||||
if (ev.target.nodeName === 'STATE-CARD-INPUT_TEXT' ||
|
if (!item && !this.groupEntity) {
|
||||||
(!ev.model && !this.groupEntity)) {
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
ev.stopPropagation();
|
ev.stopPropagation();
|
||||||
|
|
||||||
if (ev.model) {
|
if (item) {
|
||||||
entityId = ev.model.item.entity_id;
|
entityId = item.entity_id;
|
||||||
} else {
|
} else {
|
||||||
entityId = this.groupEntity.entity_id;
|
entityId = this.groupEntity.entity_id;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user