Bugzilla – Attachment 80306 Details for
Bug 19263
Advanced Editor - Rancor - Add auto control number (001) widget
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 19263: Rancor - Add auto-001 widget
Bug-19263-Rancor---Add-auto-001-widget.patch (text/plain), 6.60 KB, created by
Nick Clemens (kidclamp)
on 2018-10-09 19:19:23 UTC
(
hide
)
Description:
Bug 19263: Rancor - Add auto-001 widget
Filename:
MIME Type:
Creator:
Nick Clemens (kidclamp)
Created:
2018-10-09 19:19:23 UTC
Size:
6.60 KB
patch
obsolete
>From b746f545e389c394af065b0a739152be940db53a Mon Sep 17 00:00:00 2001 >From: Jesse Weaver <pianohacker@gmail.com> >Date: Tue, 10 Nov 2015 12:04:14 -0700 >Subject: [PATCH] Bug 19263: Rancor - Add auto-001 widget > >To test: > >1 - Define a new authorised valued category "CONTROL_NUM_SEQUENCE" >2 - Add a value/sequence > The authorised_value is the starting value - shoudl end in a number > that can be incremented e.g. "control_sequence_001" > The description field is the name for the seqeuence > Opac description is unused >3 - Edit a record in rancor >4 - Note the new widget and option to increment or assign manually > >Signed-off-by: Claire Gravely <claire.gravely@bsz-bw.de> >--- > koha-tmpl/intranet-tmpl/prog/css/cateditor.css | 7 +++ > .../prog/en/includes/cateditor-widgets-marc21.inc | 53 ++++++++++++++++++- > svc/cataloguing/control_num_sequences | 59 ++++++++++++++++++++++ > 3 files changed, 118 insertions(+), 1 deletion(-) > create mode 100755 svc/cataloguing/control_num_sequences > >diff --git a/koha-tmpl/intranet-tmpl/prog/css/cateditor.css b/koha-tmpl/intranet-tmpl/prog/css/cateditor.css >index 7889a49..7fc4119 100644 >--- a/koha-tmpl/intranet-tmpl/prog/css/cateditor.css >+++ b/koha-tmpl/intranet-tmpl/prog/css/cateditor.css >@@ -134,6 +134,13 @@ body { > padding: 2px; > } > >+#editor .subfield-widget button { >+ font-family: inherit; >+ font-size: inherit; >+ margin-left: 5px; >+ vertical-align: middle; >+} >+ > #editor .subfield-widget select, #editor .subfield-widget input { > height: 1.5em; > vertical-align: middle; >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 b425fd3..92b8b8c 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 >@@ -85,7 +85,7 @@ > * single subfield, '@'. > */ > >-require( [ 'widget' ], function( Widget ) { >+require( [ 'koha-backend', 'widget' ], function( KohaBackend, Widget ) { > Widget.Register( '000@', { > makeTemplate: function() { > return ' nam a22 7a 4500'; >@@ -113,6 +113,57 @@ require( [ 'widget' ], function( Widget ) { > }, > } ); > >+ Widget.Register( '001@', { >+ init: function() { >+ var $result = $( >+ '<span class="subfield-widget">' >+ + _("Control number: ") >+ + '<span class="control-number-widget-contents"></span>' >+ + '<button class="control-number-widget-assign">' + _("Assign next") + '</button>' >+ + '<select class="control-number-widget-sequence"></select>' >+ + '<button class="control-number-widget-override">Override</button>' >+ + '</span>' >+ ); >+ >+ return $result[0]; >+ }, >+ setControlNumber: function( text ) { >+ if ( text ) this.setText( text ); >+ $( this.node ).find('.control-number-widget-contents') >+ .html( text == '<empty>' ? ( '<span class="hint">' + _("unset") + '</span>' ) : 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( '<option>' + sequence + '</option>' ); >+ } ); >+ >+ // TODO: Make Enter on select click "Assign" >+ } >+ } ); >+ > Widget.Register( '005@', { > init: function() { > var $result = $( '<span class="subfield-widget fixed-widget">' + _("Updated: ") + '</span>' ); >diff --git a/svc/cataloguing/control_num_sequences b/svc/cataloguing/control_num_sequences >new file mode 100755 >index 0000000..e8a4307 >--- /dev/null >+++ b/svc/cataloguing/control_num_sequences >@@ -0,0 +1,59 @@ >+#!/usr/bin/perl >+# >+# Copyright 2015 ByWater Solutions >+# >+# This file is part of Koha. >+# >+# Koha is free software; you can redistribute it and/or modify it under the >+# terms of the GNU General Public License as published by the Free Software >+# Foundation; either version 3 of the License, or (at your option) any later >+# version. >+# >+# Koha is distributed in the hope that it will be useful, but WITHOUT ANY >+# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR >+# A PARTICULAR PURPOSE. See the GNU General Public License for more details. >+# >+# You should have received a copy of the GNU General Public License along >+# with Koha; if not, write to the Free Software Foundation, Inc., >+# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. >+ >+use Modern::Perl; >+ >+use C4::Service; >+use Koha::Database; >+use MARC::Record; >+ >+our ( $query, $response ) = C4::Service->init( editcatalogue => 'edit_catalogue' ); >+ >+sub get_and_increment { >+ my ( $control_num_sequence ) = @_; >+ >+ my $schema = Koha::Database->new->schema(); >+ my $authval = $schema->resultset( 'AuthorisedValue' )->find( >+ { >+ category => 'CONTROL_NUM_SEQUENCE', >+ lib => $control_num_sequence >+ } >+ ); >+ >+ if ( !$authval ) { >+ C4::Service->return_error( 'not_found' ); >+ } >+ >+ my $value = $authval->authorised_value; >+ >+ $response->param( next_value => $value ); >+ >+ my ( $prefix, $num ) = ( $value =~ /(.+?)(\d+)$/ ); >+ >+ $value = $prefix . sprintf( '%0*d', length( $num ), $num + 1 ); >+ >+ $authval->authorised_value( $value ); >+ $authval->update(); >+ >+ C4::Service->return_success( $response ); >+} >+ >+C4::Service->dispatch( >+ [ 'POST /(.*)', [], \&get_and_increment ], >+); >-- >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 19263
:
66897
|
76864
|
78085
|
80231
|
80237
|
80240
|
80257
|
80306
|
80307
|
80308
|
80500
|
80508
|
80509
|
80510
|
80511