mirror of
https://github.com/home-assistant/frontend.git
synced 2025-07-16 22:06:34 +00:00
Allow using icon/name for default_view. Add hover-title whn using an icon. (#244)
This commit is contained in:
parent
cd9d52caec
commit
16f0775af5
@ -54,14 +54,26 @@
|
|||||||
<paper-tab
|
<paper-tab
|
||||||
data-entity=''
|
data-entity=''
|
||||||
on-tap='scrollToTop'
|
on-tap='scrollToTop'
|
||||||
>[[locationName]]</paper-tab>
|
>
|
||||||
|
<template is='dom-if' if='[[!defaultView]]'>
|
||||||
|
[[locationName]]
|
||||||
|
</template>
|
||||||
|
<template is='dom-if' if='[[defaultView]]'>
|
||||||
|
<template is='dom-if' if='[[defaultView.attributes.icon]]'>
|
||||||
|
<iron-icon title=$='[[computeStateName(defaultView)]]' icon='[[defaultView.attributes.icon]]'></iron-icon>
|
||||||
|
</template>
|
||||||
|
<template is='dom-if' if='[[!defaultView.attributes.icon]]'>
|
||||||
|
[[computeStateName(defaultView)]]
|
||||||
|
</template>
|
||||||
|
</template>
|
||||||
|
</paper-tab>
|
||||||
<template is='dom-repeat' items='[[views]]'>
|
<template is='dom-repeat' items='[[views]]'>
|
||||||
<paper-tab
|
<paper-tab
|
||||||
data-entity$='[[item.entity_id]]'
|
data-entity$='[[item.entity_id]]'
|
||||||
on-tap='scrollToTop'
|
on-tap='scrollToTop'
|
||||||
>
|
>
|
||||||
<template is='dom-if' if='[[item.attributes.icon]]'>
|
<template is='dom-if' if='[[item.attributes.icon]]'>
|
||||||
<iron-icon icon='[[item.attributes.icon]]'></iron-icon>
|
<iron-icon title$='[[computeStateName(item)]]' icon='[[item.attributes.icon]]'></iron-icon>
|
||||||
</template>
|
</template>
|
||||||
<template is='dom-if' if='[[!item.attributes.icon]]'>
|
<template is='dom-if' if='[[!item.attributes.icon]]'>
|
||||||
[[computeStateName(item)]]
|
[[computeStateName(item)]]
|
||||||
@ -114,6 +126,7 @@ Polymer({
|
|||||||
hass: {
|
hass: {
|
||||||
type: Object,
|
type: Object,
|
||||||
value: null,
|
value: null,
|
||||||
|
observer: 'computeAllViews'
|
||||||
},
|
},
|
||||||
|
|
||||||
narrow: {
|
narrow: {
|
||||||
@ -154,7 +167,10 @@ Polymer({
|
|||||||
|
|
||||||
views: {
|
views: {
|
||||||
type: Array,
|
type: Array,
|
||||||
computed: 'computeViews(hass)',
|
},
|
||||||
|
|
||||||
|
defaultView: {
|
||||||
|
type: Object,
|
||||||
},
|
},
|
||||||
|
|
||||||
viewStates: {
|
viewStates: {
|
||||||
@ -242,6 +258,13 @@ Polymer({
|
|||||||
},
|
},
|
||||||
|
|
||||||
computeStateName: function (stateObj) {
|
computeStateName: function (stateObj) {
|
||||||
|
if (stateObj.entity_id === this.DEFAULT_VIEW_ENTITY_ID) {
|
||||||
|
if (stateObj.attributes.friendly_name &&
|
||||||
|
stateObj.attributes.friendly_name !== 'default_view') {
|
||||||
|
return stateObj.attributes.friendly_name;
|
||||||
|
}
|
||||||
|
return this.computeLocationName(this.hass);
|
||||||
|
}
|
||||||
return window.hassUtil.computeStateName(stateObj);
|
return window.hassUtil.computeStateName(stateObj);
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -253,15 +276,16 @@ Polymer({
|
|||||||
return window.hassUtil.isComponentLoaded(hass, 'introduction');
|
return window.hassUtil.isComponentLoaded(hass, 'introduction');
|
||||||
},
|
},
|
||||||
|
|
||||||
computeViews: function (hass) {
|
computeAllViews: function (hass) {
|
||||||
var views = window.HAWS.extractViews(hass.states);
|
var views = window.HAWS.extractViews(hass.states);
|
||||||
|
|
||||||
// If default view present, it's in first index.
|
// If default view present, it's in first index.
|
||||||
if (views.length > 0 && views[0].entity_id === 'group.default_view') {
|
if (views.length > 0 && views[0].entity_id === this.DEFAULT_VIEW_ENTITY_ID) {
|
||||||
views.shift();
|
this.defaultView = views.shift();
|
||||||
|
} else {
|
||||||
|
this.defaultView = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
return views;
|
this.views = views;
|
||||||
},
|
},
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
Loading…
x
Reference in New Issue
Block a user