mirror of
https://github.com/inventree/InvenTree
synced 2024-08-30 18:33:04 +00:00
Allow user to select file format when downloadin BOM import template
(cherry picked from commit 8030ca0bb9
)
This commit is contained in:
parent
95db82a4ea
commit
d75ce451be
@ -32,7 +32,7 @@
|
|||||||
<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>
|
||||||
<li>{% trans "The BOM file must contain the required named columns as provided in the " %} <strong><a href="/part/bom_template/">{% trans "BOM Upload Template" %}</a></strong></li>
|
<li>{% trans "The BOM file must contain the required named columns as provided in the " %} <strong><a href='#' id='bom-template-download'>{% trans "BOM Upload Template" %}</a></strong></li>
|
||||||
<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>
|
||||||
@ -60,4 +60,8 @@
|
|||||||
|
|
||||||
enableSidebar('bom-upload');
|
enableSidebar('bom-upload');
|
||||||
|
|
||||||
|
$('#bom-template-download').click(function() {
|
||||||
|
downloadBomTemplate();
|
||||||
|
});
|
||||||
|
|
||||||
{% endblock js_ready %}
|
{% endblock js_ready %}
|
@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
/* globals
|
/* globals
|
||||||
constructForm,
|
constructForm,
|
||||||
|
exportFormatOptions,
|
||||||
imageHoverIcon,
|
imageHoverIcon,
|
||||||
inventreeGet,
|
inventreeGet,
|
||||||
inventreePut,
|
inventreePut,
|
||||||
@ -14,6 +15,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
/* exported
|
/* exported
|
||||||
|
downloadBomTemplate,
|
||||||
newPartFromBomWizard,
|
newPartFromBomWizard,
|
||||||
loadBomTable,
|
loadBomTable,
|
||||||
loadUsedInTable,
|
loadUsedInTable,
|
||||||
@ -21,12 +23,41 @@
|
|||||||
removeColFromBomWizard,
|
removeColFromBomWizard,
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/* BOM management functions.
|
function downloadBomTemplate(options={}) {
|
||||||
* Requires follwing files to be loaded first:
|
|
||||||
* - api.js
|
var format = options.format;
|
||||||
* - part.js
|
|
||||||
* - modals.js
|
if (!format) {
|
||||||
*/
|
format = inventreeLoad('bom-export-format', 'csv');
|
||||||
|
}
|
||||||
|
|
||||||
|
constructFormBody({}, {
|
||||||
|
title: '{% trans "Download BOM Template" %}',
|
||||||
|
fields: {
|
||||||
|
format: {
|
||||||
|
label: '{% trans "Format" %}',
|
||||||
|
help_text: '{% trans "Select file format" %}',
|
||||||
|
required: true,
|
||||||
|
type: 'choice',
|
||||||
|
value: format,
|
||||||
|
choices: exportFormatOptions(),
|
||||||
|
}
|
||||||
|
},
|
||||||
|
onSubmit: function(fields, opts) {
|
||||||
|
var format = getFormFieldValue('format', fields['format'], opts);
|
||||||
|
|
||||||
|
// Save the format for next time
|
||||||
|
inventreeSave('bom-export-format', format);
|
||||||
|
|
||||||
|
// Hide the modal
|
||||||
|
$(opts.modal).modal('hide');
|
||||||
|
|
||||||
|
// Download the file
|
||||||
|
location.href = `{% url "bom-upload-template" %}?format=${format}`;
|
||||||
|
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
function bomItemFields() {
|
function bomItemFields() {
|
||||||
|
Loading…
Reference in New Issue
Block a user