diff options
author | Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com> | 2016-02-05 18:02:47 +0300 |
---|---|---|
committer | Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com> | 2016-02-05 18:02:47 +0300 |
commit | 9bf85c01a909db0cb7633710fa99143ffd1196ab (patch) | |
tree | 6ce71c50be9d1b2670c97460cc3d296a4d9e3438 /app/assets | |
parent | 0c449e36eab2df5f3ea2532c6276d551094cf9b7 (diff) | |
parent | f1102b3373ecd294e625edf541d47552d5dc489f (diff) |
Merge branch 'paginate-dashboard-projects' into 'master'
Page project list on dashboard
See merge request !2689
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/projects_list.js.coffee | 2 |
3 files changed, 31 insertions, 6 deletions
diff --git a/app/assets/javascripts/dashboard.js.coffee b/app/assets/javascripts/dashboard.js.coffee index 00ee503ff16..dd295088312 100644 --- a/app/assets/javascripts/dashboard.js.coffee +++ b/app/assets/javascripts/dashboard.js.coffee @@ -1,3 +1,30 @@ -class @Dashboard - constructor: -> - new ProjectsList() +@Dashboard = + init: -> + this.initSearch() + + initSearch: -> + @timer = null + $("#project-filter-form-field").on('keyup', -> + clearTimeout(@timer) + @timer = setTimeout(Dashboard.filterResults, 500) + ) + + filterResults: => + $('.projects-list-holder').fadeTo(250, 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').fadeTo(250, 1) + 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" 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/projects_list.js.coffee b/app/assets/javascripts/projects_list.js.coffee index b71509dbc5a..ebf7140b7e3 100644 --- a/app/assets/javascripts/projects_list.js.coffee +++ b/app/assets/javascripts/projects_list.js.coffee @@ -22,5 +22,3 @@ class @ProjectsList else $(this).show() uiBox.find("ul.projects-list li.bottom").hide() - - |