Bugzilla – Attachment 167743 Details for
Bug 37047
Patron bookings are not visible from patrons checkout page
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 37047: Move bookings table JS table to its own file
Bug-37047-Move-bookings-table-JS-table-to-its-own-.patch (text/plain), 12.10 KB, created by
Martin Renvoize (ashimema)
on 2024-06-14 15:57:19 UTC
(
hide
)
Description:
Bug 37047: Move bookings table JS table to its own file
Filename:
MIME Type:
Creator:
Martin Renvoize (ashimema)
Created:
2024-06-14 15:57:19 UTC
Size:
12.10 KB
patch
obsolete
>From 58fb9bbc30c830f33cca57dc0bf7d5fb88140df8 Mon Sep 17 00:00:00 2001 >From: Pedro Amorim <pedro.amorim@ptfs-europe.com> >Date: Wed, 12 Jun 2024 11:39:56 +0000 >Subject: [PATCH] Bug 37047: Move bookings table JS table to its own file > >For reusability > >Signed-off-by: Pedro Amorim <pedro.amorim@ptfs-europe.com> >Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com> >--- > .../prog/en/modules/circ/circulation.tt | 103 +-------------- > .../intranet-tmpl/prog/js/bookings-table.js | 123 ++++++++++++++++++ > 2 files changed, 126 insertions(+), 100 deletions(-) > create 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 76859fe0980..57b549e86b9 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/circulation.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/circ/circulation.tt >@@ -1034,106 +1034,8 @@ > table_settings_relatives_issues_table = [% TablesSettings.GetTableSettings( 'circ', 'circulation', 'relatives-issues-table', 'json' ) | $raw %] > table_settings_holds_table = [% TablesSettings.GetTableSettings( 'circ', 'circulation', '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 += '<button type="button" class="btn btn-default btn-xs cancel-action" data-toggle="modal" data-target="#cancelBookingModal" data-booking="'+row.booking_id+'"><i class="fa fa-trash" aria-hidden="true"></i> '+_("Cancel")+'</button>'; >- [% 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 %] > > [% IF borrowernumber and patron %] > if( Cookies.get("holdfor") != [% patron.borrowernumber | html %]){ >@@ -1235,6 +1137,7 @@ > </script> > [% INCLUDE 'str/members-menu.inc' %] > [% Asset.js("js/members-menu.js") | $raw %] >+ [% Asset.js("js/bookings-table.js") | $raw %] > [% Asset.js("js/recalls.js") | $raw %] > [% END %] > >diff --git a/koha-tmpl/intranet-tmpl/prog/js/bookings-table.js b/koha-tmpl/intranet-tmpl/prog/js/bookings-table.js >new file mode 100644 >index 00000000000..c8bab13bc5f >--- /dev/null >+++ b/koha-tmpl/intranet-tmpl/prog/js/bookings-table.js >@@ -0,0 +1,123 @@ >+$(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 += >+ '<button type="button" class="btn btn-default btn-xs cancel-action" data-toggle="modal" data-target="#cancelBookingModal" data-booking="' + >+ row.booking_id + >+ '"><i class="fa fa-trash" aria-hidden="true"></i> ' + >+ _("Cancel") + >+ "</button>"; >+ } >+ return result; >+ }, >+ }, >+ ], >+ }, >+ table_settings_bookings_table, >+ 0, >+ { >+ patron_id: patron_borrowernumber, >+ end_date: { ">=": today.toISOString() }, >+ } >+ ); >+ } >+ }); >+ }); >+}); >-- >2.45.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 37047
:
167640
|
167650
|
167651
|
167652
|
167742
|
167743
|
167744
|
167745
|
167924
|
167925
|
167926
|
167927
|
167928
|
167958
|
167959
|
167960
|
167961
|
167962
|
167963