This commit is contained in:
Brian Smith 2014-02-16 17:39:26 -05:00
parent 83f347e84c
commit 348f96f5b0
12 changed files with 44 additions and 36 deletions

View File

@ -4,5 +4,10 @@ module JamRuby
belongs_to :user, :class_name => "JamRuby::User", :foreign_key => "user_id"
belongs_to :likable, :polymorphic => true
def type
type = self.likable_type.gsub("JamRuby::", "").downcase
type
end
end
end

View File

@ -80,30 +80,6 @@
.fail(app.ajaxError);
}
function isFollowingMember(userId) {
var alreadyFollowing = false;
var url = "/api/users/" + context.JK.currentUserId + "/followings/" + userId;
$.ajax({
type: "GET",
dataType: "json",
url: url,
async: false,
processData: false,
success: function(response) {
if (response.id !== undefined) {
alreadyFollowing = true;
}
else {
alreadyFollowing = false;
}
},
error: app.ajaxError
});
return alreadyFollowing;
}
function configureBandFollowingButton(following) {
$('#btn-follow-band').unbind("click");
@ -372,9 +348,7 @@
$('#band-profile-members').append(memberHtml);
// wire up Follow button click handler
var following = isFollowingMember(musician.id);
configureMemberFollowingButton(following, musician.id);
configureMemberFollowingButton(musician.is_following, musician.id);
configureRemoveMemberButton(musician.id);
// TODO: wire up Friend button click handler

View File

@ -25,8 +25,19 @@
followingHtml += '<tr>';
}
followingHtml += '<td width="24"><a href="#" class="avatar-tiny"><img src="' + context.JK.resolveAvatarUrl(val.photo_url) + '" /></a></td>';
followingHtml += '<td><a href="/client#/profile/' + val.id + '"><strong>' + val.name + '</strong></a></td>';
var avatarUrl, profilePath;
if (val.type === "band") {
avatarUrl = context.JK.resolveBandAvatarUrl(val.photo_url);
profilePath = "bandProfile";
}
else {
avatarUrl = context.JK.resolveAvatarUrl(val.photo_url);
profilePath = "profile";
}
followingHtml += '<td width="24"><a href="#" class="avatar-tiny"><img src="' + avatarUrl + '" /></a></td>';
followingHtml += '<td><a href="/client#/' + profilePath + '/' + val.id + '"><strong>' + val.name + '</strong></a></td>';
if (index % 2 > 0) {
followingHtml += '</tr>';

View File

@ -26,7 +26,7 @@
// followings
var followingHtml = '';
$.each(response.followings, function(index, val) {
if (index < 4) { // display max of 4 followings (NOTE: this only displays USER followings, not BAND followings)
if (index < 4) { // display max of 4 followings
if (index % 2 === 0) {
followingHtml += '<tr>';
}
@ -35,7 +35,7 @@
if (val.type === "band") {
avatarUrl = context.JK.resolveBandAvatarUrl(val.photo_url);
profilePath = "bandProfile"
profilePath = "bandProfile";
}
else {
avatarUrl = context.JK.resolveAvatarUrl(val.photo_url);

View File

@ -578,7 +578,7 @@
function addBandFollowing(evt) {
evt.stopPropagation();
var bandId = $(this).parent().parent().attr('band-id');
var bandId = $(this).parent().parent().parent().parent().attr('band-id');
var newFollowing = {};
newFollowing.band_id = bandId;

View File

@ -14,3 +14,12 @@ node :biography do |musician|
musician.biography.nil? ? "" : musician.biography
end
if current_user
node :is_following do |musician|
current_user.following?(musician)
end
node :is_liking do |musician|
current_user.likes?(musician)
end
end

View File

@ -25,4 +25,7 @@ if current_user
node :is_following do |uu|
current_user.following?(@band)
end
node :is_liking do |uu|
current_user.likes?(@band)
end
end

View File

@ -20,4 +20,8 @@ end
node :photo_url do |following|
following.followable.photo_url
end
node :type do |following|
following.type
end

View File

@ -1,3 +1,3 @@
object @following
attributes :id, :user_id, :follower_id
attributes :id, :user_id, :followable_id

View File

@ -20,4 +20,8 @@ end
node :photo_url do |liking|
liking.likable.photo_url
end
node :type do |liking|
liking.type
end

View File

@ -32,7 +32,6 @@ child :friends => :friends do
end
child :followings => :followings do
attributes :type
node :id do |f|
@ -50,7 +49,6 @@ child :followings => :followings do
node :photo_url do |f|
f.followable.photo_url
end
end
child :band_musicians => :bands do

View File

@ -154,7 +154,7 @@
<div class="right" style="width:250px;margin-top:10px;">
<table class="profile-musicians" cellpadding="0" cellspacing="5">{musicians}</table>
</div>
<div class="" style="margin-left: 63px; margin-right: 260px;margin-top:12px;">
<div style="margin-left: 63px; margin-right: 260px;margin-top:12px;">
<div class="first-row" data-hint="top-row">
<div class="lcol left">
<!-- name & location -->