VRFS-1746 RSVP cancel dialog complete

This commit is contained in:
Brian Smith 2014-05-29 22:02:29 -04:00
parent f1229f6842
commit d4a21e62f3
5 changed files with 31 additions and 20 deletions

View File

@ -43,13 +43,18 @@
e.preventDefault();
var error = false;
rest.cancelRsvpRequest(sessionId, rsvpRequestId)
var cancelOption = $('input[name="cancel"]:checked', $screen).val();
rest.cancelRsvpRequest(sessionId, rsvpRequestId, cancelOption)
.done(function(response) {
console.log("add session comment");
var comment = $.trim($('#txtComment', $screen).val());
if (comment.length > 0) {
rest.addSessionInfoComment(sessionId, comment)
.done(function(response) {
if (!error) {
app.layout.closeDialog(dialogId);
$btnCancel.trigger("rsvpCancelEvent");
}
})
.fail(function(xhr) {
error = true;
@ -57,17 +62,18 @@
$('.error', $screen).show();
});
}
else {
if (!error) {
app.layout.closeDialog(dialogId);
$btnCancel.trigger("rsvpCancelEvent");
}
}
})
.fail(function(xhr) {
error = true;
$('.error', $screen).html("Unexpected error occurred while cancelling RSVP request (" + xhr.status + ")");
$('.error', $screen).show();
});
if (!error) {
app.layout.closeDialog(dialogId);
$btnCancel.trigger("rsvpCancelEvent");
}
});
}

View File

@ -78,7 +78,10 @@
if (comment.length > 0) {
rest.addSessionInfoComment(sessionId, comment)
.done(function(response) {
if (!error) {
app.layout.closeDialog(dialogId);
$btnSubmit.trigger("rsvpSubmitEvent");
}
})
.fail(function(xhr) {
error = true;
@ -86,17 +89,18 @@
$('.error', $screen).show();
});
}
else {
if (!error) {
app.layout.closeDialog(dialogId);
$btnSubmit.trigger("rsvpSubmitEvent");
}
}
})
.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(dialogId);
$btnSubmit.trigger("rsvpSubmitEvent");
}
});
}

View File

@ -36,14 +36,12 @@
}
function launchRsvpSubmitDialog(sessionId) {
console.log("launching submit");
var rsvpDialog = new JK.RsvpSubmitDialog(JK.app, sessionId);
rsvpDialog.initialize();
rsvpDialog.showDialog();
}
function launchRsvpCancelDialog(sessionId, rsvpRequestId) {
console.log("launching cancel");
var rsvpDialog = new JK.RsvpCancelDialog(JK.app, sessionId, rsvpRequestId);
rsvpDialog.initialize();
rsvpDialog.showDialog();

View File

@ -79,15 +79,18 @@
});
// retrieve RSVP requests for this user
rest.getRsvpRequests(musicSessionId)
.done(function(rsvp) {
if (rsvp && rsvp.length > 0) {
.done(function(rsvps) {
if (rsvps && rsvps.length > 0) {
// should only be 1 RSVP for this session
var rsvp = rsvps[0];
if (rsvp.canceled) {
$('.call-to-action').html('Your RSVP request to this session has been cancelled.');
$btnAction.hide();
}
else {
$('.call-to-action').html('Tell session organizer if you can no longer join this session');
$('.call-to-action').html('Tell the session organizer if you can no longer join this session');
$btnAction.html('CANCEL RSVP');
$btnAction.click(function(e) {
ui.launchRsvpCancelDialog(musicSessionId, rsvp.id);
@ -96,7 +99,7 @@
}
// no RSVP
else {
$('.call-to-action').html("Tell the session creator you'd like to play in this session");
$('.call-to-action').html("Tell the session organizer you'd like to play in this session");
$btnAction.html('RSVP NOW!');
$btnAction.click(function(e) {
ui.launchRsvpSubmitDialog(musicSessionId);

View File

@ -12,7 +12,7 @@
%br/
%br/
.error{:style => 'display:none'}
%input{:type => 'radio', :name => 'cancel', :value => 'single', :checked => true} Cancel RSVP just for this one session
%input{:type => 'radio', :name => 'cancel', :value => 'yes', :checked => true} Cancel RSVP just for this one session
%br/
%input{:type => 'radio', :name => 'cancel', :value => 'all'} Cancel RSVP for all future sessions
%br/