Bugzilla – Attachment 165232 Details for
Bug 35560
Use the REST API for holds history
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 35560: Add filter on status
Bug-35560-Add-filter-on-status.patch (text/plain), 7.34 KB, created by
Lucas Gass (lukeg)
on 2024-04-19 22:31:26 UTC
(
hide
)
Description:
Bug 35560: Add filter on status
Filename:
MIME Type:
Creator:
Lucas Gass (lukeg)
Created:
2024-04-19 22:31:26 UTC
Size:
7.34 KB
patch
obsolete
>From f89ef4628aa751e4912415d84fe476bd4ea360b8 Mon Sep 17 00:00:00 2001 >From: Jonathan Druart <jonathan.druart@bugs.koha-community.org> >Date: Mon, 25 Mar 2024 16:27:23 +0100 >Subject: [PATCH] Bug 35560: Add filter on status > >Signed-off-by: Lucas Gass <lucas@bywatersolutions.com> >--- > .../prog/en/modules/members/holdshistory.tt | 99 +++++++++++++++++-- > 1 file changed, 93 insertions(+), 6 deletions(-) > >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/members/holdshistory.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/members/holdshistory.tt >index 797eac1afa..3a08912316 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/members/holdshistory.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/members/holdshistory.tt >@@ -56,6 +56,30 @@ > <div id="holdshistory" class="page-section"> > <h2>Current holds</h2> > [% IF patron.holds.count %] >+ <div id="current_holds_filters" data-table-id="table_holdshistory"> >+ <p> >+ <span class="selected"> >+ <input id="current_show_all" type="checkbox" checked="checked" class="show_all"/> >+ <label for="current_show_all">Show all</label> >+ </span> >+ <span class="selected"> >+ <input id="current_pending_filter" type="checkbox" checked="checked" /> >+ <label for="current_pending_filter">Pending</label> >+ </span> >+ <span class="selected"> >+ <input id="current_waiting_filter" type="checkbox" checked="checked" /> >+ <label for="current_waiting_filter">Waiting</label> >+ </span> >+ <span class="selected"> >+ <input id="current_processing_filter" type="checkbox" checked="checked" /> >+ <label for="current_processing_filter">Processing</label> >+ </span> >+ <span class="selected"> >+ <input id="current_transit_filter" type="checkbox" checked="checked" /> >+ <label for="current_transit_filter">In transit</label> >+ </span> >+ </p> >+ </div> > <table id="table_holdshistory"> > <thead> > <tr> >@@ -81,6 +105,22 @@ > > <h2>Historical holds</h2> > [% IF patron.old_holds.count %] >+ <div id="old_holds_filters" data-table-id="table_oldholdshistory"> >+ <p> >+ <span class="selected"> >+ <input id="old_show_all" type="checkbox" checked="checked" class="show_all"/> >+ <label for="old_show_all">Show all</label> >+ </span> >+ <span class="selected"> >+ <input id="old_fulfilled_filter" type="checkbox" checked="checked" /> >+ <label for="old_fulfilled_filter">Fulfilled</label> >+ </span> >+ <span class="selected"> >+ <input id="old_cancelled_filter" type="checkbox" checked="checked" /> >+ <label for="old_cancelled_filter">Cancelled</label> >+ </span> >+ </p> >+ </div> > <table id="table_oldholdshistory"> > <thead> > <tr> >@@ -129,12 +169,46 @@ > //Remove item type column settings > table_settings['columns'] = table_settings['columns'].filter(function(c){return c['columnname'] != 'itemtype';}); > [% END %] >- build_holds_table("#table_holdshistory"); >- build_holds_table("#table_oldholdshistory", 1); >+ let current_holds_table = build_holds_table("#table_holdshistory"); >+ let old_holds_table = build_holds_table("#table_oldholdshistory", 1); > function build_holds_table(table_id, old){ >+ let additional_filters = { >+ "-or": function(){ >+ let statuses = []; >+ let include_cancelled = false; >+ if ( table_id == '#table_holdshistory' ) { >+ if ( $("#current_pending_filter").is(":checked") ) { >+ statuses.push(null); >+ } >+ if ( $("#current_waiting_filter").is(":checked") ) { >+ statuses.push("W"); >+ } >+ if ( $("#current_processing_filter").is(":checked") ) { >+ statuses.push("P"); >+ } >+ if ( $("#current_transit_filter").is(":checked") ) { >+ statuses.push("T"); >+ } >+ } else { >+ if ( $("#old_fulfilled_filter").is(":checked") ) { >+ statuses.push("F"); >+ } >+ if ( $("#old_cancelled_filter").is(":checked") ) { >+ include_cancelled = true; >+ } >+ } >+ if ( include_cancelled ) { >+ return [{status: statuses}, { cancellation_date: {"<": new Date().toISOString() } } ]; // cancellation_date cannot be in the future. Would be better a 'not null' here however. >+ } else { >+ return [{status: statuses}]; >+ } >+ }, >+ >+ }; >+ > let table_url = '/api/v1/patrons/[% patron.borrowernumber | uri %]/holds'; > if (old){table_url += '?old=1'} >- $(table_id).kohaTable({ >+ return $(table_id).kohaTable({ > ajax: { > url: table_url, > }, >@@ -232,8 +306,8 @@ > }, > [% END %] > { >- data: "found", // FIXME filter with dropdown list >- searchable: true, >+ data: "status", >+ searchable: false, > orderable: true, > render: function (data, type, row, meta) { > if ( row.status == 'F' ) { >@@ -256,8 +330,21 @@ > } > }, > ], >- }, table_settings); >+ }, table_settings, true, additional_filters); > } >+ $("#current_holds_filters :checkbox, #old_holds_filters :checkbox").on("change", function(e){ >+ e.preventDefault(); >+ let container = $(this).closest("div"); >+ if ( $(this).hasClass("show_all") ) { >+ if ( $(this).is(":checked") ) { >+ container.find(":checkbox").prop("checked", true); >+ } >+ } else if ( $(this).not(":checked") ) { >+ container.find(".show_all").prop("checked", false); >+ } >+ let table_dt = $("#"+container.data("table-id")).DataTable(); >+ table_dt.draw(); >+ }); > }); > </script> > [% END %] >-- >2.30.2
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 35560
:
160100
|
160101
|
163831
|
163832
|
164093
|
165231
|
165232
|
165233
|
177161
|
177162
|
177163
|
177200
|
177201
|
177202
|
177203