mirror of
https://github.com/discourse/discourse.git
synced 2024-11-23 20:54:31 +08:00
UX: Use created_at as the default order when viewing reviewed items or everything (#9601)
This commit is contained in:
parent
0fe8ad13fa
commit
29c6c4b092
|
@ -25,7 +25,7 @@ export default Controller.extend({
|
|||
username: "",
|
||||
from_date: null,
|
||||
to_date: null,
|
||||
sort_order: "priority",
|
||||
sort_order: null,
|
||||
additional_filters: null,
|
||||
|
||||
init(...args) {
|
||||
|
@ -108,6 +108,38 @@ export default Controller.extend({
|
|||
},
|
||||
|
||||
refresh() {
|
||||
const currentStatus = this.status;
|
||||
const nextStatus = this.filterStatus;
|
||||
const currentOrder = this.sort_order;
|
||||
let nextOrder = this.filterSortOrder;
|
||||
|
||||
const createdAtStatuses = ["reviewed", "all"];
|
||||
const priorityStatuses = [
|
||||
"approved",
|
||||
"rejected",
|
||||
"deleted",
|
||||
"ignored",
|
||||
"pending"
|
||||
];
|
||||
|
||||
if (
|
||||
createdAtStatuses.includes(currentStatus) &&
|
||||
currentOrder === "created_at" &&
|
||||
priorityStatuses.includes(nextStatus) &&
|
||||
nextOrder === "created_at"
|
||||
) {
|
||||
nextOrder = "priority";
|
||||
}
|
||||
|
||||
if (
|
||||
priorityStatuses.includes(currentStatus) &&
|
||||
currentOrder === "priority" &&
|
||||
createdAtStatuses.includes(nextStatus) &&
|
||||
nextOrder === "priority"
|
||||
) {
|
||||
nextOrder = "created_at";
|
||||
}
|
||||
|
||||
this.setProperties({
|
||||
type: this.filterType,
|
||||
priority: this.filterPriority,
|
||||
|
@ -120,7 +152,7 @@ export default Controller.extend({
|
|||
to_date: isPresent(this.filterToDate)
|
||||
? this.filterToDate.toISOString(true).split("T")[0]
|
||||
: null,
|
||||
sort_order: this.filterSortOrder,
|
||||
sort_order: nextOrder,
|
||||
additional_filters: JSON.stringify(this.additionalFilters)
|
||||
});
|
||||
|
||||
|
|
|
@ -3,6 +3,14 @@ import { isPresent } from "@ember/utils";
|
|||
|
||||
export default DiscourseRoute.extend({
|
||||
model(params) {
|
||||
if (params.sort_order === null) {
|
||||
if (params.status === "reviewed" || params.status === "all") {
|
||||
params.sort_order = "created_at";
|
||||
} else {
|
||||
params.sort_order = "priority";
|
||||
}
|
||||
}
|
||||
|
||||
return this.store.findAll("reviewable", params);
|
||||
},
|
||||
|
||||
|
@ -27,6 +35,7 @@ export default DiscourseRoute.extend({
|
|||
filterFromDate: isPresent(meta.from_date) ? moment(meta.from_date) : null,
|
||||
filterToDate: isPresent(meta.to_date) ? moment(meta.to_date) : null,
|
||||
filterSortOrder: meta.sort_order,
|
||||
sort_order: meta.sort_order,
|
||||
additionalFilters: meta.additional_filters || {}
|
||||
});
|
||||
},
|
||||
|
|
Loading…
Reference in New Issue
Block a user