Fix reference to this.language (#1825)

This commit is contained in:
Paulus Schoutsen 2018-10-21 20:31:41 +02:00 committed by GitHub
parent e7ec18d270
commit d93c09b27b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
11 changed files with 32 additions and 20 deletions

View File

@ -259,7 +259,7 @@ class StateHistoryChartLine extends LocalizeMixin(PolymerElement) {
const item = items[0]; const item = items[0];
const date = data.datasets[item.datasetIndex].data[item.index].x; const date = data.datasets[item.datasetIndex].data[item.index].x;
return formatDateTime(date, this.language); return formatDateTime(date, this.hass.language);
}; };
const chartOptions = { const chartOptions = {

View File

@ -153,8 +153,8 @@ class StateHistoryChartTimeline extends LocalizeMixin(PolymerElement) {
const formatTooltipLabel = function(item, data) { const formatTooltipLabel = function(item, data) {
const values = data.datasets[item.datasetIndex].data[item.index]; const values = data.datasets[item.datasetIndex].data[item.index];
const start = formatDateTime(values[0], this.language); const start = formatDateTime(values[0], this.hass.language);
const end = formatDateTime(values[1], this.language); const end = formatDateTime(values[1], this.hass.language);
const state = values[2]; const state = values[2];
return [state, start, end]; return [state, start, end];

View File

@ -31,13 +31,25 @@ class StateHistoryCharts extends LocalizeMixin(PolymerElement) {
</template> </template>
<template is="dom-if" if="[[historyData.timeline.length]]"> <template is="dom-if" if="[[historyData.timeline.length]]">
<state-history-chart-timeline data="[[historyData.timeline]]" end-time="[[_computeEndTime(endTime, upToNow, historyData)]]" no-single="[[noSingle]]" names="[[names]]"> <state-history-chart-timeline
</state-history-chart-timeline> hass='[[hass]]'
data="[[historyData.timeline]]"
end-time="[[_computeEndTime(endTime, upToNow, historyData)]]"
no-single="[[noSingle]]"
names="[[names]]"
></state-history-chart-timeline>
</template> </template>
<template is="dom-repeat" items="[[historyData.line]]"> <template is="dom-repeat" items="[[historyData.line]]">
<state-history-chart-line unit="[[item.unit]]" data="[[item.data]]" identifier="[[item.identifier]]" is-single-device="[[_computeIsSingleLineChart(item.data, noSingle)]]" end-time="[[_computeEndTime(endTime, upToNow, historyData)]]" names="[[names]]"> <state-history-chart-line
</state-history-chart-line> hass='[[hass]]'
unit="[[item.unit]]"
data="[[item.data]]"
identifier="[[item.identifier]]"
is-single-device="[[_computeIsSingleLineChart(item.data, noSingle)]]"
end-time="[[_computeEndTime(endTime, upToNow, historyData)]]"
names="[[names]]"
></state-history-chart-line>
</template> </template>
`; `;
} }

View File

@ -65,7 +65,7 @@ class MoreInfoSun extends LocalizeMixin(PolymerElement) {
} }
itemValue(type) { itemValue(type) {
return formatTime(this.itemDate(type), this.language); return formatTime(this.itemDate(type), this.hass.language);
} }
} }

View File

@ -213,7 +213,7 @@ class HaConfigCloudAccount extends EventsMixin(LocalizeMixin(PolymerElement)) {
"{periodEnd}", "{periodEnd}",
formatDateTime( formatDateTime(
new Date(subInfo.plan_renewal_date * 1000), new Date(subInfo.plan_renewal_date * 1000),
this.language this.hass.language
) )
); );
} }

View File

@ -345,8 +345,8 @@ class HaPanelDevInfo extends EventsMixin(LocalizeMixin(PolymerElement)) {
const dateTimeDay = new Date(date * 1000).setHours(0, 0, 0, 0); const dateTimeDay = new Date(date * 1000).setHours(0, 0, 0, 0);
return dateTimeDay < today return dateTimeDay < today
? formatDateTime(dateTime, this.language) ? formatDateTime(dateTime, this.hass.language)
: formatTime(dateTime, this.language); : formatTime(dateTime, this.hass.language);
} }
openLog(event) { openLog(event) {

View File

@ -86,11 +86,11 @@ class HaLogbook extends EventsMixin(PolymerElement) {
} }
_formatTime(date) { _formatTime(date) {
return formatTime(new Date(date), this.language); return formatTime(new Date(date), this.hass.language);
} }
_formatDate(date) { _formatDate(date) {
return formatDate(new Date(date), this.language); return formatDate(new Date(date), this.hass.language);
} }
_needHeader(change, index) { _needHeader(change, index) {

View File

@ -106,7 +106,7 @@ class HaPanelLogbook extends LocalizeMixin(PolymerElement) {
disabled='[[isLoading]]' disabled='[[isLoading]]'
required required
></vaadin-date-picker> ></vaadin-date-picker>
<paper-dropdown-menu <paper-dropdown-menu
label-float label-float
label="[[localize('ui.panel.logbook.period')]]" label="[[localize('ui.panel.logbook.period')]]"
@ -121,7 +121,7 @@ class HaPanelLogbook extends LocalizeMixin(PolymerElement) {
<paper-item>[[localize('ui.duration.week', 'count', 1)]]</paper-item> <paper-item>[[localize('ui.duration.week', 'count', 1)]]</paper-item>
</paper-listbox> </paper-listbox>
</paper-dropdown-menu> </paper-dropdown-menu>
<ha-entity-picker <ha-entity-picker
hass="[[hass]]" hass="[[hass]]"
value="{{_entityId}}" value="{{_entityId}}"
@ -200,7 +200,7 @@ class HaPanelLogbook extends LocalizeMixin(PolymerElement) {
// We are unable to parse date because we use intl api to render date // We are unable to parse date because we use intl api to render date
this.$.picker.set("i18n.parseDate", null); this.$.picker.set("i18n.parseDate", null);
this.$.picker.set("i18n.formatDate", (date) => this.$.picker.set("i18n.formatDate", (date) =>
formatDate(new Date(date.year, date.month, date.day), this.language) formatDate(new Date(date.year, date.month, date.day), this.hass.language)
); );
} }

View File

@ -88,7 +88,7 @@ class HaLongLivedTokens extends LocalizeMixin(EventsMixin(PolymerElement)) {
return this.localize( return this.localize(
"ui.panel.profile.long_lived_access_tokens.created_at", "ui.panel.profile.long_lived_access_tokens.created_at",
"date", "date",
formatDateTime(new Date(created), this.language) formatDateTime(new Date(created), this.hass.language)
); );
} }

View File

@ -74,7 +74,7 @@ class HaPickLanguageRow extends LocalizeMixin(EventsMixin(PolymerElement)) {
languageSelectionChanged(newVal) { languageSelectionChanged(newVal) {
// Only fire event if language was changed. This prevents select updates when // Only fire event if language was changed. This prevents select updates when
// responding to hass changes. // responding to hass changes.
if (newVal !== this.language) { if (newVal !== this.hass.language) {
this.fire("hass-language-select", { language: newVal }); this.fire("hass-language-select", { language: newVal });
} }
} }

View File

@ -75,7 +75,7 @@ class HaRefreshTokens extends LocalizeMixin(EventsMixin(PolymerElement)) {
return this.localize( return this.localize(
"ui.panel.profile.refresh_tokens.created_at", "ui.panel.profile.refresh_tokens.created_at",
"date", "date",
formatDateTime(new Date(created), this.language) formatDateTime(new Date(created), this.hass.language)
); );
} }
@ -84,7 +84,7 @@ class HaRefreshTokens extends LocalizeMixin(EventsMixin(PolymerElement)) {
? this.localize( ? this.localize(
"ui.panel.profile.refresh_tokens.last_used", "ui.panel.profile.refresh_tokens.last_used",
"date", "date",
formatDateTime(new Date(item.last_used_at), this.language), formatDateTime(new Date(item.last_used_at), this.hass.language),
"location", "location",
item.last_used_ip item.last_used_ip
) )