From b4151c27e999bcd5da8f9b056644df32cfa4b76a Mon Sep 17 00:00:00 2001 From: Brian Smith Date: Thu, 19 Jun 2014 00:21:34 -0400 Subject: [PATCH] VRFS-1669 VRFS-1672 session settings dialog / find session work --- db/manifest | 3 +- db/up/rsvp_slots_prof_level.sql | 1 + ruby/lib/jam_ruby/models/rsvp_slot.rb | 10 ++- web/app/assets/javascripts/findSession.js | 70 ++++++++++++++----- web/app/assets/javascripts/jam_rest.js | 14 ++++ .../assets/stylesheets/client/dialog.css.scss | 2 +- .../api_music_sessions/show_history.rabl | 5 +- web/app/views/clients/_findSession.html.erb | 4 ++ .../views/clients/_sessionSettings.html.haml | 4 +- .../music_sessions/session_info.html.haml | 3 + web/config/routes.rb | 2 +- 11 files changed, 94 insertions(+), 24 deletions(-) create mode 100644 db/up/rsvp_slots_prof_level.sql diff --git a/db/manifest b/db/manifest index db2adf057..8b4c6e74c 100755 --- a/db/manifest +++ b/db/manifest @@ -176,4 +176,5 @@ ams_index.sql update_ams_index.sql update_ams_index_2.sql sms_index.sql -music_sessions_description_search.sql \ No newline at end of file +music_sessions_description_search.sql +rsvp_slots_prof_level.sql diff --git a/db/up/rsvp_slots_prof_level.sql b/db/up/rsvp_slots_prof_level.sql new file mode 100644 index 000000000..8c9e19874 --- /dev/null +++ b/db/up/rsvp_slots_prof_level.sql @@ -0,0 +1 @@ +alter table rsvp_slots alter column proficiency_level type smallint using proficiency_level::smallint; \ No newline at end of file diff --git a/ruby/lib/jam_ruby/models/rsvp_slot.rb b/ruby/lib/jam_ruby/models/rsvp_slot.rb index 3f92833ee..7d7a1d06d 100644 --- a/ruby/lib/jam_ruby/models/rsvp_slot.rb +++ b/ruby/lib/jam_ruby/models/rsvp_slot.rb @@ -6,7 +6,11 @@ module JamRuby has_many :rsvp_requests_rsvp_slots, :class_name => "JamRuby::RsvpRequestRsvpSlot", :foreign_key => "rsvp_slot_id" has_many :rsvp_requests, :class_name => "JamRuby::RsvpRequest", :through => :rsvp_requests_rsvp_slots - attr_accessor :chosen + attr_accessor :chosen, :proficiency_desc + + class << self + @@proficiency_map = ["Beg", "Beg/Int", "Int", "Int/Adv", "Adv"] + end # TODO: validates :proficiency_level @@ -19,6 +23,10 @@ module JamRuby !chosen_slots.blank? end + def proficiency_desc + @@proficiency_map[self.proficiency_level - 1] + end + # def has_rsvp_from_user(user) # user_slot = RsvpRequest.joins(:rsvp_requests_rsvp_slots) # .where(:rsvp_request_id => ) diff --git a/web/app/assets/javascripts/findSession.js b/web/app/assets/javascripts/findSession.js index c6f40ffab..3c31d585a 100644 --- a/web/app/assets/javascripts/findSession.js +++ b/web/app/assets/javascripts/findSession.js @@ -9,6 +9,8 @@ SCHEDULED: {index: 1, id: "table#sessions-scheduled"} }; + var $dateFilter = $("#session-date-filter"); + var logger = context.JK.logger; var rest = context.JK.Rest(); var sessionLatency; @@ -46,33 +48,38 @@ function loadSessionsOriginal() { addSpinner(); - rest.findSessions(currentQuery) + rest.findActiveSessions(currentQuery) + .done(afterLoadSessions) + .fail(app.ajaxError) + .always(removeSpinner) + + rest.findInactiveSessions(currentQuery) .done(afterLoadSessions) .fail(app.ajaxError) .always(removeSpinner) } - function loadSessionsNew() { + // function loadSessionsNew() { - addSpinner(); + // addSpinner(); - rest.findScoredSessions(app.clientId, currentQuery) - .done(function(response) { afterLoadScoredSessions(response); }) - .always(function(){ removeSpinner(); }) - .fail(app.ajaxError) - } + // rest.findScoredSessions(app.clientId, currentQuery) + // .done(function(response) { afterLoadScoredSessions(response); }) + // .always(function(){ removeSpinner(); }) + // .fail(app.ajaxError) + // } - function loadSessions() { + // function loadSessions() { - if (gon.use_cached_session_scores) { - loadSessionsNew(); - } - else { - loadSessionsOriginal(); - } + // if (gon.use_cached_session_scores) { + // loadSessionsNew(); + // } + // else { + // loadSessionsOriginal(); + // } - } + // } function buildQuery() { currentQuery = defaultQuery(); @@ -174,7 +181,8 @@ $noMoreSessions.show(); } - }else { + } + else { currentPage++; buildQuery(); registerInfiniteScroll(); @@ -443,9 +451,37 @@ $next = $('#findSession .btn-next') $scroller = $('#findSession .content-body-scroller'); $noMoreSessions = $('#end-of-session-list'); + + $dateFilter.datepicker({ + dateFormat: "D d MM yy", + onSelect: toggleDate + } + ); + events(); } + function toggleDate() { + var selectedDate = new Date($dateFilter.val()); + var currentDate = new Date(); + var startIndex = 0; + + if (currentDate.getYear() == selectedDate.getYear() && + currentDate.getMonth() == selectedDate.getMonth() && + currentDate.getDate() == selectedDate.getDate()) { + + var timeString = getFormattedTime(currentDate, true); + startIndex = defaultTimeArray.indexOf(timeString); + } + + // var $startTimeList = $('#start-time-list'); + // $startTimeList.empty(); + // for (var i = startIndex; i < defaultTimeArray.length; i++) { + // var strTime = defaultTimeArray[i]; + // $startTimeList.append($('')); + // } + } + this.initialize = initialize; this.renderSession = renderSession; this.afterShow = afterShow; diff --git a/web/app/assets/javascripts/jam_rest.js b/web/app/assets/javascripts/jam_rest.js index d766a898c..583d7b1ba 100644 --- a/web/app/assets/javascripts/jam_rest.js +++ b/web/app/assets/javascripts/jam_rest.js @@ -118,6 +118,20 @@ }); } + function findActiveSessions(query) { + return $.ajax({ + type: "GET", + url: "/api/sessions/active?" + $.param(query) + }); + } + + function findInactiveSessions(query) { + return $.ajax({ + type: "GET", + url: "/api/sessions/inactive?" + $.param(query) + }); + } + function findScheduledSessions(query) { return $.ajax({ type: "GET", diff --git a/web/app/assets/stylesheets/client/dialog.css.scss b/web/app/assets/stylesheets/client/dialog.css.scss index c7882be42..fa4c12d1a 100644 --- a/web/app/assets/stylesheets/client/dialog.css.scss +++ b/web/app/assets/stylesheets/client/dialog.css.scss @@ -6,7 +6,7 @@ border: 1px solid $ColorScreenPrimary; color:#fff; min-width: 400px; - min-height: 350px; + min-height: 450px; z-index: 100; h2 { diff --git a/web/app/views/api_music_sessions/show_history.rabl b/web/app/views/api_music_sessions/show_history.rabl index 2fa6836ff..274ca4e51 100644 --- a/web/app/views/api_music_sessions/show_history.rabl +++ b/web/app/views/api_music_sessions/show_history.rabl @@ -79,12 +79,15 @@ else } child({:approved_rsvps => :approved_rsvps}) { - attributes :id, :photo_url, :first_name, :last_name, :instrument_id + attributes :id, :photo_url, :first_name, :last_name, :instrument_list node do |user| { latency: user_score(user.id) } end + } + child({:open_slots => :open_slots}) { + attributes :id, :instrument_id, :proficiency_level, :proficiency_desc :music_session_id } child(:active_music_session => :active_music_session) { diff --git a/web/app/views/clients/_findSession.html.erb b/web/app/views/clients/_findSession.html.erb index 467852aaa..b24066255 100644 --- a/web/app/views/clients/_findSession.html.erb +++ b/web/app/views/clients/_findSession.html.erb @@ -22,6 +22,10 @@ <%= render "genreSelector" %> +
+ +
+