mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2025-09-07 21:55:20 +08:00
Improve server side assets validation display for steps [SCI-1747]
This commit is contained in:
parent
038c15a1ee
commit
fe8b7d26c1
5 changed files with 18 additions and 24 deletions
|
@ -593,21 +593,15 @@
|
|||
animateSpinner(null, false);
|
||||
setupAssetsLoading();
|
||||
},
|
||||
error: function(e) {
|
||||
$form.after(xhr.responseJSON.html);
|
||||
var $new_form = $form.next();
|
||||
$form.remove();
|
||||
|
||||
$errInput = $new_form.find(".form-group.has-error")
|
||||
.first()
|
||||
.find("input");
|
||||
renderFormError(e, $errInput);
|
||||
|
||||
formCallback($form);
|
||||
applyCancelOnNew();
|
||||
error: function(xhr) {
|
||||
if (xhr.responseJSON['assets.file'] != null) {
|
||||
$('#new-step-assets-group').addClass('has-error');
|
||||
$('#new-step-assets-tab').addClass('has-error');
|
||||
$.each(xhr.responseJSON['assets.file'], function(_, value) {
|
||||
$('#new-step-assets-group').prepend('<span class="help-block">' + value + '</span>');
|
||||
});
|
||||
}
|
||||
animateSpinner(null, false);
|
||||
|
||||
TinyMCE.destroyAll();
|
||||
SmartAnnotation.preventPropagation('.atwho-user-popover');
|
||||
}
|
||||
});
|
||||
|
|
|
@ -26,7 +26,7 @@
|
|||
$('.panel-step-attachment-new').remove();
|
||||
_dragNdropAssetsOff();
|
||||
for(var i = 0; i < droppedFiles.length; i++) {
|
||||
$('#new-step-assets')
|
||||
$('#new-step-assets-group')
|
||||
.append(_uploadedAssetPreview(droppedFiles[i], i))
|
||||
.promise()
|
||||
.done(function() {
|
||||
|
@ -49,7 +49,6 @@
|
|||
var name = 'step[assets_attributes][' + index + '][file]';
|
||||
fd.append(name, droppedFiles[i]);
|
||||
}
|
||||
droppedFiles = [];
|
||||
filesValid = true;
|
||||
totalSize = 0;
|
||||
_dragNdropAssetsOff();
|
||||
|
|
|
@ -96,11 +96,9 @@ class StepsController < ApplicationController
|
|||
status: :ok
|
||||
end
|
||||
else
|
||||
format.json {
|
||||
render json: {
|
||||
html: render_to_string(partial: 'new.html.erb')
|
||||
}, status: :bad_request
|
||||
}
|
||||
format.json do
|
||||
render json: @step.errors.to_json, status: :bad_request
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -50,9 +50,11 @@
|
|||
style="display: none" multiple>
|
||||
</label>
|
||||
</div>
|
||||
<%= f.nested_fields_for :assets do |ff| %>
|
||||
<%= render "form_assets.html.erb", ff: ff, step: step %>
|
||||
<% end %>
|
||||
<div id="new-step-assets-group" class="form-group">
|
||||
<%= f.nested_fields_for :assets do |ff| %>
|
||||
<%= render "form_assets.html.erb", ff: ff, step: step %>
|
||||
<% end %>
|
||||
</div>
|
||||
</div>
|
||||
<div class="tab-pane" role="tabpanel" id="new-step-tables">
|
||||
<%= f.nested_fields_for :tables do |ff| %>
|
||||
|
|
|
@ -217,6 +217,7 @@ module Paperclip
|
|||
application/vnd.sun.xml.calc.template
|
||||
application/vnd.stardivision.calc
|
||||
application/x-starcalc
|
||||
application/CDFV2-encrypted
|
||||
)) ||
|
||||
# Presentation application
|
||||
(Set[content_type, content_types_from_name].subset? Set.new %w(
|
||||
|
|
Loading…
Add table
Reference in a new issue