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/: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/:id')->to('admin-transactions#read');

View file

@ -18,6 +18,8 @@ sub home {
my $token_rs = $c->schema->resultset('AccountToken');
my $pending_orgs_rs = $c->schema->resultset('Organisation')->search({ pending => 1 });
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(
user_count => $user_rs->count,
tokens => {
@ -26,6 +28,10 @@ sub home {
},
pending_orgs => $pending_orgs_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;

View file

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

View file

@ -30,6 +30,15 @@
<span>Submitted At:</span>
<span><%= format_human_datetime $feedback->submitted_at %></span>
</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>
</div>
</div>

View file

@ -3,7 +3,7 @@
% content_for javascript => begin
% end
<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">
User Count
</div>
@ -13,7 +13,7 @@
</h2>
</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">
Unused Tokens
</div>
@ -23,7 +23,9 @@
</h2>
</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">
Pending Organisations
</div>
@ -33,7 +35,7 @@
</h2>
</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">
Pending Transactions
</div>
@ -44,3 +46,15 @@
</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>