From 60646cebf615834c970c124b4850bc826895844b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicol=C3=B2=20P=2E?= Date: Tue, 23 Jun 2026 22:47:17 +0200 Subject: [PATCH] Keep all ontology domains in menu --- scenes/ssgp/index.html | 2 +- src/controllers/menu_controller.js | 39 ++++++++++++++++++------------ src/ontology.js | 20 +++++++-------- 3 files changed, 33 insertions(+), 28 deletions(-) diff --git a/scenes/ssgp/index.html b/scenes/ssgp/index.html index 158037f..3647729 100644 --- a/scenes/ssgp/index.html +++ b/scenes/ssgp/index.html @@ -157,7 +157,7 @@
diff --git a/src/controllers/menu_controller.js b/src/controllers/menu_controller.js index 6843a09..d42c8b6 100644 --- a/src/controllers/menu_controller.js +++ b/src/controllers/menu_controller.js @@ -225,30 +225,37 @@ export default class extends Controller { /** * Temporary implementation to show domains only * @todo Don't rebuild it every time, use caching, return a container - * @param {Object} ontology The traversed ontology object (temp) + * @param {Array<{id: string, tree: Array}>} domains The traversed ontology domains * @param {HTMLElement} tab Tab content element */ - #buildOntologyMenu(ontology, tab) { + #buildOntologyMenu(domains, tab) { const mainNode = tab.querySelector('#ontology-list'); - mainNode.innerHTML = html` - ${ontology.ontology} - `; mainNode.classList.add('pb-3'); - let domainList = document.createElement('div'); + for (let domain of domains) { + const heading = document.createElement('span'); + heading.className ="fs-5 fw-bold"; + heading.textContent = domain.id; + mainNode.appendChild(heading); - for (let domain of ontology.domains) { - const domainItem = document.createElement('div'); - domainItem.className = 'border-start border-bottom rounded'; - domainItem.textContent = domain.label; - // Indentation... - domainItem.classList.add(`ms-${domain.depth}`, `ps-${domain.depth}`, 'py-2'); + let domainList = document.createElement('div'); - if (domain.depth === 1) domainItem.classList.add('fw-bold'); + console.debug(domain.tree); - domainList.appendChild(domainItem); + // Traverse class trees for each domain + for (let item of domain.tree) { + const domainItem = document.createElement('div'); + domainItem.className = 'border-start border-bottom rounded'; + domainItem.textContent = item.label; + // Indentation... + domainItem.classList.add(`ms-${item.depth}`, `ps-${item.depth}`, 'py-2'); + + if (item.depth === 1) domainItem.classList.add('fw-bold'); + + domainList.appendChild(domainItem); + } + + mainNode.appendChild(domainList); } - - mainNode.appendChild(domainList); } } diff --git a/src/ontology.js b/src/ontology.js index 628ded2..788f2fe 100644 --- a/src/ontology.js +++ b/src/ontology.js @@ -12,21 +12,20 @@ export async function traverseOntology(jsonPath) { const ontology = await loadOntology(jsonPath); const modules = ontology.modules; - let tree = []; + const domains = []; for (const module of modules) { - if (module.id === 'Architecture') { - console.debug(module.classTrees); - for (const classTree of module.classTrees) { - traverseClasses(classTree, tree); - } + let tree = []; + for (const classTree of module.classTrees) { + traverseClasses(classTree, tree); } + domains.push({ + id: module.id, + tree + }); } - return { - ontology: "Architecture", - domains: tree - }; + return domains; } /** @@ -52,7 +51,6 @@ function traverseClasses(ontologyClass, tree, depth = 1) { ); } } - } /**