VRFS-1210 VRFS-1212 VRFS-1223 bug fixes

This commit is contained in:
Brian Smith 2014-02-24 01:10:09 -05:00
parent 1e75e2ffeb
commit ccee2e15b3
15 changed files with 286 additions and 132 deletions

View File

@ -47,55 +47,53 @@
/****************** MAIN PORTION OF SCREEN *****************/ /****************** MAIN PORTION OF SCREEN *****************/
function addFollowing(isBand, id) { function addFollowing(isBand, id) {
var newFollowing = {}; var newFollowing = {};
if (!isBand) { if (!isBand) {
newFollowing.user_id = id; newFollowing.user_id = id;
} }
else { else {
newFollowing.band_id = id; newFollowing.band_id = id;
} }
rest.addFollowing(newFollowing) rest.addFollowing(newFollowing)
.done(function() { .done(function() {
if (isBand) { if (isBand) {
var newCount = parseInt($("#band-profile-follower-stats").text()) + 1; var newCount = parseInt($("#band-profile-follower-stats").text()) + 1;
var text = newCount > 1 || newCount == 0 ? " Followers" : " Follower"; var text = newCount > 1 || newCount == 0 ? " Followers" : " Follower";
$('#band-profile-follower-stats').html(newCount + text); $('#band-profile-follower-stats').html(newCount + text);
configureBandFollowingButton(true); configureBandFollowingButton(true);
} }
else { else {
configureMemberFollowingButton(true, id); configureMemberFollowingButton(true, id);
} }
}) renderActive();
.fail(app.ajaxError); })
.fail(app.ajaxError);
} }
function removeFollowing(isBand, id) { function removeFollowing(isBand, id) {
var following = {}; rest.removeFollowing(id)
following.target_entity_id = id; .done(function() {
if (isBand) {
rest.removeFollowing(following) var newCount = parseInt($("#band-profile-follower-stats").text()) - 1;
.done(function() { var text = newCount > 1 || newCount == 0 ? " Followers" : " Follower";
renderActive(); // refresh stats $('#band-profile-follower-stats').html(newCount + text);
if (isBand) { configureBandFollowingButton(false);
var newCount = parseInt($("#band-profile-follower-stats").text()) - 1; }
var text = newCount > 1 || newCount == 0 ? " Followers" : " Follower"; else {
$('#band-profile-follower-stats').html(newCount + text); configureMemberFollowingButton(false, id);
configureBandFollowingButton(false); }
} renderActive();
else { })
configureMemberFollowingButton(false, id); .fail(app.ajaxError);
}
})
.fail(app.ajaxError);
} }
function configureBandFollowingButton(following) { function configureBandFollowingButton(following) {
$('#btn-follow-band').unbind("click"); $('#btn-follow-band').unbind("click");
if (following) { if (following) {
$('#btn-follow-band').text('STOP FOLLOWING'); $('#btn-follow-band').text('UNFOLLOW');
$('#btn-follow-band').click(function() { $('#btn-follow-band').click(function() {
removeFollowing(true, bandId); removeFollowing(true, bandId);
return false; return false;
@ -121,7 +119,7 @@
$btnFollowMember.unbind("click"); $btnFollowMember.unbind("click");
if (following) { if (following) {
$btnFollowMember.text('UN-FOLLOW'); $btnFollowMember.text('UNFOLLOW');
$btnFollowMember.click(function() { $btnFollowMember.click(function() {
removeFollowing(false, userId); removeFollowing(false, userId);
return false; return false;

View File

@ -49,21 +49,23 @@
}); });
var bandHtml = context.JK.fillTemplate(template, { var bandHtml = context.JK.fillTemplate(template, {
avatar_url: context.JK.resolveBandAvatarUrl(response.photo_url), bandId: response.id,
name: response.name, avatar_url: context.JK.resolveBandAvatarUrl(response.photo_url),
location: response.location, name: response.name,
genres: genres.join(', '), location: response.location,
musicians: musicianHtml, genres: genres.join(', '),
like_count: response.liker_count, musicians: musicianHtml,
follower_count: response.follower_count, like_count: response.liker_count,
recording_count: response.recording_count, follower_count: response.follower_count,
session_count: response.session_count, recording_count: response.recording_count,
biography: response.biography, session_count: response.session_count,
profile_url: "/client#/bandProfile/" + response.id biography: response.biography,
followAction: response.is_following ? "removeBandFollowing" : "addBandFollowing",
profile_url: "/client#/bandProfile/" + response.id
}); });
$(hoverSelector).append('<h2>Band Detail</h2>' + bandHtml); $(hoverSelector).append('<h2>Band Detail</h2>' + bandHtml);
toggleActionButtons(); configureActionButtons(response);
}) })
.fail(function(xhr) { .fail(function(xhr) {
if(xhr.status >= 500) { if(xhr.status >= 500) {
@ -78,9 +80,17 @@
}); });
}; };
function toggleActionButtons() { function configureActionButtons(band) {
var btnFollowSelector = "#btnFollow";
// if unauthenticated or authenticated user is viewing his own profile
if (!context.JK.currentUserId) { if (!context.JK.currentUserId) {
$("#btnFollow", hoverSelector).hide(); $(btnFollowSelector, hoverSelector).hide();
}
else {
if (band.is_following) {
$(btnFollowSelector, hoverSelector).html('UNFOLLOW');
}
} }
} }

View File

@ -56,13 +56,15 @@
location: response.location, location: response.location,
friend_count: response.friend_count, friend_count: response.friend_count,
follower_count: response.follower_count, follower_count: response.follower_count,
friendAction: response.is_friend ? "removeFanFriend" : (response.pending_friend_request ? "" : "sendFanFriendRequest"),
followAction: response.is_following ? "removeFanFollowing" : "addFanFollowing",
biography: response.biography, biography: response.biography,
followings: response.followings && response.followings.length > 0 ? followingHtml : "<tr><td>N/A</td></tr>", followings: response.followings && response.followings.length > 0 ? followingHtml : "<tr><td>N/A</td></tr>",
profile_url: "/client#/profile/" + response.id profile_url: "/client#/profile/" + response.id
}); });
$(hoverSelector).append('<h2>Fan Detail</h2>' + fanHtml); $(hoverSelector).append('<h2>Fan Detail</h2>' + fanHtml);
toggleActionButtons(); configureActionButtons(response);
}) })
.fail(function(xhr) { .fail(function(xhr) {
if(xhr.status >= 500) { if(xhr.status >= 500) {
@ -77,10 +79,30 @@
}); });
}; };
function toggleActionButtons() { function configureActionButtons(user) {
if (!context.JK.currentUserId) { var btnFriendSelector = "#btnFriend";
$("#btnFriend", hoverSelector).hide(); var btnFollowSelector = "#btnFollow";
$("#btnFollow", hoverSelector).hide();
if (!context.JK.currentUserId || context.JK.currentUserId === user.id) {
$(btnFriendSelector, hoverSelector).hide();
$(btnFollowSelector, hoverSelector).hide();
}
else {
if (user.is_friend) {
$(btnFriendSelector, hoverSelector).html('DISCONNECT');
}
if (user.is_following) {
$(btnFollowSelector, hoverSelector).html('UNFOLLOW');
$(btnFollowSelector, hoverSelector).click(function(evt) {
rest.removeFollowing(user.id);
});
}
if (user.pending_friend_request) {
$(btnFriendSelector, hoverSelector).hide();
}
} }
} }

View File

@ -75,13 +75,15 @@
session_count: response.session_count, session_count: response.session_count,
session_display: sessionDisplayStyle, session_display: sessionDisplayStyle,
session_id: sessionId, session_id: sessionId,
friendAction: response.is_friend ? "removeMusicianFriend" : (response.pending_friend_request ? "" : "sendMusicianFriendRequest"),
followAction: response.is_following ? "removeMusicianFollowing" : "addMusicianFollowing",
biography: response.biography, biography: response.biography,
followings: response.followings && response.followings.length > 0 ? followingHtml : "<tr><td>N/A</td></tr>", followings: response.followings && response.followings.length > 0 ? followingHtml : "<tr><td>N/A</td></tr>",
profile_url: "/client#/profile/" + response.id profile_url: "/client#/profile/" + response.id
}); });
$(hoverSelector).append('<h2>Musician Detail</h2>' + musicianHtml); $(hoverSelector).append('<h2>Musician Detail</h2>' + musicianHtml);
toggleActionButtons(); configureActionButtons(response);
}) })
.fail(function(xhr) { .fail(function(xhr) {
if(xhr.status >= 500) { if(xhr.status >= 500) {
@ -96,10 +98,25 @@
}); });
}; };
function toggleActionButtons() { function configureActionButtons(user) {
if (!context.JK.currentUserId) { var btnFriendSelector = "#btnFriend";
$("#btnFriend", hoverSelector).hide(); var btnFollowSelector = "#btnFollow";
$("#btnFollow", hoverSelector).hide();
// if unauthenticated or authenticated user is viewing his own profile
if (!context.JK.currentUserId || context.JK.currentUserId === user.id) {
$(btnFriendSelector, hoverSelector).hide();
$(btnFollowSelector, hoverSelector).hide();
}
else {
if (user.is_friend) {
$(btnFriendSelector, hoverSelector).html('DISCONNECT');
}
if (user.is_following) {
$(btnFollowSelector, hoverSelector).html('UNFOLLOW');
}
if (user.pending_friend_request) {
$(btnFriendSelector, hoverSelector).hide();
}
} }
} }

View File

@ -451,7 +451,7 @@
}); });
} }
function removeLike(options) { function removeLike(likableId, options) {
var id = getId(options); var id = getId(options);
return $.ajax({ return $.ajax({
type: "DELETE", type: "DELETE",
@ -476,15 +476,13 @@
}); });
} }
function removeFollowing(options) { function removeFollowing(followableId, options) {
var id = getId(options); var id = getId(options);
return $.ajax({ return $.ajax({
type: "DELETE", type: "DELETE",
dataType: "json", dataType: "json",
contentType: 'application/json', contentType: 'application/json',
url: "/api/users/" + id + "/followings", url: "/api/users/" + id + "/followings/" + followableId,
data: JSON.stringify(options),
processData: false processData: false
}); });
} }

View File

@ -193,10 +193,10 @@
function configureFriendButton() { function configureFriendButton() {
if (isFriend()) { if (isFriend()) {
$('#btn-add-friend').text('REMOVE FRIEND'); $('#btn-add-friend').text('DISCONNECT');
} }
else { else {
$('#btn-add-friend').text('ADD FRIEND'); $('#btn-add-friend').text('CONNECT');
} }
} }
@ -213,10 +213,7 @@
} }
function removeFollowing(isBand, id) { function removeFollowing(isBand, id) {
var following = {}; rest.removeFollowing(id)
following.target_entity_id = id;
rest.removeFollowing(following)
.done(function() { .done(function() {
if (!isBand) { if (!isBand) {
updateFollowingCount(-1); updateFollowingCount(-1);
@ -242,7 +239,7 @@
function configureFollowingButton() { function configureFollowingButton() {
if (isFollowing()) { if (isFollowing()) {
$('#btn-follow-user').text('STOP FOLLOWING'); $('#btn-follow-user').text('UNFOLLOW');
} }
else { else {
$('#btn-follow-user').text('FOLLOW'); $('#btn-follow-user').text('FOLLOW');

View File

@ -117,23 +117,23 @@
selector = isSidebar ? '#sidebar-search-results' : '#search-results'; selector = isSidebar ? '#sidebar-search-results' : '#search-results';
$(selector).append(invitationSentHtml); $(selector).append(invitationSentHtml);
// wire up button click handler if search result is not a friend or the current use // wire up button click handler if search result is not a friend or the current user
if (isSidebar) { if (isSidebar) {
var $sidebar = $('div[layout=sidebar] div[user-id=' + val.id + ']'); var $sidebar = $('div[layout=sidebar] div[user-id=' + val.id + ']');
if (!val.is_friend && val.id !== context.JK.currentUserId) { if (val.is_friend || val.pending_friend_request || val.id === context.JK.currentUserId) {
$sidebar.find('.btn-connect-friend').click(sendFriendRequest); // hide the button if the search result is already a friend
$sidebar.find('.btn-connect-friend').hide();
} }
else { else {
// hide the button if the search result is already a friend $sidebar.find('.btn-connect-friend').click(sendFriendRequest);
$sidebar.find('.btn-connect-friend').hide();
} }
} }
else { else {
if (!val.is_friend && val.id !== context.JK.currentUserId) { if (val.is_friend || val.pending_friend_request || val.id === context.JK.currentUserId) {
$('div[user-id=' + val.id + ']').find('.btn-connect-friend').click(sendFriendRequest); $('div[user-id=' + val.id + ']').find('.btn-connect-friend').hide();
} }
else { else {
$('div[user-id=' + val.id + ']').find('.btn-connect-friend').hide(); $('div[user-id=' + val.id + ']').find('.btn-connect-friend').click(sendFriendRequest);
} }
} }
resultDivVisibility(val, isSidebar); resultDivVisibility(val, isSidebar);

View File

@ -202,7 +202,7 @@ class ApiUsersController < ApiController
end end
def liking_destroy def liking_destroy
User.delete_liking(params[:id], params[:target_entity_id]) User.delete_liking(params[:id], params[:likable_id])
respond_with responder: ApiResponder, :status => 204 respond_with responder: ApiResponder, :status => 204
end end
@ -230,7 +230,7 @@ class ApiUsersController < ApiController
end end
def following_destroy def following_destroy
User.delete_following(params[:id], params[:target_entity_id]) User.delete_following(params[:id], params[:followable_id])
respond_with responder: ApiResponder, :status => 204 respond_with responder: ApiResponder, :status => 204
end end

View File

@ -23,6 +23,10 @@ if @search.musicians_text_search?
musician.friends?(current_user) musician.friends?(current_user)
end end
node :pending_friend_request do |musician|
musician.pending_friend_request?(current_user)
end
child :musician_instruments => :instruments do child :musician_instruments => :instruments do
attributes :instrument_id, :description, :proficiency_level, :priority attributes :instrument_id, :description, :proficiency_level, :priority
end end
@ -50,6 +54,10 @@ if @search.musicians_filter_search?
@search.is_follower?(musician) @search.is_follower?(musician)
end end
node :pending_friend_request do |musician|
@search.pending_friend_request?(musician)
end
node :biography do |musician| node :biography do |musician|
musician.biography.nil? ? "" : musician.biography musician.biography.nil? ? "" : musician.biography
end end
@ -112,6 +120,10 @@ if @search.fans_text_search?
node :is_friend do |fan| node :is_friend do |fan|
fan.friends?(current_user) fan.friends?(current_user)
end end
node :pending_friend_request do |musician|
@search.pending_friend_request?(musician)
end
} }
end end

View File

@ -5,25 +5,49 @@
<script type="text/javascript"> <script type="text/javascript">
var rest = JK.Rest(); var rest = JK.Rest();
function addLike(bandId) { // function addLike(bandId) {
rest.addLike({band_id: bandId}) // rest.addLike({band_id: bandId})
// .done(function(response) {
// $("#spnLikeCount", "#band-hover").html(parseInt($("#spnLikeCount", "#band-hover").text()) + 1);
// var $btnLikeSelector = $("#btnLike", "#band-hover");
// $btnLikeSelector.unbind("click");
// $btnLikeSelector.html("LIKED");
// });
// }
function addBandFollowing(bandId) {
rest.addFollowing({band_id: bandId})
.done(function(response) { .done(function(response) {
$("#spnLikeCount", "#band-hover").html(parseInt($("#spnLikeCount", "#band-hover").text()) + 1); adjustBandFollowingCount(1);
var $btnLikeSelector = $("#btnLike", "#band-hover");
$btnLikeSelector.unbind("click"); var $btnFollowSelector = $("#btnFollow", "#band-hover");
$btnLikeSelector.html("LIKED"); $btnFollowSelector.unbind('click');
$btnFollowSelector.attr('onclick', '');
$btnFollowSelector.click(function() {
removeBandFollowing(bandId);
});
$btnFollowSelector.html("UNFOLLOW");
}); });
} }
function addFollowing(bandId) { function removeBandFollowing(bandId) {
rest.addFollowing({band_id: bandId}) rest.removeFollowing(bandId)
.done(function(response) { .done(function(response) {
$("#spnFollowCount", "#band-hover").html(parseInt($("#spnFollowCount", "#band-hover").text()) + 1); adjustBandFollowingCount(-1);
var $btnFollowSelector = $("#btnFollow", "#band-hover");
$btnFollowSelector.unbind("click"); var $btnFollowSelector = $("#btnFollow", "#band-hover");
$btnFollowSelector.html("STOP FOLLOWING"); $btnFollowSelector.unbind('click');
$btnFollowSelector.attr('onclick', '');
$btnFollowSelector.click(function() {
addBandFollowing(bandId);
});
$btnFollowSelector.html("FOLLOW");
}); });
} }
function adjustBandFollowingCount(value) {
$("#spnFollowCount", "#band-hover").text(parseInt($("#spnFollowCount", "#band-hover").text()) + value);
}
</script> </script>
<script type="text/template" id="template-hover-band"> <script type="text/template" id="template-hover-band">
@ -33,7 +57,6 @@
<h3>{name}</h3> <h3>{name}</h3>
<small>{location}<br /><strong>{genres}</strong></small><br /> <small>{location}<br /><strong>{genres}</strong></small><br />
<br clear="all" /> <br clear="all" />
<span id="spnLikeCount">{like_count}</span> <img src="/assets/content/icon_like.png" align="absmiddle" />&nbsp;&nbsp;&nbsp;
<span id="spnFollowCount">{follower_count}</span> <img src="/assets/content/icon_followers.png" width="22" height="12" align="absmiddle" />&nbsp;&nbsp;&nbsp; <span id="spnFollowCount">{follower_count}</span> <img src="/assets/content/icon_followers.png" width="22" height="12" align="absmiddle" />&nbsp;&nbsp;&nbsp;
{recording_count} <img src="/assets/content/icon_recordings.png" width="12" height="13" align="absmiddle" />&nbsp;&nbsp;&nbsp; {recording_count} <img src="/assets/content/icon_recordings.png" width="12" height="13" align="absmiddle" />&nbsp;&nbsp;&nbsp;
{session_count} <img src="/assets/content/icon_session_tiny.png" width="12" height="12" align="absmiddle" /> {session_count} <img src="/assets/content/icon_session_tiny.png" width="12" height="12" align="absmiddle" />
@ -47,8 +70,8 @@
<br /> <br />
<div align="center"> <div align="center">
<div class="left"><a href="{profile_url}" class="button-orange">PROFILE</a></div> <div class="left"><a href="{profile_url}" class="button-orange">PROFILE</a></div>
<div class="left"><a class="button-orange">LIKE</a></div> <div class="left" style="display:none;"><a class="button-orange">LIKE</a></div>
<div class="left"><a class="button-orange">FOLLOW</a></div> <div class="left"><a id="btnFollow" onclick="{followAction}('{bandId}');" class="button-orange">FOLLOW</a></div>
</div> </div>
<br /><br /> <br /><br />
</div> </div>

View File

@ -5,19 +5,58 @@
<script type="text/javascript"> <script type="text/javascript">
var rest = JK.Rest(); var rest = JK.Rest();
function addFollowing(userId) { function addFanFollowing(userId) {
rest.addFollowing({user_id: userId}) rest.addFollowing({user_id: userId})
.done(function(response) { .done(function(response) {
$("#spnFollowCount", "#fan-hover").html(parseInt($("#spnFollowCount", "#fan-hover").text()) + 1); adjustFanFollowingCount(1);
var $btnFollowSelector = $("#btnFollow", "#fan-hover");
$btnFollowSelector.unbind("click"); var $btnFollowSelector = $("#btnFollow", "#fan-hover");
$btnFollowSelector.html("STOP FOLLOWING"); $btnFollowSelector.unbind('click');
$btnFollowSelector.attr('onclick', '');
$btnFollowSelector.click(function() {
removeFanFollowing(userId);
});
$btnFollowSelector.html("UNFOLLOW");
}); });
} }
function sendFriendRequest(userId) { function removeFanFollowing(userId) {
rest.sendFriendRequest(JK.app, userId); rest.removeFollowing(userId)
.done(function(response) {
adjustFanFollowingCount(-1);
var $btnFollowSelector = $("#btnFollow", "#fan-hover");
$btnFollowSelector.unbind('click');
$btnFollowSelector.attr('onclick', '');
$btnFollowSelector.click(function() {
addFanFollowing(userId);
});
$btnFollowSelector.html("FOLLOW");
});
} }
function adjustFanFollowingCount(value) {
$("#spnFollowCount", "#fan-hover").text(parseInt($("#spnFollowCount", "#fan-hover").text()) + value);
}
function sendFanFriendRequest(userId) {
rest.sendFriendRequest(JK.app, userId);
$("#btnFriend", "#fan-hover").hide();
}
function removeFanFriend(userId) {
rest.removeFriend({friend_id: userId})
.done(function() {
var $btnFriendSelector = $("#btnFriend", "#fan-hover");
$btnFriendSelector.unbind("click");
$btnFriendSelector.attr('onclick', '');
$btnFriendSelector.html("CONNECT");
$btnFriendSelector.click(function() {
sendFanFriendRequest(userId);
});
});
}
</script> </script>
<script type="text/template" id="template-hover-fan"> <script type="text/template" id="template-hover-fan">
@ -38,8 +77,8 @@
<br /> <br />
<div align="center"> <div align="center">
<div class="left"><a href="{profile_url}" class="button-orange">PROFILE</a></div> <div class="left"><a href="{profile_url}" class="button-orange">PROFILE</a></div>
<div class="left"><a id="btnFriend" onclick="sendFriendRequest('{userId}');" class="button-orange">FRIEND</a></div> <div class="left"><a id="btnFriend" onclick="{friendAction}('{userId}');" class="button-orange">CONNECT</a></div>
<div class="left"><a id="btnFollow" onclick="addFollowing('{userId}');" class="button-orange">FOLLOW</a></div> <div class="left"><a id="btnFollow" onclick="{followAction}('{userId}');" class="button-orange">FOLLOW</a></div>
</div> </div>
<br /><br /> <br /><br />
</div> </div>

View File

@ -5,28 +5,66 @@
<script type="text/javascript"> <script type="text/javascript">
var rest = JK.Rest(); var rest = JK.Rest();
function addLike(userId) { // function addLike(userId) {
rest.addLike({user_id: userId}) // rest.addLike({user_id: userId})
.done(function(response) { // .done(function(response) {
$("#spnLikeCount", "#musician-hover").html(parseInt($("#spnLikeCount", "#musician-hover").text()) + 1); // $("#spnLikeCount", "#musician-hover").text(parseInt($("#spnLikeCount", "#musician-hover").text()) + 1);
var $btnLikeSelector = $("#btnLike", "#musician-hover"); // var $btnLikeSelector = $("#btnLike", "#musician-hover");
$btnLikeSelector.unbind("click"); // $btnLikeSelector.unbind("click");
$btnLikeSelector.html("LIKED"); // $btnLikeSelector.html("LIKED");
}); // });
} // }
function addFollowing(userId) { function addMusicianFollowing(userId) {
rest.addFollowing({user_id: userId}) rest.addFollowing({user_id: userId})
.done(function(response) { .done(function(response) {
$("#spnFollowCount", "#musician-hover").html(parseInt($("#spnFollowCount", "#musician-hover").text()) + 1); adjustMusicianFollowingCount(1);
var $btnFollowSelector = $("#btnFollow", "#musician-hover");
$btnFollowSelector.unbind("click"); var $btnFollowSelector = $("#btnFollow", "#musician-hover");
$btnFollowSelector.html("UNFOLLOW"); $btnFollowSelector.unbind('click');
$btnFollowSelector.attr('onclick', '');
$btnFollowSelector.click(function() {
removeMusicianFollowing(userId);
});
$btnFollowSelector.html("UNFOLLOW");
}); });
} }
function sendFriendRequest(userId) { function removeMusicianFollowing(userId) {
rest.removeFollowing(userId)
.done(function(response) {
adjustMusicianFollowingCount(-1);
var $btnFollowSelector = $("#btnFollow", "#musician-hover");
$btnFollowSelector.unbind('click');
$btnFollowSelector.attr('onclick', '');
$btnFollowSelector.click(function() {
addMusicianFollowing(userId);
});
$btnFollowSelector.html("FOLLOW");
});
}
function adjustMusicianFollowingCount(value) {
$("#spnFollowCount", "#musician-hover").html(parseInt($("#spnFollowCount", "#musician-hover").html()) + value);
}
function sendMusicianFriendRequest(userId) {
rest.sendFriendRequest(JK.app, userId); rest.sendFriendRequest(JK.app, userId);
$("#btnFriend", "#musician-hover").hide();
}
function removeMusicianFriend(userId) {
rest.removeFriend({friend_id: userId})
.done(function() {
var $btnFriendSelector = $("#btnFriend", "#musician-hover");
$btnFriendSelector.unbind("click");
$btnFriendSelector.attr('onclick', '');
$btnFriendSelector.html("CONNECT");
$btnFriendSelector.click(function() {
sendMusicianFriendRequest(userId);
});
});
} }
</script> </script>
@ -54,9 +92,9 @@
<br /> <br />
<div align="center"> <div align="center">
<div class="left"><a href="{profile_url}" class="button-orange">PROFILE</a></div> <div class="left"><a href="{profile_url}" class="button-orange">PROFILE</a></div>
<div class="left"><a id="btnLike" onclick="addLike('{userId}');" class="button-orange">LIKE</a></div> <div class="left" style="display:none;"><a id="btnLike" onclick="addLike('{userId}');" class="button-orange">LIKE</a></div>
<div class="left"><a id="btnFriend" onclick="sendFriendRequest('{userId}');" class="button-orange">FRIEND</a></div> <div class="left"><a id="btnFriend" onclick="{friendAction}('{userId}');" class="button-orange">CONNECT</a></div>
<div class="left"><a id="btnFollow" onclick="addFollowing('{userId}');" class="button-orange">FOLLOW</a></div> <div class="left"><a id="btnFollow" onclick="{followAction}('{userId}');" class="button-orange">FOLLOW</a></div>
</div> </div>
<br /><br /> <br /><br />
</div> </div>

View File

@ -53,7 +53,7 @@
<div class="w100"> <div class="w100">
<div class="recording-controls"> <div class="recording-controls">
<% if !@music_session.music_session.nil? && !@music_session.music_session.mount.blank? %> <% if !@music_session.music_session.nil? && !@music_session.music_session.mount.blank? %>
<a id="btnPlayPause" class="left mr20" href="#"> <a id="btnPlayPause" class="left mr20">
<%= image_tag "content/icon_playbutton.png", {:id => "imgPlayPause", :width => 20, :height => 20, :alt => ""} %> <%= image_tag "content/icon_playbutton.png", {:id => "imgPlayPause", :width => 20, :height => 20, :alt => ""} %>
</a> </a>
<% end %> <% end %>

View File

@ -161,7 +161,7 @@ SampleApp::Application.routes.draw do
# user likes # user likes
match '/users/:id/likings' => 'api_users#liking_index', :via => :get, :as => 'api_user_liking_index' match '/users/:id/likings' => 'api_users#liking_index', :via => :get, :as => 'api_user_liking_index'
match '/users/:id/likings' => 'api_users#liking_create', :via => :post match '/users/:id/likings' => 'api_users#liking_create', :via => :post
match '/users/:id/likings' => 'api_users#liking_destroy', :via => :delete match '/users/:id/likings/:likable_id' => 'api_users#liking_destroy', :via => :delete
# user followers # user followers
match '/users/:id/followers' => 'api_users#follower_index', :via => :get, :as => 'api_user_follower_index' match '/users/:id/followers' => 'api_users#follower_index', :via => :get, :as => 'api_user_follower_index'
@ -169,7 +169,7 @@ SampleApp::Application.routes.draw do
# user followings # user followings
match '/users/:id/followings' => 'api_users#following_index', :via => :get, :as => 'api_user_following_index' match '/users/:id/followings' => 'api_users#following_index', :via => :get, :as => 'api_user_following_index'
match '/users/:id/followings' => 'api_users#following_create', :via => :post match '/users/:id/followings' => 'api_users#following_create', :via => :post
match '/users/:id/followings' => 'api_users#following_destroy', :via => :delete match '/users/:id/followings/:followable_id' => 'api_users#following_destroy', :via => :delete
# favorites # favorites
match '/users/:id/favorites' => 'api_users#favorite_index', :via => :get, :as => 'api_favorite_index' match '/users/:id/favorites' => 'api_users#favorite_index', :via => :get, :as => 'api_favorite_index'

View File

@ -56,7 +56,7 @@ describe "User API", :type => :api do
def delete_user_like(authenticated_user, source_user, target_user) def delete_user_like(authenticated_user, source_user, target_user)
login(authenticated_user.email, authenticated_user.password, 200, true) login(authenticated_user.email, authenticated_user.password, 200, true)
delete "/api/users/#{source_user.id}/likings.json", { :target_entity_id => target_user.id }.to_json, "CONTENT_TYPE" => 'application/json' delete "/api/users/#{source_user.id}/likings/#{target_user.id}.json", "CONTENT_TYPE" => 'application/json'
return last_response return last_response
end end
@ -99,7 +99,7 @@ describe "User API", :type => :api do
def delete_user_following(authenticated_user, source_user, target_user) def delete_user_following(authenticated_user, source_user, target_user)
login(authenticated_user.email, authenticated_user.password, 200, true) login(authenticated_user.email, authenticated_user.password, 200, true)
delete "/api/users/#{source_user.id}/followings.json", { :target_entity_id => target_user.id }.to_json, "CONTENT_TYPE" => 'application/json' delete "/api/users/#{source_user.id}/followings/#{target_user.id}.json", "CONTENT_TYPE" => 'application/json'
return last_response return last_response
end end