$_->SUPER::delete for @{ $r->objects || [] };
$r->objects([ $self->retrieve_all ]);
$r->{template} = "list";
- $self->list;
+ $self->list($r);
}
sub stringify_column {
my %values = map { $_ => {$oper, $params{$_} } }
grep { $params{$_} and $fields{$_} } keys %params;
- $self = $self->do_pager($r);
- $r->objects([ %values ? $self->search_where(%values) : $self->retrieve_all ]);
$r->template("list");
+ if (!%values) { return $self->list($r) }
+ $self = $self->do_pager($r);
+ my $order = $self->order($r);
+ $r->objects([ $self->search_where(\%values),
+ ($order ? { order => $order } : ())
+ ]);
$r->{template_args}{search} = 1;
}
} else { return $self }
}
-sub list :Exported {
+sub order {
my ($self, $r) = @_;
- my %ok_columns = map {$_ => 1} $self->columns;
- $self = $self->do_pager($r);
my $order;
+ my %ok_columns = map {$_ => 1} $self->columns;
if ($order = $r->query->{order} and $ok_columns{$order}) {
- $r->objects([ $self->retrieve_all_sorted_by( $order.
- ($r->query->{o2} eq "desc" && " DESC")
- )]);
+ $order .= ($r->query->{o2} eq "desc" && " DESC")
+ }
+ $order;
+}
+
+sub list :Exported {
+ my ($self, $r) = @_;
+ $self = $self->do_pager($r);
+ my $order = $self->order($r);
+ if ($order) {
+ $r->objects([ $self->retrieve_all_sorted_by( $order )]);
} else {
$r->objects([ $self->retrieve_all ]);
}