Improved Feedback list page
This commit is contained in:
parent
4beb26a0a4
commit
c3519fa4df
5 changed files with 61 additions and 8 deletions
|
@ -9,8 +9,15 @@ has result_set => sub {
|
|||
sub index {
|
||||
my $c = shift;
|
||||
|
||||
my $feedback_rs = $c->result_set;
|
||||
$c->stash( feedbacks => [ $feedback_rs->all ] );
|
||||
my $feedback_rs = $c->result_set->search(
|
||||
undef,
|
||||
{
|
||||
page => $c->param('page') || 1,
|
||||
rows => 12,
|
||||
order_by => { -desc => 'submitted_at' },
|
||||
},
|
||||
);
|
||||
$c->stash( feedback_rs => $feedback_rs );
|
||||
}
|
||||
|
||||
sub read {
|
||||
|
|
|
@ -6,6 +6,17 @@ use DateTime::Format::Strptime;
|
|||
sub register {
|
||||
my ( $plugin, $app, $conf ) = @_;
|
||||
|
||||
$app->helper( human_datetime_parser => sub {
|
||||
return DateTime::Format::Strptime->new( pattern => '%x %X' );
|
||||
});
|
||||
|
||||
$app->helper( format_human_datetime => sub {
|
||||
my ( $c, $datetime_obj ) = @_;
|
||||
return $c->human_datetime_parser->format_datetime(
|
||||
$datetime_obj,
|
||||
);
|
||||
});
|
||||
|
||||
$app->helper( iso_datetime_parser => sub {
|
||||
return DateTime::Format::Strptime->new( pattern => '%Y-%m-%dT%H:%M:%S.%3N%z' );
|
||||
});
|
||||
|
|
18
lib/Pear/LocalLoop/Plugin/TemplateHelpers.pm
Normal file
18
lib/Pear/LocalLoop/Plugin/TemplateHelpers.pm
Normal file
|
@ -0,0 +1,18 @@
|
|||
package Pear::LocalLoop::Plugin::TemplateHelpers;
|
||||
use Mojo::Base 'Mojolicious::Plugin';
|
||||
|
||||
sub register {
|
||||
my ( $plugin, $app, $conf ) = @_;
|
||||
|
||||
$app->helper( truncate_text => sub {
|
||||
my ( $c, $string, $length ) = @_;
|
||||
if ( length $string < $length ) {
|
||||
return $string;
|
||||
} else {
|
||||
return substr( $string, 0, $length - 3 ) . '...';
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
1;
|
Reference in a new issue