From d0078e6f11591959c5ce25c293c0e2e314e7f313 Mon Sep 17 00:00:00 2001 From: Jonathan Druart <jonathan.druart@biblibre.com> Date: Mon, 7 Oct 2013 10:41:24 +0200 Subject: [PATCH] Bug 11002: Mandatory fields are not translatable When the pref BorrowerMandatoryField is set and a librarian forget to fill fields, a js popup appears with the following message: "The following fields are mandatory: surname, etc." The fields are not translatable. Test plan: - fill the pref BorrowerMandatoryField with something like: title|zipcode|surname|cardnumber|branchcode - go the members/memberentry.pl?op=add page - verify you are not allowed to add the patron without filling all mandatory fields. Signed-off-by: Paola Rossi <paola.rossi@cineca.it> Signed-off-by: Brendan Gallagher <brendan@bywatersolutions.com> --- koha-tmpl/intranet-tmpl/prog/en/js/members.js | 38 +++----------------- .../prog/en/modules/members/memberentrygen.tt | 1 - 2 files changed, 5 insertions(+), 34 deletions(-) diff --git a/koha-tmpl/intranet-tmpl/prog/en/js/members.js b/koha-tmpl/intranet-tmpl/prog/en/js/members.js index 28bf5c7..d7c2947 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/js/members.js +++ b/koha-tmpl/intranet-tmpl/prog/en/js/members.js @@ -98,38 +98,6 @@ function check_form_borrowers(nav){ } } - if (document.form.BorrowerMandatoryField.value==='') - {} - else - { - var champ_verif = document.form.BorrowerMandatoryField.value.split ('|'); - message += MSG_MISSING_MANDATORY; - message += "\n"; - for (var i=0; i<champ_verif.length; i++) { - if (document.getElementsByName(""+champ_verif[i]+"")[0]) { - var val_champ=eval("document.form."+champ_verif[i]+".value"); - var ref_champ=eval("document.form."+champ_verif[i]); - //check if it's a select - if (ref_champ.type=='select-one'){ - // check to see if first option is selected and is blank - if (ref_champ.options[0].selected && - ref_champ.options[0].text === ''){ - // action if field is empty - message_champ+=champ_verif[i]+"\n"; - //test to know if you must show a message with error - statut=1; - } - } else { - if ( val_champ === '' ) { - // action if the field is not empty - message_champ+=champ_verif[i]+"\n"; - statut=1; - } - } - } - } - } - if ( document.form.password.value != document.form.password2.value ){ if ( message_champ !== '' ){ message_champ += "\n"; @@ -182,4 +150,8 @@ $(document).ready(function(){ $("#debarreduntil").hide(); } }); -}); \ No newline at end of file + var mandatory_fields = $("input[name='BorrowerMandatoryField']").val().split ('|'); + $(mandatory_fields).each(function(){ + $("[name='"+this+"']").attr('required', 'required'); + }); +}); diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/members/memberentrygen.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/members/memberentrygen.tt index cfd81c8..7858bf0 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/members/memberentrygen.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/members/memberentrygen.tt @@ -83,7 +83,6 @@ var MSG_DUPLICATE_PATRON = _("Warning: Duplicate patron"); var MSG_DUPLICATE_ORGANIZATION = _("Warning: Duplicate organization"); var MSG_LATE_EXPIRY = _("Warning: Expiration date falls before enrollment date"); - var MSG_MISSING_MANDATORY = _("The following fields are mandatory:"); var MSG_DUPLICATE_SUSPICION = _("Please confirm whether this is a duplicate patron"); var MSG_PASSWORD_MISMATCH = _("The passwords entered do not match"); //]]> -- 1.7.10.4