From dcd5896cea2f3962a8163631b24a5e0d017c2e26 Mon Sep 17 00:00:00 2001 From: Tom Bloor Date: Tue, 24 Oct 2017 13:31:04 +0100 Subject: [PATCH] Added pagination to organisation listings --- lib/Pear/LocalLoop/Controller/Admin/Organisations.pm | 9 ++++++++- templates/admin/organisations/list.html.ep | 7 ++++++- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/lib/Pear/LocalLoop/Controller/Admin/Organisations.pm b/lib/Pear/LocalLoop/Controller/Admin/Organisations.pm index 31f92b2..78d8460 100644 --- a/lib/Pear/LocalLoop/Controller/Admin/Organisations.pm +++ b/lib/Pear/LocalLoop/Controller/Admin/Organisations.pm @@ -6,7 +6,14 @@ use Try::Tiny; sub list { my $c = shift; - my $orgs_rs = $c->schema->resultset('Organisation'); + my $orgs_rs = $c->schema->resultset('Organisation')->search( + undef, + { + page => $c->param('page') || 1, + rows => 10, + order_by => { -asc => 'name' }, + }, + ); $c->stash( orgs_rs => $orgs_rs, diff --git a/templates/admin/organisations/list.html.ep b/templates/admin/organisations/list.html.ep index de43a90..ac9b90e 100644 --- a/templates/admin/organisations/list.html.ep +++ b/templates/admin/organisations/list.html.ep @@ -11,7 +11,7 @@ Success! <%= $success %> % } -
+

@@ -35,3 +35,8 @@

+
+
+ %= bootstrap_pagination( $c->param('page') || 1, $orgs_rs->pager->last_page, { class => 'justify-content-center' } ); +
+