diff --git a/ruby/lib/jam_ruby/models/rsvp_request.rb b/ruby/lib/jam_ruby/models/rsvp_request.rb index 8d9d124a4..5bcd1b302 100644 --- a/ruby/lib/jam_ruby/models/rsvp_request.rb +++ b/ruby/lib/jam_ruby/models/rsvp_request.rb @@ -34,9 +34,9 @@ module JamRuby ) if options[:status] == 'approved' - query = query.where("rrrs.chosen = true") + query = query.where("rrrs.chosen = true AND canceled != TRUE") elsif options[:status] == 'pending' - query = query.where("rrrs.chosen is null") + query = query.where("rrrs.chosen is null AND canceled != TRUE") end query = query.where("rsvp_requests.user_id = ?", user.id) unless user.nil? diff --git a/web/app/assets/javascripts/accounts_session_detail.js b/web/app/assets/javascripts/accounts_session_detail.js index 2a3bfdaf4..ba39633e6 100644 --- a/web/app/assets/javascripts/accounts_session_detail.js +++ b/web/app/assets/javascripts/accounts_session_detail.js @@ -7,6 +7,7 @@ context.JK.AccountSessionDetail = function (app) { var logger = context.JK.logger; var rest = context.JK.Rest(); + var sessionUtils = context.JK.SessionUtils; var sessionId = null; var sessionData = null; var rsvpData = null; @@ -14,9 +15,11 @@ var $cancelRsvpBtn = null; var $inviteOthersBtn = null; var $sessionDetail = null; + var $templateOpenSlots = null; var instrument_logo_map = context.JK.getInstrumentIconMap24(); var invitationDialog = null; + var LATENCY = { GOOD : {description: "GOOD", style: "latency-green", min: 0.0, max: 20.0}, MEDIUM : {description: "MEDIUM", style: "latency-yellow", min: 20.0, max: 40.0}, @@ -195,7 +198,6 @@ else { var latency = user.latency; - console.log("latency = %o", latency); if (!latency || latency === 1000) { // 1000 is a magical number returned by new scoring API to indicate one or more people in the session have an unknown score @@ -232,12 +234,11 @@ $.each(sessionData.pending_rsvp_requests, function(index, request) { if (request.user_id != context.JK.currentUserId) { if ("instrument_list" in request && request.instrument_list != null) { + console.log(request.instrument_list) $.each(request.instrument_list, function (index, instrument) { - var inst = '/assets/content/icon_instrument_default24.png'; - if (instrument.id in instrument_logo_map) { - inst = instrument_logo_map[instrument.id].asset; - } - instrumentLogoHtml += ' '; + var instrumentId = instrument == null ? null : instrument.id; + var inst = context.JK.getInstrumentIcon24(instrumentId); + instrumentLogoHtml += ' '; }) } @@ -273,10 +274,8 @@ $.each(sessionData.approved_rsvps, function(index, request) { if ("instrument_list" in request) { $.each(request.instrument_list, function(index, instrument) { - var inst = '/assets/content/icon_instrument_default24.png'; - if (instrument.id in instrument_logo_map) { - inst = instrument_logo_map[instrument.id].asset; - } + var instrumentId = instrument == null ? null : instrument.id; + var inst = context.JK.getInstrumentIcon24(instrumentId); instrumentLogoHtml += ' '; }); } @@ -323,21 +322,12 @@ function generateSessionNeeded() { var resultHtml = ""; - var slotHtml = ""; + if(sessionData['is_unstructured_rsvp?']) { + resultHtml += sessionUtils.createOpenSlot($templateOpenSlots, {description: 'Any Instrument'}); + } + $.each(sessionData.open_slots, function(index, slot) { - var inst = '/assets/content/icon_instrument_default24.png'; - if ("instrument_id" in slot) { - inst = instrument_logo_map[slot.instrument_id].asset; - } - - slotHtml = context._.template( - $("#template-account-open-slot").html(), - {instrument_url: inst, instrument: slot.description, - proficiency: slot.proficiency_desc}, - {variable: 'data'} - ); - - resultHtml += slotHtml; + resultHtml += sessionUtils.createOpenSlot($templateOpenSlots, slot); }); return resultHtml; @@ -384,6 +374,7 @@ $inviteOthersBtn.hide(); $cancelRsvpBtn.hide(); $sessionDetail = $screen.find("#account-session-detail-div"); invitationDialog = invitationDlg; + $templateOpenSlots = $('#template-open-slots'); } this.initialize = initialize; diff --git a/web/app/assets/javascripts/scheduled_session.js b/web/app/assets/javascripts/scheduled_session.js index f1e742541..779855bcf 100644 --- a/web/app/assets/javascripts/scheduled_session.js +++ b/web/app/assets/javascripts/scheduled_session.js @@ -302,7 +302,12 @@ $('#session-instruments-me-disp').html(instruments_me.join(', ')); var instruments_rsvp = []; - $.each(instrumentRSVP.getSelectedInstruments(), function(index, instrument) { + var otherInstruments = instrumentRSVP.getSelectedInstruments(); + var isUnstructuredRsvp = otherInstruments.length == 0 && userSelectedSlots(createSessionSettings.createType); + if(isUnstructuredRsvp) { + instruments_rsvp.push('Any Instrument Allowed'); + } + $.each(otherInstruments, function(index, instrument) { instruments_rsvp.push(instrument.name + ' (' + instrument.count + ') (' + proficiencyDescriptionMap[instrument.level] + ')'); }); $('#session-instruments-rsvp-disp').html(instruments_rsvp.join(', ')); @@ -528,6 +533,11 @@ } } + // did the user have to pick the RSVP slots explicitely? + function userSelectedSlots(createType) { + return createType == "immediately" || createType == "schedule-future" || createType == "rsvp"; + } + function startSession() { var data = {}; @@ -595,7 +605,7 @@ }); var otherInstruments = instrumentRSVP.getSelectedInstruments(); - data.isUnstructuredRsvp = otherInstruments.length == 0; + data.isUnstructuredRsvp = otherInstruments.length == 0 && userSelectedSlots(createSessionSettings.createType); $.each(instrumentRSVP.getSelectedInstruments(), function(index, instrument) { for (var i = 0; i < instrument.count; i++) { var slot = {}; diff --git a/web/app/assets/javascripts/sessionList.js b/web/app/assets/javascripts/sessionList.js index 6c020e0ed..8e2b9c0b1 100644 --- a/web/app/assets/javascripts/sessionList.js +++ b/web/app/assets/javascripts/sessionList.js @@ -8,6 +8,7 @@ var logger = context.JK.logger; var rest = context.JK.Rest(); var ui = new context.JK.UIHelper(app); + var sessionUtils = context.JK.SessionUtils; var $activeSessionTemplate = $('#template-active-session-row'); var $inactiveSessionTemplate = $('#template-inactive-session-row'); var $notationFileTemplate = $('#template-notation-files'); @@ -72,13 +73,13 @@ // render if anyone interested if(session['is_unstructured_rsvp?']) { - openSlotsHtml += createOpenSlot({description: 'Any Instrument'}) + openSlotsHtml += sessionUtils.createOpenSlot($openSlotsTemplate, {description: 'Any Instrument'}) } // render open slots if (session.open_slots) { for (i=0; i < session.open_slots.length; i++) { - openSlotsHtml += createOpenSlot(session.open_slots[i]); + openSlotsHtml += sessionUtils.createOpenSlot($openSlotsTemplate, session.open_slots[i]); } } @@ -157,14 +158,14 @@ if(session['is_unstructured_rsvp?']) { openSlots = true; - openSlotsHtml += createOpenSlot({description: 'Any Instrument'}) + openSlotsHtml += sessionUtils.createOpenSlot($openSlotsTemplate, {description: 'Any Instrument'}) } // render open slots if (session.open_slots) { for (i=0; i < session.open_slots.length; i++) { openSlots = true; - openSlotsHtml += createOpenSlot(session.open_slots[i]); + openSlotsHtml += sessionUtils.createOpenSlot($openSlotsTemplate, session.open_slots[i]); } } @@ -333,27 +334,6 @@ }; } - function createOpenSlot(slot) { - var inst = context.JK.getInstrumentIcon24(slot.instrument_id); - - var proficiency_desc = slot.proficiency_desc; - if(!proficiency_desc) { - // this is to allow unstructured RSVPs to not specify proficiency_desc - proficiency_desc = "Any Skill Level"; - } - - if(!slot.proficiency_desc) { - proficiency_desc - } - var slot = { - instrument_url: inst, - instrument: slot.description, - proficiency: proficiency_desc - }; - - return context.JK.fillTemplate($openSlotsTemplate.html(), slot); - } - function createNotationFile(notation) { var notationVals = { file_url: notation.file_url, diff --git a/web/app/assets/javascripts/session_utils.js b/web/app/assets/javascripts/session_utils.js new file mode 100644 index 000000000..004b44b0e --- /dev/null +++ b/web/app/assets/javascripts/session_utils.js @@ -0,0 +1,35 @@ +/** + * Common utility functions. + */ +(function (context, $) { + + "use strict"; + + context.JK = context.JK || {}; + var sessionUtils = {}; + var rest = new context.JK.Rest(); + context.JK.SessionUtils = sessionUtils; + var logger = context.JK.logger; + + sessionUtils.createOpenSlot = function($openSlotsTemplate, slot) { + var inst = context.JK.getInstrumentIcon24(slot.instrument_id); + + var proficiency_desc = slot.proficiency_desc; + if(!proficiency_desc) { + // this is to allow unstructured RSVPs to not specify proficiency_desc + proficiency_desc = "Any Skill Level"; + } + + if(!slot.proficiency_desc) { + proficiency_desc + } + var slot = { + instrument_url: inst, + instrument: slot.description, + proficiency: proficiency_desc + }; + + return context.JK.fillTemplate($openSlotsTemplate.html(), slot); + } + +})(window, jQuery); \ No newline at end of file diff --git a/web/app/views/clients/_account_session_detail.html.haml b/web/app/views/clients/_account_session_detail.html.haml index 2cddd976d..f17231201 100644 --- a/web/app/views/clients/_account_session_detail.html.haml +++ b/web/app/views/clients/_account_session_detail.html.haml @@ -14,8 +14,8 @@ .left.sessions-caption %h2 session details: .right - %a.button-orange{href: "#", id: 'cancel-rsvp'} Cancel RSVP - %a.button-orange{href: "#", id: 'invite-others'} Invite Others + %a.button-orange{href: "#", id: 'cancel-rsvp'} CANCEL RSVP + %a.button-orange{href: "#", id: 'invite-others'} INVITE OTHERS .clearall #account-session-detail-div @@ -148,13 +148,6 @@ {{data.legal_policy}} .clearall -%script{type: 'text/template', id: 'template-account-open-slot'} - %tr - %td{width: 24} - %img{src: "{{data.instrument_url}}"} - %td - %div{class: 'nowrap'} - {{data.instrument}} ({{data.proficiency}}) %script{type: 'text/template', id: 'template-account-invited'} %td diff --git a/web/app/views/music_sessions/session_info.html.haml b/web/app/views/music_sessions/session_info.html.haml index 59297bcf2..88673e092 100644 --- a/web/app/views/music_sessions/session_info.html.haml +++ b/web/app/views/music_sessions/session_info.html.haml @@ -80,7 +80,7 @@ - if @approved_rsvps.blank? None - @approved_rsvps.each_with_index do |rsvp, index| - .clearall.left.w100.h20.ib.mb10.rsvp-details + .clearall.left.w100.h20.ib.mb10.rsvp-details{'data-user-id' => rsvp.id} .avatar-tiny{'hoveraction' => "musician", 'user-id' => rsvp.id} - if rsvp.photo_url.nil? = image_tag 'shared/avatar_generic.png', :alt => "" diff --git a/web/spec/features/create_session_flow_spec.rb b/web/spec/features/create_session_flow_spec.rb index 60f1a82d8..f8e672f0e 100644 --- a/web/spec/features/create_session_flow_spec.rb +++ b/web/spec/features/create_session_flow_spec.rb @@ -190,22 +190,24 @@ describe "Create Session Flow", :js => true, :type => :feature, :capybara_featur find('div#divSessionPolicy ins').trigger(:click) find('.btn-next').trigger(:click) end + end - it "initial status" do - find('.session-step-title', text: 'Review & Confirm?') - find('em#session-name-disp', text: 'Test (Rock)') - find('div#session-description-disp', text: 'Test Description') - find('div#session-language-disp', text: 'English') - find('div#session-invited-disp', text: 'Any interested JamKazam musicians that I approve') - find('div#session-instruments-me-disp', text: 'Electric Guitar') - find('div#session-musician-access-disp', text: 'Musicians: Musicians may join by approval') - find('div#session-fans-access-disp', text: 'Fans: Fans may listen, chat with each other') - find('div#session-policy-disp', text: 'Standard') - page.should have_css(".btn-back") - page.should have_css(".btn-next") - page.should have_css(".btn-help") - end + it "initial status" do + find('.session-step-title', text: 'Review & Confirm') + find('em#session-name-disp', text: 'Test Name (Rock)') + find('div#session-description-disp', text: 'Test Description') + find('div#session-language-disp', text: 'English') + find('div#session-invited-disp', text: 'Any interested JamKazam musicians that I approve') + find('div#session-instruments-me-disp', text: 'Other') + find('div#session-instruments-rsvp-disp', text: 'Any Instrument Allowed') + find('div#session-musician-access-disp', text: 'Musicians: Musicians may join by approval') + find('div#session-fans-access-disp', text: 'Fans: Fans may listen, chat with each other') + find('div#session-policy-disp', text: 'Standard') + + page.should have_css(".btn-back") + page.should have_css(".btn-next") + page.should have_css(".btn-help") end end end diff --git a/web/spec/features/find_sessions_spec.rb b/web/spec/features/find_sessions_spec.rb index 77fd482f5..b6a6a04ef 100644 --- a/web/spec/features/find_sessions_spec.rb +++ b/web/spec/features/find_sessions_spec.rb @@ -88,16 +88,24 @@ describe "Find Session", :js => true, :type => :feature, :capybara_feature => tr it "handles is_unstructured_rsvp sessions correctly" do + # create an unstructured session music_session = FactoryGirl.create(:music_session, creator: user, is_unstructured_rsvp: true) fast_signin(finder, Nav.find_session) + # verify it says the right thing in the 'Still Needed' section find("#sessions-scheduled tr.found-session div.instruments", text: 'Any Instrument (Any Skill Level)') + # bring up the RSVP dialog find('.rsvp-link').trigger(:click) - # bring up the RSVP dialog + # select the only option (Any Instrument) find('.rsvp-instruments input[value="unstructured"]').trigger(:click) + + # submit the RSVP + find('#btnSubmitRsvp').trigger(:click) + + # TODO: verify that the UI works - after VRFS-1892 end end end diff --git a/web/spec/features/session_info_spec.rb b/web/spec/features/session_info_spec.rb index 23b9d88e8..c0ae5682b 100644 --- a/web/spec/features/session_info_spec.rb +++ b/web/spec/features/session_info_spec.rb @@ -93,9 +93,9 @@ describe "Session Info", :js => true, :type => :feature, :capybara_feature => tr find('div.legal_policy', text: @music_session.legal_policy.capitalize) # right sidebar - RSVPs - find('div.rsvp-details .avatar-tiny') - find('div.rsvp-details .rsvp-name', text: @rsvp_approved_user.name) - find('div.rsvp-details img.instrument-icon') + find("div.rsvp-details[data-user-id=\"#{@rsvp_approved_user.id}\"] .avatar-tiny") + find("div.rsvp-details[data-user-id=\"#{@rsvp_approved_user.id}\"] .rsvp-name", text: @rsvp_approved_user.name) + find("div.rsvp-details[data-user-id=\"#{@rsvp_approved_user.id}\"] img.instrument-icon") # right sidebar - Still Needed find('div.still-needed', text: @slot2.instrument.id.capitalize)