Skip to content

Commit

Permalink
tools: dashboard: open wizard on tab with default value
Browse files Browse the repository at this point in the history
Signed-off-by: Starbeuck <solenn.daumand@gmail.com>
  • Loading branch information
Starbeuck committed Feb 1, 2025
1 parent 0c7e3ac commit 83fa160
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions cogip/tools/dashboard/static/js/wizardModule.js
Original file line number Diff line number Diff line change
Expand Up @@ -300,13 +300,24 @@ function configureChoiceInput(typeInput, value, choices) {
const tabContentDiv = document.createElement("div");
setAttributes(tabContentDiv, { id: "tabContentDiv" });

let defaultTab = Object.keys(tabGroups)[0]; // By default, it's first tab
Object.entries(tabGroups).forEach(([tab, labels]) => {
labels.forEach(({ inputValue }) => {
if (value.includes(inputValue)) {
defaultTab = tab; // Update default tab
}
});
});

// Iterate through the tab groups to create tabs and their content
Object.entries(tabGroups).forEach(([tab, labels], tabIndex) => {
const isActive = tab === defaultTab;

// Create tab button
const tabButton = document.createElement("button");
setAttributes(tabButton, {
class: `tab-button px-4 py-2 text-sm font-semibold border-b-2 ${
tabIndex === 0
isActive
? "border-red-cogip text-red-cogip"
: " text-gray-600 border-transparent"
} hover:border-red-cogip hover:text-red-cogip focus:outline-none`,
Expand All @@ -319,7 +330,7 @@ function configureChoiceInput(typeInput, value, choices) {
setAttributes(tabContent, {
id: `tab-content-${tab}`,
class: `tab-content ${
tabIndex === 0 ? "" : "hidden"
isActive ? "" : "hidden"
} max-h-[70vh] overflow-y-auto mt-4`,
});

Expand Down

0 comments on commit 83fa160

Please sign in to comment.