Koha/koha-tmpl/intranet-tmpl/prog/js/sms_providers.js
Owen Leonard 9e06e62a7f Bug 26240: Move translatable strings out of sms_providers.tt and into sms_providers.js
This patch removes the definition of translatable strings out of
templates and into the corresponding JavaScript file, using the new JS
i81n function.

To test you must have the SMSSendDriver preference populated ("Email" is
fine).

- Apply the patch and go to Administration -> SMS cellular providers.
- Click "New SMS provider."
- The legend on the form's fieldset should read "Add an SMS cellular
  provider."
- Add an SMS provider.
- Edit an SMS provider.
- The legend on the form's fieldset should read "Edit provider <provider
  name>"
- If necessary, edit a patron's SMS settings to use one of your existing
  SMS providers.
- From the list of SMS providers, click to delete the provider which is
  in use.
- The error message should read "Are you sure you want to delete
  <provider name>? <number> patron(s) are using it!"
- Click to delete a provider which isn't in use. The error message
  should read "Are you sure you want to delete <provider>?"

TESTING TRANSLATABILITY

- Update a translation, e.g. fr-FR:

  > cd misc/translator
  > perl translate update fr-FR

- Open the corresponding .po file for JavaScript strings, e.g.
  misc/translator/po/fr-FR-messages-js.po
- Locate strings pulled from
  koha-tmpl/intranet-tmpl/prog/js/sms_providers.js for translation,
  e.g.:

  msgid "Add an SMS cellular provider"
  msgstr ""

- Edit the "msgstr" string however you want (it's just for testing).
- Install the updated translation:

  > perl translate install fr-FR

- Switch to your newly translated language in the staff client
  and repeat the test plan above. The translated strings should
  appear.

Signed-off-by: David Nind <david@davidnind.com>

Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
2020-09-29 14:28:18 +02: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,#providerst").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,#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( __("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();
}
}