mirror of
https://github.com/inventree/InvenTree.git
synced 2025-04-29 20:16:44 +00:00
Toot toot all aboard the refactor tractor
- launchModalForm now accepts a 'secondary' parameter which is a list of secondary modals to attach
This commit is contained in:
parent
97c4e5acbf
commit
9d50f2a6ac
@ -90,25 +90,20 @@
|
|||||||
category: {{ category.id }}
|
category: {{ category.id }}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
},
|
},
|
||||||
after_render: function(modal, response) {
|
secondary: [
|
||||||
attachSecondaryModal(modal,
|
{
|
||||||
{
|
field: 'category',
|
||||||
field: 'category',
|
label: 'New Category',
|
||||||
label: 'New Category',
|
title: 'Create new Part Category',
|
||||||
title: 'Create new Part Category',
|
url: "{% url 'category-create' %}",
|
||||||
url: "{% url 'category-create' %}",
|
},
|
||||||
}
|
{
|
||||||
);
|
field: 'default_location',
|
||||||
|
label: 'New Location',
|
||||||
attachSecondaryModal(modal,
|
title: 'Create new Stock Location',
|
||||||
{
|
url: "{% url 'stock-location-create' %}",
|
||||||
field: 'default_location',
|
}
|
||||||
label: 'New Location',
|
]
|
||||||
title: 'Create new Stock Location',
|
|
||||||
url: "{% url 'stock-location-create' %}",
|
|
||||||
}
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
@ -420,6 +420,15 @@ function attachSecondaryModal(modal, options) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function attachSecondaries(modal, secondaries) {
|
||||||
|
/* Attach a provided list of secondary modals */
|
||||||
|
|
||||||
|
for (var i = 0; i < secondaries.length; i++) {
|
||||||
|
attachSecondaryModal(modal, secondaries[i]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
function handleModalForm(url, options) {
|
function handleModalForm(url, options) {
|
||||||
/* Update a modal form after data are received from the server.
|
/* Update a modal form after data are received from the server.
|
||||||
* Manages POST requests until the form is successfully submitted.
|
* Manages POST requests until the form is successfully submitted.
|
||||||
@ -471,6 +480,10 @@ function handleModalForm(url, options) {
|
|||||||
if (options.after_render) {
|
if (options.after_render) {
|
||||||
options.after_render(modal, response);
|
options.after_render(modal, response);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (options.secondary) {
|
||||||
|
attachSecondaries(modal, options.secondary);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
$(modal).modal('hide');
|
$(modal).modal('hide');
|
||||||
@ -514,6 +527,7 @@ function launchModalForm(url, options = {}) {
|
|||||||
* close_text - Text for the close button (default = 'Close')
|
* close_text - Text for the close button (default = 'Close')
|
||||||
* no_post - If true, only display form data, hide submit button, and disallow POST
|
* no_post - If true, only display form data, hide submit button, and disallow POST
|
||||||
* after_render - Callback function to run after form is rendered
|
* after_render - Callback function to run after form is rendered
|
||||||
|
* secondary - List of secondary modals to attach
|
||||||
*/
|
*/
|
||||||
|
|
||||||
var modal = options.modal || '#modal-form';
|
var modal = options.modal || '#modal-form';
|
||||||
@ -550,6 +564,10 @@ function launchModalForm(url, options = {}) {
|
|||||||
options.after_render(modal, response);
|
options.after_render(modal, response);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (options.secondary) {
|
||||||
|
attachSecondaries(modal, options.secondary);
|
||||||
|
}
|
||||||
|
|
||||||
if (options.no_post) {
|
if (options.no_post) {
|
||||||
modalShowSubmitButton(modal, false);
|
modalShowSubmitButton(modal, false);
|
||||||
} else {
|
} else {
|
||||||
|
@ -124,26 +124,20 @@
|
|||||||
location: {{ location.id }}
|
location: {{ location.id }}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
},
|
},
|
||||||
after_render: function(modal, response) {
|
secondary: [
|
||||||
|
{
|
||||||
attachSecondaryModal(modal,
|
field: 'part',
|
||||||
{
|
label: 'New Part',
|
||||||
field: 'part',
|
title: 'Create New Part',
|
||||||
label: 'New Part',
|
url: "{% url 'part-create' %}",
|
||||||
title: 'Create New Part',
|
},
|
||||||
url: "{% url 'part-create' %}",
|
{
|
||||||
}
|
field: 'location',
|
||||||
);
|
label: 'New Location',
|
||||||
|
title: 'Create New Location',
|
||||||
attachSecondaryModal(modal,
|
url: "{% url 'stock-location-create' %}",
|
||||||
{
|
}
|
||||||
field: 'location',
|
]
|
||||||
label: 'New Location',
|
|
||||||
title: 'Create New Location',
|
|
||||||
url: "{% url 'stock-location-create' %}",
|
|
||||||
}
|
|
||||||
);
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user