Owen Leonard
6d7aa51a40
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 <veron@veron.ch> Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de> Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
73 lines
No EOL
1.9 KiB
JavaScript
73 lines
No EOL
1.9 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 );
|
|
}
|
|
});
|
|
});
|
|
|
|
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();
|
|
}
|
|
} |