Bugzilla – Attachment 189095 Details for
Bug 17387
Add an undelete feature for items/biblios
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 17387: add sidebar date filtering for item/biblio restore
Bug-17387-add-sidebar-date-filtering-for-itembibli.patch (text/plain), 5.97 KB, created by
Jacob O'Mara
on 2025-11-05 15:39:55 UTC
(
hide
)
Description:
Bug 17387: add sidebar date filtering for item/biblio restore
Filename:
MIME Type:
Creator:
Jacob O'Mara
Created:
2025-11-05 15:39:55 UTC
Size:
5.97 KB
patch
obsolete
>From 23701e3ab37566b029e40fbc7d78ce17a0c7c70e Mon Sep 17 00:00:00 2001 >From: Jacob O'Mara <Jacob.omara@openfifth.co.uk> >Date: Thu, 30 Oct 2025 12:50:46 +0000 >Subject: [PATCH] Bug 17387: add sidebar date filtering for item/biblio restore > >--- > .../prog/en/modules/tools/restore-records.tt | 96 +++++++++++++++++-- > 1 file changed, 88 insertions(+), 8 deletions(-) > >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/restore-records.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/tools/restore-records.tt >index 1e9a28947c0..bd73665c189 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/restore-records.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/tools/restore-records.tt >@@ -30,12 +30,9 @@ > [% END #/ WRAPPER breadcrumbs %] > [% END #/ WRAPPER sub-header.inc %] > >-[% SET asides = [] %] >-[% asides.push('cat-menu') %] >- >-[% WRAPPER 'main-container.inc' %] >+<div class="main container-fluid"> > <div class="row"> >- <div class="col-md-10 col-md-push-2"> >+ <div class="col-md-10 order-md-2 order-sm-1"> > <main> > <h1>Restore deleted records</h1> > >@@ -74,8 +71,36 @@ > </div> > </main> > </div> >+ >+ <div class="col-md-2 order-sm-2 order-md-1"> >+ <aside> >+ <div id="filters"> >+ <fieldset class="brief"> >+ <h4>Filter results</h4> >+ <ol> >+ <li> >+ <label for="from">Deleted from:</label> >+ <input type="text" size="10" id="from" name="from" class="flatpickr" data-date_to="to" /> >+ <div class="hint">[% INCLUDE 'date-format.inc' %]</div> >+ </li> >+ <li> >+ <label for="to">Deleted to:</label> >+ <input type="text" size="10" id="to" name="to" class="flatpickr" /> >+ <div class="hint">[% INCLUDE 'date-format.inc' %]</div> >+ </li> >+ </ol> >+ <fieldset class="action"> >+ <button type="button" id="filter_table" class="btn btn-primary btn-sm">Apply</button> >+ <button type="button" id="clear_filters" class="btn btn-default btn-sm">Clear</button> >+ </fieldset> >+ </fieldset> >+ </div> >+ >+ [% INCLUDE 'cat-menu.inc' %] >+ </aside> >+ </div> > </div> >-[% END #/ WRAPPER main-container.inc %] >+</div> > > <!-- Modal for deleted biblio warning --> > <div class="modal" id="deletedBiblioModal" tabindex="-1" role="dialog" aria-labelledby="deletedBiblioModalLabel"> >@@ -151,6 +176,7 @@ > [% MACRO jsinclude BLOCK %] > [% Asset.js("js/tools-menu.js") | $raw %] > [% INCLUDE 'datatables.inc' %] >+ [% INCLUDE 'calendar.inc' %] > <script> > function showMessage(message, type) { > var alert = $('<div class="alert alert-' + type + '">' + message + "</div>"); >@@ -164,10 +190,52 @@ > } > > $(document).ready(function () { >+ var oneYearAgo = new Date(); >+ oneYearAgo.setFullYear(oneYearAgo.getFullYear() - 1); >+ var today = new Date(); >+ >+ var fromDate = oneYearAgo.toISOString().split("T")[0]; >+ var toDate = today.toISOString().split("T")[0]; >+ >+ setTimeout(function () { >+ if ($("#from")[0]._flatpickr) { >+ $("#from")[0]._flatpickr.setDate(fromDate); >+ } >+ if ($("#to")[0]._flatpickr) { >+ $("#to")[0]._flatpickr.setDate(toDate); >+ } >+ }, 100); >+ >+ function buildApiUrl(baseUrl) { >+ var from = $("#from").val(); >+ var to = $("#to").val(); >+ >+ if (!from && !to) { >+ return baseUrl; >+ } >+ >+ var query = {}; >+ if (from && to) { >+ query["me.timestamp"] = { >+ "-between": [from + "T00:00:00Z", to + "T23:59:59Z"], >+ }; >+ } else if (from) { >+ query["me.timestamp"] = { >+ ">=": from + "T00:00:00Z", >+ }; >+ } else if (to) { >+ query["me.timestamp"] = { >+ "<=": to + "T23:59:59Z", >+ }; >+ } >+ >+ return baseUrl + "?q=" + encodeURIComponent(JSON.stringify(query)); >+ } >+ > // Deleted biblios DataTable > var biblios_table = $("#deleted_biblios_table").kohaTable({ > ajax: { >- url: "/api/v1/deleted/biblios", >+ url: buildApiUrl("/api/v1/deleted/biblios"), > }, > embed: "items", > order: [[3, "desc"]], >@@ -235,7 +303,7 @@ > // Deleted items DataTable > var items_table = $("#deleted_items_table").kohaTable({ > ajax: { >- url: "/api/v1/deleted/items", >+ url: buildApiUrl("/api/v1/deleted/items"), > }, > embed: "biblio", > order: [[5, "desc"]], >@@ -581,6 +649,18 @@ > }, > }); > }); >+ >+ $("#filter_table").on("click", function () { >+ biblios_table_api.ajax.url(buildApiUrl("/api/v1/deleted/biblios")).load(); >+ items_table_api.ajax.url(buildApiUrl("/api/v1/deleted/items")).load(); >+ }); >+ >+ $("#clear_filters").on("click", function () { >+ $("#from").val(""); >+ $("#to").val(""); >+ biblios_table_api.ajax.url("/api/v1/deleted/biblios").load(); >+ items_table_api.ajax.url("/api/v1/deleted/items").load(); >+ }); > }); > </script> > [% END %] >-- >2.39.5
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 17387
:
188670
|
188671
|
188672
|
188673
|
188674
|
188675
|
188676
|
188677
|
188678
|
188679
|
188680
|
188681
|
188682
|
188683
|
188684
|
188685
|
188686
|
188687
|
188688
|
188689
|
188690
|
188691
|
188692
|
188693
|
188694
|
188695
|
188696
|
188697
|
188698
|
188699
|
188700
|
188701
|
188780
|
188781
|
188782
|
188783
|
188784
|
188785
|
188786
|
188787
|
188788
|
188789
|
188790
|
188791
|
188792
|
188793
|
188794
|
188795
|
189046
|
189047
|
189048
|
189049
|
189050
|
189051
|
189052
|
189053
|
189054
|
189055
|
189056
|
189057
|
189058
|
189059
|
189060
|
189061
|
189062
|
189082
|
189083
|
189084
|
189085
|
189086
|
189087
|
189088
|
189089
|
189090
|
189091
|
189092
|
189093
|
189094
|
189095
|
189096
|
189097
|
189098
|
189099
|
189100
|
189101
|
189102
|
189103
|
189104
|
189105
|
189106
|
189107
|
189108
|
189109
|
189110
|
189111
|
189112
|
189113
|
189114
|
189115
|
189116
|
189117
|
189118
|
189119