Skip to content

Commit

Permalink
Merge branch 'develop' of git://github.com/antwebes/ChateaClientBundl…
Browse files Browse the repository at this point in the history
…e into develop
  • Loading branch information
Borja committed Dec 29, 2015
2 parents d73d434 + f4c3ed6 commit f7120b0
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 10 deletions.
4 changes: 2 additions & 2 deletions CHANGELOG-0.1.md
Original file line number Diff line number Diff line change
Expand Up @@ -167,5 +167,5 @@ To get the diff between two versions, go to https://github.com/antwebes/ChateaCl
* 0.1.33 (2015-12-10)
* Added notifyPhotoWithMostPhotos method in notifications.js

* 0.1.34 (2015-12-??)
* Refix page reset password and separate in some subtemplates
* 0.1.34 (2015-12-28)
* ResetPassword: Include template footer to can include data in templat. Include ResetPassword:_reset_footer
28 changes: 20 additions & 8 deletions Resources/public/js/userNickSuggestions.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,11 @@ function userNickSuggestions(messages) {

var suggestionMinlength = 4;

function transServerError(error){
sendEvent("registration", "error", error);
function transServerError(error, throwEvent){
var throwEvent = typeof throwEvent !== 'undefined' ? throwEvent : true;
if (throwEvent){
sendEvent("registration", "error", error);
}
if(typeof messages.server_errors[error] != 'undefined'){
return messages.server_errors[error];
}
Expand Down Expand Up @@ -91,8 +94,8 @@ function userNickSuggestions(messages) {
error: function (responseError) {
var response = $.parseJSON(responseError.responseText);
var messageError = response.errors.email.message;
$('span[data-id="email-suggestions"]').html('<p class="alert-danger">' + transServerError(messageError) + '</p>');
sendEvent("registration", "error", response.errors.email.message);
$('span[data-id="email-suggestions"]').html('<p class="alert-danger">' + transServerError(messageError, false) + '</p>');
sendEvent("registration", "error", messageError);
}

});
Expand Down Expand Up @@ -125,6 +128,7 @@ function userNickSuggestions(messages) {

}

//check if nick is available, and show suggestions if is not available
function findSuggestions(usernameInput, emailInput) {
var url_source = '/api/users/username-available';

Expand All @@ -149,10 +153,18 @@ function userNickSuggestions(messages) {
error: function (responseError) {
var response = $.parseJSON(responseError.responseText);
writeUsernameSuggestions(response.suggestion);
sendEvent("registration", "error", "username_not_available");
if (response.errors.username){
$('span[data-id="username-validate"]').html('<p class="alert-danger">' + transServerError(response.errors.username.message) + '</p>');
}else if (response.errors.email){
if (response.errors.username) {
var message;
if (response.suggestion){
//Dont send event in translation error
message = transServerError(response.errors.username.message, false);
sendEvent("registration", "error", "username_not_available");
}else{
//Send event in translation error
message = transServerError(response.errors.username.message);
}
$('span[data-id="username-validate"]').html('<p class="alert-danger">' + message + '</p>');
} else if (response.errors.email) {
$('span[data-id="username-validate"]').html('<p class="alert-danger">' + transServerError(response.errors.email.message) + '</p>');
}
}
Expand Down
Empty file.
2 changes: 2 additions & 0 deletions Resources/views/ResetPassword/reset.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,6 @@

{% block chatea_body %}
{% include "ChateaClientBundle:ResetPassword:_reset_body.html.twig" %}

{% include "ChateaClientBundle:ResetPassword:_reset_footer.html.twig" %}
{% endblock %}

0 comments on commit f7120b0

Please sign in to comment.