From fc9b8d8ea10b45a05bd60ecb420b4d11db04a265 Mon Sep 17 00:00:00 2001 From: George Veranis Date: Fri, 2 Sep 2022 22:30:45 +0200 Subject: [PATCH] Bug 29825: Preview of authority record on edit mode as MARC formatted view This bug adds a new functionality on Edit mode of a new or existing authority. Add a new button 'MARC Preview' in order librarian have the ability to preview the record on MARC plain structure mode and have all fields and subfields that entered before save/update the record. To test: 1. Open or add an authority 2. The preview button isn't on toolbar 3. Apply the patch 4. Do step 1 5. The preview button exists 6. Do some changes or not to the authority record 7. Click to Preview MARC button and a modal window will appear with all fields indicators and subfields that filled in the form of cataloguing. Mentored by: Andreas Roussos --- .../en/modules/authorities/authorities.tt | 56 ++++++++++++++++++- 1 file changed, 55 insertions(+), 1 deletion(-) 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 548b841aa1..448d762ffb 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/authorities/authorities.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/authorities/authorities.tt @@ -78,6 +78,57 @@ selectTab( tablink ); window.scrollTo( 0, getScrollto( field, "toolbar" ) ); }); + + $('#preview').click(function (){ + var content="

Authority #: [% authid %]


"; + content+="
"; + var line=1; + var has_input=0; + var sf_has_input=0; + $('#authoritytabs').find('[id^=tag_]').each(function(){ + //check if tag has content + has_input=0; + $(this).find('.input_marceditor').each(function(){ + if($(this).val()) has_input=1; + }); + + if(has_input){ + line=1; + //tag + var $tag = $(this).find('.tagnum').text(); + content += $tag.replace('*','') +"  "; + //indicators + $(this).find('.indicator').each(function(){ + if( $(this).val() ) content += $(this).val(); + else content += "_"; + }); + content += "  "; + //subfields + $(this).find('.subfield_line').each(function(){ + //check if subfield has content + sf_has_input=0; + $(this).find('.input_marceditor').each(function(){ + if($(this).val()) sf_has_input=1; + }); + if(sf_has_input){ + if(line>1) content += "              "; + //code + $(this).find('.subfieldcode').each(function(){ + $(this).find('.flat').each(function(){ + if($(this).val()!='00') + content += "\$"+$(this).val()+"  "; + }); + }); + //value + $(this).find('.input_marceditor').each(function(){ + content += ""+$(this).val()+""; + }); + content+="
"; + line+=1; + } + }); + } + }); }); function selectTab( tablink ){ @@ -321,6 +372,9 @@ Z39.50/SRU search [% END %]
+
+ MARC Preview +
[% IF ( authid ) %] Cancel @@ -604,7 +658,7 @@ [% INCLUDE 'modals/cataloguing_create_av.inc' %] - + [% INCLUDE 'modals/edit_authority_preview.inc' %]
-- 2.20.1