added keyword search to find session

This commit is contained in:
Brian Smith 2013-02-02 18:53:57 -05:00
parent 9375c036f5
commit 8ce893c8b3
4 changed files with 22 additions and 5 deletions

View File

@ -57,7 +57,15 @@
queryString += "genres=" + genres.join(',');
}
// TODO: keyword filter
// keyword filter
var keyword = $('#session-keyword-srch').val();
if (keyword != null && keyword.length > 0) {
if (queryString.length > 0) {
queryString += "&";
}
queryString += "keyword=" + $('#session-keyword-srch').val();
}
if (queryString.length > 0) {
$.ajax({
@ -219,6 +227,15 @@
//$('#findSession-tableBody').on("click", '[action="delete"]', deleteSession);
$('#musician-list-header').on("click", toggleMusicianBox);
$('#musician-list-arrow').on("click", toggleMusicianBox);
$('#session-keyword-srch').focus(function() {
$(this).val('');
});
// $('#session-keyword-srch').blur(function() {
// $(this).val('Search by Keyword');
// });
$('#btn-refresh').on("click", search);
}

View File

@ -15,7 +15,7 @@
MUSICIANS_ONLY:"Musicians Only"
};
var instrument_logos = { "accordion": '',
var instrument_logo_map = { "accordion": '',
"acoustic guitar": '',
"banjo": '',
"bass guitar": '',
@ -86,7 +86,7 @@
// loop through the tracks to get the instruments
for (j=0; j < participant.tracks.length; j++) {
var track = participant.tracks[j];
instrumentLogoHtml += '<img src="' + instrument_logos[track.instrument_id] + '" width="24" height="24" />&nbsp;';
instrumentLogoHtml += '<img src="' + instrument_logo_map[track.instrument_id] + '" width="24" height="24" />&nbsp;';
}
var id = participant.user.id;

View File

@ -12,7 +12,7 @@ class ApiMusicSessionsController < ApiController
# params[:friends_only] does the obvious.
# params[:my_bands_only] also does the obvious.
# Importantly, friends and my_bands are ORed not ANDed. So, if you specify both as true, you'll get more results, not fewer.
@music_sessions = MusicSession.index(current_user, params[:participants], params[:genres], params[:friends_only], params[:my_bands_only])
@music_sessions = MusicSession.index(current_user, params[:participants], params[:genres], params[:friends_only], params[:my_bands_only], params[:keyword])
end
def create

View File

@ -34,7 +34,7 @@
<!-- keyword filter -->
<div class="search-box">
<input id="search-session-input" type="text" name="search" value="Search by Keyword" onfocus="enterText(this.id,'')" onblur="enterText(this.id,'Search by Keyword')" />
<input id="session-keyword-srch" type="text" name="search" value="Search by Keyword" />
</div>
<div class="right mr10">
<a id="btn-refresh" href="#" style="text-decoration:none;" class="button-grey">REFRESH</a>