diff --git a/InvenTree/InvenTree/views.py b/InvenTree/InvenTree/views.py index d6ee093a6f..985c676417 100644 --- a/InvenTree/InvenTree/views.py +++ b/InvenTree/InvenTree/views.py @@ -56,7 +56,6 @@ class AjaxMixin(object): ajax_form_action = '' ajax_form_title = '' - ajax_submit_text = 'Submit' def get_data(self): return {} @@ -76,8 +75,6 @@ class AjaxMixin(object): data['title'] = self.ajax_form_title - data['submit_label'] = self.ajax_submit_text - data['html_form'] = render_to_string( self.getAjaxTemplate(), context, diff --git a/InvenTree/build/templates/build/detail.html b/InvenTree/build/templates/build/detail.html index 287c5c1bd5..ad25b4307d 100644 --- a/InvenTree/build/templates/build/detail.html +++ b/InvenTree/build/templates/build/detail.html @@ -109,7 +109,8 @@ $("#build-cancel").click(function() { launchModalForm("{% url 'build-cancel' build.id %}", { - reload: true + reload: true, + submit_text: "Cancel", }); }); {% endblock %} diff --git a/InvenTree/build/views.py b/InvenTree/build/views.py index 97e5a2fb51..c4f406c974 100644 --- a/InvenTree/build/views.py +++ b/InvenTree/build/views.py @@ -40,7 +40,6 @@ class BuildCancel(AjaxView): model = Build template_name = 'build/cancel.html' ajax_form_title = 'Cancel Build' - ajax_submit_text = 'Cancel' context_object_name = 'build' fields = [] diff --git a/InvenTree/static/script/inventree/modals.js b/InvenTree/static/script/inventree/modals.js index 72f51d9d5a..f729282b52 100644 --- a/InvenTree/static/script/inventree/modals.js +++ b/InvenTree/static/script/inventree/modals.js @@ -57,8 +57,9 @@ function modalSetContent(modal, content='') { $(modal).find('.modal-form-content').html(content); } -function modalSetButtonText(modal, text) { - $(modal).find("#modal-form-submit").html(text); +function modalSetButtonText(modal, submit_text, close_text) { + $(modal).find("#modal-form-submit").html(submit_text); + $(modal).find("#modal-form-close").html(close_text); } function closeModal(modal='#modal-form') { @@ -102,9 +103,11 @@ function openModal(options) { modalSetContent(modal, options.content); } - if (options.submit_label) { - modalSetButtonText(modal, options.submit_label); - } + // Default labels for 'Submit' and 'Close' buttons in the form + var submit_text = options.submit_text || 'Submit'; + var close_text = options.close_text || 'Close'; + + modalSetButtonText(modal, submit_text, close_text); $(modal).modal({ backdrop: 'static', @@ -243,23 +246,27 @@ function launchModalForm(url, options = {}) { var modal = options.modal || '#modal-form'; + // Default labels for 'Submit' and 'Close' buttons in the form + var submit_text = options.submit_text || 'Submit'; + var close_text = options.close_text || 'Close'; + // Form the ajax request to retrieve the django form data ajax_data = { url: url, type: 'get', dataType: 'json', beforeSend: function () { - openModal({modal: modal}); + openModal({ + modal: modal, + submit_text: submit_text, + close_text: close_text, + }); }, success: function(response) { if (response.title) { modalSetTitle(modal, response.title); } - if (response.submit_label) { - modalSetButtonText(modal, String(response.submit_label)); - } - if (response.html_form) { injectModalForm(modal, response.html_form); handleModalForm(url, options); diff --git a/InvenTree/static/script/inventree/stock.js b/InvenTree/static/script/inventree/stock.js index 3ad4503b8b..4f008aec0c 100644 --- a/InvenTree/static/script/inventree/stock.js +++ b/InvenTree/static/script/inventree/stock.js @@ -207,7 +207,7 @@ function moveStockItems(items, options) { openModal({ modal: modal, title: "Move " + items.length + " stock items", - submit_label: "Move" + submit_text: "Move" }); // Extact part row info diff --git a/InvenTree/stock/templates/stock/item.html b/InvenTree/stock/templates/stock/item.html index 7f6673621c..572f7b8e4b 100644 --- a/InvenTree/stock/templates/stock/item.html +++ b/InvenTree/stock/templates/stock/item.html @@ -135,7 +135,8 @@ launchModalForm( "{% url 'stock-item-edit' item.id %}", { - reload: true + reload: true, + submit_text: "Save", }); }); @@ -145,6 +146,7 @@ "{% url 'stock-item-move' item.id %}", { reload: true, + submit_text: "Move" }); }); diff --git a/InvenTree/stock/views.py b/InvenTree/stock/views.py index 3df9ce0893..d195671bca 100644 --- a/InvenTree/stock/views.py +++ b/InvenTree/stock/views.py @@ -134,7 +134,6 @@ class StockItemMove(AjaxUpdateView): template_name = 'modal_form.html' context_object_name = 'item' ajax_form_title = 'Move Stock Item' - ajax_submit_text = 'Move' form_class = MoveStockItemForm def post(self, request, *args, **kwargs): diff --git a/InvenTree/templates/modals.html b/InvenTree/templates/modals.html index d229c29215..a84e4c7b44 100644 --- a/InvenTree/templates/modals.html +++ b/InvenTree/templates/modals.html @@ -10,7 +10,7 @@