From 226644e59ac76cd227a455b84dc40790304d0a12 Mon Sep 17 00:00:00 2001 From: Oliver Walters Date: Tue, 14 May 2019 22:37:45 +1000 Subject: [PATCH] Open a secondary modal over the top of a primary one --- InvenTree/static/script/inventree/modals.js | 14 ++++++++++++++ InvenTree/stock/templates/stock/location.html | 14 ++++++++------ 2 files changed, 22 insertions(+), 6 deletions(-) diff --git a/InvenTree/static/script/inventree/modals.js b/InvenTree/static/script/inventree/modals.js index 8a2da5ff9c..05a0473b42 100644 --- a/InvenTree/static/script/inventree/modals.js +++ b/InvenTree/static/script/inventree/modals.js @@ -385,10 +385,24 @@ function attachSecondaryModal(modal, options) { * field: Name of the field to attach to * label: Button text * title: Hover text to display over button (optional) + * url: URL for the secondary modal + * query: Query params for the secondary modal */ // Insert the button insertNewItemButton(modal, options); + + // Add a callback to the button + $(modal).find("#btn-new-" + options.field).on('click', function() { + + // Launch the secondary modal + launchModalForm( + options.url, + { + modal: '#modal-form-secondary', + } + ); + }); } diff --git a/InvenTree/stock/templates/stock/location.html b/InvenTree/stock/templates/stock/location.html index d3379c32e2..18aa369d0d 100644 --- a/InvenTree/stock/templates/stock/location.html +++ b/InvenTree/stock/templates/stock/location.html @@ -128,17 +128,19 @@ attachSecondaryModal(modal, { - 'field': 'part', - 'label': 'New Part', - 'title': 'Create New Part', + field: 'part', + label: 'New Part', + title: 'Create New Part', + url: "{% url 'part-create' %}", } ); attachSecondaryModal(modal, { - 'field': 'location', - 'label': 'New Location', - 'title': 'Create New Location' + field: 'location', + label: 'New Location', + title: 'Create New Location', + url: "{% url 'stock-location-create' %}", } ); }