VRFS-2795 instrument selection; json posting
This commit is contained in:
parent
03321a8166
commit
23ccc855d5
|
|
@ -1584,7 +1584,8 @@
|
|||
function postMusicianSearchFilter(query) {
|
||||
return $.ajax({
|
||||
type: "POST",
|
||||
url: "/api/search/musicians.json?" + $.param(query)
|
||||
url: "/api/search/musicians.json",
|
||||
data: query
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -97,9 +97,9 @@ context.JK.MusicianSearchFilter = class MusicianSearchFilter
|
|||
selected = ''
|
||||
ageLabel = ages_map[key]
|
||||
if 0 < @searchFilter.ages.length
|
||||
|
||||
key_val = key.toString()
|
||||
ageMatch = $.grep(@searchFilter.ages, (n, i) ->
|
||||
n.id == key
|
||||
n == key_val
|
||||
)
|
||||
if ageMatch.length > 0
|
||||
selected = 'checked'
|
||||
|
|
@ -117,7 +117,7 @@ context.JK.MusicianSearchFilter = class MusicianSearchFilter
|
|||
selected = ''
|
||||
if 0 < @searchFilter.genres.length
|
||||
genreMatch = $.grep(@searchFilter.genres, (n, i) ->
|
||||
n.id == genre.id
|
||||
n == genre.id
|
||||
)
|
||||
if genreMatch.length > 0
|
||||
selected = 'checked'
|
||||
|
|
@ -133,17 +133,24 @@ context.JK.MusicianSearchFilter = class MusicianSearchFilter
|
|||
$.each instruments, (index, instrument) =>
|
||||
instrumentTemplate = $('#template-search-filter-setup-instrument').html()
|
||||
selected = ''
|
||||
proficiency = '1'
|
||||
if 0 < @searchFilter.instruments.length
|
||||
instrumentMatch = $.grep(@searchFilter.instruments, (n, i) ->
|
||||
n.id == instrument.id
|
||||
instMatch = $.grep(@searchFilter.instruments, (inst, i) ->
|
||||
yn = inst.instrument_id == instrument.id
|
||||
proficiency = inst.proficiency_level if yn
|
||||
yn
|
||||
)
|
||||
if instrumentMatch.length > 0
|
||||
selected = 'checked'
|
||||
if instMatch.length > 0
|
||||
selected = 'checked'
|
||||
instrumentHtml = context.JK.fillTemplate(instrumentTemplate,
|
||||
id: instrument.id
|
||||
description: instrument.description
|
||||
checked: selected)
|
||||
checked: selected
|
||||
)
|
||||
$('#search-filter-instruments').append instrumentHtml
|
||||
instsel = '#search-filter-instruments tr[data-instrument-id="'+instrument.id+'"] select'
|
||||
$(instsel).val(proficiency)
|
||||
return true
|
||||
|
||||
_selectedValue: (identifier) =>
|
||||
elem = $ '#musician-search-filter-builder select[name='+identifier+']'
|
||||
|
|
@ -171,6 +178,5 @@ context.JK.MusicianSearchFilter = class MusicianSearchFilter
|
|||
$.each gon.musician_search_filter.filter_keys.multi, (index, key) =>
|
||||
@searchFilter[key] = this._selectedMultiValue(key)
|
||||
|
||||
@logger.debug("performSearch: "+JSON.stringify(@searchFilter))
|
||||
@rest.postMusicianSearchFilter { filter: @searchFilter }
|
||||
@rest.postMusicianSearchFilter { filter: JSON.stringify(@searchFilter), page: 1 }
|
||||
|
||||
|
|
@ -27,8 +27,10 @@ class ApiSearchController < ApiController
|
|||
render :json => MusicianSearch.search_filter_json(current_user), :status => 200
|
||||
|
||||
elsif request.post?
|
||||
logger.debug("*** params = #{params.inspect}")
|
||||
ms = MusicianSearch.user_search_filter(current_user)
|
||||
results = ms.search_results_page(params[:filter])
|
||||
json = JSON.parse(params[:filter], :create_additions => false)
|
||||
results = ms.search_results_page(json, [params[:page].to_i, 1].max)
|
||||
render :json => results, :status => 200
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -45,8 +45,8 @@ script#template-musician-search-filter type="text/template"
|
|||
|
||||
script#template-search-filter-setup-instrument type="text/template"
|
||||
tr data-instrument-id="{id}"
|
||||
td <input type="checkbox" checked} />{description}
|
||||
td align="right" width="50%"
|
||||
td <input type="checkbox" {checked} />{description}
|
||||
td align="right" width="50%" id="{proficiency_id}"
|
||||
select.proficiency_selector name="proficiency"
|
||||
option value="1" Beginner
|
||||
option value="2" Intermediate
|
||||
|
|
|
|||
Loading…
Reference in New Issue