Added toggling of actioned on feedback, and view change for lists

This commit is contained in:
Tom Bloor 2017-10-23 16:09:20 +01:00
parent 0302a3d299
commit de90fe1f77
6 changed files with 50 additions and 5 deletions

View file

@ -191,6 +191,7 @@ sub startup {
$admin_routes->get('/feedback')->to('admin-feedback#index'); $admin_routes->get('/feedback')->to('admin-feedback#index');
$admin_routes->get('/feedback/:id')->to('admin-feedback#read'); $admin_routes->get('/feedback/:id')->to('admin-feedback#read');
$admin_routes->get('/feedback/:id/actioned')->to('admin-feedback#actioned');
$admin_routes->get('/transactions')->to('admin-transactions#index'); $admin_routes->get('/transactions')->to('admin-transactions#index');
$admin_routes->get('/transactions/:id')->to('admin-transactions#read'); $admin_routes->get('/transactions/:id')->to('admin-transactions#read');

View file

@ -18,6 +18,8 @@ sub home {
my $token_rs = $c->schema->resultset('AccountToken'); my $token_rs = $c->schema->resultset('AccountToken');
my $pending_orgs_rs = $c->schema->resultset('Organisation')->search({ pending => 1 }); my $pending_orgs_rs = $c->schema->resultset('Organisation')->search({ pending => 1 });
my $pending_transaction_rs = $pending_orgs_rs->entity->sales; my $pending_transaction_rs = $pending_orgs_rs->entity->sales;
my $feedback_rs = $c->schema->resultset('Feedback');
my $pending_feedback_rs = $feedback_rs->search({ actioned => 0 });
$c->stash( $c->stash(
user_count => $user_rs->count, user_count => $user_rs->count,
tokens => { tokens => {
@ -26,6 +28,10 @@ sub home {
}, },
pending_orgs => $pending_orgs_rs->count, pending_orgs => $pending_orgs_rs->count,
pending_trans => $pending_transaction_rs->count, pending_trans => $pending_transaction_rs->count,
feedback => {
total => $feedback_rs->count,
pending => $pending_feedback_rs->count,
},
); );
} }

View file

@ -33,4 +33,19 @@ sub read {
} }
} }
sub actioned {
my $c = shift;
my $id = $c->param('id');
if ( my $feedback = $c->result_set->find($id) ) {
$feedback->actioned( ! $feedback->actioned );
$feedback->update;
$c->redirect_to( '/admin/feedback/' . $id );
} else {
$c->flash( error => 'No Feedback found' );
$c->redirect_to( '/admin/feedback' );
}
}
1; 1;

View file

@ -15,7 +15,7 @@
% for my $feedback ( $feedback_rs->all ) { % for my $feedback ( $feedback_rs->all ) {
<div class="col col-md-4 mb-3"> <div class="col col-md-4 mb-3">
<div class="card"> <div class="card">
<div class="card-header"> <div class="card-header<%= $feedback->actioned ? '' : ' text-white bg-danger' %>">
<span class="font-bold"><%= $feedback->id %></span> <span class="font-bold"><%= $feedback->id %></span>
%= $feedback->user->email; %= $feedback->user->email;
</div> </div>

View file

@ -30,6 +30,15 @@
<span>Submitted At:</span> <span>Submitted At:</span>
<span><%= format_human_datetime $feedback->submitted_at %></span> <span><%= format_human_datetime $feedback->submitted_at %></span>
</li> </li>
<li class="list-group-item d-flex justify-content-between">
<span>Actioned:</span>
<span>
<%= $feedback->actioned ? 'Done' : 'Needs Action' %>
<a class="btn btn-sm btn-success" href="<%= url_for . '/actioned' %>">
Toggle
</a>
</span>
</li>
</ul> </ul>
</div> </div>
</div> </div>

View file

@ -3,7 +3,7 @@
% content_for javascript => begin % content_for javascript => begin
% end % end
<div class="card-deck"> <div class="card-deck">
<div class="card text-center text-white bg-primary"> <div class="card mb-3 text-center text-white bg-primary">
<div class="card-header card-inverse"> <div class="card-header card-inverse">
User Count User Count
</div> </div>
@ -13,7 +13,7 @@
</h2> </h2>
</div> </div>
</div> </div>
<div class="card text-center text-white bg-success"> <div class="card mb-3 text-center text-white bg-success">
<div class="card-header card-inverse"> <div class="card-header card-inverse">
Unused Tokens Unused Tokens
</div> </div>
@ -23,7 +23,9 @@
</h2> </h2>
</div> </div>
</div> </div>
<div class="card text-center text-white bg-danger"> </div>
<div class="card-deck">
<div class="card mb-3 text-center text-white bg-danger">
<div class="card-header card-inverse"> <div class="card-header card-inverse">
Pending Organisations Pending Organisations
</div> </div>
@ -33,7 +35,7 @@
</h2> </h2>
</div> </div>
</div> </div>
<div class="card text-center text-white bg-danger"> <div class="card mb-3 text-center text-white bg-danger">
<div class="card-header card-inverse"> <div class="card-header card-inverse">
Pending Transactions Pending Transactions
</div> </div>
@ -44,3 +46,15 @@
</div> </div>
</div> </div>
</div> </div>
<div class="card-deck">
<div class="card mb-3 text-center text-white bg-danger">
<div class="card-header card-inverse">
Unactioned Feedback
</div>
<div class="card-body">
<h2 class="card-title">
<%= $feedback->{pending} %> / <%= $feedback->{total} %>
</h2>
</div>
</div>
</div>