From 1b4c6fbd52c3426b0a0b62d422cfd9043c9af219 Mon Sep 17 00:00:00 2001 From: Owen Leonard Date: Tue, 29 Sep 2020 11:12:31 +0000 Subject: [PATCH] Bug 26572: Add autocomplete to librarian field in log viewer This patch adds patron autocomplete to the librarian field in the log viewer search form. Also changed: Some HTML markup errors in the template have been corrected: Labels with invalid corresponding ids or with no valid id. To test, apply the patch and go to Tools -> Log Viewer. Type a name or cardnumber into the "Librarian" form field. This should trigger an autocomplete dropdown. Select a patron and confirm that the field is populated with the correct borrowernumber. Signed-off-by: David Nind --- .../intranet-tmpl/prog/en/modules/tools/viewlog.tt | 10 +++++----- koha-tmpl/intranet-tmpl/prog/js/viewlog.js | 22 ++++++++++++++++++++++ 2 files changed, 27 insertions(+), 5 deletions(-) diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/viewlog.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/tools/viewlog.tt index 1a1f8fb18c..11cb6c0d92 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/viewlog.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/tools/viewlog.tt @@ -147,7 +147,7 @@ [% UNLESS src == "circ" %]
  • - +
    [% IF modules.size == 0 %] @@ -168,7 +168,7 @@ [% END %]
  • - +
    [% IF actions.length == 0 %] @@ -178,9 +178,9 @@ [% FOREACH actx IN [ 'ADD' 'DELETE' 'MODIFY' 'ISSUE' 'RETURN' 'RENEW' 'CREATE' 'CANCEL' 'SUSPEND' 'RESUME' 'ADDCIRCMESSAGE' 'DELCIRCMESSAGE' 'STATUS_CHANGE' 'CHANGE PASS' 'Run' ] %] [% IF actions.grep(actx).size %] - + [% ELSE %] - + [% END %] [% END %]
    @@ -199,7 +199,7 @@
  • - + [% IF interfaces.size == 0 %] [% ELSE %] diff --git a/koha-tmpl/intranet-tmpl/prog/js/viewlog.js b/koha-tmpl/intranet-tmpl/prog/js/viewlog.js index 58c126de59..ff835f5787 100644 --- a/koha-tmpl/intranet-tmpl/prog/js/viewlog.js +++ b/koha-tmpl/intranet-tmpl/prog/js/viewlog.js @@ -144,4 +144,26 @@ $(document).ready(function(){ e.preventDefault(); $(".compare:checked").prop("checked", false).change(); }); + var obj = $("#user").autocomplete({ + source: "/cgi-bin/koha/circ/ysearch.pl", + minLength: 3, + select: function ( event, ui ) { + $("#user").val( ui.item.borrowernumber ); + return false; + } + }).data("ui-autocomplete"); + if (obj) { + obj._renderItem = function (ul, item) { + var cardnumber = ""; + if (item.cardnumber != "") { + // Display card number in parentheses if it exists + cardnumber = " (" + item.cardnumber + ") "; + } + return $("
  • ") + .data("ui-autocomplete-item", item) + .append("" + item.surname + ", " + item.firstname + cardnumber + " " + item.dateofbirth + " " + item.address + " " + item.city + " " + item.zipcode + " " + item.country + "") + .appendTo(ul); + }; + } + }); -- 2.11.0