VRFS-1671 RSVP submit dialog
This commit is contained in:
parent
fea728923f
commit
4d63dad502
|
|
@ -222,7 +222,7 @@
|
||||||
subject = "Session Invitation"
|
subject = "Session Invitation"
|
||||||
unique_args = {:type => "scheduled_session_invitation"}
|
unique_args = {:type => "scheduled_session_invitation"}
|
||||||
@body = msg
|
@body = msg
|
||||||
@session_name = session.description
|
@session_name = session.name
|
||||||
@session_date = session.scheduled_start
|
@session_date = session.scheduled_start
|
||||||
@session_url = "#{APP_CONFIG.external_root_url}/sessions/#{session.id}/details"
|
@session_url = "#{APP_CONFIG.external_root_url}/sessions/#{session.id}/details"
|
||||||
sendgrid_category "Notification"
|
sendgrid_category "Notification"
|
||||||
|
|
@ -241,7 +241,7 @@
|
||||||
subject = "Session RSVP"
|
subject = "Session RSVP"
|
||||||
unique_args = {:type => "scheduled_session_rsvp"}
|
unique_args = {:type => "scheduled_session_rsvp"}
|
||||||
@body = msg
|
@body = msg
|
||||||
@session_name = session.description
|
@session_name = session.name
|
||||||
@session_date = session.scheduled_start
|
@session_date = session.scheduled_start
|
||||||
@session_url = "#{APP_CONFIG.external_root_url}/sessions/#{session.id}/details"
|
@session_url = "#{APP_CONFIG.external_root_url}/sessions/#{session.id}/details"
|
||||||
sendgrid_category "Notification"
|
sendgrid_category "Notification"
|
||||||
|
|
@ -260,7 +260,7 @@
|
||||||
subject = "Session RSVP Approved"
|
subject = "Session RSVP Approved"
|
||||||
unique_args = {:type => "scheduled_session_rsvp_approved"}
|
unique_args = {:type => "scheduled_session_rsvp_approved"}
|
||||||
@body = msg
|
@body = msg
|
||||||
@session_name = session.description
|
@session_name = session.name
|
||||||
@session_date = session.scheduled_start
|
@session_date = session.scheduled_start
|
||||||
@session_url = "#{APP_CONFIG.external_root_url}/sessions/#{session.id}/details"
|
@session_url = "#{APP_CONFIG.external_root_url}/sessions/#{session.id}/details"
|
||||||
sendgrid_category "Notification"
|
sendgrid_category "Notification"
|
||||||
|
|
@ -279,7 +279,7 @@
|
||||||
subject = "Session RSVP Cancelled"
|
subject = "Session RSVP Cancelled"
|
||||||
unique_args = {:type => "scheduled_session_rsvp_cancelled"}
|
unique_args = {:type => "scheduled_session_rsvp_cancelled"}
|
||||||
@body = msg
|
@body = msg
|
||||||
@session_name = session.description
|
@session_name = session.name
|
||||||
@session_date = session.scheduled_start
|
@session_date = session.scheduled_start
|
||||||
@session_url = "#{APP_CONFIG.external_root_url}/sessions/#{session.id}/details"
|
@session_url = "#{APP_CONFIG.external_root_url}/sessions/#{session.id}/details"
|
||||||
sendgrid_category "Notification"
|
sendgrid_category "Notification"
|
||||||
|
|
@ -298,7 +298,7 @@
|
||||||
subject = "Your Session RSVP Cancelled"
|
subject = "Your Session RSVP Cancelled"
|
||||||
unique_args = {:type => "scheduled_session_rsvp_cancelled_org"}
|
unique_args = {:type => "scheduled_session_rsvp_cancelled_org"}
|
||||||
@body = msg
|
@body = msg
|
||||||
@session_name = session.description
|
@session_name = session.name
|
||||||
@session_date = session.scheduled_start
|
@session_date = session.scheduled_start
|
||||||
@session_url = "#{APP_CONFIG.external_root_url}/sessions/#{session.id}/details"
|
@session_url = "#{APP_CONFIG.external_root_url}/sessions/#{session.id}/details"
|
||||||
sendgrid_category "Notification"
|
sendgrid_category "Notification"
|
||||||
|
|
@ -317,7 +317,7 @@
|
||||||
subject = "Session Cancelled"
|
subject = "Session Cancelled"
|
||||||
unique_args = {:type => "scheduled_session_cancelled"}
|
unique_args = {:type => "scheduled_session_cancelled"}
|
||||||
@body = msg
|
@body = msg
|
||||||
@session_name = session.description
|
@session_name = session.name
|
||||||
@session_date = session.scheduled_start
|
@session_date = session.scheduled_start
|
||||||
@session_url = "#{APP_CONFIG.external_root_url}/sessions/#{session.id}/details"
|
@session_url = "#{APP_CONFIG.external_root_url}/sessions/#{session.id}/details"
|
||||||
sendgrid_category "Notification"
|
sendgrid_category "Notification"
|
||||||
|
|
@ -336,7 +336,7 @@
|
||||||
subject = "Session Rescheduled"
|
subject = "Session Rescheduled"
|
||||||
unique_args = {:type => "scheduled_session_rescheduled"}
|
unique_args = {:type => "scheduled_session_rescheduled"}
|
||||||
@body = msg
|
@body = msg
|
||||||
@session_name = session.description
|
@session_name = session.name
|
||||||
@session_date = session.scheduled_start
|
@session_date = session.scheduled_start
|
||||||
@session_url = "#{APP_CONFIG.external_root_url}/sessions/#{session.id}/details"
|
@session_url = "#{APP_CONFIG.external_root_url}/sessions/#{session.id}/details"
|
||||||
sendgrid_category "Notification"
|
sendgrid_category "Notification"
|
||||||
|
|
@ -355,7 +355,7 @@
|
||||||
subject = "Session Rescheduled"
|
subject = "Session Rescheduled"
|
||||||
unique_args = {:type => "scheduled_session_reminder"}
|
unique_args = {:type => "scheduled_session_reminder"}
|
||||||
@body = msg
|
@body = msg
|
||||||
@session_name = session.description
|
@session_name = session.name
|
||||||
@session_date = session.scheduled_start
|
@session_date = session.scheduled_start
|
||||||
@session_url = "#{APP_CONFIG.external_root_url}/sessions/#{session.id}/details"
|
@session_url = "#{APP_CONFIG.external_root_url}/sessions/#{session.id}/details"
|
||||||
sendgrid_category "Notification"
|
sendgrid_category "Notification"
|
||||||
|
|
@ -374,7 +374,7 @@
|
||||||
subject = "New Session Comment"
|
subject = "New Session Comment"
|
||||||
unique_args = {:type => "scheduled_session_comment"}
|
unique_args = {:type => "scheduled_session_comment"}
|
||||||
@body = msg
|
@body = msg
|
||||||
@session_name = session.description
|
@session_name = session.name
|
||||||
@session_date = session.scheduled_start
|
@session_date = session.scheduled_start
|
||||||
@comment = comment
|
@comment = comment
|
||||||
@session_url = "#{APP_CONFIG.external_root_url}/sessions/#{session.id}/details"
|
@session_url = "#{APP_CONFIG.external_root_url}/sessions/#{session.id}/details"
|
||||||
|
|
|
||||||
|
|
@ -42,8 +42,8 @@ module JamRuby
|
||||||
# verify invitation exists for this user and session
|
# verify invitation exists for this user and session
|
||||||
invitation = Invitation.where("music_session_id = ? AND receiver_id = ?", music_session.id, user.id)
|
invitation = Invitation.where("music_session_id = ? AND receiver_id = ?", music_session.id, user.id)
|
||||||
|
|
||||||
if invitation.blank?
|
if invitation.blank? && !music_session.open_rsvps
|
||||||
raise PermissionError, "Only a session invitee can create an RSVP."
|
raise PermissionError, "Only a session invitee can create an RSVP for this session."
|
||||||
end
|
end
|
||||||
|
|
||||||
# verify slot IDs exist in request
|
# verify slot IDs exist in request
|
||||||
|
|
@ -56,6 +56,7 @@ module JamRuby
|
||||||
@rsvp.user = user
|
@rsvp.user = user
|
||||||
|
|
||||||
slot_ids = params[:rsvp_slots]
|
slot_ids = params[:rsvp_slots]
|
||||||
|
|
||||||
instruments = []
|
instruments = []
|
||||||
|
|
||||||
# for each slot requested, do the following:
|
# for each slot requested, do the following:
|
||||||
|
|
|
||||||
|
|
@ -135,11 +135,11 @@
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function submitRsvpRequest(sessionId) {
|
function submitRsvpRequest(sessionId, slotIds) {
|
||||||
return $.ajax({
|
return $.ajax({
|
||||||
url: '/api/rsvp_requests',
|
url: '/api/rsvp_requests',
|
||||||
type: "POST",
|
type: "POST",
|
||||||
data : JSON.stringify({"session_id": sessionId}),
|
data : JSON.stringify({"session_id": sessionId, "rsvp_slots": slotIds}),
|
||||||
dataType : 'json',
|
dataType : 'json',
|
||||||
contentType: 'application/json'
|
contentType: 'application/json'
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -38,7 +38,7 @@
|
||||||
var instrumentTitleCase = context.JK.toTitleCase(instrument);
|
var instrumentTitleCase = context.JK.toTitleCase(instrument);
|
||||||
// var instrumentTitleCase = instrument.charAt(0).toUpperCase() + instrument.substr(1).toLowerCase();
|
// var instrumentTitleCase = instrument.charAt(0).toUpperCase() + instrument.substr(1).toLowerCase();
|
||||||
// var instTitleCase = val.instrument_id.charAt(0).toUpperCase() + context.val.instrument_id.charAt(0)
|
// 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 {
|
else {
|
||||||
|
|
@ -59,10 +59,22 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
function events() {
|
function events() {
|
||||||
|
$("#btnSubmit").unbind('click');
|
||||||
$("#btnSubmit").click(function(e) {
|
$("#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) {
|
.done(function(response) {
|
||||||
|
|
||||||
var comment = $.trim($('#txtComment', $screen).val());
|
var comment = $.trim($('#txtComment', $screen).val());
|
||||||
if (comment.length > 0) {
|
if (comment.length > 0) {
|
||||||
rest.addSessionInfoComment(sessionId, comment)
|
rest.addSessionInfoComment(sessionId, comment)
|
||||||
|
|
@ -70,15 +82,22 @@
|
||||||
|
|
||||||
})
|
})
|
||||||
.fail(function(xhr) {
|
.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) {
|
.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");
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -92,6 +92,10 @@
|
||||||
$("#txtSessionComment").blur();
|
$("#txtSessionComment").blur();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
$(document).on("rsvpSubmitEvent", function() {
|
||||||
|
location.reload();
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
this.initialize = initialize;
|
this.initialize = initialize;
|
||||||
|
|
|
||||||
|
|
@ -383,7 +383,7 @@ input[type="text"], input[type="password"]{
|
||||||
}
|
}
|
||||||
|
|
||||||
.error input {
|
.error input {
|
||||||
background-color:#Fadfd1 !important;
|
background-color:#fadfd1 !important;
|
||||||
margin-bottom:5px;
|
margin-bottom:5px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -10,8 +10,9 @@
|
||||||
%br/
|
%br/
|
||||||
%span.schedule-recurrence
|
%span.schedule-recurrence
|
||||||
%br/
|
%br/
|
||||||
%br/
|
%br/
|
||||||
%span.slot-instructions Check the box(es) next to the track(s) you want to play in the session:
|
%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
|
.rsvp-instruments
|
||||||
%br/
|
%br/
|
||||||
Enter a message to the other musicians in the session (optional):
|
Enter a message to the other musicians in the session (optional):
|
||||||
|
|
|
||||||
|
|
@ -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
|
it "should allow only RSVP approvals or session invitees to add comments" do
|
||||||
end
|
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
|
end
|
||||||
Loading…
Reference in New Issue