Skip to content

Commit

Permalink
WIP: refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
AndrewPrigorshnev committed Mar 4, 2024
1 parent 286efd1 commit 8524998
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
2 changes: 1 addition & 1 deletion assets/javascripts/discourse/services/task-actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ export default class TaskActions extends Service {
}

unassignPost(postId) {
this.unassign(postId, "Post");
return this.unassign(postId, "Post");
}

showAssignModal(
Expand Down
10 changes: 8 additions & 2 deletions assets/javascripts/discourse/widgets/assigned-to.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,13 @@ export const AssignedToWidget = ["assigned-to", {
"span",
hbs`
<DMenu @inline={{true}} @label="...">
<Menu::Buttons::UnassignPost @post={{@data.post}} />
<Menu::Buttons::EditPostAssignment @post={{@data.post}} />
<button {{on "click" @data.unassign}}>Unassign</button>

Check failure on line 41 in assets/javascripts/discourse/widgets/assigned-to.js

View workflow job for this annotation

GitHub Actions / ci / linting

All `<button>` elements should have a valid `type` attribute
<button {{on "click" @data.editAssignment}}>Edit assignment...</button>

Check failure on line 42 in assets/javascripts/discourse/widgets/assigned-to.js

View workflow job for this annotation

GitHub Actions / ci / linting

All `<button>` elements should have a valid `type` attribute
</DMenu>
`,
{
post: this.attrs.post,
unassign: () => this.unassign(),
editAssignment: () => this.editAssignment()
}
)
Expand All @@ -56,5 +56,11 @@ export const AssignedToWidget = ["assigned-to", {
taskActions.showAssignModal(this.attrs.post, {
targetType: "Post",
});
},

unassign() {
const taskActions = getOwner(this).lookup("service:task-actions");
const post = this.attrs.post;
taskActions.unassignPost(post.id).then(() => delete post.topic.indirectly_assigned_to[post.id]);
}
}];

0 comments on commit 8524998

Please sign in to comment.