From d5ad37d20ca33f7505f4ffc6a75a060f8f007bcd Mon Sep 17 00:00:00 2001 From: Kaushik Date: Sat, 14 Feb 2026 11:55:20 +0000 Subject: [PATCH] Add guard clause to prevent duplicate tab creation in license admin form Signed-off-by: Kaushik --- .../license_library/license/change_form.html | 31 ++++++++++--------- 1 file changed, 17 insertions(+), 14 deletions(-) diff --git a/license_library/templates/admin/license_library/license/change_form.html b/license_library/templates/admin/license_library/license/change_form.html index 8c58e0f0..0c796f16 100644 --- a/license_library/templates/admin/license_library/license/change_form.html +++ b/license_library/templates/admin/license_library/license/change_form.html @@ -156,20 +156,23 @@ // Hack to move the transform the Inline into a "tab" // Manipulate the DOM to prepare before activating the tags - // Add the tabs list links - var tabs_ul = $(''); - tabs_ul.prependTo('#license_form'); - $("#grp-content-container").attr('style', 'clear:both;'); - // We put a tabs-1 id on the wrapper div in the form - $("#license_form > div:last-child").attr('id', 'tabs-1'); - // Add a new div tabs-2 in the form and move the Inline into it - $('
').appendTo('#license_form'); - $("#licenseassignedtag_set-group").appendTo('#tabs-2'); - // The footer needs to be moved too to be outside "tabs-1" - $("footer").appendTo('#license_form'); - - // Activate the tabs - $("#license_form").tabs(); + // Check if tabs already exist to prevent duplication + if ($('#license_form > ul').length === 0) { + // Add the tabs list links + var tabs_ul = $(''); + tabs_ul.prependTo('#license_form'); + $("#grp-content-container").attr('style', 'clear:both;'); + // We put a tabs-1 id on the wrapper div in the form + $("#license_form > div:last-child").attr('id', 'tabs-1'); + // Add a new div tabs-2 in the form and move the Inline into it + $('
').appendTo('#license_form'); + $("#licenseassignedtag_set-group").appendTo('#tabs-2'); + // The footer needs to be moved too to be outside "tabs-1" + $("footer").appendTo('#license_form'); + + // Activate the tabs + $("#license_form").tabs(); + } // Removing un-wanted class, to ensure visual consistency $("#license_form").removeClass("ui-widget ui-widget-content ui-corner-all"); $("#tabs-1, #tabs-2").removeClass("ui-tabs-panel ui-widget-content ui-corner-bottom");