Skip to content
This repository was archived by the owner on Jul 14, 2025. It is now read-only.

Commit ad45c67

Browse files
committed
Add ability to select priority in modal
And also disable immediately triggering assign when user is selected
1 parent 8b575a0 commit ad45c67

File tree

5 files changed

+39
-9
lines changed

5 files changed

+39
-9
lines changed

assets/javascripts/discourse-assign/controllers/assign-user.js

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,18 @@
11
import Controller, { inject as controller } from "@ember/controller";
2+
import { action } from "@ember/object";
3+
import { not, or } from "@ember/object/computed";
24
import { inject as service } from "@ember/service";
5+
import { isEmpty } from "@ember/utils";
36
import { ajax } from "discourse/lib/ajax";
47
import { popupAjaxError } from "discourse/lib/ajax-error";
5-
import { not, or } from "@ember/object/computed";
6-
import { isEmpty } from "@ember/utils";
7-
import { action } from "@ember/object";
8+
import I18n from "I18n";
9+
10+
const PRIORITIES = [
11+
{ name: I18n.t("discourse_assign.priorities.low"), value: 4 },
12+
{ name: I18n.t("discourse_assign.priorities.medium"), value: 3 },
13+
{ name: I18n.t("discourse_assign.priorities.high"), value: 2 },
14+
{ name: I18n.t("discourse_assign.priorities.urgent"), value: 1 },
15+
];
816

917
export default Controller.extend({
1018
topicBulkActions: controller(),
@@ -13,6 +21,7 @@ export default Controller.extend({
1321
taskActions: service(),
1422
autofocus: not("capabilities.touch"),
1523
assigneeName: or("model.username", "model.group_name"),
24+
priorities: PRIORITIES,
1625

1726
init() {
1827
this._super(...arguments);
@@ -63,14 +72,14 @@ export default Controller.extend({
6372
}
6473

6574
this.send("closeModal");
66-
6775
return ajax(path, {
6876
type: "PUT",
6977
data: {
7078
username: this.get("model.username"),
7179
group_name: this.get("model.group_name"),
7280
target_id: this.get("model.target.id"),
7381
target_type: this.get("model.targetType"),
82+
priority: this.get("model.priority"),
7483
},
7584
})
7685
.then(() => {
@@ -99,14 +108,15 @@ export default Controller.extend({
99108
"model.allowedGroups": this.taskActions.allowedGroups,
100109
});
101110
}
102-
103-
if (name) {
104-
return this.assign();
105-
}
106111
},
107112

108113
@action
109114
assignUsername(selected) {
110115
this.assignUser(selected.firstObject);
111116
},
117+
118+
@action
119+
assignPriority(priority) {
120+
this.set("model.priority", priority);
121+
},
112122
});

assets/javascripts/discourse-assign/initializers/extend-for-assigns.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ const DEPENDENT_KEYS = [
2323
"topic.assigned_to_group",
2424
"currentUser.can_assign",
2525
"topic.assigned_to_user.username",
26+
"topic.assignment_priority",
2627
];
2728

2829
function titleForState(name) {

assets/javascripts/discourse/services/task-actions.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ export default Service.extend({
3838
group_name: target.assigned_to_group?.name,
3939
target,
4040
targetType: options.targetType,
41+
priority: target.assignment_priority,
4142
},
4243
});
4344
},

assets/javascripts/discourse/templates/modal/assign-user.hbs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,17 @@
2525
</a>
2626
{{/each}}
2727
</div>
28+
<label>{{i18n "discourse_assign.assign_modal.priority_label"}}</label>
29+
{{combo-box
30+
name="assign-priority"
31+
content=priorities
32+
value=model.priority
33+
valueProperty="value"
34+
onChange=(action "assignPriority")
35+
options=(hash
36+
none="discourse_assign.priorities.none"
37+
)
38+
}}
2839
</div>
2940
{{/d-modal-body}}
3041

config/locales/client.en.yml

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,12 +47,13 @@ en:
4747
help: "Reassign Topic to a different user"
4848
reassign_modal:
4949
title: "Reassign Topic"
50-
description: "Enter the name of the user you'd like to Reassign this topic"
50+
description: "Enter the name of the user you'd like to reassign this topic"
5151
assign_modal:
5252
title: "Assign Topic"
5353
reassign_title: "Reassign Topic"
5454
description: "Enter the name of the user you'd like to assign this topic"
5555
assign: "Assign"
56+
priority_label: Set a priority (Optional)
5657
assign_post_modal:
5758
title: "Assign Post"
5859
description: "Enter the name of the user you'd like to assign this post"
@@ -79,6 +80,12 @@ en:
7980
assign: "Assign"
8081
assignable_levels:
8182
title: "Who can assign this group"
83+
priorities:
84+
none: None
85+
low: Low
86+
medium: Medium
87+
high: High
88+
urgent: Urgent
8289
user:
8390
messages:
8491
assigned_title: "Assigned (%{count})"

0 commit comments

Comments
 (0)