From d8fd1c9a07b815ee5a126ba3bdfa19bf7565bf3c Mon Sep 17 00:00:00 2001 From: Martin Renvoize Date: Fri, 14 Jun 2024 16:13:26 +0100 Subject: [PATCH] Bug 37047: (QA follow-up) Move non-bookings code back We inadvertantly adding a little more than just the bookings table js into it's own asset. This patch moves that code back and also renames the asset file to /tables/bookings.js from /bookings-table.js as is the scheme we're attempting to follow now (see '/modals/'). Signed-off-by: Martin Renvoize --- .../prog/en/modules/circ/circulation.tt | 2 +- .../prog/en/modules/members/moremember.tt | 27 +++- .../intranet-tmpl/prog/js/bookings-table.js | 123 ------------------ 3 files changed, 27 insertions(+), 125 deletions(-) delete mode 100644 koha-tmpl/intranet-tmpl/prog/js/bookings-table.js diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/circulation.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/circ/circulation.tt index 57b549e86b9..ff812fe5c1d 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/circulation.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/circ/circulation.tt @@ -1137,7 +1137,7 @@ [% INCLUDE 'str/members-menu.inc' %] [% Asset.js("js/members-menu.js") | $raw %] - [% Asset.js("js/bookings-table.js") | $raw %] + [% Asset.js("js/tables/bookings.js") | $raw %] [% Asset.js("js/recalls.js") | $raw %] [% END %] diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/members/moremember.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/members/moremember.tt index 8b34ef3b6f7..4debd1abda8 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/members/moremember.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/members/moremember.tt @@ -804,8 +804,33 @@ } } } + + $(document).ready(function () { + $("#info_digests").tooltip(); + + $("#finesholdsissues a[data-toggle='tab']").on( + "shown.bs.tab", + function (e) { + var oTable = $( + "div.dataTables_wrapper > table", + $(e.target.hash) + ).dataTable(); + if (oTable.length > 0) { + oTable.fnAdjustColumnSizing(); + } + } + ); + + $("#view_restrictions").on("click", function () { + $("#reldebarments-tab").click(); + }); + + $("#view_guarantees_finesandcharges").on("click", function () { + $("#guarantees_finesandcharges-tab").click(); + }); + }); - [% Asset.js("js/bookings-table.js") | $raw %] + [% Asset.js("js/tables/bookings.js") | $raw %] [% END %] [% INCLUDE 'intranet-bottom.inc' %] diff --git a/koha-tmpl/intranet-tmpl/prog/js/bookings-table.js b/koha-tmpl/intranet-tmpl/prog/js/bookings-table.js deleted file mode 100644 index c8bab13bc5f..00000000000 --- a/koha-tmpl/intranet-tmpl/prog/js/bookings-table.js +++ /dev/null @@ -1,123 +0,0 @@ -$(document).ready(function () { - var bookings_table; - $(document).ready(function () { - $("#info_digests").tooltip(); - - $("#finesholdsissues a[data-toggle='tab']").on( - "shown.bs.tab", - function (e) { - var oTable = $( - "div.dataTables_wrapper > table", - $(e.target.hash) - ).dataTable(); - if (oTable.length > 0) { - oTable.fnAdjustColumnSizing(); - } - } - ); - - $("#view_restrictions").on("click", function () { - $("#reldebarments-tab").click(); - }); - - $("#view_guarantees_finesandcharges").on("click", function () { - $("#guarantees_finesandcharges-tab").click(); - }); - - // Bookings - // Load bookings table on tab selection - $("#bookings-tab").on("click", function () { - if (!bookings_table) { - var today = new Date(); - var bookings_table_url = "/api/v1/bookings"; - bookings_table = $("#bookings_table").kohaTable( - { - ajax: { - url: bookings_table_url, - }, - embed: ["biblio", "item", "patron"], - columns: [ - { - data: "booking_id", - title: _("Booking ID"), - }, - { - data: "biblio.title", - title: _("Title"), - searchable: true, - orderable: true, - render: function (data, type, row, meta) { - return $biblio_to_html(row.biblio, { - link: "bookings", - }); - }, - }, - { - data: "item.external_id", - title: _("Item"), - searchable: true, - orderable: true, - defaultContent: _("Any item"), - render: function (data, type, row, meta) { - if (row.item) { - return ( - row.item.external_id + - " (" + - row.booking_id + - ")" - ); - } else { - return null; - } - }, - }, - { - data: "start_date", - title: _("Start date"), - searchable: true, - orderable: true, - render: function (data, type, row, meta) { - return $date(row.start_date); - }, - }, - { - data: "end_date", - title: _("End date"), - searchable: true, - orderable: true, - render: function (data, type, row, meta) { - return $date(row.end_date); - }, - }, - { - data: "", - title: _("Actions"), - class: "actions", - searchable: false, - orderable: false, - render: function (data, type, row, meta) { - let result = ""; - if (CAN_user_circulate_manage_bookings) { - result += - '"; - } - return result; - }, - }, - ], - }, - table_settings_bookings_table, - 0, - { - patron_id: patron_borrowernumber, - end_date: { ">=": today.toISOString() }, - } - ); - } - }); - }); -}); -- 2.45.2