2020-05-23 00:56:13 -04:00
|
|
|
import { action, computed } from "@ember/object";
|
2019-10-23 12:30:52 -04:00
|
|
|
import Component from "@ember/component";
|
2020-08-28 15:30:20 -04:00
|
|
|
import layout from "select-kit/templates/components/topic-notifications-button";
|
2020-02-03 08:22:14 -05:00
|
|
|
|
2019-10-23 12:30:52 -04:00
|
|
|
export default Component.extend({
|
2020-08-28 15:30:20 -04:00
|
|
|
layout,
|
2020-02-03 08:22:14 -05:00
|
|
|
classNames: ["topic-notifications-button"],
|
2020-05-23 00:56:13 -04:00
|
|
|
classNameBindings: ["isLoading"],
|
2020-02-03 08:22:14 -05:00
|
|
|
appendReason: true,
|
2017-10-19 15:51:08 -04:00
|
|
|
showFullTitle: true,
|
2020-04-28 14:12:16 -04:00
|
|
|
notificationLevel: null,
|
|
|
|
topic: null,
|
2020-05-18 08:07:40 -04:00
|
|
|
showCaret: true,
|
2020-05-23 00:56:13 -04:00
|
|
|
isLoading: false,
|
|
|
|
icon: computed("isLoading", function () {
|
|
|
|
return this.isLoading ? "spinner" : null;
|
|
|
|
}),
|
2020-05-19 07:27:57 -04:00
|
|
|
|
2020-04-28 14:12:16 -04:00
|
|
|
@action
|
|
|
|
changeTopicNotificationLevel(levelId) {
|
|
|
|
if (levelId !== this.notificationLevel) {
|
2020-05-23 00:56:13 -04:00
|
|
|
this.set("isLoading", true);
|
|
|
|
this.topic.details
|
|
|
|
.updateNotifications(levelId)
|
|
|
|
.finally(() => this.set("isLoading", false));
|
2020-02-03 08:22:14 -05:00
|
|
|
}
|
|
|
|
},
|
2017-10-19 15:51:08 -04:00
|
|
|
});
|