From 4393f8f25025ea600dae30be2d6ad9067496ba40 Mon Sep 17 00:00:00 2001
From: Zero~Informatique
Date: Sat, 20 Jun 2020 06:04:39 +0200
Subject: viewer: component dispatch (no functional change)
a cleaner way to add new components to LdGallery
---
viewer/src/views/GalleryDirectory.vue | 43 ---------------------------------
viewer/src/views/GalleryNavigation.vue | 44 ++++++++++++++++++----------------
2 files changed, 24 insertions(+), 63 deletions(-)
delete mode 100644 viewer/src/views/GalleryDirectory.vue
(limited to 'viewer/src/views')
diff --git a/viewer/src/views/GalleryDirectory.vue b/viewer/src/views/GalleryDirectory.vue
deleted file mode 100644
index bfe484e..0000000
--- a/viewer/src/views/GalleryDirectory.vue
+++ /dev/null
@@ -1,43 +0,0 @@
-
-
-
-
-
-
-
-
-
diff --git a/viewer/src/views/GalleryNavigation.vue b/viewer/src/views/GalleryNavigation.vue
index b141d44..843550f 100644
--- a/viewer/src/views/GalleryNavigation.vue
+++ b/viewer/src/views/GalleryNavigation.vue
@@ -18,23 +18,10 @@
-->
-
-
-
-
-
-
-
-
-
-
+
+
+
@@ -42,12 +29,10 @@
import { Component, Vue, Prop, Watch } from "vue-property-decorator";
import { ItemType } from "@/@types/ItemType";
import Navigation from "@/services/navigation";
-import GalleryDirectory from "./GalleryDirectory.vue";
import GallerySearch from "@/views/GallerySearch.vue";
@Component({
components: {
- GalleryDirectory,
GallerySearch,
},
})
@@ -55,13 +40,32 @@ export default class GalleryNavigation extends Vue {
@Prop(String) readonly path!: string;
@Prop(Array) readonly query!: string[];
- // For the template
- readonly ItemType = Object.freeze(ItemType);
+ readonly COMPONENT_BY_TYPE: Record = {
+ directory: "ld-directory",
+ picture: "ld-picture",
+ plaintext: "ld-plain-text-viewer",
+ pdf: "ld-pdf-viewer",
+ video: "ld-video-viewer",
+ audio: "ld-audio-viewer",
+ other: "ld-download",
+ };
mounted() {
this.pathChanged();
}
+ get isError() {
+ return this.checkType(null);
+ }
+
+ get isSearch() {
+ return this.checkType(ItemType.DIRECTORY) && this.query.length > 0;
+ }
+
+ get componentName() {
+ return this.COMPONENT_BY_TYPE[this.$galleryStore.currentItem?.properties.type ?? ItemType.OTHER];
+ }
+
@Watch("path")
pathChanged() {
this.$galleryStore.setCurrentPath(this.path);
--
cgit v1.2.3