mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
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) {
|
updateNotifications(level) {
|
||||||
this.set("notification_level", v);
|
this.setProperties({
|
||||||
this.set("notifications_reason_id", null);
|
notification_level: level,
|
||||||
return ajax("/t/" + this.get("topic.id") + "/notifications", {
|
notifications_reason_id: null
|
||||||
|
});
|
||||||
|
return ajax(`/t/${this.get("topic.id")}/notifications`, {
|
||||||
type: "POST",
|
type: "POST",
|
||||||
data: { notification_level: v }
|
data: { notification_level: level }
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -1,20 +1,38 @@
|
|||||||
import Component from "@ember/component";
|
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({
|
export default Component.extend({
|
||||||
layoutName: "select-kit/templates/components/topic-notifications-button",
|
layoutName: "select-kit/templates/components/topic-notifications-button",
|
||||||
classNames: ["topic-notifications-button"],
|
classNames: ["topic-notifications-button"],
|
||||||
|
classNameBindings: ["isLoading"],
|
||||||
appendReason: true,
|
appendReason: true,
|
||||||
showFullTitle: true,
|
showFullTitle: true,
|
||||||
placement: "bottom-start",
|
placement: "bottom-start",
|
||||||
notificationLevel: null,
|
notificationLevel: null,
|
||||||
topic: null,
|
topic: null,
|
||||||
showCaret: true,
|
showCaret: true,
|
||||||
|
isLoading: false,
|
||||||
|
icon: computed("isLoading", function() {
|
||||||
|
return this.isLoading ? "spinner" : null;
|
||||||
|
}),
|
||||||
|
|
||||||
|
willDestroyElement() {
|
||||||
|
this._super(...arguments);
|
||||||
|
|
||||||
|
this._endLoadingHandler && cancel(this._endLoadingHandler);
|
||||||
|
},
|
||||||
|
|
||||||
@action
|
@action
|
||||||
changeTopicNotificationLevel(levelId) {
|
changeTopicNotificationLevel(levelId) {
|
||||||
if (levelId !== this.notificationLevel) {
|
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
|
topic=topic
|
||||||
onChange=(action "changeTopicNotificationLevel")
|
onChange=(action "changeTopicNotificationLevel")
|
||||||
options=(hash
|
options=(hash
|
||||||
|
icon=icon
|
||||||
showFullTitle=showFullTitle
|
showFullTitle=showFullTitle
|
||||||
placement=placement
|
placement=placement
|
||||||
preventsClickPropagation=true
|
preventsClickPropagation=true
|
||||||
@ -19,6 +20,7 @@
|
|||||||
topic=topic
|
topic=topic
|
||||||
onChange=(action "changeTopicNotificationLevel")
|
onChange=(action "changeTopicNotificationLevel")
|
||||||
options=(hash
|
options=(hash
|
||||||
|
icon=icon
|
||||||
showFullTitle=showFullTitle
|
showFullTitle=showFullTitle
|
||||||
placement=placement
|
placement=placement
|
||||||
preventsClickPropagation=true
|
preventsClickPropagation=true
|
||||||
|
@ -1026,6 +1026,14 @@ a.mention-group {
|
|||||||
margin-top: 0;
|
margin-top: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.topic-notifications-button.is-loading {
|
||||||
|
pointer-events: none;
|
||||||
|
user-select: none;
|
||||||
|
.topic-notifications-options {
|
||||||
|
opacity: 0.5;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
.pinned-button,
|
.pinned-button,
|
||||||
.topic-notifications-button {
|
.topic-notifications-button {
|
||||||
margin: 1em 0;
|
margin: 1em 0;
|
||||||
|
@ -63,6 +63,11 @@
|
|||||||
flex-direction: row;
|
flex-direction: row;
|
||||||
min-height: 30px;
|
min-height: 30px;
|
||||||
|
|
||||||
|
.d-icon-spinner {
|
||||||
|
-webkit-animation: rotate-forever 1s infinite linear;
|
||||||
|
animation: rotate-forever 1s infinite linear;
|
||||||
|
}
|
||||||
|
|
||||||
.selected-name {
|
.selected-name {
|
||||||
text-align: left;
|
text-align: left;
|
||||||
flex: 0 1 auto;
|
flex: 0 1 auto;
|
||||||
|
Loading…
Reference in New Issue
Block a user