From 154a282c6d69e4a59be7e62fc08fc364feeda075 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=UTF-8 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 --- koha-tmpl/intranet-tmpl/prog/en/js/sms_providers.js | 15 +++++++++++++++ .../prog/en/modules/admin/sms_providers.tt | 19 +++++-------------- 2 files changed, 20 insertions(+), 14 deletions(-) diff --git a/koha-tmpl/intranet-tmpl/prog/en/js/sms_providers.js b/koha-tmpl/intranet-tmpl/prog/en/js/sms_providers.js index 23a9c12..bccedeb 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/js/sms_providers.js +++ b/koha-tmpl/intranet-tmpl/prog/en/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(){ 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 d164a0d..6646c2b 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 %] -- 1.7.10.4