Added badges to users and pagination
This commit is contained in:
parent
bccb292441
commit
9aaf3b4718
2 changed files with 32 additions and 7 deletions
|
@ -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 {
|
||||
|
|
|
@ -12,11 +12,30 @@
|
|||
</div>
|
||||
% }
|
||||
<div class="list-group">
|
||||
% for my $user (@$users) {
|
||||
<a href="<%= url_for . '/' . $user->{id} %>" class="list-group-item list-group-item-action">
|
||||
<div>
|
||||
%= $user->{email}
|
||||
% for my $user ($user_rs->all) {
|
||||
<a href="<%= url_for . '/' . $user->id %>" class="list-group-item list-group-item-action">
|
||||
<div class="row">
|
||||
<div class="col-4">
|
||||
%= $user->name
|
||||
</div>
|
||||
<div class="col-4 text-center">
|
||||
%= $user->email
|
||||
</div>
|
||||
<div class="col-4 text-right">
|
||||
% if ( $user->type eq 'customer' ) {
|
||||
<span class="badge badge-success">Customer</span>
|
||||
% } elsif ( $user->type eq 'organisation' ) {
|
||||
<span class="badge badge-info">Organisation</span>
|
||||
% } else {
|
||||
<span class="badge badge-danger">Unknown</span>
|
||||
% }
|
||||
</div>
|
||||
</div>
|
||||
</a>
|
||||
% }
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col">
|
||||
%= bootstrap_pagination( $c->param('page') || 1, $user_rs->pager->last_page, { class => 'justify-content-center' } );
|
||||
</div>
|
||||
</div>
|
||||
|
|
Reference in a new issue