fixed critical bugs introduced earlier and changed category viewing

This commit is contained in:
Finn 2018-03-14 19:38:05 +00:00
parent d5e03cc9e3
commit 551a40a9a0
2 changed files with 14 additions and 9 deletions

View file

@ -198,7 +198,7 @@ sub post_upload {
( defined $file ? ( proof_image => $file ) : () ), ( defined $file ? ( proof_image => $file ) : () ),
purchase_time => $c->format_db_datetime($purchase_time), purchase_time => $c->format_db_datetime($purchase_time),
essential => ( defined $essential ? $essential : 0 ), essential => ( defined $essential ? $essential : 0 ),
distance => ( defined $category ? $category : undef ), distance => $distance,
} }
); );
@ -227,7 +227,7 @@ sub post_upload {
value => $transaction_value * 100000, value => $transaction_value * 100000,
start_time => $c->format_db_datetime($purchase_time), start_time => $c->format_db_datetime($purchase_time),
essential => ( defined $essential ? $essential : 0 ), essential => ( defined $essential ? $essential : 0 ),
distance => ( defined $category ? $category : undef ), distance => $distance,
category_id => ( defined $category ? $category : undef ), category_id => ( defined $category ? $category : undef ),
recurring_period => $recurring_period, recurring_period => $recurring_period,
}); });
@ -243,18 +243,22 @@ sub post_category {
my $c = shift; my $c = shift;
my $self = $c; my $self = $c;
my $categories = { ids => [], names => [] };
my $category_rs = $c->schema->resultset('Category'); my $category_rs = $c->schema->resultset('Category');
for ( $category_rs->all ) { # for ( $category_rs->all ) {
push @{ $categories->{ ids } }, $_->get_column('id'); # push @{ $categories->{ ids } }, $_->get_column('id');
push @{ $categories->{ names } }, $_->get_column('name'); # push @{ $categories->{ names } }, $_->get_column('name');
} # }
my @category_list = (
map {{
id => $_->id,
name => $_->name,
}} $category_rs->all
);
return $self->render( json => { return $self->render( json => {
success => Mojo::JSON->true, success => Mojo::JSON->true,
categories => $categories, categories => \@category_list,
}); });
} }

View file

@ -66,6 +66,7 @@ sub register {
$app->helper( format_iso_datetime => sub { $app->helper( format_iso_datetime => sub {
my ( $c, $datetime_obj ) = @_; my ( $c, $datetime_obj ) = @_;
return unless defined $datetime_obj;
return $c->iso_datetime_parser->format_datetime( return $c->iso_datetime_parser->format_datetime(
$datetime_obj, $datetime_obj,
); );