This is a feature that used to be present in discourse-assign but is much easier to implement in core. It also allows a topic to be assigned without it claiming for review and vice versa and allows it to work with category group reviewers.
34 lines
793 B
JavaScript
34 lines
793 B
JavaScript
import computed from "ember-addons/ember-computed-decorators";
|
|
import { popupAjaxError } from "discourse/lib/ajax-error";
|
|
import { ajax } from "discourse/lib/ajax";
|
|
|
|
export default Ember.Component.extend({
|
|
tagName: "",
|
|
|
|
@computed
|
|
enabled() {
|
|
return this.siteSettings.reviewable_claiming !== "disabled";
|
|
},
|
|
|
|
actions: {
|
|
unclaim() {
|
|
ajax(`/reviewable_claimed_topics/${this.get("topicId")}`, {
|
|
method: "DELETE"
|
|
}).then(() => {
|
|
this.set("claimedBy", null);
|
|
});
|
|
},
|
|
|
|
claim() {
|
|
let claim = this.store.createRecord("reviewable-claimed-topic");
|
|
|
|
claim
|
|
.save({ topic_id: this.get("topicId") })
|
|
.then(() => {
|
|
this.set("claimedBy", this.currentUser);
|
|
})
|
|
.catch(popupAjaxError);
|
|
}
|
|
}
|
|
});
|