Bug 41602: Allow _status to be in nested structure

This patch allows _status to be in a nested structure.

Cannot be combined in all the possible ways, but at least it should fix
the UI.

Test plan:
Use the filters on the holdings table and confirm that you can combine
the status with other filters.

Signed-off-by: David Nind <david@davidnind.com>
Signed-off-by: Lisette Scheer <lisette@bywatersolutions.com>
Signed-off-by: Pedro Amorim <pedro.amorim@openfifth.co.uk>
This commit is contained in:
Jonathan Druart 2026-01-22 15:32:39 +01:00 committed by Pedro Amorim
parent 128c24d58c
commit 134fe95444
No known key found for this signature in database
GPG Key ID: 06B75BA7F3894D55
1 changed files with 34 additions and 1 deletions

View File

@ -662,9 +662,42 @@ Filters items based on the specified status.
=cut
sub _extract_custom_attrs {
my ($params) = @_;
my %custom_attrs;
my $clean_params = _process_params( $params, \%custom_attrs );
return ( \%custom_attrs, $clean_params );
}
sub _process_params {
my ( $params, $custom_attrs ) = @_;
return $params unless ref $params;
if ( ref $params eq 'HASH' ) {
my %clean;
for my $key ( keys %$params ) {
if ( $key =~ /^_(.+)/ ) {
$custom_attrs->{$key} = $params->{$key};
} else {
$clean{$key} = _process_params( $params->{$key}, $custom_attrs );
}
}
return \%clean;
} elsif ( ref $params eq 'ARRAY' ) {
return [ map { _process_params( $_, $custom_attrs ) } @$params ];
} else {
return $params;
}
}
sub search {
my ( $self, $params, $attributes ) = @_;
my $status = ( $params && ref($params) eq 'HASH' ) ? delete $params->{_status} : undef;
my ( $custom_attrs, $clean_params ) = _extract_custom_attrs($params);
$params = $clean_params;
my $status = $custom_attrs->{_status};
if ($status) {
if ( $status eq 'checked_out' ) {
$self = $self->filter_by_checked_out( { onsite_checkout => 0 } );