refactors header notifications (renders them via separate controller / template)

This commit is contained in:
Wojciech Zawistowski
2013-11-08 21:06:27 +01:00
parent 965a0a91a2
commit 67a1da7af4
14 changed files with 244 additions and 75 deletions
@@ -9,6 +9,7 @@
Discourse.HeaderController = Discourse.Controller.extend({
topic: null,
showExtraInfo: null,
notifications: null,
categories: function() {
return Discourse.Category.list();
@@ -39,6 +40,16 @@ Discourse.HeaderController = Discourse.Controller.extend({
toggleMobileView: function() {
Discourse.Mobile.toggleMobileView();
},
showNotifications: function(headerView) {
var self = this;
Discourse.ajax("/notifications").then(function(result) {
self.set("notifications", result);
self.set("currentUser.unread_notifications", 0);
headerView.showDropdownBySelector("#user-notifications");
});
}
}
@@ -0,0 +1,17 @@
Discourse.NotificationController = Discourse.ObjectController.extend({
scope: function() {
return "notifications." + Discourse.Site.currentProp("notificationLookup")[this.get("notification_type")];
}.property(),
username: function() {
return this.get("data.display_username");
}.property(),
link: function() {
if (this.blank("data.topic_title")) {
return "";
}
var url = Discourse.Utilities.postUrl(this.get("slug"), this.get("topic_id"), this.get("post_number"));
return '<a href="' + url + '">' + this.get("data.topic_title") + '</a>';
}.property()
});
@@ -0,0 +1,3 @@
Discourse.NotificationsController = Ember.ArrayController.extend(Discourse.HasCurrentUser, {
itemController: "notification"
});