From d07da4bf9fb96012ec43ab2e1a8f767643521a29 Mon Sep 17 00:00:00 2001 From: Ere Maijala Date: Fri, 22 Feb 2019 11:53:43 +0200 Subject: [PATCH] Bug 21280: Move MARC editor tabs to an include file Moves the tabs code from addbiblio.tt to marc_editor.inc and changes authorities.tt to use it too. Minor changes in the tabs code were needed to support both functions. Adds support for toggling docs and tags for authorities and updates default documentation links. Test plan: 1. Test adding and editing biblio records and authority records. 2. Make sure visibility of fields is correct initially and when values are added. 3. Make sure settings for tags and documentation links work and stick across edits, also for authorities. Signed-off-by: Michal Denar Signed-off-by: Michal Denar Signed-off-by: Josef Moravec --- .../intranet-tmpl/prog/en/includes/marc_editor.inc | 397 ++++++++++++++++++++ .../prog/en/modules/authorities/authorities.tt | 291 +-------------- .../prog/en/modules/cataloguing/addbiblio.tt | 401 +-------------------- 3 files changed, 411 insertions(+), 678 deletions(-) create mode 100644 koha-tmpl/intranet-tmpl/prog/en/includes/marc_editor.inc diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/marc_editor.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/marc_editor.inc new file mode 100644 index 0000000..e3abb8d --- /dev/null +++ b/koha-tmpl/intranet-tmpl/prog/en/includes/marc_editor.inc @@ -0,0 +1,397 @@ +[% USE Koha %] + + +
+ + +[% FOREACH BIG_LOO IN BIG_LOOP %] +
+ + [% IF ( BIG_LOOP.size > 1 ) %] +

Section [% BIG_LOO.number | html %]

+ [% END %] + [% FOREACH innerloo IN BIG_LOO.innerloop %] + [% IF ( innerloo.tag ) %] +
+
+ [% IF advancedMARCEditor %] + [% innerloo.tag | html %] + [% ELSE %] + [% innerloo.tag | html %] + [% IF marcflavour != 'NORMARC' %] ?[% END %] + [% END %] + [% IF ( innerloo.fixedfield ) %] + + + [% ELSE %] + + + [% END %] - + + [% UNLESS advancedMARCEditor %] + [% innerloo.tag_lib | html %] + [% END %] + + [% IF ( innerloo.repeatable ) %] + + Repeat this Tag + + [% END %] + + Delete this Tag + + + +
+ + [% FOREACH subfield_loo IN innerloo.subfield_loop %] + +
+ + [% UNLESS advancedMARCEditor %] + [% IF ( subfield_loo.fixedfield ) %]
+ + [% END %] + +
+ [% END %] + [% END %] +
+[% END %] + +
diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/authorities/authorities.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/authorities/authorities.tt index d16e587..3ea5145 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/authorities/authorities.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/authorities/authorities.tt @@ -54,89 +54,6 @@ function GetZ3950Terms(){ return strQuery; } -/** - * check if mandatory subfields are written - */ -function AreMandatoriesNotOk(){ - var mandatories = new Array(); - var mandatoriesfields = new Array(); - var tab = new Array(); - var label = new Array(); - [% FOREACH BIG_LOO IN BIG_LOOP %] - [% FOREACH innerloo IN BIG_LOO.innerloop %] - [% IF ( innerloo.mandatory ) %] - mandatoriesfields.push(new Array("[% innerloo.tag | html %]","[% innerloo.index | html %][% innerloo.random | html %]","[% innerloo.index | html %]")); - [% END %] - [% FOREACH subfield_loo IN innerloo.subfield_loop %] - [% IF ( subfield_loo.mandatory ) %]mandatories.push("[% subfield_loo.id | html %]"); - tab.push("[% BIG_LOO.number | html %]"); - label.push("[% subfield_loo.marc_lib | $raw |replace("'", "\'") |replace('"', '\"') |replace('\n', '\\n') |replace('\r', '\\r') %]"); - [% END %] - [% END %] - [% END %] - [% END %] - var StrAlert = ""; - for(var i=0,len=mandatories.length; i= 10){ - elem = document.getElementById(divid); - eleminputs = elem.getElementsByTagName('input'); - - for(var j=0,len2=eleminputs.length; j Z39.50 search + + +
[% IF ( authid ) %] Cancel @@ -227,202 +156,8 @@ function confirmnotdup(redirect){
-
- + [% INCLUDE 'marc_editor.inc' maindiv='authoritytabs' marc21_doc_base='http://www.loc.gov/marc/authority/ad' unimarc_doc_base='https://www.ifla.org/publications/unimarc-authorities--3rd-edition--updates' %] -[% FOREACH BIG_LOO IN BIG_LOOP %] -
- - [% FOREACH innerloo IN BIG_LOO.innerloop %] - [% IF ( innerloo.tag ) %] -
-
- [% UNLESS hide_marc %] - [% IF advancedMARCEditor %] - [% innerloo.tag | html %] - [% ELSE %] - [% innerloo.tag | html %] - [% END %] - [% IF ( innerloo.fixedfield ) %] - - - [% ELSE %] - - - [% END %] - - [% ELSE %] - [% IF ( innerloo.fixedfield ) %] - - - [% ELSE %] - - - [% END %] - [% END %] - - [% UNLESS advancedMARCEditor %] - [% innerloo.tag_lib | html %] - [% END %] - - [% IF ( innerloo.repeatable ) %] - - Repeat this Tag - - [% END %] - - Delete this Tag - - - -
- - [% FOREACH subfield_loo IN innerloo.subfield_loop %] - -
- - [% UNLESS advancedMARCEditor %] - [% IF ( subfield_loo.fixedfield ) %]
- - [% END %] - -
- [% END %] - [% END %] -
-[% END %] - -
- -
-[% FOREACH hidden_loo IN hidden_loop %] - - - - - -[% END %] -
[% IF ( oldauthnumtagfield ) %] 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 2aa091e..bb4b125 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/addbiblio.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/addbiblio.tt @@ -37,43 +37,6 @@ stickyClass: "floating" }); - /* check cookie to hide/show marcdocs*/ - if($.cookie("marcdocs_[% borrowernumber | html %]") == 'hide'){ - toggleMARCdocLinks(false); - } else { - toggleMARCdocLinks(true); - } - - $("#marcDocsSelect").click(function(){ - if($.cookie("marcdocs_[% borrowernumber | html %]") == 'hide'){ - toggleMARCdocLinks(true); - } else { - toggleMARCdocLinks(false); - } - }); - - /* check cookie to hide/show marc tags*/ - var marctags_cookie = $.cookie("marctags_[% borrowernumber | html %]"); - if( marctags_cookie == 'hide'){ - toggleMARCTagLinks(false); - } else if( marctags_cookie == 'show'){ - toggleMARCTagLinks(true) - } else { - [% UNLESS Koha.Preference("hide_marc") %] - toggleMARCTagLinks(true) - [% ELSE %] - toggleMARCTagLinks(false); - [% END %] - } - - $("#marcTagsSelect").click(function(){ - if( $.cookie("marctags_[% borrowernumber | html %]") == 'hide'){ - toggleMARCTagLinks(true) - } else { - toggleMARCTagLinks(false); - } - }); - [%# Only ask for a confirmation if it is an edit %] $("#z3950search").click(function(){ [% IF biblionumber %] @@ -190,203 +153,6 @@ function PopupZ3950() { } } -function PopupMARCFieldDoc(field) { - [% IF Koha.Preference('marcfielddocurl') %] - var docurl = "[% Koha.Preference('marcfielddocurl').replace('"','"') | html %]"; - docurl = docurl.replace("{MARC}", "[% marcflavour | html %]"); - docurl = docurl.replace("{FIELD}", ""+field); - docurl = docurl.replace("{LANG}", "[% lang | html %]"); - window.open(docurl); - [% ELSIF ( marcflavour == 'MARC21' ) %] - _MARC21FieldDoc(field); - [% ELSIF ( marcflavour == 'UNIMARC' ) %] - _UNIMARCFieldDoc(field); - [% END %] -} - -function _MARC21FieldDoc(field) { - if(field == 0) { - window.open("http://www.loc.gov/marc/bibliographic/bdleader.html"); - } else if (field < 900) { - window.open("http://www.loc.gov/marc/bibliographic/bd" + ("000"+field).slice(-3) + ".html"); - } else { - window.open("http://www.loc.gov/marc/bibliographic/bd9xx.html"); - } -} - -function _UNIMARCFieldDoc(field) { - /* http://archive.ifla.org/VI/3/p1996-1/ is an outdated version of UNIMARC, but - seems to be the only version available that can be linked to per tag. More recent - versions of the UNIMARC standard are available on the IFLA website only as - PDFs! - */ - var url; - if (field == 0) { - url = "http://archive.ifla.org/VI/3/p1996-1/uni.htm"; - } else { - var first = field.substring(0,1); - url = "http://archive.ifla.org/VI/3/p1996-1/uni" + first + ".htm#"; - if (first == 0) url = url + "b"; - url = first == 9 - ? "http://archive.ifla.org/VI/3/p1996-1/uni9.htm" - : url + field; - } - window.open(url); -} - -/* - * Functions to hide/show marc docs and tags links - */ - -function toggleMARCdocLinks(flag){ - if( flag === true ){ - $(".marcdocs").show(); - $.cookie("marcdocs_[% borrowernumber | html %]",'show', { path: "/", expires: 365 }); - $("#marcDocsSelect i").addClass('fa-check-square-o').removeClass('fa-square-o'); - } else { - $(".marcdocs").hide(); - $.cookie("marcdocs_[% borrowernumber | html %]",'hide', { path: "/", expires: 365 }); - $("#marcDocsSelect i").removeClass('fa-check-square-o').addClass('fa-square-o'); - } -} - -function toggleMARCTagLinks(flag){ - if( flag === true ){ - $(".tagnum").show(); - $(".subfieldcode").show(); - $.cookie("marctags_[% borrowernumber | html %]",'show', { path: "/", expires: 365 }); - $("#marcTagsSelect i").addClass('fa-check-square-o').removeClass('fa-square-o'); - } else { - $(".tagnum").hide(); - $(".subfieldcode").hide(); - $.cookie("marctags_[% borrowernumber | html %]",'hide', { path: "/", expires: 365 }); - $("#marcTagsSelect i").removeClass('fa-check-square-o').addClass('fa-square-o'); - } -} - -/** - * check if mandatory subfields are written - */ -function AreMandatoriesNotOk(){ - var mandatories = new Array(); - var mandatoriesfields = new Array(); - var tab = new Array(); - var label = new Array(); - var flag=0; - var tabflag= new Array(); - [% FOREACH BIG_LOO IN BIG_LOOP %] - [% FOREACH innerloo IN BIG_LOO.innerloop %] - [% IF ( innerloo.mandatory ) %] - mandatoriesfields.push(new Array("[% innerloo.tag | html %]","[% innerloo.index | html %][% innerloo.random | html %]","[% innerloo.index | html %]")); - [% END %] - [% FOREACH subfield_loo IN innerloo.subfield_loop %] - [% IF ( subfield_loo.mandatory ) %]mandatories.push("[% subfield_loo.id | html %]"); - tab.push("[% BIG_LOO.number | html %]"); - label.push("[% subfield_loo.marc_lib | $raw %]"); - [% END %] - [% END %] - [% END %] - [% END %] - var StrAlert = _("Can't save this record because the following field aren't filled:"); - StrAlert += "\n\n"; - for(var i=0,len=mandatories.length; i= 10){ - elem = document.getElementById(divid); - eleminputs = elem.getElementsByTagName('input'); - - for(var j=0,len2=eleminputs.length; j -
- - -[% FOREACH BIG_LOO IN BIG_LOOP %] -
- - [% IF ( BIG_LOOP.size > 1 ) %] -

Section [% BIG_LOO.number | html %]

- [% END %] - [% FOREACH innerloo IN BIG_LOO.innerloop %] - [% IF ( innerloo.tag ) %] -
-
- [% IF advancedMARCEditor %] - [% innerloo.tag | html %] - [% ELSE %] - [% innerloo.tag | html %] - [% IF marcflavour != 'NORMARC' %] ?[% END %] - [% END %] - [% IF ( innerloo.fixedfield ) %] - - - [% ELSE %] - - - [% END %] - - - [% UNLESS advancedMARCEditor %] - [% innerloo.tag_lib | html %] - [% END %] - - [% IF ( innerloo.repeatable ) %] - - Repeat this Tag - - [% END %] - - Delete this Tag - - - -
- - [% FOREACH subfield_loo IN innerloo.subfield_loop %] - -
- - [% UNLESS advancedMARCEditor %] - [% IF ( subfield_loo.fixedfield ) %]
- - [% END %] - -
- [% END %] - [% END %] -
-[% END %] - -
+ [% INCLUDE 'marc_editor.inc' maindiv='addbibliotabs' marc21_doc_base='http://www.loc.gov/marc/bibliographic/bd' unimarc_doc_base='https://www.ifla.org/publications/unimarc-bibliographic--3rd-edition--updates-2012-and-updates-2016' %] [%# Fields for fast cataloging %] -- 2.1.4