From 1f99ebef89800d44cd6dbdd5892a511cfb257adf Mon Sep 17 00:00:00 2001 From: Brian Smith Date: Wed, 17 Sep 2014 12:49:58 -0400 Subject: [PATCH] VRFS-2067 expand / collapse RSVP musicians and latencies when there are more than 3 --- web/app/assets/javascripts/sessionList.js | 51 +++++++++++++++++---- web/app/views/clients/_findSession.html.erb | 5 +- 2 files changed, 44 insertions(+), 12 deletions(-) diff --git a/web/app/assets/javascripts/sessionList.js b/web/app/assets/javascripts/sessionList.js index ef83c22ec..5cb64a23d 100644 --- a/web/app/assets/javascripts/sessionList.js +++ b/web/app/assets/javascripts/sessionList.js @@ -56,7 +56,7 @@ if (session.approved_rsvps[i].id === context.JK.currentUserId) { showJoinLink = true; } - var rsvpUserInfo = createRsvpUser(session.approved_rsvps[i], session); + var rsvpUserInfo = createRsvpUser(session.approved_rsvps[i], session, approvedRsvpCount, i); if (i < 3) { rsvpFirst3UsersHtml += rsvpUserInfo[0]; latencyFirst3Html += rsvpUserInfo[1]; @@ -115,15 +115,12 @@ var $parentRow = $('tr[data-session-id=' + session.id + ']', tbGroup); - $(tbGroup).on('click', 'a.more.slots', function() { - alert("HERE"); + // wire up "more" links + $('a.more.slots', $parentRow).click(toggleSlots); + $('a.more.rsvps', $parentRow).click(function() { + toggleRsvps(session.id); }); - // if ($moreLink) { - // console.log("IN HERE"); - // $moreLink[0].click(toggleSlots); - // } - if (showJoinLink) { // wire up the Join Link to the T&Cs dialog @@ -181,7 +178,7 @@ approvedRsvpId = approved_rsvp.rsvp_request_id; } - var rsvpUserInfo = createRsvpUser(approved_rsvp, session); + var rsvpUserInfo = createRsvpUser(approved_rsvp, session, approvedRsvpCount, i); if (i < 3) { rsvpFirst3UsersHtml += rsvpUserInfo[0]; @@ -266,6 +263,9 @@ // wire up "more" links $('a.more.slots', $parentRow).click(toggleSlots); + $('a.more.rsvps', $parentRow).click(function() { + toggleRsvps(session.id); + }); var showRsvpLink = true; var noLinkText = ''; @@ -400,6 +400,11 @@ } } + var moreLinkHtml = ''; + if (rsvpCount > 3 && currentIndex === 2) { + moreLinkHtml = 'more'; + } + var id = user.id; var name = user.name; var musicianVals = { @@ -407,7 +412,8 @@ avatar_url: context.JK.resolveAvatarUrl(user.photo_url), profile_url: "/client#/profile/" + id, musician_name: name, - instruments: instrumentLogoHtml + instruments: instrumentLogoHtml, + more_link: moreLinkHtml }; var musicianHtml = context.JK.fillTemplate($musicianTemplate.html(), musicianVals); @@ -444,6 +450,31 @@ } } + function toggleRsvps(sessionId) { + // musicians + var $musicians = $(this).closest('table').next(); + + // latency indicators that need expanding / collapsing + var $extraLatencies = $("#latency-extra-" + sessionId); + + var $arrow = $(this).next(); + + if ($musicians.is(":visible")) { + $(this).text('more'); + $arrow.removeClass('arrow-up-orange'); + $arrow.addClass('arrow-down-orange'); + $musicians.hide(); + $extraLatencies.hide(); + } + else { + $(this).text('less'); + $arrow.addClass('arrow-up-orange'); + $arrow.removeClass('arrow-down-orange'); + $musicians.show(); + $extraLatencies.show(); + } + } + this.renderActiveSession = renderActiveSession; this.renderInactiveSession = renderInactiveSession; diff --git a/web/app/views/clients/_findSession.html.erb b/web/app/views/clients/_findSession.html.erb index 364dc71bc..ecc97bad9 100644 --- a/web/app/views/clients/_findSession.html.erb +++ b/web/app/views/clients/_findSession.html.erb @@ -137,7 +137,7 @@ {latency_first_3} -
+ -
+