ES6: AvatarSelector and HeaderController - also includes support for controllers with

camelcase via an error message.
This commit is contained in:
Robin Ward
2014-04-29 21:16:57 -04:00
parent a4e30e8f93
commit eee5f85654
7 changed files with 40 additions and 12 deletions
@@ -0,0 +1,45 @@
/**
This controller supports actions on the site header
@class HeaderController
@extends Discourse.Controller
@namespace Discourse
@module Discourse
**/
export default Discourse.Controller.extend({
topic: null,
showExtraInfo: null,
notifications: null,
showStarButton: function() {
return Discourse.User.current() && !this.get('topic.isPrivateMessage');
}.property('topic.isPrivateMessage'),
actions: {
toggleStar: function() {
var topic = this.get('topic');
if (topic) topic.toggleStar();
return false;
},
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");
});
},
jumpToTopPost: function () {
var topic = this.get('topic');
if (topic) {
Discourse.URL.routeTo(topic.get('firstPostUrl'));
}
}
}
});