Skip to content
Extraits de code Groupes Projets
Valider c3b9bb9a rédigé par danielgrippi's avatar danielgrippi
Parcourir les fichiers

expanding likes works again

parent 8b4f0473
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
<% if(likes_count > 0) { %> <% if(likes_count > 0) { %>
<img alt="Heart" src="/images/icons/heart.png" /> <img alt="Heart" src="/images/icons/heart.png" />
<a href="#" class="expand_likes"> <% if(likes && likes.length == 0) { %>
<%= Diaspora.I18n.t('stream.likes', {count: likes_count}) %> <a href="#" class="expand_likes">
</a> <%= 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({ ...@@ -2,7 +2,7 @@ app.models.Post = Backbone.Model.extend({
urlRoot : "/posts", urlRoot : "/posts",
initialize : function() { initialize : function() {
this.comments = new app.collections.Comments(this.get("last_three_comments"), {post : this}); 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() { createdAt : function() {
......
...@@ -2,6 +2,25 @@ app.views.LikesInfo = app.views.StreamObject.extend({ ...@@ -2,6 +2,25 @@ app.views.LikesInfo = app.views.StreamObject.extend({
template_name : "#likes-info-template", 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 ...@@ -3449,9 +3449,11 @@ a.toggle_selector
.likes_list .likes_list
.avatar .avatar
:position relative
:float none :float none
:height 20px :height 20px
:width 20px :width 20px
:top 5px
#gs-name-form-spinner #gs-name-form-spinner
:position absolute :position absolute
......
...@@ -28,5 +28,24 @@ describe("app.views.LikesInfo", function(){ ...@@ -28,5 +28,24 @@ describe("app.views.LikesInfo", function(){
expect($(this.view.el).html().trim()).toBe(""); 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
})
})
}) })
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Terminez d'abord l'édition de ce message.
Veuillez vous inscrire ou vous pour commenter