From 859e3ce41b69692471e9a1e37d646f9ed0bfe6dd Mon Sep 17 00:00:00 2001 From: Owen Leonard Date: Fri, 19 Feb 2016 20:24:46 -0500 Subject: [PATCH] Bug 15936 - Revise layout and behavior of SMS cellular providers management This patch changes the behavior of the SMS cellular providers management page so that sections of the page are shown or hidden based on what the current task is. Other changes include: - Moving JavaScript to a separate file - Adding a toolbar with a "New SMS provider" button. - Adding the "generic" catalog search header form to the top of the page. - Adding "Required" classes to required fields so that the staff client's built-in JS validation library can be used. To test, the SMSSendDriver system preference must be set to "Email." Apply the patch and go to Administration -> SMS cellular providers. - Confirm that the add/edit form is hidden initially. A toolbar with a "New SMS provider" button should appear with existing SMS cellular providers in a table below. If there are no existing providers a message dialog should say so. - Confirm that the "New SMS provider" button works: - The table should be hidden and an empty "add" form displayed. - Confirm that an empty form cannot be submitted. - Confirm that submitting valid data works. - Confirm that clicking the "Cancel" button hides the form and redisplays the table. - Test the "edit" button for an existing provider: - Confirm that the edit form is displayed and populated with the correct data. - Confirm that edits are saved correctly. - When viewing the table of existing providers, confirm that clicking the "Delete" button triggers a confirmation dialog. Test both cancelling and confirming that dialog. - Ponder whether all this is an improvement or not. Signed-off-by: Nicole C Engard Signed-off-by: Jonathan Druart Signed-off-by: Kyle M Hall Signed-off-by: Brendan A Gallagher --- .../intranet-tmpl/prog/en/js/sms_providers.js | 58 ++++++ .../prog/en/modules/admin/sms_providers.tt | 191 ++++++++---------- 2 files changed, 144 insertions(+), 105 deletions(-) create mode 100644 koha-tmpl/intranet-tmpl/prog/en/js/sms_providers.js diff --git a/koha-tmpl/intranet-tmpl/prog/en/js/sms_providers.js b/koha-tmpl/intranet-tmpl/prog/en/js/sms_providers.js new file mode 100644 index 0000000000..23a9c12a01 --- /dev/null +++ b/koha-tmpl/intranet-tmpl/prog/en/js/sms_providers.js @@ -0,0 +1,58 @@ +$(document).ready(function() { + $('#submit_update').hide(); + $("#name").focus(); + $("#sms_add_form").hide(); + $("#new_provider").on("click",function(){ + add_provider(); + }); +}); + +function clear_form(){ + $("#id,#name,#domain").val(""); +} + +function add_provider(){ + clear_form(); + $(".dialog").hide(); + $("legend").text( LABEL_SMS_ADD_PROVIDER ); + $("#toolbar,#submit_update,#providerst").hide(); + $("#sms_add_form,#submit_save").show(); + $("#name").focus(); +} + +function edit_provider( id ) { + clear_form(); + $("legend").text( LABEL_SMS_EDIT_PROVIDER.format( $("#name_" + id).text() ) ); + $("#sms_add_form,#submit_update").show(); + + $("#id").val( id ); + $("#name").val( $("#name_" + id).text() ); + $("#domain").val( $("#domain_" + id).text() ); + + $("#toolbar,#submit_save,#providerst").hide(); + + $("#name").focus(); +} + + +function cancel_edit() { + clear_form(); + $(".dialog").show(); + $("#sms_add_form,#submit_update").hide(); + $("#toolbar,#submit_save,#providerst").show(); +} + +function delete_provider( id, users ) { + var c; + if ( users ) { + c = confirm( MSG_SMS_PATRONS_USING.format( $("#name_" + id).html(), users ) ); + } else { + c = confirm( MSG_SMS_DELETE_CONFIRM.format( $("#name_" + id).html() ) ); + } + + if ( c ) { + $("#op").val('delete'); + $("#id").val( id ); + $("#sms_form").submit(); + } +} \ No newline at end of file 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 8fbd415564..d164a0d160 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 @@ -1,128 +1,109 @@ [% INCLUDE 'doc-head-open.inc' %] Koha › Administration › SMS cellular providers [% INCLUDE 'doc-head-close.inc' %] - - + + + [% INCLUDE 'header.inc' %] +[% INCLUDE 'cat-search.inc' %]
-
+
+ + +

SMS cellular providers

- - - - - - - - - - + [% IF providers.size %] - - [% FOREACH p IN providers %] +
NameDomainPatrons  
+ - - - - - + + + + + - [% END %] - - - - + + + + [% FOREACH p IN providers %] + + + + + + + + [% END %] + +
[% p.name %][% p.domain %][% p.patrons_using %] - - Edit - - - [% IF p.patrons_using %] - - Delete - - [% ELSE %] - - Delete - - [% END %] - NameDomainPatrons  
[% p.name %][% p.domain %][% p.patrons_using %] + + Edit + + + [% IF p.patrons_using %] + + Delete + + [% ELSE %] + + Delete + + [% END %] +
+ + [% ELSE %] + +
+ There are no SMS cellular providers defined. +
+ + [% END %] + +
+ +
+ Add an SMS cellular provider - - - - - - - - - - Cancel - - - - - - +
    +
  1. + + + Required +
  2. +
  3. + + + Required +
  4. +
+
+
+ + + Cancel +
+ +
+
-- 2.39.5