diff --git a/web/app/assets/javascripts/profile.js b/web/app/assets/javascripts/profile.js index a5db58050..fb9bab119 100644 --- a/web/app/assets/javascripts/profile.js +++ b/web/app/assets/javascripts/profile.js @@ -74,7 +74,11 @@ return false; } - function configUserType() { + function isCurrentUser() { + return userId === context.JK.currentUserId; + } + + function configureUserType() { if (isMusician()) { $('#profile-history-link').show(); $('#profile-bands-link').show(); @@ -82,11 +86,11 @@ $('#profile-session-stats').show(); $('#profile-recording-stats').show(); - $('#profile-following-stats').hide(); - $('#profile-favorites-stats').hide(); + // $('#profile-following-stats').hide(); + // $('#profile-favorites-stats').hide(); $('#btn-add-friend').show(); - $('#profile-social-left').show(); + $('.profile-social-left').show(); $('#profile-type-label').text('musician'); $('#profile-location-label').text('Location'); @@ -98,20 +102,28 @@ $('#profile-session-stats').hide(); $('#profile-recording-stats').hide(); - $('#profile-following-stats').show(); - $('#profile-favorites-stats').show(); + // $('#profile-following-stats').show(); + // $('#profile-favorites-stats').show(); $('#btn-add-friend').hide(); - $('#profile-social-left').hide(); + $('.profile-social-left').hide(); $('#profile-type-label').text('fan'); $('#profile-location-label').text('Presence'); } + + if (isCurrentUser()) { + $('#btn-profile-edit').show(); + } else { + $('#btn-profile-edit').hide(); + } } /****************** MAIN PORTION OF SCREEN *****************/ // events for main screen function events() { + configureUserType(); + // wire up panel clicks $('#profile-about-link').click(renderAbout); $('#profile-history-link').click(renderHistory); @@ -120,14 +132,12 @@ $('#profile-favorites-link').click(renderFavorites); // wire up buttons if you're not viewing your own profile - if (userId != context.JK.currentUserId) { + if (!isCurrentUser()) { // wire up Add Friend click - var friend = isFriend(); - configureFriendButton(friend); + configureFriendButton(isFriend()); // wire up Follow click - var following = isFollowing(); - configureFollowingButton(following); + configureFollowingButton(isFollowing()); } else { $('#btn-add-friend').hide(); @@ -248,6 +258,10 @@ } } + function configureEditProfileButton() { + $('#btn-follow-user').click(addFollowing); + } + // refreshes the currently active tab function renderActive() { if ($('#profile-about-link').hasClass('active')) { @@ -287,7 +301,6 @@ $('#profile-instruments').empty(); if (getUser()) { - configUserType(); // name $('#profile-username').html(user.name); @@ -325,7 +338,7 @@ text = user.follower_count > 1 || user.follower_count === 0 ? " Followers" : " Follower"; $('#profile-follower-stats').html(user.follower_count + text); - if (user.musician === true) { + if (isMusician()) { text = user.session_count > 1 || user.session_count === 0 ? " Sessions" : " Session"; $('#profile-session-stats').html(user.session_count + text); @@ -334,6 +347,8 @@ } else { text = " Following"; $('#profile-following-stats').html(user.following_count + text); + text = user.favorite_count > 1 || user.favorite_count === 0 ? " Favorites" : " Favorite"; + $('#profile-favorite-stats').html(user.favorite_count + text); } $('#profile-biography').html(user.biography); @@ -358,6 +373,12 @@ $('.profile-nav a.active').removeClass('active'); $('.profile-nav a.#profile-social-link').addClass('active'); + /*if (isMusician()) { + $('.profile-social-left').show(); + } else { + $('.profile-social-left').hide(); + }*/ + bindSocial(); } @@ -501,7 +522,7 @@ async: false, processData:false, success: function(response) { - if ( (!response || response.length === 0) && context.JK.currentUserId === userId) { + if ( (!response || response.length === 0) && isCurrentUser()) { var noBandHtml = $('#template-no-bands').html(); $("#profile-bands").append(noBandHtml); } @@ -567,7 +588,7 @@ } function addMoreBandsLink() { - if (context.JK.currentUserId === userId) { + if (isCurrentUser()) { var moreBandsHtml = $('#template-more-bands').html(); $("#profile-bands").append(moreBandsHtml); } diff --git a/web/app/controllers/api_users_controller.rb b/web/app/controllers/api_users_controller.rb index 40a96b869..1fa1c4271 100644 --- a/web/app/controllers/api_users_controller.rb +++ b/web/app/controllers/api_users_controller.rb @@ -19,7 +19,10 @@ class ApiUsersController < ApiController end def show - @user = User.find(params[:id]) + @user = User.includes([{:musician_instruments => :instrument}, + {:band_musicians => :user}, + :bands, :instruments]) + .find(params[:id]) respond_with @user, responder: ApiResponder, :status => 200 end diff --git a/web/app/views/api_users/show.rabl b/web/app/views/api_users/show.rabl index 4c63e2c39..13360ac19 100644 --- a/web/app/views/api_users/show.rabl +++ b/web/app/views/api_users/show.rabl @@ -1,6 +1,6 @@ object @user -attributes :id, :first_name, :last_name, :name, :city, :state, :country, :location, :online, :photo_url, :musician, :gender, :birth_date, :internet_service_provider, :friend_count, :liker_count, :like_count, :band_like_count, :follower_count, :following_count, :band_following_count, :recording_count, :session_count, :biography +attributes :id, :first_name, :last_name, :name, :city, :state, :country, :location, :online, :photo_url, :musician, :gender, :birth_date, :internet_service_provider, :friend_count, :liker_count, :like_count, :band_like_count, :follower_count, :following_count, :band_following_count, :recording_count, :session_count, :biography, :favorite_count if @user.musician? node :location do @user.location end diff --git a/web/app/views/clients/_account.html.erb b/web/app/views/clients/_account.html.erb index 0bd1a893c..526d56727 100644 --- a/web/app/views/clients/_account.html.erb +++ b/web/app/views/clients/_account.html.erb @@ -75,6 +75,8 @@

+ + <% if current_user && current_user.musician? %>

payments:

@@ -106,6 +108,8 @@ UPDATE

+ <% end %> + diff --git a/web/app/views/clients/_profile.html.erb b/web/app/views/clients/_profile.html.erb index 84b4ae9fe..5586c9546 100644 --- a/web/app/views/clients/_profile.html.erb +++ b/web/app/views/clients/_profile.html.erb @@ -23,6 +23,7 @@
ADD FRIEND FOLLOW + <%= link_to("EDIT PROFILE", '/client#/account/profile', :id => "btn-profile-edit", :class => "button-orange") %>


@@ -53,6 +54,7 @@


+


diff --git a/web/app/views/users/_user_dropdown.html.erb b/web/app/views/users/_user_dropdown.html.erb index ef6b4eed9..558e8d25c 100644 --- a/web/app/views/users/_user_dropdown.html.erb +++ b/web/app/views/users/_user_dropdown.html.erb @@ -18,8 +18,10 @@
  • <%= link_to "Profile", '/client#/account/profile' %>
  • -
  • <%= link_to "Audio Gear", '/client#/account/audio' %>
  • -
  • <%= link_to "Band Setup", '/client#/band/setup' %>
  • + <% if current_user && current_user.musician? %> +
  • <%= link_to "Audio Gear", '/client#/account/audio' %>
  • +
  • <%= link_to "Band Setup", '/client#/band/setup' %>
  • + <% end %>
  • <%= link_to "Invite Friends", '#' %>