Skip to content
Snippets Groups Projects
Select Git revision
  • uiv2
  • master default protected
  • gitkeep
  • Issue/2463-newCoscinePIDTypes
  • dev protected
  • Issue/2309-docs
  • Issue/2259-updatePids
  • Issue/1321-pidEnquiryOverhaul
  • Issue/2158-emailServicedesk
  • Hotfix/2130-uiv2ContactChange
  • Hotfix/2087-efNet6
  • Issue/1910-MigrationtoNET6.0
  • Issue/1971-projectEditCreateMigration
  • Issue/1980-userManagement
  • Sprint/2022-01
  • Sprint/2021-2022
  • Issue/1741-semanticSearchActions
  • Sprint/2021-23
  • Issue/1746-ApplicationProfileStoringMethod
  • Hotfix/1466-projectCreationTimeout
  • v3.3.2
  • v3.3.1
  • v3.3.0
  • v3.2.0
  • v3.1.0
  • v3.0.0
  • v2.4.1
  • v2.4.0
  • v2.3.0
  • v2.2.0
  • v2.1.1
  • v2.1.0
  • v2.0.0
  • v1.18.0
  • v1.17.1
  • v1.17.0
  • v1.16.0
  • v1.15.1
  • v1.15.0
  • v1.14.0
40 results

README.md

Blame
  • Code owners
    Assign users and groups as approvers for specific file changes. Learn more.
    To learn more about this project, read the wiki.
    ProjectModule.vue 3.15 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.currentResourceTypesQuotas !== null &&
            this.projectStore.currentProjectRoles !== null &&
            this.projectStore.roles !== null &&
            this.projectStore.roles !== undefined &&
            this.resourceStore.enabledResourceTypes !== 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) {
            await this.projectStore.retrieveProjectRoles(this.project);
          }
          // Load list of all Project Role Types if not present
          if (this.projectStore.roles === null) {
            await this.projectStore.retrieveRoles();
          }
    
          // Load Invitations for the project if not present
          if (
            this.projectStore.currentInvitations === null &&
            this.projectStore.currentUserRoleIsOwner
          ) {
            this.projectStore.retrieveInvitations(this.project);
          }
          await this.resourceStore.retrieveEnabledResourceTypes(this.project);
        },
      },
    });
    </script>