* Unify page navigation to NavigateMixin * revert unintended change * Use template literal
88 lines
2.3 KiB
HTML
88 lines
2.3 KiB
HTML
<link rel="import" href="../../../bower_components/polymer/polymer-element.html">
|
|
<link rel="import" href="../../../bower_components/paper-card/paper-card.html">
|
|
<link rel="import" href="../../../bower_components/paper-item/paper-item.html">
|
|
<link rel="import" href="../../../bower_components/paper-item/paper-item-body.html">
|
|
<link rel="import" href="../../../bower_components/iron-icon/iron-icon.html">
|
|
|
|
<link rel='import' href='../../../src/util/hass-mixins.html'>
|
|
|
|
<dom-module id="ha-config-navigation">
|
|
<template>
|
|
<style include="iron-flex">
|
|
paper-card {
|
|
display: block;
|
|
}
|
|
paper-item {
|
|
cursor: pointer;
|
|
}
|
|
</style>
|
|
<paper-card>
|
|
<template is='dom-repeat' items='[[pages]]'>
|
|
<template is='dom-if' if='[[_computeLoaded(hass, item)]]'>
|
|
<paper-item on-click='_navigate'>
|
|
<paper-item-body two-line>
|
|
[[_computeCaption(item, localize)]]
|
|
<div secondary>[[_computeDescription(item, localize)]]</div>
|
|
</paper-item-body>
|
|
<iron-icon icon='mdi:chevron-right'></iron-icon>
|
|
</paper-item>
|
|
</template>
|
|
</template>
|
|
</paper-card>
|
|
</template>
|
|
</dom-module>
|
|
|
|
<script>
|
|
{
|
|
const CORE_PAGES = [
|
|
'core',
|
|
'customize',
|
|
];
|
|
/*
|
|
* @appliesMixin window.hassMixins.LocalizeMixin
|
|
* @appliesMixin window.hassMixins.EventsMixin
|
|
*/
|
|
class HaConfigNavigation extends
|
|
window.hassMixins.LocalizeMixin(window.hassMixins.NavigateMixin(Polymer.Element)) {
|
|
static get is() { return 'ha-config-navigation'; }
|
|
|
|
static get properties() {
|
|
return {
|
|
hass: {
|
|
type: Object,
|
|
},
|
|
|
|
pages: {
|
|
type: Array,
|
|
value: [
|
|
'core',
|
|
'customize',
|
|
'automation',
|
|
'script',
|
|
'zwave',
|
|
],
|
|
}
|
|
};
|
|
}
|
|
|
|
_computeLoaded(hass, page) {
|
|
return CORE_PAGES.includes(page) || window.hassUtil.isComponentLoaded(hass, page);
|
|
}
|
|
|
|
_computeCaption(page, localize) {
|
|
return localize(`ui.panel.config.${page}.caption`);
|
|
}
|
|
|
|
_computeDescription(page, localize) {
|
|
return localize(`ui.panel.config.${page}.description`);
|
|
}
|
|
|
|
_navigate(ev) {
|
|
this.navigate('/config/' + ev.model.item);
|
|
}
|
|
}
|
|
|
|
customElements.define(HaConfigNavigation.is, HaConfigNavigation);
|
|
}
|
|
</script>
|