FIX: add ability to show report data for all categories

This commit is contained in:
Neil Lalonde 2015-07-03 12:58:13 -04:00
parent 67135a472a
commit 06dc63fbae
3 changed files with 14 additions and 8 deletions

View File

@ -7,16 +7,21 @@ export default Ember.ObjectController.extend({
categoryId: null,
refreshing: false,
categoryOptions: function() {
var arr = [{name: I18n.t('category.all'), value: 'all'}];
return arr.concat( Discourse.Site.currentProp('sortedCategories').map(function(i) { return {name: i.get('name'), value: i.get('id') }; }) );
}.property(),
actions: {
refreshReport() {
var q;
this.set("refreshing", true);
Discourse.Report.find(
this.get("type"),
this.get("startDate"),
this.get("endDate"),
this.get("categoryId")
).then(m => this.set("model", m)
).finally(() => this.set("refreshing", false));
if (this.get('categoryId') === "all") {
q = Discourse.Report.find(this.get("model.type"), this.get("startDate"), this.get("endDate"));
} else {
q = Discourse.Report.find(this.get("model.type"), this.get("startDate"), this.get("endDate"), this.get("categoryId"));
}
q.then(m => this.set("model", m)).finally(() => this.set("refreshing", false));
},
viewAsTable() {

View File

@ -3,7 +3,7 @@
<div>
{{i18n 'admin.dashboard.reports.start_date'}} {{input type="date" value=startDate}}
{{i18n 'admin.dashboard.reports.end_date'}} {{input type="date" value=endDate}}
{{category-chooser valueAttribute="id" value=categoryId source=categoryId}}
{{combo-box valueAttribute="value" content=categoryOptions value=categoryId}}
{{d-button action="refreshReport" class="btn-primary" label="admin.dashboard.reports.refresh_report" icon="refresh"}}
</div>

View File

@ -1411,6 +1411,7 @@ en:
category:
can: 'can&hellip; '
none: '(no category)'
all: 'All categories'
choose: 'Select a category&hellip;'
edit: 'edit'
edit_long: "Edit"