From 5f8c575345aa0ab44922f83142838e7adcf68f6d Mon Sep 17 00:00:00 2001 From: Pedro Amorim Date: Wed, 12 Jun 2024 11:42:24 +0000 Subject: [PATCH] Bug 37047: Make use of DRY bookings-table.js in moremember.tt Test plan: No functionality change, follow the original test plan and make sure the table is displayed correctly on both screens: /cgi-bin/koha/circ/circulation.pl?borrowernumber= /cgi-bin/koha/members/moremember.pl?borrowernumber=1 Signed-off-by: Pedro Amorim Signed-off-by: Martin Renvoize Signed-off-by: Katrin Fischer --- .../prog/en/modules/members/moremember.tt | 103 +----------------- 1 file changed, 3 insertions(+), 100 deletions(-) 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 e00506ab50..8b34ef3b6f 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/members/moremember.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/members/moremember.tt @@ -779,106 +779,8 @@ table_settings_relatives_issues_table = [% TablesSettings.GetTableSettings( 'members', 'moremember', 'relatives-issues-table', 'json' ) | $raw %] table_settings_holds_table = [% TablesSettings.GetTableSettings( 'members', 'moremember', 'holds-table', 'json' ) | $raw %] table_settings_bookings_table = [% TablesSettings.GetTableSettings( 'members', 'moremember', 'bookings-table', 'json' ) | $raw %] - - 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 += ''; - [% END %] - return result; - } - }] - }, table_settings_bookings_table, 0, { patron_id: "[% patron.borrowernumber | html %]", end_date: { ">=": today.toISOString() } }); - }; - }); - }); + CAN_user_circulate_manage_bookings = [% CAN_user_circulate_manage_bookings | $raw %] + patron_borrowernumber = [% patron.borrowernumber | $raw %] function uncheck_sibling(me){ nodename=me.getAttribute("name"); @@ -903,6 +805,7 @@ } } + [% Asset.js("js/bookings-table.js") | $raw %] [% END %] [% INCLUDE 'intranet-bottom.inc' %] -- 2.39.5