Fix avatar upload validators [SCI-2253]

This commit is contained in:
Oleksii Kriuchykhin 2018-07-23 12:16:52 +02:00
parent 812a3dcf7d
commit 5c999300b5
3 changed files with 7 additions and 5 deletions

View file

@ -111,8 +111,10 @@ function filesValidator(ev, fileInputs, fileTypeEnum, canBeEmpty) {
var filesValid = true;
if (fileInputs.length) {
var filesPresentValid = canBeEmpty || filesPresentValidator(ev, fileInputs);
var filesSizeValid = filesSizeValidator(ev, fileInputs, fileTypeEnum);
var filesSizeValid = false;
if (filesPresentValid) {
filesSizeValid = filesSizeValidator(ev, fileInputs, fileTypeEnum);
}
// File spoof check is done on server-side only
filesValid = filesPresentValid && filesSizeValid;
}

View file

@ -68,7 +68,7 @@
$(this).renderFormErrors('user', data.responseJSON);
});
function processFile(ev) {
$('#user-avatar-field :submit').click(function(ev) {
var $form = $(ev.target.form);
var $fileInput = $form.find('input[type=file]');
$form.clearFormErrors();
@ -77,5 +77,5 @@
// Local file uploading
animateSpinner();
}
}
});
}());

View file

@ -49,7 +49,7 @@
</div>
<div class="align-right">
<a href="#" class="btn btn-default" data-action="cancel"><%=t "general.cancel" %></a>
<%= f.submit t("users.registrations.edit.avatar_submit"), class: 'btn btn-success', onclick: "processFile(event);" %>
<%= f.submit t("users.registrations.edit.avatar_submit"), class: 'btn btn-success' %>
</div>
</div>
</div>