2
0
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:
Oliver Walters
2021-08-05 00:24:38 +10:00
parent 0e8fb6a5ad
commit aa4ed9feb0
6 changed files with 15 additions and 182 deletions

View File

@ -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}/`;