From b7f2b2a2aa913ccdfa92bf1bcda85c4793d442db Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Tue, 8 Jan 2013 14:49:24 +0100 Subject: [PATCH] [PASSED QA] Bug 9366: On cataloguing each user can easily display tags or not If the syspref hide_marc is set to "don't display", tags are not shown by default. This patch adds a checkbox to hide/show tags directly on the cataloguing page. The value is stored in a cookie. Test plan: Enable/disable the sysprefs hide_marc and advancedMARCeditor in order to check if the display is according with what the user want. Reload the page and verify the value is kept. The first value of the cookie is retrieved from the hide_marc pref. Bonus: This patch removes the link "Show MARCtag documentation links" if the syspref advancedMARCeditor is enabled. Signed-off-by: Joel Aloi Signed-off-by: Katrin Fischer This works as described, the editor will remember the choices made by the cataloguer. Passes all tests and QA script. Notes: - The error messages for mandatory fields upon saving only give the tag number and not the description, so this might require to turn back on the tag display. - The advancedMARCeditor doesn't display the documentation links before and after the patch was applied. I think it could still be useful for an advanced cataloger to be able to look up information on a field quickly. --- .../prog/en/modules/cataloguing/addbiblio.tt | 108 +++++++++++++-------- 1 file changed, 67 insertions(+), 41 deletions(-) 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 cbe0a39..286e8b7 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/addbiblio.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/addbiblio.tt @@ -1,3 +1,4 @@ +[% USE Koha %] [% INCLUDE 'doc-head-open.inc' %] Koha › Cataloging › [% IF ( biblionumber ) %]Editing [% title |html %] (Record number [% biblionumber %])[% ELSE %]Add MARC record[% END %] [% INCLUDE 'doc-head-close.inc' %] @@ -42,6 +43,32 @@ hideMARCdocLinks(); } }); + + /* check cookie to hide/show marc tags*/ + var marctags_cookie = $.cookie("marctags_[% borrowernumber %]"); + if( marctags_cookie == 'false'){ + hideMARCTagLinks(); + $("#marcTagsSelect").removeAttr('checked'); + } else if( marctags_cookie == 'true'){ + showMARCTagLinks(); + $("#marcTagsSelect").attr('checked', 'checked'); + } else { + [% UNLESS Koha.Preference("hide_marc") %] + showMARCTagLinks(); + $("#marcTagsSelect").attr('checked', 'checked'); + [% ELSE %] + hideMARCTagLinks(); + $("#marcTagsSelect").removeAttr('checked'); + [% END %] + } + $("#marcTagsSelect").click(function(){ + if($(this).attr("checked")){ + showMARCTagLinks(); + } else { + hideMARCTagLinks(); + } + }); + $("#z3950search").click(function(){ if (confirm(_("Please note that this Z39.50 search could replace the current record."))){ PopupZ3950(); @@ -73,8 +100,7 @@ redirect("just_save", tab); return false; }); - - }); + }); function redirect(dest){ $("#redirect").attr("value",dest); @@ -147,7 +173,7 @@ function _UNIMARCFieldDoc(field) { } /* - * Functions to hide/show marc docs links + * Functions to hide/show marc docs and tags links */ function hideMARCdocLinks() { $(".marcdocs").hide(); @@ -159,6 +185,32 @@ function showMARCdocLinks() { $.cookie("marcdocs_[% borrowernumber %]",'true', { path: "/", expires: 365 }); } +function hideMARCTagLinks() { + $(".tagnum").hide(); + $(".subfieldcode").hide(); + $.cookie("marctags_[% borrowernumber %]",'false', { path: "/", expires: 365 }); +} +function showMARCTagLinks() { + $(".tagnum").show(); + $(".subfieldcode").show(); + $.cookie("marctags_[% borrowernumber %]",'true', { path: "/", expires: 365 }); +} + [% IF hide_marc %] + var hide = false; + [% ELSE %] + var hide = true; + [% END %] + $("#show_tags").change( function(){ + if ( $(this).is(':checked') ) { + $(".tagnum").show(); + $(".subfieldcode").show(); + } else { + } + } ); + $("#show_tags").attr("checked", !hide) + $("#show_tags").change(); + + /** * check if mandatory subfields are written */ @@ -339,8 +391,11 @@ function Changefwk(FwkList) { [% END %] -[% IF marcflavour != 'NORMARC' %] -
Show MARC tag documentation links
+[% IF marcflavour != 'NORMARC' AND NOT advancedMARCEditor %] +
+ + +
[% END %] [% UNLESS ( number ) %] @@ -437,8 +492,8 @@ function Changefwk(FwkList) { [% frameworkcodeloo.frameworktext %] [% END %] - - + + [% IF ( popup ) %] @@ -464,13 +519,11 @@ function Changefwk(FwkList) { [% IF ( innerloo.tag ) %]
- [% UNLESS hide_marc %] [% IF advancedMARCEditor %] [% innerloo.tag %] [% ELSE %] - [% innerloo.tag %] + [% innerloo.tag %] [% IF marcflavour != 'NORMARC' %] ?[% END %] - [% END %] [% IF ( innerloo.fixedfield ) %] [% END %] - - [% ELSE %] - [% IF ( innerloo.fixedfield ) %] - - - [% ELSE %] - - - [% END %] - [% END %] [% UNLESS advancedMARCEditor %] [% innerloo.tag_lib %] [% END %] [% IF ( innerloo.repeatable ) %] - + Repeat this Tag [% END %] @@ -546,14 +578,13 @@ function Changefwk(FwkList) { [% FOREACH subfield_loo IN innerloo.subfield_loop %]
- + [% UNLESS advancedMARCEditor %] [% IF ( subfield_loo.fixedfield ) %]