From 5cbb67b91cedb9cf53ba972170fd5cfff0729b7e Mon Sep 17 00:00:00 2001 From: Oliver Walters Date: Sat, 14 Aug 2021 00:20:34 +1000 Subject: [PATCH] Add options to show / hide form groups --- InvenTree/templates/js/translated/forms.js | 26 +++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/InvenTree/templates/js/translated/forms.js b/InvenTree/templates/js/translated/forms.js index a5f4f56bc9..b4f1203220 100644 --- a/InvenTree/templates/js/translated/forms.js +++ b/InvenTree/templates/js/translated/forms.js @@ -842,10 +842,12 @@ function handleFormErrors(errors, fields, options) { var non_field_errors = $(options.modal).find('#non-field-errors'); + // TODO: Display the JSON error text when hovering over the "info" icon non_field_errors.append( `
{% trans "Form errors exist" %} - + +
` ); @@ -985,6 +987,28 @@ function initializeGroups(fields, options) { } else { $(modal).find(`#form-panel-content-${group}`).collapse("show"); } + + if (group_options.hidden) { + hideFormGroup(group, options); + } + } +} + +// Hide a form group +function hideFormGroup(group, options) { + $(options.modal).find(`#form-panel-${group}`).hide(); +} + +// Show a form group +function showFormGroup(group, options) { + $(options.modal).find(`#form-panel-${group}`).show(); +} + +function setFormGroupVisibility(group, vis, options) { + if (vis) { + showFormGroup(group, options); + } else { + hideFormGroup(group, options); } }