aboutsummaryrefslogtreecommitdiff
path: root/viewer
diff options
context:
space:
mode:
Diffstat (limited to 'viewer')
-rw-r--r--viewer/src/services/navigation.ts4
-rw-r--r--viewer/src/views/GalleryNavigation.vue28
2 files changed, 10 insertions, 22 deletions
diff --git a/viewer/src/services/navigation.ts b/viewer/src/services/navigation.ts
index fa17990..aa7ef5e 100644
--- a/viewer/src/services/navigation.ts
+++ b/viewer/src/services/navigation.ts
@@ -40,8 +40,8 @@ export default class Navigation {
40 } 40 }
41 41
42 // Checks if the type of an item matches 42 // Checks if the type of an item matches
43 public static checkType(item: Gallery.Item | null, type: Gallery.ItemType): boolean { 43 public static checkType(item: Gallery.Item | null, type: Gallery.ItemType | null): boolean {
44 return item?.properties.type === type ?? false; 44 return item?.properties.type === type;
45 } 45 }
46 46
47 public static getLastDirectory(itemPath: Gallery.Item[]): Gallery.Directory { 47 public static getLastDirectory(itemPath: Gallery.Item[]): Gallery.Directory {
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 @@
20<template> 20<template>
21 <!-- TODO: eliminate intermediate div --> 21 <!-- TODO: eliminate intermediate div -->
22 <div> 22 <div>
23 <component :is="dispatch().component" v-bind="dispatch().properties" /> 23 <ld-error v-if="checkType(null)" icon="folder-open" :message="$t('gallery.unknown-resource')" />
24 <gallery-search v-else-if="checkType('directory') && query.length > 0" :path="path" />
25 <gallery-directory v-else-if="checkType('directory')" :directory="$galleryStore.currentItem" />
26 <ld-picture v-else-if="checkType('picture')" :picture="$galleryStore.currentItem" />
27 <ld-download v-else :item="$galleryStore.currentItem" />
24 </div> 28 </div>
25</template> 29</template>
26 30
27<script lang="ts"> 31<script lang="ts">
28import { Component, Vue, Prop, Watch } from "vue-property-decorator"; 32import { Component, Vue, Prop, Watch } from "vue-property-decorator";
33import Navigation from "@/services/navigation";
29import GalleryDirectory from "./GalleryDirectory.vue"; 34import GalleryDirectory from "./GalleryDirectory.vue";
30import GallerySearch from "@/views/GallerySearch.vue"; 35import GallerySearch from "@/views/GallerySearch.vue";
31 36
@@ -48,25 +53,8 @@ export default class GalleryNavigation extends Vue {
48 this.$galleryStore.setCurrentPath(this.path); 53 this.$galleryStore.setCurrentPath(this.path);
49 } 54 }
50 55
51 dispatch(): { component: string, properties: {} } { 56 checkType(type: Gallery.ItemType | null): boolean {
52 switch (this.$galleryStore.currentItem?.properties.type ?? null) { 57 return Navigation.checkType(this.$galleryStore.currentItem, type);
53 case null:
54 return {
55 component: "ld-error",
56 properties: { icon: "folder-open", message: this.$t("gallery.unknown-resource") }
57 };
58
59 case "directory":
60 return this.query.length > 0
61 ? { component: "gallery-search", properties: { path: this.path } }
62 : { component: "gallery-directory", properties: { directory: this.$galleryStore.currentItem } };
63
64 case "picture":
65 return { component: "ld-picture", properties: { picture: this.$galleryStore.currentItem } };
66
67 default:
68 return { component: "ld-download", properties: { item: this.$galleryStore.currentItem } };
69 }
70 } 58 }
71} 59}
72</script> 60</script>