diff options
author | Josh Frye <joshfng@gmail.com> | 2016-02-04 02:21:14 +0300 |
---|---|---|
committer | Josh Frye <joshfng@gmail.com> | 2016-02-04 21:03:41 +0300 |
commit | 2ad094132de3c491511261bf0e6a2e577fd699dd (patch) | |
tree | 7ba4cf6ed687cde58b13a0c4151ac243db09e47f /app/assets | |
parent | 2c871ca1968846871ed264cad34b50611eecae3b (diff) |
Various filter fixes
Diffstat (limited to 'app/assets')
-rw-r--r-- | app/assets/javascripts/dashboard.js.coffee | 33 | ||||
-rw-r--r-- | app/assets/javascripts/dispatcher.js.coffee | 2 | ||||
-rw-r--r-- | app/assets/javascripts/issues.js.coffee | 2 | ||||
-rw-r--r-- | app/assets/javascripts/projects_list.js.coffee | 43 | ||||
-rw-r--r-- | app/assets/javascripts/user.js.coffee | 2 |
5 files changed, 49 insertions, 33 deletions
diff --git a/app/assets/javascripts/dashboard.js.coffee b/app/assets/javascripts/dashboard.js.coffee index dc0b9597d1f..0229c588b41 100644 --- a/app/assets/javascripts/dashboard.js.coffee +++ b/app/assets/javascripts/dashboard.js.coffee @@ -1,3 +1,30 @@ -class @Dashboard - constructor: -> - ProjectsList.init() +@Dashboard = + init: -> + this.initSearch() + + initSearch: -> + @timer = null + $("#project-filter-form-field").keyup -> + clearTimeout(@timer) + @timer = setTimeout(Dashboard.filterResults, 500) + + filterResults: => + $('.projects-list-holder').css("opacity", '0.5') + + form = null + form = $("#project-filter-form") + search = $("#project-filter-form-field").val() + project_filter_url = form.attr('action') + '?' + form.serialize() + + $.ajax + type: "GET" + url: form.attr('action') + data: form.serialize() + complete: -> + $('.projects-list-holder').css("opacity", '1.0') + success: (data) -> + $('div.projects-list-holder').replaceWith(data.html) + # Change url so if user reload a page - search results are saved + history.replaceState {page: project_filter_url}, document.title, project_filter_url + dataType: "json" + #uiBox.find("ul.projects-list li.bottom").hide() diff --git a/app/assets/javascripts/dispatcher.js.coffee b/app/assets/javascripts/dispatcher.js.coffee index 2cdf01d874c..d4a2b74b143 100644 --- a/app/assets/javascripts/dispatcher.js.coffee +++ b/app/assets/javascripts/dispatcher.js.coffee @@ -58,7 +58,7 @@ class Dispatcher shortcut_handler = new ShortcutsNavigation() MergeRequests.init() when 'dashboard:show', 'root:show' - new Dashboard() + Dashboard.init() when 'dashboard:activity' new Activities() when 'dashboard:projects:starred' diff --git a/app/assets/javascripts/issues.js.coffee b/app/assets/javascripts/issues.js.coffee index 54e00741424..a0acf3028bf 100644 --- a/app/assets/javascripts/issues.js.coffee +++ b/app/assets/javascripts/issues.js.coffee @@ -45,7 +45,7 @@ filterResults: => form = $("#issue_search_form") - search = $("#projects-list-filter").val() + search = $("#issue_search").val() $('.issues-holder').css("opacity", '0.5') issues_url = form.attr('action') + '?' + form.serialize() diff --git a/app/assets/javascripts/projects_list.js.coffee b/app/assets/javascripts/projects_list.js.coffee index 384b95118c9..ebf7140b7e3 100644 --- a/app/assets/javascripts/projects_list.js.coffee +++ b/app/assets/javascripts/projects_list.js.coffee @@ -1,35 +1,24 @@ -@ProjectsList = - init: -> +class @ProjectsList + constructor: -> $(".projects-list .js-expand").on 'click', (e) -> e.preventDefault() list = $(this).closest('.projects-list') list.find("li").show() list.find("li.bottom").hide() - this.initSearch() - initSearch: -> - @timer = null - $("#projects-list-filter").keyup -> - clearTimeout(@timer) - @timer = setTimeout(ProjectsList.filterResults, 500) + $(".projects-list-filter").keyup -> + terms = $(this).val() + uiBox = $('div.projects-list-holder') + filterSelector = $(this).data('filter-selector') || 'span.filter-title' - filterResults: => - form = $("#project-list-form") - search = $("#issue_search").val() - uiBox = $('div.projects-list-holder') + 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() - $('.projects-list-holder').css("opacity", '0.5') - - project_filter_url = form.attr('action') + '?' + form.serialize() - $.ajax - type: "GET" - url: form.attr('action') - data: form.serialize() - complete: -> - $('.projects-list-holder').css("opacity", '1.0') - success: (data) -> - $('.projects-list-holder').html(data.html) - # Change url so if user reload a page - search results are saved - history.replaceState {page: project_filter_url}, document.title, project_filter_url - dataType: "json" - uiBox.find("ul.projects-list li.bottom").hide() + if name.toLowerCase().search(terms.toLowerCase()) == -1 + $(this).hide() + else + $(this).show() + uiBox.find("ul.projects-list li.bottom").hide() diff --git a/app/assets/javascripts/user.js.coffee b/app/assets/javascripts/user.js.coffee index eb7f7bb26b1..ec4271b092c 100644 --- a/app/assets/javascripts/user.js.coffee +++ b/app/assets/javascripts/user.js.coffee @@ -1,7 +1,7 @@ class @User constructor: -> $('.profile-groups-avatars').tooltip("placement": "top") - ProjectsList.init() + new ProjectsList() $('.hide-project-limit-message').on 'click', (e) -> path = '/' |