From eec37fbd240e9df93fa140b68463d621a2e000ee Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Fri, 12 Jun 2020 18:11:41 +0200 Subject: [PATCH] Bug 19361: Add a tooltip warning if value not in AV list (This patch depends on bug 25728) When cataloguing it may happen that a previous value of a subfield is not longer in the list of AVs. Prior to this patch the value was removed. This patch suggests to display a tooltip next to the problematic subfield. If nothing is done, the value is kept. This patch work when cataloguing a bibliographic record, and adding/editing items. It could be implemented easily for authority cataloguing. --- cataloguing/addbiblio.pl | 1 + cataloguing/additem.pl | 2 ++ .../prog/en/modules/cataloguing/addbiblio.tt | 5 ++++- .../intranet-tmpl/prog/en/modules/cataloguing/additem.tt | 8 ++++++-- koha-tmpl/intranet-tmpl/prog/js/cataloging.js | 9 +++++++++ 5 files changed, 22 insertions(+), 3 deletions(-) diff --git a/cataloguing/addbiblio.pl b/cataloguing/addbiblio.pl index d8d376ea4f..6386cf9ef5 100755 --- a/cataloguing/addbiblio.pl +++ b/cataloguing/addbiblio.pl @@ -227,6 +227,7 @@ sub build_authorized_values_list { name => "tag_".$tag."_subfield_".$subfield."_".$index_tag."_".$index_subfield, default => $value, values => \@authorised_values, + not_in_av => ( ( grep { $_ eq $value } @authorised_values ) ? 0 : 1 ), labels => \%authorised_lib, ( ( grep { $_ eq $category } ( qw(branches itemtypes cn_source) ) ) ? () : ( category => $category ) ), }; diff --git a/cataloguing/additem.pl b/cataloguing/additem.pl index 89b72690f5..e2e9cb5882 100755 --- a/cataloguing/additem.pl +++ b/cataloguing/additem.pl @@ -231,6 +231,7 @@ sub generate_subfield_form { id => $subfield_data{id}, maxlength => $subfield_data{maxlength}, value => $value, + not_in_av => ( ( grep { $_ eq $value } @authorised_values ) ? 0 : 1 ), ( ( grep { $_ eq $subfieldlib->{authorised_value}} ( qw(branches itemtypes cn_source) ) ) ? () : ( category => $subfieldlib->{authorised_value}) ), }; } @@ -241,6 +242,7 @@ sub generate_subfield_form { values => \@authorised_values, labels => \%authorised_lib, default => $value, + not_in_av => ( ( grep { $_ eq $value } @authorised_values ) ? 0 : 1 ), ( ( grep { $_ eq $subfieldlib->{authorised_value}} ( qw(branches itemtypes cn_source) ) ) ? () : ( category => $subfieldlib->{authorised_value}) ), }; } diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/addbiblio.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/addbiblio.tt index e5fdff84de..3e9ee85982 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/addbiblio.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/addbiblio.tt @@ -843,7 +843,10 @@ [% ELSIF ( mv.type == 'textarea' ) %] [% ELSIF ( mv.type == 'select' ) %] - + [% IF mv.not_in_av %] + + [% END %] [% FOREACH aval IN mv.values %] [% IF aval == mv.default %] diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/additem.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/additem.tt index e82b5c9262..077967f587 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/additem.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/additem.tt @@ -151,9 +151,13 @@ [% ELSIF ( mv.type == 'select' ) %] [% IF ( mv.readonly ) %] - [% ELSE %] - + [% END %] + + [% IF mv.not_in_av %] + [% END %] [% FOREACH aval IN mv.values %] [% IF aval == mv.default %] diff --git a/koha-tmpl/intranet-tmpl/prog/js/cataloging.js b/koha-tmpl/intranet-tmpl/prog/js/cataloging.js index fd462b67ed..47d8548aa9 100644 --- a/koha-tmpl/intranet-tmpl/prog/js/cataloging.js +++ b/koha-tmpl/intranet-tmpl/prog/js/cataloging.js @@ -576,4 +576,13 @@ $(document).ready(function() { }); return false; }); + + var tooltip_msg = _("The selected value is not in the list of authorised values!"); + $("select[data-not_av='1']").each(function(){ + var li = $(this).parent(); + var tooltip = $(''); + $(tooltip).tooltip(); + $(li).append(tooltip); + }); + }); -- 2.20.1