Merge branch 'pr/79'

This commit is contained in:
Paulus Schoutsen 2016-07-27 20:24:38 -07:00
commit 75bea5f615
3 changed files with 48 additions and 6 deletions

@ -1 +1 @@
Subproject commit b7ac88af0bf5a6065c021e47dc6af0f7006b187b Subproject commit 114f8ad6517744889b2a013a6b4836e89083df4a

View File

@ -35,8 +35,12 @@
on-tap="handleRefreshClick"></paper-icon-button> on-tap="handleRefreshClick"></paper-icon-button>
<div class$="[[computeContentClasses(narrow)]]"> <div class$="[[computeContentClasses(narrow)]]">
<paper-input label='Showing entries for' id='datePicker' <paper-input
value='[[selectedDate]]'></paper-input> label='Showing entries for'
id='datePicker'
value='[[selectedDateStr]]'
on-focus='datepickerFocus'
></paper-input>
<state-history-charts state-history="[[stateHistory]]" <state-history-charts state-history="[[stateHistory]]"
is-loading-data="[[isLoadingData]]"></state-history-charts> is-loading-data="[[isLoadingData]]"></state-history-charts>
@ -94,6 +98,20 @@ Polymer({
return hass.entityHistoryGetters.currentDate; return hass.entityHistoryGetters.currentDate;
}, },
}, },
selectedDateStr: {
type: String,
value: null,
bindNuclear: function (hass) {
return [
hass.entityHistoryGetters.currentDate,
function (currentDate) {
var dateObj = new Date(currentDate);
return dateObj.toLocaleDateString();
},
];
},
},
}, },
isDataLoadedChanged: function (newVal) { isDataLoadedChanged: function (newVal) {
@ -114,9 +132,14 @@ Polymer({
attached: function () { attached: function () {
this.datePicker = new window.Pikaday({ this.datePicker = new window.Pikaday({
field: this.$.datePicker.inputElement, // Bind field to dummy input to prevent pikaday from overwriting
// field value with its internal formatting.
field: document.createElement('input'),
trigger: this.$.datePicker.inputElement,
onSelect: this.hass.entityHistoryActions.changeCurrentDate, onSelect: this.hass.entityHistoryActions.changeCurrentDate,
}); });
// Set the initial datePicker date, without triggering onSelect handler.
this.datePicker.setDate(this.selectedDate, true);
}, },
detached: function () { detached: function () {

View File

@ -37,7 +37,7 @@
<paper-input <paper-input
label='Showing entries for' label='Showing entries for'
id='datePicker' id='datePicker'
value='[[selectedDate]]' value='[[selectedDateStr]]'
on-focus='datepickerFocus' on-focus='datepickerFocus'
></paper-input> ></paper-input>
@ -77,6 +77,20 @@ Polymer({
}, },
}, },
selectedDateStr: {
type: String,
value: null,
bindNuclear: function (hass) {
return [
hass.logbookGetters.currentDate,
function (currentDate) {
var dateObj = new Date(currentDate);
return dateObj.toLocaleDateString();
},
];
},
},
isLoading: { isLoading: {
type: Boolean, type: Boolean,
bindNuclear: function (hass) { bindNuclear: function (hass) {
@ -125,9 +139,14 @@ Polymer({
attached: function () { attached: function () {
this.datePicker = new window.Pikaday({ this.datePicker = new window.Pikaday({
field: this.$.datePicker.inputElement, // Bind field to dummy input to prevent pikaday from overwriting
// field value with its internal formatting.
field: document.createElement('input'),
trigger: this.$.datePicker.inputElement,
onSelect: this.hass.logbookActions.changeCurrentDate, onSelect: this.hass.logbookActions.changeCurrentDate,
}); });
// Set the initial datePicker date, without triggering onSelect handler.
this.datePicker.setDate(this.selectedDate, true);
}, },
detached: function () { detached: function () {