From a46664acfec74042441f51476ea84763901a647d Mon Sep 17 00:00:00 2001 From: Brian Smith Date: Sat, 15 Nov 2014 11:05:12 -0500 Subject: [PATCH] VRFS-2489 scheduled session with is_unstructured_rsvp=true should not prompt user to add slots when approving --- .../javascripts/accounts_session_detail.js | 80 ++++++++++--------- 1 file changed, 43 insertions(+), 37 deletions(-) diff --git a/web/app/assets/javascripts/accounts_session_detail.js b/web/app/assets/javascripts/accounts_session_detail.js index a3debe85e..b35210caa 100644 --- a/web/app/assets/javascripts/accounts_session_detail.js +++ b/web/app/assets/javascripts/accounts_session_detail.js @@ -87,48 +87,54 @@ var instrumentIds = $(e.target).attr('data-instrument-text'); var params = buildRsvpRequestActionParams(rsvpId, true); - // first check if any open slots exist for these instruments - rest.getOpenSessionSlots(sessionData.id, true) - .done(function(openSlots) { - if (openSlots) { - if (openSlots.length === 0) { - ui.launchRsvpCreateSlotDialog(sessionData.id, instrumentIds.split('|'), userName, function() { - approve(rsvpId, params); - }); - } - else { - var arrInstrumentIds = instrumentIds.split('|'); - var openSlotInstrumentIds = []; - var unavailableSlotInstrumentIds = []; + if (sessionData['is_unstructured_rsvp?']) { + approve(rsvpId, params); + } - // ensure each instrument in the user's list is available in the open slots list - $.each(openSlots, function(index, slot) { - openSlotInstrumentIds.push(slot.instrument_id); - }); - - // build list of instrument IDs in the RSVP request for which there are no open slots - for (var i=0; i < arrInstrumentIds.length; i++) { - if ($.inArray(arrInstrumentIds[i], openSlotInstrumentIds) === -1) { - unavailableSlotInstrumentIds.push(arrInstrumentIds[i]); - } - } - - if (unavailableSlotInstrumentIds.length > 0) { - ui.launchRsvpCreateSlotDialog(sessionData.id, unavailableSlotInstrumentIds, userName, function() { - approve(rsvpId, params); - }); + // check if any open slots exist for these instruments + else { + rest.getOpenSessionSlots(sessionData.id, true) + .done(function(openSlots) { + if (openSlots) { + if (openSlots.length === 0) { + ui.launchRsvpCreateSlotDialog(sessionData.id, instrumentIds.split('|'), userName, function() { + approve(rsvpId, params); + }); } else { - approve(rsvpId, params); + var arrInstrumentIds = instrumentIds.split('|'); + var openSlotInstrumentIds = []; + var unavailableSlotInstrumentIds = []; + + // ensure each instrument in the user's list is available in the open slots list + $.each(openSlots, function(index, slot) { + openSlotInstrumentIds.push(slot.instrument_id); + }); + + // build list of instrument IDs in the RSVP request for which there are no open slots + for (var i=0; i < arrInstrumentIds.length; i++) { + if ($.inArray(arrInstrumentIds[i], openSlotInstrumentIds) === -1) { + unavailableSlotInstrumentIds.push(arrInstrumentIds[i]); + } + } + + if (unavailableSlotInstrumentIds.length > 0) { + ui.launchRsvpCreateSlotDialog(sessionData.id, unavailableSlotInstrumentIds, userName, function() { + approve(rsvpId, params); + }); + } + else { + approve(rsvpId, params); + } } } - } - else { - ui.launchRsvpCreateSlotDialog(sessionData.id, instrumentIds.split('|'), userName, function() { - approve(rsvpId, params); - }); - } - }); + else { + ui.launchRsvpCreateSlotDialog(sessionData.id, instrumentIds.split('|'), userName, function() { + approve(rsvpId, params); + }); + } + }); + } } function approve(rsvpId, params) {