From fea728923fa0f67915a3e19602a3ea4daa5db6fb Mon Sep 17 00:00:00 2001 From: Brian Smith Date: Wed, 28 May 2014 01:14:14 -0400 Subject: [PATCH] VRFS-1671 RSVP submit dialog work --- .../images/content/icon_checkmark_circle.png | Bin 0 -> 448 bytes web/app/assets/javascripts/commentDialog.js | 6 +- web/app/assets/javascripts/jam_rest.js | 27 +++++ .../assets/javascripts/rsvpSubmitDialog.js | 105 ++++++++++++++++++ web/app/assets/javascripts/ui_helper.js | 14 +++ web/app/assets/javascripts/utils.js | 6 + .../javascripts/web/scheduled_session.js | 5 + .../stylesheets/client/screen_common.css.scss | 8 ++ .../controllers/api_rsvp_slots_controller.rb | 6 +- web/app/views/api_music_sessions/show.rabl | 2 +- .../api_music_sessions/show_history.rabl | 2 +- .../views/clients/_rsvpReviewDialog.html.haml | 0 .../views/clients/_rsvpSubmitDialog.html.haml | 26 +++++ web/app/views/layouts/web.html.erb | 2 + 14 files changed, 203 insertions(+), 6 deletions(-) create mode 100644 web/app/assets/images/content/icon_checkmark_circle.png delete mode 100644 web/app/views/clients/_rsvpReviewDialog.html.haml diff --git a/web/app/assets/images/content/icon_checkmark_circle.png b/web/app/assets/images/content/icon_checkmark_circle.png new file mode 100644 index 0000000000000000000000000000000000000000..ee372cf25217800c79aff43743b0575728f58fec GIT binary patch literal 448 zcmV;x0YCnUP)l9f zdkt3Lix)hCxv@jZoaZ`TyRr;wA$|`g5#pW+ukj{zXi$o@Y|ao4*@$$N(x4S-nGO)n z`Ex4L)p~l2P4Oy;0pX0&%M?@rcApte)&n6#x`0PDXunJ>``$SA+8=3qa1b@ qKdwi)a7MW@|NYWWFa6r`E5HElU-PE-1}eq?0000 0) { + $.each(response, function(index, val) { + var instrument = val.instrument_id; + + var instrumentTitleCase = context.JK.toTitleCase(instrument); + // var instrumentTitleCase = instrument.charAt(0).toUpperCase() + instrument.substr(1).toLowerCase(); + // var instTitleCase = val.instrument_id.charAt(0).toUpperCase() + context.val.instrument_id.charAt(0) + $('.rsvp-instruments', $screen).append('' + instrumentTitleCase + "
"); + }); + } + else { + $('.slot-instructions', $screen).hide(); + $('.rsvp-instruments', $screen).hide(); + } + }) + .fail(function(xhr) { + + }); + } + + function afterHide() { + } + + function showDialog() { + app.layout.showDialog('rsvp-submit-dialog'); + } + + function events() { + $("#btnSubmit").click(function(e) { + rest.submitRsvpRequest(sessionId) + .done(function(response) { + + var comment = $.trim($('#txtComment', $screen).val()); + if (comment.length > 0) { + rest.addSessionInfoComment(sessionId, comment) + .done(function(response) { + + }) + .fail(function(xhr) { + + }); + } + + app.layout.cDialog('rsvp-submit-dialog'); + }) + .fail(function(xhr) { + + }); + }); + } + + function initialize() { + + var dialogBindings = { + 'beforeShow' : beforeShow, + 'afterShow' : afterShow, + 'afterHide': afterHide + }; + + app.bindDialog('rsvp-submit-dialog', dialogBindings); + + $screen = $('[layout-id="rsvp-submit-dialog"]'); + + events(); + } + + this.initialize = initialize; + this.showDialog = showDialog; + } + + return this; +})(window,jQuery); \ No newline at end of file diff --git a/web/app/assets/javascripts/ui_helper.js b/web/app/assets/javascripts/ui_helper.js index 97eacab17..a4b1240d1 100644 --- a/web/app/assets/javascripts/ui_helper.js +++ b/web/app/assets/javascripts/ui_helper.js @@ -35,10 +35,24 @@ shareDialog.showDialog(); } + function launchRsvpSubmitDialog(sessionId) { + var rsvpDialog = new JK.RsvpSubmitDialog(JK.app, sessionId); + rsvpDialog.initialize(); + rsvpDialog.showDialog(); + } + + function launchRsvpCancelDialog(sessionId) { + var rsvpDialog = new JK.RsvpCancelDialog(JK.app, sessionId); + rsvpDialog.initialize(); + rsvpDialog.showDialog(); + } + this.addSessionLike = addSessionLike; this.addRecordingLike = addRecordingLike; this.launchCommentDialog = launchCommentDialog; this.launchShareDialog = launchShareDialog; + this.launchRsvpSubmitDialog = launchRsvpSubmitDialog; + this.launchRsvpCancelDialog = launchRsvpCancelDialog; return this; }; diff --git a/web/app/assets/javascripts/utils.js b/web/app/assets/javascripts/utils.js index 2203d6ffb..bcbb6d295 100644 --- a/web/app/assets/javascripts/utils.js +++ b/web/app/assets/javascripts/utils.js @@ -302,6 +302,12 @@ }); } + context.JK.toTitleCase = function(str) { + return str.replace(/\w\S*/g, function(txt){ + return txt.charAt(0).toUpperCase() + txt.substr(1).toLowerCase(); + }); + } + // Uber-simple templating // var template = "Hey {name}"; diff --git a/web/app/assets/javascripts/web/scheduled_session.js b/web/app/assets/javascripts/web/scheduled_session.js index 0c89246c0..ff3792ede 100644 --- a/web/app/assets/javascripts/web/scheduled_session.js +++ b/web/app/assets/javascripts/web/scheduled_session.js @@ -7,6 +7,7 @@ context.JK.ShowSessionInfo = function(app) { var logger = context.JK.logger; var rest = JK.Rest(); + var ui = new context.JK.UIHelper(app); function addComment(musicSessionId) { console.log("here"); @@ -80,6 +81,10 @@ context.JK.bindHoverEvents($parent); context.JK.setInstrumentAssetPath($('.instrument-icon', $parent)); + $("#btn-rsvp").click(function(e) { + ui.launchRsvpSubmitDialog(musicSessionId); + }); + $("#btnPostComment").click(function(e) { if ($.trim($("#txtSessionInfoComment").val()).length > 0) { addComment(musicSessionId); diff --git a/web/app/assets/stylesheets/client/screen_common.css.scss b/web/app/assets/stylesheets/client/screen_common.css.scss index 459d37cdd..1687c332d 100644 --- a/web/app/assets/stylesheets/client/screen_common.css.scss +++ b/web/app/assets/stylesheets/client/screen_common.css.scss @@ -171,6 +171,14 @@ a img {border:none;} small, .small {font-size:11px;} .bold {font-weight:bold;} +.rsvp-instruments { + height:80px; + overflow:auto; + background-color:#202020; + padding:8px; + margin-top:5px; +} + .button-grey { margin:0px 8px 0px 8px; background-color:#666; diff --git a/web/app/controllers/api_rsvp_slots_controller.rb b/web/app/controllers/api_rsvp_slots_controller.rb index 38771aa48..7b4f2e3bc 100644 --- a/web/app/controllers/api_rsvp_slots_controller.rb +++ b/web/app/controllers/api_rsvp_slots_controller.rb @@ -13,7 +13,11 @@ class ApiRsvpSlotsController < ApiController music_session = MusicSession.find(params[:session_id]) # retrieve all slots for this session - @rsvp_slots = RsvpSlot.index(music_session) + if params[:open_only] + @rsvp_slots = music_session.open_slots + else + @rsvp_slots = RsvpSlot.index(music_session) + end respond_with @rsvp_slots, responder: ApiResponder, :status => 200 diff --git a/web/app/views/api_music_sessions/show.rabl b/web/app/views/api_music_sessions/show.rabl index f2498edaf..a8547fe17 100644 --- a/web/app/views/api_music_sessions/show.rabl +++ b/web/app/views/api_music_sessions/show.rabl @@ -1,4 +1,4 @@ - object @music_session +object @music_session if !current_user # there should be more data returned, but we need to think very carefully about what data is public for a music session diff --git a/web/app/views/api_music_sessions/show_history.rabl b/web/app/views/api_music_sessions/show_history.rabl index 01fef08f3..3ccfcb73e 100644 --- a/web/app/views/api_music_sessions/show_history.rabl +++ b/web/app/views/api_music_sessions/show_history.rabl @@ -17,7 +17,7 @@ if !current_user else attributes :id, :music_session_id, :name, :description, :musician_access, :approval_required, :fan_access, :fan_chat, - :band_id, :user_id, :genre_id, :created_at, :like_count, :comment_count, :scheduled_start, :scheduled_duration, :language + :band_id, :user_id, :genre_id, :created_at, :like_count, :comment_count, :scheduled_start, :scheduled_duration, :language, :recurring_mode, :language_description, :scheduled_start_time, :access_description node :share_url do |history| unless history.share_token.nil? diff --git a/web/app/views/clients/_rsvpReviewDialog.html.haml b/web/app/views/clients/_rsvpReviewDialog.html.haml deleted file mode 100644 index e69de29bb..000000000 diff --git a/web/app/views/clients/_rsvpSubmitDialog.html.haml b/web/app/views/clients/_rsvpSubmitDialog.html.haml index e69de29bb..49e7b2d9c 100644 --- a/web/app/views/clients/_rsvpSubmitDialog.html.haml +++ b/web/app/views/clients/_rsvpSubmitDialog.html.haml @@ -0,0 +1,26 @@ +.dialog.dialog-overlay-sm{layout: 'dialog', 'layout-id' => 'rsvp-submit-dialog', id: 'rsvp-submit-dialog'} + .content-head + = image_tag 'content/icon_checkmark_circle.png', :alt => "", :class => "content-icon", :width => "20", :height => "20" + %h1 rsvp + .dialog-inner + %h2 SESSION + %span.session-name + %br/ + %span.scheduled-start + %br/ + %span.schedule-recurrence + %br/ + %br/ + %span.slot-instructions Check the box(es) next to the track(s) you want to play in the session: + .rsvp-instruments + %br/ + Enter a message to the other musicians in the session (optional): + %textarea.w95.p5.f15{id: 'txtComment', rows: '2', placeholder: 'Enter a comment...'} + %br/ + %br/ + .left + %a.button-orange{:href => 'TBD', :rel => 'external'} HELP + .right + %a.button-grey{:id => 'btnCancel', :href => 'TBD', 'layout-action' => 'close'} CANCEL + %a.button-orange{:id => 'btnSubmit', :href => 'TBD'} SUBMIT RSVP + %br{:clear => "all"}/ \ No newline at end of file diff --git a/web/app/views/layouts/web.html.erb b/web/app/views/layouts/web.html.erb index 60b500f40..b4518492c 100644 --- a/web/app/views/layouts/web.html.erb +++ b/web/app/views/layouts/web.html.erb @@ -83,6 +83,8 @@ <%= render "clients/hoverBand" %> <%= render "clients/hoverSession" %> <%= render "clients/hoverRecording" %> + <%= render "clients/rsvpSubmitDialog" %> + <%= render "clients/rsvpCancelDialog" %> <%= yield(:extra_dialogs) %>