diff options
author | Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com> | 2014-09-03 19:18:23 +0300 |
---|---|---|
committer | Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com> | 2014-09-03 19:18:23 +0300 |
commit | 5f6eb09cdf1bb264e788521cd7289e419fd68e13 (patch) | |
tree | 246ad4c5dd621e6179e62f509f268f90d73d49cd /app | |
parent | e8f1331fa4b3f4c4037f6509b2a846f521f506fc (diff) | |
download | gitlab-ce-5f6eb09cdf1bb264e788521cd7289e419fd68e13.tar.gz |
Improve issue filtering. Make tests pass
Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
Diffstat (limited to 'app')
-rw-r--r-- | app/assets/javascripts/issues.js.coffee | 40 | ||||
-rw-r--r-- | app/views/projects/issues/_head.html.haml | 2 |
2 files changed, 24 insertions, 18 deletions
diff --git a/app/assets/javascripts/issues.js.coffee b/app/assets/javascripts/issues.js.coffee index 54de93a4e04..2499ad5ad80 100644 --- a/app/assets/javascripts/issues.js.coffee +++ b/app/assets/javascripts/issues.js.coffee @@ -43,25 +43,31 @@ $(".selected_issue").bind "change", Issues.checkChanged - + # Make sure we trigger ajax request only after user stop typing initSearch: -> - form = $("#issue_search_form") - last_terms = "" + @timer = null $("#issue_search").keyup -> - terms = $(this).val() - unless terms is last_terms - last_terms = terms - if terms.length >= 2 or terms.length is 0 - $.ajax - type: "GET" - url: location.href - data: "issue_search=" + terms - complete: -> - $(".loading").hide() - success: (data) -> - $('.issues-holder').html(data.html) - Issues.reload() - dataType: "json" + clearTimeout(@timer); + @timer = setTimeout(Issues.filterResults, 500) + + filterResults: => + form = $("#issue_search_form") + search = $("#issue_search").val() + $('.issues-holder').css("opacity", '0.5') + issues_url = form.attr('action') + '? '+ form.serialize() + + $.ajax + type: "GET" + url: form.attr('action') + data: form.serialize() + complete: -> + $('.issues-holder').css("opacity", '1.0') + success: (data) -> + $('.issues-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 + Issues.reload() + dataType: "json" checkChanged: -> checked_issues = $(".selected_issue:checked") diff --git a/app/views/projects/issues/_head.html.haml b/app/views/projects/issues/_head.html.haml index dad547d4ebc..82cde14e05d 100644 --- a/app/views/projects/issues/_head.html.haml +++ b/app/views/projects/issues/_head.html.haml @@ -24,7 +24,7 @@ %i.icon.icon-list = form_tag project_issues_path(@project), method: :get, id: "issue_search_form", class: 'pull-left issue-search-form' do .append-right-10.hidden-xs.hidden-sm - = search_field_tag :issue_search, nil, { placeholder: 'Filter by title or description', class: 'form-control issue_search search-text-input input-mn-300' } + = search_field_tag :issue_search, params[:issue_search], { placeholder: 'Filter by title or description', class: 'form-control issue_search search-text-input input-mn-300' } = hidden_field_tag :state, params['state'] = hidden_field_tag :scope, params['scope'] = hidden_field_tag :assignee_id, params['assignee_id'] |