diff options
author | Josh Frye <joshfng@gmail.com> | 2016-02-05 22:33:24 +0300 |
---|---|---|
committer | Josh Frye <joshfng@gmail.com> | 2016-02-09 18:10:41 +0300 |
commit | 30e022a2feec7450c4173038d3fdfef0d6242953 (patch) | |
tree | 6a145d62527573a381072710fc17ec5785cf7954 /app | |
parent | 0dc64a8ce1e9bde993ea7a862c71d7edaa69a286 (diff) |
Starred, All, and Trending on explore are paged also group projects. Need ajax filter.
Diffstat (limited to 'app')
-rw-r--r-- | app/assets/javascripts/dashboard.js.coffee | 4 | ||||
-rw-r--r-- | app/assets/javascripts/dispatcher.js.coffee | 2 | ||||
-rw-r--r-- | app/assets/javascripts/projects_list.js.coffee | 4 | ||||
-rw-r--r-- | app/controllers/explore/projects_controller.rb | 30 | ||||
-rw-r--r-- | app/controllers/groups_controller.rb | 11 | ||||
-rw-r--r-- | app/views/groups/_projects.html.haml | 17 | ||||
-rw-r--r-- | app/views/shared/projects/_list.html.haml | 1 |
7 files changed, 55 insertions, 14 deletions
diff --git a/app/assets/javascripts/dashboard.js.coffee b/app/assets/javascripts/dashboard.js.coffee index c7757540b31..7e77ed5e7ff 100644 --- a/app/assets/javascripts/dashboard.js.coffee +++ b/app/assets/javascripts/dashboard.js.coffee @@ -5,7 +5,7 @@ initSearch: -> @timer = null - $("#project-filter-form-field").on('keyup', -> + $("#project-filter-form-field,.projects-list-filter").on('keyup', -> clearTimeout(@timer) @timer = setTimeout(Dashboard.filterResults, 500) ) @@ -25,7 +25,7 @@ complete: -> $('.projects-list-holder').fadeTo(250, 1) success: (data) -> - $('div.projects-list-holder').replaceWith(data.html) + $('.projects-list-holder,.public-projects').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 d4a2b74b143..b17f8e51470 100644 --- a/app/assets/javascripts/dispatcher.js.coffee +++ b/app/assets/javascripts/dispatcher.js.coffee @@ -16,6 +16,8 @@ class Dispatcher shortcut_handler = null switch page + when 'explore:projects:index', 'explore:projects:starred', 'explore:projects:trending' + Dashboard.init() when 'projects:issues:index' Issues.init() shortcut_handler = new ShortcutsNavigation() diff --git a/app/assets/javascripts/projects_list.js.coffee b/app/assets/javascripts/projects_list.js.coffee index b4f5546a42f..bb392140b73 100644 --- a/app/assets/javascripts/projects_list.js.coffee +++ b/app/assets/javascripts/projects_list.js.coffee @@ -11,8 +11,8 @@ class @ProjectsList ProjectsList.filter_results($("#project-filter-form-field")) @filter_results: ($element) -> - terms = $($element).val() - filterSelector = $($element).data('filter-selector') || 'span.filter-title' + terms = $element.val() + filterSelector = $element.data('filter-selector') || 'span.filter-title' if not terms $("ul.projects-list li").show() diff --git a/app/controllers/explore/projects_controller.rb b/app/controllers/explore/projects_controller.rb index 2689bf4f1ec..317ad835006 100644 --- a/app/controllers/explore/projects_controller.rb +++ b/app/controllers/explore/projects_controller.rb @@ -6,19 +6,49 @@ class Explore::ProjectsController < Explore::ApplicationController @projects = @projects.where(visibility_level: params[:visibility_level]) if params[:visibility_level].present? @projects = @projects.non_archived @projects = @projects.search(params[:search]) if params[:search].present? + @projects = @projects.search(params[:filter_projects]) if params[:filter_projects].present? @projects = @projects.sort(@sort = params[:sort]) @projects = @projects.includes(:namespace).page(params[:page]).per(PER_PAGE) + + respond_to do |format| + format.html + format.json do + render json: { + html: view_to_html_string("dashboard/projects/_projects", locals: { projects: @projects }) + } + end + end end def trending @projects = TrendingProjectsFinder.new.execute(current_user) @projects = @projects.non_archived + @projects = @projects.search(params[:filter_projects]) if params[:filter_projects].present? @projects = @projects.page(params[:page]).per(PER_PAGE) + + respond_to do |format| + format.html + format.json do + render json: { + html: view_to_html_string("dashboard/projects/_projects", locals: { projects: @projects }) + } + end + end end def starred @projects = ProjectsFinder.new.execute(current_user) + @projects = @projects.search(params[:filter_projects]) if params[:filter_projects].present? @projects = @projects.reorder('star_count DESC') @projects = @projects.page(params[:page]).per(PER_PAGE) + + respond_to do |format| + format.html + format.json do + render json: { + html: view_to_html_string("dashboard/projects/_projects", locals: { projects: @projects }) + } + end + end end end diff --git a/app/controllers/groups_controller.rb b/app/controllers/groups_controller.rb index 90475c17c17..b4dd0021ed7 100644 --- a/app/controllers/groups_controller.rb +++ b/app/controllers/groups_controller.rb @@ -41,14 +41,21 @@ class GroupsController < Groups::ApplicationController def show @last_push = current_user.recent_push if current_user @projects = @projects.includes(:namespace) + @projects = @projects.search(params[:filter_projects]) if params[:filter_projects].present? @projects = @projects.page(params[:page]).per(PER_PAGE) respond_to do |format| format.html format.json do - load_events - pager_json("events/_events", @events.count) + if params[:filter_projects] + render json: { + html: view_to_html_string("dashboard/projects/_projects", locals: { projects: @projects }) + } + else + load_events + pager_json("events/_events", @events.count) + end end format.atom do diff --git a/app/views/groups/_projects.html.haml b/app/views/groups/_projects.html.haml index a829479bb38..73305efbcb9 100644 --- a/app/views/groups/_projects.html.haml +++ b/app/views/groups/_projects.html.haml @@ -1,10 +1,11 @@ -.projects-list-holder.prepend-top-default - .input-group - = search_field_tag :filter_projects, nil, placeholder: 'Filter by name', class: 'projects-list-filter form-control', spellcheck: false - - if can? current_user, :create_projects, @group - %span.input-group-btn - = link_to new_project_path(namespace_id: @group.id), class: 'btn btn-new' do - = icon('plus') - New Project +.top-area + .nav-controls + = form_tag request.original_url, method: :get, class: 'project-filter-form', id: 'project-filter-form' do |f| + = search_field_tag :filter_projects, params[:filter_projects], placeholder: 'Filter by name...', class: 'input-short project-filter-form-field form-control', spellcheck: false, id: 'project-filter-form-field' + - if current_user && current_user.can_create_project? + = link_to new_project_path, class: 'btn btn-new' do + = icon('plus') + New Project +.projects-list-holder = render 'shared/projects/list', projects: @projects, projects_limit: 20, stars: false, skip_namespace: true diff --git a/app/views/shared/projects/_list.html.haml b/app/views/shared/projects/_list.html.haml index 67edb264b7e..4787502fbc2 100644 --- a/app/views/shared/projects/_list.html.haml +++ b/app/views/shared/projects/_list.html.haml @@ -27,3 +27,4 @@ :javascript new ProjectsList(); + Dashboard.init(); |