expanding likes works again
This commit is contained in:
parent
8b4f0473a7
commit
c3b9bb9a9a
5 changed files with 55 additions and 5 deletions
|
|
@ -1,6 +1,16 @@
|
|||
<% if(likes_count > 0) { %>
|
||||
<img alt="Heart" src="/images/icons/heart.png" />
|
||||
<% if(likes && likes.length == 0) { %>
|
||||
<a href="#" class="expand_likes">
|
||||
<%= Diaspora.I18n.t('stream.likes', {count: likes_count}) %>
|
||||
</a>
|
||||
<% } else { %>
|
||||
<span class="likes_list">
|
||||
<% _.each(likes, function(like){ %>
|
||||
<a href="/people/<%= like.get("author").id %>">
|
||||
<img src="<%= like.get("author").avatar.small %>" class="avatar" title="<%= like.get("author").name %>"/>
|
||||
</a>
|
||||
<% }) %>
|
||||
</span>
|
||||
<% } %>
|
||||
<% } %>
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ app.models.Post = Backbone.Model.extend({
|
|||
urlRoot : "/posts",
|
||||
initialize : function() {
|
||||
this.comments = new app.collections.Comments(this.get("last_three_comments"), {post : this});
|
||||
this.likes = new app.collections.Likes(this.get("user_like"), { post : this}); // load in the user like initially
|
||||
this.likes = new app.collections.Likes([], {post : this}); // load in the user like initially
|
||||
},
|
||||
|
||||
createdAt : function() {
|
||||
|
|
|
|||
|
|
@ -2,6 +2,25 @@ app.views.LikesInfo = app.views.StreamObject.extend({
|
|||
|
||||
template_name : "#likes-info-template",
|
||||
|
||||
className : "likes_container"
|
||||
className : "likes_container",
|
||||
|
||||
events : {
|
||||
"click .expand_likes" : "showAvatars"
|
||||
},
|
||||
|
||||
tooltipSelector : ".avatar",
|
||||
|
||||
presenter : function() {
|
||||
return _.extend(this.defaultPresenter(), {likes : this.model.likes.models})
|
||||
},
|
||||
|
||||
showAvatars : function(evt){
|
||||
if(evt) { evt.preventDefault() }
|
||||
var self = this;
|
||||
this.model.likes.fetch()
|
||||
.done(function(resp){
|
||||
// set like attribute and like collection
|
||||
self.model.set({likes : self.model.likes.reset(resp)})
|
||||
})
|
||||
}
|
||||
});
|
||||
|
|
|
|||
|
|
@ -3449,9 +3449,11 @@ a.toggle_selector
|
|||
|
||||
.likes_list
|
||||
.avatar
|
||||
:position relative
|
||||
:float none
|
||||
:height 20px
|
||||
:width 20px
|
||||
:top 5px
|
||||
|
||||
#gs-name-form-spinner
|
||||
:position absolute
|
||||
|
|
|
|||
|
|
@ -28,5 +28,24 @@ describe("app.views.LikesInfo", function(){
|
|||
expect($(this.view.el).html().trim()).toBe("");
|
||||
})
|
||||
})
|
||||
|
||||
describe("showAvatars", function(){
|
||||
beforeEach(function(){
|
||||
spyOn(this.post.likes, "fetch").andCallThrough()
|
||||
})
|
||||
|
||||
it("calls fetch on the model's like collection", function(){
|
||||
this.view.showAvatars();
|
||||
expect(this.post.likes.fetch).toHaveBeenCalled();
|
||||
})
|
||||
|
||||
it("sets the fetched response to the model's likes", function(){
|
||||
//placeholder... not sure how to test done functionalty here
|
||||
})
|
||||
|
||||
it("re-renders the view", function(){
|
||||
//placeholder... not sure how to test done functionalty here
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
Loading…
Reference in a new issue