From 347a6f016e5c101271dc83578a558f5aa8e5b42e Mon Sep 17 00:00:00 2001 From: Owen Leonard Date: Thu, 28 Sep 2023 11:30:35 +0000 Subject: [PATCH] Bug 34945: Remove the use of event attributes from OPAC clubs tab This patch removes the use of event attributes (onclick) from the template for the clubs tab shown in the OPAC to a logged-in user. These events are defined now along with the other in-page JS. The patch also makes some general improvements to the template for consistency: - Adding Bootstrap color classes to the "Enroll" and "Cancel enrollment" buttons. - Enhancing the responsive configuration to the DataTable. To test you should have a few patron clubs defined (Tools -> Patron clubs). - Apply the patch and log in to the OPAC. - On the user summary page, click the "Clubs" tab. - The "Enroll" and "Cancel enrollment" buttons should look correct and work as expected: - Click the "Enroll" button. - On the enrollment confirmation view, test both the "Finish enrollment" button and the "Cancel" link. - Test "Cancel enrollment" button. - Test the responsive behavior of the page to confirm that it adjusts well to narrow browser widths. Signed-off-by: Victor Grousset/tuxayo Signed-off-by: Katrin Fischer Signed-off-by: Tomas Cohen Arazi (cherry picked from commit a3849909a98f286ffedead029aff5fc2b16a6c76) Signed-off-by: Fridolin Somers (cherry picked from commit a19515a9d41e14ff01b272292238853aba74c9be) Signed-off-by: Matt Blenkinsop --- .../bootstrap/en/modules/clubs/clubs-tab.tt | 58 ++++++++++++------- .../bootstrap/en/modules/clubs/enroll.tt | 16 ++++- 2 files changed, 51 insertions(+), 23 deletions(-) diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/modules/clubs/clubs-tab.tt b/koha-tmpl/opac-tmpl/bootstrap/en/modules/clubs/clubs-tab.tt index c5a53492f1..f342fdcbce 100644 --- a/koha-tmpl/opac-tmpl/bootstrap/en/modules/clubs/clubs-tab.tt +++ b/koha-tmpl/opac-tmpl/bootstrap/en/modules/clubs/clubs-tab.tt @@ -8,10 +8,10 @@ Clubs - Name + Name Description Date enrolled -   +   @@ -24,7 +24,7 @@ [% e.date_enrolled | $KohaDates %] [% IF e.club.club_template.is_enrollable_from_opac %] - [% ELSE %] @@ -45,9 +45,9 @@ - + - + @@ -59,7 +59,7 @@
NameName Description  
[% c.description | html %] [% IF !c.club_template.is_email_required || ( c.club_template.is_email_required && borrower.first_valid_email_address ) %] - [% ELSE %] @@ -102,19 +102,35 @@ function cancelEnrollment( id ) { }); return false; } -var Tables = $("#clubs-table-enrolled,#clubs-table-unenrolled"); -Tables.each(function(){ - $(this).dataTable($.extend(true, {}, dataTablesDefaults, { - "searching": false, - "paging": false, - "info": false, - "autoWidth": false, - "responsive": { - "details": { "type": 'column',"target": -1 } - }, - "columnDefs": [ - { "className": 'dtr-control', "orderable": false, "targets": -1 } - ], - })); -}); + + var Tables = $("#clubs-table-enrolled,#clubs-table-unenrolled"); + Tables.each(function(){ + $(this).dataTable($.extend(true, {}, dataTablesDefaults, { + "searching": false, + "paging": false, + "info": false, + "autoWidth": false, + "responsive": { + "details": { "type": "column", "target": -1 } + }, + "columnDefs": [ + { "orderable": false, "searchable": false, "targets": [ 'NoSort' ] }, + { "className": "dtr-control", "orderable": false, "targets": -1 }, + ], + })); + }); + + $(".cancel_enrollment").on("click", function(e){ + e.preventDefault(); + let clubid = $(this).data("id"); + cancelEnrollment( clubid ); + }); + + $(".load_enrollment").on("click", function(e){ + e.preventDefault(); + let clubid = $(this).data("id"); + loadEnrollmentForm( clubid ); + }); + + diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/modules/clubs/enroll.tt b/koha-tmpl/opac-tmpl/bootstrap/en/modules/clubs/enroll.tt index b83e1e3156..397b1de229 100644 --- a/koha-tmpl/opac-tmpl/bootstrap/en/modules/clubs/enroll.tt +++ b/koha-tmpl/opac-tmpl/bootstrap/en/modules/clubs/enroll.tt @@ -29,8 +29,8 @@
- - Cancel + + Cancel
@@ -62,4 +62,16 @@ function showClubs() { $("body").css("cursor", "default"); }); } + + $(document).ready(function(){ + $(".add_enrollment").on("click", function(e){ + e.preventDefault(); + addEnrollment(); + }); + + $(".show_clubs").on("click", function(e){ + e.preventDefault(); + showClubs(); + }); + }); -- 2.39.5