From b4e8842253adcc64713e95d122536a6516045055 Mon Sep 17 00:00:00 2001 From: Martin Stenberg Date: Wed, 26 Aug 2015 20:22:30 +0200 Subject: [PATCH] Bug 14242: Use ISBN-field to automatically fill out purchase suggestions Add new jQuery plugin "autofill" which transforms selected element(s) into search fields for Google Books API and automatically fills requested fields with search result. Use in OPAC purchase suggestions to automatically fill out fields when entering ISBN-number. Test plan: 1. Run updatedatabase.pl 2. Enable system precference "OPACAutoFill" 3. Log into OPAC and go to purchase suggetions page 4. Write a valid ISBN into the ISBN field and press the edit icon next to the field, or unfocus the field. 5. Title, Author, Publisher and Item Type fields should now be filled automaticly. 6. Press "undo" to undo - should restore all changed fields to original values Tested all patches together, works as expected. Signed-off-by: Marc Signed-off-by: Maryse Simard Signed-off-by: Lisette Scheer --- installer/data/mysql/mandatory/sysprefs.sql | 1 + .../prog/en/modules/admin/preferences/opac.pref | 7 + .../bootstrap/en/includes/opac-bottom.inc | 4 + .../bootstrap/en/modules/opac-suggestions.tt | 22 ++- koha-tmpl/opac-tmpl/bootstrap/js/autofill.js | 202 +++++++++++++++++++++ 5 files changed, 234 insertions(+), 2 deletions(-) create mode 100644 koha-tmpl/opac-tmpl/bootstrap/js/autofill.js diff --git a/installer/data/mysql/mandatory/sysprefs.sql b/installer/data/mysql/mandatory/sysprefs.sql index 0e9f488055..b2ce37903e 100644 --- a/installer/data/mysql/mandatory/sysprefs.sql +++ b/installer/data/mysql/mandatory/sysprefs.sql @@ -368,6 +368,7 @@ INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, ` ('OAI-PMH:DeletedRecord','persistent','Koha\'s deletedbiblio table will never be deleted (persistent), might be deleted (transient), or will never have any data in it (no)','transient|persistent|no','Choice'), ('OAI-PMH:MaxCount','50',NULL,'OAI-PMH maximum number of records by answer to ListRecords and ListIdentifiers queries','Integer'), ('OPACAcquisitionDetails','0','','Show the acquisition details at the OPAC','YesNo'), +('OPACAutoFill','0',NULL,'Automaticly fill forms with data from Google Books API','YesNo'), ('OpacAddMastheadLibraryPulldown','0','','Adds a pulldown menu to select the library to search on the opac masthead.','YesNo'), ('OpacAdvSearchMoreOptions','pubdate,itemtype,language,subtype,sorting,location','Show search options for the expanded view (More options)','pubdate|itemtype|language|subtype|sorting|location','multiple'), ('OpacAdvSearchOptions','pubdate,itemtype,language,sorting,location','Show search options','pubdate|itemtype|language|subtype|sorting|location','multiple'), diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/opac.pref b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/opac.pref index 3d8cd4fab9..3f0a49fb77 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/opac.pref +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/opac.pref @@ -531,6 +531,13 @@ OPAC: no: Don't display - a library selection list for news items in the OPAC. - + - pref: OPACAutoFill + default: 0 + choices: + yes: Enable + no: Disable + - automatic form filling with data from Google Books API. + - - "Use the following as the OPAC ISBD template:" - pref: OPACISBD type: textarea diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/includes/opac-bottom.inc b/koha-tmpl/opac-tmpl/bootstrap/en/includes/opac-bottom.inc index 1641593395..e7625718eb 100644 --- a/koha-tmpl/opac-tmpl/bootstrap/en/includes/opac-bottom.inc +++ b/koha-tmpl/opac-tmpl/bootstrap/en/includes/opac-bottom.inc @@ -279,6 +279,10 @@ $.widget.bridge('uitooltip', $.ui.tooltip); [% END %] +[% IF ( Koha.Preference('OPACAutoFill') ) %] + +[% END %] + [% IF ( BakerTaylorEnabled ) %] [% Asset.js("js/bakertaylorimages.js") | $raw %]