From 100a3b1d2a34527e7706d1bc165aeafe6868d334 Mon Sep 17 00:00:00 2001 From: Emanuele Ferrelli Date: Tue, 25 Feb 2025 15:46:57 +0100 Subject: [PATCH] =?UTF-8?q?Create=20multilayer=20men=C3=B9=20using=20type?= =?UTF-8?q?=20field=20in=20application=20collection=20(db)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/SingleClassViewer.vue | 1 - src/layout/AppMenu.vue | 101 ++++++++++++++++++--------- 2 files changed, 68 insertions(+), 34 deletions(-) diff --git a/src/components/SingleClassViewer.vue b/src/components/SingleClassViewer.vue index f754667..97c54c7 100644 --- a/src/components/SingleClassViewer.vue +++ b/src/components/SingleClassViewer.vue @@ -96,7 +96,6 @@
-
Select a Scenario
0) { + const groupedScenarios = {}; + + //Raggruppa gli scenari per categoria (solo se type non è null) selectedApp.available_scenarios.forEach(app => { - let scenarioItem = { - label: app.label, - icon: 'pi pi-fw pi-wrench', - items: [], // Sub-items per ogni scenario - command: () => { - route.push({ path: `/scenario/exec/${app.scenario_id}` }); + if (app.type) { + const type = app.type; + if (!groupedScenarios[type]) { + groupedScenarios[type] = []; } - }; + groupedScenarios[type].push(app); + } else { + //Se non ha categoria, lo trattiamo singolarmente + model.value[1].items.push(createScenarioItem(app)); + } + }); + + //Creazione del menu in base ai gruppi + Object.keys(groupedScenarios).forEach(type => { + const scenarios = groupedScenarios[type]; - // Aggiungi la sottovoce "Execution List" - scenarioItem.items.push({ - label: 'Execution List', - icon: 'pi pi-fw pi-list', - to: '/executions/filter', - command: () => { - // Salva il nome dello scenario nello store - userPrefStore.setSelectedScenario(app.label); - } - }); + if (scenarios.length >= 2) { + //Se ci sono almeno 2 scenari nella stessa categoria, creiamo un gruppo + const typeItem = { + label: type, + icon: 'pi pi-fw pi-folder', + items: [] + }; - // Aggiungi lo scenario alla lista principale - model.value[1].items.push(scenarioItem); + scenarios.forEach(app => { + typeItem.items.push(createScenarioItem(app)); + }); + + model.value[1].items.push(typeItem); + }else { + //Se c'è solo un elemento, lo aggiungiamo direttamente + model.value[1].items.push(createScenarioItem(scenarios[0])); + } + }); + + //Aggiungi "Rev Eng Code" alla fine della lista + model.value[1].items.push({ + label: 'Rev Eng Code', + icon: 'pi pi-fw pi-cog', + command: () => { + route.push({ path: '/app-browser' }); + } }); } - - // Aggiungi "Rev Eng Code" alla fine della lista - model.value[1].items.push({ - label: 'Rev Eng Code', - icon: 'pi pi-fw pi-wrench', - command: () => { - route.push({ path: '/app-browser' }); - } - }); - } else { - // Se selectedApp è nullo, svuota gli item + //Se selectedApp è nullo, svuota il menu model.value[1].label = ''; model.value[1].items = []; } } +//Funzione per creare un item scenario con Execution List +function createScenarioItem(app) { + return { + label: app.label, + icon: 'pi pi-fw pi-wrench', + items: [ + { + label: 'Execution List', + icon: 'pi pi-fw pi-list', + to: '/executions/filter', + command: () => { + userPrefStore.setSelectedScenario(app.label); + } + } + ], + command: () => { + route.push({ path: `/scenario/exec/${app.scenario_id}` }); + } + }; +} + +