FEATURE: allow adding note when bulk assigning topics
This commit is contained in:
parent
9c270cac9a
commit
7ab93d1410
|
|
@ -43,10 +43,11 @@ export default Controller.extend(ModalFunctionality, {
|
|||
}
|
||||
},
|
||||
|
||||
bulkAction(username) {
|
||||
bulkAction(username, note) {
|
||||
return this.topicBulkActions.performAndRefresh({
|
||||
type: "assign",
|
||||
username,
|
||||
note,
|
||||
});
|
||||
},
|
||||
|
||||
|
|
@ -81,7 +82,10 @@ export default Controller.extend(ModalFunctionality, {
|
|||
@action
|
||||
assign() {
|
||||
if (this.isBulkAction) {
|
||||
return this.bulkAction(this.model.username);
|
||||
return this.bulkAction(
|
||||
this.get("model.username"),
|
||||
this.get("model.note")
|
||||
);
|
||||
}
|
||||
|
||||
if (!this.assigneeName) {
|
||||
|
|
@ -127,10 +131,6 @@ export default Controller.extend(ModalFunctionality, {
|
|||
|
||||
@action
|
||||
assignUser(name) {
|
||||
if (this.isBulkAction) {
|
||||
return this.bulkAction(name);
|
||||
}
|
||||
|
||||
this.setGroupOrUser(name);
|
||||
|
||||
if (name) {
|
||||
|
|
@ -140,10 +140,6 @@ export default Controller.extend(ModalFunctionality, {
|
|||
|
||||
@action
|
||||
assignUsername(selected) {
|
||||
if (this.isBulkAction) {
|
||||
return this.bulkAction(selected.firstObject);
|
||||
}
|
||||
|
||||
this.setGroupOrUser(selected.firstObject);
|
||||
},
|
||||
|
||||
|
|
|
|||
|
|
@ -945,7 +945,7 @@ export default {
|
|||
actions: {
|
||||
showReAssign() {
|
||||
this.set("assignUser.isBulkAction", true);
|
||||
this.set("assignUser.model", { username: "" });
|
||||
this.set("assignUser.model", { username: "", note: "" });
|
||||
this.send("changeBulkTemplate", "modal/assign-user");
|
||||
},
|
||||
unassignTopics() {
|
||||
|
|
|
|||
|
|
@ -627,7 +627,9 @@ after_initialize do
|
|||
TopicsBulkAction.register_operation("assign") do
|
||||
if @user.can_assign?
|
||||
assign_user = User.find_by_username(@operation[:username])
|
||||
topics.each { |topic| Assigner.new(topic, @user).assign(assign_user) }
|
||||
topics.each do |topic|
|
||||
Assigner.new(topic, @user).assign(assign_user, note: @operation[:note])
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
|
@ -638,6 +640,7 @@ after_initialize do
|
|||
end
|
||||
|
||||
register_permitted_bulk_action_parameter :username
|
||||
register_permitted_bulk_action_parameter :note
|
||||
|
||||
add_to_class(:user_bookmark_base_serializer, :assigned_to) do
|
||||
@assigned_to ||=
|
||||
|
|
|
|||
|
|
@ -22,7 +22,7 @@ describe TopicsBulkAction do
|
|||
TopicsBulkAction.new(
|
||||
user,
|
||||
[post.topic.id, post1.topic.id],
|
||||
{ type: "assign", username: user.username },
|
||||
{ type: "assign", username: user.username, note: "foobar" },
|
||||
).perform!
|
||||
|
||||
assigned_topics = TopicQuery.new(user, { page: 0 }).list_messages_assigned(user).topics
|
||||
|
|
@ -30,6 +30,9 @@ describe TopicsBulkAction do
|
|||
expect(assigned_topics.length).to eq(2)
|
||||
|
||||
expect(assigned_topics).to contain_exactly(post.topic, post1.topic)
|
||||
|
||||
expect(post.topic.assignment.note).to eq "foobar"
|
||||
expect(post1.topic.assignment.note).to eq "foobar"
|
||||
end
|
||||
|
||||
it "doesn't allows to assign to user not in assign_allowed_group" do
|
||||
|
|
|
|||
Loading…
Reference in New Issue