diff --git a/InvenTree/part/templates/part/bom_upload/upload_file.html b/InvenTree/part/templates/part/bom_upload/upload_file.html index 40411f074a..27f681acae 100644 --- a/InvenTree/part/templates/part/bom_upload/upload_file.html +++ b/InvenTree/part/templates/part/bom_upload/upload_file.html @@ -14,21 +14,22 @@ {% endblock %} {% block actions %} + + + {% endblock %} {% block page_info %}
-

{% blocktrans with step=wizard.steps.step1 count=wizard.steps.count %}Step {{step}} of {{count}}{% endblocktrans %} - {% if description %}- {{ description }}{% endif %}

-
- {% csrf_token %} - {% load crispy_forms_tags %} - - {% block form_buttons_top %} - {% endblock form_buttons_top %} - - {% block form_alert %}
{% trans "Requirements for BOM upload" %}:
    @@ -36,22 +37,29 @@
  • {% trans "Each part must already exist in the database" %}
- {% endblock %} - - {{ wizard.management_form }} - {% block form_content %} - {% crispy wizard.form %} - {% endblock form_content %} +
+ +
+ + +
+ + + + + + + + + + + + + +
{% trans "Part" %}{% trans "Quantity" %}{% trans "Reference" %}{% trans "Overage" %}{% trans "Allow Variants" %}{% trans "Inherited" %}{% trans "Optional" %}{% trans "Note" %}
- {% block form_buttons_bottom %} - {% if wizard.steps.prev %} - - {% endif %} - -
- {% endblock form_buttons_bottom %}
{% endblock page_info %} @@ -64,4 +72,34 @@ $('#bom-template-download').click(function() { 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 %} \ No newline at end of file diff --git a/InvenTree/templates/js/translated/bom.js b/InvenTree/templates/js/translated/bom.js index c80f9a2694..cb07f93a38 100644 --- a/InvenTree/templates/js/translated/bom.js +++ b/InvenTree/templates/js/translated/bom.js @@ -172,36 +172,22 @@ function submitBomTable(part_id, options={}) { getApiEndpointOptions(url, function(response) { var fields = response.actions.POST; - constructForm(url, { + inventreePut(url, data, { 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, { - method: 'POST', - success: function(response) { - // TODO: Return to the "bom" page - }, - error: function(xhr) { - switch (xhr.status) { - case 400: - handleFormErrors(xhr.responseJSON, fields, options); - break; - default: - showApiError(xhr, url); - break; - } - } - }); + success: function(response) { + window.location.href = `/part/${part_id}/?display=bom`; + }, + error: function(xhr) { + switch (xhr.status) { + case 400: + handleFormErrors(xhr.responseJSON, fields, options); + break; + default: + showApiError(xhr, url); + break; + } } - }); + }); }); }