VRFS-3247 : JS rendering of band instruments, current interests and experience.

This commit is contained in:
Steven Miers 2015-06-10 15:34:43 -05:00
parent 8cd3b836ea
commit 4e8d563184
4 changed files with 122 additions and 19 deletions

View File

@ -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();

View File

@ -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');

View File

@ -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)

View File

@ -117,15 +117,18 @@
<div class="band-entry">
<div class="item-caption">Current Interests</div>
<ul>
<li class="interests-new-members">
<li class="interests-new-members hidden">
<span>Our band is looking for new members who play our genre(s) of music and can play the following:</span>
<span class="new_member_details"></span>
<span class="new-member-details"></span>
</li>
<li class="interests-paid-gigs">
<li class="interests-paid-gigs hidden">
<span>Our band is available for hire to perform at concerts and events for</span>
<span class="paid-gig-details"></span>
<span class="paid-gig-rate">
</span>
<span class="paid-gig-minimum">
</span>
</li>
<li class="interests-free-gigs">
<li class="interests-free-gigs hidden">
<span>Our band is available to perform at concerts and events at no charge as we are currently building our live performance experience.</span>
</li>
</ul>