Commit beab104d authored by Phil Hughes's avatar Phil Hughes

Filters by text on element

parent 850fa65e
...@@ -9,6 +9,7 @@ class @Compare ...@@ -9,6 +9,7 @@ class @Compare
$dropdown.glDropdown( $dropdown.glDropdown(
selectable: true selectable: true
fieldName: $dropdown.data 'field-name' fieldName: $dropdown.data 'field-name'
filterable: true
id: (obj, $el) -> id: (obj, $el) ->
$el.data 'id' $el.data 'id'
toggleLabel: (obj, $el) -> toggleLabel: (obj, $el) ->
......
...@@ -57,6 +57,8 @@ class GitLabDropdownFilter ...@@ -57,6 +57,8 @@ class GitLabDropdownFilter
filter: (search_text) -> filter: (search_text) ->
data = @options.data() data = @options.data()
if data?
results = data results = data
if search_text isnt "" if search_text isnt ""
...@@ -65,6 +67,20 @@ class GitLabDropdownFilter ...@@ -65,6 +67,20 @@ class GitLabDropdownFilter
) )
@options.callback results @options.callback results
else
elements = @options.elements()
if search_text
elements.each ->
$el = $(@)
matches = fuzzaldrinPlus.match($el.text().trim(), search_text)
if matches.length
$el.show()
else
$el.hide()
else
elements.show()
class GitLabDropdownRemote class GitLabDropdownRemote
constructor: (@dataEndpoint, @options) -> constructor: (@dataEndpoint, @options) ->
...@@ -147,7 +163,14 @@ class GitLabDropdown ...@@ -147,7 +163,14 @@ class GitLabDropdown
filterInputBlur: @filterInputBlur filterInputBlur: @filterInputBlur
remote: @options.filterRemote remote: @options.filterRemote
query: @options.data query: @options.data
keys: @options.search.fields keys: search_fields
elements: =>
selector = ".dropdown-content li:not(.divider)"
if @dropdown.find(".dropdown-toggle-page").length
selector = ".dropdown-page-one #{selector}"
return $(selector)
data: => data: =>
return @fullData return @fullData
callback: (data) => callback: (data) =>
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment