diff --git a/ruby/lib/jam_ruby/models/rsvp_request.rb b/ruby/lib/jam_ruby/models/rsvp_request.rb index 9e534f584..689aad72e 100644 --- a/ruby/lib/jam_ruby/models/rsvp_request.rb +++ b/ruby/lib/jam_ruby/models/rsvp_request.rb @@ -33,6 +33,7 @@ module JamRuby rs.music_session_id = '#{music_session.id}' } ) + .order('rsvp_requests.created_at DESC') if options[:status] == 'approved' query = query.where("rrrs.chosen = true AND canceled != TRUE") diff --git a/web/app/assets/javascripts/jam_rest.js b/web/app/assets/javascripts/jam_rest.js index 619ea3036..9d51abb2a 100644 --- a/web/app/assets/javascripts/jam_rest.js +++ b/web/app/assets/javascripts/jam_rest.js @@ -226,14 +226,10 @@ } function cancelRsvpRequest(sessionId, rsvpRequestId, cancelAll) { - var cancel = "yes"; - if (cancelAll) { - cancel = "all"; - } return $.ajax({ url: '/api/rsvp_requests/' + rsvpRequestId, type: "DELETE", - data : JSON.stringify({"session_id": sessionId, "cancelled": cancel}), + data : JSON.stringify({"session_id": sessionId, "cancelled": cancelAll}), dataType : 'json', contentType: 'application/json' }); diff --git a/web/app/assets/javascripts/sessionList.js b/web/app/assets/javascripts/sessionList.js index 4321cc183..705ccafae 100644 --- a/web/app/assets/javascripts/sessionList.js +++ b/web/app/assets/javascripts/sessionList.js @@ -142,7 +142,7 @@ var rsvpUsersHtml = '', openSlotsHtml = '', latencyHtml = '', notationFileHtml = ''; context._.each(session.pending_rsvp_requests, function(pending_rsvp_request) { - if(pending_rsvp_request.user_id == context.JK.currentUserId) { + if(pending_rsvp_request.user_id === context.JK.currentUserId) { pendingRsvpId = pending_rsvp_request.id; } }); @@ -185,6 +185,29 @@ } } + // notation files + if (session.music_notations) { + for (i=0; i < session.music_notations.length; i++) { + notationFileHtml += createNotationFile(session.music_notations[i]); + } + } + + var sessionVals = buildSessionObject(session, notationFileHtml, rsvpUsersHtml, openSlotsHtml, latencyHtml); + sessionVals.scheduled_start = session.pretty_scheduled_start_with_timezone; + + var row = context.JK.fillTemplate($inactiveSessionTemplate.html(), sessionVals); + + // initial page load + if (!$rowToUpdate) { + $(tbGroup).append(row); + } + // inline update after an RSVP submission / cancellation + else { + $rowToUpdate.replaceWith(row); + } + + var $parentRow = $('tr[data-session-id=' + session.id + ']', tbGroup); + var showRsvpLink = true; var noLinkText = ''; @@ -194,7 +217,10 @@ noLinkText.find('a').click(function() { ui.launchRsvpCancelDialog(session.id, approvedRsvpId) .one(EVENTS.RSVP_CANCELED, function() { - // VRFS-1891 + rest.getSessionHistory(session.id) + .done(function(response) { + renderInactiveSession(response, tbGroup, $parentRow); + }); }) .one(EVENTS.DIALOG_CLOSED, function() { $(this).unbind(EVENTS.RSVP_CANCELED); @@ -208,7 +234,10 @@ noLinkText.find('a').click(function() { ui.launchRsvpCancelDialog(session.id, pendingRsvpId) .one(EVENTS.RSVP_CANCELED, function() { - // VRFS-1891 + rest.getSessionHistory(session.id) + .done(function(response) { + renderInactiveSession(response, tbGroup, $parentRow); + }); }) .one(EVENTS.DIALOG_CLOSED, function() { $(this).unbind(EVENTS.RSVP_CANCELED); @@ -224,35 +253,10 @@ showRsvpLink = false; noLinkText = 'You need an invitation to RSVP to this session.'; } - - // notation files - if (session.music_notations) { - for (i=0; i < session.music_notations.length; i++) { - notationFileHtml += createNotationFile(session.music_notations[i]); - } - } - - var sessionVals = buildSessionObject(session, notationFileHtml, rsvpUsersHtml, openSlotsHtml, latencyHtml); - sessionVals.scheduled_start = session.pretty_scheduled_start_with_timezone; - sessionVals.rsvp_link_display_style = showRsvpLink ? "block" : "none"; - - var row = context.JK.fillTemplate($inactiveSessionTemplate.html(), sessionVals); - - // initial page load - if (!$rowToUpdate) { - $(tbGroup).append(row); - } - // inline update after an RSVP submission / cancellation - else { - $rowToUpdate.replaceWith(row); - } - - var $parentRow = $('tr[data-session-id=' + session.id + ']', tbGroup); if (showRsvpLink) { - $('.rsvp-msg', $parentRow).hide(); - var $parentRow = $('tr[data-session-id=' + session.id + ']', tbGroup); + $('.rsvp-link', $parentRow).show(); $('.rsvp-link', $parentRow).click(function(evt) { ui.launchRsvpSubmitDialog(session.id) @@ -270,6 +274,7 @@ } else { $('.rsvp-msg', $parentRow).html(noLinkText).show(); + $('.rsvp-link', $parentRow).hide(); } } diff --git a/web/app/assets/javascripts/web/session_info.js b/web/app/assets/javascripts/web/session_info.js index 2d76b7d80..3886a6068 100644 --- a/web/app/assets/javascripts/web/session_info.js +++ b/web/app/assets/javascripts/web/session_info.js @@ -150,11 +150,18 @@ rest.getRsvpRequests(musicSessionId) .done(function(rsvps) { if (rsvps && rsvps.length > 0) { - // should only be 1 RSVP for this session and user + // the first RSVP should be the most recent (users may have many RSVPs to same session if they cancel + // and resubmit); use its status to determine what CTA to present var rsvp = rsvps[0]; if (rsvp.canceled) { - $('.call-to-action').html('Your RSVP request to this session has been cancelled.'); - $btnAction.hide(); + $('.call-to-action').html("Tell the session organizer you'd like to play in this session"); + $btnAction.html('RSVP NOW!'); + $btnAction.click(function(e) { + ui.launchRsvpSubmitDialog(musicSessionId) + .one(EVENTS.RSVP_SUBMITTED, function() { + location.reload(); + }) + }); } else { var declined = true; diff --git a/web/app/helpers/feeds_helper.rb b/web/app/helpers/feeds_helper.rb index 50664cf89..c77c382cd 100644 --- a/web/app/helpers/feeds_helper.rb +++ b/web/app/helpers/feeds_helper.rb @@ -50,7 +50,7 @@ module FeedsHelper end def session_name(music_session, user) - if music_session.fan_access || ( (user && user.id == music_session.creator.id) || (music_session.band && music_session.band.users.include?(user)) ) + if music_session.fan_access || music_session.unique_users.include?(user) music_session.name else PRIVATE_TEXT @@ -58,7 +58,7 @@ module FeedsHelper end def session_description(music_session, user) - if music_session.fan_access || ( (user && user.id == music_session.creator.id) || (music_session.band && music_session.band.users.include?(user)) ) + if music_session.fan_access || music_session.unique_users.include?(user) music_session.description else PRIVATE_TEXT @@ -96,7 +96,7 @@ module FeedsHelper def recording_name(recording, user) r = recording.candidate_claimed_recording - if r.is_public || (user && user.id == r.user.id) + if r.is_public || recording.users.include?(user) r.name else PRIVATE_TEXT @@ -105,7 +105,7 @@ module FeedsHelper def recording_description(recording, user) r = recording.candidate_claimed_recording - if r.is_public || (user && user.id == r.user.id) + if r.is_public || recording.users.include?(user) r.description else PRIVATE_TEXT diff --git a/web/app/views/clients/_findSession.html.erb b/web/app/views/clients/_findSession.html.erb index 1fa5cb07e..5b642c0f2 100644 --- a/web/app/views/clients/_findSession.html.erb +++ b/web/app/views/clients/_findSession.html.erb @@ -202,7 +202,7 @@