aboutsummaryrefslogtreecommitdiff
path: root/viewer/src/views/GallerySearch.vue
diff options
context:
space:
mode:
Diffstat (limited to 'viewer/src/views/GallerySearch.vue')
-rw-r--r--viewer/src/views/GallerySearch.vue72
1 files changed, 34 insertions, 38 deletions
diff --git a/viewer/src/views/GallerySearch.vue b/viewer/src/views/GallerySearch.vue
index e75a37e..d148b9c 100644
--- a/viewer/src/views/GallerySearch.vue
+++ b/viewer/src/views/GallerySearch.vue
@@ -1,7 +1,7 @@
1<!-- ldgallery - A static generator which turns a collection of tagged 1<!-- ldgallery - A static generator which turns a collection of tagged
2-- pictures into a searchable web gallery. 2-- pictures into a searchable web gallery.
3-- 3--
4-- Copyright (C) 2019-2020 Guillaume FOUET 4-- Copyright (C) 2019-2022 Guillaume FOUET
5-- 5--
6-- This program is free software: you can redistribute it and/or modify 6-- This program is free software: you can redistribute it and/or modify
7-- it under the terms of the GNU Affero General Public License as 7-- it under the terms of the GNU Affero General Public License as
@@ -18,43 +18,39 @@
18--> 18-->
19 19
20<template> 20<template>
21 <ld-gallery :items="items()" :noresult="noResult()" /> 21 <GalleryTiles
22 :items="items.filteredByPath"
23 :noresult-message="noResult"
24 />
22</template> 25</template>
23 26
24<script lang="ts"> 27<script setup lang="ts">
25import { Component, Vue, Prop } from "vue-property-decorator"; 28import { useIndexSearch } from '@/services/indexSearch';
26import { Operation } from "@/@types/Operation"; 29import { useGalleryStore } from '@/store/galleryStore';
27import IndexSearch from "@/services/indexsearch"; 30import { useUiStore } from '@/store/uiStore';
28 31import { computed, onUnmounted } from 'vue';
29@Component 32import { useI18n } from 'vue-i18n';
30export default class GalleryPicture extends Vue { 33import GalleryTiles from './GalleryTiles.vue';
31 @Prop(String) readonly path!: string; 34
32 35const { t } = useI18n();
33 otherCount: Number = 0; 36const uiStore = useUiStore();
34 37const galleryStore = useGalleryStore();
35 mounted() { 38const indexSearch = useIndexSearch();
36 this.$uiStore.toggleFullscreen(false); 39
37 this.$uiStore.toggleSearchMode(true); 40uiStore.toggleFullscreen(false);
38 } 41uiStore.searchMode = true;
39 42onUnmounted(() => {
40 destroyed() { 43 uiStore.searchMode = false;
41 this.$uiStore.toggleSearchMode(false); 44 galleryStore.currentSearch = [];
42 this.$galleryStore.setCurrentSearch([]); 45});
43 } 46
44 47const items = computed(() => {
45 items() { 48 const { currentPath, currentSearch } = galleryStore;
46 const searchResult = IndexSearch.search(this.$galleryStore.currentSearch); 49 if (!currentPath) return { searchResult: [], filteredByPath: [] };
47 const filteredByPath = searchResult.filter(item => item.path.startsWith(this.path)); 50 const searchResult = indexSearch(currentSearch);
48 this.otherCount = searchResult.length - filteredByPath.length; 51 const filteredByPath = searchResult.filter(item => item.path.startsWith(currentPath));
49 return filteredByPath; 52 return { searchResult, filteredByPath };
50 } 53});
51 54const otherCount = computed(() => items.value.searchResult.length - items.value.filteredByPath.length);
52 noResult() { 55const noResult = computed(() => t('search.no-result-fmt', [otherCount.value]));
53 const params = [this.otherCount, this.otherCount > 1 ? "s" : ""];
54 return this.$t("search.no-results.otherfolders", params);
55 }
56}
57</script> 56</script>
58
59<style lang="scss">
60</style>