2017-11-21 18:53:09 +08:00
|
|
|
import ComboBoxComponent from "select-kit/components/combo-box";
|
2017-10-20 03:51:08 +08:00
|
|
|
|
|
|
|
export default ComboBoxComponent.extend({
|
2017-11-21 18:53:09 +08:00
|
|
|
pluginApiIdentifiers: ["topic-footer-mobile-dropdown"],
|
2017-10-20 03:51:08 +08:00
|
|
|
classNames: "topic-footer-mobile-dropdown",
|
|
|
|
filterable: false,
|
|
|
|
autoFilterable: false,
|
2017-11-21 18:53:09 +08:00
|
|
|
allowInitialValueMutation: false,
|
2017-10-20 03:51:08 +08:00
|
|
|
|
2017-11-21 18:53:09 +08:00
|
|
|
computeHeaderContent() {
|
2018-03-22 18:29:55 +08:00
|
|
|
let content = this._super();
|
2017-11-21 18:53:09 +08:00
|
|
|
content.name = I18n.t("topic.controls");
|
|
|
|
return content;
|
2017-10-20 03:51:08 +08:00
|
|
|
},
|
|
|
|
|
2017-11-21 18:53:09 +08:00
|
|
|
computeContent(content) {
|
|
|
|
const topic = this.get("topic");
|
|
|
|
const details = topic.get("details");
|
2017-10-20 03:51:08 +08:00
|
|
|
|
|
|
|
if (details.get("can_invite_to")) {
|
2018-06-15 23:03:24 +08:00
|
|
|
content.push({
|
|
|
|
id: "invite",
|
|
|
|
icon: "users",
|
|
|
|
name: I18n.t("topic.invite_reply.title")
|
|
|
|
});
|
2017-10-20 03:51:08 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
if (topic.get("bookmarked")) {
|
2018-06-15 23:03:24 +08:00
|
|
|
content.push({
|
|
|
|
id: "bookmark",
|
|
|
|
icon: "bookmark",
|
|
|
|
name: I18n.t("bookmarked.clear_bookmarks")
|
|
|
|
});
|
2017-10-20 03:51:08 +08:00
|
|
|
} else {
|
2018-06-15 23:03:24 +08:00
|
|
|
content.push({
|
|
|
|
id: "bookmark",
|
|
|
|
icon: "bookmark",
|
|
|
|
name: I18n.t("bookmarked.title")
|
|
|
|
});
|
2017-10-20 03:51:08 +08:00
|
|
|
}
|
|
|
|
|
2018-06-15 23:03:24 +08:00
|
|
|
content.push({
|
|
|
|
id: "share",
|
|
|
|
icon: "link",
|
|
|
|
name: I18n.t("topic.share.title")
|
|
|
|
});
|
2017-10-20 03:51:08 +08:00
|
|
|
|
|
|
|
if (details.get("can_flag_topic")) {
|
2018-06-15 23:03:24 +08:00
|
|
|
content.push({
|
|
|
|
id: "flag",
|
|
|
|
icon: "flag",
|
|
|
|
name: I18n.t("topic.flag_topic.title")
|
|
|
|
});
|
2017-10-20 03:51:08 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
return content;
|
|
|
|
},
|
|
|
|
|
2017-11-21 18:53:09 +08:00
|
|
|
autoHighlight() {},
|
|
|
|
|
|
|
|
mutateValue(value) {
|
2017-11-10 02:57:53 +08:00
|
|
|
const topic = this.get("topic");
|
2017-10-20 03:51:08 +08:00
|
|
|
|
2017-11-10 02:57:53 +08:00
|
|
|
if (!topic.get("id")) {
|
|
|
|
return;
|
|
|
|
}
|
2017-10-20 03:51:08 +08:00
|
|
|
|
2018-03-22 18:29:55 +08:00
|
|
|
const refresh = () => this.deselect(this.get("selection"));
|
2017-10-20 03:51:08 +08:00
|
|
|
|
2018-06-15 23:03:24 +08:00
|
|
|
switch (value) {
|
2017-11-10 02:57:53 +08:00
|
|
|
case "invite":
|
|
|
|
this.attrs.showInvite();
|
|
|
|
refresh();
|
|
|
|
break;
|
|
|
|
case "bookmark":
|
2018-06-15 23:03:24 +08:00
|
|
|
topic.toggleBookmark().then(() => refresh());
|
2017-11-10 02:57:53 +08:00
|
|
|
break;
|
|
|
|
case "share":
|
2018-06-15 23:03:24 +08:00
|
|
|
this.appEvents.trigger(
|
|
|
|
"share:url",
|
|
|
|
topic.get("shareUrl"),
|
|
|
|
$("#topic-footer-buttons")
|
|
|
|
);
|
2017-11-10 02:57:53 +08:00
|
|
|
refresh();
|
|
|
|
break;
|
|
|
|
case "flag":
|
|
|
|
this.attrs.showFlagTopic();
|
|
|
|
refresh();
|
|
|
|
break;
|
2017-10-20 03:51:08 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|