mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2025-09-08 06:04:35 +08:00
Merge pull request #889 from okriuchykhin/ok_SCI_1747
Improve server side assets validation display for steps [SCI-1747]
This commit is contained in:
commit
b3b0e367e8
5 changed files with 29 additions and 27 deletions
|
@ -123,6 +123,7 @@
|
||||||
initPreviewModal();
|
initPreviewModal();
|
||||||
SmartAnnotation.preventPropagation('.atwho-user-popover');
|
SmartAnnotation.preventPropagation('.atwho-user-popover');
|
||||||
TinyMCE.destroyAll();
|
TinyMCE.destroyAll();
|
||||||
|
DragNDropSteps.clearFiles();
|
||||||
}, 1000);
|
}, 1000);
|
||||||
|
|
||||||
})
|
})
|
||||||
|
@ -148,8 +149,8 @@
|
||||||
initializeCheckboxSorting();
|
initializeCheckboxSorting();
|
||||||
animateSpinner(null, false);
|
animateSpinner(null, false);
|
||||||
initPreviewModal();
|
initPreviewModal();
|
||||||
|
DragNDropSteps.clearFiles();
|
||||||
TinyMCE.refresh()
|
TinyMCE.refresh();
|
||||||
$("#new-step-checklists fieldset.nested_step_checklists ul").each(function () {
|
$("#new-step-checklists fieldset.nested_step_checklists ul").each(function () {
|
||||||
enableCheckboxSorting(this);
|
enableCheckboxSorting(this);
|
||||||
});
|
});
|
||||||
|
@ -371,6 +372,7 @@
|
||||||
newStepHandler();
|
newStepHandler();
|
||||||
});
|
});
|
||||||
toggleButtons(true);
|
toggleButtons(true);
|
||||||
|
DragNDropSteps.clearFiles();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -592,22 +594,17 @@
|
||||||
});
|
});
|
||||||
animateSpinner(null, false);
|
animateSpinner(null, false);
|
||||||
setupAssetsLoading();
|
setupAssetsLoading();
|
||||||
|
DragNDropSteps.clearFiles();
|
||||||
},
|
},
|
||||||
error: function(e) {
|
error: function(xhr) {
|
||||||
$form.after(xhr.responseJSON.html);
|
if (xhr.responseJSON['assets.file']) {
|
||||||
var $new_form = $form.next();
|
$('#new-step-assets-group').addClass('has-error');
|
||||||
$form.remove();
|
$('#new-step-assets-tab').addClass('has-error');
|
||||||
|
$.each(xhr.responseJSON['assets.file'], function(_, value) {
|
||||||
$errInput = $new_form.find(".form-group.has-error")
|
$('#new-step-assets-group').prepend('<span class="help-block">' + value + '</span>');
|
||||||
.first()
|
});
|
||||||
.find("input");
|
}
|
||||||
renderFormError(e, $errInput);
|
|
||||||
|
|
||||||
formCallback($form);
|
|
||||||
applyCancelOnNew();
|
|
||||||
animateSpinner(null, false);
|
animateSpinner(null, false);
|
||||||
|
|
||||||
TinyMCE.destroyAll();
|
|
||||||
SmartAnnotation.preventPropagation('.atwho-user-popover');
|
SmartAnnotation.preventPropagation('.atwho-user-popover');
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
@ -19,6 +19,10 @@
|
||||||
return filesValid;
|
return filesValid;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function clearFiles() {
|
||||||
|
droppedFiles = [];
|
||||||
|
}
|
||||||
|
|
||||||
// loops through a list of files and display each file in a separate panel
|
// loops through a list of files and display each file in a separate panel
|
||||||
function listItems() {
|
function listItems() {
|
||||||
totalSize = 0;
|
totalSize = 0;
|
||||||
|
@ -26,7 +30,7 @@
|
||||||
$('.panel-step-attachment-new').remove();
|
$('.panel-step-attachment-new').remove();
|
||||||
_dragNdropAssetsOff();
|
_dragNdropAssetsOff();
|
||||||
for(var i = 0; i < droppedFiles.length; i++) {
|
for(var i = 0; i < droppedFiles.length; i++) {
|
||||||
$('#new-step-assets')
|
$('#new-step-assets-group')
|
||||||
.append(_uploadedAssetPreview(droppedFiles[i], i))
|
.append(_uploadedAssetPreview(droppedFiles[i], i))
|
||||||
.promise()
|
.promise()
|
||||||
.done(function() {
|
.done(function() {
|
||||||
|
@ -49,7 +53,6 @@
|
||||||
var name = 'step[assets_attributes][' + index + '][file]';
|
var name = 'step[assets_attributes][' + index + '][file]';
|
||||||
fd.append(name, droppedFiles[i]);
|
fd.append(name, droppedFiles[i]);
|
||||||
}
|
}
|
||||||
droppedFiles = [];
|
|
||||||
filesValid = true;
|
filesValid = true;
|
||||||
totalSize = 0;
|
totalSize = 0;
|
||||||
_dragNdropAssetsOff();
|
_dragNdropAssetsOff();
|
||||||
|
@ -144,7 +147,8 @@
|
||||||
init: init,
|
init: init,
|
||||||
appendFilesToForm: appendFilesToForm,
|
appendFilesToForm: appendFilesToForm,
|
||||||
listItems: listItems,
|
listItems: listItems,
|
||||||
filesStatus: filesStatus
|
filesStatus: filesStatus,
|
||||||
|
clearFiles: clearFiles
|
||||||
});
|
});
|
||||||
})();
|
})();
|
||||||
|
|
||||||
|
|
|
@ -96,11 +96,9 @@ class StepsController < ApplicationController
|
||||||
status: :ok
|
status: :ok
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
format.json {
|
format.json do
|
||||||
render json: {
|
render json: @step.errors.to_json, status: :bad_request
|
||||||
html: render_to_string(partial: 'new.html.erb')
|
end
|
||||||
}, status: :bad_request
|
|
||||||
}
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -50,9 +50,11 @@
|
||||||
style="display: none" multiple>
|
style="display: none" multiple>
|
||||||
</label>
|
</label>
|
||||||
</div>
|
</div>
|
||||||
<%= f.nested_fields_for :assets do |ff| %>
|
<div id="new-step-assets-group" class="form-group">
|
||||||
<%= render "form_assets.html.erb", ff: ff, step: step %>
|
<%= f.nested_fields_for :assets do |ff| %>
|
||||||
<% end %>
|
<%= render "form_assets.html.erb", ff: ff, step: step %>
|
||||||
|
<% end %>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="tab-pane" role="tabpanel" id="new-step-tables">
|
<div class="tab-pane" role="tabpanel" id="new-step-tables">
|
||||||
<%= f.nested_fields_for :tables do |ff| %>
|
<%= f.nested_fields_for :tables do |ff| %>
|
||||||
|
|
|
@ -217,6 +217,7 @@ module Paperclip
|
||||||
application/vnd.sun.xml.calc.template
|
application/vnd.sun.xml.calc.template
|
||||||
application/vnd.stardivision.calc
|
application/vnd.stardivision.calc
|
||||||
application/x-starcalc
|
application/x-starcalc
|
||||||
|
application/CDFV2-encrypted
|
||||||
)) ||
|
)) ||
|
||||||
# Presentation application
|
# Presentation application
|
||||||
(Set[content_type, content_types_from_name].subset? Set.new %w(
|
(Set[content_type, content_types_from_name].subset? Set.new %w(
|
||||||
|
|
Loading…
Add table
Reference in a new issue