|
Lines 280-287
sub get_items {
Link Here
|
| 280 |
); |
280 |
); |
| 281 |
} |
281 |
} |
| 282 |
|
282 |
|
| 283 |
# FIXME We need to order_by serial.publisheddate if we have _order_by=+me.serial_issue_number |
283 |
my $items; |
| 284 |
my $items = $c->objects->search($items_rs); |
284 |
|
|
|
285 |
my $sort = $c->param('_order_by') // ''; |
| 286 |
my $args = $c->validation->output; |
| 287 |
|
| 288 |
if ( $sort =~ /^[+-]me\._status$/ && $args->{_order_by} ) { |
| 289 |
my $order_by = $args->{_order_by}; |
| 290 |
my @order_by = ref $order_by eq 'ARRAY' ? @$order_by : ($order_by); |
| 291 |
|
| 292 |
# Supprimer les tris sur champs virtuels comme me._status |
| 293 |
@order_by = grep { $_ !~ /^[-+]?me\._status$/ } @order_by; |
| 294 |
|
| 295 |
$args->{_order_by} = @order_by ? \@order_by : undef; |
| 296 |
delete $args->{_order_by} unless (@order_by); |
| 297 |
$items = $c->objects->search( $items_rs, $args ); |
| 298 |
if ( $sort eq '+me._status' ) { |
| 299 |
@$items = |
| 300 |
sort { join( ',', @{ $a->{_status} // [] } ) cmp join( ',', @{ $b->{_status} // [] } ) } @$items; |
| 301 |
} elsif ( $sort eq '-me._status' ) { |
| 302 |
@$items = |
| 303 |
sort { join( ',', @{ $b->{_status} // [] } ) cmp join( ',', @{ $a->{_status} // [] } ) } @$items; |
| 304 |
} |
| 305 |
} else { |
| 306 |
# FIXME We need to order_by serial.publisheddate if we have _order_by=+me.serial_issue_number |
| 307 |
$items = $c->objects->search($items_rs); |
| 308 |
} |
| 285 |
|
309 |
|
| 286 |
return $c->render( |
310 |
return $c->render( |
| 287 |
status => 200, |
311 |
status => 200, |