Introduce per_page parameter for custom page size
This commit is contained in:
@ -28,7 +28,7 @@ class ConsumersController < ApplicationController
|
|||||||
private :consumer_params
|
private :consumer_params
|
||||||
|
|
||||||
def index
|
def index
|
||||||
@consumers = Consumer.paginate(page: params[:page])
|
@consumers = Consumer.paginate(page: params[:page], per_page: per_page_param)
|
||||||
authorize!
|
authorize!
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -12,7 +12,7 @@ class ErrorTemplateAttributesController < ApplicationController
|
|||||||
# GET /error_template_attributes.json
|
# GET /error_template_attributes.json
|
||||||
def index
|
def index
|
||||||
@error_template_attributes = ErrorTemplateAttribute.all.order('important DESC', :key,
|
@error_template_attributes = ErrorTemplateAttribute.all.order('important DESC', :key,
|
||||||
:id).paginate(page: params[:page])
|
:id).paginate(page: params[:page], per_page: per_page_param)
|
||||||
authorize!
|
authorize!
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -11,7 +11,7 @@ class ErrorTemplatesController < ApplicationController
|
|||||||
# GET /error_templates
|
# GET /error_templates
|
||||||
# GET /error_templates.json
|
# GET /error_templates.json
|
||||||
def index
|
def index
|
||||||
@error_templates = ErrorTemplate.all.order(:execution_environment_id, :name).paginate(page: params[:page])
|
@error_templates = ErrorTemplate.all.order(:execution_environment_id, :name).paginate(page: params[:page], per_page: per_page_param)
|
||||||
authorize!
|
authorize!
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -121,7 +121,7 @@ class ExecutionEnvironmentsController < ApplicationController
|
|||||||
private :execution_environment_params
|
private :execution_environment_params
|
||||||
|
|
||||||
def index
|
def index
|
||||||
@execution_environments = ExecutionEnvironment.all.includes(:user).order(:name).paginate(page: params[:page])
|
@execution_environments = ExecutionEnvironment.all.includes(:user).order(:name).paginate(page: params[:page], per_page: per_page_param)
|
||||||
authorize!
|
authorize!
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -6,7 +6,7 @@ class ExerciseCollectionsController < ApplicationController
|
|||||||
before_action :set_exercise_collection, only: %i[show edit update destroy statistics]
|
before_action :set_exercise_collection, only: %i[show edit update destroy statistics]
|
||||||
|
|
||||||
def index
|
def index
|
||||||
@exercise_collections = ExerciseCollection.all.paginate(page: params[:page])
|
@exercise_collections = ExerciseCollection.all.paginate(page: params[:page], per_page: per_page_param)
|
||||||
authorize!
|
authorize!
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -103,7 +103,7 @@ raise: false
|
|||||||
|
|
||||||
def feedback
|
def feedback
|
||||||
authorize!
|
authorize!
|
||||||
@feedbacks = @exercise.user_exercise_feedbacks.paginate(page: params[:page])
|
@feedbacks = @exercise.user_exercise_feedbacks.paginate(page: params[:page], per_page: per_page_param)
|
||||||
@submissions = @feedbacks.map do |feedback|
|
@submissions = @feedbacks.map do |feedback|
|
||||||
feedback.exercise.final_submission(feedback.user)
|
feedback.exercise.final_submission(feedback.user)
|
||||||
end
|
end
|
||||||
@ -410,7 +410,7 @@ working_time_accumulated: working_time_accumulated})
|
|||||||
|
|
||||||
def index
|
def index
|
||||||
@search = policy_scope(Exercise).ransack(params[:q])
|
@search = policy_scope(Exercise).ransack(params[:q])
|
||||||
@exercises = @search.result.includes(:execution_environment, :user).order(:title).paginate(page: params[:page])
|
@exercises = @search.result.includes(:execution_environment, :user).order(:title).paginate(page: params[:page], per_page: per_page_param)
|
||||||
authorize!
|
authorize!
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -10,7 +10,7 @@ class ExternalUsersController < ApplicationController
|
|||||||
|
|
||||||
def index
|
def index
|
||||||
@search = ExternalUser.ransack(params[:q])
|
@search = ExternalUser.ransack(params[:q])
|
||||||
@users = @search.result.in_study_group_of(current_user).includes(:consumer).paginate(page: params[:page])
|
@users = @search.result.in_study_group_of(current_user).includes(:consumer).paginate(page: params[:page], per_page: per_page_param)
|
||||||
authorize!
|
authorize!
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -19,7 +19,7 @@ class FileTemplatesController < ApplicationController
|
|||||||
# GET /file_templates
|
# GET /file_templates
|
||||||
# GET /file_templates.json
|
# GET /file_templates.json
|
||||||
def index
|
def index
|
||||||
@file_templates = FileTemplate.all.order(:file_type_id).paginate(page: params[:page])
|
@file_templates = FileTemplate.all.order(:file_type_id).paginate(page: params[:page], per_page: per_page_param)
|
||||||
authorize!
|
authorize!
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -33,7 +33,7 @@ class FileTypesController < ApplicationController
|
|||||||
private :file_type_params
|
private :file_type_params
|
||||||
|
|
||||||
def index
|
def index
|
||||||
@file_types = FileType.all.includes(:user).order(:name).paginate(page: params[:page])
|
@file_types = FileType.all.includes(:user).order(:name).paginate(page: params[:page], per_page: per_page_param)
|
||||||
authorize!
|
authorize!
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -63,7 +63,7 @@ class InternalUsersController < ApplicationController
|
|||||||
|
|
||||||
def index
|
def index
|
||||||
@search = InternalUser.ransack(params[:q])
|
@search = InternalUser.ransack(params[:q])
|
||||||
@users = @search.result.includes(:consumer).order(:name).paginate(page: params[:page])
|
@users = @search.result.includes(:consumer).order(:name).paginate(page: params[:page], per_page: per_page_param)
|
||||||
authorize!
|
authorize!
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -51,7 +51,7 @@ class ProxyExercisesController < ApplicationController
|
|||||||
|
|
||||||
def index
|
def index
|
||||||
@search = policy_scope(ProxyExercise).ransack(params[:q])
|
@search = policy_scope(ProxyExercise).ransack(params[:q])
|
||||||
@proxy_exercises = @search.result.order(:title).paginate(page: params[:page])
|
@proxy_exercises = @search.result.order(:title).paginate(page: params[:page], per_page: per_page_param)
|
||||||
authorize!
|
authorize!
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -23,7 +23,7 @@ class RequestForCommentsController < ApplicationController
|
|||||||
.where(exercises: {unpublished: false})
|
.where(exercises: {unpublished: false})
|
||||||
.includes(submission: [:study_group])
|
.includes(submission: [:study_group])
|
||||||
.order('created_at DESC')
|
.order('created_at DESC')
|
||||||
.paginate(page: params[:page], total_entries: @search.result.length)
|
.paginate(page: params[:page], per_page: per_page_param, total_entries: @search.result.length)
|
||||||
|
|
||||||
authorize!
|
authorize!
|
||||||
end
|
end
|
||||||
@ -36,7 +36,7 @@ class RequestForCommentsController < ApplicationController
|
|||||||
.ransack(params[:q])
|
.ransack(params[:q])
|
||||||
@request_for_comments = @search.result
|
@request_for_comments = @search.result
|
||||||
.order('created_at DESC')
|
.order('created_at DESC')
|
||||||
.paginate(page: params[:page])
|
.paginate(page: params[:page], per_page: per_page_param)
|
||||||
authorize!
|
authorize!
|
||||||
render 'index'
|
render 'index'
|
||||||
end
|
end
|
||||||
@ -50,7 +50,7 @@ class RequestForCommentsController < ApplicationController
|
|||||||
.ransack(params[:q])
|
.ransack(params[:q])
|
||||||
@request_for_comments = @search.result
|
@request_for_comments = @search.result
|
||||||
.order('last_comment DESC')
|
.order('last_comment DESC')
|
||||||
.paginate(page: params[:page])
|
.paginate(page: params[:page], per_page: per_page_param)
|
||||||
authorize!
|
authorize!
|
||||||
render 'index'
|
render 'index'
|
||||||
end
|
end
|
||||||
@ -65,7 +65,7 @@ class RequestForCommentsController < ApplicationController
|
|||||||
@request_for_comments = @search.result
|
@request_for_comments = @search.result
|
||||||
.joins(:exercise)
|
.joins(:exercise)
|
||||||
.order('last_comment DESC')
|
.order('last_comment DESC')
|
||||||
.paginate(page: params[:page])
|
.paginate(page: params[:page], per_page: per_page_param)
|
||||||
# let the exercise decide, whether its rfcs should be visible
|
# let the exercise decide, whether its rfcs should be visible
|
||||||
authorize(exercise)
|
authorize(exercise)
|
||||||
render 'index'
|
render 'index'
|
||||||
|
@ -7,7 +7,7 @@ class StudyGroupsController < ApplicationController
|
|||||||
|
|
||||||
def index
|
def index
|
||||||
@search = policy_scope(StudyGroup).ransack(params[:q])
|
@search = policy_scope(StudyGroup).ransack(params[:q])
|
||||||
@study_groups = @search.result.includes(:consumer).order(:name).paginate(page: params[:page])
|
@study_groups = @search.result.includes(:consumer).order(:name).paginate(page: params[:page], per_page: per_page_param)
|
||||||
authorize!
|
authorize!
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -65,7 +65,7 @@ class SubmissionsController < ApplicationController
|
|||||||
|
|
||||||
def index
|
def index
|
||||||
@search = Submission.ransack(params[:q])
|
@search = Submission.ransack(params[:q])
|
||||||
@submissions = @search.result.includes(:exercise, :user).paginate(page: params[:page])
|
@submissions = @search.result.includes(:exercise, :user).paginate(page: params[:page], per_page: per_page_param)
|
||||||
authorize!
|
authorize!
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -28,7 +28,7 @@ class TagsController < ApplicationController
|
|||||||
private :tag_params
|
private :tag_params
|
||||||
|
|
||||||
def index
|
def index
|
||||||
@tags = Tag.all.paginate(page: params[:page])
|
@tags = Tag.all.paginate(page: params[:page], per_page: per_page_param)
|
||||||
authorize!
|
authorize!
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -34,7 +34,7 @@ class TipsController < ApplicationController
|
|||||||
private :tip_params
|
private :tip_params
|
||||||
|
|
||||||
def index
|
def index
|
||||||
@tips = Tip.all.paginate(page: params[:page])
|
@tips = Tip.all.paginate(page: params[:page], per_page: per_page_param)
|
||||||
authorize!
|
authorize!
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -34,6 +34,14 @@ module ApplicationHelper
|
|||||||
tag.i(nil, class: 'fa fa-times')
|
tag.i(nil, class: 'fa fa-times')
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def per_page_param
|
||||||
|
if params[:per_page]
|
||||||
|
[params[:per_page].to_i, 100].min
|
||||||
|
else
|
||||||
|
WillPaginate.per_page
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
def progress_bar(value)
|
def progress_bar(value)
|
||||||
tag.div(class: value ? 'progress' : 'disabled progress') do
|
tag.div(class: value ? 'progress' : 'disabled progress') do
|
||||||
tag.div(value ? "#{value}%" : '', 'aria-valuemax': 100, 'aria-valuemin': 0,
|
tag.div(value ? "#{value}%" : '', 'aria-valuemax': 100, 'aria-valuemin': 0,
|
||||||
|
Reference in New Issue
Block a user