80b2f3fb86
It is same search like we have at issues page. It allows to quickly filter merge requests based on title or desription. I copy-pasted some js code from Issues.js. In future search (filtering) logic should be refactoed into one class for merge requests and issues
35 lines
1 KiB
CoffeeScript
35 lines
1 KiB
CoffeeScript
#
|
|
# * Filter merge requests
|
|
#
|
|
@MergeRequests =
|
|
init: ->
|
|
MergeRequests.initSearch()
|
|
|
|
# Make sure we trigger ajax request only after user stop typing
|
|
initSearch: ->
|
|
@timer = null
|
|
$("#issue_search").keyup ->
|
|
clearTimeout(@timer)
|
|
@timer = setTimeout(MergeRequests.filterResults, 500)
|
|
|
|
filterResults: =>
|
|
form = $("#issue_search_form")
|
|
search = $("#issue_search").val()
|
|
$('.merge-requests-holder').css("opacity", '0.5')
|
|
issues_url = form.attr('action') + '? '+ form.serialize()
|
|
|
|
$.ajax
|
|
type: "GET"
|
|
url: form.attr('action')
|
|
data: form.serialize()
|
|
complete: ->
|
|
$('.merge-requests-holder').css("opacity", '1.0')
|
|
success: (data) ->
|
|
$('.merge-requests-holder').html(data.html)
|
|
# Change url so if user reload a page - search results are saved
|
|
History.replaceState {page: issues_url}, document.title, issues_url
|
|
MergeRequests.reload()
|
|
dataType: "json"
|
|
|
|
reload: ->
|
|
$('#filter_issue_search').val($('#issue_search').val())
|