From 0cc2e7184349521126c029b2dce85a4453f1cca8 Mon Sep 17 00:00:00 2001 From: Oliver Walters Date: Tue, 14 May 2019 19:00:59 +1000 Subject: [PATCH 01/15] Provide an after_render callback - User callback after the form data are rendered --- InvenTree/static/script/inventree/modals.js | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/InvenTree/static/script/inventree/modals.js b/InvenTree/static/script/inventree/modals.js index 67d4497674..6c6c449fb3 100644 --- a/InvenTree/static/script/inventree/modals.js +++ b/InvenTree/static/script/inventree/modals.js @@ -401,6 +401,10 @@ function handleModalForm(url, options) { else { if (response.html_form) { injectModalForm(modal, response.html_form); + + if (options.after_render) { + options.after_render(modal, response); + } } else { $(modal).modal('hide'); @@ -443,6 +447,7 @@ function launchModalForm(url, options = {}) { * submit_text - Text for the submit button (default = 'Submit') * close_text - Text for the close button (default = 'Close') * no_post - If true, only display form data, hide submit button, and disallow POST + * after_render - Callback function to run after form is rendered */ var modal = options.modal || '#modal-form'; @@ -475,6 +480,10 @@ function launchModalForm(url, options = {}) { if (response.html_form) { injectModalForm(modal, response.html_form); + if (options.after_render) { + options.after_render(modal, response); + } + if (options.no_post) { modalShowSubmitButton(modal, false); } else { From a96cd2240cc8efd9d378808ba02f1bbbbe8e2432 Mon Sep 17 00:00:00 2001 From: Oliver Walters Date: Tue, 14 May 2019 22:12:22 +1000 Subject: [PATCH 02/15] Function to insert a 'create new' button into a form - Look for a label like