X-Git-Url: http://git.ieval.ro/?a=blobdiff_plain;f=lib%2FGruntmaster%2FPage%2FGeneric.pm;h=fe9525dc44a1feb392f30f290adcdd9450d0896f;hb=8e0d50d43afb77675f39bb30a4355048e6aae57e;hp=256add635bed2a31ed85d929cab7e710722ea57f;hpb=491e82eb192b76e7e8eece5aaf43b7aebb81a12d;p=plack-app-gruntmaster.git diff --git a/lib/Gruntmaster/Page/Generic.pm b/lib/Gruntmaster/Page/Generic.pm index 256add6..fe9525d 100644 --- a/lib/Gruntmaster/Page/Generic.pm +++ b/lib/Gruntmaster/Page/Generic.pm @@ -37,6 +37,7 @@ sub list { $rs = $rs->search(undef, {order_by => 'me.id'}) unless $rs->is_ordered; if (my $page = $env->{'gruntmaster.page'}) { my $pages = $rs->count / PAGE_SIZE; + $page = $pages if $page == -1; $rs = $rs->search(undef, {offset => ($page - 1) * PAGE_SIZE, ($page == $pages ? () : (rows => PAGE_SIZE))}); } $rs = $rs->search(undef, {prefetch => $thing{prefetch}}) if exists $thing{prefetch}; @@ -72,7 +73,7 @@ sub create_thing { my $pkg = "Gruntmaster::Page::$ucid"; putsym "${pkg}::_generate", sub { $_[1]->param(list \%thing, @_[2..$#_]) } if makepkg $pkg, @thing{qw/id title/}; - putsym "${pkg}::Entry::_generate", sub { $_[1]->param(entry \%thing, @_[2..$#_]) } if makepkg "${pkg}::Entry", "$thing{id}_entry", ''; + putsym "${pkg}::Entry::_generate", sub { $_[1]->param(entry \%thing, @_[2..$#_]) } if makepkg "${pkg}::Entry", "$thing{id}_entry", $thing{entry_title} // ''; putsym "${pkg}::Read::generate", sub { [200, headers shift, [encode_json list \%thing, @_]] } if makepkg "${pkg}::Read"; putsym "${pkg}::Entry::Read::generate", sub { [200, headers shift, [encode_json entry \%thing, @_]] } if makepkg "${pkg}::Entry::Read"; } @@ -88,7 +89,7 @@ sub prefetch; sub thing (&){ my %thing; no strict 'refs'; - local *{"params"} = sub { @thing{qw/id rsname title/} = @_ }; + local *{"params"} = sub { @thing{qw/id rsname title entry_title/} = @_ }; local *{"choose"} = sub { $thing{choose} = shift }; local *{"sortby"} = sub { $thing{sortby} = shift }; local *{"mangle"} = sub { $thing{mangle} = shift }; @@ -144,7 +145,7 @@ thing { }; thing { - params qw/log Job/, 'Job log'; + params qw/log Job/, 'Job log', 'Job '; prefetch 'owner', 'problem'; makers { my $env = $_[0];