From 76af6cffce939ef3c9a0952e6f7adc234e92f782 Mon Sep 17 00:00:00 2001 From: Zero~Informatique Date: Thu, 30 Jan 2020 17:04:09 +0100 Subject: viewer: directories first and sorted by title in the navigation mode --- viewer/src/@types/gallery/index.d.ts | 9 ++- viewer/src/router/index.ts | 2 +- viewer/src/tools.ts | 17 ++++++ viewer/src/views/Gallery.vue | 104 -------------------------------- viewer/src/views/GalleryDirectory.vue | 8 ++- viewer/src/views/MainGallery.vue | 108 ++++++++++++++++++++++++++++++++++ 6 files changed, 141 insertions(+), 107 deletions(-) delete mode 100644 viewer/src/views/Gallery.vue create mode 100644 viewer/src/views/MainGallery.vue (limited to 'viewer') diff --git a/viewer/src/@types/gallery/index.d.ts b/viewer/src/@types/gallery/index.d.ts index 25407e8..b112b6d 100644 --- a/viewer/src/@types/gallery/index.d.ts +++ b/viewer/src/@types/gallery/index.d.ts @@ -18,6 +18,9 @@ */ declare namespace Gallery { + interface Other extends Item { + properties: OtherProperties, + } interface Picture extends Item { properties: PictureProperties, } @@ -31,7 +34,10 @@ declare namespace Gallery { tags: RawTag[], path: string, thumbnail?: string, - properties: PictureProperties | DirectoryProperties, + properties: OtherProperties | PictureProperties | DirectoryProperties, + } + interface OtherProperties { + type: "other", } interface PictureProperties { type: "picture", @@ -42,4 +48,5 @@ declare namespace Gallery { items: Item[] } type RawTag = string; + type ItemType = "other" | "picture" | "directory"; } \ No newline at end of file diff --git a/viewer/src/router/index.ts b/viewer/src/router/index.ts index 55b4b6c..0f3d2c7 100644 --- a/viewer/src/router/index.ts +++ b/viewer/src/router/index.ts @@ -19,7 +19,7 @@ import Vue from "vue"; import VueRouter from "vue-router"; -import Gallery from "@/views/Gallery.vue"; +import Gallery from "@/views/MainGallery.vue"; Vue.use(VueRouter); diff --git a/viewer/src/tools.ts b/viewer/src/tools.ts index 5eb287e..57a889d 100644 --- a/viewer/src/tools.ts +++ b/viewer/src/tools.ts @@ -27,4 +27,21 @@ export default class Tools { .toLowerCase(); } + + public static checkType(item: Gallery.Item | null, type: Gallery.ItemType): boolean { + return item?.properties.type === type ?? false; + } + + public static directoriesFirst(items: Gallery.Item[]) { + return [ + ...items + .filter(child => Tools.checkType(child, "directory")) + .sort((a, b) => a.title.localeCompare(b.title)), + + ...items + .filter(child => !Tools.checkType(child, "directory")), + ]; + } + + } \ No newline at end of file diff --git a/viewer/src/views/Gallery.vue b/viewer/src/views/Gallery.vue deleted file mode 100644 index fad7cc3..0000000 --- a/viewer/src/views/Gallery.vue +++ /dev/null @@ -1,104 +0,0 @@ - - - - - - - diff --git a/viewer/src/views/GalleryDirectory.vue b/viewer/src/views/GalleryDirectory.vue index 1df0c4d..d01032d 100644 --- a/viewer/src/views/GalleryDirectory.vue +++ b/viewer/src/views/GalleryDirectory.vue @@ -19,7 +19,7 @@