diff --git a/custom_subtabs/public/js/custom_subtabs.js b/custom_subtabs/public/js/custom_subtabs.js index a6720a9..2bff563 100644 --- a/custom_subtabs/public/js/custom_subtabs.js +++ b/custom_subtabs/public/js/custom_subtabs.js @@ -3,8 +3,10 @@ frappe.ui.form.Layout.prototype.setup_tab_events = function () { setTimeout(() => { const tabs = this.wrapper.find("ul.form-tabs > li.nav-item"); - const doctype = this.frm.doctype; - const hierarchy = frappe.boot.tab_hierarchy[doctype]; + // Получение текущего Doctype в нижнем регистре + const currentDoctype = cur_frm.doctype; + + const hierarchy = frappe.boot.tab_hierarchy[currentDoctype]; if (!hierarchy) { return; @@ -18,7 +20,6 @@ frappe.ui.form.Layout.prototype.setup_tab_events = function () { if (tabPane) { tabPane.style.display = 'block'; tabPane.classList.add('active', 'show'); - } else { } } @@ -47,12 +48,11 @@ frappe.ui.form.Layout.prototype.setup_tab_events = function () { return; } - // Show the subtabs for the parent tab const parentSubtabs = subtabs[parentTabName] || []; parentSubtabs.forEach((subtabName) => { const subtabElement = $(`.nav-item:contains(${subtabName})`); - const subtabContentId = `item-${subtabName.toLowerCase().replace(/\s+/g, '_')}_tab`; + const subtabContentId = `${currentDoctype.toLowerCase()}-${subtabName.toLowerCase().replace(/\s+/g, '_')}_tab`; const subtabContent = $(`#${subtabContentId}`); if (subtabElement.length) { @@ -62,12 +62,12 @@ frappe.ui.form.Layout.prototype.setup_tab_events = function () { if (subtabName === currentTabName) { subtabContent.addClass("active show").css("display", "block"); } - } else { } }); // Show the parent tab's content - showTabContent(`item-${parentTabName.toLowerCase().replace(/\s+/g, '_')}_tab`); + const parentTabContentId = `${currentDoctype.toLowerCase()}-${parentTabName.toLowerCase().replace(/\s+/g, '_')}_tab`; + showTabContent(parentTabContentId); // Recursively handle the parent tab findParentAndShowSubtabs(parentTabName);