Skip to content
Snippets Groups Projects
Commit 7d2448e7 authored by Hanna Führ's avatar Hanna Führ Committed by Petar Hristov
Browse files

Update: extending enabled resource types

parent 83330a57
No related branches found
No related tags found
2 merge requests!201Release: Sprint Feb 10, 2023 - Sprint Feb 23, 2023,!195Update: extending enabled resource types
......@@ -314,8 +314,8 @@ export default defineComponent({
},
created() {
// Load list of Enabled Resource Types if not present
if (this.resourceStore.enabledResourceTypes === null) {
// Load list of all Resource Types if not present
if (this.resourceStore.resourceTypes === null) {
this.resourceStore.retrieveResourceTypes();
}
},
......
......@@ -95,10 +95,7 @@ export default defineComponent({
) {
this.projectStore.retrieveInvitations(this.project);
}
// Load list of Enabled Resource Types if not present
if (this.resourceStore.enabledResourceTypes === null) {
await this.resourceStore.retrieveResourceTypes();
}
await this.resourceStore.retrieveEnabledResourceTypes(this.project);
},
},
});
......
......@@ -191,7 +191,7 @@ export default defineComponent({
}
// Load list of Enabled Resource Types if not present
if (this.resourceStore.enabledResourceTypes === null) {
await this.resourceStore.retrieveResourceTypes();
await this.resourceStore.retrieveEnabledResourceTypes(this.project);
}
// Load Project Visibilities if not present
if (this.projectStore.visibilities === null) {
......
......@@ -17,7 +17,6 @@ import type {
Project,
ResourceObject,
ResourceQuotaReturnObject,
ResourceTypeInformation,
} from "@coscine/api-client/dist/types/Coscine.Api.Resources";
import type { Route } from "vue-router/types/router";
import type { BilingualLabels } from "@coscine/api-client/dist/types/Coscine.Api.Metadata";
......@@ -48,6 +47,7 @@ export const useResourceStore = defineStore({
classes: {},
currentId: null,
resourceTypes: null,
enabledResourceTypes: null,
visitedResources: {},
}),
......@@ -84,14 +84,6 @@ export const useResourceStore = defineStore({
return null;
}
},
enabledResourceTypes(): ResourceTypeInformation[] | null {
if (this.resourceTypes) {
return this.resourceTypes.filter((rt) => rt.isEnabled);
} else {
return null;
}
},
},
/*
--------------------------------------------------------------------------------------
......@@ -205,6 +197,24 @@ export const useResourceStore = defineStore({
}
},
async retrieveEnabledResourceTypes(project: ProjectObject | null) {
const notificationStore = useNotificationStore();
try {
if (project && project.id) {
const apiResponse =
await ResourceTypeApi.resourceTypeGetEnabledResourceTypesAll(
project.id
);
this.enabledResourceTypes = apiResponse.data;
} else {
console.error("Selected project is null or its ID is undefined.");
}
} catch (error) {
// Handle other Status Codes
notificationStore.postApiErrorNotification(error as AxiosError);
}
},
async retrieveResourceTypes() {
const notificationStore = useNotificationStore();
try {
......
......@@ -64,5 +64,6 @@ export interface ResourceState {
classes: { [className: string]: BilingualLabels };
currentId: string | null;
resourceTypes: ResourceTypeInformation[] | null;
enabledResourceTypes: ResourceTypeInformation[] | null;
visitedResources: { [slug: string]: VisitedResourceObject };
}
......@@ -41,7 +41,8 @@ export default defineComponent({
if (!this.resourceStore.allResources) {
await this.resourceStore.retrieveAllResources();
}
if (!this.resourceStore.enabledResourceTypes) {
// Load list of all Resource Types if not present
if (!this.resourceStore.resourceTypes) {
await this.resourceStore.retrieveResourceTypes();
}
},
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment