Bugzilla – Attachment 83771 Details for
Bug 18530
Remove event attributes from patron clubs templates
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 18530: Remove event attributes from patron clubs templates
Bug-18530-Remove-event-attributes-from-patron-club.patch (text/plain), 16.53 KB, created by
Owen Leonard
on 2019-01-10 15:31:02 UTC
(
hide
)
Description:
Bug 18530: Remove event attributes from patron clubs templates
Filename:
MIME Type:
Creator:
Owen Leonard
Created:
2019-01-10 15:31:02 UTC
Size:
16.53 KB
patch
obsolete
>From 89dc3cc8553ccd4aebf420a787b82dcbea05ab28 Mon Sep 17 00:00:00 2001 >From: Owen Leonard <oleonard@myacpl.org> >Date: Mon, 30 Jul 2018 14:01:36 +0000 >Subject: [PATCH] Bug 18530: Remove event attributes from patron clubs > templates > >This patch removes event attributes like "onclick" from patron clubs >templates in favor of putting these event handlers in the JavaScript. > >To test, apply the patch and go to Tools -> Patron clubs. > > - Test deletion of both club templates and clubs. Deletion confirmation > dialogs should work as expected, both for OK and Cancel. > - Test editing of a club template. Under "Club fields," the "Add new > field" and "Delete field" links should work correctly. > - Open a patron record for checkout. > - Test enrolling and un-enrolling the patron. > - Test the same process from the patron detail page. >--- > .../intranet-tmpl/prog/en/includes/strings.inc | 5 +- > .../prog/en/modules/circ/circulation.tt | 1 + > .../intranet-tmpl/prog/en/modules/clubs/clubs.tt | 18 ++++- > .../prog/en/modules/clubs/patron-clubs-tab.tt | 38 +--------- > .../prog/en/modules/clubs/patron-enroll.tt | 33 +-------- > .../prog/en/modules/clubs/templates-add-modify.tt | 24 +++++-- > .../prog/en/modules/members/moremember.tt | 1 + > .../intranet-tmpl/prog/js/pages/circulation.js | 82 +++++++++++++++++++++- > 8 files changed, 124 insertions(+), 78 deletions(-) > >diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/strings.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/strings.inc >index cb90180..62aa46f 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/includes/strings.inc >+++ b/koha-tmpl/intranet-tmpl/prog/en/includes/strings.inc >@@ -1,5 +1,4 @@ >-<script type="text/javascript"> >-//<![CDATA[ >+<script> > var CIRCULATION_RETURNED = _("Checked in"); > var CIRCULATION_NOT_RETURNED = _("Unable to check in"); > var NOT_RENEWABLE_OVERDUE = _("Not allowed: overdue"); >@@ -47,5 +46,5 @@ > var CURRENT = _(" (current) "); > var MSG_NO_ITEMTYPE = _("No itemtype"); > var MSG_CHECKOUTS_BY_ITEMTYPE = _("Number of checkouts by item type"); >-//]]> >+ var MSG_CANT_CANCEL_ENROLLMENT = _("Unable to cancel enrollment!"); > </script> >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 3c5a777..c7457ea 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/circulation.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/circ/circulation.tt >@@ -1001,6 +1001,7 @@ No patron matched <span class="ex">[% message | html %]</span> > [% FOREACH b IN relatives_borrowernumbers %] > relatives_borrowernumbers.push("[% b | html %]"); > [% END %] >+ var club_id = "[% club.id %]"; > > var MSG_EXPORT_SELECT_CHECKOUTS = _("You must select checkout(s) to export"); > var MSG_CONFIRM_DELETE_MESSAGE = _("Are you sure you want to delete this message? This cannot be undone."); >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/clubs/clubs.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/clubs/clubs.tt >index 1dff30d..b3d42af 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/clubs/clubs.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/clubs/clubs.tt >@@ -88,7 +88,7 @@ > <a class="btn btn-xs btn-default" style="white-space:nowrap" href="/cgi-bin/koha/clubs/templates-add-modify.pl?id=[% t.id | html %]"> > <i class="fa fa-pencil"></i> Edit > </a> >- <a class="btn btn-xs btn-default" href="#" onclick='ConfirmDeleteTemplate([% t.id | html %], "[% t.name | html %]", $(this) ); return false;'> >+ <a class="delete_template btn btn-xs btn-default" href="#" data-id="[% t.id | html %]" data-name="[% t.name | html %]"> > <i class="fa fa-trash"></i> Delete > </a> > [% END %] >@@ -196,7 +196,7 @@ > </a> > </li> > <li> >- <a href="#" onclick='ConfirmDeleteClub([% c.id | html %], "[% c.name | html %]", $(this) ); return false;'> >+ <a href="#" class="delete_club" data-id="[% c.id %]" data-name="[% c.name | html %]"> > <i class="fa fa-trash"></i> Delete > </a> > </li> >@@ -248,6 +248,20 @@ > } )); > }); > >+ $(".delete_template").on("click", function(e){ >+ e.preventDefault(); >+ var name = $(this).data("name"); >+ var id = $(this).data("id"); >+ ConfirmDeleteTemplate( id, name, $(this) ); >+ }); >+ >+ $(".delete_club").on("click", function(e){ >+ e.preventDefault(); >+ var name = $(this).data("name"); >+ var id = $(this).data("id"); >+ ConfirmDeleteClub( id, name, $(this) ); >+ }); >+ > function ConfirmDeleteTemplate( id, name, a ) { > if ( confirm( _("Are you sure you want to delete the club template %s? This will delete all clubs using this template and cancel patron enrollments" ).format(name) ) ) { > $.ajax({ >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/clubs/patron-clubs-tab.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/clubs/patron-clubs-tab.tt >index 94dca4f..ad65078 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/clubs/patron-clubs-tab.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/clubs/patron-clubs-tab.tt >@@ -21,7 +21,7 @@ > <td>[% e.date_enrolled | $KohaDates %]</td> > [% IF CAN_user_clubs_enroll %] > <td> >- <button class="btn btn-xs btn-default" onclick="cancelEnrollment( [% e.id | html %] )"> >+ <button data-id="[% e.id | html %]" class="cancel_enrollment btn btn-xs btn-default"> > <i class="fa fa-remove"></i> Cancel enrollment > </button> > </td> >@@ -33,7 +33,6 @@ > [% END %] > > [% IF clubs %] >- > <h4>Clubs not enrolled in</h4> > > <table> >@@ -52,7 +51,7 @@ > <td>[% c.description | html %]</td> > [% IF CAN_user_clubs_enroll %] > <td class="action"> >- <button class="btn btn-xs btn-default" onclick="loadEnrollmentForm([% c.id | html %])"> >+ <button data-id="[% c.id | html %]" class="load_enrollment btn btn-xs btn-default"> > <i class="fa fa-plus"></i> Enroll > </button> > </td> >@@ -62,36 +61,3 @@ > </tbody> > </table> > [% END %] >- >-[% IF CAN_user_clubs_enroll %] >-<script type="text/javascript"> >-function loadEnrollmentForm( id ) { >- $("body").css("cursor", "progress"); >- $('#clubs-tab').load('/cgi-bin/koha/clubs/patron-enroll.pl?borrowernumber=[% borrowernumber | html %]&id=' + id, function() { >- $("body").css("cursor", "default"); >- }); >- >- return false; >-} >- >-function cancelEnrollment( id ) { >- $("body").css("cursor", "progress"); >- $.ajax({ >- type: "POST", >- url: '/cgi-bin/koha/svc/club/cancel_enrollment', >- data: { id: id }, >- success: function( data ) { >- if ( data.success ) { >- $('#clubs-tab').load('/cgi-bin/koha/clubs/patron-clubs-tab.pl?borrowernumber=[% borrowernumber | html %]', function() { >- $("body").css("cursor", "default"); >- }); >- } else { >- alert(_("Unable to cancel enrollment!")); >- } >- }, >- dataType: 'json' >- }); >- return false; >-} >-</script> >-[% END %] >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/clubs/patron-enroll.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/clubs/patron-enroll.tt >index 350e81c..86a1f13 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/clubs/patron-enroll.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/clubs/patron-enroll.tt >@@ -28,39 +28,10 @@ > [% END %] > > <li> >- <a href="#" class="btn btn-sm btn-default" onclick="addEnrollment(); return false;">Finish enrollment</a> >- <a class="cancel" href="#" onclick="showClubs(); return false;">Cancel</a> >+ <a href="#" class="btn btn-sm btn-default add_enrollment" data-borrowernumber="[% borrowernumber %]" data-club_id="[% club.id %]">Finish enrollment</a> >+ <a class="cancel cancel_add_enrollment" data-borrowernumber="[% borrowernumber %]" data-club_id="[% club.id %]" href="#">Cancel</a> > </li> > </ol> > </fieldset> > </form> > </div> >- >-<script type="text/javascript"> >-function addEnrollment() { >- $("body").css("cursor", "progress"); >- $.ajax({ >- type: "POST", >- url: '/cgi-bin/koha/svc/club/enroll', >- data: $( "#patron-enrollment-form" ).serialize(), >- success: function( data ) { >- if ( data.success ) { >- $('#clubs-tab').load('/cgi-bin/koha/clubs/patron-clubs-tab.pl?borrowernumber=[% borrowernumber | html %]&id=[% club.id | html %]', function() { >- $("body").css("cursor", "default"); >- }); >- } else { >- alert(_("Unable to create enrollment!")); >- } >- }, >- dataType: 'json' >- }); >- return false; >-} >- >-function showClubs() { >- $("body").css("cursor", "progress"); >- $('#clubs-tab').load('/cgi-bin/koha/clubs/patron-clubs-tab.pl?borrowernumber=[% borrowernumber | html %]&id=[% club.id | html %]', function() { >- $("body").css("cursor", "default"); >- }); >-} >-</script> >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/clubs/templates-add-modify.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/clubs/templates-add-modify.tt >index 063c55a..3583df0 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/clubs/templates-add-modify.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/clubs/templates-add-modify.tt >@@ -1,5 +1,6 @@ > [% USE Branches %] > [% USE AuthorisedValues %] >+[% SET footerjs = 1 %] > [% INCLUDE 'doc-head-open.inc' %] > <title>Koha › Tools › Patron clubs › > [% IF club_template %] >@@ -9,7 +10,7 @@ > [% END %] > </title> > [% INCLUDE 'doc-head-close.inc' %] >-<style type="text/css"> >+<style> > .club-field, > .enrollment-field { > border-top: 1px solid #DDD; >@@ -169,7 +170,7 @@ > [% END %] > </div> > <fieldset class="action"> >- <a href="#" onclick="$('#new-enrollment-field-template').clone().attr('id','').show().appendTo('#club-template-enrollment-fields'); return false;"> >+ <a href="#" class="add_field"> > <i class="fa fa-plus"></i> Add new field > </a> > </fieldset> >@@ -209,7 +210,7 @@ > </select> > </li> > </ol> >- <fieldset class="action"><a href="#" onclick="$(this).parent().parent().remove(); return false;"><i class="fa fa-trash"></i> Delete field</a></fieldset> >+ <fieldset class="action"><a href="#" class="delete_field"><i class="fa fa-trash"></i> Delete field</a></fieldset> > <hr/> > </div> > >@@ -236,7 +237,22 @@ > </select> > </li> > </ol> >- <fieldset class="action"><a href="#" onclick="$(this).parent().parent().remove(); return false;"><i class="fa fa-trash"></i> Delete field</a></fieldset> >+ <fieldset class="action"><a href="#" class="delete_field"><i class="fa fa-trash"></i> Delete field</a></fieldset> > </div> > >+[% MACRO jsinclude BLOCK %] >+ <script> >+ $(document).ready(function() { >+ $("body").on("click", ".delete_field", function(e){ >+ e.preventDefault(); >+ $(this).parent().parent().remove(); >+ }); >+ $(".add_field").on("click", function(e){ >+ e.preventDefault(); >+ $('#new-enrollment-field-template').clone().attr('id','').show().appendTo('#club-template-enrollment-fields'); >+ }); >+ }); >+ </script> >+[% END %] >+ > [% INCLUDE 'intranet-bottom.inc' %] >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 6e15e3c..ba2a149 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/members/moremember.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/members/moremember.tt >@@ -820,6 +820,7 @@ > [% FOREACH b IN relatives_borrowernumbers %] > relatives_borrowernumbers.push("[% b | html %]"); > [% END %] >+ var club_id = "[% club.id %]"; > > var MSG_EXPORT_SELECT_CHECKOUTS = _("You must select checkout(s) to export"); > var MSG_CONFIRM_DELETE_MESSAGE = _("Are you sure you want to delete this message? This cannot be undone."); >diff --git a/koha-tmpl/intranet-tmpl/prog/js/pages/circulation.js b/koha-tmpl/intranet-tmpl/prog/js/pages/circulation.js >index cd2ca9b..372be71 100644 >--- a/koha-tmpl/intranet-tmpl/prog/js/pages/circulation.js >+++ b/koha-tmpl/intranet-tmpl/prog/js/pages/circulation.js >@@ -107,8 +107,29 @@ $(document).ready(function() { > var fieldID = this.id.replace("clear-date-",""); > $("#" + fieldID).val(""); > }); >- >- >+ // Patron clubs >+ $("body").on("click", ".cancel_enrollment", function(e){ >+ e.preventDefault(); >+ var id = $(this).data("id"); >+ cancelEnrollment( id ); >+ }); >+ $("body").on("click", ".load_enrollment", function(e){ >+ e.preventDefault(); >+ var id = $(this).data("id"); >+ loadEnrollmentForm( id ); >+ }); >+ $("body").on("click", ".add_enrollment", function(e){ >+ e.preventDefault(); >+ var club_id = $(this).data("club_id"); >+ var borrowernumber = $(this).data("borrowernumber"); >+ addEnrollment( borrowernumber, club_id ); >+ }); >+ $("body").on("click", ".cancel_add_enrollment", function(e){ >+ e.preventDefault(); >+ var club_id = $(this).data("club_id"); >+ var borrowernumber = $(this).data("borrowernumber"); >+ showClubs( borrowernumber, club_id ); >+ }); > }); > > function export_checkouts(format) { >@@ -145,3 +166,60 @@ function validate1(date) { > return false; > } > } >+ >+// Patron clubs tab, circulation.pl and moremember.pl >+function loadEnrollmentForm( id ) { >+ $("body").css("cursor", "progress"); >+ $('#clubs-tab').load('/cgi-bin/koha/clubs/patron-enroll.pl?borrowernumber=' + borrowernumber + '&id=' + id, function() { >+ $("body").css("cursor", "default"); >+ }); >+ >+ return false; >+} >+ >+function cancelEnrollment( id ) { >+ $("body").css("cursor", "progress"); >+ $.ajax({ >+ type: "POST", >+ url: '/cgi-bin/koha/svc/club/cancel_enrollment', >+ data: { id: id }, >+ success: function( data ) { >+ if ( data.success ) { >+ $('#clubs-tab').load('/cgi-bin/koha/clubs/patron-clubs-tab.pl?borrowernumber=' + borrowernumber, function() { >+ $("body").css("cursor", "default"); >+ }); >+ } else { >+ alert( MSG_CANT_CANCEL_ENROLLMENT ); >+ } >+ }, >+ dataType: 'json' >+ }); >+ return false; >+} >+ >+function addEnrollment( borrowernumber, club_id ) { >+ $("body").css("cursor", "progress"); >+ $.ajax({ >+ type: "POST", >+ url: '/cgi-bin/koha/svc/club/enroll', >+ data: $( "#patron-enrollment-form" ).serialize(), >+ success: function( data ) { >+ if ( data.success ) { >+ $('#clubs-tab').load('/cgi-bin/koha/clubs/patron-clubs-tab.pl?borrowernumber=' + borrowernumber + '&id=' + club_id, function() { >+ $("body").css("cursor", "default"); >+ }); >+ } else { >+ alert(_("Unable to create enrollment!")); >+ } >+ }, >+ dataType: 'json' >+ }); >+ return false; >+} >+ >+function showClubs( borrowernumber, club_id ) { >+ $("body").css("cursor", "progress"); >+ $('#clubs-tab').load('/cgi-bin/koha/clubs/patron-clubs-tab.pl?borrowernumber=' + borrowernumber + '&id=' + club_id, function() { >+ $("body").css("cursor", "default"); >+ }); >+} >\ No newline at end of file >-- >2.1.4
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 18530
:
82093
|
82100
|
82332
|
83771