show a follow button for users with pre-existing contacts (legacy beta testers)
This commit is contained in:
parent
4dea64fe9f
commit
52efb3710c
4 changed files with 51 additions and 14 deletions
|
|
@ -24,11 +24,10 @@ app.pages.Profile = app.views.Base.extend({
|
||||||
presenter : function(){
|
presenter : function(){
|
||||||
var bio = this.model.get("bio") || ''
|
var bio = this.model.get("bio") || ''
|
||||||
|
|
||||||
console.log(this.isOwnProfile())
|
|
||||||
|
|
||||||
return _.extend(this.defaultPresenter(),
|
return _.extend(this.defaultPresenter(),
|
||||||
{text : this.model && app.helpers.textFormatter(bio, this.model),
|
{text : this.model && app.helpers.textFormatter(bio, this.model),
|
||||||
isOwnProfile : this.isOwnProfile() })
|
isOwnProfile : this.isOwnProfile(),
|
||||||
|
showFollowButton : this.showFollowButton() })
|
||||||
},
|
},
|
||||||
|
|
||||||
initialize : function(options) {
|
initialize : function(options) {
|
||||||
|
|
@ -55,6 +54,14 @@ app.pages.Profile = app.views.Base.extend({
|
||||||
evt.preventDefault();
|
evt.preventDefault();
|
||||||
},
|
},
|
||||||
|
|
||||||
|
followingEnabled : function() {
|
||||||
|
return app.currentUser.get("following_count") != 0
|
||||||
|
},
|
||||||
|
|
||||||
|
showFollowButton : function() {
|
||||||
|
return this.followingEnabled() && !this.isOwnProfile()
|
||||||
|
},
|
||||||
|
|
||||||
isOwnProfile : function() {
|
isOwnProfile : function() {
|
||||||
return(app.currentUser.get("guid") == this.personGUID)
|
return(app.currentUser.get("guid") == this.personGUID)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,5 @@
|
||||||
<div id="top-right-nav">
|
<div id="top-right-nav">
|
||||||
|
{{#if showFollowButton}}
|
||||||
{{#unless isOwnProfile}}
|
|
||||||
<a href="#" onClick="alert('Not yet implemented!')" id="follow-button">
|
<a href="#" onClick="alert('Not yet implemented!')" id="follow-button">
|
||||||
<span class="label label-inverse">
|
<span class="label label-inverse">
|
||||||
<i class="icon-plus icon-white"></i>
|
<i class="icon-plus icon-white"></i>
|
||||||
|
|
@ -9,7 +8,7 @@
|
||||||
</span>
|
</span>
|
||||||
</span>
|
</span>
|
||||||
</a>
|
</a>
|
||||||
{{/unless}}
|
{{/if}}
|
||||||
|
|
||||||
<a href="/" id="home-button">
|
<a href="/" id="home-button">
|
||||||
<span class="label label-inverse">
|
<span class="label label-inverse">
|
||||||
|
|
@ -29,7 +28,6 @@
|
||||||
{{/if}}
|
{{/if}}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
<section id="profile-info"/>
|
<section id="profile-info"/>
|
||||||
|
|
||||||
<div id="composer" style="display:none;">
|
<div id="composer" style="display:none;">
|
||||||
|
|
@ -47,6 +45,6 @@
|
||||||
{{/if}}
|
{{/if}}
|
||||||
</section>
|
</section>
|
||||||
|
|
||||||
<section id="canvas"/>
|
<section id="canvas"></section>
|
||||||
|
|
||||||
<div id="paginate"><span class="loader hidden"/></div>
|
<div id="paginate"><span class="loader hidden"/></div>
|
||||||
|
|
@ -11,7 +11,8 @@ class UserPresenter
|
||||||
:unread_messages_count => unread_messages_count,
|
:unread_messages_count => unread_messages_count,
|
||||||
:admin => admin,
|
:admin => admin,
|
||||||
:aspects => aspects,
|
:aspects => aspects,
|
||||||
:services => services
|
:services => services,
|
||||||
|
:following_count => self.user.contacts.receiving.count
|
||||||
}
|
}
|
||||||
).to_json(options)
|
).to_json(options)
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -40,11 +40,16 @@ describe("app.pages.Profile", function(){
|
||||||
expect(this.page.$("#profile-controls .control").length).toBe(2)
|
expect(this.page.$("#profile-controls .control").length).toBe(2)
|
||||||
})
|
})
|
||||||
|
|
||||||
it("shows a follow button if not", function() {
|
it("shows a follow button if showFollowButton returns true", function() {
|
||||||
// will fix this in the next commit.
|
spyOn(this.page, "showFollowButton").andReturn(true)
|
||||||
// spyOn(this.page, "isOwnProfile").andReturn(false)
|
this.page.render()
|
||||||
// this.page.render()
|
expect(this.page.$("#follow-button").length).toBe(1)
|
||||||
// expect(this.page.$("#follow .control").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()
|
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()
|
||||||
|
})
|
||||||
|
})
|
||||||
});
|
});
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue