FIX: The `title` attribute was missed when refactoring UserAction streams

This commit is contained in:
Robin Ward 2013-05-28 10:20:19 -04:00
parent f2fb1f75fc
commit 55526e24d6
3 changed files with 41 additions and 36 deletions

View File

@ -8,7 +8,7 @@
**/
Discourse.UserAction = Discourse.Model.extend({
descriptionHtml: (function() {
descriptionHtml: function() {
var action = this.get('action_type');
var ua = Discourse.UserAction;
var actions = [ua.LIKE, ua.WAS_LIKED, ua.STAR, ua.EDIT, ua.BOOKMARK, ua.GOT_PRIVATE_MESSAGE, ua.NEW_PRIVATE_MESSAGE];
@ -73,19 +73,19 @@ Discourse.UserAction = Discourse.Model.extend({
}
return new Handlebars.SafeString(icon + " " + sentence);
}).property(),
}.property(),
targetUserUrl: (function() {
targetUserUrl: function() {
return Discourse.Utilities.userUrl(this.get('target_username'));
}).property(),
}.property(),
userUrl: (function() {
userUrl: function() {
return Discourse.Utilities.userUrl(this.get('username'));
}).property(),
}.property(),
postUrl: (function() {
postUrl: function() {
return Discourse.Utilities.postUrl(this.get('slug'), this.get('topic_id'), this.get('post_number'));
}).property(),
}.property(),
replyUrl: function() {
return Discourse.Utilities.postUrl(this.get('slug'), this.get('topic_id'), this.get('reply_to_post_number'));
@ -102,27 +102,19 @@ Discourse.UserAction = Discourse.Model.extend({
}.property(),
addChild: function(action) {
var bucket, current, groups, ua;
groups = this.get("childGroups");
var groups = this.get("childGroups");
if (!groups) {
groups = {
likes: Discourse.UserActionGroup.create({
icon: "icon-heart"
}),
stars: Discourse.UserActionGroup.create({
icon: "icon-star"
}),
edits: Discourse.UserActionGroup.create({
icon: "icon-pencil"
}),
bookmarks: Discourse.UserActionGroup.create({
icon: "icon-bookmark"
})
likes: Discourse.UserActionGroup.create({ icon: "icon-heart" }),
stars: Discourse.UserActionGroup.create({ icon: "icon-star" }),
edits: Discourse.UserActionGroup.create({ icon: "icon-pencil" }),
bookmarks: Discourse.UserActionGroup.create({ icon: "icon-bookmark" })
};
}
this.set("childGroups", groups);
ua = Discourse.UserAction;
bucket = (function() {
var ua = Discourse.UserAction;
var bucket = (function() {
switch (action.action_type) {
case ua.LIKE:
case ua.WAS_LIKED:
@ -135,23 +127,22 @@ Discourse.UserAction = Discourse.Model.extend({
return "bookmarks";
}
})();
current = groups[bucket];
var current = groups[bucket];
if (current) {
current.push(action);
}
},
children: (function() {
var g, rval;
g = this.get("childGroups");
rval = [];
children: function() {
var g = this.get("childGroups");
var rval = [];
if (g) {
rval = [g.likes, g.stars, g.edits, g.bookmarks].filter(function(i) {
return i.get("items") && i.get("items").length > 0;
});
}
return rval;
}).property("childGroups"),
}.property("childGroups"),
switchToActing: function() {
this.set('username', this.get('acting_username'));

View File

@ -27,6 +27,7 @@ Discourse.UserStream = Discourse.Model.extend({
if (result && result.user_actions && result.user_actions.each) {
var copy = Em.A();
result.user_actions.each(function(i) {
console.log(i);
return copy.pushObject(Discourse.UserAction.create(i));
});
copy = Discourse.UserAction.collapseStream(copy);

View File

@ -1,11 +1,24 @@
class UserActionSerializer < ApplicationSerializer
attributes :action_type, :created_at, :excerpt,
:avatar_template, :acting_avatar_template,
:slug, :topic_id, :target_user_id, :target_name,
:target_username, :post_number, :reply_to_post_number,
:username, :name, :user_id, :acting_username,
:acting_name, :acting_user_id
attributes :action_type,
:created_at,
:excerpt,
:avatar_template,
:acting_avatar_template,
:slug,
:topic_id,
:target_user_id,
:target_name,
:target_username,
:post_number,
:reply_to_post_number,
:username,
:name,
:user_id,
:acting_username,
:acting_name,
:acting_user_id,
:title
def excerpt