mirror of
https://github.com/inventree/InvenTree
synced 2024-08-30 18:33:04 +00:00
Refactor button in first step of "order parts" wizard
- "new supplier part" button was broken - Was linked to the old "launchModalForm" code - Now calls createSupplierPart
This commit is contained in:
parent
370fbea396
commit
449e0c0af2
@ -109,27 +109,47 @@ function newSupplierPartFromOrderWizard(e) {
|
|||||||
|
|
||||||
var part = $(src).attr('part');
|
var part = $(src).attr('part');
|
||||||
|
|
||||||
console.log('part: ' + part);
|
|
||||||
|
|
||||||
if (!part) {
|
if (!part) {
|
||||||
part = $(src).closest('button').attr('part');
|
part = $(src).closest('button').attr('part');
|
||||||
console.log('parent: ' + part);
|
console.log('parent: ' + part);
|
||||||
}
|
}
|
||||||
|
|
||||||
launchModalForm("/supplier-part/new/", {
|
createSupplierPart({
|
||||||
modal: '#modal-form-secondary',
|
part: part,
|
||||||
data: {
|
onSuccess: function(response) {
|
||||||
part: part,
|
|
||||||
},
|
// TODO: 2021-08-23 - This whole form wizard needs to be refactored.
|
||||||
success: function(response) {
|
// In the future, use the API forms functionality to add the new item
|
||||||
/* A new supplier part has been created! */
|
// For now, this hack will have to do...
|
||||||
|
|
||||||
var dropdown = '#id_supplier_part_' + part;
|
var dropdown = `#id_supplier_part_${part}`;
|
||||||
|
|
||||||
var option = new Option(response.text, response.pk, true, true);
|
var pk = response.pk;
|
||||||
|
|
||||||
$('#modal-form').find(dropdown).append(option).trigger('change');
|
inventreeGet(
|
||||||
},
|
`/api/company/part/${pk}/`,
|
||||||
|
{
|
||||||
|
supplier_detail: true,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
success: function(response) {
|
||||||
|
var text = '';
|
||||||
|
|
||||||
|
if (response.supplier_detail) {
|
||||||
|
text += response.supplier_detail.name;
|
||||||
|
text += " | ";
|
||||||
|
}
|
||||||
|
|
||||||
|
text += response.SKU;
|
||||||
|
|
||||||
|
var option = new Option(text, pk, true, true);
|
||||||
|
|
||||||
|
$('#modal-form').find(dropdown).append(option).trigger('change');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user