Something similar as on bug 34817. But obstacle currently is REST API not supporting ccl search on index. So in its current form it should need a svc script to do the index search.
Created attachment 155966 [details] [review] Bug 34860: New framework plugin for ISBN/ISSN A Koha patch should still be submitted. The REST API does not yet support an index search like the one in isbn_count.
Added concept code for now. Not yet ready for inclusion. The svc/isbn_count does the index search. The isbn.js includes checking the validity of ISBN on client side. As to hyphenation, I have chosen the following approach: LOC seems to recommend no hyphens in 020 and one hypen in 022 for the MARC fields. When displaying you can add the hyphens for ISBN. The code here removes the hyphens from ISBN when searching the index and does also replace the contents of 020 when hyphens were entered. (The current version removes additional text too..) From 2013 onwards, additional text should actually be in $q. In order to make this ready for submittal, the following is probably needed: - proper handling of $a suffixes for 020/022 (We may still assume presence.) - allow hyphenation for ISBN in MARC (index, db) - Pref needed? - removing code overlap between isbn/issn code in js - prepare transition from svc script to REST API - the red or green color approach might be replaced by an alert Please do not hesitate to give your feedback.
Code with optional suffix stripping: function isbn_check ( subfield, strip_suffix ) { // Remove hyphens from isbn part, handle suffix by split on space var split_field = subfield.split( ' ', 2 ); var isbn = split_field[0].replace( /[-]/g, '' ); var suffix; if( strip_suffix ) suffix = ''; else suffix = split_field[1] ? ' ' + split_field[1] : ''; if ( isbn.match(/^\d{9}(\d{3})?[0-9X]$/) ) { if( valid_isbn_check_digit(isbn) ) return [ 1, isbn + suffix ]; } return [ 0, isbn + suffix ]; }
Comment on attachment 155966 [details] [review] Bug 34860: New framework plugin for ISBN/ISSN This version is obsolete. I will upload an new version later on.