View | Details | Raw Unified | Return to bug 14242
Collapse All | Expand All

(-)a/installer/data/mysql/atomicupdate/bug_14242-autofill_syspref.perl (+6 lines)
Line 0 Link Here
1
$DBversion = 'XXX';
2
if( CheckVersion( $DBversion ) ) {
3
    $dbh->do(q{ INSERT IGNORE INTO systempreferences (`variable`, `value`, `options`, `explanation`,`type`) VALUES ('OPACSuggestionAutoFill', '0', NULL, 'Automatically fill OPAC suggestion form with data from Google Books API','YesNo') });
4
5
    NewVersion( $DBversion, 14242, "Add OPACSuggestionAutoFill system preference");
6
}
(-)a/installer/data/mysql/atomicupdate/bug_14242-autofill_syspref.sql (-1 lines)
Line 1 Link Here
1
INSERT IGNORE INTO systempreferences (`variable`, `value`, `options`, `explanation`,`type`) VALUES ('OPACSuggestionAutoFill', '0', NULL, 'Automaticly fill forms with data from Google Books API','YesNo');
(-)a/installer/data/mysql/sysprefs.sql (-1 / +1 lines)
Lines 360-366 INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, ` Link Here
360
('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'),
360
('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'),
361
('OAI-PMH:MaxCount','50',NULL,'OAI-PMH maximum number of records by answer to ListRecords and ListIdentifiers queries','Integer'),
361
('OAI-PMH:MaxCount','50',NULL,'OAI-PMH maximum number of records by answer to ListRecords and ListIdentifiers queries','Integer'),
362
('OPACAcquisitionDetails','0','','Show the acquisition details at the OPAC','YesNo'),
362
('OPACAcquisitionDetails','0','','Show the acquisition details at the OPAC','YesNo'),
363
('OPACSuggestionAutoFill','0',NULL,'Automaticly fill forms with data from Google Books API','YesNo'),
363
('OPACSuggestionAutoFill','0',NULL,'Automatically fill OPAC suggestion form with data from Google Books API','YesNo'),
364
('OpacAddMastheadLibraryPulldown','0','','Adds a pulldown menu to select the library to search on the opac masthead.','YesNo'),
364
('OpacAddMastheadLibraryPulldown','0','','Adds a pulldown menu to select the library to search on the opac masthead.','YesNo'),
365
('OpacAdvSearchMoreOptions','pubdate,itemtype,language,subtype,sorting,location','Show search options for the expanded view (More options)','pubdate|itemtype|language|subtype|sorting|location','multiple'),
365
('OpacAdvSearchMoreOptions','pubdate,itemtype,language,subtype,sorting,location','Show search options for the expanded view (More options)','pubdate|itemtype|language|subtype|sorting|location','multiple'),
366
('OpacAdvSearchOptions','pubdate,itemtype,language,sorting,location','Show search options','pubdate|itemtype|language|subtype|sorting|location','multiple'),
366
('OpacAdvSearchOptions','pubdate,itemtype,language,sorting,location','Show search options','pubdate|itemtype|language|subtype|sorting|location','multiple'),
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/opac.pref (-1 / +1 lines)
Lines 531-537 OPAC: Link Here
531
              choices:
531
              choices:
532
                  yes: Enable
532
                  yes: Enable
533
                  no: Disable
533
                  no: Disable
534
            - automatic form filling with data from Google Books API.
534
            - OPAC suggestions form automatically filling with data from Google Books API.
535
        -
535
        -
536
            - "Use the following as the OPAC ISBD template:"
536
            - "Use the following as the OPAC ISBD template:"
537
            - pref: OPACISBD
537
            - pref: OPACISBD
(-)a/koha-tmpl/opac-tmpl/bootstrap/en/includes/opac-bottom.inc (-4 lines)
Lines 244-253 $.widget.bridge('uitooltip', $.ui.tooltip); Link Here
244
    </script>
244
    </script>
245
[% END %]
245
[% END %]
246
246
247
[% IF ( Koha.Preference('OPACSuggestionAutoFill') ) %]
248
    <script type="text/javascript" src="[% interface %]/[% theme %]/js/autofill.js"></script>
249
[% END %]
250
251
[% IF ( BakerTaylorEnabled ) %]
247
[% IF ( BakerTaylorEnabled ) %]
252
    [% Asset.js("js/bakertaylorimages.js") | $raw %]
248
    [% Asset.js("js/bakertaylorimages.js") | $raw %]
253
    <script>
249
    <script>
(-)a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-suggestions.tt (-4 / +11 lines)
Lines 56-63 Link Here
56
56
57
                            <form action="/cgi-bin/koha/opac-suggestions.pl" method="post" id="add_suggestion_form">
57
                            <form action="/cgi-bin/koha/opac-suggestions.pl" method="post" id="add_suggestion_form">
58
                                [% IF Koha.Preference( 'OPACSuggestionAutoFill' ) %]
58
                                [% IF Koha.Preference( 'OPACSuggestionAutoFill' ) %]
59
                                <fieldset class="rows well" style="margin-bottom: 3em;padding-top: 5px;">
59
                                <fieldset class="rows well" style="margin-bottom: 3em;padding: 5px;">
60
                                    <label for="isbn">Standard number (ISBN, ISSN or other):</label><input type="text" id="isbn" name="isbn"  maxlength="80" />
60
                                    <ol><li>
61
                                        <label for="isbn">Standard number (ISBN, ISSN or other):</label>
62
                                        <input type="text" id="isbn" name="isbn" maxlength="80" style="margin-right:10px;margin-top:10px;" size="15"/>
63
                                    </li></ol>
61
                                </fieldset>
64
                                </fieldset>
62
                                [% END %]
65
                                [% END %]
63
                                    <fieldset class="rows [% IF Koha.Preference( 'OPACSuggestionAutoFill' ) %]well[% END %]">
66
                                    <fieldset class="rows [% IF Koha.Preference( 'OPACSuggestionAutoFill' ) %]well[% END %]">
Lines 86-96 Link Here
86
                                            <div title="Copyright or publication year, for example: 2016">
89
                                            <div title="Copyright or publication year, for example: 2016">
87
                                                [% IF ( copyrightdate_required ) %]
90
                                                [% IF ( copyrightdate_required ) %]
88
                                                    <label for="copyrightdate" class="required">Copyright date:</label>
91
                                                    <label for="copyrightdate" class="required">Copyright date:</label>
89
                                                    <input type="text" id="copyrightdate" name="copyrightdate" pattern="[12]\d{3}" size="4" maxlength="4" value="[% copyrightdate | html %]" required="required" />
92
                                                    <input type="text" id="copyrightdate" name="copyrightdate" pattern="[12]\d{3}" size="10" maxlength="4" value="[% copyrightdate | html %]" required="required" />
90
                                                <span class="required">Required</span>
93
                                                <span class="required">Required</span>
91
                                                [% ELSE %]
94
                                                [% ELSE %]
92
                                                    <label for="copyrightdate">Copyright date:</label>
95
                                                    <label for="copyrightdate">Copyright date:</label>
93
                                                    <input type="text" id="copyrightdate" name="copyrightdate" pattern="[12]\d{3}" size="4" maxlength="4" value="[% copyrightdate | html %]" />
96
                                                    <input type="text" id="copyrightdate" name="copyrightdate" pattern="[12]\d{3}" size="10" maxlength="4" value="[% copyrightdate | html %]" />
94
                                                [% END %]
97
                                                [% END %]
95
                                            </div>
98
                                            </div>
96
                                        </li>
99
                                        </li>
Lines 439-444 Link Here
439
442
440
[% INCLUDE 'opac-bottom.inc' %]
443
[% INCLUDE 'opac-bottom.inc' %]
441
[% BLOCK jsinclude %]
444
[% BLOCK jsinclude %]
445
[% IF ( Koha.Preference("OPACSuggestionAutoFill") ) %]
446
    [% Asset.js("js/autofill.js") | $raw %]
447
[% END %]
442
[% Asset.js("lib/jquery/plugins/jquery.checkboxes.min.js") | $raw %]
448
[% Asset.js("lib/jquery/plugins/jquery.checkboxes.min.js") | $raw %]
443
[% INCLUDE 'datatables.inc' %]
449
[% INCLUDE 'datatables.inc' %]
444
<script>
450
<script>
Lines 464-469 Link Here
464
            'volumeInfo.title': {target: 'title', effect: 'flash'},
470
            'volumeInfo.title': {target: 'title', effect: 'flash'},
465
            'volumeInfo.authors': {target: 'author', effect: 'flash'},
471
            'volumeInfo.authors': {target: 'author', effect: 'flash'},
466
            'volumeInfo.publisher': {target: 'publishercode', effect: 'flash'},
472
            'volumeInfo.publisher': {target: 'publishercode', effect: 'flash'},
473
            'volumeInfo.publishedDate': {target: 'copyrightdate', effect: 'flash'},
467
            /* google books api seem to only have books, so if we got a result
474
            /* google books api seem to only have books, so if we got a result
468
             * item, type will be a book, so set to BK (book). */
475
             * item, type will be a book, so set to BK (book). */
469
            'kind': {target: 'itemtype', handle: function(t,v) { t.val('BK'); },},
476
            'kind': {target: 'itemtype', handle: function(t,v) { t.val('BK'); },},
(-)a/koha-tmpl/opac-tmpl/bootstrap/js/autofill.js (-11 / +8 lines)
Lines 1-7 Link Here
1
/*
1
/*
2
 * jQuery autofill plugin
2
 * Plugin dealing with the Google API based on jQuery autofill plugin
3
 * https://plugins.jquery.com/autofill/
3
 *
4
 *
4
 * Automaticly fills form inputs with relevant data based on search result
5
 * Automatically fills form inputs with relevant data based on search result
6
 * Modified for OPAC Suggestion form
5
 */
7
 */
6
8
7
(function ($) {
9
(function ($) {
Lines 26-36 Link Here
26
        self.fields = fields;
28
        self.fields = fields;
27
29
28
        /* decorate element as autofiller */
30
        /* decorate element as autofiller */
29
        var $inputgroup = $('<div class="input-prepend">');
31
        self.$undo = $('<input type="button" class="btn" style="display:none;margin-left:5px;" value="' + MSG_UNDO_AUTOFILL_SUGGESTION + '" />');
30
        self.$undo = $('<span class="add-on" style="display:none;cursor:pointer;">' + MSG_UNDO_AUTOFILL_SUGGESTION + '</span>');
32
        self.$fillbtn = $('<input type="button" class="btn" value="' + MSG_SEARCH_GOOGLE_BOOKS + '" />');
31
        self.$fillbtn = $('<span class="add-on" style="cursor:pointer;">' + MSG_SEARCH_GOOGLE_BOOKS + '</span>');
33
        self.$error = $('<span class="add-on" style="display:none;padding-left:5px;"></span>');
32
        self.$error = $('<span class="add-on" style="display:none;"></span>');
33
        self.$elm.wrap($inputgroup);
34
        self.$elm.after(self.$error);
34
        self.$elm.after(self.$error);
35
        self.$elm.after(self.$undo);
35
        self.$elm.after(self.$undo);
36
        self.$elm.after(self.$fillbtn);
36
        self.$elm.after(self.$fillbtn);
Lines 65-77 Link Here
65
            self.$fillbtn.fadeOut(1000).fadeIn(1000);
65
            self.$fillbtn.fadeOut(1000).fadeIn(1000);
66
            if ( self.$elm.val()) {
66
            if ( self.$elm.val()) {
67
                var gAPI = 'https://www.googleapis.com/books/v1/volumes?q=';
67
                var gAPI = 'https://www.googleapis.com/books/v1/volumes?q=';
68
                if(self.type)
69
                    gAPI += self.type + ':';
70
                gAPI += self.$elm.val().replace(/\-/g, '');
68
                gAPI += self.$elm.val().replace(/\-/g, '');
71
                gAPI += '&maxResults=1';
69
                gAPI += '&maxResults=1';
72
                $.getJSON(gAPI, function (response) {
70
                $.getJSON(gAPI, function (response) {
73
                    if(response.totalItems == 0) {
71
                    if(response.totalItems == 0) {
74
                        self.$error.html('Sorry, nothing found.');
72
                        self.$error.html(_('Sorry, nothing found.'));
75
                        self.$error.show();
73
                        self.$error.show();
76
                        return;
74
                        return;
77
                    }
75
                    }
78
- 

Return to bug 14242