From 4e8d563184567d87d23c3427c089ae6d66447f6e Mon Sep 17 00:00:00 2001 From: Steven Miers Date: Wed, 10 Jun 2015 15:34:43 -0500 Subject: [PATCH] VRFS-3247 : JS rendering of band instruments, current interests and experience. --- web/app/assets/javascripts/bandProfile.js | 88 ++++++++++++++++++--- web/app/assets/javascripts/profile_utils.js | 28 ++++++- web/app/views/api_bands/show.rabl | 12 +++ web/app/views/clients/_bandProfile.html.erb | 13 +-- 4 files changed, 122 insertions(+), 19 deletions(-) diff --git a/web/app/assets/javascripts/bandProfile.js b/web/app/assets/javascripts/bandProfile.js index a2dd98891..05db1463d 100644 --- a/web/app/assets/javascripts/bandProfile.js +++ b/web/app/assets/javascripts/bandProfile.js @@ -12,7 +12,7 @@ var band = {}; var instrument_logo_map = context.JK.getInstrumentIconMap24(); var profileUtils = context.JK.ProfileUtils; - + var $root = $("#band-profile") function beforeShow(data) { bandId = data.id; } @@ -180,6 +180,9 @@ $('.band-profile-nav a.active').removeClass('active'); $('.band-profile-nav a#band-profile-about-link').addClass('active'); + + + bindAbout(); } @@ -210,15 +213,10 @@ $('#band-profile-biography').text(band.biography); - if (band.website) { - $('#band-profile-website').attr('href', band.website); - $('#band-profile-website').text(band.website); - } - - // profileUtils.renderMusicalExperience(band, $("#bandProfile")) - // profileUtils.renderPerformanceSamples(band, $("#bandProfile"), isAdmin) - // profileUtils.renderOnlinePresence(band, $("#bandProfile"), isAdmin) - //renderInterests() + renderMusicalExperience() + profileUtils.renderPerformanceSamples(band, $("#bandProfile"), isAdmin) + profileUtils.renderOnlinePresence(band, $("#bandProfile"), isAdmin) + renderCurrentInterests() // wire up Follow click configureBandFollowingButton(band.is_following); @@ -240,6 +238,63 @@ }); } + function renderMusicalExperience() { + var genres = buildGenreList(band.genres) + var gigs = (band.concert_count > 0) ? 'Has played ' + profileUtils.gigMap[band.concert_count] + ' live concert gigs' : NOT_SPECIFIED_TEXT; + var bandType ; + if (!band.band_type || typeof(band.band_type)=="undefined" || band.band_type==="") { + bandType = "Not specified"; + } else if (band.band_type.toLowerCase()==="physical") { + bandType = "Physical"; + } else if (band.band_type.toLowerCase()==="virtual") { + bandType = "Virtual"; + } else { + bandType = "Not specified"; + } + + var bandStatus ; + if (!band.band_status || typeof(band.band_status)=="undefined" || band.band_status==="") { + bandStatus = "Not specified"; + } else if (band.band_status.toLowerCase()==="amateur") { + bandStatus = "Amateur Band"; + } else if (band.band_status.toLowerCase()==="professional") { + bandStatus = "Professional Band"; + } else { + bandStatus = "Not specified"; + } + + $root.find(".experience-genres").html(genres) + $root.find(".experience-gigs").html(gigs) + $root.find(".experience-status").html(bandStatus) + $root.find(".experience-type").html(bandType) + + } + + function renderCurrentInterests() { + if (band.add_new_members) { + $root.find(".new-member-details").html(profileUtils.renderBandInstruments(band)) + $root.find(".interests-new-members").removeClass("hidden") + } else { + $root.find(".interests-new-members").addClass("hidden") + } + + if (band.paid_gigs) { + $root.find(".paid-gig-rate").html(band.hourly_rate) + $root.find(".paid-gig-minimum").html(band.gig_minimum) + $root.find(".interests-paid-gigs").removeClass("hidden") + } else { + $root.find(".interests-paid-gigs").addClass("hidden") + } + + if (band.free_gigs) { + $root.find(".interests-free-gigs").removeClass("hidden") + } else { + $root.find(".interests-free-gigs").addClass("hidden") + } + + } + + /****************** SOCIAL TAB *****************/ function renderSocial() { $('#band-profile-social-followers').empty(); @@ -304,6 +359,19 @@ } + function buildGenreList(genres) { + var list = ''; + + for (var i=0; i < genres.length; i++) { + list = list.concat(genres[i].id); + if (i !== genres.length - 1) { + list = list.concat(', '); + } + } + + return list; + } + /****************** BANDS TAB *****************/ function renderMembers() { $('#band-profile-members').empty(); diff --git a/web/app/assets/javascripts/profile_utils.js b/web/app/assets/javascripts/profile_utils.js index 29801b9f2..90c385eec 100644 --- a/web/app/assets/javascripts/profile_utils.js +++ b/web/app/assets/javascripts/profile_utils.js @@ -285,6 +285,30 @@ return matches; } + // Render band instruments to a string: + profileUtils.renderBandInstruments = function (band) { + var msg = "" + if (band.instruments) { + for (var i = 0; i < band.instruments.length; i++) { + var instrument = band.instruments[i] + var description = instrument.instrument_id + + if (msg.length > 0) { + msg += ", " + } + msg += instrument + msg += "(" + proficiencyDescriptionMap[instrument.proficiency_level] + ")" + } + } + if (msg.length==0) { + msg = "None specified" + } + return msg + } + + function formatTitle(title) { + return title && title.length > 30 ? title.substring(0, 30) + "..." : title; + } profileUtils.renderMusicalExperience = function(player, $root) { var $instruments = $root.find('#instruments'); @@ -385,10 +409,6 @@ } }// function renderPerformanceSamples - profileUtils.formatTitle = function(title) { - return title && title.length > 30 ? title.substring(0, 30) + "..." : title; - } - profileUtils.renderOnlinePresence = function(player, $root, isOwner) { var $noOnlinePresence = $root.find('#no-online-presence'); var $userWebsite = $root.find('#user-website'); diff --git a/web/app/views/api_bands/show.rabl b/web/app/views/api_bands/show.rabl index dde9f8760..7c855b180 100644 --- a/web/app/views/api_bands/show.rabl +++ b/web/app/views/api_bands/show.rabl @@ -27,6 +27,18 @@ child :genres => :genres do #partial('api_genres/index', :object => @band.genres) end +child :performance_samples => :performance_samples do + attributes :id, :url, :service_type, :claimed_recording_id, :service_id, :description + + child :claimed_recording => :claimed_recording do + attributes :id, :name + end +end + +child :online_presences => :online_presences do + attributes :id, :service_type, :username +end + if current_user node :is_following do |uu| current_user.following?(@band) diff --git a/web/app/views/clients/_bandProfile.html.erb b/web/app/views/clients/_bandProfile.html.erb index 4bf6b3102..857d4f432 100644 --- a/web/app/views/clients/_bandProfile.html.erb +++ b/web/app/views/clients/_bandProfile.html.erb @@ -117,15 +117,18 @@
Current Interests