mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2025-01-01 13:13:22 +08:00
Merge pull request #4938 from sboursen-scinote/sb_SCI-7831
No warning message on modal, when importing existing protocol from protocols.io into My Protocols [SCI-7831]
This commit is contained in:
commit
db75d1cb34
4 changed files with 17 additions and 7 deletions
|
@ -152,7 +152,7 @@ function showFormErrors(modal, errors) {
|
|||
Object.keys(errors.protocol).forEach(function(key) {
|
||||
var input = modal.find('#protocol_' + key);
|
||||
var msg;
|
||||
msg = key.charAt(0).toUpperCase() + key.slice(1) + ': ' + errors.protocol[key].join(', ');
|
||||
msg = errors.protocol[key].join(', ');
|
||||
if ((input.length > 0) && (errors.protocol[key].length > 0)) {
|
||||
input.closest('.form-group').children('span.help-block').html(msg);
|
||||
input.closest('.form-group').addClass('has-error');
|
||||
|
@ -195,7 +195,7 @@ function handleFormSubmit(modal) {
|
|||
HelperModule.flashAlertMsg(data.message, 'success');
|
||||
},
|
||||
error: function(data) {
|
||||
showFormErrors(modal, data.responseJSON.errors);
|
||||
showFormErrors(modal, data.responseJSON.validation_errors);
|
||||
},
|
||||
complete: function() {
|
||||
animateSpinner(modal, false);
|
||||
|
|
|
@ -13,6 +13,14 @@
|
|||
.ql-editor {
|
||||
min-height: initial;
|
||||
}
|
||||
|
||||
.form-group.has-error {
|
||||
color: $brand-danger;
|
||||
|
||||
.sci-input-field {
|
||||
border: 1px solid $brand-danger;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.general-error {
|
||||
|
|
|
@ -19,7 +19,7 @@ class ExternalProtocolsController < ApplicationController
|
|||
page_id: service_call.protocols_list[:pagination][:current_page]
|
||||
}
|
||||
else
|
||||
render json: { errors: service_call.errors }, status: 400
|
||||
render json: { errors: service_call.errors }, status: :bad_request
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -43,7 +43,7 @@ class ExternalProtocolsController < ApplicationController
|
|||
rescue StandardError => e
|
||||
render json: {
|
||||
errors: [protocol_html_preview: e.message]
|
||||
}, status: 400
|
||||
}, status: :bad_request
|
||||
end
|
||||
|
||||
# GET build_online_sources_protocol
|
||||
|
@ -74,7 +74,7 @@ class ExternalProtocolsController < ApplicationController
|
|||
validation_errors: { protocol: @protocol.errors.messages }
|
||||
}
|
||||
else
|
||||
render json: { errors: service_call.errors }, status: 400
|
||||
render json: { errors: service_call.errors }, status: :bad_request
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -95,7 +95,7 @@ class ExternalProtocolsController < ApplicationController
|
|||
render json: { protocol: service_call.protocol,
|
||||
message: message }
|
||||
else
|
||||
render json: { errors: service_call.errors }, status: 400
|
||||
render json: { validation_errors: service_call.errors }, status: :bad_request
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -39,10 +39,12 @@ module ProtocolImporters
|
|||
|
||||
TinyMceAsset.update_images(step_text, '[]', @user)
|
||||
|
||||
# 'Manually' create assets here. "Accept nasted attributes" won't work for assets
|
||||
# 'Manually' create assets here. "Accept nested attributes" won't work for assets
|
||||
step.assets << AttachmentsBuilder.generate(step_params.deep_symbolize_keys, user: @user, team: @team)
|
||||
step
|
||||
end
|
||||
rescue ActiveRecord::RecordInvalid => e
|
||||
@errors[:protocol] = e.record.errors
|
||||
rescue StandardError => e
|
||||
@errors[:protocol] = e.message
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue