diff --git a/web/app/assets/javascripts/findMusician.js b/web/app/assets/javascripts/findMusician.js index 78acdfe3e..03852dc25 100644 --- a/web/app/assets/javascripts/findMusician.js +++ b/web/app/assets/javascripts/findMusician.js @@ -6,7 +6,6 @@ var logger = context.JK.logger; var musicians = {}; - var musicianCounts = [0, 0, 0]; var musicianList; function removeSpinner() { @@ -26,7 +25,7 @@ $.ajax({ type: "GET", - url: "/api/musicians?" + queryString, + url: "/api/users?" + queryString, async: true, success: afterLoadMusicians, complete: removeSpinner, @@ -37,21 +36,34 @@ function search() { logger.debug("Searching for musicians..."); clearResults(); - var queryString = ''; + var queryString = 'musicians=1&'; - // instrument filter - var instruments = context.JK.InstrumentSelectorHelper.getSelectedInstruments('#find-musician-instrument'); - if (instruments !== null && instruments.length > 0) { - queryString += "instruments=" + instruments.join(','); + // order by + var orderby = $('.musician-order-by').val(); + if (orderby !== null && orderby.length() > 0) { + queryString += "orderby=" + orderby + '&'; } - - // keyword filter - var keyword = $('#musician-keyword-srch').val(); - if (keyword !== null && keyword.length > 0 && keyword !== 'Search by Keyword') { - if (queryString.length > 0) { - queryString += "&"; - } - queryString += "keyword=" + $('#musician-keyword-srch').val(); + // instrument filter + var instrument = $('.instrument-list').val(); + if (instruments !== null && instruments.length() > 0) { + queryString += "instrument=" + instrument; + } + // distance filter + var query_param = $('#musician-query-distance').val(); + if (query_param !== null && query_param.length > 0) { + var matches = query_param.match(/(\d)/); + if (0 < matches.length()) { + var distance = matches[0]; + query_param = $('#musician-query-center').val(); + if (query_param !== null && query_param.length > 0) { + matches = query_param.match(/\\d{5}(-\\d{4})?/); + if (0 < matches.length()) { + var zip = matches[0]; + queryString += "zip=" + query_param + '&'; + queryString += "distance=" + query_param + '&'; + } + } + } } loadMusicians(queryString); } diff --git a/web/app/assets/stylesheets/client/search.css.scss b/web/app/assets/stylesheets/client/search.css.scss index 488e053c0..56cd7368d 100644 --- a/web/app/assets/stylesheets/client/search.css.scss +++ b/web/app/assets/stylesheets/client/search.css.scss @@ -55,3 +55,21 @@ font-size: 90%; } +.query-distance-params { + float:left; + width:140px; + margin-left: 10px; + -webkit-border-radius: 6px; + border-radius: 6px; + background-color:$ColorTextBoxBackground; + border: none; + color:#333; + font-weight:400; + padding:0px 0px 0px 8px; + height:18px; + line-height:18px; + overflow:hidden; + -webkit-box-shadow: inset 2px 2px 3px 0px #888; + box-shadow: inset 2px 2px 3px 0px #888; +} + diff --git a/web/app/controllers/api_users_controller.rb b/web/app/controllers/api_users_controller.rb index 40a96b869..427a2647a 100644 --- a/web/app/controllers/api_users_controller.rb +++ b/web/app/controllers/api_users_controller.rb @@ -14,8 +14,15 @@ class ApiUsersController < ApiController respond_to :json def index - @users = User.paginate(page: params[:page]) - respond_with @users, responder: ApiResponder, :status => 200 + if 1 == params[:musicians].to_i + query = params.clone + query[:remote_ip] = request.remote_ip + @users = User.musician_search(query, current_user) + respond_with @users, responder: ApiResponder, :status => 200 + else + @users = User.paginate(page: params[:page]) + respond_with @users, responder: ApiResponder, :status => 200 + end end def show diff --git a/web/app/views/clients/_instrumentSelector.html.erb b/web/app/views/clients/_instrumentSelector.html.erb deleted file mode 100644 index 2455a2079..000000000 --- a/web/app/views/clients/_instrumentSelector.html.erb +++ /dev/null @@ -1,3 +0,0 @@ - diff --git a/web/app/views/clients/_musician_filter.html.erb b/web/app/views/clients/_musician_filter.html.erb index 83eb139f6..1de14836e 100644 --- a/web/app/views/clients/_musician_filter.html.erb +++ b/web/app/views/clients/_musician_filter.html.erb @@ -1,18 +1,20 @@