mirror of
https://github.com/inventree/InvenTree.git
synced 2025-06-20 05:46:34 +00:00
Refactor MakeVariant form
- Now is essentially identical to the DuplicatePart form - Uses the API form structure
This commit is contained in:
@ -189,22 +189,30 @@ function editPart(pk, options={}) {
|
||||
}
|
||||
|
||||
|
||||
// Launch form to duplicate a part
|
||||
function duplicatePart(pk, options={}) {
|
||||
|
||||
// First we need all the part information
|
||||
inventreeGet(`/api/part/${pk}/`, {}, {
|
||||
|
||||
success: function(response) {
|
||||
success: function(data) {
|
||||
|
||||
var fields = partFields({
|
||||
duplicate: pk,
|
||||
});
|
||||
|
||||
// If we are making a "variant" part
|
||||
if (options.variant) {
|
||||
|
||||
// Override the "variant_of" field
|
||||
data.variant_of = pk;
|
||||
}
|
||||
|
||||
constructForm('{% url "api-part-list" %}', {
|
||||
method: 'POST',
|
||||
fields: fields,
|
||||
title: '{% trans "Duplicate Part" %}',
|
||||
data: response,
|
||||
data: data,
|
||||
onSuccess: function(data) {
|
||||
// Follow the new part
|
||||
location.href = `/part/${data.pk}/`;
|
||||
|
Reference in New Issue
Block a user