From 6d7aa51a401b9a427ac143e53a8f898c15065eb6 Mon Sep 17 00:00:00 2001 From: Owen Leonard Date: Wed, 20 Apr 2016 08:31:16 -0400 Subject: [PATCH] Bug 16301 - Remove the use of "onclick" from SMS cellular providers template MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit This patch refactors some of the JavaScript in the SMS cellular providers template so that event attributes are removed from the markup. This patch also updates the markup for the "Edit" and "Delete" buttons to make them consistent with similar buttons in Koha. To test you must have the SMSSendDriver system preference set to "Email." - Go to Administration -> SMS cellular providers. - If necessary, create a new SMS cellular provider. - Edit at least one patron to use an SMS cellular provider under "Patron messaging preferences." - In the table of SMS cellular providers: - Click the "Edit" button. The correct edit form should be displayed. - Click the "Delete" button next to a provider which is not used by any patrons. You should see an error message, "Are you sure you want to delete [provider name]." Test both cancel and confirm. - Click the "Delete" button next to a provider which is in use by one or more patrons. YOu should see an error message, "Are you sure you want to delete [provider name]? X patron(s) are using it!" Test both cancel and confirm. Followed test plan, works as expected. Signed-off-by: Marc Véron Signed-off-by: Katrin Fischer Signed-off-by: Kyle M Hall --- .../prog/en/modules/admin/sms_providers.tt | 19 +++++-------------- .../intranet-tmpl/prog/js/sms_providers.js | 15 +++++++++++++++ 2 files changed, 20 insertions(+), 14 deletions(-) diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/sms_providers.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/sms_providers.tt index 0f396230ee..2979b5162f 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/sms_providers.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/sms_providers.tt @@ -38,7 +38,6 @@ Domain Patrons   -   @@ -48,21 +47,13 @@ [% p.name %] [% p.domain %] [% p.patrons_using %] - - + + Edit - - - [% IF p.patrons_using %] - - Delete - - [% ELSE %] - - Delete - - [% END %] + + Delete + [% END %] diff --git a/koha-tmpl/intranet-tmpl/prog/js/sms_providers.js b/koha-tmpl/intranet-tmpl/prog/js/sms_providers.js index 23a9c12a01..bccedeb532 100644 --- a/koha-tmpl/intranet-tmpl/prog/js/sms_providers.js +++ b/koha-tmpl/intranet-tmpl/prog/js/sms_providers.js @@ -5,6 +5,21 @@ $(document).ready(function() { $("#new_provider").on("click",function(){ add_provider(); }); + $(".edit").on("click",function(e){ + e.preventDefault(); + var providerid = $(this).data("providerid"); + edit_provider( providerid ); + }); + $(".delete").on("click",function(e){ + e.preventDefault(); + var providerid = $(this).data("providerid"); + var patrons_using = $(this).data("patrons_using"); + if( patrons_using !== "" ){ + delete_provider( providerid, patrons_using ); + } else { + delete_provider( providerid ); + } + }); }); function clear_form(){ -- 2.39.5