diff --git a/pb/src/client_container.proto b/pb/src/client_container.proto index ffa1478b7..335bd1858 100644 --- a/pb/src/client_container.proto +++ b/pb/src/client_container.proto @@ -124,6 +124,8 @@ message ClientMessage { optional SessionDepart session_depart = 171; optional MusicianSessionJoin musician_session_join = 172; optional TracksChanged tracks_changed = 173; + + // scheduled sessions optional ScheduledSessionInvitation scheduled_session_invitation = 174; optional ScheduledSessionRsvp scheduled_session_rsvp = 175; optional ScheduledSessionRsvpApproved scheduled_session_rsvp_approved = 176; @@ -356,7 +358,7 @@ message ScheduledSessionRsvp { optional string session_id = 1; optional string photo_url = 2; optional string msg = 3; - optional string slot_id = 4; + optional string user_id = 4; optional string instruments = 5; optional string session_name = 6; optional string session_date = 7; @@ -365,31 +367,67 @@ message ScheduledSessionRsvp { } message ScheduledSessionRsvpApproved { - + optional string session_id = 1; + optional string msg = 2; + optional string session_name = 3; + optional string session_date = 4; + optional string notification_id = 5; + optional string created_at = 6; } message ScheduledSessionRsvpCancelled { - + optional string session_id = 1; + optional string msg = 2; + optional string session_name = 3; + optional string session_date = 4; + optional string notification_id = 5; + optional string created_at = 6; } message ScheduledSessionRsvpCancelledOrg { - + optional string session_id = 1; + optional string msg = 2; + optional string session_name = 3; + optional string session_date = 4; + optional string notification_id = 5; + optional string created_at = 6; } message ScheduledSessionCancelled { - + optional string session_id = 1; + optional string msg = 2; + optional string session_name = 3; + optional string session_date = 4; + optional string notification_id = 5; + optional string created_at = 6; } message ScheduledSessionRescheduled { - + optional string session_id = 1; + optional string msg = 2; + optional string session_name = 3; + optional string session_date = 4; + optional string notification_id = 5; + optional string created_at = 6; } message ScheduledSessionReminder { - + optional string session_id = 1; + optional string msg = 2; + optional string session_name = 3; + optional string session_date = 4; + optional string notification_id = 5; + optional string created_at = 6; } message ScheduledSessionComment { - + optional string session_id = 1; + optional string photo_url = 2; + optional string msg = 3; + optional string session_name = 4; + optional string session_date = 5; + optional string notification_id = 6; + optional string created_at = 7; } message MusicianRecordingSaved { diff --git a/ruby/lib/jam_ruby/app/views/jam_ruby/user_mailer/scheduled_session_cancelled.html.erb b/ruby/lib/jam_ruby/app/views/jam_ruby/user_mailer/scheduled_session_cancelled.html.erb new file mode 100644 index 000000000..e69de29bb diff --git a/ruby/lib/jam_ruby/app/views/jam_ruby/user_mailer/scheduled_session_cancelled.text.erb b/ruby/lib/jam_ruby/app/views/jam_ruby/user_mailer/scheduled_session_cancelled.text.erb new file mode 100644 index 000000000..e69de29bb diff --git a/ruby/lib/jam_ruby/app/views/jam_ruby/user_mailer/scheduled_session_comment.html.erb b/ruby/lib/jam_ruby/app/views/jam_ruby/user_mailer/scheduled_session_comment.html.erb new file mode 100644 index 000000000..e69de29bb diff --git a/ruby/lib/jam_ruby/app/views/jam_ruby/user_mailer/scheduled_session_comment.text.erb b/ruby/lib/jam_ruby/app/views/jam_ruby/user_mailer/scheduled_session_comment.text.erb new file mode 100644 index 000000000..e69de29bb diff --git a/ruby/lib/jam_ruby/app/views/jam_ruby/user_mailer/scheduled_session_invitation.html.erb b/ruby/lib/jam_ruby/app/views/jam_ruby/user_mailer/scheduled_session_invitation.html.erb new file mode 100644 index 000000000..e69de29bb diff --git a/ruby/lib/jam_ruby/app/views/jam_ruby/user_mailer/scheduled_session_invitation.text.erb b/ruby/lib/jam_ruby/app/views/jam_ruby/user_mailer/scheduled_session_invitation.text.erb new file mode 100644 index 000000000..e69de29bb diff --git a/ruby/lib/jam_ruby/app/views/jam_ruby/user_mailer/scheduled_session_reminder.html.erb b/ruby/lib/jam_ruby/app/views/jam_ruby/user_mailer/scheduled_session_reminder.html.erb new file mode 100644 index 000000000..e69de29bb diff --git a/ruby/lib/jam_ruby/app/views/jam_ruby/user_mailer/scheduled_session_reminder.text.erb b/ruby/lib/jam_ruby/app/views/jam_ruby/user_mailer/scheduled_session_reminder.text.erb new file mode 100644 index 000000000..e69de29bb diff --git a/ruby/lib/jam_ruby/app/views/jam_ruby/user_mailer/scheduled_session_rescheduled.html.erb b/ruby/lib/jam_ruby/app/views/jam_ruby/user_mailer/scheduled_session_rescheduled.html.erb new file mode 100644 index 000000000..e69de29bb diff --git a/ruby/lib/jam_ruby/app/views/jam_ruby/user_mailer/scheduled_session_rescheduled.text.erb b/ruby/lib/jam_ruby/app/views/jam_ruby/user_mailer/scheduled_session_rescheduled.text.erb new file mode 100644 index 000000000..e69de29bb diff --git a/ruby/lib/jam_ruby/app/views/jam_ruby/user_mailer/scheduled_session_rsvp.html.erb b/ruby/lib/jam_ruby/app/views/jam_ruby/user_mailer/scheduled_session_rsvp.html.erb new file mode 100644 index 000000000..e69de29bb diff --git a/ruby/lib/jam_ruby/app/views/jam_ruby/user_mailer/scheduled_session_rsvp.text.erb b/ruby/lib/jam_ruby/app/views/jam_ruby/user_mailer/scheduled_session_rsvp.text.erb new file mode 100644 index 000000000..e69de29bb diff --git a/ruby/lib/jam_ruby/app/views/jam_ruby/user_mailer/scheduled_session_rsvp_approved.html.erb b/ruby/lib/jam_ruby/app/views/jam_ruby/user_mailer/scheduled_session_rsvp_approved.html.erb new file mode 100644 index 000000000..e69de29bb diff --git a/ruby/lib/jam_ruby/app/views/jam_ruby/user_mailer/scheduled_session_rsvp_approved.text.erb b/ruby/lib/jam_ruby/app/views/jam_ruby/user_mailer/scheduled_session_rsvp_approved.text.erb new file mode 100644 index 000000000..e69de29bb diff --git a/ruby/lib/jam_ruby/app/views/jam_ruby/user_mailer/scheduled_session_rsvp_cancelled.html.erb b/ruby/lib/jam_ruby/app/views/jam_ruby/user_mailer/scheduled_session_rsvp_cancelled.html.erb new file mode 100644 index 000000000..e69de29bb diff --git a/ruby/lib/jam_ruby/app/views/jam_ruby/user_mailer/scheduled_session_rsvp_cancelled.text.erb b/ruby/lib/jam_ruby/app/views/jam_ruby/user_mailer/scheduled_session_rsvp_cancelled.text.erb new file mode 100644 index 000000000..e69de29bb diff --git a/ruby/lib/jam_ruby/app/views/jam_ruby/user_mailer/scheduled_session_rsvp_cancelled_org.html.erb b/ruby/lib/jam_ruby/app/views/jam_ruby/user_mailer/scheduled_session_rsvp_cancelled_org.html.erb new file mode 100644 index 000000000..e69de29bb diff --git a/ruby/lib/jam_ruby/app/views/jam_ruby/user_mailer/scheduled_session_rsvp_cancelled_org.text.erb b/ruby/lib/jam_ruby/app/views/jam_ruby/user_mailer/scheduled_session_rsvp_cancelled_org.text.erb new file mode 100644 index 000000000..e69de29bb diff --git a/ruby/lib/jam_ruby/message_factory.rb b/ruby/lib/jam_ruby/message_factory.rb index 784d5965a..626b5c776 100644 --- a/ruby/lib/jam_ruby/message_factory.rb +++ b/ruby/lib/jam_ruby/message_factory.rb @@ -452,20 +452,13 @@ module JamRuby ) end - # SCHEDULED_SESSION_RSVP = 175; - # SCHEDULED_SESSION_RSVP_APPROVED = 176; - # SCHEDULED_SESSION_RSVP_CANCELLED = 177; - # SCHEDULED_SESSION_RSVP_CANCELLED_ORG = 178; - # SCHEDULED_SESSION_CANCELLED = 179; - # SCHEDULED_SESSION_RESCHEDULED = 180; - # SCHEDULED_SESSION_REMINDER = 181; - # SCHEDULED_SESSION_COMMENT = 182; - - def scheduled_session_rsvp(receiver_id, session_id, photo_url, msg, slots, instruments, session_name, session_date, notification_id, created_at) + def scheduled_session_rsvp(receiver_id, session_id, photo_url, msg, user_id, instruments, session_name, session_date, notification_id, created_at) scheduled_session_rsvp = Jampb::ScheduledSessionRsvp.new( :session_id => session_id, :photo_url => photo_url, :msg => msg, + :user_id => user_id, + :instruments => instruments, :session_name => session_name, :session_date => session_date, :notification_id => notification_id, @@ -479,6 +472,134 @@ module JamRuby ) end + def scheduled_session_rsvp_approved(receiver_id, session_id, msg, session_name, session_date, notification_id, created_at) + + scheduled_session_rsvp_approved = Jampb::ScheduledSessionRsvpApproved.new( + :session_id => session_id, + :msg => msg, + :session_name => session_name, + :session_date => session_date, + :notification_id => notification_id, + :created_at => created_at + ) + + Jampb::ClientMessage.new( + :type => ClientMessage::Type::SCHEDULED_SESSION_RSVP_APPROVED, + :route_to => USER_TARGET_PREFIX + receiver_id, + :scheduled_session_rsvp_approved => scheduled_session_rsvp_approved + ) + end + + def scheduled_session_rsvp_cancelled(receiver_id, session_id, msg, session_name, session_date, notification_id, created_at) + + scheduled_session_rsvp_cancelled = Jampb::ScheduledSessionRsvpCancelled.new( + :session_id => session_id, + :msg => msg, + :session_name => session_name, + :session_date => session_date, + :notification_id => notification_id, + :created_at => created_at + ) + + Jampb::ClientMessage.new( + :type => ClientMessage::Type::SCHEDULED_SESSION_RSVP_CANCELLED, + :route_to => USER_TARGET_PREFIX + receiver_id, + :scheduled_session_rsvp_cancelled => scheduled_session_rsvp_cancelled + ) + end + + def scheduled_session_rsvp_cancelled_org(receiver_id, session_id, msg, session_name, session_date, notification_id, created_at) + + scheduled_session_rsvp_cancelled_org = Jampb::ScheduledSessionRsvpCancelledOrg.new( + :session_id => session_id, + :msg => msg, + :session_name => session_name, + :session_date => session_date, + :notification_id => notification_id, + :created_at => created_at + ) + + Jampb::ClientMessage.new( + :type => ClientMessage::Type::SCHEDULED_SESSION_RSVP_CANCELLED_ORG, + :route_to => USER_TARGET_PREFIX + receiver_id, + :scheduled_session_rsvp_cancelled_org => scheduled_session_rsvp_cancelled_org + ) + end + + def scheduled_session_cancelled(receiver_id, session_id, msg, session_name, session_date, notification_id, created_at) + + scheduled_session_cancelled = Jampb::ScheduledSessionCancelled.new( + :session_id => session_id, + :msg => msg, + :session_name => session_name, + :session_date => session_date, + :notification_id => notification_id, + :created_at => created_at + ) + + Jampb::ClientMessage.new( + :type => ClientMessage::Type::SCHEDULED_SESSION_CANCELLED, + :route_to => USER_TARGET_PREFIX + receiver_id, + :scheduled_session_cancelled => scheduled_session_cancelled + ) + end + + def scheduled_session_rescheduled(receiver_id, session_id, msg, session_name, session_date, notification_id, created_at) + + scheduled_session_rescheduled = Jampb::ScheduledSessionRescheduled.new( + :session_id => session_id, + :msg => msg, + :session_name => session_name, + :session_date => session_date, + :notification_id => notification_id, + :created_at => created_at + ) + + Jampb::ClientMessage.new( + :type => ClientMessage::Type::SCHEDULED_SESSION_RESCHEDULED, + :route_to => USER_TARGET_PREFIX + receiver_id, + :scheduled_session_rescheduled => scheduled_session_rescheduled + ) + end + + def scheduled_session_reminder(receiver_id, session_id, msg, session_name, session_date, notification_id, created_at) + + scheduled_session_reminder = Jampb::ScheduledSessionReminder.new( + :session_id => session_id, + :msg => msg, + :session_name => session_name, + :session_date => session_date, + :notification_id => notification_id, + :created_at => created_at + ) + + Jampb::ClientMessage.new( + :type => ClientMessage::Type::SCHEDULED_SESSION_REMINDER, + :route_to => USER_TARGET_PREFIX + receiver_id, + :scheduled_session_reminder => scheduled_session_reminder + ) + end + + def scheduled_session_comment(receiver_id, session_id, photo_url, msg, comment, session_name, session_date, notification_id, created_at) + + scheduled_session_comment = Jampb::ScheduledSessionComment.new( + :session_id => session_id, + :photo_url => photo_url, + :msg => msg, + :comment => comment, + :session_name => session_name, + :session_date => session_date, + :notification_id => notification_id, + :created_at => created_at + ) + + Jampb::ClientMessage.new( + :type => ClientMessage::Type::SCHEDULED_SESSION_COMMENT, + :route_to => USER_TARGET_PREFIX + receiver_id, + :scheduled_session_comment => scheduled_session_comment + ) + end + def band_session_join(receiver_id, session_id, photo_url, fan_access, musician_access, approval_required, msg, notification_id, created_at) band_session_join = Jampb::BandSessionJoin.new( :session_id => session_id, diff --git a/ruby/lib/jam_ruby/models/music_session.rb b/ruby/lib/jam_ruby/models/music_session.rb index 5f72ecc57..b25053f2a 100644 --- a/ruby/lib/jam_ruby/models/music_session.rb +++ b/ruby/lib/jam_ruby/models/music_session.rb @@ -39,7 +39,7 @@ module JamRuby validates :musician_access, :inclusion => {:in => [true, false]} validates :legal_terms, :inclusion => {:in => [true]}, :on => :create validates :creator, :presence => true - validates :recurring_mode, :inclusion => {:in => RECURRING_MODES}, :on => :create + # validates :recurring_mode, :inclusion => {:in => RECURRING_MODES}, :on => :create validate :creator_is_musician before_create :generate_share_token diff --git a/ruby/lib/jam_ruby/models/notification.rb b/ruby/lib/jam_ruby/models/notification.rb index 5de5bc2c6..71677e970 100644 --- a/ruby/lib/jam_ruby/models/notification.rb +++ b/ruby/lib/jam_ruby/models/notification.rb @@ -50,7 +50,11 @@ module JamRuby band = Band.find(self.band_id) end - self.class.format_msg(self.description, {:user => source_user, :band => band}) + unless self.session_id.nil? + session = MusicSession.find(self.session_id) + end + + self.class.format_msg(self.description, {:user => source_user, :band => band, :session => session}) end # TODO: MAKE ALL METHODS BELOW ASYNC SO THE CLIENT DOESN'T BLOCK ON NOTIFICATION LOGIC @@ -184,7 +188,7 @@ module JamRuby return "A musician has cancelled an RSVP to your session." when NotificationTypes::SCHEDULED_SESSION_RSVP_CANCELLED_ORG - return "The session organizer has cancelled this session." + return "The session organizer has cancelled this session:" when NotificationTypes::SCHEDULED_SESSION_CANCELLED return "The session organizer has cancelled this session:" @@ -573,19 +577,22 @@ module JamRuby end def send_scheduled_session_invitation(music_session, user) + target_user = user + source_user = music_session.creator + notification = Notification.new notification.description = NotificationTypes::SCHEDULED_SESSION_INVITATION - notification.source_user_id = music_session.creator.id - notification.target_user_id = user.id + notification.source_user_id = source_user.id + notification.target_user_id = target_user.id notification.session_id = music_session.id notification.save - notification_msg = format_msg(notification.description, {:user => music_session.creator, :session => music_session}) + notification_msg = format_msg(notification.description, {:user => source_user, :session => music_session}) msg = @@message_factory.scheduled_session_invitation( - user.id, + target_user.id, music_session.id, - music_session.creator.photo_url, + source_user.photo_url, notification_msg, music_session.description, music_session.scheduled_start, @@ -593,31 +600,235 @@ module JamRuby notification.created_date ) - @@mq_router.publish_to_user(user.id, msg) + @@mq_router.publish_to_user(target_user.id, msg) end - def send_scheduled_session_rsvp(music_session, user, rsvp_requests) + def send_scheduled_session_rsvp(music_session, user, instruments) + target_user = music_session.creator + source_user = user + + notification = Notification.new + notification.description = NotificationTypes::SCHEDULED_SESSION_RSVP + notification.source_user_id = source_user.id + notification.target_user_id = target_user.id + notification.session_id = music_session.id + notification.save + + notification_msg = format_msg(notification.description, {:user => source_user, :session => music_session}) + + msg = @@message_factory.scheduled_session_rsvp( + target_user.id, + music_session.id, + source_user.photo_url, + notification_msg, + source_user.id, + instruments, + music_session.description, + music_session.scheduled_start, + notification.id, + notification.created_date + ) + + @@mq_router.publish_to_user(target_user.id, msg) end - def send_scheduled_session_approved(email, msg) + def send_scheduled_session_rsvp_approved(music_session, user) + target_user = user + source_user = music_session.creator + + notification = Notification.new + notification.description = NotificationTypes::SCHEDULED_SESSION_RSVP_APPROVED + notification.source_user_id = source_user.id + notification.target_user_id = target_user.id + notification.session_id = music_session.id + notification.save + + notification_msg = format_msg(notification.description, {:session => music_session}) + + msg = @@message_factory.scheduled_session_rsvp_approved( + target_user.id, + music_session.id, + notification_msg, + music_session.description, + music_session.scheduled_start, + notification.id, + notification.created_date + ) + + @@mq_router.publish_to_user(target_user.id, msg) end - def send_scheduled_session_rsvp_cancelled(email, msg) + def send_scheduled_session_rsvp_cancelled(music_session, user) + target_user = music_session.creator + source_user = user + + notification = Notification.new + notification.description = NotificationTypes::SCHEDULED_SESSION_RSVP_CANCELLED + notification.source_user_id = source_user.id + notification.target_user_id = target_user.id + notification.session_id = music_session.id + notification.save + + notification_msg = format_msg(notification.description, {:session => music_session}) + + msg = @@message_factory.scheduled_session_rsvp_cancelled( + target_user.id, + music_session.id, + notification_msg, + music_session.description, + music_session.scheduled_start, + notification.id, + notification.created_date + ) + + @@mq_router.publish_to_user(target_user.id, msg) end - def send_scheduled_session_rsvp_cancelled_org(email, msg) + def send_scheduled_session_rsvp_cancelled_org(music_session, user) + target_user = user + source_user = music_session.creator + + notification = Notification.new + notification.description = NotificationTypes::SCHEDULED_SESSION_RSVP_CANCELLED_ORG + notification.source_user_id = source_user.id + notification.target_user_id = target_user.id + notification.session_id = music_session.id + notification.save + + notification_msg = format_msg(notification.description, {:session => music_session}) + + msg = @@message_factory.scheduled_session_rsvp_cancelled_org( + target_user.id, + music_session.id, + notification_msg, + music_session.description, + music_session.scheduled_start, + notification.id, + notification.created_date + ) + + @@mq_router.publish_to_user(target_user.id, msg) end - def send_scheduled_session_cancelled(email, msg) + def send_scheduled_session_cancelled(music_session) + rsvp_requests = RsvpRequest.requests_by_session(music_session) + + rsvp_requests.each do |rsvp| + target_user = rsvp.user + source_user = music_session.creator + + notification = Notification.new + notification.description = NotificationTypes::SCHEDULED_SESSION_CANCELLED + notification.source_user_id = source_user.id + notification.target_user_id = target_user.id + notification.session_id = music_session.id + notification.save + + notification_msg = format_msg(notification.description, {:session => music_session}) + + msg = @@message_factory.scheduled_session_cancelled( + target_user.id, + music_session.id, + notification_msg, + music_session.description, + music_session.scheduled_start, + notification.id, + notification.created_date + ) + + @@mq_router.publish_to_user(target_user.id, msg) + end end - def send_scheduled_session_rescheduled(email, msg) + def send_scheduled_session_rescheduled(music_session) + rsvp_requests = RsvpRequest.requests_by_session(music_session) + + rsvp_requests.each do |rsvp| + target_user = rsvp.user + source_user = music_session.creator + + notification = Notification.new + notification.description = NotificationTypes::SCHEDULED_SESSION_RESCHEDULED + notification.source_user_id = source_user.id + notification.target_user_id = target_user.id + notification.session_id = music_session.id + notification.save + + notification_msg = format_msg(notification.description, {:session => music_session}) + + msg = @@message_factory.scheduled_session_rescheduled( + target_user.id, + music_session.id, + notification_msg, + music_session.description, + music_session.scheduled_start, + notification.id, + notification.created_date + ) + + @@mq_router.publish_to_user(target_user.id, msg) + end end - def send_scheduled_session_reminder(email, msg) + def send_scheduled_session_reminder(music_session) + rsvp_requests = RsvpRequest.requests_by_session(music_session) + + rsvp_requests.each do |rsvp| + target_user = rsvp.user + source_user = music_session.creator + + notification = Notification.new + notification.description = NotificationTypes::SCHEDULED_SESSION_REMINDER + notification.source_user_id = source_user.id + notification.target_user_id = target_user.id + notification.session_id = music_session.id + notification.save + + notification_msg = format_msg(notification.description, {:session => music_session}) + + msg = @@message_factory.scheduled_session_reminder( + target_user.id, + music_session.id, + notification_msg, + music_session.description, + music_session.scheduled_start, + notification.id, + notification.created_date + ) + + @@mq_router.publish_to_user(target_user.id, msg) + end end - def send_scheduled_session_comment(email, msg) + def send_scheduled_session_comment(music_session, comment) + rsvp_requests = RsvpRequest.requests_by_session(music_session) + + rsvp_requests.each do |rsvp| + target_user = rsvp.user + source_user = music_session.creator + + notification = Notification.new + notification.description = NotificationTypes::SCHEDULED_SESSION_CANCELLED + notification.source_user_id = source_user.id + notification.target_user_id = target_user.id + notification.session_id = music_session.id + notification.save + + notification_msg = format_msg(notification.description, {:session => music_session}) + + msg = @@message_factory.scheduled_session_comment( + target_user.id, + music_session.id, + notification_msg, + comment, + music_session.description, + music_session.scheduled_start, + notification.id, + notification.created_date + ) + + @@mq_router.publish_to_user(target_user.id, msg) + end end def send_band_session_join(music_session, band) diff --git a/ruby/lib/jam_ruby/models/rsvp_request.rb b/ruby/lib/jam_ruby/models/rsvp_request.rb index 28ca90401..9b7e917c0 100644 --- a/ruby/lib/jam_ruby/models/rsvp_request.rb +++ b/ruby/lib/jam_ruby/models/rsvp_request.rb @@ -9,6 +9,26 @@ module JamRuby validates :canceled, :inclusion => {:in => [nil, true, false]} validates :rsvp_slot, presence: true + def self.requests_by_session(session, user = nil) + query = RsvpRequest + .includes(:user) + .joins( + %Q{ + INNER join + rsvp_slots rs + ON + rsvp_requests.rsvp_slot_id = rs.id + } + ) + .where( + %Q{ + rsvp_slots.music_session_id = '#{session.id}'' + } + ) + + query = query.where("rsvp_requests.user_id = '#{user.id}'") unless user.nil? + return query + end # XXX we need to validate that only one RsvpRequest.chosen = true for a given RsvpSlot # in other words, you can have many requests to a slot, but only 0 or 1 rsvp_request.chosen = true) diff --git a/web/app/assets/javascripts/jam_rest.js b/web/app/assets/javascripts/jam_rest.js index 3334d5c38..b386447c3 100644 --- a/web/app/assets/javascripts/jam_rest.js +++ b/web/app/assets/javascripts/jam_rest.js @@ -41,7 +41,8 @@ contentType: 'application/json', url: "/api/sessions/legacy", processData:false, - data: JSON.stringify(options)}); + data: JSON.stringify(options) + }); } function legacyJoinSession(options) { diff --git a/web/app/assets/javascripts/layout.js b/web/app/assets/javascripts/layout.js index ebc4990af..a20180d78 100644 --- a/web/app/assets/javascripts/layout.js +++ b/web/app/assets/javascripts/layout.js @@ -768,7 +768,7 @@ text: "OKAY", "layout-action": "close", href: "#", - css: "button-orange" + "class": "button-orange" }; var cancelButton = { @@ -776,7 +776,7 @@ text: "CANCEL", "layout-action": "close", href: "#", - css: "button-grey" + "class": "button-grey" }; var defaultButtons = [ @@ -861,14 +861,27 @@ $buttonDiv.empty(); $.each(buttons, function(index, val) { - $buttonDiv.append('' + val.text + '  ') + + // build button HTML based on KV pairs + var keys = Object.keys(val); + var buttonHtml = '  '; + $buttonDiv.append(buttonHtml); // ensure it doesn't fire twice $('#' + val.id, $notify).unbind('click'); $('#' + val.id, $notify).click(function() { - console.log($(this).attr('class')); - console.log("handling click"); if (val.callback !== undefined) { if (val.callback_args) { val.callback(val.callback_args); diff --git a/web/app/assets/javascripts/notificationPanel.js b/web/app/assets/javascripts/notificationPanel.js index 49f42b98e..d136a583d 100644 --- a/web/app/assets/javascripts/notificationPanel.js +++ b/web/app/assets/javascripts/notificationPanel.js @@ -428,7 +428,7 @@ text: "JOIN SESSION", "layout-action": "close", href: "#", - css: "button-orange", + "class": "button-orange", callback: openTerms, callback_args: { "session_id": payload.session_id, @@ -469,7 +469,7 @@ text: "APPROVE", "layout-action": "close", href: "#", - css: "button-orange", + "class": "button-orange", callback: approveJoinRequest, callback_args: { "join_request_id": payload.join_request_id, @@ -481,7 +481,7 @@ text: "REJECT", "layout-action": "close", href: "#", - css: "button-grey", + "class": "button-grey", callback: rejectJoinRequest, callback_args: { "join_request_id": payload.join_request_id, @@ -556,7 +556,7 @@ text: "ACCEPT", "layout-action": "close", href: "#", - css: "button-orange", + "class": "button-orange", callback: acceptFriendRequest, callback_args: { "friend_request_id": payload.friend_request_id, @@ -623,7 +623,7 @@ text: "JOIN SESSION", "layout-action": "close", href: "#", - css: "button-orange", + "class": "button-orange", callback: openTerms, callback_args: { "session_id": payload.session_id, @@ -679,7 +679,7 @@ text: okText, "layout-action": "close", href: "#", - css: "button-orange", + "class": "button-orange", callback: callback, callback_args: { "session_id": payload.session_id, @@ -737,7 +737,7 @@ text: okText, "layout-action": "close", href: "#", - css: "button-orange", + "class": "button-orange", callback: callback, callback_args: { "session_id": payload.session_id, @@ -763,7 +763,15 @@ "title": "Session Invitation", "text": payload.msg, "icon_url": context.JK.resolveAvatarUrl(payload.photo_url) - }); + }, [{ + id: "btn-more-info", + text: "More Info", + "layout-action": "close", + href: JK.root_url + "/sessions/" + payload.session_id + "/details", + rel: "external", + "class": "button-orange" + }] + ); }); } @@ -775,10 +783,18 @@ handleNotification(payload, header.type); app.notify({ - "title": "Session Invitation", + "title": "Session RSVP", "text": payload.msg, "icon_url": context.JK.resolveAvatarUrl(payload.photo_url) - }); + }, [{ + id: "btn-view-profile", + text: "View Profile", + "layout-action": "close", + href: JK.root_url + "/client#/profile/" + payload.user_id, + rel: "external", + "class": "button-orange" + }] + ); }); } @@ -789,10 +805,18 @@ handleNotification(payload, header.type); app.notify({ - "title": "Session Invitation", + "title": "Session RSVP Approved!", "text": payload.msg, "icon_url": context.JK.resolveAvatarUrl(payload.photo_url) - }); + }, [{ + id: "btn-session-details", + text: "Session Details", + "layout-action": "close", + href: JK.root_url + "/sessions/" + payload.session_id + "/details", + rel: "external", + "class": "button-orange" + }] + ); }); } @@ -803,10 +827,18 @@ handleNotification(payload, header.type); app.notify({ - "title": "Session Invitation", + "title": "Session RSVP Cancelled", "text": payload.msg, "icon_url": context.JK.resolveAvatarUrl(payload.photo_url) - }); + }, [{ + id: "btn-session-details", + text: "Session Details", + "layout-action": "close", + href: JK.root_url + "/sessions/" + payload.session_id + "/details", + rel: "external", + "class": "button-orange" + }] + ); }); } @@ -817,10 +849,18 @@ handleNotification(payload, header.type); app.notify({ - "title": "Session Invitation", + "title": "Session RSVP Cancelled", "text": payload.msg, "icon_url": context.JK.resolveAvatarUrl(payload.photo_url) - }); + }, [{ + id: "btn-session-details", + text: "Session Details", + "layout-action": "close", + href: JK.root_url + "/sessions/" + payload.session_id + "/details", + rel: "external", + "class": "button-orange" + }] + ); }); } @@ -831,10 +871,18 @@ handleNotification(payload, header.type); app.notify({ - "title": "Session Invitation", + "title": "Session Cancelled", "text": payload.msg, "icon_url": context.JK.resolveAvatarUrl(payload.photo_url) - }); + }, [{ + id: "btn-session-details", + text: "Session Details", + "layout-action": "close", + href: JK.root_url + "/sessions/" + payload.session_id + "/details", + rel: "external", + "class": "button-orange" + }] + ); }); } @@ -845,10 +893,18 @@ handleNotification(payload, header.type); app.notify({ - "title": "Session Invitation", + "title": "Session Rescheduled", "text": payload.msg, "icon_url": context.JK.resolveAvatarUrl(payload.photo_url) - }); + }, [{ + id: "btn-session-details", + text: "Session Details", + "layout-action": "close", + href: JK.root_url + "/sessions/" + payload.session_id + "/details", + rel: "external", + "class": "button-orange" + }] + ); }); } @@ -859,10 +915,18 @@ handleNotification(payload, header.type); app.notify({ - "title": "Session Invitation", + "title": "Session Reminder", "text": payload.msg, "icon_url": context.JK.resolveAvatarUrl(payload.photo_url) - }); + }, [{ + id: "btn-session-details", + text: "Session Details", + "layout-action": "close", + href: JK.root_url + "/sessions/" + payload.session_id + "/details", + rel: "external", + "class": "button-orange" + }] + ); }); } @@ -874,10 +938,18 @@ handleNotification(payload, header.type); app.notify({ - "title": "Session Invitation", + "title": "Session Comment", "text": payload.msg, "icon_url": context.JK.resolveAvatarUrl(payload.photo_url) - }); + }, [{ + id: "btn-session-details", + text: "Session Details", + "layout-action": "close", + href: JK.root_url + "/sessions/" + payload.session_id + "/details", + rel: "external", + "class": "button-orange" + }] + ); }); } @@ -897,7 +969,7 @@ text: "LISTEN", "layout-action": "close", href: "#", - css: "button-orange", + "class": "button-orange", callback: listenToRecording, callback_args: { "recording_id": payload.recording_id, @@ -923,7 +995,7 @@ text: "LISTEN", "layout-action": "close", href: "#", - css: "button-orange", + "class": "button-orange", callback: listenToRecording, callback_args: { "recording_id": payload.recording_id, @@ -950,7 +1022,7 @@ text: "SHARE", "layout-action": "close", href: "#", - css: "button-orange", + "class": "button-orange", callback: shareRecording, callback_args: { "recording_id": payload.recording_id @@ -979,7 +1051,7 @@ text: "ACCEPT", "layout-action": "close", href: "#", - css: "button-orange", + "class": "button-orange", callback: acceptBandInvitation, callback_args: { "band_invitation_id": payload.band_invitation_id, diff --git a/web/app/controllers/music_sessions_controller.rb b/web/app/controllers/music_sessions_controller.rb index d25749826..8e14e995a 100644 --- a/web/app/controllers/music_sessions_controller.rb +++ b/web/app/controllers/music_sessions_controller.rb @@ -7,4 +7,7 @@ class MusicSessionsController < ApplicationController render :layout => "web" end + def show_scheduled_session_info + end + end diff --git a/web/config/routes.rb b/web/config/routes.rb index a597d0bec..8842a6303 100644 --- a/web/config/routes.rb +++ b/web/config/routes.rb @@ -26,6 +26,7 @@ SampleApp::Application.routes.draw do match '/auth/failure', :to => 'sessions#failure' # session / recording landing pages + match '/sessions/:id/details' => 'music_sessions#show_scheduled_session_info', :via => :get, :as => 'music_scheduled_session_detail' match '/sessions/:id' => 'music_sessions#show', :via => :get, :as => 'music_session_detail' match '/recordings/:id' => 'recordings#show', :via => :get, :as => 'recording_detail'