83370c519c
This commit adds support for displaying authority hierarchies for all flavours of MARC, not just UNIMARC. Display now uses the jQuery jstree plugin, selected with the help of Owen Leonard, resulting in a much faster experience for users. Be aware that the jstree file uses tabs rather than 4-space indentation, which I left as-is so as to make it easier to integrate upstream releases in the future. To test: 1) Enable the AuthDisplayHierarchy syspref 2) Create authority records with a hierarchy of see also fields (in MARC21/NORMARC, you'll be using 5xx fields for this, with a subfield $w=g for broader terms and subfield $w=h for narrower terms) 3) View the authorities in the OPAC, noting the hierarchical view at the top of the page. This initial patch does not create bidirection linkages from unidirectional links in MARC21 authorities. This means that when moving up the authority hierarchy, lower levels will disappear. This is intentional, as the first patch is intended merely to ensure that AuthDisplayHierarchy functions the same for all marcflavours. A future patch will add a cron job to generate the bidirectional linkages, once we are sure that the hierarchy functionality for UNIMARC and MARC21/NORMARC coexists peaceably. Signed-off-by: Katrin Fischer <Katrin.Fischer.83@web.de> Resolved conflicts in updatedatabase.pl, sysprefs.sql and in one of the CSS files. Test plan: 1) Run t/AuthoritiesMarc.t New tests complete without any errors. 2) Make sure updatedatabase works correctly. Update works nicely, new system preference is also added to syspref.sql 3) Make sure new terms are translatable. Created new po files for de-DE and checked for new terms. All translations appear correctly. 4) Make sure everything works with AuthDisplayHieararchy OFF - Add authority - Edit authority - Delete authority 5) Test feature with AuthDisplayHieararchy ON - Add authority - Edit authority - Delete authority 6) Add a couple of hierarchically linked authorities Note: links have to be created in both directions Example: 151 $aGermany 551 $a Baden-Württemberg $w h 151 $aBaden-Württemberg 551 $a Konstanz $w h 551 $a Germany $w g 151 $aKonstanz 551 $a Baden-Württemberg $w g 551 $a Fürstenberg $w h 551 $a Paradies $w h 151 $a Fürstenberg 551 $a Konstanz $w g 151 $a Paradies 551 $a Konstanz $w g Tree shows up nicely above the authority record - in staff - in OPAC - on the normal view tab - on the MARC view tab 7) Checking the logs for warnings - no Javascript errors or warnings - no warnings or errors in log files
98 lines
2.9 KiB
Perl
Executable file
98 lines
2.9 KiB
Perl
Executable file
#!/usr/bin/perl
|
|
#
|
|
# This Koha test module is a stub!
|
|
# Add more tests here!!!
|
|
|
|
use strict;
|
|
use warnings;
|
|
|
|
use Test::More tests => 5;
|
|
use Test::MockModule;
|
|
use MARC::Record;
|
|
|
|
BEGIN {
|
|
use_ok('C4::AuthoritiesMarc');
|
|
}
|
|
|
|
# We are now going to be testing the authorities hierarchy code, and
|
|
# therefore need to pretend that we have consistent data in our database
|
|
my $module = new Test::MockModule('C4::AuthoritiesMarc');
|
|
$module->mock('GetHeaderAuthority', sub {
|
|
return {'authtrees' => ''};
|
|
});
|
|
$module->mock('AddAuthorityTrees', sub {
|
|
return;
|
|
});
|
|
$module->mock('GetAuthority', sub {
|
|
my ($authid) = @_;
|
|
my $record = MARC::Record->new();
|
|
if ($authid eq '1') {
|
|
$record->add_fields(
|
|
[ '001', '1' ],
|
|
[ '151', ' ', ' ', a => 'United States' ]
|
|
);
|
|
} elsif ($authid eq '2') {
|
|
$record->add_fields(
|
|
[ '001', '2' ],
|
|
[ '151', ' ', ' ', a => 'New York (State)' ],
|
|
[ '551', ' ', ' ', a => 'United States', w => 'g', 9 => '1' ]
|
|
);
|
|
} elsif ($authid eq '3') {
|
|
$record->add_fields(
|
|
[ '001', '3' ],
|
|
[ '151', ' ', ' ', a => 'New York (City)' ],
|
|
[ '551', ' ', ' ', a => 'New York (State)', w => 'g', 9 => '2' ]
|
|
);
|
|
} elsif ($authid eq '4') {
|
|
$record->add_fields(
|
|
[ '001', '4' ],
|
|
[ '151', ' ', ' ', a => 'New York (City)' ],
|
|
[ '551', ' ', ' ', a => 'New York (State)', w => 'g' ]
|
|
);
|
|
} else {
|
|
undef $record;
|
|
}
|
|
return $record;
|
|
});
|
|
|
|
is(BuildAuthHierarchies(3, 1), '1,2,3', "Built linked authtrees hierarchy string");
|
|
|
|
my $expectedhierarchy = [ [ {
|
|
'authid' => '1',
|
|
'value' => 'United States',
|
|
'class' => 'child0',
|
|
'children' => [ {
|
|
'authid' => '2',
|
|
'value' => 'New York (State)',
|
|
'class' => 'child1',
|
|
'children' => [ {
|
|
'authid' => '3',
|
|
'current_value' => 1,
|
|
'value' => 'New York (City)',
|
|
'class' => 'child2',
|
|
'children' => [],
|
|
'parents' => [ {
|
|
'authid' => '2',
|
|
'value' => 'New York (State)'
|
|
} ]
|
|
} ],
|
|
'parents' => [ {
|
|
'authid' => '1',
|
|
'value' => 'United States'
|
|
} ]
|
|
} ],
|
|
'parents' => []
|
|
} ] ];
|
|
|
|
is_deeply(GenerateHierarchy(3), $expectedhierarchy, "Generated hierarchy data structure for linked hierarchy");
|
|
|
|
is(BuildAuthHierarchies(4, 1), '4', "Built unlinked authtrees hierarchy string");
|
|
$expectedhierarchy = [ [ {
|
|
'authid' => '4',
|
|
'current_value' => 1,
|
|
'value' => 'New York (City)',
|
|
'class' => 'child0',
|
|
'children' => [],
|
|
'parents' => []
|
|
} ] ];
|
|
is_deeply(GenerateHierarchy(4), $expectedhierarchy, "Generated hierarchy data structure for unlinked hierarchy");
|