From 2f7f15bfff29435ddd2c7583391e10d8a93bcfd2 Mon Sep 17 00:00:00 2001 From: Owen Leonard Date: Mon, 9 Nov 2020 19:36:22 +0000 Subject: [PATCH] Bug 27296: Return claims should be filtered by default to show unresolved claims This patch modifies the DataTables configuration of the return claims table on the checkout and patron detail pages. Using the footerCallback function, the count of resolved and unresolved claims is calculated and used to filter the list of claims to show only unresolved claims by default. To test, apply the patch and rebuild the staff interface CSS (https://wiki.koha-community.org/wiki/Working_with_SCSS_in_the_OPAC_and_staff_client). - If necessary, Enable claims returned functionality by defining a value in the ClaimReturnedLostValue system preference. - Open for checkout a patron who has items checked out. - From the table of checkouts, click "Claim returned" for one or more items. - As you mark items "Clamed returned," the the items should appear under the "Claims" tab. The corresonding filter links should be updated accordingly, "Show all X claims." - Mark one or more claims resolved. As you do so they should disappear from the list of claims. The filter links should be updated to reflect that there are some resolved and some unresolved claims. - Clicking each filter link should trigger the correct filter. - Test this process when the count of unresolved claims is zero and when the cound of resolved claims is zero. TESTING TRANSLATABILITY - Update a translation, e.g. fr-FR: > cd misc/translator > perl translate update fr-FR - Open the corresponding .po file for JavaScript strings, e.g. misc/translator/po/fr-FR-messages-js.po - Locate strings pulled from koha-tmpl/intranet-tmpl/prog/js/checkouts.js for translation, e.g.: #: koha-tmpl/intranet-tmpl/prog/js/checkouts.js:1086 msgid "Show 1 claim" msgid_plural "Show all {count} claims" msgstr[0] "" msgstr[1] "" - Edit the "msgstr" strings however you want (it's just for testing). - Install the updated translation: > perl translate install fr-FR - Switch to your newly translated language in the staff client and repeat the test plan above. The translated strings should appear. --- .../intranet-tmpl/prog/css/src/staff-global.scss | 5 +- .../prog/en/includes/patron-return-claims.inc | 12 ++++- koha-tmpl/intranet-tmpl/prog/js/checkouts.js | 59 ++++++++++++++++++++++ 3 files changed, 74 insertions(+), 2 deletions(-) diff --git a/koha-tmpl/intranet-tmpl/prog/css/src/staff-global.scss b/koha-tmpl/intranet-tmpl/prog/css/src/staff-global.scss index 4b243ca1e9..67025cc4d6 100644 --- a/koha-tmpl/intranet-tmpl/prog/css/src/staff-global.scss +++ b/koha-tmpl/intranet-tmpl/prog/css/src/staff-global.scss @@ -60,7 +60,6 @@ a { } } - &.csv { background-image: url("../img/famfamfam/silk/page_white_excel.png"); } @@ -123,6 +122,10 @@ a { } } +a.ctrl_link { + display: inline-block; + padding-right: 1rem; +} aside { h5 { diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/patron-return-claims.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/patron-return-claims.inc index 63f1dad303..b2ad9700a9 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/includes/patron-return-claims.inc +++ b/koha-tmpl/intranet-tmpl/prog/en/includes/patron-return-claims.inc @@ -1,14 +1,24 @@
+

+ [% IF ( patron.return_claims.resolved.count > 0 || patron.return_claims.unresolved.count > 0 ) %] + Show all [% patron.return_claims.count | html %] claim(s) + Show [% patron.return_claims.unresolved.count | html %] unresolved claims + [% ELSE %] + + + [% END %] +

+ - +
Claim IDResolved? Title Notes Created on Updated on Resolution  
diff --git a/koha-tmpl/intranet-tmpl/prog/js/checkouts.js b/koha-tmpl/intranet-tmpl/prog/js/checkouts.js index 7f6cd6bdc0..bd8bd538be 100644 --- a/koha-tmpl/intranet-tmpl/prog/js/checkouts.js +++ b/koha-tmpl/intranet-tmpl/prog/js/checkouts.js @@ -934,12 +934,26 @@ $(document).ready(function() { "bAutoWidth": false, "sDom": "rt", "aaSorting": [], + "aoColumnDefs": [ + { "bSortable": false, "bSearchable": false, 'aTargets': ['NoSort'] }, + { "sType": "anti-the", "aTargets": ["anti-the"] }, + ], "aoColumns": [ { "mDataProp": "id", "bVisible": false, }, { + "mDataProp": function (oObj) { + if (oObj.resolution) { + return "is_resolved"; + } else { + return "is_unresolved"; + } + }, + "bVisible": false, + }, + { "mDataProp": function ( oObj ) { let title = '' + oObj.title @@ -1047,10 +1061,41 @@ $(document).ready(function() { fnCallback(json) } ); }, + "search": { "search": "is_unresolved" }, + "footerCallback": function (row, data, start, end, display) { + var api = this.api(); + // Total over all pages + var colData = api.column(1).data(); + var is_unresolved = 0; + var is_resolved = 0; + colData.each(function( index, value ){ + if( index == "is_unresolved" ){ is_unresolved++; } + if (index == "is_resolved") { is_resolved++; } + }); + // Update footer + $("#return-claims-controls").html( showClaimFilter( is_unresolved, is_resolved ) ) + } }); } } + function showClaimFilter( is_unresolved, is_resolved ){ + var showAll, showUnresolved; + var total = Number( is_unresolved ) + Number( is_resolved ); + if( total > 0 ){ + showAll = __nx("Show 1 claim", "Show all {count} claims", total, { count: total }); + } else { + showAll = ""; + } + if( is_unresolved > 0 ){ + showUnresolved = __nx("Show 1 unresolved claim", "Show {count} unresolved claims", is_unresolved, { count: is_unresolved }) + } else { + showUnresolved = ""; + } + $("#show_all_claims").html( showAll ); + $("#show_unresolved_claims").html( showUnresolved ); + } + $('body').on('click', '.return-claim-tools-editnotes', function() { let id = $(this).data('return-claim-id'); $('#return-claim-notes-static-' + id).parent().dblclick(); @@ -1155,4 +1200,18 @@ $(document).ready(function() { }); + $("#show_all_claims").on("click", function(e){ + e.preventDefault(); + $(".ctrl_link").removeClass("disabled"); + $(this).addClass("disabled"); + $("#return-claims-table").DataTable().search("").draw(); + }); + + $("#show_unresolved_claims").on("click", function (e) { + e.preventDefault(); + $(".ctrl_link").removeClass("disabled"); + $(this).addClass("disabled"); + $("#return-claims-table").DataTable().search("is_unresolved").draw(); + }); + }); -- 2.11.0