mirror of
https://github.com/inventree/InvenTree.git
synced 2025-05-02 13:28:49 +00:00
Display per-line errors
This commit is contained in:
parent
51314a0261
commit
5329e3e56c
@ -816,33 +816,27 @@ function handleFormErrors(errors, fields, options) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for (field_name in errors) {
|
for (field_name in errors) {
|
||||||
if (field_name in fields) {
|
|
||||||
|
|
||||||
// Add the 'has-error' class
|
// Add the 'has-error' class
|
||||||
$(options.modal).find(`#div_id_${field_name}`).addClass('has-error');
|
$(options.modal).find(`#div_id_${field_name}`).addClass('has-error');
|
||||||
|
|
||||||
var field_dom = $(options.modal).find(`#errors-${field_name}`); // $(options.modal).find(`#id_${field_name}`);
|
var field_dom = $(options.modal).find(`#errors-${field_name}`); // $(options.modal).find(`#id_${field_name}`);
|
||||||
|
|
||||||
var field_errors = errors[field_name];
|
var field_errors = errors[field_name];
|
||||||
|
|
||||||
// Add an entry for each returned error message
|
// Add an entry for each returned error message
|
||||||
for (var idx = field_errors.length-1; idx >= 0; idx--) {
|
for (var idx = field_errors.length-1; idx >= 0; idx--) {
|
||||||
|
|
||||||
var error_text = field_errors[idx];
|
var error_text = field_errors[idx];
|
||||||
|
|
||||||
var html = `
|
var html = `
|
||||||
<span id='error_${idx+1}_id_${field_name}' class='help-block form-error-message'>
|
<span id='error_${idx+1}_id_${field_name}' class='help-block form-error-message'>
|
||||||
<strong>${error_text}</strong>
|
<strong>${error_text}</strong>
|
||||||
</span>`;
|
</span>`;
|
||||||
|
|
||||||
field_dom.append(html);
|
field_dom.append(html);
|
||||||
}
|
|
||||||
|
|
||||||
} else {
|
|
||||||
console.log(`WARNING: handleFormErrors found no match for field '${field_name}'`);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -167,7 +167,12 @@ function adjustStock(items, options={}) {
|
|||||||
<td id='part_${pk}'><img src='${image}' class='hover-img-thumb'> ${item.part_detail.full_name}</td>
|
<td id='part_${pk}'><img src='${image}' class='hover-img-thumb'> ${item.part_detail.full_name}</td>
|
||||||
<td id='stock_${pk}'>${quantity}${status}</td>
|
<td id='stock_${pk}'>${quantity}${status}</td>
|
||||||
<td id='location_${pk}'>${location}</td>
|
<td id='location_${pk}'>${location}</td>
|
||||||
<td id='action_${pk}'>${actionInput}</td>
|
<td id='action_${pk}'>
|
||||||
|
<div id='div_id_${pk}'>
|
||||||
|
${actionInput}
|
||||||
|
<div id='errors-${pk}'></div>
|
||||||
|
</div>
|
||||||
|
</td>
|
||||||
<td id='buttons_${pk}'>${buttons}</td>
|
<td id='buttons_${pk}'>${buttons}</td>
|
||||||
</tr>`;
|
</tr>`;
|
||||||
|
|
||||||
@ -259,8 +264,6 @@ function adjustStock(items, options={}) {
|
|||||||
error: function(xhr) {
|
error: function(xhr) {
|
||||||
switch (xhr.status) {
|
switch (xhr.status) {
|
||||||
case 400:
|
case 400:
|
||||||
console.log('400 bad request');
|
|
||||||
console.log(xhr.responseJSON);
|
|
||||||
|
|
||||||
// Handle errors for standard fields
|
// Handle errors for standard fields
|
||||||
handleFormErrors(
|
handleFormErrors(
|
||||||
|
Loading…
x
Reference in New Issue
Block a user