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.vue69
1 files changed, 34 insertions, 35 deletions
diff --git a/viewer/src/views/GallerySearch.vue b/viewer/src/views/GallerySearch.vue
index fec7216..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,40 +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 otherCount: number = 0; 35const { t } = useI18n();
33 36const uiStore = useUiStore();
34 mounted() { 37const galleryStore = useGalleryStore();
35 this.$uiStore.toggleFullscreen(false); 38const indexSearch = useIndexSearch();
36 this.$uiStore.toggleSearchMode(true); 39
37 } 40uiStore.toggleFullscreen(false);
38 41uiStore.searchMode = true;
39 destroyed() { 42onUnmounted(() => {
40 this.$uiStore.toggleSearchMode(false); 43 uiStore.searchMode = false;
41 this.$galleryStore.setCurrentSearch([]); 44 galleryStore.currentSearch = [];
42 } 45});
43 46
44 get items() { 47const items = computed(() => {
45 const searchResult = IndexSearch.search(this.$galleryStore.currentSearch); 48 const { currentPath, currentSearch } = galleryStore;
46 const filteredByPath = searchResult.filter(item => item.path.startsWith(this.path)); 49 if (!currentPath) return { searchResult: [], filteredByPath: [] };
47 this.otherCount = searchResult.length - filteredByPath.length; 50 const searchResult = indexSearch(currentSearch);
48 return filteredByPath; 51 const filteredByPath = searchResult.filter(item => item.path.startsWith(currentPath));
49 } 52 return { searchResult, filteredByPath };
50 53});
51 get noResult() { 54const otherCount = computed(() => items.value.searchResult.length - items.value.filteredByPath.length);
52 return this.$tc("search.no-result-fmt", this.otherCount, [this.otherCount]); 55const noResult = computed(() => t('search.no-result-fmt', [otherCount.value]));
53 }
54}
55</script> 56</script>
56
57<style lang="scss"></style>