toggle + menù app

This commit is contained in:
Florinda
2024-10-22 18:12:55 +02:00
parent aa466491c2
commit 6b1eb70239
7 changed files with 153 additions and 61 deletions

View File

@@ -1,6 +1,7 @@
import { useAuth } from '@websanova/vue-auth/src/v3.js';
import { defineStore } from 'pinia';
import { computed, ref } from 'vue';
import { ProjectService } from '../service/ProjectService';
import { LoadingStore } from './LoadingStore';
export const UserPrefStore = defineStore('userpref_store', () => {
@@ -24,14 +25,43 @@ export const UserPrefStore = defineStore('userpref_store', () => {
});
};
async function updateSelectedProject(project) {
try {
loadingStore.user_loading = true;
// Aspetta che l'aggiornamento del progetto finisca
await ProjectService.updateSelectedProject(project);
} catch (error) {
console.error("Errore durante l'aggiornamento del progetto:", error);
} finally {
// Assicurati che il caricamento venga disabilitato anche in caso di errore
loadingStore.user_loading = false;
}
};
function setSelectedApp(app){
selectedApp.value = app;
}
const selectedProject = computed(() => user.value.selectedProject)
const availableApp = computed(() => user.value.selectedProject.lstApplications)
//const availableApp = computed(() => user.value.selectedProject.lstApplications)
const availableApp = computed(() => {
if (user.value.selectedProject!=null) {
return user.value.selectedProject.lstApplications
} else {
return []
}
});
const getSelApp = computed(() => {
return selectedApp.value
})
return { user,fetchUserData,userLoaded,selectedProject,availableApp,setSelectedApp,selectedApp }
return { user,fetchUserData,userLoaded,selectedProject,availableApp,getSelApp,setSelectedApp,selectedApp, updateSelectedProject }
})