Bug 29016: (QA follow-up) Restore biblio<->item log expansion
The catalog detail page links to the modification log with
modules=CATALOGUING&object_type=biblio&object=<biblionumber>. The old
server-rendered viewer matched both biblio-level entries (object =
biblionumber, info LIKE 'biblio%') and item-level entries (object IN
(itemnumbers of this biblio), info LIKE 'item%'). Converting to the
AJAX DataTable kept that expansion only in the CSV export branch, so
the on-screen view silently dropped item-level history.
Recreate the expansion in the AJAX path:
* tools/viewlog.pl: when (single CATALOGUING module + object_type
=biblio + non-empty object) collect the biblio's itemnumbers and
expose them, along with object_type, to the template.
* viewlog.tt: include object_type and biblio_itemnumbers in the
search_params JSON the inline script builds for the JS.
* viewlog.js: when those params are present, build the same -or
clause the old SQL produced and skip the regular per-object filter.
The info substring filter is also suppressed in that branch (the
old code did the same: it dropped %info% in favour of the -or).
Test plan:
1. Enable CataloguingLog.
2. Edit the biblio and a couple of its items.
3. From the biblio detail page, open "Modification log".
4. Verify the table shows both the biblio MODIFY rows and the item
MODIFY rows for that biblio (and only those).
5. From Tools -> Log viewer, plain Cataloguing filter still returns
the unfiltered log set as before.
Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
This commit is contained in:
parent
19df8f3dfc
commit
c6a8634ff5
|
|
@ -351,6 +351,8 @@
|
|||
actions: [% To.json(actions || []) | $raw %],
|
||||
interfaces: [% To.json(interfaces || []) | $raw %],
|
||||
object: "[% object | html %]",
|
||||
object_type: "[% object_type | html %]",
|
||||
biblio_itemnumbers: [% To.json(biblio_itemnumbers || []) | $raw %],
|
||||
info: "[% info | html %]",
|
||||
datefrom: "[% datefrom | html %]",
|
||||
dateto: "[% dateto | html %]",
|
||||
|
|
|
|||
|
|
@ -419,11 +419,33 @@ function buildApiFilters(params) {
|
|||
filters.user = params.user;
|
||||
}
|
||||
|
||||
if (params.object) {
|
||||
// Cataloguing modification log: object_type=biblio means we should
|
||||
// surface biblio-level changes ("biblio%") on the biblionumber AND
|
||||
// item-level changes ("item%") on each of the biblio's itemnumbers
|
||||
// (computed server-side and passed in via biblio_itemnumbers).
|
||||
var biblio_expansion = false;
|
||||
if (
|
||||
params.object &&
|
||||
params.object_type === "biblio" &&
|
||||
params.modules &&
|
||||
params.modules.length === 1 &&
|
||||
params.modules[0] === "CATALOGUING"
|
||||
) {
|
||||
var itemnumbers = params.biblio_itemnumbers || [];
|
||||
var or_clauses = [{ object: params.object, info: { like: "biblio%" } }];
|
||||
if (itemnumbers.length) {
|
||||
or_clauses.push({
|
||||
object: itemnumbers,
|
||||
info: { like: "item%" },
|
||||
});
|
||||
}
|
||||
filters["-or"] = or_clauses;
|
||||
biblio_expansion = true;
|
||||
} else if (params.object) {
|
||||
filters.object = params.object;
|
||||
}
|
||||
|
||||
if (params.info) {
|
||||
if (params.info && !biblio_expansion) {
|
||||
filters.info = { like: "%" + params.info + "%" };
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -30,6 +30,7 @@ use C4::Serials qw( CountSubscriptionFromBiblionumber );
|
|||
use C4::Search qw( enabled_staff_search_views );
|
||||
|
||||
use Koha::ActionLogs;
|
||||
use Koha::Biblios;
|
||||
use Koha::Database;
|
||||
use Koha::DateUtils qw( dt_from_string );
|
||||
use Koha::Items;
|
||||
|
|
@ -91,18 +92,34 @@ $template->param(
|
|||
if ($do_it) {
|
||||
if ( $output eq "screen" ) {
|
||||
|
||||
# Cataloguing modification log opens with modules=CATALOGUING and
|
||||
# object_type=biblio: surface item-level changes alongside the
|
||||
# biblio ones by collecting the biblio's itemnumbers and asking
|
||||
# the JS to filter on either object set. Mirrors the CSV export
|
||||
# branch below. The biblio object is also exposed so that the
|
||||
# biblio-view-menu sidebar can render its links.
|
||||
my $biblio;
|
||||
my @biblio_itemnumbers;
|
||||
if ( @modules == 1 && $object_type eq 'biblio' && $object ) {
|
||||
$biblio = Koha::Biblios->find($object);
|
||||
@biblio_itemnumbers = $biblio->items->get_column('itemnumber') if $biblio;
|
||||
}
|
||||
|
||||
# Screen output: pass search params to template, DataTable loads via REST API
|
||||
$template->param(
|
||||
logview => 1,
|
||||
do_it => 1,
|
||||
datefrom => $datefrom,
|
||||
dateto => $dateto,
|
||||
user => $user,
|
||||
info => $info,
|
||||
src => $src,
|
||||
modules => \@modules,
|
||||
actions => \@actions,
|
||||
interfaces => \@interfaces
|
||||
logview => 1,
|
||||
do_it => 1,
|
||||
datefrom => $datefrom,
|
||||
dateto => $dateto,
|
||||
user => $user,
|
||||
info => $info,
|
||||
src => $src,
|
||||
modules => \@modules,
|
||||
actions => \@actions,
|
||||
interfaces => \@interfaces,
|
||||
object_type => $object_type,
|
||||
biblio => $biblio,
|
||||
biblio_itemnumbers => \@biblio_itemnumbers,
|
||||
);
|
||||
|
||||
# Used modules
|
||||
|
|
|
|||
Loading…
Reference in New Issue