This repository has been archived on 2023-03-18. You can view files and clone it, but cannot push or open issues or pull requests.
osr-discourse-src/app/assets/javascripts/discourse/controllers/review-index.js.es6
Robin Ward 5af7c90bab FEATURE: Hide Reviewable scores, change score filter to Priority
We found score hard to understand. It is still there behind the scenes
for sorting purposes, but it is no longer shown.

You can now filter by minimum priority (low, med, high) instead of
score.
2019-05-07 14:05:23 -04:00

103 lines
2.1 KiB
JavaScript

import computed from "ember-addons/ember-computed-decorators";
export default Ember.Controller.extend({
queryParams: [
"priority",
"type",
"status",
"category_id",
"topic_id",
"username"
],
type: null,
status: "pending",
priority: "low",
category_id: null,
reviewables: null,
topic_id: null,
filtersExpanded: false,
username: "",
init(...args) {
this._super(...args);
this.set("priority", this.siteSettings.reviewable_default_visibility);
this.set("filtersExpanded", !this.site.mobileView);
},
@computed("reviewableTypes")
allTypes() {
return (this.get("reviewableTypes") || []).map(type => {
return {
id: type,
name: I18n.t(`review.types.${type.underscore()}.title`)
};
});
},
@computed
priorities() {
return ["low", "medium", "high"].map(priority => {
return {
id: priority,
name: I18n.t(`review.filters.priority.${priority}`)
};
});
},
@computed
statuses() {
return [
"pending",
"approved",
"rejected",
"ignored",
"reviewed",
"all"
].map(id => {
return { id, name: I18n.t(`review.statuses.${id}.title`) };
});
},
@computed("filtersExpanded")
toggleFiltersIcon(filtersExpanded) {
return filtersExpanded ? "chevron-up" : "chevron-down";
},
actions: {
remove(ids) {
if (!ids) {
return;
}
let newList = this.get("reviewables").reject(reviewable => {
return ids.indexOf(reviewable.id) !== -1;
});
this.set("reviewables", newList);
},
resetTopic() {
this.set("topic_id", null);
this.send("refreshRoute");
},
refresh() {
this.setProperties({
type: this.get("filterType"),
priority: this.get("filterPriority"),
status: this.get("filterStatus"),
category_id: this.get("filterCategoryId"),
username: this.get("filterUsername")
});
this.send("refreshRoute");
},
loadMore() {
return this.get("reviewables").loadMore();
},
toggleFilters() {
this.toggleProperty("filtersExpanded");
}
}
});