VRFS-1671 RSVP submit dialog

This commit is contained in:
Brian Smith 2014-05-28 23:43:57 -04:00
parent fea728923f
commit 4d63dad502
8 changed files with 55 additions and 22 deletions

View File

@ -222,7 +222,7 @@
subject = "Session Invitation"
unique_args = {:type => "scheduled_session_invitation"}
@body = msg
@session_name = session.description
@session_name = session.name
@session_date = session.scheduled_start
@session_url = "#{APP_CONFIG.external_root_url}/sessions/#{session.id}/details"
sendgrid_category "Notification"
@ -241,7 +241,7 @@
subject = "Session RSVP"
unique_args = {:type => "scheduled_session_rsvp"}
@body = msg
@session_name = session.description
@session_name = session.name
@session_date = session.scheduled_start
@session_url = "#{APP_CONFIG.external_root_url}/sessions/#{session.id}/details"
sendgrid_category "Notification"
@ -260,7 +260,7 @@
subject = "Session RSVP Approved"
unique_args = {:type => "scheduled_session_rsvp_approved"}
@body = msg
@session_name = session.description
@session_name = session.name
@session_date = session.scheduled_start
@session_url = "#{APP_CONFIG.external_root_url}/sessions/#{session.id}/details"
sendgrid_category "Notification"
@ -279,7 +279,7 @@
subject = "Session RSVP Cancelled"
unique_args = {:type => "scheduled_session_rsvp_cancelled"}
@body = msg
@session_name = session.description
@session_name = session.name
@session_date = session.scheduled_start
@session_url = "#{APP_CONFIG.external_root_url}/sessions/#{session.id}/details"
sendgrid_category "Notification"
@ -298,7 +298,7 @@
subject = "Your Session RSVP Cancelled"
unique_args = {:type => "scheduled_session_rsvp_cancelled_org"}
@body = msg
@session_name = session.description
@session_name = session.name
@session_date = session.scheduled_start
@session_url = "#{APP_CONFIG.external_root_url}/sessions/#{session.id}/details"
sendgrid_category "Notification"
@ -317,7 +317,7 @@
subject = "Session Cancelled"
unique_args = {:type => "scheduled_session_cancelled"}
@body = msg
@session_name = session.description
@session_name = session.name
@session_date = session.scheduled_start
@session_url = "#{APP_CONFIG.external_root_url}/sessions/#{session.id}/details"
sendgrid_category "Notification"
@ -336,7 +336,7 @@
subject = "Session Rescheduled"
unique_args = {:type => "scheduled_session_rescheduled"}
@body = msg
@session_name = session.description
@session_name = session.name
@session_date = session.scheduled_start
@session_url = "#{APP_CONFIG.external_root_url}/sessions/#{session.id}/details"
sendgrid_category "Notification"
@ -355,7 +355,7 @@
subject = "Session Rescheduled"
unique_args = {:type => "scheduled_session_reminder"}
@body = msg
@session_name = session.description
@session_name = session.name
@session_date = session.scheduled_start
@session_url = "#{APP_CONFIG.external_root_url}/sessions/#{session.id}/details"
sendgrid_category "Notification"
@ -374,7 +374,7 @@
subject = "New Session Comment"
unique_args = {:type => "scheduled_session_comment"}
@body = msg
@session_name = session.description
@session_name = session.name
@session_date = session.scheduled_start
@comment = comment
@session_url = "#{APP_CONFIG.external_root_url}/sessions/#{session.id}/details"

View File

@ -42,8 +42,8 @@ module JamRuby
# verify invitation exists for this user and session
invitation = Invitation.where("music_session_id = ? AND receiver_id = ?", music_session.id, user.id)
if invitation.blank?
raise PermissionError, "Only a session invitee can create an RSVP."
if invitation.blank? && !music_session.open_rsvps
raise PermissionError, "Only a session invitee can create an RSVP for this session."
end
# verify slot IDs exist in request
@ -56,6 +56,7 @@ module JamRuby
@rsvp.user = user
slot_ids = params[:rsvp_slots]
instruments = []
# for each slot requested, do the following:

View File

@ -135,11 +135,11 @@
});
}
function submitRsvpRequest(sessionId) {
function submitRsvpRequest(sessionId, slotIds) {
return $.ajax({
url: '/api/rsvp_requests',
type: "POST",
data : JSON.stringify({"session_id": sessionId}),
data : JSON.stringify({"session_id": sessionId, "rsvp_slots": slotIds}),
dataType : 'json',
contentType: 'application/json'
});

View File

@ -38,7 +38,7 @@
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('<input type="checkbox" value="' + val.instrument_id + '"/>' + instrumentTitleCase + "<br/>");
$('.rsvp-instruments', $screen).append('<input type="checkbox" value="' + val.id + '"/>' + instrumentTitleCase + "<br/>");
});
}
else {
@ -59,10 +59,22 @@
}
function events() {
$("#btnSubmit").unbind('click');
$("#btnSubmit").click(function(e) {
rest.submitRsvpRequest(sessionId)
e.preventDefault();
var slotIds = [];
$("input:checked", '.rsvp-instruments').each(function(index) {
slotIds.push($(this).val());
});
if (slotIds.length === 0) {
$('.error', $screen).show();
return;
}
var error = false;
rest.submitRsvpRequest(sessionId, slotIds)
.done(function(response) {
var comment = $.trim($('#txtComment', $screen).val());
if (comment.length > 0) {
rest.addSessionInfoComment(sessionId, comment)
@ -70,15 +82,22 @@
})
.fail(function(xhr) {
error = true;
$('.error', $screen).html("Unexpected error occurred while saving message (" + xhr.status + ")");
$('.error', $screen).show();
});
}
app.layout.cDialog('rsvp-submit-dialog');
})
.fail(function(xhr) {
error = true;
$('.error', $screen).html("Unexpected error occurred while saving RSVP request (" + xhr.status + ")");
$('.error', $screen).show();
});
if (!error) {
app.layout.closeDialog('rsvp-submit-dialog');
$("#btnSubmit").trigger("rsvpSubmitEvent");
}
});
}

View File

@ -92,6 +92,10 @@
$("#txtSessionComment").blur();
}
});
$(document).on("rsvpSubmitEvent", function() {
location.reload();
});
}
this.initialize = initialize;

View File

@ -383,7 +383,7 @@ input[type="text"], input[type="password"]{
}
.error input {
background-color:#Fadfd1 !important;
background-color:#fadfd1 !important;
margin-bottom:5px;
}

View File

@ -10,8 +10,9 @@
%br/
%span.schedule-recurrence
%br/
%br/
%br/
%span.slot-instructions Check the box(es) next to the track(s) you want to play in the session:
.error{:style => 'display:none'} You must select at least 1 instrument.
.rsvp-instruments
%br/
Enter a message to the other musicians in the session (optional):

View File

@ -60,5 +60,13 @@ describe "Session Info", :js => true, :type => :feature, :capybara_feature => tr
it "should allow only RSVP approvals or session invitees to add comments" do
end
it "should show Submit RSVP button and launch submit dialog if user has not RSVPed" do
end
it "should show Cancel RSVP button and launch cancel dialog if user has RSVPed" do
end
it "should show no call to action button if user has not RSVPed and all slots are taken" do
end
end