From 297529c251a13bab5817c0fb4f9dd66708229eb1 Mon Sep 17 00:00:00 2001 From: Nick Clemens Date: Thu, 6 Jul 2017 16:35:38 +0000 Subject: [PATCH] Bug 18904: Advanced editor - Rancor - Add authority support This patchset adds the ability to use the authorities search to select or clear fields in the advanced editor To test: 1 - Open a record in the advanced cataloging editor 2 - Press 'Ctrl+L' while in a field that shuold not be linked to authorities (300 for instance) 3 - Nothing should happen 4 - Try it in a field that should be linked 5 - You should get the authorities pop-up 6 - Values in pop-up should be populated from values in record (as appropriate for authority type) 7 - Correct authority type should be selected ( PERSO_NAME for 100, TOPIC_TERM for 650, etc.) 8 - Press 'Clear', field should be blanked 9 - Search again and select an authority 10 - Field should be correctly populated Signed-off-by: Katrin Fischer Signed-off-by: Marcel de Rooy Signed-off-by: Jonathan Druart --- cataloguing/editor.pl | 4 +++ .../lib/koha/cateditor/marc-editor.js | 24 ++++++++++++++ .../prog/en/includes/cateditor-ui.inc | 8 +++++ .../authorities/blinddetail-biblio-search.tt | 33 +++++++++++++++---- .../prog/en/modules/cataloguing/editor.tt | 5 +++ 5 files changed, 68 insertions(+), 6 deletions(-) diff --git a/cataloguing/editor.pl b/cataloguing/editor.pl index fe31c0ba9a..0806233fa0 100755 --- a/cataloguing/editor.pl +++ b/cataloguing/editor.pl @@ -29,6 +29,7 @@ use C4::Context; use C4::Output; use DBIx::Class::ResultClass::HashRefInflator; use Koha::Database; +use Koha::MarcSubfieldStructures; my $input = CGI->new; @@ -56,6 +57,9 @@ $template->{VARS}->{editable_batches} = [ $schema->resultset('ImportBatch')->sea # Needed information for cataloging plugins $template->{VARS}->{DefaultLanguageField008} = pack( 'A3', C4::Context->preference('DefaultLanguageField008') || 'eng' ); +my $authtags = Koha::MarcSubfieldStructures->search({ authtypecode => { '!=' => '' }, 'frameworkcode' => '' }); +$template->{VARS}->{authtags} = $authtags; + # Z39.50 servers my $dbh = C4::Context->dbh; $template->{VARS}->{z3950_servers} = $dbh->selectall_arrayref( q{ diff --git a/koha-tmpl/intranet-tmpl/lib/koha/cateditor/marc-editor.js b/koha-tmpl/intranet-tmpl/lib/koha/cateditor/marc-editor.js index d2cc7b5192..6343f5e8de 100644 --- a/koha-tmpl/intranet-tmpl/lib/koha/cateditor/marc-editor.js +++ b/koha-tmpl/intranet-tmpl/lib/koha/cateditor/marc-editor.js @@ -18,6 +18,7 @@ */ define( [ 'marc-record', 'koha-backend', 'preferences', 'text-marc', 'widget' ], function( MARC, KohaBackend, Preferences, TextMARC, Widget ) { + var NOTIFY_TIMEOUT = 250; function editorCursorActivity( cm ) { @@ -163,6 +164,29 @@ define( [ 'marc-record', 'koha-backend', 'preferences', 'text-marc', 'widget' ], cm.execCommand('deleteLine'); }, + 'Ctrl-L': function( cm ) { + // Launch the auth search popup + var field = cm.marceditor.getCurrentField(); + + if ( !field ) return; + if ( authInfo[field.tag] == undefined ) return; + authtype = authInfo[field.tag].authtypecode; + index = 'rancor';//+field.line+'|'+field.tag; + var mainmainstring = ''; + if( field.getSubfields( authInfo[field.tag].subfield ).length != 0 ){ + mainmainstring += field.getSubfields( authInfo[field.tag].subfield )[0].text; + } + + var subfields = field.getSubfields(); + var mainstring= ''; + for(i=0;i < subfields.length ;i++){ + if ( authInfo[field.tag].subfield == subfields[i].code ) continue; + mainstring += subfields[i].text+' '; + } + newin=window.open("../authorities/auth_finder.pl?source=biblio&authtypecode="+authtype+"&index="+index+"&value_mainstr="+encodeURI(mainmainstring)+"&value_main="+encodeURI(mainstring), "_blank",'width=700,height=550,toolbar=false,scrollbars=yes'); + + }, + 'Shift-Ctrl-X': function( cm ) { // Delete subfield var field = cm.marceditor.getCurrentField(); diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/cateditor-ui.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/cateditor-ui.inc index 62f19b0c97..68a168fab9 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/includes/cateditor-ui.inc +++ b/koha-tmpl/intranet-tmpl/prog/en/includes/cateditor-ui.inc @@ -3,6 +3,14 @@ + [% IF ( bidi ) %] [% END %] @@ -276,6 +277,10 @@ Ctrl-H Get help on current subfield + + Ctrl-L + Link field to authorities + Ctrl-S Save record -- 2.39.5