Browse Source

fix navigation

Olivier Massot 2 years ago
parent
commit
cd1a8dab89

+ 1 - 3
pages/parameters/cycles/[id].vue

@@ -4,7 +4,7 @@
       <h2>{{ $t('cycle') }}</h2>
       <h2>{{ $t('cycle') }}</h2>
       <UiFormEdition
       <UiFormEdition
           :model="Cycle"
           :model="Cycle"
-          :go-back-route="goBackRoute"
+          go-back-route="/parameters/teaching"
       >
       >
         <template v-slot="{ entity }">
         <template v-slot="{ entity }">
           <UiInputText
           <UiInputText
@@ -23,8 +23,6 @@ import Cycle from "~/models/Education/Cycle";
 
 
 const i18n = useI18n()
 const i18n = useI18n()
 
 
-const goBackRoute = { path: `/parameters`, query: { tab: 'teaching' } }
-
 const rules = () => [
 const rules = () => [
   (label: string | null) => (label !== null && label.length > 0) || i18n.t('please_enter_a_value'),
   (label: string | null) => (label !== null && label.length > 0) || i18n.t('please_enter_a_value'),
 ]
 ]

+ 0 - 10
pages/parameters/cycles/index.vue

@@ -1,10 +0,0 @@
-<template>
-</template>
-
-<script setup lang="ts">
-/** Redirect to /parameters?tab=teaching */
-const router = useRouter()
-router.push(
-    { path: `/parameters`, query: { tab: 'teaching' } }
-)
-</script>

+ 0 - 100
pages/parameters/education_timings.vue

@@ -1,100 +0,0 @@
-<template>
-  <LayoutContainer>
-    <UiLoadingPanel v-if="pending" />
-    <div v-else>
-      <v-table>
-        <thead>
-          <tr>
-            <td>{{ $t('educationTimings') }}</td>
-            <td></td>
-          </tr>
-        </thead>
-        <tbody>
-          <tr v-if="educationTimings.length > 0" v-for="timing in educationTimings" :key="timing.id">
-            <td class="cycle-editable-cell">
-              {{ timing.timing }}
-            </td>
-            <td class="d-flex flex-row">
-              <v-btn
-                  :flat="true"
-                  icon="fa fa-pen"
-                  class="cycle-edit-icon mr-3"
-                  @click="goToEditPage(timing.id as number)"
-              />
-              <UiButtonDelete
-                  :model="EducationTiming"
-                  :entity="timing"
-                  :flat="true"
-                  class="cycle-edit-icon"
-              />
-            </td>
-          </tr>
-          <tr v-else class="theme-neutral">
-            <td><i>{{ $t('nothing_to_show')}}</i></td>
-            <td></td>
-          </tr>
-        </tbody>
-      </v-table>
-      <v-btn
-          :flat="true"
-          prepend-icon="fa fa-plus"
-          class="theme-primary mt-4"
-          @click="goToCreatePage"
-      >
-        {{ $t('add') }}
-      </v-btn>
-    </div>
-  </LayoutContainer>
-
-</template>
-
-<script setup lang="ts">
-import { useEntityFetch } from '~/composables/data/useEntityFetch'
-import EducationTiming from '~/models/Education/EducationTiming'
-import { useRepo } from 'pinia-orm'
-import EducationTimingsRepository from '~/stores/repositories/EducationTimingsRepository'
-import type {ComputedRef} from "vue";
-import {useOrganizationProfileStore} from "~/stores/organizationProfile";
-import UrlUtils from "~/services/utils/urlUtils";
-
-const organizationProfile = useOrganizationProfileStore()
-
-if (organizationProfile.parametersId === null) {
-  throw new Error('Missing organization parameters id')
-}
-
-const { fetch, fetchCollection } = useEntityFetch()
-
-const { pending } = fetchCollection(EducationTiming)
-
-const educationTimingRepo = useRepo(EducationTimingsRepository)
-
-/**
- * On récupère les timings via le store
- * (sans ça, les mises à jour SSE ne seront pas prises en compte)
- */
-const educationTimings: ComputedRef<Array<EducationTiming>> = computed(() => {
-  return educationTimingRepo.getEducationTimings()
-})
-
-const goToEditPage = (id: number) => {
-  navigateTo(UrlUtils.join('/parameters/education_timings', id))
-}
-
-const goToCreatePage = () => {
-  navigateTo('/parameters/education_timings/new')
-}
-</script>
-
-<style scoped lang="scss">
-.v-table {
-  width: 100%;
-  max-width: 800px;
-}
-
-// TODO: voir à factoriser ces styles, ptêt en faisant un component de ces boutons?
-:deep(.cycle-edit-icon .v-icon) {
-  color: rgb(var(--v-theme-primary));
-  font-size: 18px;
-}
-</style>

+ 1 - 3
pages/parameters/education_timings/[id].vue

@@ -4,7 +4,7 @@
       <h2>{{ $t('educationTiming') }}</h2>
       <h2>{{ $t('educationTiming') }}</h2>
       <UiFormEdition
       <UiFormEdition
         :model="EducationTiming"
         :model="EducationTiming"
-        :go-back-route="goBackRoute"
+        go-back-route="/parameters/education_timings"
       >
       >
         <template v-slot="{ entity }">
         <template v-slot="{ entity }">
           <UiInputNumber
           <UiInputNumber
@@ -24,8 +24,6 @@ import { useI18n } from 'vue-i18n'
 
 
 const i18n = useI18n()
 const i18n = useI18n()
 
 
-const goBackRoute: RouteLocationPathRaw = { path: `/parameters`, query: { tab: 'educationTimings' } }
-
 const rules = () => [
 const rules = () => [
   (timing: string | null) =>
   (timing: string | null) =>
     (timing !== null && parseInt(timing) > 0) || i18n.t('please_enter_a_value'),
     (timing !== null && parseInt(timing) > 0) || i18n.t('please_enter_a_value'),

+ 95 - 5
pages/parameters/education_timings/index.vue

@@ -1,10 +1,100 @@
 <template>
 <template>
+  <LayoutContainer>
+    <UiLoadingPanel v-if="pending" />
+    <div v-else>
+      <v-table>
+        <thead>
+          <tr>
+            <td>{{ $t('educationTimings') }}</td>
+            <td></td>
+          </tr>
+        </thead>
+        <tbody>
+          <tr v-if="educationTimings.length > 0" v-for="timing in educationTimings" :key="timing.id">
+            <td class="cycle-editable-cell">
+              {{ timing.timing }}
+            </td>
+            <td class="d-flex flex-row">
+              <v-btn
+                  :flat="true"
+                  icon="fa fa-pen"
+                  class="cycle-edit-icon mr-3"
+                  @click="goToEditPage(timing.id as number)"
+              />
+              <UiButtonDelete
+                  :model="EducationTiming"
+                  :entity="timing"
+                  :flat="true"
+                  class="cycle-edit-icon"
+              />
+            </td>
+          </tr>
+          <tr v-else class="theme-neutral">
+            <td><i>{{ $t('nothing_to_show')}}</i></td>
+            <td></td>
+          </tr>
+        </tbody>
+      </v-table>
+      <v-btn
+          :flat="true"
+          prepend-icon="fa fa-plus"
+          class="theme-primary mt-4"
+          @click="goToCreatePage"
+      >
+        {{ $t('add') }}
+      </v-btn>
+    </div>
+  </LayoutContainer>
+
 </template>
 </template>
 
 
 <script setup lang="ts">
 <script setup lang="ts">
-/** Redirect to /parameters?tab=educationTimings */
-const router = useRouter()
-router.push(
-    { path: `/parameters`, query: { tab: 'educationTimings' } }
-)
+import { useEntityFetch } from '~/composables/data/useEntityFetch'
+import EducationTiming from '~/models/Education/EducationTiming'
+import { useRepo } from 'pinia-orm'
+import EducationTimingsRepository from '~/stores/repositories/EducationTimingsRepository'
+import type {ComputedRef} from "vue";
+import {useOrganizationProfileStore} from "~/stores/organizationProfile";
+import UrlUtils from "~/services/utils/urlUtils";
+
+const organizationProfile = useOrganizationProfileStore()
+
+if (organizationProfile.parametersId === null) {
+  throw new Error('Missing organization parameters id')
+}
+
+const { fetch, fetchCollection } = useEntityFetch()
+
+const { pending } = fetchCollection(EducationTiming)
+
+const educationTimingRepo = useRepo(EducationTimingsRepository)
+
+/**
+ * On récupère les timings via le store
+ * (sans ça, les mises à jour SSE ne seront pas prises en compte)
+ */
+const educationTimings: ComputedRef<Array<EducationTiming>> = computed(() => {
+  return educationTimingRepo.getEducationTimings()
+})
+
+const goToEditPage = (id: number) => {
+  navigateTo(UrlUtils.join('/parameters/education_timings', id))
+}
+
+const goToCreatePage = () => {
+  navigateTo('/parameters/education_timings/new')
+}
 </script>
 </script>
+
+<style scoped lang="scss">
+.v-table {
+  width: 100%;
+  max-width: 800px;
+}
+
+// TODO: voir à factoriser ces styles, ptêt en faisant un component de ces boutons?
+:deep(.cycle-edit-icon .v-icon) {
+  color: rgb(var(--v-theme-primary));
+  font-size: 18px;
+}
+</style>

+ 1 - 3
pages/parameters/education_timings/new.vue

@@ -4,7 +4,7 @@
       <h2>{{ $t("new_education_timing")}}</h2>
       <h2>{{ $t("new_education_timing")}}</h2>
       <UiFormCreation
       <UiFormCreation
         :model="EducationTiming"
         :model="EducationTiming"
-        :go-back-route="goBackRoute"
+        go-back-route="/parameters/education_timings"
       >
       >
         <template v-slot="{ entity }">
         <template v-slot="{ entity }">
           <v-container :fluid="true" class="container">
           <v-container :fluid="true" class="container">
@@ -33,8 +33,6 @@ import { useI18n } from 'vue-i18n'
 
 
 const i18n = useI18n()
 const i18n = useI18n()
 
 
-const goBackRoute = { path: `/parameters`, query: { tab: 'educationTimings' } }
-
 const rules = () => [
 const rules = () => [
   (timing: number | null ) =>
   (timing: number | null ) =>
     (timing !== null && timing > 0) || i18n.t('please_enter_a_value'),
     (timing !== null && timing > 0) || i18n.t('please_enter_a_value'),

+ 0 - 99
pages/parameters/residence_areas.vue

@@ -1,99 +0,0 @@
-<template>
-  <LayoutContainer>
-    <UiLoadingPanel v-if="pending" />
-    <div v-else>
-      <v-table>
-        <thead>
-          <tr>
-            <td>{{ $t('residenceAreas') }}</td>
-            <td></td>
-          </tr>
-        </thead>
-        <tbody>
-        <tr
-            v-if="residenceAreas.length > 0"
-            v-for="residenceArea in residenceAreas"
-            :key="residenceArea.id ?? undefined"
-        >
-          <td class="cycle-editable-cell">
-            {{ residenceArea.label }}
-          </td>
-          <td class="d-flex flex-row">
-            <v-btn
-                :flat="true"
-                icon="fa fa-pen"
-                class="cycle-edit-icon mr-3"
-                @click="goToEditPage(residenceArea.id as number)"
-            />
-            <UiButtonDelete
-                :model="ResidenceArea"
-                :entity="residenceArea"
-                :flat="true"
-                class="cycle-edit-icon"
-            />
-          </td>
-        </tr>
-        <tr v-else class="theme-neutral">
-          <td><i>{{ $t('nothing_to_show')}}</i></td>
-          <td></td>
-        </tr>
-        </tbody>
-      </v-table>
-
-      <v-btn
-          :flat="true"
-          prepend-icon="fa fa-plus"
-          class="theme-primary mt-4"
-          @click="goToCreatePage"
-      >
-        {{ $t('add') }}
-      </v-btn>
-    </div>
-  </LayoutContainer>
-</template>
-
-<script setup lang="ts">
-import { useEntityFetch } from '~/composables/data/useEntityFetch'
-import ResidenceArea from '~/models/Billing/ResidenceArea'
-import { useRepo } from 'pinia-orm'
-import ResidenceAreasRepository from '~/stores/repositories/ResidenceAreasRepository'
-import { useRouter } from 'vue-router'
-import UrlUtils from "~/services/utils/urlUtils";
-
-const residenceAreasRepo = useRepo(ResidenceAreasRepository)
-
-const router = useRouter()
-const { fetchCollection } = useEntityFetch()
-const i18n = useI18n()
-
-const { pending } = fetchCollection(ResidenceArea)
-
-/**
- * On récupère les Residence Area via le store
- * (sans ça, les mises à jour SSE ne seront pas prises en compte)
- */
- const residenceAreas: ComputedRef<Array<ResidenceArea>> = computed(() => {
-  return residenceAreasRepo.getResidenceAreas()
-})
-
-const goToEditPage = (id: number) => {
-  navigateTo(UrlUtils.join('/parameters/residence_areas', id))
-}
-
-const goToCreatePage = () => {
-  navigateTo(`/parameters/residence_areas/new`)
-}
-</script>
-
-<style scoped lang="scss">
-.v-table {
-  width: 100%;
-  max-width: 800px;
-}
-
-// TODO: voir à factoriser ces styles, ptêt en faisant un component de ces boutons?
-:deep(.cycle-edit-icon .v-icon) {
-  color: rgb(var(--v-theme-primary));
-  font-size: 18px;
-}
-</style>

+ 1 - 5
pages/parameters/residence_areas/[id].vue

@@ -4,7 +4,7 @@
       <h2>Éditer la zone de résidence</h2>
       <h2>Éditer la zone de résidence</h2>
       <UiFormEdition
       <UiFormEdition
         :model="ResidenceArea"
         :model="ResidenceArea"
-        :go-back-route="goBackRoute"
+        go-back-route="/parameters/residence_areas"
       >
       >
         <template v-slot="{ entity }">
         <template v-slot="{ entity }">
           <UiInputText
           <UiInputText
@@ -24,10 +24,6 @@ import ResidenceArea from '~/models/Billing/ResidenceArea'
 import { useI18n } from 'vue-i18n'
 import { useI18n } from 'vue-i18n'
 
 
 const i18n = useI18n()
 const i18n = useI18n()
-const { fetch } = useEntityFetch()
-const router = useRouter()
-
-const goBackRoute = { path: `/parameters`, query: { tab: 'residenceAreas' } }
 
 
 const rules = () => [
 const rules = () => [
   (label: string | null) =>
   (label: string | null) =>

+ 93 - 4
pages/parameters/residence_areas/index.vue

@@ -1,10 +1,99 @@
 <template>
 <template>
+  <LayoutContainer>
+    <UiLoadingPanel v-if="pending" />
+    <div v-else>
+      <v-table>
+        <thead>
+          <tr>
+            <td>{{ $t('residenceAreas') }}</td>
+            <td></td>
+          </tr>
+        </thead>
+        <tbody>
+        <tr
+            v-if="residenceAreas.length > 0"
+            v-for="residenceArea in residenceAreas"
+            :key="residenceArea.id ?? undefined"
+        >
+          <td class="cycle-editable-cell">
+            {{ residenceArea.label }}
+          </td>
+          <td class="d-flex flex-row">
+            <v-btn
+                :flat="true"
+                icon="fa fa-pen"
+                class="cycle-edit-icon mr-3"
+                @click="goToEditPage(residenceArea.id as number)"
+            />
+            <UiButtonDelete
+                :model="ResidenceArea"
+                :entity="residenceArea"
+                :flat="true"
+                class="cycle-edit-icon"
+            />
+          </td>
+        </tr>
+        <tr v-else class="theme-neutral">
+          <td><i>{{ $t('nothing_to_show')}}</i></td>
+          <td></td>
+        </tr>
+        </tbody>
+      </v-table>
+
+      <v-btn
+          :flat="true"
+          prepend-icon="fa fa-plus"
+          class="theme-primary mt-4"
+          @click="goToCreatePage"
+      >
+        {{ $t('add') }}
+      </v-btn>
+    </div>
+  </LayoutContainer>
 </template>
 </template>
 
 
 <script setup lang="ts">
 <script setup lang="ts">
-/** Redirect to /parameters?tab=residenceAreas */
+import { useEntityFetch } from '~/composables/data/useEntityFetch'
+import ResidenceArea from '~/models/Billing/ResidenceArea'
+import { useRepo } from 'pinia-orm'
+import ResidenceAreasRepository from '~/stores/repositories/ResidenceAreasRepository'
+import { useRouter } from 'vue-router'
+import UrlUtils from "~/services/utils/urlUtils";
+
+const residenceAreasRepo = useRepo(ResidenceAreasRepository)
+
 const router = useRouter()
 const router = useRouter()
-router.push(
-    { path: `/parameters`, query: { tab: 'residenceAreas' } }
-)
+const { fetchCollection } = useEntityFetch()
+const i18n = useI18n()
+
+const { pending } = fetchCollection(ResidenceArea)
+
+/**
+ * On récupère les Residence Area via le store
+ * (sans ça, les mises à jour SSE ne seront pas prises en compte)
+ */
+ const residenceAreas: ComputedRef<Array<ResidenceArea>> = computed(() => {
+  return residenceAreasRepo.getResidenceAreas()
+})
+
+const goToEditPage = (id: number) => {
+  navigateTo(UrlUtils.join('/parameters/residence_areas', id))
+}
+
+const goToCreatePage = () => {
+  navigateTo(`/parameters/residence_areas/new`)
+}
 </script>
 </script>
+
+<style scoped lang="scss">
+.v-table {
+  width: 100%;
+  max-width: 800px;
+}
+
+// TODO: voir à factoriser ces styles, ptêt en faisant un component de ces boutons?
+:deep(.cycle-edit-icon .v-icon) {
+  color: rgb(var(--v-theme-primary));
+  font-size: 18px;
+}
+</style>

+ 1 - 3
pages/parameters/residence_areas/new.vue

@@ -4,7 +4,7 @@
       <h2>{{ $t('create_a_new_residence_area') }}</h2>
       <h2>{{ $t('create_a_new_residence_area') }}</h2>
       <UiFormCreation
       <UiFormCreation
         :model="ResidenceArea"
         :model="ResidenceArea"
-        :go-back-route="goBackRoute"
+        go-back-route="/parameters/residence_areas"
       >
       >
         <template v-slot="{ entity }">
         <template v-slot="{ entity }">
           <v-container :fluid="true" class="container">
           <v-container :fluid="true" class="container">
@@ -31,8 +31,6 @@ import { useI18n } from 'vue-i18n'
 
 
 const i18n = useI18n()
 const i18n = useI18n()
 
 
-const goBackRoute = { path: `/parameters`, query: { tab: 'residenceAreas' } }
-
 const rules = () => [
 const rules = () => [
   (label: string | null) =>
   (label: string | null) =>
     (label !== null && label.length > 0) || i18n.t('please_enter_a_value'),
     (label !== null && label.length > 0) || i18n.t('please_enter_a_value'),

+ 1 - 1
pages/parameters/subdomains/[id].vue

@@ -79,7 +79,7 @@
   }
   }
 
 
   const quit = () => {
   const quit = () => {
-    router.push('/parameters?tab=website')
+    router.push('/parameters/website')
     activationPending.value = false
     activationPending.value = false
     pageStore.loading = false
     pageStore.loading = false
   }
   }

+ 0 - 10
pages/parameters/subdomains/index.vue

@@ -1,10 +0,0 @@
-<template>
-</template>
-
-<script setup lang="ts">
-/** Redirect to /parameters?tab=website */
-const router = useRouter()
-router.push(
-    { path: `/parameters`, query: { tab: 'website' } }
-)
-</script>

+ 2 - 4
pages/parameters/subdomains/new.vue

@@ -39,7 +39,7 @@
         </v-container>
         </v-container>
 
 
         <template #form.button>
         <template #form.button>
-          <NuxtLink :to="goBackRoute" class="no-decoration">
+          <NuxtLink to="/parameters/website" class="no-decoration">
             <v-btn class="mr-4 theme-neutral">
             <v-btn class="mr-4 theme-neutral">
               {{ $t('back') }}
               {{ $t('back') }}
             </v-btn>
             </v-btn>
@@ -68,11 +68,9 @@ const { subdomainValidation } = useSubdomainValidation()
 //@ts-ignore
 //@ts-ignore
 const subdomain: Ref<Subdomain> = ref(em.newInstance(Subdomain) as Subdomain)
 const subdomain: Ref<Subdomain> = ref(em.newInstance(Subdomain) as Subdomain)
 
 
-const goBackRoute = { path: `/parameters`, query: { tab: 'website' } }
-
 const submitActions = computed(() => {
 const submitActions = computed(() => {
   let actions: AnyJson = {}
   let actions: AnyJson = {}
-  actions[SUBMIT_TYPE.SAVE_AND_BACK] = goBackRoute
+  actions[SUBMIT_TYPE.SAVE_AND_BACK] = '/parameters/website'
   return actions
   return actions
 })
 })
 
 

+ 1 - 1
pages/parameters/teaching.vue

@@ -95,7 +95,7 @@ const orderedCycles: ComputedRef<AnyJson> = computed(() => {
 
 
 
 
 const goToCycleEditPage = (id: number) => {
 const goToCycleEditPage = (id: number) => {
-  navigateTo(`parameters/cycles/${id}`)
+  navigateTo(`/parameters/cycles/${id}`)
 }
 }
 </script>
 </script>
 
 

+ 1 - 1
pages/parameters/website.vue

@@ -154,7 +154,7 @@ const canAddNewSubdomain: ComputedRef<boolean> = computed(() => subdomains.value
 
 
 const goToEditPage = (id: number) => {
 const goToEditPage = (id: number) => {
   console.log(parameters.value)
   console.log(parameters.value)
-  navigateTo(`parameters/subdomains/${id}`)
+  navigateTo(`/parameters/subdomains/${id}`)
 }
 }
 
 
 const onAddSubdomainClick = () => {
 const onAddSubdomainClick = () => {