2017-11-21 05:53:09 -05:00
|
|
|
import DropdownSelectBox from "select-kit/components/dropdown-select-box";
|
2017-11-14 10:55:08 -05:00
|
|
|
import computed from "ember-addons/ember-computed-decorators";
|
2018-03-22 06:29:55 -04:00
|
|
|
const { get } = Ember;
|
2017-11-14 10:55:08 -05:00
|
|
|
|
|
|
|
export default DropdownSelectBox.extend({
|
|
|
|
classNames: ["delete-flag", "admin-delete-flag-dropdown"],
|
|
|
|
adminTools: Ember.inject.service(),
|
|
|
|
nameProperty: "label",
|
2017-11-21 05:53:09 -05:00
|
|
|
headerIcon: "trash-o",
|
2017-11-14 10:55:08 -05:00
|
|
|
|
2017-11-21 05:53:09 -05:00
|
|
|
computeHeaderContent() {
|
2018-03-22 06:29:55 -04:00
|
|
|
let content = this._super();
|
2018-01-29 19:15:03 -05:00
|
|
|
content.name = `${I18n.t("admin.flags.delete")}...`;
|
2017-11-21 05:53:09 -05:00
|
|
|
return content;
|
2017-11-14 10:55:08 -05:00
|
|
|
},
|
|
|
|
|
|
|
|
@computed("adminTools", "post.user")
|
|
|
|
spammerDetails(adminTools, user) {
|
|
|
|
return adminTools.spammerDetails(user);
|
|
|
|
},
|
|
|
|
|
|
|
|
canDeleteSpammer: Ember.computed.and("spammerDetails.canDelete", "post.flaggedForSpam"),
|
|
|
|
|
2017-11-21 05:53:09 -05:00
|
|
|
computeContent() {
|
2017-11-14 10:55:08 -05:00
|
|
|
const content = [];
|
2017-11-21 05:53:09 -05:00
|
|
|
const canDeleteSpammer = this.get("canDeleteSpammer");
|
2017-11-14 10:55:08 -05:00
|
|
|
|
|
|
|
content.push({
|
|
|
|
icon: "external-link",
|
|
|
|
id: "delete-defer",
|
|
|
|
action: () => this.send("deletePostDeferFlag"),
|
2017-11-14 15:44:16 -05:00
|
|
|
label: I18n.t("admin.flags.delete_post_defer_flag"),
|
|
|
|
description: I18n.t("admin.flags.delete_post_defer_flag_title"),
|
2017-11-14 10:55:08 -05:00
|
|
|
});
|
|
|
|
|
|
|
|
content.push({
|
|
|
|
icon: "thumbs-o-up",
|
|
|
|
id: "delete-agree",
|
|
|
|
action: () => this.send("deletePostAgreeFlag"),
|
2017-11-14 15:44:16 -05:00
|
|
|
label: I18n.t("admin.flags.delete_post_agree_flag"),
|
|
|
|
description: I18n.t("admin.flags.delete_post_agree_flag_title"),
|
2017-11-14 10:55:08 -05:00
|
|
|
});
|
|
|
|
|
|
|
|
if (canDeleteSpammer) {
|
|
|
|
content.push({
|
|
|
|
title: I18n.t("admin.flags.delete_post_agree_flag_title"),
|
|
|
|
icon: "exclamation-triangle",
|
|
|
|
id: "delete-spammer",
|
|
|
|
action: () => this.send("deleteSpammer"),
|
|
|
|
label: I18n.t("admin.flags.delete_spammer")
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
return content;
|
|
|
|
},
|
|
|
|
|
2017-11-21 05:53:09 -05:00
|
|
|
mutateValue(value) {
|
|
|
|
const computedContentItem = this.get("computedContent").findBy("value", value);
|
2018-03-22 06:29:55 -04:00
|
|
|
get(computedContentItem, "originalContent.action")();
|
2017-11-14 10:55:08 -05:00
|
|
|
},
|
|
|
|
|
|
|
|
actions: {
|
|
|
|
deleteSpammer() {
|
|
|
|
let spammerDetails = this.get("spammerDetails");
|
|
|
|
this.attrs.removeAfter(spammerDetails.deleteUser());
|
|
|
|
},
|
|
|
|
|
|
|
|
deletePostDeferFlag() {
|
|
|
|
let flaggedPost = this.get('post');
|
|
|
|
this.attrs.removeAfter(flaggedPost.deferFlags(true));
|
|
|
|
},
|
|
|
|
|
|
|
|
deletePostAgreeFlag() {
|
|
|
|
let flaggedPost = this.get('post');
|
|
|
|
this.attrs.removeAfter(flaggedPost.agreeFlags('delete'));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|