2
0
mirror of https://github.com/inventree/InvenTree.git synced 2025-08-14 15:41:10 +00:00

Refactor "CreatePartCategory" form to API

(cherry picked from commit 06ff961564)
This commit is contained in:
Oliver
2021-08-04 11:33:20 +10:00
parent 8daf601f00
commit 83d8226ad6
5 changed files with 46 additions and 110 deletions

View File

@@ -240,32 +240,20 @@
});
$("#cat-create").click(function() {
launchModalForm(
"{% url 'category-create' %}",
{
follow: true,
data: {
{% if category %}
category: {{ category.id }}
{% endif %}
},
secondary: [
{
field: 'default_location',
label: '{% trans "New Location" %}',
title: '{% trans "Create new location" %}',
url: "{% url 'stock-location-create' %}",
},
{
field: 'parent',
label: '{% trans "New Category" %}',
title: '{% trans "Create new category" %}',
url: "{% url 'category-create' %}",
},
]
}
);
})
var fields = categoryFields();
{% if category %}
fields.parent.value = {{ category.pk }};
{% endif %}
constructForm('{% url "api-part-category-list" %}', {
fields: fields,
method: 'POST',
title: '{% trans "Create Part Category" %}',
follow: true,
});
});
$("#part-export").click(function() {
@@ -286,12 +274,6 @@
{% endif %}
},
secondary: [
{
field: 'category',
label: '{% trans "New Category" %}',
title: '{% trans "Create new Part Category" %}',
url: "{% url 'category-create' %}",
},
{
field: 'default_location',
label: '{% trans "New Location" %}',
@@ -307,24 +289,7 @@
{% if category %}
$("#cat-edit").click(function () {
constructForm(
'{% url "api-part-category-detail" category.pk %}',
{
fields: {
name: {},
description: {},
parent: {
help_text: '{% trans "Select parent category" %}',
},
default_location: {},
default_keywords: {
icon: 'fa-key',
}
},
title: '{% trans "Edit Part Category" %}',
reload: true
}
);
editCategory({{ category.pk }});
});
{% if category.parent %}