REFACTOR: Convert admin flagged posts to a component
This commit is contained in:
@@ -1,24 +1,19 @@
|
||||
import ModalFunctionality from 'discourse/mixins/modal-functionality';
|
||||
|
||||
export default Ember.Controller.extend(ModalFunctionality, {
|
||||
adminFlagsList: Ember.inject.controller(),
|
||||
removeAfter: null,
|
||||
|
||||
_agreeFlag: function (actionOnPost) {
|
||||
const adminFlagController = this.get("adminFlagsList");
|
||||
const post = this.get("content");
|
||||
|
||||
return post.agreeFlags(actionOnPost).then(() => {
|
||||
adminFlagController.get('model').removeObject(post);
|
||||
this.send("closeModal");
|
||||
}, function () {
|
||||
bootbox.alert(I18n.t("admin.flags.error"));
|
||||
_agreeFlag(action) {
|
||||
let flaggedPost = this.get('model');
|
||||
return this.removeAfter(flaggedPost.agreeFlags(action), flaggedPost).then(() => {
|
||||
this.send('closeModal');
|
||||
});
|
||||
},
|
||||
|
||||
actions: {
|
||||
agreeFlagHidePost: function () { return this._agreeFlag("hide"); },
|
||||
agreeFlagKeepPost: function () { return this._agreeFlag("keep"); },
|
||||
agreeFlagRestorePost: function () { return this._agreeFlag("restore"); }
|
||||
agreeFlagHidePost() { return this._agreeFlag("hide"); },
|
||||
agreeFlagKeepPost() { return this._agreeFlag("keep"); },
|
||||
agreeFlagRestorePost() { return this._agreeFlag("restore"); }
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
@@ -1,30 +1,20 @@
|
||||
import ModalFunctionality from 'discourse/mixins/modal-functionality';
|
||||
|
||||
export default Ember.Controller.extend(ModalFunctionality, {
|
||||
adminFlagsList: Ember.inject.controller(),
|
||||
removeAfter: null,
|
||||
|
||||
actions: {
|
||||
deletePostDeferFlag() {
|
||||
const adminFlagController = this.get("adminFlagsList");
|
||||
const post = this.get("content");
|
||||
|
||||
return post.deferFlags(true).then(() => {
|
||||
adminFlagController.get('model').removeObject(post);
|
||||
this.send("closeModal");
|
||||
}, function () {
|
||||
bootbox.alert(I18n.t("admin.flags.error"));
|
||||
let flaggedPost = this.get('model');
|
||||
this.removeAfter(flaggedPost.deferFlags(true), flaggedPost).then(() => {
|
||||
this.send('closeModal');
|
||||
});
|
||||
},
|
||||
|
||||
deletePostAgreeFlag() {
|
||||
const adminFlagController = this.get("adminFlagsList");
|
||||
const post = this.get("content");
|
||||
|
||||
return post.agreeFlags("delete").then(() => {
|
||||
adminFlagController.get('model').removeObject(post);
|
||||
this.send("closeModal");
|
||||
}, function () {
|
||||
bootbox.alert(I18n.t("admin.flags.error"));
|
||||
let flaggedPost = this.get('model');
|
||||
this.removeAfter(flaggedPost.agreeFlags('delete'), flaggedPost).then(() => {
|
||||
this.send('closeModal');
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user