mirror of
https://github.com/inventree/InvenTree.git
synced 2025-04-30 04:26:44 +00:00
Display initial errors when importing data
This commit is contained in:
parent
aa962aac83
commit
383835aa89
@ -43,7 +43,7 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- This table is filled out after BOM file is uploaded and processed -->
|
<!-- This table is filled out after BOM file is uploaded and processed -->
|
||||||
<table class='table table-striped table-condensed' id='bom-import-table'>
|
<table class='table table-condensed' id='bom-import-table'>
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
<th style='max-width: 500px;'>{% trans "Part" %}</th>
|
<th style='max-width: 500px;'>{% trans "Part" %}</th>
|
||||||
|
@ -40,6 +40,12 @@ function constructBomUploadTable(data, options={}) {
|
|||||||
function constructRow(row, idx, fields) {
|
function constructRow(row, idx, fields) {
|
||||||
// Construct an individual row from the provided data
|
// Construct an individual row from the provided data
|
||||||
|
|
||||||
|
var errors = {};
|
||||||
|
|
||||||
|
if (data.errors && data.errors.length > idx) {
|
||||||
|
errors = data.errors[idx];
|
||||||
|
}
|
||||||
|
|
||||||
var field_options = {
|
var field_options = {
|
||||||
hideLabels: true,
|
hideLabels: true,
|
||||||
hideClearButton: true,
|
hideClearButton: true,
|
||||||
@ -92,6 +98,15 @@ function constructBomUploadTable(data, options={}) {
|
|||||||
|
|
||||||
$('#bom-import-table tbody').append(html);
|
$('#bom-import-table tbody').append(html);
|
||||||
|
|
||||||
|
// Handle any errors raised by initial data import
|
||||||
|
if (errors.part) {
|
||||||
|
addFieldErrorMessage(`items_sub_part_${idx}`, errors.part);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (errors.quantity) {
|
||||||
|
addFieldErrorMessage(`items_quantity_${idx}`, errors.quantity);
|
||||||
|
}
|
||||||
|
|
||||||
// Initialize the "part" selector for this row
|
// Initialize the "part" selector for this row
|
||||||
initializeRelatedField(
|
initializeRelatedField(
|
||||||
{
|
{
|
||||||
|
@ -1196,13 +1196,13 @@ function handleFormErrors(errors, fields={}, options={}) {
|
|||||||
/*
|
/*
|
||||||
* Add a rendered error message to the provided field
|
* Add a rendered error message to the provided field
|
||||||
*/
|
*/
|
||||||
function addFieldErrorMessage(name, error_text, error_idx, options={}) {
|
function addFieldErrorMessage(name, error_text, error_idx=0, options={}) {
|
||||||
|
|
||||||
field_name = getFieldName(name, options);
|
field_name = getFieldName(name, options);
|
||||||
|
|
||||||
var field_dom = null;
|
var field_dom = null;
|
||||||
|
|
||||||
if (options.modal) {
|
if (options && options.modal) {
|
||||||
$(options.modal).find(`#div_id_${field_name}`).addClass('form-field-error');
|
$(options.modal).find(`#div_id_${field_name}`).addClass('form-field-error');
|
||||||
field_dom = $(options.modal).find(`#errors-${field_name}`);
|
field_dom = $(options.modal).find(`#errors-${field_name}`);
|
||||||
} else {
|
} else {
|
||||||
@ -1210,7 +1210,7 @@ function addFieldErrorMessage(name, error_text, error_idx, options={}) {
|
|||||||
field_dom = $(`#errors-${field_name}`);
|
field_dom = $(`#errors-${field_name}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (field_dom) {
|
if (field_dom.exists()) {
|
||||||
|
|
||||||
var error_html = `
|
var error_html = `
|
||||||
<span id='error_${error_idx}_id_${field_name}' class='help-block form-error-message'>
|
<span id='error_${error_idx}_id_${field_name}' class='help-block form-error-message'>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user