From 4641f35baebd618ec51fa549adf64670c31c647f Mon Sep 17 00:00:00 2001
From: Zero~Informatique
Date: Thu, 27 Feb 2020 17:42:24 +0100
Subject: viewer: added a count of results found in other folders when
 no-results are found

---
 viewer/src/views/GallerySearch.vue | 13 +++++++++++--
 1 file changed, 11 insertions(+), 2 deletions(-)

(limited to 'viewer/src/views/GallerySearch.vue')

diff --git a/viewer/src/views/GallerySearch.vue b/viewer/src/views/GallerySearch.vue
index 4b6dd7f..9f2ac17 100644
--- a/viewer/src/views/GallerySearch.vue
+++ b/viewer/src/views/GallerySearch.vue
@@ -18,7 +18,7 @@
 -->
 
 <template>
-  <ld-gallery :items="items()" :noresult="$t('search.no-results')" />
+  <ld-gallery :items="items()" :noresult="noResult()" />
 </template>
 
 <script lang="ts">
@@ -30,6 +30,8 @@ import IndexSearch from "@/services/indexsearch";
 export default class GalleryPicture extends Vue {
   @Prop(String) readonly path!: string;
 
+  otherCount: Number = 0;
+
   mounted() {
     this.$uiStore.fullscreen = false;
     this.$uiStore.searchMode = true;
@@ -40,7 +42,14 @@ export default class GalleryPicture extends Vue {
   }
 
   items() {
-    return IndexSearch.search(this.$galleryStore.currentSearch, this.path);
+    const searchResult = IndexSearch.search(this.$galleryStore.currentSearch);
+    const filteredByPath = searchResult.filter(item => item.path.startsWith(this.path));
+    this.otherCount = searchResult.length - filteredByPath.length;
+    return filteredByPath;
+  }
+
+  noResult() {
+    return `${this.$t("search.no-results")} • ${this.otherCount} ${this.$t("search.no-results.otherfolders")}`;
   }
 }
 </script>
-- 
cgit v1.2.3

