mirror of
https://github.com/inventree/InvenTree
synced 2024-08-30 18:33:04 +00:00
Fix persist buttons (#4640)
Fixes "persist form" buttons for the following models: - Part - PartCategory - StockItem - StockLocation Closes https://github.com/inventree/InvenTree/issues/4491
This commit is contained in:
parent
c64ff9d569
commit
7bc4de6a92
@ -334,18 +334,8 @@
|
||||
});
|
||||
|
||||
$("#cat-create").click(function() {
|
||||
|
||||
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,
|
||||
createPartCategory({
|
||||
{% if category %}parent: {{ category.pk }},{% endif %}
|
||||
});
|
||||
});
|
||||
|
||||
|
@ -730,7 +730,7 @@ function insertPersistButton(options) {
|
||||
var html = `
|
||||
<div class="form-check form-switch">
|
||||
<input class="form-check-input" type="checkbox" id="modal-persist">
|
||||
<label class="form-check-label" for="modal-persist">${message}</label>
|
||||
<label class="form-check-label" for="modal-persist"><small>${message}</small></label>
|
||||
</div>
|
||||
`;
|
||||
|
||||
|
@ -20,6 +20,7 @@
|
||||
|
||||
/* exported
|
||||
createPart,
|
||||
createPartCategory,
|
||||
deletePart,
|
||||
deletePartCategory,
|
||||
duplicateBom,
|
||||
@ -253,8 +254,8 @@ function partFields(options={}) {
|
||||
/*
|
||||
* Construct a set of fields for a PartCategory intance
|
||||
*/
|
||||
function categoryFields() {
|
||||
return {
|
||||
function categoryFields(options={}) {
|
||||
let fields = {
|
||||
parent: {
|
||||
help_text: '{% trans "Parent part category" %}',
|
||||
required: false,
|
||||
@ -276,6 +277,28 @@ function categoryFields() {
|
||||
placeholder: 'fas fa-tag',
|
||||
},
|
||||
};
|
||||
|
||||
if (options.parent) {
|
||||
fields.parent.value = options.parent;
|
||||
}
|
||||
|
||||
return fields;
|
||||
}
|
||||
|
||||
|
||||
// Create a PartCategory via the API
|
||||
function createPartCategory(options={}) {
|
||||
let fields = categoryFields(options);
|
||||
|
||||
constructForm('{% url "api-part-category-list" %}', {
|
||||
fields: fields,
|
||||
method: 'POST',
|
||||
title: '{% trans "Create Part Category" %}',
|
||||
follow: true,
|
||||
persist: true,
|
||||
persistMessage: '{% trans "Create new category after this one" %}',
|
||||
successMessage: '{% trans "Part category created" %}'
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@ -349,7 +372,7 @@ function createPart(options={}) {
|
||||
fields: partFields(options),
|
||||
groups: partGroups(),
|
||||
title: '{% trans "Create Part" %}',
|
||||
reloadFormAfterSuccess: true,
|
||||
persist: true,
|
||||
persistMessage: '{% trans "Create another part after this one" %}',
|
||||
successMessage: '{% trans "Part created successfully" %}',
|
||||
onSuccess: function(data) {
|
||||
|
@ -159,6 +159,9 @@ function createStockLocation(options={}) {
|
||||
options.method = 'POST';
|
||||
options.fields = stockLocationFields(options);
|
||||
options.title = '{% trans "New Stock Location" %}';
|
||||
options.persist = true;
|
||||
options.persistMessage = '{% trans "Create another location after this one" %}';
|
||||
options.successMessage = '{% trans "Stock location created" %}';
|
||||
|
||||
constructForm(url, options);
|
||||
}
|
||||
@ -473,6 +476,10 @@ function createNewStockItem(options={}) {
|
||||
|
||||
options.create = true;
|
||||
|
||||
options.persist = true;
|
||||
options.persistMessage = '{% trans "Create another item after this one" %}';
|
||||
options.successMessage = '{% trans "Stock item created" %}';
|
||||
|
||||
options.fields = stockItemFields(options);
|
||||
options.groups = stockItemGroups(options);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user