mirror of
https://github.com/inventree/InvenTree.git
synced 2025-04-29 03:56:43 +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
|
return None
|
||||||
|
|
||||||
def get_headers(self):
|
def columns(self):
|
||||||
""" Return a list of headers for the thingy """
|
""" Return a list of headers for the thingy """
|
||||||
headers = []
|
headers = []
|
||||||
|
|
||||||
|
@ -62,11 +62,6 @@
|
|||||||
|
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
||||||
{% block js_load %}
|
|
||||||
{{ block.super }}
|
|
||||||
<script type='text/javascript' src="{% static 'script/inventree/bom.js' %}"></script>
|
|
||||||
{% endblock %}
|
|
||||||
|
|
||||||
{% block js_ready %}
|
{% block js_ready %}
|
||||||
{{ block.super }}
|
{{ block.super }}
|
||||||
|
|
||||||
|
@ -1,16 +1,20 @@
|
|||||||
{% extends "modal_form.html" %}
|
{% extends "part/part_base.html" %}
|
||||||
|
{% load static %}
|
||||||
{% load inventree_extras %}
|
{% 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 %}
|
{% if missing and missing|length > 0 %}
|
||||||
<div class='alert alert-danger alert-block' role='alert'>
|
<div class='alert alert-danger alert-block' role='alert'>
|
||||||
Missing selections for the following required columns:
|
Missing selections for the following required columns:
|
||||||
<br>
|
<br>
|
||||||
<ul>
|
<ul>
|
||||||
{% for col in missing %}
|
{% for col in missing_columns %}
|
||||||
<li>{{ col }}</li>
|
<li>{{ col }}</li>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</ul>
|
</ul>
|
||||||
@ -29,7 +33,7 @@
|
|||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
<th>Row</th>
|
<th>Row</th>
|
||||||
{% for col in bom_cols %}
|
{% for col in bom_columns %}
|
||||||
<th>
|
<th>
|
||||||
<div>
|
<div>
|
||||||
<input type='hidden' name='col_name_{{ forloop.counter0 }}' value='{{ col.name }}'/>
|
<input type='hidden' name='col_name_{{ forloop.counter0 }}' value='{{ col.name }}'/>
|
||||||
@ -45,11 +49,11 @@
|
|||||||
<tbody>
|
<tbody>
|
||||||
<tr>
|
<tr>
|
||||||
<td></td>
|
<td></td>
|
||||||
{% for col in bom_cols %}
|
{% for col in bom_columns %}
|
||||||
<td>
|
<td>
|
||||||
<select class='select' id='id_col_{{ forloop.counter0 }}' name='col_select_{{ forloop.counter0 }}'>
|
<select class='select' id='id_col_{{ forloop.counter0 }}' name='col_select_{{ forloop.counter0 }}'>
|
||||||
<option value=''>---------</option>
|
<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>
|
<option value='{{ req }}'{% if req == col.guess %}selected='selected'{% endif %}>{{ req }}</option>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</select>
|
</select>
|
||||||
@ -73,6 +77,7 @@
|
|||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
|
|
||||||
|
<button type="submit" class="save btn btn-default">Next</button>
|
||||||
</form>
|
</form>
|
||||||
|
|
||||||
<b>BOM Rows: {{ bom.row_count }}</b>
|
<b>BOM Rows: {{ bom.row_count }}</b>
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
{% extends "part/part_base.html" %}
|
{% extends "part/part_base.html" %}
|
||||||
{% load static %}
|
{% load static %}
|
||||||
|
{% load inventree_extras %}
|
||||||
|
|
||||||
{% block details %}
|
{% block details %}
|
||||||
|
|
||||||
@ -8,6 +9,8 @@
|
|||||||
<h4>Upload Bill of Materials</h4>
|
<h4>Upload Bill of Materials</h4>
|
||||||
<hr>
|
<hr>
|
||||||
|
|
||||||
|
<p>Step 1 - Select BOM File</p>
|
||||||
|
|
||||||
<div class='alert alert-info alert-block'>
|
<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>
|
<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>
|
</div>
|
||||||
@ -20,7 +23,7 @@
|
|||||||
|
|
||||||
{% crispy form %}
|
{% crispy form %}
|
||||||
|
|
||||||
<button type="submit" class="save btn btn-default">Upload</button>
|
<button type="submit" class="save btn btn-default">Next</button>
|
||||||
</form>
|
</form>
|
||||||
|
|
||||||
{% endblock %}
|
{% endblock %}
|
@ -649,6 +649,13 @@ class BomUpload(FormView):
|
|||||||
|
|
||||||
template_name='part/bom_upload/upload_file.html'
|
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):
|
def get_success_url(self):
|
||||||
part = self.get_object()
|
part = self.get_object()
|
||||||
return reverse('upload-bom', kwargs={'pk': part.id})
|
return reverse('upload-bom', kwargs={'pk': part.id})
|
||||||
@ -668,6 +675,10 @@ class BomUpload(FormView):
|
|||||||
ctx = super().get_context_data(*args, **kwargs)
|
ctx = super().get_context_data(*args, **kwargs)
|
||||||
|
|
||||||
ctx['part'] = self.part
|
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
|
return ctx
|
||||||
|
|
||||||
@ -715,22 +726,26 @@ class BomUpload(FormView):
|
|||||||
for k, v in errors.items():
|
for k, v in errors.items():
|
||||||
self.form.errors[k] = v
|
self.form.errors[k] = v
|
||||||
|
|
||||||
if 0 and bom_file_valid:
|
if bom_file_valid:
|
||||||
# BOM file is valid? Proceed to the next step!
|
# BOM file is valid? Proceed to the next step!
|
||||||
form = part_forms.BomUploadSelectFields
|
form = part_forms.BomUploadSelectFields
|
||||||
|
self.template_name = 'part/bom_upload/select_fields.html'
|
||||||
|
|
||||||
# Provide context to the next form
|
self.extractDataFromFile(manager)
|
||||||
ctx = {
|
|
||||||
'req_cols': BomUploadManager.HEADERS,
|
|
||||||
'bom_cols': manager.get_headers(),
|
|
||||||
'bom_rows': manager.rows(),
|
|
||||||
}
|
|
||||||
else:
|
else:
|
||||||
form = self.form
|
form = self.form
|
||||||
form.errors['bom_file'] = [_('no errors')]
|
form.errors['bom_file'] = [_('no errors')]
|
||||||
|
|
||||||
return self.render_to_response(self.get_context_data(form=form))
|
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):
|
def handleFieldSelection(self):
|
||||||
""" Handle the output of the field selection form.
|
""" Handle the output of the field selection form.
|
||||||
Here the user is presented with the raw data and must select the
|
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/inventree.js' %}"></script>
|
||||||
<script type='text/javascript' src="{% static 'script/inventree/api.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/tables.js' %}"></script>
|
||||||
<script type='text/javascript' src="{% static 'script/inventree/modals.js' %}"></script>
|
<script type='text/javascript' src="{% static 'script/inventree/modals.js' %}"></script>
|
||||||
<script type='text/javascript' src="{% static 'script/inventree/order.js' %}"></script>
|
<script type='text/javascript' src="{% static 'script/inventree/order.js' %}"></script>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user