mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2024-12-29 03:35:25 +08:00
Fix avatar upload validators [SCI-2253]
This commit is contained in:
parent
812a3dcf7d
commit
5c999300b5
3 changed files with 7 additions and 5 deletions
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
}
|
||||
});
|
||||
}());
|
||||
|
|
|
@ -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>
|
||||
|
|
Loading…
Reference in a new issue