Browse Source

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 <david@davidnind.com>

Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
20.11.x
Owen Leonard 4 years ago
committed by Jonathan Druart
parent
commit
38507b041b
  1. 10
      koha-tmpl/intranet-tmpl/prog/en/modules/tools/viewlog.tt
  2. 22
      koha-tmpl/intranet-tmpl/prog/js/viewlog.js

10
koha-tmpl/intranet-tmpl/prog/en/modules/tools/viewlog.tt

@ -160,7 +160,7 @@
</li>
[% UNLESS src == "circ" %]
<li>
<label for="modules">Modules:</label>
<label>Modules:</label>
<div class="log_modules">
[% IF modules.size == 0 %]
<label for="moduleALL" class="viewlog"><input type="checkbox" id="moduleALL" name="modules" value="" checked="checked"> All</label>
@ -181,7 +181,7 @@
<input type="hidden" name="modules" value="CIRCULATION" />
[% END %]
<li>
<label for="actions">Actions:</label>
<label>Actions:</label>
<div class="log_modules">
[% IF actions.length == 0 %]
<label for="actionALL" class="viewlog"><input type="checkbox" id="actionALL" name="actions" value="" checked="checked"> All</label>
@ -191,9 +191,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 %]
<label for="action[% actx | html %]" class="viewlog"><input type="checkbox" id="action[% actx | html %]" name="actions" value="[% actx | html %]" checked="checked"> [% PROCESS translate_log_action action=actx %]</label>
<label for="action[% actx| replace('\s+', '_') | html %]" class="viewlog"><input type="checkbox" id="action[% actx | replace('\s+', '_') | html %]" name="actions" value="[% actx | html %]" checked="checked"> [% PROCESS translate_log_action action=actx %]</label>
[% ELSE %]
<label for="action[% actx | html %]" class="viewlog"><input type="checkbox" id="action[% actx | html %]" name="actions" value="[% actx | html %]"> [% PROCESS translate_log_action action=actx %]</label>
<label for="action[% actx| replace('\s+', '_') | html %]" class="viewlog"><input type="checkbox" id="action[% actx | replace('\s+', '_') | html %]" name="actions" value="[% actx | html %]"> [% PROCESS translate_log_action action=actx %]</label>
[% END %]
[% END %]
</div>
@ -212,7 +212,7 @@
<input type="text" id="info" name="info" value="[% info | html %]" />
</li>
<li>
<label for="interfaces">Interface:</label>
<label>Interface:</label>
[% IF interfaces.size == 0 %]
<label for="interfaceALL" class="viewlog"><input type="checkbox" id="interfaceALL" name="interfaces" value="" checked="checked"> All</label>
[% ELSE %]

22
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 $("<li></li>")
.data("ui-autocomplete-item", item)
.append("<a href=\"#\">" + item.surname + ", " + item.firstname + cardnumber + " <small>" + item.dateofbirth + " " + item.address + " " + item.city + " " + item.zipcode + " " + item.country + "</small></a>")
.appendTo(ul);
};
}
});

Loading…
Cancel
Save