forked from DMPRoadmap/roadmap
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Create
paginable/research_outputs_controller.rb
- Loading branch information
1 parent
e289fba
commit 3c5a478
Showing
1 changed file
with
26 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
# frozen_string_literal: true | ||
|
||
module Paginable | ||
# Controller for paginating/sorting/searching the research_outputs table | ||
class ResearchOutputsController < ApplicationController | ||
include Paginable | ||
|
||
after_action :verify_authorized | ||
|
||
# GET /paginable/plans/:plan_id/research_outputs | ||
def index | ||
@plan = Plan.find_by(id: params[:plan_id]) | ||
|
||
# Same @research_outputs assignment as app/controllers/research_outputs_controller.rb | ||
@research_outputs = ResearchOutput.includes(:repositories).where(plan_id: @plan.id) | ||
# Same authorize handling as app/controllers/research_outputs_controller.rb | ||
authorize @research_outputs.first || ResearchOutput.new(plan_id: @plan.id) | ||
paginable_renderise( | ||
partial: 'index', | ||
scope: @research_outputs, | ||
query_params: { sort_field: 'research_outputs.title' }, | ||
format: :json | ||
) | ||
end | ||
end | ||
end |