mirror of
https://github.com/inventree/InvenTree
synced 2024-08-30 18:33:04 +00:00
Update upload file template
This commit is contained in:
parent
131663cecc
commit
11d5900b69
@ -14,21 +14,22 @@
|
|||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
||||||
{% block actions %}
|
{% block actions %}
|
||||||
|
<!--
|
||||||
|
<button type='button' class='btn btn-outline-secondary' id='bom-info'>
|
||||||
|
<span class='fas fa-info-circle' title='{% trans "BOM upload requirements" %}'></span>
|
||||||
|
</button>
|
||||||
|
-->
|
||||||
|
<button type='button' class='btn btn-primary' id='bom-upload'>
|
||||||
|
<span class='fas fa-file-upload'></span> {% trans "Upload BOM File" %}
|
||||||
|
</button>
|
||||||
|
<button type='button' class='btn btn-success' id='bom-submit' style='display: none;'>
|
||||||
|
<span class='fas fa-sign-in-alt'></span> {% trans "Submit BOM Data" %}
|
||||||
|
</button>
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
||||||
{% block page_info %}
|
{% block page_info %}
|
||||||
<div class='panel-content'>
|
<div class='panel-content'>
|
||||||
<p>{% blocktrans with step=wizard.steps.step1 count=wizard.steps.count %}Step {{step}} of {{count}}{% endblocktrans %}
|
|
||||||
{% if description %}- {{ description }}{% endif %}</p>
|
|
||||||
|
|
||||||
<form action="" method="post" class='js-modal-form' enctype="multipart/form-data">
|
|
||||||
{% csrf_token %}
|
|
||||||
{% load crispy_forms_tags %}
|
|
||||||
|
|
||||||
{% block form_buttons_top %}
|
|
||||||
{% endblock form_buttons_top %}
|
|
||||||
|
|
||||||
{% block form_alert %}
|
|
||||||
<div class='alert alert-info alert-block'>
|
<div class='alert alert-info alert-block'>
|
||||||
<strong>{% trans "Requirements for BOM upload" %}:</strong>
|
<strong>{% trans "Requirements for BOM upload" %}:</strong>
|
||||||
<ul>
|
<ul>
|
||||||
@ -36,22 +37,29 @@
|
|||||||
<li>{% trans "Each part must already exist in the database" %}</li>
|
<li>{% trans "Each part must already exist in the database" %}</li>
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
{% endblock %}
|
|
||||||
|
|
||||||
<table class='table table-striped' style='margin-top: 12px; margin-bottom: 0px'>
|
<div id='non-field-errors'>
|
||||||
{{ wizard.management_form }}
|
<!-- Upload error messages go here -->
|
||||||
{% block form_content %}
|
</div>
|
||||||
{% crispy wizard.form %}
|
|
||||||
{% endblock form_content %}
|
<!-- This table is filled out after BOM file is uploaded and processed -->
|
||||||
|
<table class='table table-striped table-condensed' id='bom-import-table'>
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th style='max-width: 500px;'>{% trans "Part" %}</th>
|
||||||
|
<th>{% trans "Quantity" %}</th>
|
||||||
|
<th>{% trans "Reference" %}</th>
|
||||||
|
<th>{% trans "Overage" %}</th>
|
||||||
|
<th>{% trans "Allow Variants" %}</th>
|
||||||
|
<th>{% trans "Inherited" %}</th>
|
||||||
|
<th>{% trans "Optional" %}</th>
|
||||||
|
<th>{% trans "Note" %}</th>
|
||||||
|
<th><!-- Buttons Column --></th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody></tbody>
|
||||||
</table>
|
</table>
|
||||||
|
|
||||||
{% block form_buttons_bottom %}
|
|
||||||
{% if wizard.steps.prev %}
|
|
||||||
<button name="wizard_goto_step" type="submit" value="{{ wizard.steps.prev }}" class="save btn btn-outline-secondary">{% trans "Previous Step" %}</button>
|
|
||||||
{% endif %}
|
|
||||||
<button type="submit" class="save btn btn-outline-secondary">{% trans "Upload File" %}</button>
|
|
||||||
</form>
|
|
||||||
{% endblock form_buttons_bottom %}
|
|
||||||
</div>
|
</div>
|
||||||
{% endblock page_info %}
|
{% endblock page_info %}
|
||||||
|
|
||||||
@ -64,4 +72,34 @@ $('#bom-template-download').click(function() {
|
|||||||
downloadBomTemplate();
|
downloadBomTemplate();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
$('#bom-upload').click(function() {
|
||||||
|
|
||||||
|
constructForm('{% url "api-bom-extract" %}', {
|
||||||
|
method: 'POST',
|
||||||
|
fields: {
|
||||||
|
bom_file: {},
|
||||||
|
part: {
|
||||||
|
value: {{ part.pk }},
|
||||||
|
hidden: true,
|
||||||
|
},
|
||||||
|
clear_existing: {},
|
||||||
|
},
|
||||||
|
title: '{% trans "Upload BOM File" %}',
|
||||||
|
onSuccess: function(response) {
|
||||||
|
$('#bom-upload').hide();
|
||||||
|
|
||||||
|
$('#bom-submit').show();
|
||||||
|
|
||||||
|
constructBomUploadTable(response);
|
||||||
|
|
||||||
|
$('#bom-submit').click(function() {
|
||||||
|
submitBomTable({{ part.pk }}, {
|
||||||
|
bom_data: response,
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
{% endblock js_ready %}
|
{% endblock js_ready %}
|
@ -172,22 +172,10 @@ function submitBomTable(part_id, options={}) {
|
|||||||
getApiEndpointOptions(url, function(response) {
|
getApiEndpointOptions(url, function(response) {
|
||||||
var fields = response.actions.POST;
|
var fields = response.actions.POST;
|
||||||
|
|
||||||
constructForm(url, {
|
|
||||||
method: 'POST',
|
|
||||||
fields: {
|
|
||||||
clear_existing: {},
|
|
||||||
},
|
|
||||||
title: '{% trans "Submit BOM Data" %}',
|
|
||||||
onSubmit: function(fields, opts) {
|
|
||||||
|
|
||||||
data.clear_existing = getFormFieldValue('clear_existing', {}, opts);
|
|
||||||
|
|
||||||
$(opts.modal).modal('hide');
|
|
||||||
|
|
||||||
inventreePut(url, data, {
|
inventreePut(url, data, {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
success: function(response) {
|
success: function(response) {
|
||||||
// TODO: Return to the "bom" page
|
window.location.href = `/part/${part_id}/?display=bom`;
|
||||||
},
|
},
|
||||||
error: function(xhr) {
|
error: function(xhr) {
|
||||||
switch (xhr.status) {
|
switch (xhr.status) {
|
||||||
@ -200,8 +188,6 @@ function submitBomTable(part_id, options={}) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user