From 949c7dd81bc9c691e1925cd3ea0dc025d54f8e9b Mon Sep 17 00:00:00 2001 From: Oliver Date: Sat, 26 Jun 2021 14:30:14 +1000 Subject: [PATCH] Set modal form title --- InvenTree/part/api.py | 3 ++- InvenTree/templates/js/forms.js | 21 +++++++++++++-------- 2 files changed, 15 insertions(+), 9 deletions(-) diff --git a/InvenTree/part/api.py b/InvenTree/part/api.py index 60cea121a7..8ef6902600 100644 --- a/InvenTree/part/api.py +++ b/InvenTree/part/api.py @@ -337,8 +337,9 @@ class PartDetail(generics.RetrieveUpdateDestroyAPIView): def get_serializer(self, *args, **kwargs): + # By default, include 'category_detail' information in the detail view try: - kwargs['category_detail'] = str2bool(self.request.query_params.get('category_detail', False)) + kwargs['category_detail'] = str2bool(self.request.query_params.get('category_detail', True)) except AttributeError: pass diff --git a/InvenTree/templates/js/forms.js b/InvenTree/templates/js/forms.js index a68def10b0..5996e1a1cd 100644 --- a/InvenTree/templates/js/forms.js +++ b/InvenTree/templates/js/forms.js @@ -161,17 +161,18 @@ function constructChangeForm(url, fields, options={}) { * and construct a modal form based on the response. * * arguments: - * - method: The HTTP method e.g. 'PUT', 'POST', 'DELETE', + * - url: API URL * * options: - * - method: + * - method: The HTTP method e.g. 'PUT', 'POST', 'DELETE', + * - title: The form title + * - fields: list of fields to display + * - exclude: List of fields to exclude */ -function constructForm(url, method, options={}) { +function constructForm(url, options={}) { - method = method.toUpperCase(); - - // Store the method in the options struct - options.method = method; + // Default HTTP method + options.method = options.method || 'PATCH'; // Request OPTIONS endpoint from the API getApiEndpointOptions(url, function(OPTIONS) { @@ -183,7 +184,7 @@ function constructForm(url, method, options={}) { * First we must determine if the user has the correct permissions! */ - switch (method) { + switch (options.method) { case 'POST': if (canCreate(OPTIONS)) { constructCreateForm(url, OPTIONS.actions.POST, options); @@ -322,6 +323,10 @@ function constructFormBody(url, fields, options={}) { $(modal + ' .select2-container').css('width', '100%'); modalShowSubmitButton(modal, true); + + var title = options.title || '{% trans "Form Title" %}'; + + modalSetTitle(modal, title); }