From 2c9fee0be73b4da03b54e0f179379d73899c3bcc Mon Sep 17 00:00:00 2001 From: Paudet Date: Wed, 19 Jul 2017 17:03:17 -0400 Subject: [PATCH] Bug 8643: Add hint for important fields and implemented it for item fields Signed-off-by: Katrin Fischer --- cataloguing/additem.pl | 1 + .../prog/en/modules/cataloguing/addbiblio.tt | 5 ++++ .../prog/en/modules/cataloguing/additem.tt | 34 +++++++++++++++++----- koha-tmpl/intranet-tmpl/prog/js/cataloging.js | 12 ++++++++ 4 files changed, 45 insertions(+), 7 deletions(-) diff --git a/cataloguing/additem.pl b/cataloguing/additem.pl index a6aa25cd0e..f5e0d755b5 100755 --- a/cataloguing/additem.pl +++ b/cataloguing/additem.pl @@ -125,6 +125,7 @@ sub generate_subfield_form { $subfield_data{subfield} = $subfieldtag; $subfield_data{marc_lib} ="{lib}."\">".$subfieldlib->{lib}.""; $subfield_data{mandatory} = $subfieldlib->{mandatory}; + $subfield_data{important} = $subfieldlib->{important}; $subfield_data{repeatable} = $subfieldlib->{repeatable}; $subfield_data{maxlength} = $subfieldlib->{maxlength}; 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 c92d51e62d..8134c714ed 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/addbiblio.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/addbiblio.tt @@ -577,6 +577,11 @@ function Changefwk() { [% innerloo.tag %] [% ELSE %] [% innerloo.tag %] + [% IF innerloo.mandatory %] + * + [% ELSIF innerloo.important %] + * + [% END %] [% IF marcflavour != 'NORMARC' %] ?[% END %] [% END %] [% IF ( innerloo.fixedfield ) %] 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 8df082e259..f037de1c11 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/additem.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/additem.tt @@ -88,8 +88,10 @@ $(document).ready(function(){ }); function Check(f) { - var total_errors = CheckMandatorySubfields(f); - if (total_errors==0) { + var total_mandatory = CheckMandatorySubfields(f); + var total_important = CheckImportantSubfields(f); + var alertString2; + if (total_mandatory==0) { // Explanation about this line: // In case of limited edition permission, we have to prevent user from modifying some fields. // But there is no such thing as readonly attribute for select elements. @@ -97,12 +99,27 @@ function Check(f) { // So we "un-disable" the elements just before submitting. // That's a bit clumsy, and if someone comes up with a better solution, feel free to improve that. $("select[name=field_value]").prop('disabled', false); - return true; } else { - var alertString2 = _("Form not submitted because of the following problem(s)"); + alertString2 = _("Form not submitted because of the following problem(s)"); alertString2 += "\n------------------------------------------------------------------------------------\n"; - alertString2 += "\n- " + _("%s mandatory fields empty (highlighted)").format(total_errors); - alert(alertString2); + alertString2 += "\n- " + _("%s mandatory fields empty (highlighted)").format(total_mandatory); + } + if(total_important > 0){ + if( !alertString2 ){ + alertString2 = ""; + } + alertString2 += "\n\n " + _("%s important field(s) empty (highlighted)").format(total_important); + alertString2 += "\n\n " + _("Are you sure you want to save?"); + } + if(alertString2){ + if(total_mandatory){ + alert(alertString2); + }else{ + var a = confirm(alertString2); + if( a ){ + return true; + } + } return false; } return true; @@ -320,12 +337,15 @@ function confirm_deletion() { + [% IF ( ite.repeatable ) %] Clone [% END %] - [% IF ( ite.mandatory ) %] Required[% END %] + [% IF ( ite.mandatory ) %] Required + [% ELSIF ( ite.important ) %] Important + [% END %] [% END %] diff --git a/koha-tmpl/intranet-tmpl/prog/js/cataloging.js b/koha-tmpl/intranet-tmpl/prog/js/cataloging.js index b685c2ac73..7a417b497c 100644 --- a/koha-tmpl/intranet-tmpl/prog/js/cataloging.js +++ b/koha-tmpl/intranet-tmpl/prog/js/cataloging.js @@ -557,6 +557,18 @@ function CheckMandatorySubfields(p){ return total; } +function CheckImportantSubfields(p){ + var total = 0; + $(p).find(".subfield_line input[name='important'][value='1']").each(function(i){ + var editor = $(this).siblings("[name='field_value']"); + if (!editor.val()) { + editor.addClass("missing"); + total++; + } + }); + return total; +} + $(document).ready(function() { $("input.input_marceditor, input.indicator").addClass('noEnterSubmit'); }); -- 2.14.1