diff options
author | pacien | 2020-05-08 19:28:07 +0200 |
---|---|---|
committer | pacien | 2020-05-08 19:28:07 +0200 |
commit | 34bcf9339c86f145442b9edc799416462bf21fc5 (patch) | |
tree | b9b64f4f445b7464ff59eba91ef7e42829f751e5 /viewer/src | |
parent | e02b09f405c81fd3eb612b0bb1f78f5860b0a5e8 (diff) | |
download | ldgallery-34bcf9339c86f145442b9edc799416462bf21fc5.tar.gz |
viewer/GalleryNavigation: revert to static template component dispatching
We'll see for dynamic component loading later.
Diffstat (limited to 'viewer/src')
-rw-r--r-- | viewer/src/services/navigation.ts | 4 | ||||
-rw-r--r-- | viewer/src/views/GalleryNavigation.vue | 28 |
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"> |
28 | import { Component, Vue, Prop, Watch } from "vue-property-decorator"; | 32 | import { Component, Vue, Prop, Watch } from "vue-property-decorator"; |
33 | import Navigation from "@/services/navigation"; | ||
29 | import GalleryDirectory from "./GalleryDirectory.vue"; | 34 | import GalleryDirectory from "./GalleryDirectory.vue"; |
30 | import GallerySearch from "@/views/GallerySearch.vue"; | 35 | import 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> |