2015-04-30 17:06:18 +00:00
|
|
|
class Dashboard::GroupsController < Dashboard::ApplicationController
|
2013-07-12 15:22:03 +00:00
|
|
|
def index
|
2017-09-13 08:25:37 +00:00
|
|
|
@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])
|
2017-09-12 12:58:44 +00:00
|
|
|
@groups = @groups.search(params[:filter]) if params[:filter].present?
|
2017-05-04 20:45:02 +00:00
|
|
|
@groups = @groups.includes(:route)
|
2017-09-13 09:29:32 +00:00
|
|
|
@groups = @groups.sort(@sort = params[:sort])
|
2017-05-04 20:45:02 +00:00
|
|
|
@groups = @groups.page(params[:page])
|
2017-03-01 13:31:56 +00:00
|
|
|
|
|
|
|
respond_to do |format|
|
|
|
|
format.html
|
|
|
|
format.json do
|
2017-09-12 12:58:44 +00:00
|
|
|
serializer = GroupChildSerializer.new(current_user: current_user)
|
|
|
|
.with_pagination(request, response)
|
|
|
|
render json: serializer.represent(@groups)
|
2017-03-01 13:31:56 +00:00
|
|
|
end
|
|
|
|
end
|
2013-07-12 15:22:03 +00:00
|
|
|
end
|
|
|
|
end
|