Koha/koha-tmpl/intranet-tmpl/prog/js/sms_providers.js
Owen Leonard 2addd2879a
Bug 32618: Add 'page-section' to various administration pages
This patch adds a "page-section" container div around the main section
of administration pages which lack it.

The SMS providers page required a small change to the associated
JavaScript in order to target the right container, so you may need to
clear your browser cache to get the correct behavior.

This patch contains indentation changes, so please ignore whitespace
when looking at the diff.

To test, apply the patch and view the following pages to confirm that
the main content is contained in a white box:

 - Acquisitions -> Vendor -> Contracts
 - Administration -> Budgets -> Budget details -> Planning
 - Administration -> Circulation desks
 - Administration -> OAI sets configuration -> Define mappings
 - Administration -> System preferences -> Search for
   'OverDriveAuthName' -> OverDrive library authnames table
 - Administration -> SMS cellular providers
   - Confirm that the "Edit" buttons work correctly to show and hide the
     right content.

Signed-off-by: David Nind <david@davidnind.com>
Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
2023-01-31 09:36:42 -03:00

77 lines
2.1 KiB
JavaScript

$(document).ready(function() {
$('#submit_update').hide();
$("#name").focus();
$("#sms_add_form").hide();
$("#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 );
}
});
$(".cancel_edit").on("click",function(e){
e.preventDefault();
cancel_edit();
});
});
function clear_form(){
$("#id,#name,#domain").val("");
}
function add_provider(){
clear_form();
$(".dialog").hide();
$("legend").text( __("Add an SMS cellular provider") );
$("#toolbar,#submit_update,#providers").hide();
$("#sms_add_form,#submit_save").show();
$("#name").focus();
}
function edit_provider( id ) {
clear_form();
$("legend").text( __("Edit provider %s").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,#providers").hide();
$("#name").focus();
}
function cancel_edit() {
clear_form();
$(".dialog").show();
$("#sms_add_form,#submit_update").hide();
$("#toolbar,#submit_save,#providers").show();
}
function delete_provider( id, users ) {
var c;
if ( users ) {
c = confirm( __("Are you sure you want to delete %s? %s patron(s) are using it!").format($("#name_" + id).html(), users) );
} else {
c = confirm( __("Are you sure you want to delete %s?").format($("#name_" + id).html()) );
}
if ( c ) {
$("#op").val('delete');
$("#id").val( id );
$("#sms_form").submit();
}
}