From 6f8fe7e22a59cef7bd1804440cbd7ceaaddf25b7 Mon Sep 17 00:00:00 2001 From: Cori Lynn Arnold Date: Tue, 9 Oct 2018 12:48:58 +0000 Subject: [PATCH] Bug 19263: Rancor - 001 widdget only for configured client Tests: 1) Verify that a new entry for CONTROL_NUM_SEQUENCE is added to table authorised_value_categories 2) Edit a bib record using advanced editor and note that 001 widget isn't there when adding/editing 001 field 3) Add a new row into authorised_values table with: a) CONTROL_NUM_SEQUENCE in category column b) authorised_value column has a string ending with a number i.e. "faw0001" c) lib column has a short string indicating type of control number i.e. "FAW" 4) Edit a bib record using the advanced editor and note that the 001 widget is there when adding / editing 001 field Signed-off-by: Nick Clemens Signed-off-by: Josef Moravec Signed-off-by: Nick Clemens --- .../data/mysql/mandatory/auth_val_cat.sql | 3 +- .../en/includes/cateditor-widgets-marc21.inc | 106 ++++++++++-------- 2 files changed, 59 insertions(+), 50 deletions(-) diff --git a/installer/data/mysql/mandatory/auth_val_cat.sql b/installer/data/mysql/mandatory/auth_val_cat.sql index 6fff954edc..df119a08f9 100644 --- a/installer/data/mysql/mandatory/auth_val_cat.sql +++ b/installer/data/mysql/mandatory/auth_val_cat.sql @@ -44,7 +44,8 @@ INSERT IGNORE INTO authorised_value_categories( category_name ) ('HINGS_C'), ('HINGS_AS'), ('HINGS_RD'), - ('STACK'); + ('STACK') + ('CONTROL_NUM_SEQUENCE'); -- UNIMARC specific? INSERT IGNORE INTO authorised_value_categories( category_name ) VALUES diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/cateditor-widgets-marc21.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/cateditor-widgets-marc21.inc index 92b8b8c65a..970f58e6d6 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/includes/cateditor-widgets-marc21.inc +++ b/koha-tmpl/intranet-tmpl/prog/en/includes/cateditor-widgets-marc21.inc @@ -113,56 +113,64 @@ require( [ 'koha-backend', 'widget' ], function( KohaBackend, Widget ) { }, } ); - Widget.Register( '001@', { - init: function() { - var $result = $( - '' - + _("Control number: ") - + '' - + '' - + '' - + '' - + '' - ); + /* Check to see if there are any Control Number entries + * in the authorised values table. + * If not, let's not show the widget + */ + var reg001 = KohaBackend.GetAuthorisedValues( 'CONTROL_NUM_SEQUENCE'); + if(reg001) { + + Widget.Register( '001@', { + init: function() { + var $result = $( + '' + + _("Control number: ") + + '' + + '' + + '' + + '' + + '' + ); - return $result[0]; - }, - setControlNumber: function( text ) { - if ( text ) this.setText( text ); - $( this.node ).find('.control-number-widget-contents') - .html( text == '' ? ( '' + _("unset") + '' ) : text ); - this.mark.changed(); - }, - postCreate: function( node, mark ) { - var widget = this; - this.setControlNumber( this.text ); - $( this.node ) - .find('.control-number-widget-assign').click( function() { - var sequence = $( widget.node ).find('.control-number-widget-sequence').val(); - $.post( - '/cgi-bin/koha/svc/cataloguing/control_num_sequences/' + sequence - ).done( function( result ) { - if ( result.next_value ) widget.setControlNumber( result.next_value ); - } ); - } ).end() - .find('.control-number-widget-override').click( function() { - var result = prompt( _("Enter new control number") ); - - if ( result ) widget.setControlNumber( result ); - } ).end(); - - var sequence_list = $.map( KohaBackend.GetAuthorisedValues( 'CONTROL_NUM_SEQUENCE' ), function( authval ) { - return authval.lib; - } ); - sequence_list.sort(); - - $.each( sequence_list, function( undef, sequence ) { - $( widget.node ).find('.control-number-widget-sequence').append( '' ); - } ); - - // TODO: Make Enter on select click "Assign" - } - } ); + return $result[0]; + }, + setControlNumber: function( text ) { + if ( text ) this.setText( text ); + $( this.node ).find('.control-number-widget-contents') + .html( text == '' ? ( '' + _("unset") + '' ) : text ); + this.mark.changed(); + }, + postCreate: function( node, mark ) { + var widget = this; + this.setControlNumber( this.text ); + $( this.node ) + .find('.control-number-widget-assign').click( function() { + var sequence = $( widget.node ).find('.control-number-widget-sequence').val(); + $.post( + '/cgi-bin/koha/svc/cataloguing/control_num_sequences/' + sequence + ).done( function( result ) { + if ( result.next_value ) widget.setControlNumber( result.next_value ); + } ); + } ).end() + .find('.control-number-widget-override').click( function() { + var result = prompt( _("Enter new control number") ); + + if ( result ) widget.setControlNumber( result ); + } ).end(); + + var sequence_list = $.map( KohaBackend.GetAuthorisedValues( 'CONTROL_NUM_SEQUENCE' ), function( authval ) { + return authval.lib; + } ); + sequence_list.sort(); + + $.each( sequence_list, function( undef, sequence ) { + $( widget.node ).find('.control-number-widget-sequence').append( '' ); + } ); + + // TODO: Make Enter on select click "Assign" + } + } ); + }; Widget.Register( '005@', { init: function() { -- 2.39.5