diff --git a/lib/Pear/LocalLoop/Controller/Admin/Users.pm b/lib/Pear/LocalLoop/Controller/Admin/Users.pm index 13905c6..e731d7b 100644 --- a/lib/Pear/LocalLoop/Controller/Admin/Users.pm +++ b/lib/Pear/LocalLoop/Controller/Admin/Users.pm @@ -22,9 +22,15 @@ has organisation_result_set => sub { sub index { my $c = shift; - my $user_rs = $c->user_result_set; - $user_rs->result_class('DBIx::Class::ResultClass::HashRefInflator'); - $c->stash( users => [ $user_rs->all ] ); + my $user_rs = $c->user_result_set->search( + undef, { + prefech => { entity => [ qw/ customer organisation / ] }, + page => $c->param('page') || 1, + rows => 10, + order_by => { -asc => 'email' }, + } + ); + $c->stash( user_rs => $user_rs ); } sub read { diff --git a/templates/admin/users/index.html.ep b/templates/admin/users/index.html.ep index b31330a..0728042 100644 --- a/templates/admin/users/index.html.ep +++ b/templates/admin/users/index.html.ep @@ -12,11 +12,30 @@ % }
- % for my $user (@$users) { - -
- %= $user->{email} + % for my $user ($user_rs->all) { + +
+
+ %= $user->name +
+
+ %= $user->email +
+
+ % if ( $user->type eq 'customer' ) { + Customer + % } elsif ( $user->type eq 'organisation' ) { + Organisation + % } else { + Unknown + % } +
% }
+
+
+ %= bootstrap_pagination( $c->param('page') || 1, $user_rs->pager->last_page, { class => 'justify-content-center' } ); +
+