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