UX: adds visual feedback when changing topic notifications level (#9831)
This commit is contained in:
parent
05ca0c908f
commit
7c3663ff73
|
@ -61,12 +61,14 @@ const TopicDetails = RestModel.extend({
|
|||
}
|
||||
},
|
||||
|
||||
updateNotifications(v) {
|
||||
this.set("notification_level", v);
|
||||
this.set("notifications_reason_id", null);
|
||||
return ajax("/t/" + this.get("topic.id") + "/notifications", {
|
||||
updateNotifications(level) {
|
||||
this.setProperties({
|
||||
notification_level: level,
|
||||
notifications_reason_id: null
|
||||
});
|
||||
return ajax(`/t/${this.get("topic.id")}/notifications`, {
|
||||
type: "POST",
|
||||
data: { notification_level: v }
|
||||
data: { notification_level: level }
|
||||
});
|
||||
},
|
||||
|
||||
|
|
|
@ -1,20 +1,38 @@
|
|||
import Component from "@ember/component";
|
||||
import { action } from "@ember/object";
|
||||
import { action, computed } from "@ember/object";
|
||||
import { later, cancel } from "@ember/runloop";
|
||||
|
||||
export default Component.extend({
|
||||
layoutName: "select-kit/templates/components/topic-notifications-button",
|
||||
classNames: ["topic-notifications-button"],
|
||||
classNameBindings: ["isLoading"],
|
||||
appendReason: true,
|
||||
showFullTitle: true,
|
||||
placement: "bottom-start",
|
||||
notificationLevel: null,
|
||||
topic: null,
|
||||
showCaret: true,
|
||||
isLoading: false,
|
||||
icon: computed("isLoading", function() {
|
||||
return this.isLoading ? "spinner" : null;
|
||||
}),
|
||||
|
||||
willDestroyElement() {
|
||||
this._super(...arguments);
|
||||
|
||||
this._endLoadingHandler && cancel(this._endLoadingHandler);
|
||||
},
|
||||
|
||||
@action
|
||||
changeTopicNotificationLevel(levelId) {
|
||||
if (levelId !== this.notificationLevel) {
|
||||
this.topic.details.updateNotifications(levelId);
|
||||
this.set("isLoading", true);
|
||||
this.topic.details.updateNotifications(levelId).finally(() => {
|
||||
this._endLoadingHandler = later(
|
||||
() => this.set("isLoading", false),
|
||||
250
|
||||
);
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
topic=topic
|
||||
onChange=(action "changeTopicNotificationLevel")
|
||||
options=(hash
|
||||
icon=icon
|
||||
showFullTitle=showFullTitle
|
||||
placement=placement
|
||||
preventsClickPropagation=true
|
||||
|
@ -19,6 +20,7 @@
|
|||
topic=topic
|
||||
onChange=(action "changeTopicNotificationLevel")
|
||||
options=(hash
|
||||
icon=icon
|
||||
showFullTitle=showFullTitle
|
||||
placement=placement
|
||||
preventsClickPropagation=true
|
||||
|
|
|
@ -1026,6 +1026,14 @@ a.mention-group {
|
|||
margin-top: 0;
|
||||
}
|
||||
|
||||
.topic-notifications-button.is-loading {
|
||||
pointer-events: none;
|
||||
user-select: none;
|
||||
.topic-notifications-options {
|
||||
opacity: 0.5;
|
||||
}
|
||||
}
|
||||
|
||||
.pinned-button,
|
||||
.topic-notifications-button {
|
||||
margin: 1em 0;
|
||||
|
|
|
@ -63,6 +63,11 @@
|
|||
flex-direction: row;
|
||||
min-height: 30px;
|
||||
|
||||
.d-icon-spinner {
|
||||
-webkit-animation: rotate-forever 1s infinite linear;
|
||||
animation: rotate-forever 1s infinite linear;
|
||||
}
|
||||
|
||||
.selected-name {
|
||||
text-align: left;
|
||||
flex: 0 1 auto;
|
||||
|
|
Loading…
Reference in New Issue