Skip to content
Snippets Groups Projects
Select Git revision
  • 29f8faf7be0025eebaf202bafe4ce7bdaffb47ff
  • main default protected
  • dev protected
  • Issue/3175-uiQuotaSettingAndDisplayBug
  • Issue/3090-tosProblems
  • Issue/3178-iconColorBug
  • Issue/3176-addNewNFDI4INGLogo
  • Issue/3141-rdsNoLonga
  • Issue/3180-fixMetadataNotLoading
  • Issue/3177-resourceTypeDescriptionTexts
  • Issue/3160-deactivateDownloadForFolders
  • Issue/3111-fixLoadingGitLabResource
  • Issue/3133-subProjectsChanges
  • Issue/3139-dsnrw
  • Issue/3167-changeTextAndAddLink
  • Issue/3070-newIconsForResourceTypes
  • Issue/3145-redesignLoginPage
  • Issue/3093-moreInformationInTheDeletionEmails
  • Issue/3040-closeTokenWindowWithXButton
  • Issue/3152-fixResourceStore
  • Issue/xxxx-DuckDBTest
  • v3.19.1
  • v3.19.0
  • v3.18.0
  • v3.17.2
  • v3.17.1
  • v3.17.0
  • v3.16.1
  • v3.16.0
  • v3.15.6
  • v3.15.5
  • v3.15.4
  • v3.15.3
  • v3.15.2
  • v3.15.1
  • v3.15.0
  • v3.14.0
  • v3.13.1
  • v3.13.0
  • v3.12.0
  • v3.11.0
41 results

ProjectModule.vue

Blame
  • Code owners
    Assign users and groups as approvers for specific file changes. Learn more.
    ProjectModule.vue 2.97 KiB
    <template>
      <div>
        <RouterView />
      </div>
    </template>
    
    <script lang="ts">
    import { defineComponent } from "vue";
    
    // import the store for current module
    import useProjectStore from "./store";
    import useResourceStore from "@/modules/resource/store";
    import useNotificationStore from "@/store/notification";
    
    import type { ProjectObject } from "@coscine/api-client/dist/types/Coscine.Api.Project";
    import type { Route } from "vue-router";
    
    export default defineComponent({
      async beforeRouteUpdate(to, from, next) {
        await this.apiFetch(to);
        next();
      },
      setup() {
        const projectStore = useProjectStore();
        const notificationStore = useNotificationStore();
        const resourceStore = useResourceStore();
    
        return { projectStore, notificationStore, resourceStore };
      },
    
      computed: {
        project(): ProjectObject | null {
          return this.projectStore.currentProject;
        },
        moduleIsReady(): boolean {
          // Currently unused
          return (
            this.projectStore.currentSlug !== null &&
            this.projectStore.currentProject !== null &&
            this.projectStore.currentResources !== null &&
            this.projectStore.currentSubProjects !== null &&
            this.projectStore.currentQuotas !== null &&
            this.projectStore.currentProjectRoles !== null &&
            this.projectStore.roles !== null &&
            this.projectStore.roles !== undefined &&
            this.resourceStore.resourceTypes !== null
          );
        },
      },
    
      created() {
        this.initialize();
      },
    
      beforeDestroy() {
        // Set the slug to null in order to hide the project from the sidebar
        if (this.projectStore.currentSlug) {
          this.projectStore.currentSlug = null;
        }
      },
    
      methods: {
        async initialize() {
          await this.apiFetch(this.$router.currentRoute);
        },
    
        async apiFetch(route: Route) {
          // Project may be unset (e.g. when entering from a direct link)
          await this.projectStore.retrieveUnsetProject(this.project, route);
          // Load All Projects if not present
          if (this.projectStore.allProjects === null) {
            this.projectStore.retrieveAllProjects();
          }
          // Load Resources for the project if not present
          if (this.projectStore.currentResources === null) {
            this.projectStore.retrieveResources(this.project);
          }
          // Load Sub-Projects for the project if not present
          if (this.projectStore.currentSubProjects === null) {
            this.projectStore.retrieveSubProjects(this.project);
          }
          // Load Project Roles for the project if not present
          if (this.projectStore.currentProjectRoles === null) {
            this.projectStore.retrieveProjectRoles(this.project);
          }
          // Load list of all Project Role Types if not present
          if (this.projectStore.roles === null) {
            this.projectStore.retrieveRoles();
          }
          // Load list of Enabled Resource Types if not present
          if (this.resourceStore.resourceTypes === null) {
            await this.resourceStore.retrieveResourceTypes();
          }
        },
      },
    });
    </script>