Combine organisation lists into one with badges for warnings

This commit is contained in:
Tom Bloor 2017-10-23 17:44:38 +01:00
parent 11d6785062
commit ed8607fd35
2 changed files with 11 additions and 29 deletions

View file

@ -6,12 +6,10 @@ use Try::Tiny;
sub list { sub list {
my $c = shift; my $c = shift;
my $valid_orgs_rs = $c->schema->resultset('Organisation')->search({ pending => 0 }); my $orgs_rs = $c->schema->resultset('Organisation');
my $pending_orgs_rs = $c->schema->resultset('Organisation')->search({ pending => 1 });
$c->stash( $c->stash(
valid_orgs_rs => $valid_orgs_rs, orgs_rs => $orgs_rs,
pending_orgs_rs => $pending_orgs_rs,
); );
} }

View file

@ -15,39 +15,23 @@
<div class="col"> <div class="col">
<div class="card"> <div class="card">
<h3 class="card-header"> <h3 class="card-header">
Valid Organisations Organisations
<a href="<%= url_for . '/add' %>" class="btn btn-success" style="float: right">Add Organisation</a> <a href="<%= url_for . '/add' %>" class="btn btn-success" style="float: right">Add Organisation</a>
</h3> </h3>
<div class="list-group list-group-flush"> <div class="list-group list-group-flush">
% for my $valid_org ($valid_orgs_rs->all) { % for my $org_result ($orgs_rs->all) {
<a href="<%= url_for . '/' . $valid_org->id %>" class="list-group-item list-group-item-action"> <a href="<%= url_for . '/' . $org_result->id %>" class="list-group-item list-group-item-action d-flex justify-content-between">
<div> <div>
%= $valid_org->name %= $org_result->name
</div>
<div>
% if ( $org_result->pending ) {
<span class="badge badge-warning">Unvalidated</span>
% }
</div> </div>
</a> </a>
% } % }
</div> </div>
</div> </div>
</div> </div>
<div class="col">
<div class="card">
<h3 class="card-header">
Pending Organisations
</h3>
<div class="list-group list-group-flush">
% if ( $pending_orgs_rs->count == 0 ) {
<div class="list-group-item">
No Pending Organisations!
</div>
% } else {
% for my $pending_org ($pending_orgs_rs->all) {
<a href="<%= url_for . '/' . $pending_org->id %>" class="list-group-item list-group-item-action">
<div>
%= $pending_org->name
</div>
</a>
% }}
</div>
</div>
</div>
</div> </div>