From c60d94a21c3e7f5805d162a6e97deeb736941b31 Mon Sep 17 00:00:00 2001 From: Emanuele Ferrelli Date: Thu, 15 Jan 2026 12:23:22 +0100 Subject: [PATCH 1/3] Update picklist for new folders --- src/views/pages/ScenarioExec.vue | 113 ++++++++++++++++++++++++++++++- 1 file changed, 110 insertions(+), 3 deletions(-) diff --git a/src/views/pages/ScenarioExec.vue b/src/views/pages/ScenarioExec.vue index 322375e..748a61c 100644 --- a/src/views/pages/ScenarioExec.vue +++ b/src/views/pages/ScenarioExec.vue @@ -335,6 +335,8 @@ const fileNamesOutput = ref([]); const ksVideoGroupStore = KsVideoGroupStore(); const userPrefStore = UserPrefStore(); const videoGroups = ref([]); +const ksFolders = ref([]); +const folderToItemsMap = ref({}); // URL di upload const uploadUrlBase = import.meta.env.VITE_BACKEND_URL; const uploadUrl = ref(''); @@ -424,6 +426,78 @@ const loadVideoGroups = async () => { }); }; +// Estrae tutte le folder/subfolder uniche dai documenti e video +const extractFoldersFromItems = (items) => { + const folderMap = {}; + const folderSet = new Set(); + + items.forEach((item) => { + const path = item.ingestionInfo?.metadata?.ksKnowledgePath; + if (!path) return; + + // Rimuovi il leading slash se presente + const cleanPath = path.startsWith('/') ? path.substring(1) : path; + if (!cleanPath) return; + + // Dividi il path in parti + const parts = cleanPath.split('/'); + + // Crea tutte le combinazioni di folder/subfolder + let currentPath = ''; + parts.forEach((part, index) => { + currentPath = index === 0 ? part : `${currentPath}/${part}`; + const fullPath = `/${currentPath}`; + + folderSet.add(fullPath); + + // Inizializza l'array per questa folder se non esiste + if (!folderMap[fullPath]) { + folderMap[fullPath] = []; + } + + // Aggiungi l'item solo se il path corrisponde esattamente + if (fullPath === path) { + folderMap[fullPath].push({ + id: item.id, + type: item.fileName ? 'document' : 'video', + name: item.fileName || item.name + }); + } + }); + }); + + return { folders: Array.from(folderSet).sort(), folderMap }; +}; + +const loadKsFolders = async () => { + try { + // Carica documenti e video + const docsResponse = await KSDocumentService.getKSDocuments(); + const documents = docsResponse.data || []; + + // Combina documenti e video + const allItems = [...documents, ...videoGroups.value]; + + // Estrai folder e crea la mappa + const { folders, folderMap } = extractFoldersFromItems(allItems); + + // Crea la struttura per la picklist + ksFolders.value = folders.map((path) => ({ + id: path, + name: path, + path: path, + itemCount: folderMap[path]?.length || 0 + })); + + // Salva la mappa folder->items per uso successivo + folderToItemsMap.value = folderMap; + + console.log(`Loaded ${ksFolders.value.length} folders with items:`, folderToItemsMap.value); + } catch (error) { + console.error('Error loading KS folders:', error); + } +}; + // Ricarica i dati quando cambia il parametro `id` watch(() => route.params.id, fetchScenario); @@ -517,9 +591,32 @@ const execScenario = async () => { const selectedItems = processedData[input.name]; if (Array.isArray(selectedItems) && selectedItems.length > 0) { - // Elaborazione per VideoGroups (backward compatibility) - processedData[`${input.name}_id`] = JSON.stringify(selectedItems.map((item) => item.id || item)); - processedData[`${input.name}_name`] = JSON.stringify(selectedItems.map((item) => item.name || item.fileName || item)); + // Elaborazione speciale per ksFolders + if (input.dataSource === 'ksFolders') { + // Ottieni tutti gli ID dei documenti/video nelle folder selezionate + const allItemIds = []; + const allItemNames = []; + + selectedItems.forEach((folder) => { + const folderPath = folder.path || folder.id || folder; + const items = folderToItemsMap.value[folderPath] || []; + + items.forEach((item) => { + allItemIds.push(item.id); + allItemNames.push(item.name); + }); + }); + + processedData[`${input.name}_id`] = JSON.stringify(allItemIds); + processedData[`${input.name}_name`] = JSON.stringify(allItemNames); + processedData[`${input.name}_folders`] = JSON.stringify(selectedItems.map((item) => item.path || item.id || item)); + + console.log(`Folder selection - Total items: ${allItemIds.length}`, allItemIds); + } else { + // Elaborazione per VideoGroups e ksDocuments (backward compatibility) + processedData[`${input.name}_id`] = JSON.stringify(selectedItems.map((item) => item.id || item)); + processedData[`${input.name}_name`] = JSON.stringify(selectedItems.map((item) => item.name || item.fileName || item)); + } // Rimuovi l'array originale delete processedData[input.name]; @@ -892,6 +989,8 @@ const getOptionsForInput = (input) => { return videoGroups.value; case 'ksDocuments': return ksDocuments.value; + case 'ksFolders': + return ksFolders.value; default: return []; } @@ -934,6 +1033,14 @@ const loadOptionsForScenario = async () => { console.log(`Loaded ${ksDocuments.value.length} KS documents`); break; + case 'ksFolders': + // Prima carica i video groups se non sono già caricati + if (videoGroups.value.length === 0) { + await loadVideoGroups(); + } + await loadKsFolders(); + break; + default: console.warn(`Unknown dataSource: ${dataSource}`); } From d697385c22750d2593a250ff27e71542694db78f Mon Sep 17 00:00:00 2001 From: "dalia.florinda" Date: Mon, 19 Jan 2026 09:57:25 +0100 Subject: [PATCH 2/3] fix picklist --- src/components/DynamicPicker.vue | 94 ++++++++++++++++++++++++++ src/views/pages/OldScenarioExec.vue | 7 +- src/views/pages/ScenarioExec.vue | 100 ++++++++++++++++++++++++++-- 3 files changed, 193 insertions(+), 8 deletions(-) diff --git a/src/components/DynamicPicker.vue b/src/components/DynamicPicker.vue index b12f8fe..84bf986 100644 --- a/src/components/DynamicPicker.vue +++ b/src/components/DynamicPicker.vue @@ -60,6 +60,60 @@ + + + + + +