Add ability to select priority in modal

And also disable immediately triggering assign when user is selected
This commit is contained in:
Nat 2022-04-20 02:15:36 +08:00
parent 8b575a0bab
commit ad45c6703f
No known key found for this signature in database
GPG Key ID: C095C891379A319E
5 changed files with 39 additions and 9 deletions

View File

@ -1,10 +1,18 @@
import Controller, { inject as controller } from "@ember/controller";
import { action } from "@ember/object";
import { not, or } from "@ember/object/computed";
import { inject as service } from "@ember/service";
import { isEmpty } from "@ember/utils";
import { ajax } from "discourse/lib/ajax";
import { popupAjaxError } from "discourse/lib/ajax-error";
import { not, or } from "@ember/object/computed";
import { isEmpty } from "@ember/utils";
import { action } from "@ember/object";
import I18n from "I18n";
const PRIORITIES = [
{ name: I18n.t("discourse_assign.priorities.low"), value: 4 },
{ name: I18n.t("discourse_assign.priorities.medium"), value: 3 },
{ name: I18n.t("discourse_assign.priorities.high"), value: 2 },
{ name: I18n.t("discourse_assign.priorities.urgent"), value: 1 },
];
export default Controller.extend({
topicBulkActions: controller(),
@ -13,6 +21,7 @@ export default Controller.extend({
taskActions: service(),
autofocus: not("capabilities.touch"),
assigneeName: or("model.username", "model.group_name"),
priorities: PRIORITIES,
init() {
this._super(...arguments);
@ -63,7 +72,6 @@ export default Controller.extend({
}
this.send("closeModal");
return ajax(path, {
type: "PUT",
data: {
@ -71,6 +79,7 @@ export default Controller.extend({
group_name: this.get("model.group_name"),
target_id: this.get("model.target.id"),
target_type: this.get("model.targetType"),
priority: this.get("model.priority"),
},
})
.then(() => {
@ -99,14 +108,15 @@ export default Controller.extend({
"model.allowedGroups": this.taskActions.allowedGroups,
});
}
if (name) {
return this.assign();
}
},
@action
assignUsername(selected) {
this.assignUser(selected.firstObject);
},
@action
assignPriority(priority) {
this.set("model.priority", priority);
},
});

View File

@ -23,6 +23,7 @@ const DEPENDENT_KEYS = [
"topic.assigned_to_group",
"currentUser.can_assign",
"topic.assigned_to_user.username",
"topic.assignment_priority",
];
function titleForState(name) {

View File

@ -38,6 +38,7 @@ export default Service.extend({
group_name: target.assigned_to_group?.name,
target,
targetType: options.targetType,
priority: target.assignment_priority,
},
});
},

View File

@ -25,6 +25,17 @@
</a>
{{/each}}
</div>
<label>{{i18n "discourse_assign.assign_modal.priority_label"}}</label>
{{combo-box
name="assign-priority"
content=priorities
value=model.priority
valueProperty="value"
onChange=(action "assignPriority")
options=(hash
none="discourse_assign.priorities.none"
)
}}
</div>
{{/d-modal-body}}

View File

@ -47,12 +47,13 @@ en:
help: "Reassign Topic to a different user"
reassign_modal:
title: "Reassign Topic"
description: "Enter the name of the user you'd like to Reassign this topic"
description: "Enter the name of the user you'd like to reassign this topic"
assign_modal:
title: "Assign Topic"
reassign_title: "Reassign Topic"
description: "Enter the name of the user you'd like to assign this topic"
assign: "Assign"
priority_label: Set a priority (Optional)
assign_post_modal:
title: "Assign Post"
description: "Enter the name of the user you'd like to assign this post"
@ -79,6 +80,12 @@ en:
assign: "Assign"
assignable_levels:
title: "Who can assign this group"
priorities:
none: None
low: Low
medium: Medium
high: High
urgent: Urgent
user:
messages:
assigned_title: "Assigned (%{count})"