Display rows that contain errors with a reddish background

This commit is contained in:
Oliver Walters 2019-07-10 12:04:24 +10:00
parent 2e3676207e
commit c2dbc37f70
2 changed files with 16 additions and 3 deletions

View File

@ -9,6 +9,12 @@
<p>Step 3 - Select Parts</p> <p>Step 3 - Select Parts</p>
<hr> <hr>
{% if form_errors %}
<div class='alert alert-danger alert-block' role='alert'>
Errors exist in the submitted data.
</div>
{% endif %}
<form method="post" action='' class='js-modal-form' enctype="multipart/form-data"> <form method="post" action='' class='js-modal-form' enctype="multipart/form-data">
<button type="submit" class="save btn btn-default">Submit BOM</button> <button type="submit" class="save btn btn-default">Submit BOM</button>
@ -39,7 +45,7 @@
</thead> </thead>
<tbody> <tbody>
{% for row in bom_rows %} {% for row in bom_rows %}
<tr part-name='{{ row.part_name }}' part-description='{{ row.description }}' part-select='#select_part_{{ row.index }}'> <tr {% if row.errors %} style='background: #ffeaea;'{% endif %} part-name='{{ row.part_name }}' part-description='{{ row.description }}' part-select='#select_part_{{ row.index }}'>
<td> <td>
<button class='btn btn-default btn-remove' id='del_row_{{ forloop.counter }}' style='display: inline; float: right;' title='Remove row'> <button class='btn btn-default btn-remove' id='del_row_{{ forloop.counter }}' style='display: inline; float: right;' title='Remove row'>
<span row_id='{{ forloop.counter }}' onClick='removeRowFromBomWizard()' class='glyphicon glyphicon-small glyphicon-remove'></span> <span row_id='{{ forloop.counter }}' onClick='removeRowFromBomWizard()' class='glyphicon glyphicon-small glyphicon-remove'></span>

View File

@ -848,7 +848,6 @@ class BomUpload(FormView):
if n_idx >= 0: if n_idx >= 0:
row['notes'] = row['data'][n_idx] row['notes'] = row['data'][n_idx]
row['part'] = part
row['quantity'] = quantity row['quantity'] = quantity
row['part_options'] = [m['part'] for m in matches] row['part_options'] = [m['part'] for m in matches]
@ -1101,7 +1100,15 @@ class BomUpload(FormView):
self.template_name = 'part/bom_upload/select_parts.html' self.template_name = 'part/bom_upload/select_parts.html'
return self.render_to_response(self.get_context_data(form=None)) ctx = self.get_context_data(form=None)
if valid:
# Save the BOM data
pass
else:
ctx['form_errors'] = True
return self.render_to_response(ctx)
def getRowByIndex(self, idx): def getRowByIndex(self, idx):