toggle + menù app
This commit is contained in:
@@ -12,6 +12,7 @@ export const ScenarioStore = defineStore('scenario_store', () => {
|
||||
const applicationScenarios = ref([])
|
||||
const filterString = ref('')
|
||||
const allScenarios = ref([])
|
||||
const typeFilter = ref('all')
|
||||
|
||||
const userPrefStore = UserPrefStore()
|
||||
const loadingStore = LoadingStore()
|
||||
@@ -27,6 +28,16 @@ export const ScenarioStore = defineStore('scenario_store', () => {
|
||||
|
||||
}
|
||||
|
||||
async function fetchScenariosCross() {
|
||||
loadingStore.scenario_loading = true;
|
||||
await ScenarioService.getScenariosCross().then(resp => {
|
||||
globalScenarios.value = resp.data;
|
||||
allScenarios.value = [...globalScenarios.value]
|
||||
loadingStore.scenario_loading = false;
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
|
||||
async function fetchApplicationScenarios() {
|
||||
loadingStore.scenario_loading = true;
|
||||
@@ -46,7 +57,22 @@ export const ScenarioStore = defineStore('scenario_store', () => {
|
||||
|
||||
const filteredScenarios = computed(() => {
|
||||
console.log("scenarios", allScenarios.value);
|
||||
return allScenarios.value.filter((item) => {
|
||||
var filteredScenario = []
|
||||
|
||||
if(typeFilter.value.value === 'all') {
|
||||
filteredScenario = [...projectScenarios.value, ...applicationScenarios.value, ...globalScenarios.value]
|
||||
}
|
||||
if(typeFilter.value.value === 'project') {
|
||||
filteredScenario = [...projectScenarios.value]
|
||||
}
|
||||
if(typeFilter.value.value === 'application') {
|
||||
filteredScenario = [...applicationScenarios.value]
|
||||
}
|
||||
if(typeFilter.value.value === 'cross') {
|
||||
filteredScenario = [...globalScenarios.value]
|
||||
}
|
||||
|
||||
return filteredScenario.filter((item) => {
|
||||
return filterString.value
|
||||
.toLowerCase()
|
||||
.split(" ")
|
||||
@@ -61,5 +87,5 @@ export const ScenarioStore = defineStore('scenario_store', () => {
|
||||
fetchScenarios,
|
||||
fetchApplicationScenarios,
|
||||
scenarios,
|
||||
filterString }
|
||||
filterString , typeFilter, fetchScenariosCross, globalScenarios}
|
||||
})
|
||||
@@ -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 }
|
||||
})
|
||||
Reference in New Issue
Block a user