Fix explore filter. Fixes #13182

This commit is contained in:
Josh Frye 2016-02-05 10:56:22 -05:00
parent 706b101f51
commit dd1a683c64
3 changed files with 21 additions and 24 deletions

View file

@ -1,5 +1,6 @@
@Dashboard =
init: ->
$("#project-filter-form-field").unbind()
this.initSearch()
initSearch: ->

View file

@ -1,24 +1,28 @@
class @ProjectsList
constructor: ->
$("#project-filter-form-field").unbind()
$(".projects-list .js-expand").on 'click', (e) ->
e.preventDefault()
list = $(this).closest('.projects-list')
list.find("li").show()
list.find("li.bottom").hide()
$(".projects-list-filter").keyup ->
terms = $(this).val()
uiBox = $('div.projects-list-holder')
filterSelector = $(this).data('filter-selector') || 'span.filter-title'
$("#filter_projects").keyup ->
ProjectsList.filter_results("#filter_projects")
$("#project-filter-form-field").keyup ->
ProjectsList.filter_results("#project-filter-form-field")
if terms == "" || terms == undefined
uiBox.find("ul.projects-list li").show()
else
uiBox.find("ul.projects-list li").each (index) ->
name = $(this).find(filterSelector).text()
@filter_results: (element) ->
terms = $(element).val()
filterSelector = $(element).data('filter-selector') || 'span.filter-title'
if name.toLowerCase().search(terms.toLowerCase()) == -1
$(this).hide()
else
$(this).show()
uiBox.find("ul.projects-list li.bottom").hide()
if terms == "" || terms == undefined
$("ul.projects-list li").show()
$('.gl-pagination').show()
else
$("ul.projects-list li").each (index) ->
name = $(this).find(filterSelector).text()
if name.toLowerCase().search(terms.toLowerCase()) == -1
$(this).hide()
else
$(this).show()
$('.gl-pagination').hide()

View file

@ -1,11 +1,3 @@
.pull-left
= form_tag explore_projects_filter_path, method: :get, class: 'form-inline form-tiny' do |f|
.form-group
= search_field_tag :search, params[:search], placeholder: "Filter by name", class: "form-control search-text-input", id: "projects_search", spellcheck: false
= hidden_field_tag :sort, @sort
.form-group
= button_tag 'Search', class: "btn"
.pull-right.hidden-sm.hidden-xs
- if current_user
.dropdown.inline.append-right-10