From 8f6dac4991ba7f5771a24175784f19dc1bbd4103 Mon Sep 17 00:00:00 2001 From: Bob Van Landuyt Date: Fri, 8 Sep 2017 19:22:33 +0200 Subject: Allow filtering children for a group When fetching children for a group with a filter, we will search all nested groups for results and render them in an expanded tree --- app/controllers/groups_controller.rb | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'app/controllers/groups_controller.rb') diff --git a/app/controllers/groups_controller.rb b/app/controllers/groups_controller.rb index a714f2cc7b0..575d5476867 100644 --- a/app/controllers/groups_controller.rb +++ b/app/controllers/groups_controller.rb @@ -74,11 +74,11 @@ class GroupsController < Groups::ApplicationController respond_to do |format| format.json do - render json: GroupChildSerializer - .new(current_user: current_user) - .with_pagination(request, response) - .hierarchy_base(parent, open_hierarchy: filter[:filter].present) - .represent(@children) + serializer = GroupChildSerializer + .new(current_user: current_user) + .with_pagination(request, response) + serializer.expand_hierarchy(parent) if params[:filter].present? + render json: serializer.represent(@children) end end end -- cgit v1.2.3