Skip to content

Commit

Permalink
[#358] Report#datepicker: default value not filled on initial load (#359
Browse files Browse the repository at this point in the history
)

The date picker does not display the date range of summary view on
load.

Let's obtain the date picker value from the hash param if provided,
otherwise, set it to be the minimum and maximum dates of the generated
report by default.
  • Loading branch information
ongspxm authored and eugenepeh committed Oct 14, 2018
1 parent 0337d36 commit adec166
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 5 deletions.
6 changes: 4 additions & 2 deletions frontend/src/index.jade
Original file line number Diff line number Diff line change
Expand Up @@ -67,10 +67,12 @@ html
label granularity
.summary-picker__section
.mui-textfield.summary-picker__date
input(type="date", v-model="tmpFilterSinceDate", v-bind:min="minDate", v-bind:max="filterUntilDate")
input(type="date", v-model="tmpFilterSinceDate", onkeydown="return false",
v-bind:min="minDate", v-bind:max="filterUntilDate")
label since
.mui-textfield.summary-picker__date
input(type="date", v-model="tmpFilterUntilDate", v-bind:min="filterSinceDate", v-bind:max="maxDate")
input(type="date", v-model="tmpFilterUntilDate", onkeydown="return false",
v-bind:min="filterSinceDate", v-bind:max="maxDate")
label until
.summary-picker__checkboxes.summary-picker__section
label
Expand Down
18 changes: 15 additions & 3 deletions frontend/src/static/js/v_summary.js
Original file line number Diff line number Diff line change
Expand Up @@ -192,16 +192,20 @@ window.vSummary = {
if (hash.search) { this.filterSearch = hash.search; }
if (hash.sort) { this.filterSort = hash.sort; }

if (hash.since) { this.filterSinceDate = hash.since; }
if (hash.until) { this.filterUntilDate = hash.until; }
if (hash.timeframe) { this.filterTimeFrame = hash.timeframe; }
if (hash.since) {
this.tmpFilterSinceDate = hash.since;
}
if (hash.until) {
this.tmpFilterUntilDate = hash.until;
}

if (hash.reverse) { this.filterSortReverse = convertBool(hash.reverse); }
if (hash.repoSort) { this.filterGroupRepos = convertBool(hash.repoSort); }
},

getDates() {
if (this.filterSinceDate && this.filterUntilDate) {
if (this.minDate && this.maxDate) {
return;
}

Expand All @@ -224,11 +228,19 @@ window.vSummary = {
});

if (!this.filterSinceDate) {
if(!this.tmpFilterSinceDate || this.tmpFilterSinceDate < minDate){
this.tmpFilterSinceDate = minDate;
}

this.filterSinceDate = minDate;
this.minDate = minDate;
}

if (!this.filterUntilDate) {
if(!this.tmpFilterUntilDate || this.tmpFilterUntilDate > maxDate){
this.tmpFilterUntilDate = maxDate;
}

this.filterUntilDate = maxDate;
this.maxDate = maxDate;
}
Expand Down

0 comments on commit adec166

Please sign in to comment.