VRFS-1669 VRFS-1672 session settings dialog / find session work

This commit is contained in:
Brian Smith 2014-06-19 00:21:34 -04:00
parent 74d5053a8a
commit b4151c27e9
11 changed files with 94 additions and 24 deletions

View File

@ -176,4 +176,5 @@ ams_index.sql
update_ams_index.sql
update_ams_index_2.sql
sms_index.sql
music_sessions_description_search.sql
music_sessions_description_search.sql
rsvp_slots_prof_level.sql

View File

@ -0,0 +1 @@
alter table rsvp_slots alter column proficiency_level type smallint using proficiency_level::smallint;

View File

@ -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 => )

View File

@ -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($('<option value="' + strTime + '" class="label">' + strTime +'</option>'));
// }
}
this.initialize = initialize;
this.renderSession = renderSession;
this.afterShow = afterShow;

View File

@ -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",

View File

@ -6,7 +6,7 @@
border: 1px solid $ColorScreenPrimary;
color:#fff;
min-width: 400px;
min-height: 350px;
min-height: 450px;
z-index: 100;
h2 {

View File

@ -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) {

View File

@ -22,6 +22,10 @@
<%= render "genreSelector" %>
</div>
<div class="right ib w85 h40">
<input type="text" id="session-date-filter">
</div>
<!-- keyword filter -->
<div class="search-box" style="height:25px;">
<input id="session-keyword-srch" type="text" name="search" placeholder="Search by Keyword" />

View File

@ -20,7 +20,7 @@
.clearall.left.w25.ib.mb10
Name:
.right.w75.ib.mb10
%input{:type => 'text', :name => 'session_name'}
%input{:type => 'text', :name => 'name'}
.clearall.left.w25.ib.mb10
Description:
@ -52,7 +52,7 @@
.right.w75.ib.mb10
List of existing notation files goes here
.clearall.right
.clearall.right.mt10
%a.button-orange{:href => 'TBD', :rel => 'external'} HELP
%a.button-grey{'layout-action' => "close"} CANCEL
%a.button-orange{:id => "session-settings-dialog-submit", :href => "#"} UPDATE SETTINGS

View File

@ -70,6 +70,8 @@
.left.w65.ib
%strong RSVPs
.right.w30.ib.f11.center Your latency
- if @approved_rsvps.blank?
None
- @approved_rsvps.each_with_index do |rsvp, index|
.clearall.left.w65.h20.ib.mb10.rsvp-details
.avatar-tiny{'hoveraction' => "musician", 'user-id' => rsvp.id}
@ -97,6 +99,7 @@
%img.instrument-icon{'instrument-id' => slot.instrument_id, height:24, width:24}
.f11.ml10.ib.h20
= slot.instrument_id.capitalize
= "(#{slot.proficiency_desc})"
%br{:clear => "all"}/

View File

@ -154,7 +154,7 @@ SampleApp::Application.routes.draw do
match '/sessions/scheduled' => 'api_music_sessions#scheduled', :via => :get
match '/sessions/legacy' => 'api_music_sessions#create_legacy', :via => :post
match '/sessions/active' => 'api_music_sessions#ams_index', :via => :get
match '/sessions/nonactive' => 'api_music_sessions#sms_index', :via => :get
match '/sessions/inactive' => 'api_music_sessions#sms_index', :via => :get
match '/sessions/:id' => 'api_music_sessions#show', :via => :get, :as => 'api_session_detail'
match '/sessions/:id' => 'api_music_sessions#update', :via => :put
match '/sessions/:id' => 'api_music_sessions#session_update', :via => :post