2017-10-19 15:51:08 -04:00
|
|
|
import computed from "ember-addons/ember-computed-decorators";
|
|
|
|
import ComboBoxComponent from "select-box-kit/components/combo-box";
|
|
|
|
import { on } from "ember-addons/ember-computed-decorators";
|
|
|
|
|
|
|
|
export default ComboBoxComponent.extend({
|
|
|
|
headerText: "topic.controls",
|
|
|
|
classNames: "topic-footer-mobile-dropdown",
|
|
|
|
filterable: false,
|
|
|
|
autoFilterable: false,
|
2017-10-20 16:40:56 -04:00
|
|
|
allowValueMutation: false,
|
|
|
|
autoSelectFirst: false,
|
2017-10-19 15:51:08 -04:00
|
|
|
|
|
|
|
@on("didReceiveAttrs")
|
2017-10-20 09:41:00 -04:00
|
|
|
_setTopicFooterMobileDropdownOptions() {
|
|
|
|
this.get("headerComponentOptions")
|
|
|
|
.set("selectedName", I18n.t(this.get("headerText")));
|
2017-10-19 15:51:08 -04:00
|
|
|
},
|
|
|
|
|
|
|
|
@computed("topic", "topic.details", "value")
|
|
|
|
content(topic, details) {
|
|
|
|
const content = [];
|
|
|
|
|
|
|
|
if (details.get("can_invite_to")) {
|
|
|
|
content.push({ id: "invite", icon: "users", name: I18n.t("topic.invite_reply.title") });
|
|
|
|
}
|
|
|
|
|
|
|
|
if (topic.get("bookmarked")) {
|
|
|
|
content.push({ id: "bookmark", icon: "bookmark", name: I18n.t("bookmarked.clear_bookmarks") });
|
|
|
|
} else {
|
|
|
|
content.push({ id: "bookmark", icon: "bookmark", name: I18n.t("bookmarked.title") });
|
|
|
|
}
|
|
|
|
|
|
|
|
content.push({ id: "share", icon: "link", name: I18n.t("topic.share.title") });
|
|
|
|
|
|
|
|
if (details.get("can_flag_topic")) {
|
|
|
|
content.push({ id: "flag", icon: "flag", name: I18n.t("topic.flag_topic.title") });
|
|
|
|
}
|
|
|
|
|
|
|
|
return content;
|
|
|
|
},
|
|
|
|
|
2017-11-09 13:57:53 -05:00
|
|
|
selectValueFunction(value) {
|
|
|
|
const topic = this.get("topic");
|
2017-10-19 15:51:08 -04:00
|
|
|
|
2017-11-09 13:57:53 -05:00
|
|
|
// In case it"s not a valid topic
|
|
|
|
if (!topic.get("id")) {
|
|
|
|
return;
|
|
|
|
}
|
2017-10-19 15:51:08 -04:00
|
|
|
|
2017-11-09 13:57:53 -05:00
|
|
|
this.set("value", value);
|
2017-10-19 15:51:08 -04:00
|
|
|
|
2017-11-09 13:57:53 -05:00
|
|
|
const refresh = () => this.send("onDeselect", value);
|
2017-10-19 15:51:08 -04:00
|
|
|
|
2017-11-09 13:57:53 -05:00
|
|
|
switch(value) {
|
|
|
|
case "invite":
|
|
|
|
this.attrs.showInvite();
|
|
|
|
refresh();
|
|
|
|
break;
|
|
|
|
case "bookmark":
|
|
|
|
topic.toggleBookmark().then(() => refresh() );
|
|
|
|
break;
|
|
|
|
case "share":
|
|
|
|
this.appEvents.trigger("share:url", topic.get("shareUrl"), $("#topic-footer-buttons"));
|
|
|
|
refresh();
|
|
|
|
break;
|
|
|
|
case "flag":
|
|
|
|
this.attrs.showFlagTopic();
|
|
|
|
refresh();
|
|
|
|
break;
|
2017-10-19 15:51:08 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|