From 34bcf9339c86f145442b9edc799416462bf21fc5 Mon Sep 17 00:00:00 2001
From: pacien
Date: Fri, 8 May 2020 19:28:07 +0200
Subject: viewer/GalleryNavigation: revert to static template component
 dispatching

We'll see for dynamic component loading later.
---
 viewer/src/views/GalleryNavigation.vue | 28 ++++++++--------------------
 1 file changed, 8 insertions(+), 20 deletions(-)

(limited to 'viewer/src/views/GalleryNavigation.vue')

diff --git a/viewer/src/views/GalleryNavigation.vue b/viewer/src/views/GalleryNavigation.vue
index 2e40409..f36fc8a 100644
--- a/viewer/src/views/GalleryNavigation.vue
+++ b/viewer/src/views/GalleryNavigation.vue
@@ -20,12 +20,17 @@
 <template>
   <!-- TODO: eliminate intermediate div -->
   <div>
-    <component :is="dispatch().component" v-bind="dispatch().properties" />
+    <ld-error v-if="checkType(null)" icon="folder-open" :message="$t('gallery.unknown-resource')" />
+    <gallery-search v-else-if="checkType('directory') && query.length > 0" :path="path" />
+    <gallery-directory v-else-if="checkType('directory')" :directory="$galleryStore.currentItem" />
+    <ld-picture v-else-if="checkType('picture')" :picture="$galleryStore.currentItem" />
+    <ld-download v-else :item="$galleryStore.currentItem" />
   </div>
 </template>
 
 <script lang="ts">
 import { Component, Vue, Prop, Watch } from "vue-property-decorator";
+import Navigation from "@/services/navigation";
 import GalleryDirectory from "./GalleryDirectory.vue";
 import GallerySearch from "@/views/GallerySearch.vue";
 
@@ -48,25 +53,8 @@ export default class GalleryNavigation extends Vue {
     this.$galleryStore.setCurrentPath(this.path);
   }
 
-  dispatch(): { component: string, properties: {} } {
-    switch (this.$galleryStore.currentItem?.properties.type ?? null) {
-      case null:
-        return {
-          component: "ld-error",
-          properties: { icon: "folder-open", message: this.$t("gallery.unknown-resource") }
-        };
-
-      case "directory":
-        return this.query.length > 0
-          ? { component: "gallery-search", properties: { path: this.path } }
-          : { component: "gallery-directory", properties: { directory: this.$galleryStore.currentItem } };
-
-      case "picture":
-        return { component: "ld-picture", properties: { picture: this.$galleryStore.currentItem } };
-
-      default:
-        return { component: "ld-download", properties: { item: this.$galleryStore.currentItem } };
-    }
+  checkType(type: Gallery.ItemType | null): boolean {
+    return Navigation.checkType(this.$galleryStore.currentItem, type);
   }
 }
 </script>
-- 
cgit v1.2.3

