Skip to content

Commit

Permalink
UX: improves dates on reports export UI (#7971)
Browse files Browse the repository at this point in the history
- show it's UTC
- allows future
- shows date in more human readable format
  • Loading branch information
jjaffeux committed Aug 6, 2019
1 parent 8390f23 commit d8dfa87
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 8 deletions.
26 changes: 26 additions & 0 deletions app/assets/javascripts/admin/components/admin-report.js.es6
Expand Up @@ -183,6 +183,32 @@ export default Ember.Component.extend({
},

actions: {
onChangeEndDate(date) {
const startDate = moment(this.startDate);
const newEndDate = moment(date).endOf("day");

if (newEndDate.isSameOrAfter(startDate)) {
this.set("endDate", newEndDate.format("YYYY-MM-DD"));
} else {
this.set("endDate", startDate.endOf("day").format("YYYY-MM-DD"));
}

this.send("refreshReport");
},

onChangeStartDate(date) {
const endDate = moment(this.endDate);
const newStartDate = moment(date).startOf("day");

if (newStartDate.isSameOrBefore(endDate)) {
this.set("startDate", newStartDate.format("YYYY-MM-DD"));
} else {
this.set("startDate", endDate.startOf("day").format("YYYY-MM-DD"));
}

this.send("refreshReport");
},

applyFilter(id, value) {
let customFilters = this.get("filters.customFilters") || {};

Expand Down
Expand Up @@ -130,9 +130,7 @@
</span>

<div class="input">
{{date-picker-past
value=startDate
defaultDate=startDate}}
{{date-input date=startDate onChange=(action "onChangeStartDate")}}
</div>
</div>

Expand All @@ -142,9 +140,7 @@
</span>

<div class="input">
{{date-picker-past
value=endDate
defaultDate=endDate}}
{{date-input date=endDate onChange=(action "onChangeEndDate")}}
</div>
</div>
{{/if}}
Expand Down
4 changes: 2 additions & 2 deletions config/locales/client.en.yml
Expand Up @@ -3155,8 +3155,8 @@ en:
view_table: "table"
view_graph: "graph"
refresh_report: "Refresh Report"
start_date: "Start Date"
end_date: "End Date"
start_date: "Start Date (UTC)"
end_date: "End Date (UTC)"
groups: "All groups"
disabled: "This report is disabled"
totals_for_sample: "Totals for sample"
Expand Down

0 comments on commit d8dfa87

Please sign in to comment.