diff --git a/app/assets/javascripts/createSession.js b/app/assets/javascripts/createSession.js
index 9f69ea374..2575eac43 100644
--- a/app/assets/javascripts/createSession.js
+++ b/app/assets/javascripts/createSession.js
@@ -107,6 +107,7 @@
processData:false,
data: jsonData,
success: function(response) {
+ resetForm();
var newSessionId = response.id;
createInvitations(newSessionId, function() {
context.location = '#/session/' + newSessionId;
diff --git a/app/assets/javascripts/findSession.js b/app/assets/javascripts/findSession.js
index cda11bbe1..df7840cd4 100644
--- a/app/assets/javascripts/findSession.js
+++ b/app/assets/javascripts/findSession.js
@@ -37,6 +37,49 @@
});
}
+ function search() {
+ clearResults();
+ var queryString = '';
+
+ // musician filter
+ var musicians = getSelectedMusicians();
+ if (musicians != null && musicians.length > 0) {
+ queryString += "participants=" + musicians.join(',');
+ }
+
+ // genre filter
+ var genres = genreSelector.getSelectedGenres();
+ if (genres != null && genres.length > 0) {
+ if (queryString.length > 0) {
+ queryString += "&";
+ }
+
+ queryString += "genres=" + genres.join(',');
+ }
+
+ // TODO: keyword filter
+
+ if (queryString.length > 0) {
+ $.ajax({
+ type: "GET",
+ url: "/api/sessions?" + queryString,
+ success: startSessionLatencyChecks
+ });
+ }
+ else {
+ loadSessions();
+ }
+ }
+
+ function getSelectedMusicians() {
+ var selectedMusicians = [];
+ $('#musician-list-items :checked').each(function() {
+ selectedMusicians.push($(this).val());
+ });
+
+ return selectedMusicians;
+ }
+
function startSessionLatencyChecks(response) {
sessionLatency.subscribe(app.clientId, latencyResponse);
$.each(response, function(index, session) {
@@ -66,9 +109,9 @@
}
function containsFriend(session) {
- var i, p, participant = null;
+ var i, participant = null;
- for (i=0, p=session.participants.length; i < p; i++) {
+ for (i=0; i < session.participants.length; i++) {
participant = session.participants[i];
// this session participant is a friend
//alert(participant.user.name);
@@ -98,7 +141,6 @@
* sortScore in sessionLatency.
*/
function renderSession(sessionId) {
-
var session = null;
var $tbGroup;
@@ -119,7 +161,33 @@
return;
}
- sessionList.renderSession(session, sessionLatency, $tbGroup, $('#template-session-row').html(), $('#template-musician-info').html());
+ var row = sessionList.renderSession(session, sessionLatency, $tbGroup, $('#template-session-row').html(), $('#template-musician-info').html(),
+ // populate the musician filter with musicians that haven't already been added
+ function(musicianArray) {
+ var template = $('#template-musician-filter').html();
+ $.each(musicianArray, function(index, val) {
+ // check if this musician is already in the filter
+ if ( $('#musician-list-items input[value=' + val.id + ']').length == 0 ) {
+ var musicianOptionHtml = context.JK.fillTemplate(template, {value: val.id, label: val.name});
+ $('#musician-list-items').append(musicianOptionHtml);
+ }
+ });
+ });
+ }
+
+ // TODO: refactor this and GenreSelector into common code
+ function toggleMusicianBox() {
+ var boxHeight = $('#musician-list').css("height");
+ // TODO: clean this up (check class name of arrow to determine current state)
+ if (boxHeight == "20px") {
+ $('#musician-list').css({height: "auto"});
+ $('#musician-list-arrow').removeClass("arrow-down").addClass("arrow-up");
+
+ }
+ else {
+ $('#musician-list').css({height: "20px"});
+ $('#musician-list-arrow').removeClass("arrow-up").addClass("arrow-down");
+ }
}
function afterShow(data) {
@@ -128,14 +196,9 @@
}
function clearResults() {
- var $tb = $(CATEGORY.INVITATION.id);
- $tb.children( 'tr:not(:first)' ).remove();
-
- $tb = $(CATEGORY.FRIENDS.id);
- $tb.children( 'tr:not(:first)' ).remove();
-
- $tb = $(CATEGORY.OTHER.id);
- $tb.children( 'tr:not(:first)' ).remove();
+ $('#sessions-invitations').children(':not(:first-child)').remove();
+ $('#sessions-friends').children(':not(:first-child)').remove();
+ $('#sessions-other').children(':not(:first-child)').remove();
}
function deleteSession(evt) {
@@ -150,6 +213,9 @@
function events() {
//$('#findSession-tableBody').on("click", '[action="delete"]', deleteSession);
+ $('#musician-list-header').on("click", toggleMusicianBox);
+ $('#musician-list-arrow').on("click", toggleMusicianBox);
+ $('#btn-refresh').on("click", search);
}
/**
diff --git a/app/assets/javascripts/genreSelector.js b/app/assets/javascripts/genreSelector.js
index 6bfe6656c..66690b92d 100644
--- a/app/assets/javascripts/genreSelector.js
+++ b/app/assets/javascripts/genreSelector.js
@@ -26,6 +26,7 @@
function reset() {
$('#genre-list-items input[type=checkbox]', _form).removeAttr('checked');
$('#genre-list-items input[type=checkbox]', _form).removeAttr('disabled');
+ $('#genre-count', _form).val('0');
}
function genresLoaded(response) {
diff --git a/app/assets/javascripts/sessionList.js b/app/assets/javascripts/sessionList.js
index 67ddaaa0f..8976b869c 100644
--- a/app/assets/javascripts/sessionList.js
+++ b/app/assets/javascripts/sessionList.js
@@ -15,6 +15,32 @@
MUSICIANS_ONLY:"Musicians Only"
};
+ var instrument_logos = { "accordion": '',
+ "acoustic guitar": '',
+ "banjo": '',
+ "bass guitar": '',
+ "cello": '',
+ "clarinet": '',
+ "computer": '',
+ "drums": '',
+ "electric guitar": '../assets/content/icon_instrument_guitar24.png',
+ "euphonium": '',
+ "flute": '',
+ "french horn": '',
+ "harmonica": '',
+ "keyboard": '../assets/content/icon_instrument_keyboard24.png',
+ "mandolin": '',
+ "oboe": '',
+ "saxophone": '',
+ "trombone": '',
+ "trumpet": '',
+ "tuba": '',
+ "ukulele": '',
+ "viola": '',
+ "violin": '',
+ "voice": '../assets/content/icon_instrument_vocal24.png'
+ }
+
var _logger = context.JK.logger;
var _sessionLatency;
@@ -23,7 +49,7 @@
* It will be inserted at the appropriate place according to the
* sortScore in sessionLatency.
*/
- function renderSession(session, sessionLatency, tbGroup, rowTemplate, musicianTemplate) {
+ function renderSession(session, sessionLatency, tbGroup, rowTemplate, musicianTemplate, onMusiciansComplete) {
// latency
var latencyInfo = sessionLatency.sessionInfo(session.id);
var latencyDescription = "";
@@ -48,36 +74,41 @@
audience = AUDIENCE.MUSICIANS_ONLY;
}
- var i, p, participant = null;
+ var i, participant = null;
var musicians = '';
- for (i=0, p=session.participants.length; i < p; i++) {
+ var musicianArray = [];
+ for (i=0; i < session.participants.length; i++) {
participant = session.participants[i];
var instrumentLogoHtml = '';
var j;
+
+ // loop through the tracks to get the instruments
for (j=0; j < participant.tracks.length; j++) {
var track = participant.tracks[j];
- instrumentLogoHtml += ' ';
+ instrumentLogoHtml += '
';
}
+ var id = participant.user.id;
+ var name = participant.user.name;
var musicianVals = {
avatar_url: participant.user.photo_url,
- profile_url: "users/" + participant.user.id,
- musician_name: participant.user.name,
+ profile_url: "users/" + id,
+ musician_name: name,
instruments: instrumentLogoHtml
}
- /*
-