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

show a follow button for users with pre-existing contacts (legacy beta testers)

parent 4dea64fe
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
......@@ -24,11 +24,10 @@ app.pages.Profile = app.views.Base.extend({
presenter : function(){
var bio = this.model.get("bio") || ''
console.log(this.isOwnProfile())
return _.extend(this.defaultPresenter(),
{text : this.model && app.helpers.textFormatter(bio, this.model),
isOwnProfile : this.isOwnProfile() })
isOwnProfile : this.isOwnProfile(),
showFollowButton : this.showFollowButton() })
},
initialize : function(options) {
......@@ -55,6 +54,14 @@ app.pages.Profile = app.views.Base.extend({
evt.preventDefault();
},
followingEnabled : function() {
return app.currentUser.get("following_count") != 0
},
showFollowButton : function() {
return this.followingEnabled() && !this.isOwnProfile()
},
isOwnProfile : function() {
return(app.currentUser.get("guid") == this.personGUID)
}
......
<div id="top-right-nav">
{{#unless isOwnProfile}}
{{#if showFollowButton}}
<a href="#" onClick="alert('Not yet implemented!')" id="follow-button">
<span class="label label-inverse">
<i class="icon-plus icon-white"></i>
......@@ -9,7 +8,7 @@
</span>
</span>
</a>
{{/unless}}
{{/if}}
<a href="/" id="home-button">
<span class="label label-inverse">
......@@ -29,7 +28,6 @@
{{/if}}
</div>
<section id="profile-info"/>
<div id="composer" style="display:none;">
......@@ -47,6 +45,6 @@
{{/if}}
</section>
<section id="canvas"/>
<section id="canvas"></section>
<div id="paginate"><span class="loader hidden"/></div>
\ No newline at end of file
......@@ -11,7 +11,8 @@ class UserPresenter
:unread_messages_count => unread_messages_count,
:admin => admin,
:aspects => aspects,
:services => services
:services => services,
:following_count => self.user.contacts.receiving.count
}
).to_json(options)
end
......
......@@ -40,11 +40,16 @@ describe("app.pages.Profile", function(){
expect(this.page.$("#profile-controls .control").length).toBe(2)
})
it("shows a follow button if not", function() {
// will fix this in the next commit.
// spyOn(this.page, "isOwnProfile").andReturn(false)
// this.page.render()
// expect(this.page.$("#follow .control").length).toBe(1)
it("shows a follow button if showFollowButton returns true", function() {
spyOn(this.page, "showFollowButton").andReturn(true)
this.page.render()
expect(this.page.$("#follow-button").length).toBe(1)
})
it("doesn't show a follow button if showFollowButton returns false", function() {
spyOn(this.page, "showFollowButton").andReturn(false)
this.page.render()
expect(this.page.$("#follow-button").length).toBe(0)
})
})
......@@ -118,4 +123,30 @@ describe("app.pages.Profile", function(){
expect(this.page.isOwnProfile()).toBeFalsy()
})
})
describe("followingEnabled", function(){
/* for legacy beta testers */
it("returns false if following_count is zero", function(){
app.currentUser.set({following_count : 0})
expect(this.page.followingEnabled()).toBeFalsy()
})
it("returns false if following_count is zero", function(){
app.currentUser.set({following_count : 1})
expect(this.page.followingEnabled()).toBeTruthy()
})
})
describe("followingEnabled", function(){
/* for legacy beta testers */
it("returns false if following_count is zero", function(){
app.currentUser.set({following_count : 0})
expect(this.page.followingEnabled()).toBeFalsy()
})
it("returns false if following_count is zero", function(){
app.currentUser.set({following_count : 1})
expect(this.page.followingEnabled()).toBeTruthy()
})
})
});
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