mirror of
https://github.com/inventree/InvenTree
synced 2024-08-30 18:33:04 +00:00
Form is now fully transferred to a formview
This commit is contained in:
parent
4008a9fb45
commit
fc5682f565
@ -122,7 +122,7 @@ class BomUploadManager:
|
||||
|
||||
return None
|
||||
|
||||
def get_headers(self):
|
||||
def columns(self):
|
||||
""" Return a list of headers for the thingy """
|
||||
headers = []
|
||||
|
||||
|
@ -62,11 +62,6 @@
|
||||
|
||||
{% endblock %}
|
||||
|
||||
{% block js_load %}
|
||||
{{ block.super }}
|
||||
<script type='text/javascript' src="{% static 'script/inventree/bom.js' %}"></script>
|
||||
{% endblock %}
|
||||
|
||||
{% block js_ready %}
|
||||
{{ block.super }}
|
||||
|
||||
|
@ -1,16 +1,20 @@
|
||||
{% extends "modal_form.html" %}
|
||||
{% extends "part/part_base.html" %}
|
||||
{% load static %}
|
||||
{% load inventree_extras %}
|
||||
|
||||
{% block form %}
|
||||
{% block details %}
|
||||
{% include "part/tabs.html" with tab='bom' %}
|
||||
<h4>Upload Bill of Materials</h4>
|
||||
|
||||
<h4>Step 2 of 3 - Select BOM Fields</h4>
|
||||
<p>Step 2 - Select Fields</p>
|
||||
<hr>
|
||||
|
||||
{% if missing and missing|length > 0 %}
|
||||
<div class='alert alert-danger alert-block' role='alert'>
|
||||
Missing selections for the following required columns:
|
||||
<br>
|
||||
<ul>
|
||||
{% for col in missing %}
|
||||
{% for col in missing_columns %}
|
||||
<li>{{ col }}</li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
@ -29,7 +33,7 @@
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Row</th>
|
||||
{% for col in bom_cols %}
|
||||
{% for col in bom_columns %}
|
||||
<th>
|
||||
<div>
|
||||
<input type='hidden' name='col_name_{{ forloop.counter0 }}' value='{{ col.name }}'/>
|
||||
@ -45,11 +49,11 @@
|
||||
<tbody>
|
||||
<tr>
|
||||
<td></td>
|
||||
{% for col in bom_cols %}
|
||||
{% for col in bom_columns %}
|
||||
<td>
|
||||
<select class='select' id='id_col_{{ forloop.counter0 }}' name='col_select_{{ forloop.counter0 }}'>
|
||||
<option value=''>---------</option>
|
||||
{% for req in req_cols %}
|
||||
{% for req in bom_headers %}
|
||||
<option value='{{ req }}'{% if req == col.guess %}selected='selected'{% endif %}>{{ req }}</option>
|
||||
{% endfor %}
|
||||
</select>
|
||||
@ -73,6 +77,7 @@
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
<button type="submit" class="save btn btn-default">Next</button>
|
||||
</form>
|
||||
|
||||
<b>BOM Rows: {{ bom.row_count }}</b>
|
||||
|
@ -1,5 +1,6 @@
|
||||
{% extends "part/part_base.html" %}
|
||||
{% load static %}
|
||||
{% load inventree_extras %}
|
||||
|
||||
{% block details %}
|
||||
|
||||
@ -8,6 +9,8 @@
|
||||
<h4>Upload Bill of Materials</h4>
|
||||
<hr>
|
||||
|
||||
<p>Step 1 - Select BOM File</p>
|
||||
|
||||
<div class='alert alert-info alert-block'>
|
||||
<p>The BOM file must contain the required named columns as provided in the <a href="/part/bom_template/">BOM Upload Template</a></a></p>
|
||||
</div>
|
||||
@ -20,7 +23,7 @@
|
||||
|
||||
{% crispy form %}
|
||||
|
||||
<button type="submit" class="save btn btn-default">Upload</button>
|
||||
<button type="submit" class="save btn btn-default">Next</button>
|
||||
</form>
|
||||
|
||||
{% endblock %}
|
@ -648,6 +648,13 @@ class BomUpload(FormView):
|
||||
"""
|
||||
|
||||
template_name='part/bom_upload/upload_file.html'
|
||||
|
||||
# Context data passed to the forms (initially empty, extracted from uploaded file)
|
||||
bom_headers = []
|
||||
bom_columns = []
|
||||
bom_rows = []
|
||||
missing_columns = []
|
||||
|
||||
|
||||
def get_success_url(self):
|
||||
part = self.get_object()
|
||||
@ -668,6 +675,10 @@ class BomUpload(FormView):
|
||||
ctx = super().get_context_data(*args, **kwargs)
|
||||
|
||||
ctx['part'] = self.part
|
||||
ctx['bom_headers'] = self.bom_headers
|
||||
ctx['bom_columns'] = self.bom_columns
|
||||
ctx['bom_rows'] = self.bom_rows
|
||||
ctx['missing_columns'] = self.missing_columns
|
||||
|
||||
return ctx
|
||||
|
||||
@ -715,22 +726,26 @@ class BomUpload(FormView):
|
||||
for k, v in errors.items():
|
||||
self.form.errors[k] = v
|
||||
|
||||
if 0 and bom_file_valid:
|
||||
if bom_file_valid:
|
||||
# BOM file is valid? Proceed to the next step!
|
||||
form = part_forms.BomUploadSelectFields
|
||||
self.template_name = 'part/bom_upload/select_fields.html'
|
||||
|
||||
# Provide context to the next form
|
||||
ctx = {
|
||||
'req_cols': BomUploadManager.HEADERS,
|
||||
'bom_cols': manager.get_headers(),
|
||||
'bom_rows': manager.rows(),
|
||||
}
|
||||
self.extractDataFromFile(manager)
|
||||
else:
|
||||
form = self.form
|
||||
form.errors['bom_file'] = [_('no errors')]
|
||||
|
||||
return self.render_to_response(self.get_context_data(form=form))
|
||||
|
||||
def extractDataFromFile(self, bom):
|
||||
""" Read data from the BOM file """
|
||||
|
||||
self.bom_headers = bom.HEADERS
|
||||
self.bom_columns = bom.columns()
|
||||
self.bom_rows = bom.rows()
|
||||
|
||||
|
||||
def handleFieldSelection(self):
|
||||
""" Handle the output of the field selection form.
|
||||
Here the user is presented with the raw data and must select the
|
||||
|
@ -99,6 +99,7 @@ InvenTree
|
||||
|
||||
<script type='text/javascript' src="{% static 'script/inventree/inventree.js' %}"></script>
|
||||
<script type='text/javascript' src="{% static 'script/inventree/api.js' %}"></script>
|
||||
<script type='text/javascript' src="{% static 'script/inventree/bom.js' %}"></script>
|
||||
<script type='text/javascript' src="{% static 'script/inventree/tables.js' %}"></script>
|
||||
<script type='text/javascript' src="{% static 'script/inventree/modals.js' %}"></script>
|
||||
<script type='text/javascript' src="{% static 'script/inventree/order.js' %}"></script>
|
||||
|
Loading…
Reference in New Issue
Block a user