From 3a4dc55f2924debcdbb37eb63d8ce57b1358df81 Mon Sep 17 00:00:00 2001 From: Bob Van Landuyt Date: Wed, 13 Sep 2017 17:16:30 +0200 Subject: Reuse the groups tree for explore and dashboard. --- app/controllers/dashboard/groups_controller.rb | 20 ++++---------------- 1 file changed, 4 insertions(+), 16 deletions(-) (limited to 'app/controllers/dashboard') diff --git a/app/controllers/dashboard/groups_controller.rb b/app/controllers/dashboard/groups_controller.rb index 6488e0b6c09..025769f512a 100644 --- a/app/controllers/dashboard/groups_controller.rb +++ b/app/controllers/dashboard/groups_controller.rb @@ -1,20 +1,8 @@ class Dashboard::GroupsController < Dashboard::ApplicationController - def index - @groups = GroupsFinder.new(current_user, all_available: false).execute - # Only show root groups if no parent-id is given - @groups = @groups.where(parent_id: params[:parent_id]) - @groups = @groups.search(params[:filter]) if params[:filter].present? - @groups = @groups.includes(:route) - @groups = @groups.sort(@sort = params[:sort]) - @groups = @groups.page(params[:page]) + include GroupTree - respond_to do |format| - format.html - format.json do - serializer = GroupChildSerializer.new(current_user: current_user) - .with_pagination(request, response) - render json: serializer.represent(@groups) - end - end + def index + groups = GroupsFinder.new(current_user, all_available: false).execute + render_group_tree(groups) end end -- cgit v1.2.1