mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2024-09-20 23:16:15 +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
|
@ -152,7 +152,7 @@ function showFormErrors(modal, errors) {
|
||||||
Object.keys(errors.protocol).forEach(function(key) {
|
Object.keys(errors.protocol).forEach(function(key) {
|
||||||
var input = modal.find('#protocol_' + key);
|
var input = modal.find('#protocol_' + key);
|
||||||
var msg;
|
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)) {
|
if ((input.length > 0) && (errors.protocol[key].length > 0)) {
|
||||||
input.closest('.form-group').children('span.help-block').html(msg);
|
input.closest('.form-group').children('span.help-block').html(msg);
|
||||||
input.closest('.form-group').addClass('has-error');
|
input.closest('.form-group').addClass('has-error');
|
||||||
|
@ -195,7 +195,7 @@ function handleFormSubmit(modal) {
|
||||||
HelperModule.flashAlertMsg(data.message, 'success');
|
HelperModule.flashAlertMsg(data.message, 'success');
|
||||||
},
|
},
|
||||||
error: function(data) {
|
error: function(data) {
|
||||||
showFormErrors(modal, data.responseJSON.errors);
|
showFormErrors(modal, data.responseJSON.validation_errors);
|
||||||
},
|
},
|
||||||
complete: function() {
|
complete: function() {
|
||||||
animateSpinner(modal, false);
|
animateSpinner(modal, false);
|
||||||
|
|
|
@ -13,6 +13,14 @@
|
||||||
.ql-editor {
|
.ql-editor {
|
||||||
min-height: initial;
|
min-height: initial;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.form-group.has-error {
|
||||||
|
color: $brand-danger;
|
||||||
|
|
||||||
|
.sci-input-field {
|
||||||
|
border: 1px solid $brand-danger;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.general-error {
|
.general-error {
|
||||||
|
|
|
@ -19,7 +19,7 @@ class ExternalProtocolsController < ApplicationController
|
||||||
page_id: service_call.protocols_list[:pagination][:current_page]
|
page_id: service_call.protocols_list[:pagination][:current_page]
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
render json: { errors: service_call.errors }, status: 400
|
render json: { errors: service_call.errors }, status: :bad_request
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -43,7 +43,7 @@ class ExternalProtocolsController < ApplicationController
|
||||||
rescue StandardError => e
|
rescue StandardError => e
|
||||||
render json: {
|
render json: {
|
||||||
errors: [protocol_html_preview: e.message]
|
errors: [protocol_html_preview: e.message]
|
||||||
}, status: 400
|
}, status: :bad_request
|
||||||
end
|
end
|
||||||
|
|
||||||
# GET build_online_sources_protocol
|
# GET build_online_sources_protocol
|
||||||
|
@ -74,7 +74,7 @@ class ExternalProtocolsController < ApplicationController
|
||||||
validation_errors: { protocol: @protocol.errors.messages }
|
validation_errors: { protocol: @protocol.errors.messages }
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
render json: { errors: service_call.errors }, status: 400
|
render json: { errors: service_call.errors }, status: :bad_request
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -95,7 +95,7 @@ class ExternalProtocolsController < ApplicationController
|
||||||
render json: { protocol: service_call.protocol,
|
render json: { protocol: service_call.protocol,
|
||||||
message: message }
|
message: message }
|
||||||
else
|
else
|
||||||
render json: { errors: service_call.errors }, status: 400
|
render json: { validation_errors: service_call.errors }, status: :bad_request
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -39,10 +39,12 @@ module ProtocolImporters
|
||||||
|
|
||||||
TinyMceAsset.update_images(step_text, '[]', @user)
|
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.assets << AttachmentsBuilder.generate(step_params.deep_symbolize_keys, user: @user, team: @team)
|
||||||
step
|
step
|
||||||
end
|
end
|
||||||
|
rescue ActiveRecord::RecordInvalid => e
|
||||||
|
@errors[:protocol] = e.record.errors
|
||||||
rescue StandardError => e
|
rescue StandardError => e
|
||||||
@errors[:protocol] = e.message
|
@errors[:protocol] = e.message
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue