mirror of
https://github.com/discourse/discourse.git
synced 2024-11-27 18:43:38 +08:00
FIX: The title
attribute was missed when refactoring UserAction streams
This commit is contained in:
parent
f2fb1f75fc
commit
55526e24d6
|
@ -8,7 +8,7 @@
|
||||||
**/
|
**/
|
||||||
Discourse.UserAction = Discourse.Model.extend({
|
Discourse.UserAction = Discourse.Model.extend({
|
||||||
|
|
||||||
descriptionHtml: (function() {
|
descriptionHtml: function() {
|
||||||
var action = this.get('action_type');
|
var action = this.get('action_type');
|
||||||
var ua = Discourse.UserAction;
|
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];
|
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);
|
return new Handlebars.SafeString(icon + " " + sentence);
|
||||||
}).property(),
|
}.property(),
|
||||||
|
|
||||||
targetUserUrl: (function() {
|
targetUserUrl: function() {
|
||||||
return Discourse.Utilities.userUrl(this.get('target_username'));
|
return Discourse.Utilities.userUrl(this.get('target_username'));
|
||||||
}).property(),
|
}.property(),
|
||||||
|
|
||||||
userUrl: (function() {
|
userUrl: function() {
|
||||||
return Discourse.Utilities.userUrl(this.get('username'));
|
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'));
|
return Discourse.Utilities.postUrl(this.get('slug'), this.get('topic_id'), this.get('post_number'));
|
||||||
}).property(),
|
}.property(),
|
||||||
|
|
||||||
replyUrl: function() {
|
replyUrl: function() {
|
||||||
return Discourse.Utilities.postUrl(this.get('slug'), this.get('topic_id'), this.get('reply_to_post_number'));
|
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(),
|
}.property(),
|
||||||
|
|
||||||
addChild: function(action) {
|
addChild: function(action) {
|
||||||
var bucket, current, groups, ua;
|
var groups = this.get("childGroups");
|
||||||
groups = this.get("childGroups");
|
|
||||||
if (!groups) {
|
if (!groups) {
|
||||||
groups = {
|
groups = {
|
||||||
likes: Discourse.UserActionGroup.create({
|
likes: Discourse.UserActionGroup.create({ icon: "icon-heart" }),
|
||||||
icon: "icon-heart"
|
stars: Discourse.UserActionGroup.create({ icon: "icon-star" }),
|
||||||
}),
|
edits: Discourse.UserActionGroup.create({ icon: "icon-pencil" }),
|
||||||
stars: Discourse.UserActionGroup.create({
|
bookmarks: Discourse.UserActionGroup.create({ icon: "icon-bookmark" })
|
||||||
icon: "icon-star"
|
|
||||||
}),
|
|
||||||
edits: Discourse.UserActionGroup.create({
|
|
||||||
icon: "icon-pencil"
|
|
||||||
}),
|
|
||||||
bookmarks: Discourse.UserActionGroup.create({
|
|
||||||
icon: "icon-bookmark"
|
|
||||||
})
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
this.set("childGroups", groups);
|
this.set("childGroups", groups);
|
||||||
ua = Discourse.UserAction;
|
|
||||||
bucket = (function() {
|
var ua = Discourse.UserAction;
|
||||||
|
var bucket = (function() {
|
||||||
switch (action.action_type) {
|
switch (action.action_type) {
|
||||||
case ua.LIKE:
|
case ua.LIKE:
|
||||||
case ua.WAS_LIKED:
|
case ua.WAS_LIKED:
|
||||||
|
@ -135,23 +127,22 @@ Discourse.UserAction = Discourse.Model.extend({
|
||||||
return "bookmarks";
|
return "bookmarks";
|
||||||
}
|
}
|
||||||
})();
|
})();
|
||||||
current = groups[bucket];
|
var current = groups[bucket];
|
||||||
if (current) {
|
if (current) {
|
||||||
current.push(action);
|
current.push(action);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
children: (function() {
|
children: function() {
|
||||||
var g, rval;
|
var g = this.get("childGroups");
|
||||||
g = this.get("childGroups");
|
var rval = [];
|
||||||
rval = [];
|
|
||||||
if (g) {
|
if (g) {
|
||||||
rval = [g.likes, g.stars, g.edits, g.bookmarks].filter(function(i) {
|
rval = [g.likes, g.stars, g.edits, g.bookmarks].filter(function(i) {
|
||||||
return i.get("items") && i.get("items").length > 0;
|
return i.get("items") && i.get("items").length > 0;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
return rval;
|
return rval;
|
||||||
}).property("childGroups"),
|
}.property("childGroups"),
|
||||||
|
|
||||||
switchToActing: function() {
|
switchToActing: function() {
|
||||||
this.set('username', this.get('acting_username'));
|
this.set('username', this.get('acting_username'));
|
||||||
|
|
|
@ -27,6 +27,7 @@ Discourse.UserStream = Discourse.Model.extend({
|
||||||
if (result && result.user_actions && result.user_actions.each) {
|
if (result && result.user_actions && result.user_actions.each) {
|
||||||
var copy = Em.A();
|
var copy = Em.A();
|
||||||
result.user_actions.each(function(i) {
|
result.user_actions.each(function(i) {
|
||||||
|
console.log(i);
|
||||||
return copy.pushObject(Discourse.UserAction.create(i));
|
return copy.pushObject(Discourse.UserAction.create(i));
|
||||||
});
|
});
|
||||||
copy = Discourse.UserAction.collapseStream(copy);
|
copy = Discourse.UserAction.collapseStream(copy);
|
||||||
|
|
|
@ -1,11 +1,24 @@
|
||||||
class UserActionSerializer < ApplicationSerializer
|
class UserActionSerializer < ApplicationSerializer
|
||||||
|
|
||||||
attributes :action_type, :created_at, :excerpt,
|
attributes :action_type,
|
||||||
:avatar_template, :acting_avatar_template,
|
:created_at,
|
||||||
:slug, :topic_id, :target_user_id, :target_name,
|
:excerpt,
|
||||||
:target_username, :post_number, :reply_to_post_number,
|
:avatar_template,
|
||||||
:username, :name, :user_id, :acting_username,
|
:acting_avatar_template,
|
||||||
:acting_name, :acting_user_id
|
: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
|
def excerpt
|
||||||
|
|
Loading…
Reference in New Issue
Block a user