$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};
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", '<tmpl_var name>';
+ putsym "${pkg}::Entry::_generate", sub { $_[1]->param(entry \%thing, @_[2..$#_]) } if makepkg "${pkg}::Entry", "$thing{id}_entry", $thing{entry_title} // '<tmpl_var name>';
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";
}
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 };
};
thing {
- params qw/log Job/, 'Job log';
+ params qw/log Job/, 'Job log', 'Job <tmpl_var id>';
prefetch 'owner', 'problem';
makers {
my $env = $_[0];