Browse Source

Bug 25968: Make logs sort by date descending as a default

This patch adds DataTables with columns configuration to the log viewer.
The table of log entries is now sorted by default by date descending.

To test, apply the patch and go to Administration -> Table settings.

 - Expand the "Tools" section and confirm that there is a section for
   "logviewer."
 - Go to Tools -> Log viewer.
 - Perform a search which will return multiple results.
 - Confirm that the results are sorted by date descending.
 - Test that the table controls work correctly: Paging, columns, export.
 - Return to the Table settings administration page and test that
   changes to those settings are correctly reflected in the log viewer
   table.

Signed-off-by: barbara <barbara.johnson@bedfordtx.gov>

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

JD amended patch: Fix indentation in .yml to match other entries

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
e68fe2a928
  1. 17
      admin/columns_settings.yml
  2. 12
      koha-tmpl/intranet-tmpl/prog/en/modules/tools/viewlog.tt
  3. 6
      koha-tmpl/intranet-tmpl/prog/js/viewlog.js

17
admin/columns_settings.yml

@ -1361,6 +1361,23 @@ modules:
columnname: spent columnname: spent
tools: tools:
logviewer:
logst:
columns:
-
columnname: date
-
columnname: librarian
-
columnname: module
-
columnname: action
-
columnname: object
-
columnname: info
-
columnname: interface
notices: notices:
lettert: lettert:
columns: columns:

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

@ -4,6 +4,7 @@
[% USE AuthorisedValues %] [% USE AuthorisedValues %]
[% USE Branches %] [% USE Branches %]
[% USE KohaDates %] [% USE KohaDates %]
[% USE TablesSettings %]
[% SET footerjs = 1 %] [% SET footerjs = 1 %]
[% INCLUDE 'doc-head-open.inc' %] [% INCLUDE 'doc-head-open.inc' %]
<title> <title>
@ -222,8 +223,8 @@ fieldset.rows label.viewlog {
</form> </form>
[% IF ( do_it ) %] [% IF ( do_it ) %]
[% IF ( total ) %] [% IF ( total ) %]
<h4>[% total | html %] lines found.</h4> <h3>Log entries</h3>
<table> <table id="logst">
<thead> <thead>
<tr> <tr>
<th>Date</th> <th>Date</th>
@ -238,7 +239,7 @@ fieldset.rows label.viewlog {
<tbody> <tbody>
[% FOREACH loopro IN looprow %] [% FOREACH loopro IN looprow %]
<tr> <tr>
<td>[% loopro.timestamp | $KohaDates with_hours=1 %]</td> <td data-order="[% loopro.timestamp | html %]">[% loopro.timestamp | $KohaDates with_hours=1 %]</td>
<td> <td>
[% IF loopro.librarian %] [% IF loopro.librarian %]
<a href="/cgi-bin/koha/members/moremember.pl?borrowernumber=[% loopro.librarian.borrowernumber | uri %]" title="display detail for this librarian."> [% IF ( loopro.librarian.firstname ) || ( loopro.librarian.surname ) %][% loopro.librarian.firstname | html %] [% loopro.librarian.surname | html %] ([% loopro.librarian.borrowernumber | html %]) [% ELSE %][% loopro.librarian.borrowernumber | html %][% END %]</a> <a href="/cgi-bin/koha/members/moremember.pl?borrowernumber=[% loopro.librarian.borrowernumber | uri %]" title="display detail for this librarian."> [% IF ( loopro.librarian.firstname ) || ( loopro.librarian.surname ) %][% loopro.librarian.firstname | html %] [% loopro.librarian.surname | html %] ([% loopro.librarian.borrowernumber | html %]) [% ELSE %][% loopro.librarian.borrowernumber | html %][% END %]</a>
@ -325,11 +326,16 @@ fieldset.rows label.viewlog {
[% MACRO jsinclude BLOCK %] [% MACRO jsinclude BLOCK %]
[% INCLUDE 'calendar.inc' %] [% INCLUDE 'calendar.inc' %]
[% INCLUDE 'datatables.inc' %]
[% INCLUDE 'columns_settings.inc' %]
[% Asset.js("js/tools-menu.js") | $raw %] [% Asset.js("js/tools-menu.js") | $raw %]
[% IF ( circulation ) %] [% IF ( circulation ) %]
[% INCLUDE 'str/members-menu.inc' %] [% INCLUDE 'str/members-menu.inc' %]
[% Asset.js("js/members-menu.js") | $raw %] [% Asset.js("js/members-menu.js") | $raw %]
[% END %] [% END %]
<script>
var columns_settings = [% TablesSettings.GetColumns('tools', 'logviewer', 'logst', 'json') | $raw %];
</script>
[% Asset.js("js/viewlog.js") | $raw %] [% Asset.js("js/viewlog.js") | $raw %]
[% END %] [% END %]

6
koha-tmpl/intranet-tmpl/prog/js/viewlog.js

@ -61,4 +61,10 @@ $(document).ready(function(){
tickAll('interfaces'); tickAll('interfaces');
} }
}); });
var logst = KohaTable("logst", {
"autoWidth": false,
"order": [[0, "desc"]],
"pagingType" : "full"
}, columns_settings);
}); });

Loading…
Cancel
Save