Bugzilla – Attachment 68678 Details for
Bug 18904
Advanced editor - Rancor - Add authority support
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 18904 - Advanced editor - Rancor - Add authority support
Bug-18904---Advanced-editor---Rancor---Add-authori.patch (text/plain), 10.20 KB, created by
Nick Clemens (kidclamp)
on 2017-10-27 11:21:42 UTC
(
hide
)
Description:
Bug 18904 - Advanced editor - Rancor - Add authority support
Filename:
MIME Type:
Creator:
Nick Clemens (kidclamp)
Created:
2017-10-27 11:21:42 UTC
Size:
10.20 KB
patch
obsolete
>From 8488bdeb0cc50c0db491366485f43c5ba46aba23 Mon Sep 17 00:00:00 2001 >From: Nick Clemens <nick@bywatersolutions.com> >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 <katrin.fischer.83@web.de> >--- > cataloguing/editor.pl | 4 ++ > .../lib/koha/cateditor/marc-editor.js | 24 +++++++++++ > .../prog/en/includes/cateditor-ui.inc | 8 ++++ > .../authorities/blinddetail-biblio-search.tt | 48 +++++++++++++++------- > .../prog/en/modules/cataloguing/editor.tt | 5 +++ > 5 files changed, 74 insertions(+), 15 deletions(-) > >diff --git a/cataloguing/editor.pl b/cataloguing/editor.pl >index fe31c0b..0806233 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 3b8622a..ac4cbe6 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 ) { >@@ -155,6 +156,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 a6ac276..8770697 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 @@ > <script src="[% interface %]/lib/koha/cateditor/marc-mode.js"></script> > <script src="[% interface %]/lib/require.js"></script> > <script> >+ var authInfo = { >+ [%- FOREACH authtag = authtags -%] >+ [% authtag.tagfield %]: { >+ subfield: '[% authtag.tagsubfield %]', >+ authtypecode: '[% authtag.authtypecode %]', >+ }, >+ [%- END -%] >+ }; > require.config( { > baseUrl: '[% interface %]/lib/koha/cateditor/', > config: { >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/authorities/blinddetail-biblio-search.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/authorities/blinddetail-biblio-search.tt >index f6ab158..8809c70 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/authorities/blinddetail-biblio-search.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/authorities/blinddetail-biblio-search.tt >@@ -4,6 +4,25 @@ > <script type="text/javascript"> > //<![CDATA[ > $(document).ready(function(){ >+ [% IF tag_number == 'rancor' %] >+ function RancorReplaceField( new_text ){ >+ var cur_field = opener.opener.jQuery(".CodeMirror")[0].CodeMirror.marceditor.getCurrentField(); >+ cur_field.setText(new_text); >+ return true; >+ } >+ [% IF ( clear ) %] >+ var new_line = ""; >+ [% ELSE %] >+ var new_line = " >+ [%- FOREACH SUBFIELD_LOO IN SUBFIELD_LOOP -%]â¡ >+ [%- SUBFIELD_LOO.marc_subfield |replace("'", "\'") |replace('"', '\"') |replace('\n', '\\n') |replace('\r', '\\r ') -%] >+ [%- FOREACH marc_value IN SUBFIELD_LOO.marc_values -%] >+ [%- marc_value |replace("'", "\'") |replace('"', '\"') |replace('\n', '\\n') |replace('\r', '\\r') -%] >+ [%- END -%] >+ [%- END -%]â¡9[% authid %]"; >+ [% END %] >+ RancorReplaceField( new_line ); >+ [% ELSE %] > var index_start = "[% index %]"; > var whichfield; > try { >@@ -21,7 +40,7 @@ > if(nb <= 1) { > return true; > } >- >+ > // Find the subfield we want to clone > var re = new RegExp('^subfield' + subfield_name,'g'); > var subfields = $(field_start).children('div').filter( function() { >@@ -52,7 +71,7 @@ > // Create the correct number of form fields for all values > // If the field cloning failed, only the first value will be added to the form. > SetSubfieldNumber(subfield_name, values.length); >- >+ > // Find the subfields where we will add the new values > var re = new RegExp('^subfield' + subfield_name,'g'); > var subfields = $(field_start).children('div').filter( function() { >@@ -71,21 +90,19 @@ > i++; > }); > } >- > [% UNLESS ( clear ) %] >- [% FOREACH SUBFIELD_LOO IN SUBFIELD_LOOP %] >- SetSubfieldValues( >- "[% tag_number |replace("'", "\'") |replace('"', '\"') |replace('\n', '\\n') |replace('\r', '\\r') %][% SUBFIELD_LOO.marc_subfield |replace("'", "\'") |replace('"', '\"') |replace('\n', '\\n') |replace('\r', '\\r') %]" >- [% FOREACH marc_value IN SUBFIELD_LOO.marc_values %] >- ,"[% marc_value |replace("'", "\'") |replace('"', '\"') |replace('\n', '\\n') |replace('\r', '\\r') %]" >+ [% FOREACH SUBFIELD_LOO IN SUBFIELD_LOOP %] >+ SetSubfieldValues( >+ "[% tag_number |replace("'", "\'") |replace('"', '\"') |replace('\n', '\\n') |replace('\r', '\\r') %][% SUBFIELD_LOO.marc_subfield |replace("'", "\'") |replace('"', '\"') |replace('\n', '\\n') |replace('\r', '\\r') %]" >+ [% FOREACH marc_value IN SUBFIELD_LOO.marc_values %] >+ ,"[% marc_value |replace("'", "\'") |replace('"', '\"') |replace('\n', '\\n') |replace('\r', '\\r') %]" >+ [% END %] >+ ); > [% END %] >- ); >+ var indicators = field_start.getElementsByClassName('indicator flat'); >+ indicators[0].value="[% indicator1 %]"; >+ indicators[1].value="[% indicator2 %]"; > [% END %] >- var indicators = field_start.getElementsByClassName('indicator flat'); >- indicators[0].value="[% indicator1 %]"; >- indicators[1].value="[% indicator2 %]"; >- [% END %] >- > // browse all its subfields (clear and $9) > var subfields = field_start.getElementsByTagName('input'); > var re = /^tag_\d*_code_/; >@@ -105,8 +122,9 @@ > [% END %] > } > } >+ [% END %] > >- opener.close(); >+ opener.close(); > window.close(); > > return false; >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/editor.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/editor.tt >index dd3ab74..365e0ab 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/editor.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/editor.tt >@@ -6,6 +6,7 @@ > <link rel="stylesheet" href="[% interface %]/lib/codemirror/codemirror.css" /> > <link rel="stylesheet" href="[% interface %]/[% theme %]/css/humanmsg.css" /> > <script src="[% interface %]/lib/jquery/plugins/humanmsg.js" type="text/javascript"></script> >+<script src="/intranet-tmpl/prog/js/cataloging.js" type="text/javascript"></script> > [% IF ( bidi ) %] > <link rel="stylesheet" type="text/css" href="[% interface %]/[% theme %]/css/right-to-left.css" /> > [% END %] >@@ -269,6 +270,10 @@ > <td>Get help on current subfield</td> > </tr> > <tr> >+ <td>Ctrl-L</td> >+ <td>Link field to authorities</td> >+ </tr> >+ <tr> > <td>Ctrl-S</td> > <td>Save record</td> > </tr> >-- >2.1.4
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 18904
:
64859
|
64860
|
65144
|
65145
|
65863
|
65864
|
65865
|
65866
|
68678
|
68679
|
68680
|
68681
|
71747
|
71748
|
71749
|
71750
|
71751
|
72920
|
73693
|
73694
|
73695
|
73696
|
73697
|
73766
|
73767
|
73768
|
73769
|
73770
|
73771
|
73851
|
73852
|
73853
|
73854
|
73855
|
73856
|
73857
|
74023
|
74055