Bug 25553: Make date columns sortable on the edit items table

When editing items, the table at the top contain several columns that
have date values, but they cannot be sorted by dates correctly.

Test plan:
Have several items with different dates in columns that contain dates,
like items.dateaccessioned, items.datelastseen)
Sort the column and confirm that with this patch the lines are sorted
correctly

Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
(cherry picked from commit 31800ba46b)

Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
This commit is contained in:
Jonathan Druart 2020-05-22 11:02:39 +02:00 committed by Lucas Gass
parent f918bee5f6
commit ca74f037d8
2 changed files with 13 additions and 3 deletions

View File

@ -872,7 +872,7 @@ for my $row ( @big_array ) {
{
my ( undef, $subfield ) = GetMarcFromKohaField($kohafield);
next unless $key eq $subfield;
$item_field->{field} = output_pref( { str => $row->{$key}, dateonly => 1 } );
$item_field->{datatype} = 'date';
}
push @item_fields, $item_field;

View File

@ -1,6 +1,7 @@
[% USE raw %]
[% USE Asset %]
[% USE Koha %]
[% USE KohaDates %]
[% USE ColumnsSettings %]
[% INCLUDE 'doc-head-open.inc' %]
<title>Koha &rsaquo; Cataloging &rsaquo; [% title | html %] [% IF ( author ) %] by [% author | html %][% END %] (Record #[% biblionumber | html %]) &rsaquo; Items</title>
@ -45,6 +46,7 @@
<div id="cataloguing_additem_itemlist">
[% IF ( item_loop ) %]
[% SET date_fields = [ 'dateaccessioned', 'onloan', 'datelastseen', 'datelastborrowed', 'replacementpricedate' ] %]
<div>
<table id="itemst">
<thead>
@ -52,7 +54,11 @@
<th>&nbsp;</th>
[% FOREACH item_header IN item_header_loop %]
[% IF item_header.column_name %]
<th data-colname="[% item_header.column_name | html %]">
[% IF date_fields.grep(item_header.column_name).size %]
<th class="title-string" data-colname="[% item_header.column_name | html %]">
[% ELSE %]
<th data-colname="[% item_header.column_name | html %]">
[% END %]
[% ELSE %]
<th>
[% END %]
@ -106,7 +112,11 @@
</td>
[% END %]
[% FOREACH item_valu IN item_loo.item_value %]
<td>[% item_valu.field | html %]</td>
[% IF item_valu.datatype == 'date' %]
<td><span title="[% item_valu.field | html %]">[% item_valu.field | $KohaDates %]</span></td>
[% ELSE %]
<td>[% item_valu.field | html %]</td>
[% END %]
[% END %]
</tr>
[% END %]