mirror of
https://github.com/inventree/InvenTree
synced 2024-08-30 18:33:04 +00:00
Upon successful creation (in a secondary modal) update the field in the primary modal
This commit is contained in:
parent
a316681ec8
commit
be1b458634
@ -102,7 +102,7 @@ function afterForm(response, options) {
|
||||
|
||||
// Was a callback provided?
|
||||
if (options.success) {
|
||||
options.success();
|
||||
options.success(response);
|
||||
}
|
||||
else if (options.follow && response.url) {
|
||||
window.location.href = response.url;
|
||||
@ -400,6 +400,20 @@ function attachSecondaryModal(modal, options) {
|
||||
options.url,
|
||||
{
|
||||
modal: '#modal-form-secondary',
|
||||
success: function(response) {
|
||||
|
||||
/* A successful object creation event should return a response which contains:
|
||||
* - pk: ID of the newly created object
|
||||
* - text: String descriptor of the newly created object
|
||||
*
|
||||
* So it is simply a matter of appending and selecting the new object!
|
||||
*/
|
||||
|
||||
var select = '#id_' + options.field;
|
||||
var option = new Option(response.text, response.pk, true, true)
|
||||
|
||||
$(modal).find(select).append(option).trigger('change');
|
||||
}
|
||||
}
|
||||
);
|
||||
});
|
||||
|
@ -32,8 +32,8 @@ class CreateStockItemForm(HelperForm):
|
||||
'part',
|
||||
'supplier_part',
|
||||
'location',
|
||||
'batch',
|
||||
'quantity',
|
||||
'batch',
|
||||
'delete_on_deplete',
|
||||
'status',
|
||||
'notes',
|
||||
|
Loading…
Reference in New Issue
Block a user