added ability to edit icons and gt them in stats
This commit is contained in:
parent
4323e49cfc
commit
2b0abd2606
4 changed files with 26 additions and 3 deletions
|
@ -59,6 +59,7 @@ sub update {
|
|||
my $validation = $c->validation;
|
||||
$validation->required('id');
|
||||
$validation->required('category', 'trim')->like(qr/^[\w]*$/);
|
||||
$validation->optional('line_icon');
|
||||
|
||||
my $id = $c->param('id');
|
||||
|
||||
|
@ -70,6 +71,7 @@ sub update {
|
|||
$category->update({
|
||||
id => $validation->param('id'),
|
||||
name => $validation->param('category'),
|
||||
line_icon => (defined $validation->param('line_icon') ? $validation->param('line_icon') : undef ),
|
||||
});
|
||||
$c->flash( success => 'Category Updated' );
|
||||
$c->redirect_to( '/admin/categories/' . $validation->param('id') );
|
||||
|
|
|
@ -132,7 +132,9 @@ sub post_customer {
|
|||
$cat_total_list{$category_list->{$category}} += $value;
|
||||
}
|
||||
|
||||
my @cat_lists = map { { category => $_, value => $cat_total_list{$_} } } sort keys %cat_total_list;
|
||||
my @cat_lists = map { { category => $_, value => $cat_total_list{$_},
|
||||
icon => $c->schema->resultset('Category')->as_hash_name_icon->{$_} } } sort keys %cat_total_list;
|
||||
Dwarn @cat_lists;
|
||||
$data->{cat_list} = [ sort { $b->{value} <=> $a->{value} } @cat_lists ];
|
||||
|
||||
my $purchase_no_essential_rs = $purchase_rs->search({
|
||||
|
|
|
@ -19,4 +19,18 @@ sub as_hash {
|
|||
return \%category_list;
|
||||
}
|
||||
|
||||
sub as_hash_name_icon {
|
||||
my ( $self ) = @_;
|
||||
|
||||
my %category_list = (
|
||||
(
|
||||
map {
|
||||
$_->name => $_->line_icon,
|
||||
} $self->all
|
||||
),
|
||||
0 => 'Uncategorised',
|
||||
);
|
||||
return \%category_list;
|
||||
}
|
||||
|
||||
1;
|
||||
|
|
|
@ -13,14 +13,19 @@
|
|||
% }
|
||||
<form action="<%= url_for %>" method="post">
|
||||
<div class="form-group">
|
||||
<label for="category-name">Token Name</label>
|
||||
<label for="category-name">Category Name</label>
|
||||
<input id="category-name" type="text" class="form-control" placeholder="Token Text" name="category" value="<%= $category->name %>">
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="category-id">Token ID</label>
|
||||
<label for="category-id">Category ID</label>
|
||||
<input id="category-id" type="text" class="form-control" placeholder="Token ID" name="id" value="<%= $category->id %>">
|
||||
<p class="help-block">Do not change the ID unless <strong>absolutely</strong> necessary.</p>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="line-icon">Simple Line Icon</label>
|
||||
<input id="line-icon" type="text" class="form-control" placeholder="Icon text" name="line_icon" value="<%= $category->line_icon %>">
|
||||
<p class="help-block">See here for all possible options http://simplelineicons.com/.</p>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<button class="btn btn-primary form-control" type="submit">Update</button>
|
||||
</div>
|
||||
|
|
Reference in a new issue