added pagination for all resources

This commit is contained in:
Hauke Klement
2015-03-11 16:13:45 +01:00
parent 400711ac58
commit acf03b1f51
20 changed files with 24 additions and 11 deletions

View File

@ -27,7 +27,7 @@ class ConsumersController < ApplicationController
private :consumer_params
def index
@consumers = Consumer.all
@consumers = Consumer.paginate(page: params[:page])
authorize!
end

View File

@ -27,7 +27,7 @@ class ErrorsController < ApplicationController
private :error_params
def index
@errors = Error.for_execution_environment(@execution_environment).grouped_by_message
@errors = Error.for_execution_environment(@execution_environment).grouped_by_message.paginate(page: params[:page])
authorize!
end

View File

@ -34,7 +34,7 @@ class ExecutionEnvironmentsController < ApplicationController
private :execution_environment_params
def index
@execution_environments = ExecutionEnvironment.all.includes(:user).order(:name)
@execution_environments = ExecutionEnvironment.all.includes(:user).order(:name).paginate(page: params[:page])
authorize!
end

View File

@ -78,7 +78,7 @@ class ExercisesController < ApplicationController
def index
@search = policy_scope(Exercise).search(params[:q])
@exercises = @search.result.includes(:execution_environment, :user).order(:title)
@exercises = @search.result.includes(:execution_environment, :user).order(:title).paginate(page: params[:page])
authorize!
end

View File

@ -5,7 +5,7 @@ class ExternalUsersController < ApplicationController
private :authorize!
def index
@users = ExternalUser.all.includes(:consumer)
@users = ExternalUser.all.includes(:consumer).paginate(page: params[:page])
authorize!
end

View File

@ -28,7 +28,7 @@ class FileTypesController < ApplicationController
private :file_type_params
def index
@file_types = FileType.all.includes(:user).order(:name)
@file_types = FileType.all.includes(:user).order(:name).paginate(page: params[:page])
authorize!
end

View File

@ -28,7 +28,7 @@ class HintsController < ApplicationController
private :hint_params
def index
@hints = @execution_environment.hints.order(:name)
@hints = @execution_environment.hints.order(:name).paginate(page: params[:page])
authorize!
end

View File

@ -62,7 +62,7 @@ class InternalUsersController < ApplicationController
def index
@search = InternalUser.search(params[:q])
@users = @search.result.includes(:consumer).order(:name)
@users = @search.result.includes(:consumer).order(:name).paginate(page: params[:page])
authorize!
end

View File

@ -22,7 +22,7 @@ class TeamsController < ApplicationController
end
def index
@teams = Team.all.includes(:internal_users).order(:name)
@teams = Team.all.includes(:internal_users).order(:name).paginate(page: params[:page])
authorize!
end

View File

@ -14,4 +14,5 @@ h1 = Consumer.model_name.human(count: 2)
td = link_to(t('shared.edit'), edit_consumer_path(consumer))
td = link_to(t('shared.destroy'), consumer, data: {confirm: t('shared.confirm_destroy')}, method: :delete)
= render('shared/pagination', collection: @consumers)
p = render('shared/new_button', model: Consumer)

View File

@ -15,3 +15,5 @@ h1 = ::Error.model_name.human(count: 2)
td = error.message
td = l(error.created_at, format: :short)
td = link_to(t('shared.show'), execution_environment_error_path(params[:execution_environment_id], error))
p = render('shared/pagination', collection: @errors)

View File

@ -20,4 +20,5 @@ h1 = ExecutionEnvironment.model_name.human(count: 2)
td = link_to(t('activerecord.models.error.other'), execution_environment_errors_path(execution_environment.id))
td = link_to(t('activerecord.models.hint.other'), execution_environment_hints_path(execution_environment.id))
= render('shared/pagination', collection: @execution_environments)
p = render('shared/new_button', model: ExecutionEnvironment)

View File

@ -35,4 +35,5 @@ h1 = Exercise.model_name.human(count: 2)
td = link_to(t('.implement'), implement_exercise_path(exercise))
td = link_to(t('shared.statistics'), statistics_exercise_path(exercise))
= render('shared/pagination', collection: @exercises)
p = render('shared/new_button', model: Exercise)

View File

@ -13,3 +13,5 @@ h1 = ExternalUser.model_name.human(count: 2)
td = user.name
td = link_to(user.consumer, user.consumer)
td = link_to(t('shared.show'), user)
= render('shared/pagination', collection: @users)

View File

@ -18,4 +18,5 @@ h1 = FileType.model_name.human(count: 2)
td = link_to(t('shared.edit'), edit_file_type_path(file_type))
td = link_to(t('shared.destroy'), file_type, data: {confirm: t('shared.confirm_destroy')}, method: :delete)
= render('shared/pagination', collection: @file_types)
p = render('shared/new_button', model: FileType)

View File

@ -16,4 +16,5 @@ h1 = Hint.model_name.human(count: 2)
td = link_to(t('shared.edit'), edit_execution_environment_hint_path(params[:execution_environment_id], hint.id))
td = link_to(t('shared.destroy'), execution_environment_hint_path(params[:execution_environment_id], hint.id), data: {confirm: t('shared.confirm_destroy')}, method: :delete)
= render('shared/pagination', collection: @hints)
p = render('shared/new_button', model: Hint, path: new_execution_environment_hint_path(params[:execution_environment_id]))

View File

@ -31,4 +31,5 @@ h1 = InternalUser.model_name.human(count: 2)
- if policy(user).destroy?
= link_to(t('shared.destroy'), user, data: {confirm: t('shared.confirm_destroy')}, method: :delete)
= render('shared/pagination', collection: @users)
p = render('shared/new_button', model: InternalUser)

View File

@ -0,0 +1,3 @@
- if (pagination = will_paginate(collection, container: false)).present?
.text-center
ul.pagination = pagination

View File

@ -29,5 +29,4 @@ h1 = Submission.model_name.human(count: 2)
td = link_to(t('shared.show'), submission)
td = link_to(t('shared.statistics'), statistics_submission_path(submission))
.text-center
ul.pagination = will_paginate(@submissions, container: false)
= render('shared/pagination', collection: @submissions)

View File

@ -16,4 +16,5 @@ h1 = Team.model_name.human(count: 2)
td = link_to(t('shared.edit'), edit_team_path(team.id))
td = link_to(t('shared.destroy'), team_path(team.id), data: {confirm: t('shared.confirm_destroy')}, method: :delete)
= render('shared/pagination', collection: @teams)
p = render('shared/new_button', model: Team, path: new_team_path)