VRFS-1671 RSVP submit dialog work
This commit is contained in:
parent
c7fc7bdc22
commit
fea728923f
Binary file not shown.
|
After Width: | Height: | Size: 448 B |
|
|
@ -128,9 +128,9 @@
|
|||
function initialize() {
|
||||
|
||||
var dialogBindings = {
|
||||
'beforeShow' : beforeShow,
|
||||
'afterShow' : afterShow,
|
||||
'afterHide': afterHide
|
||||
'beforeShow' : beforeShow,
|
||||
'afterShow' : afterShow,
|
||||
'afterHide': afterHide
|
||||
};
|
||||
|
||||
app.bindDialog('comment-dialog', dialogBindings);
|
||||
|
|
|
|||
|
|
@ -135,6 +135,31 @@
|
|||
});
|
||||
}
|
||||
|
||||
function submitRsvpRequest(sessionId) {
|
||||
return $.ajax({
|
||||
url: '/api/rsvp_requests',
|
||||
type: "POST",
|
||||
data : JSON.stringify({"session_id": sessionId}),
|
||||
dataType : 'json',
|
||||
contentType: 'application/json'
|
||||
});
|
||||
}
|
||||
|
||||
function getOpenSessionSlots(sessionId, openOnly) {
|
||||
var url = '/api/rsvp_slots?session_id=' + sessionId;
|
||||
|
||||
if (openOnly) {
|
||||
url += '&open_only=true';
|
||||
}
|
||||
return $.ajax({
|
||||
type: "GET",
|
||||
dataType: "json",
|
||||
url: url,
|
||||
contentType: 'application/json',
|
||||
processData: false
|
||||
});
|
||||
}
|
||||
|
||||
function addRecordingComment(recordingId, userId, comment) {
|
||||
return $.ajax({
|
||||
url: '/api/recordings/' + recordingId + "/comments",
|
||||
|
|
@ -1061,6 +1086,8 @@
|
|||
this.addSessionComment = addSessionComment;
|
||||
this.addSessionInfoComment = addSessionInfoComment;
|
||||
this.addSessionLike = addSessionLike;
|
||||
this.submitRsvpRequest = submitRsvpRequest;
|
||||
this.getOpenSessionSlots = getOpenSessionSlots;
|
||||
this.addRecordingComment = addRecordingComment;
|
||||
this.addRecordingLike = addRecordingLike;
|
||||
this.addPlayablePlay = addPlayablePlay;
|
||||
|
|
|
|||
|
|
@ -0,0 +1,105 @@
|
|||
(function(context,$) {
|
||||
|
||||
"use strict";
|
||||
context.JK = context.JK || {};
|
||||
context.JK.RsvpSubmitDialog = function(app, sessionId) {
|
||||
var logger = context.JK.logger;
|
||||
var rest = context.JK.Rest();
|
||||
var $screen = null;
|
||||
|
||||
function beforeShow(data) {
|
||||
}
|
||||
|
||||
function afterShow(data) {
|
||||
$('.rsvp-instruments', $screen).empty();
|
||||
|
||||
rest.getSessionHistory(sessionId)
|
||||
.done(function(response) {
|
||||
if (response) {
|
||||
$('.session-name', $screen).html(response.name);
|
||||
$('.scheduled-start', $screen).html(response.scheduled_start);
|
||||
|
||||
if (response.recurring_mode !== null) {
|
||||
$('.schedule-recurrence', $screen).html("Recurs " + response.recurring_mode + " on this day at this time");
|
||||
}
|
||||
}
|
||||
})
|
||||
.fail(function(xhr) {
|
||||
|
||||
});
|
||||
|
||||
// if the session has slots, get the open ones
|
||||
rest.getOpenSessionSlots(sessionId, true)
|
||||
.done(function(response) {
|
||||
if (response && response.length > 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('<input type="checkbox" value="' + val.instrument_id + '"/>' + instrumentTitleCase + "<br/>");
|
||||
});
|
||||
}
|
||||
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);
|
||||
|
|
@ -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;
|
||||
};
|
||||
|
|
|
|||
|
|
@ -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}";
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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?
|
||||
|
|
|
|||
|
|
@ -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"}/
|
||||
|
|
@ -83,6 +83,8 @@
|
|||
<%= render "clients/hoverBand" %>
|
||||
<%= render "clients/hoverSession" %>
|
||||
<%= render "clients/hoverRecording" %>
|
||||
<%= render "clients/rsvpSubmitDialog" %>
|
||||
<%= render "clients/rsvpCancelDialog" %>
|
||||
|
||||
<%= yield(:extra_dialogs) %>
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue