Lines 391-403
sub _convert_facets {
Link Here
|
391 |
|
391 |
|
392 |
# These should correspond to the ES field names, as opposed to the CCL |
392 |
# These should correspond to the ES field names, as opposed to the CCL |
393 |
# things that zebra uses. |
393 |
# things that zebra uses. |
|
|
394 |
# TODO let the library define the order using the interface. |
394 |
my %type_to_label = ( |
395 |
my %type_to_label = ( |
395 |
author => 'Authors', |
396 |
author => { order => 1, label => 'Authors', }, |
396 |
location => 'Location', |
397 |
itype => { order => 2, label => 'ItemTypes', }, |
397 |
itype => 'ItemTypes', |
398 |
location => { order => 3, label => 'Location', }, |
398 |
se => 'Series', |
399 |
'su-geo' => { order => 4, label => 'Places', }, |
399 |
subject => 'Topics', |
400 |
se => { order => 5, label => 'Series', }, |
400 |
'su-geo' => 'Places', |
401 |
subject => { order => 6, label => 'Topics', }, |
401 |
); |
402 |
); |
402 |
|
403 |
|
403 |
# We also have some special cases, e.g. itypes that need to show the |
404 |
# We also have some special cases, e.g. itypes that need to show the |
Lines 409-415
sub _convert_facets {
Link Here
|
409 |
itype => { map { $_->itemtype => $_->description } @itypes }, |
410 |
itype => { map { $_->itemtype => $_->description } @itypes }, |
410 |
location => { map { $_->authorised_value => ( $opac ? ( $_->lib_opac || $_->lib ) : $_->lib ) } @locations }, |
411 |
location => { map { $_->authorised_value => ( $opac ? ( $_->lib_opac || $_->lib ) : $_->lib ) } @locations }, |
411 |
); |
412 |
); |
412 |
my @res; |
413 |
my @facets; |
413 |
$exp_facet //= ''; |
414 |
$exp_facet //= ''; |
414 |
while ( ( $type, $data ) = each %$es ) { |
415 |
while ( ( $type, $data ) = each %$es ) { |
415 |
next if !exists( $type_to_label{$type} ); |
416 |
next if !exists( $type_to_label{$type} ); |
Lines 421-428
sub _convert_facets {
Link Here
|
421 |
expand => $type, |
422 |
expand => $type, |
422 |
expandable => ( $type ne $exp_facet ) |
423 |
expandable => ( $type ne $exp_facet ) |
423 |
&& ( @{ $data->{terms} } > $limit ), |
424 |
&& ( @{ $data->{terms} } > $limit ), |
424 |
"type_label_$type_to_label{$type}" => 1, |
425 |
"type_label_$type_to_label{$type}{label}" => 1, |
425 |
type_link_value => $type, |
426 |
type_link_value => $type, |
|
|
427 |
order => $type_to_label{$type}{order}, |
426 |
}; |
428 |
}; |
427 |
$limit = @{ $data->{terms} } if ( $limit > @{ $data->{terms} } ); |
429 |
$limit = @{ $data->{terms} } if ( $limit > @{ $data->{terms} } ); |
428 |
foreach my $term ( @{ $data->{terms} }[ 0 .. $limit - 1 ] ) { |
430 |
foreach my $term ( @{ $data->{terms} }[ 0 .. $limit - 1 ] ) { |
Lines 443-451
sub _convert_facets {
Link Here
|
443 |
type_link_value => $type, |
445 |
type_link_value => $type, |
444 |
}; |
446 |
}; |
445 |
} |
447 |
} |
446 |
push @res, $facet if exists $facet->{facets}; |
448 |
push @facets, $facet if exists $facet->{facets}; |
447 |
} |
449 |
} |
448 |
return \@res; |
450 |
|
|
|
451 |
@facets = sort { $a->{order} cmp $b->{order} } @facets; |
452 |
return \@facets; |
449 |
} |
453 |
} |
450 |
|
454 |
|
451 |
|
455 |
|