mirror of
https://github.com/discourse/discourse.git
synced 2025-09-06 10:50:21 +08:00
FEATURE: notification_level on a per-group basis
This commit is contained in:
parent
d0bbf5c9a6
commit
15c229195f
17 changed files with 137 additions and 30 deletions
|
@ -0,0 +1,11 @@
|
|||
import NotificationsButton from 'discourse/components/notifications-button';
|
||||
|
||||
export default NotificationsButton.extend({
|
||||
classNames: ['notification-options', 'group-notification-menu'],
|
||||
notificationLevel: Em.computed.alias('group.notification_level'),
|
||||
i18nPrefix: 'groups.notifications',
|
||||
|
||||
clicked(id) {
|
||||
this.get('group').setNotification(id);
|
||||
}
|
||||
});
|
|
@ -133,7 +133,15 @@ const Group = Discourse.Model.extend({
|
|||
return Em.Object.create(p);
|
||||
});
|
||||
});
|
||||
}
|
||||
},
|
||||
|
||||
setNotification(notification_level) {
|
||||
this.set("notification_level", notification_level);
|
||||
return Discourse.ajax(`/groups/${this.get("name")}/notifications`, {
|
||||
data: { notification_level },
|
||||
type: "POST"
|
||||
});
|
||||
},
|
||||
});
|
||||
|
||||
Group.reopenClass({
|
||||
|
|
|
@ -1,13 +1,25 @@
|
|||
import Group from 'discourse/models/group';
|
||||
import createPMRoute from "discourse/routes/build-user-topic-list-route";
|
||||
|
||||
export default createPMRoute('groups', 'private-messages-groups').extend({
|
||||
model(params) {
|
||||
return this.store.findFiltered("topicList", { filter: "topics/private-messages-group/" + this.modelFor("user").get("username_lower") + "/" + params.name });
|
||||
const username = this.modelFor("user").get("username_lower");
|
||||
return this.store.findFiltered("topicList", {
|
||||
filter: `topics/private-messages-group/${username}/${params.name}`
|
||||
});
|
||||
},
|
||||
|
||||
setupController(controller,model) {
|
||||
afterModel(model) {
|
||||
const groupName = _.last(model.get("filter").split('/'));
|
||||
Group.findAll().then(groups => {
|
||||
const group = _.first(groups.filterBy("name", groupName));
|
||||
this.controllerFor("user-topics-list").set("group", group)
|
||||
});
|
||||
},
|
||||
|
||||
setupController(controller, model) {
|
||||
this._super.apply(this, arguments);
|
||||
const filter = _.last(model.get("filter").split('/'));
|
||||
this.controllerFor("user").set("groupFilter", filter);
|
||||
const group = _.last(model.get("filter").split('/'));
|
||||
this.controllerFor("user").set("groupFilter", group);
|
||||
}
|
||||
});
|
||||
|
|
|
@ -1,8 +1,11 @@
|
|||
{{#if showNewPM}}
|
||||
<div class="clearfix">
|
||||
<a class='btn btn-primary pull-right new-private-message' {{action "composePrivateMessage"}}>{{fa-icon "envelope"}}{{i18n 'user.new_private_message'}}</a>
|
||||
</div>
|
||||
{{/if}}
|
||||
<div class="clearfix">
|
||||
{{#if group}}
|
||||
{{group-notifications-button group=group}}
|
||||
{{/if}}
|
||||
{{#if showNewPM}}
|
||||
{{d-button class="btn-primary pull-right new-private-message" action="composePrivateMessage" icon="envelope" label="user.new_private_message"}}
|
||||
{{/if}}
|
||||
</div>
|
||||
|
||||
{{basic-topic-list topicList=model
|
||||
hideCategory=hideCategory
|
||||
|
|
|
@ -630,6 +630,10 @@
|
|||
clear: both;
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
.group-notification-menu .dropdown-menu {
|
||||
top: 30px;
|
||||
bottom: auto;
|
||||
}
|
||||
}
|
||||
|
||||
.paginated-topics-list {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue