Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
Chrysweel committed Apr 15, 2015
2 parents a915ac2 + d9c9a7e commit 021c0dc
Show file tree
Hide file tree
Showing 13 changed files with 151 additions and 25 deletions.
6 changes: 5 additions & 1 deletion CHANGELOG-0.1.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,4 +48,8 @@ To get the diff between two versions, go to https://github.com/antwebes/ChateaCl

* 0.1.10 (2015-04-10)
* Update version ChateaSecureBundle v0.1.2
* remove function jquery.stringToSlug, used in function channelName->channelIrcName
* remove function jquery.stringToSlug, used in function channelName->channelIrcName

* 0.1.11 (2015-04-15)
* Include repeat form email to register and settings users
* Include check that two inputs of email are same with jquery
16 changes: 12 additions & 4 deletions Form/ChangeEmailType.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,20 @@ public function buildForm(FormBuilderInterface $builder, array $options)
);

$builder->add(
'email', 'email',
'email', 'repeated',
array(
'label' => 'form.email',
'type' => 'email',
'required' => true,
'translation_domain' => 'UserChange',
'label_attr' => array('class'=>'col-lg-3 control-label'),
'first_options' => array(
'label' => 'form.email',
'label_attr' => array('class'=>'col-lg-3 control-label'),
),
'invalid_message' => 'form.email.mismatch',
'second_options' => array(
'label' => 'form.email.repeat',
'label_attr' => array('class'=>'col-lg-3 control-label'),
)
)
);
}
Expand All @@ -40,4 +48,4 @@ public function getName()
{
return 'change_email';
}
}
}
14 changes: 11 additions & 3 deletions Form/CreateUserType.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,20 @@ public function buildForm(FormBuilderInterface $builder, array $options)
//xabier: cambie esto por que o nelmio repite os campos

$builder->add(
'email', 'email',
'email', 'repeated',
array(
'label' => 'form.email',
'type' => 'email',
'required' => true,
'translation_domain' => 'UserRegistration',
'label_attr' => array('class'=>'col-lg-3 control-label'),
'first_options' => array(
'label' => 'form.email',
'label_attr' => array('class'=>'col-lg-3 control-label'),
),
'invalid_message' => 'form.email.mismatch',
'second_options' => array(
'label' => 'form.email.repeat',
'label_attr' => array('class'=>'col-lg-3 control-label'),
)
)
);

Expand Down
58 changes: 55 additions & 3 deletions Resources/public/js/userNickSuggestions.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,13 @@
});
})(jQuery);

var emailCheckMinlength = 4;

function userNickSuggestions(messages) {
$(document).ready(function () {
$('span[data-id="email-suggestions"]').html("");

var suggestionMinlength = 4;
var emailCheckMinlength = 4;

function transServerError(error){
if(typeof messages.server_errors[error] != 'undefined'){
Expand Down Expand Up @@ -147,19 +148,70 @@ function userNickSuggestions(messages) {
});
}


$('input[data-id="registration_form_username"]').donetyping(function () {
var value = $(this).val();
var email = $('input[data-id="registration_form_email"]').val();
var email = $('input[data-id="form_email"]').val();
if (value.length > suggestionMinlength) {
$('span[data-id="username-validate"]').html("");
findSuggestions(value, email);
}
});
$('input[data-id="registration_form_email"]').donetyping(function () {
$('input[data-id="form_email"]').donetyping(function () {
var value = $(this).val();
if (value.length > emailCheckMinlength) {
checkEmail(value);
checkTwoFieldsEmailAndShowError(messages);
}
});
// Check if two fields emails mismatch
$('input[data-id="form_email_second"]').donetyping(function () {
var value = $(this).val();
if (value.length > emailCheckMinlength) {
checkEmail(value);
checkTwoFieldsEmailAndShowError(messages);
}
});
});
}

function areSameTwoFieldsEmail(){
// The two emails inputs
var email = $('input[data-id="form_email"]').val();
var confirmEmail = $('input[data-id="form_email_second"]').val();

// Check for equality with the emails inputs
if (email != confirmEmail ) {
return false;
} else {
return true;
}
}

function checkTwoFieldsEmailAndShowError(messages){
if (!($('input[data-id="form_email"]').val().length === 0 || $('input[data-id="form_email_second"]').val().length === 0)){
if (!areSameTwoFieldsEmail()){
$('span[data-id="email-mismatch-error"]').html('<p class="alert-danger">' + messages.emails_not_mismatch + '</p>');
}else{
$('span[data-id="email-mismatch-error"]').html('');
}
}
}

//this function is out of suggestions nick, so can I use this js in settings of user
function checkEmailsMismatch(messages){
// Check if two fields emails mismatch
$('input[data-id="form_email_second"]').donetyping(function () {
var value = $(this).val();
if (value.length > emailCheckMinlength) {
checkTwoFieldsEmailAndShowError(messages);
}
});

$('input[data-id="form_email"]').donetyping(function () {
var value = $(this).val();
if (value.length > emailCheckMinlength) {
checkTwoFieldsEmailAndShowError(messages);
}
});
}
6 changes: 5 additions & 1 deletion Resources/translations/UserChange.en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,12 @@ change_user.submit: "Submit"
user.change_email: "Change email"
form.password: "Password"
form.email: "Email"
form.email.repeat: "Repeat email"
form.password.placeholder: "Enter your password"
form.email.placeholder: "Enter your email"
form.email.repeat.placeholder: "Repeat your email"
form.current_password_match: "This value should be the user current password."
form.new_password_must_match: "The password fields must match."
form.email_not_valid_server: "The email '%email%' is not a valid email"
form.email.mismatch: "The emails do not match"
form.email_not_valid_server: "The email '%email%' is not a valid email"
form.mail_is_aviable: "Email already in use. An email only be used in a account at a time."
6 changes: 5 additions & 1 deletion Resources/translations/UserChange.es.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,12 @@ change_user.submit: "Enviar"
user.change_email: "Cambiar correo electrónico"
form.password: "Contraseña"
form.email: "Correo electrónico"
form.email.repeat: "Repite correo electrónico"
form.password.placeholder: "Introduzca su contraseña"
form.email.placeholder: "Introduzca su correo electrónico"
form.email.repeat.placeholder: "Repita su correo electrónico"
form.current_password_match: "El valor debería coincidir con la contraseña actual."
form.email.mismatch: "Los dos emails introducidos no coinciden"
form.new_password_must_match: "Las contraseñas deben coincidir."
form.email_not_valid_server: "El correo electrónico '%email%' no es un correo válido"
form.email_not_valid_server: "El correo electrónico '%email%' no es un correo válido"
form.mail_is_aviable: "Esta dirección de correo ya está en uso. Una dirección solo puede ser usado por una única cuenta."
3 changes: 3 additions & 0 deletions Resources/translations/UserRegistration.en.yml
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
user.register: Register user
form.username: Username
form.email: Email
form.email.repeat: Repeat email
form.password: Password
form.password_confirmation: Verification
form.country: Country
form.city: City
form.birthday: Birthday
form.username.placeholder: Enter your username
form.email.placeholder: Enter your email
form.email.repeat.placeholder: Repeat your email
form.password.placeholder: Enter your password
form.password_confirmation.placeholder: Repeat your password
form.city.placeholder: Enter a city
Expand All @@ -18,6 +20,7 @@ form.nick_not_spaces: "The nickname can not have spaces"
form.incorrect: "Incorrect"
form.correct: "Correct"
form.or: "or"
form.email.mismatch: "The emails do not match"
form.mail_is_aviable: "Email is available."
form.username_is_aviable: "Username is available."
form.username_already_used: "This username is already being used."
Expand Down
5 changes: 4 additions & 1 deletion Resources/translations/UserRegistration.es.yml
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
user.register: "Registrar usuario"
form.username: "Nombre de usuario"
form.email: "Correo electrónico"
form.email.repeat: "Repita correo electrónico"
form.password: "Contraseña"
form.password_confirmation: "Repita la contraseña"
form.country: "País"
form.city: "Ciudad"
form.birthday: "Fecha de nacimiento"
form.username.placeholder: "Introduzca su nombre de usuario"
form.email.placeholder: "Introduzca su email"
form.email.placeholder: "Introduzca su correo electrónico"
form.email.repeat.placeholder: "Repita su correo electrónico"
form.password.placeholder: "Introduzca una contraseña"
form.password_confirmation.placeholder: "Repita la contraseña"
form.city.placeholder: "Introduzca una ciudad"
Expand All @@ -18,6 +20,7 @@ form.nick_not_spaces: "El nick no puede tener espacios"
form.incorrect: "Incorrecto"
form.correct: "Correcto"
form.or: "o"
form.email.mismatch: "Los dos emails introducidos no coinciden"
form.mail_is_aviable: "La dirección de correo está disponible."
form.username_is_aviable: "El nombre de usuario está disponible."
form.username_already_used: "Este nombre de usuario ya está en uso."
Expand Down
1 change: 1 addition & 0 deletions Resources/translations/validators.en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ form.password.mismatch: 'The passwords do not match'
form.gender.not_defined: 'Not defined'
form.seeking.empty_value: 'Choose an option'
form.rfc_1459: The irc channel value is not valid. view RFC-1459
form.email.mismatch: "The emails do not match"
api.entity.channel.name.unique.constraints.message: The channel name is already used.
api.entity.channel.slug.unique.constraints.message: The slug is already used (You change channel name).
api.entity.channel.ircChannel.unique.constraints.message: The channel irc name is already used.
Expand Down
1 change: 1 addition & 0 deletions Resources/translations/validators.es.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ form:
gender.not_defined: "No está definido"
seeking.empty_value: "Elija una opción"
rfc_1459: "El canal irc no es valido. Ver RFC-1459"
email.mismatch: "Los dos emails introducidos no coinciden"
api.entity.channel.name.unique.constraints.message: El nombre del canal ya esta en uso
api.entity.channel.slug.unique.constraints.message: El slug del canal ya esta en uso (cambia el nombre del canal)
api.entity.channel.ircChannel.unique.constraints.message: El nombre irc del canal ya esta en uso
27 changes: 18 additions & 9 deletions Resources/views/User/_register_body.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,24 @@
</div>
{% endif %}

<div class="form-group">
{{ form_label(form.email) }}
<div class="col-lg-9">
<span data-id="email-suggestions" class="help-block"></span>
{{ form_errors(form.email) }}
{{ form_widget(form.email, {'attr': {'class': 'form-control', 'placeholder': 'form.email.placeholder', 'data-id': 'registration_form_email'}, 'translation_domain' : 'UserRegistration' }) }}
<span data-id="help-block">{{ "form.enter_valid_email" | trans }}</span>
</div>
</div>
<div class="form-group">
{{ form_label(form.email.first) }}
<div class="col-lg-9">
<span data-id="email-suggestions" class="help-block"></span>
{{ form_errors(form.email) }}
{{ form_errors(form.email.first) }}
{{ form_widget(form.email.first, {'attr': {'class': 'form-control', 'placeholder': 'form.email.placeholder', 'data-id': 'form_email'}, 'translation_domain' : 'UserRegistration' }) }}
<span data-id="help-block">{{ "form.enter_valid_email" | trans }}</span>
</div>
</div>
<div class="form-group">
{{ form_label(form.email.second) }}
<div class="col-lg-9">
<span data-id="email-mismatch-error" class="help-block"></span>
{{ form_errors(form.email.second) }}
{{ form_widget(form.email.second, {'attr': {'class': 'form-control', 'placeholder': 'form.email.repeat.placeholder', 'data-id': 'form_email_second'}, 'translation_domain' : 'UserRegistration' }) }}
</div>
</div>
<div class="form-group">
{{ form_label(form.username) }}
<div class="col-lg-9">
Expand Down
1 change: 1 addition & 0 deletions Resources/views/User/register.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
<script>
var executed = false;
var messages = {
emails_not_mismatch: '{{ 'form.email.mismatch' | trans }}',
mail_is_aviable: '{{ 'form.mail_is_aviable' | trans }}',
username_is_aviable: '{{ 'form.username_is_aviable' | trans }}',
nick_suggestions: '{{ 'form.nick_suggestions' | trans }}',
Expand Down
32 changes: 30 additions & 2 deletions Resources/views/User/userSettings.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -64,10 +64,19 @@
</div>
</div>
<div class="form-group">
{{ form_label(formEmail.email) }}
{{ form_label(formEmail.email.first) }}
<div class="col-lg-9">
{{ form_errors(formEmail.email) }}
{{ form_widget(formEmail.email, {'attr': {'class': 'form-control', 'placeholder': 'form.email.placeholder'}, 'translation_domain' : 'UserChange' }) }}
{{ form_errors(formEmail.email.first) }}
{{ form_widget(formEmail.email.first, {'attr': {'class': 'form-control', 'placeholder': 'form.email.placeholder', 'data-id': 'form_email'}, 'translation_domain' : 'UserChange' }) }}
</div>
</div>
<div class="form-group">
{{ form_label(formEmail.email.second) }}
<div class="col-lg-9">
<span data-id="email-mismatch-error" class="help-block"></span>
{{ form_errors(formEmail.email.second) }}
{{ form_widget(formEmail.email.second, {'attr': {'class': 'form-control', 'placeholder': 'form.email.placeholder' , 'data-id': 'form_email_second'}, 'translation_domain' : 'UserChange' }) }}
</div>
</div>

Expand All @@ -80,4 +89,23 @@
</div>
</form>
</div>
{% endblock %}


{% block chatea_js %}
{% javascripts
'@ChateaClientBundle/Resources/public/js/jquery-ui-1.10.3.custom.min.js'
'@ChateaClientBundle/Resources/public/js/userNickSuggestions.js'
%}
<script src="{{ asset(asset_url) }}"></script>
{% endjavascripts %}
<script>
var messages = {
emails_not_mismatch: '{{ 'form.email.mismatch' | trans }}'
};
$(document).ready(function(){
checkEmailsMismatch(messages);
});
</script>
{% endblock %}

0 comments on commit 021c0dc

Please sign in to comment.