Przeglądaj źródła

adapt structure details page to be shown without parent

Olivier Massot 4 lat temu
rodzic
commit
6e13cee777
1 zmienionych plików z 3 dodań i 10 usunięć
  1. 3 10
      pages/structures/_id.vue

+ 3 - 10
pages/structures/_id.vue

@@ -3,6 +3,7 @@
     <header class="mb-4">
       <v-layout>
         <v-btn
+          v-if="parent"
           :to="{path: '/structures', query: { parent: parent, view: view, theme: theme }}"
           nuxt
           plain
@@ -165,7 +166,7 @@
               </td>
               <td class="network">
                 <NuxtLink
-                  v-if="structure.n1Id !== parent"
+                  v-if="parent && (structure.n1Id !== parent)"
                   class="neutral"
                   :to="{path: '/structures/' + structure.n1Id, query: { parent: parent, view: view, theme: theme }}"
                   nuxt
@@ -221,14 +222,6 @@ import parsePhoneNumber from 'libphonenumber-js'
 import StructuresProvider from '~/services/data/StructuresProvider'
 
 export default Vue.extend({
-  validate ({ query }) {
-    if (!/^\d+$/.test(query.parent as string ?? '')) {
-      // eslint-disable-next-line no-console
-      console.error('Missing parameter: parent')
-      return false
-    }
-    return true
-  },
   async asyncData ({
     params, $axios
   }): Promise<{ structure: Structure }> {
@@ -238,7 +231,7 @@ export default Vue.extend({
   },
   data (): object {
     return {
-      parent: parseInt(this.$route.query.parent as string),
+      parent: this.$route.query.parent ? parseInt(this.$route.query.parent as string) : null,
       view: this.$route.query.view ?? 'map',
       theme: this.$route.query.theme ?? 'orange',
       showTel: false,