mirror of
https://github.com/discourse/discourse.git
synced 2025-05-24 02:01:15 +08:00
Introduces select-kit
* renames `select-box-kit` into `select-kit` * introduces `single-select` and `multi-select` as base components * introduces {{search-advanced-category-chooser}} as a better component for selecting category in advanced search * improves events handling in select-kit * recreates color selection inputs using {{multi-select}} and a custom {{selected-color}} component * replaces category-selector by a component using select-kit and based on multi-select * improves positioning of wrapper * removes the need for offscreen, and instead use `select-kit-header` as a base focus point for all select-kit based components * introduces a formal plugin api for select-kit based components * introduces a formal pattern for loading and updating select-kit based components: ``` computeValue() computeContent() mutateValue() ```
This commit is contained in:
@ -0,0 +1,77 @@
|
||||
import DropdownSelectBox from "select-kit/components/dropdown-select-box";
|
||||
import computed from "ember-addons/ember-computed-decorators";
|
||||
|
||||
export default DropdownSelectBox.extend({
|
||||
classNames: ["delete-flag", "admin-delete-flag-dropdown"],
|
||||
adminTools: Ember.inject.service(),
|
||||
nameProperty: "label",
|
||||
headerIcon: "trash-o",
|
||||
|
||||
computeHeaderContent() {
|
||||
let content = this.baseHeaderComputedContent();
|
||||
content.name = I18n.t("admin.flags.delete");
|
||||
return content;
|
||||
},
|
||||
|
||||
@computed("adminTools", "post.user")
|
||||
spammerDetails(adminTools, user) {
|
||||
return adminTools.spammerDetails(user);
|
||||
},
|
||||
|
||||
canDeleteSpammer: Ember.computed.and("spammerDetails.canDelete", "post.flaggedForSpam"),
|
||||
|
||||
computeContent() {
|
||||
const content = [];
|
||||
const canDeleteSpammer = this.get("canDeleteSpammer");
|
||||
|
||||
content.push({
|
||||
icon: "external-link",
|
||||
id: "delete-defer",
|
||||
action: () => this.send("deletePostDeferFlag"),
|
||||
label: I18n.t("admin.flags.delete_post_defer_flag"),
|
||||
description: I18n.t("admin.flags.delete_post_defer_flag_title"),
|
||||
});
|
||||
|
||||
content.push({
|
||||
icon: "thumbs-o-up",
|
||||
id: "delete-agree",
|
||||
action: () => this.send("deletePostAgreeFlag"),
|
||||
label: I18n.t("admin.flags.delete_post_agree_flag"),
|
||||
description: I18n.t("admin.flags.delete_post_agree_flag_title"),
|
||||
});
|
||||
|
||||
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;
|
||||
},
|
||||
|
||||
mutateValue(value) {
|
||||
const computedContentItem = this.get("computedContent").findBy("value", value);
|
||||
Ember.get(computedContentItem, "originalContent.action")();
|
||||
},
|
||||
|
||||
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'));
|
||||
}
|
||||
}
|
||||
});
|
Reference in New Issue
Block a user