Removed unneeded upper case for errors which had them, along with their refactoring. [fixes SCI-408]

This commit is contained in:
Matej Zrimšek 2016-09-22 17:26:55 +02:00
parent 09405c667e
commit 13e886f7a9
2 changed files with 7 additions and 22 deletions

View file

@ -20,13 +20,7 @@ $("form#new_custom_field").on("ajax:success", function(ev, data, status) {
});
$("form#new_custom_field").on("ajax:error", function(e, data, status, xhr) {
input = $(this).find("#name-input");
input.closest(".form-group").find(".help-block").remove();
input.closest(".form-group").addClass("has-error");
$.each(data.responseJSON, function(i, val) {
input.parent().append("<span class='help-block'>" + val[0].charAt(0).toUpperCase() + val[0].slice(1) +"<br /></span>");
});
$('form').renderFormErrors('custom_field', data.responseJSON, true, e);
});
// Create sample type ajax
@ -51,13 +45,7 @@ $("form#new_sample_type").on("ajax:success", function(ev, data, status) {
});
$("form#new_sample_type").on("ajax:error", function(e, data, status, xhr) {
input = $(this).find("#name-input");
input.closest(".form-group").find(".help-block").remove();
input.closest(".form-group").addClass("has-error");
$.each(data.responseJSON, function(i, val) {
input.parent().append("<span class='help-block'>" + val[0].charAt(0).toUpperCase() + val[0].slice(1) +"<br /></span>");
});
$('form').renderFormErrors('sample_type', data.responseJSON, true, e);
});
// Create sample group ajax
@ -82,13 +70,7 @@ $("form#new_sample_group").on("ajax:success", function(ev, data, status) {
});
$("form#new_sample_group").on("ajax:error", function(e, data, status, xhr) {
input = $(this).find("#name-input");
input.closest(".form-group").find(".help-block").remove();
input.closest(".form-group").addClass("has-error");
$.each(data.responseJSON, function(i, val) {
input.parent().append("<span class='help-block'>" + val[0].charAt(0).toUpperCase() + val[0].slice(1) +"<br /></span>");
});
$('form').renderFormErrors('sample_group', data.responseJSON, true, e);
});

View file

@ -20,7 +20,10 @@ class CustomFieldsController < ApplicationController
},
status: :ok }
else
format.json { render json: @custom_field.errors, status: :unprocessable_entity }
format.json do
render json: @custom_field.errors.to_json,
status: :unprocessable_entity
end
end
end
end