aboutsummaryrefslogtreecommitdiff
path: root/viewer/src/views/PanelLeft.vue
diff options
context:
space:
mode:
Diffstat (limited to 'viewer/src/views/PanelLeft.vue')
-rw-r--r--viewer/src/views/PanelLeft.vue78
1 files changed, 67 insertions, 11 deletions
diff --git a/viewer/src/views/PanelLeft.vue b/viewer/src/views/PanelLeft.vue
index 16be249..e3821a8 100644
--- a/viewer/src/views/PanelLeft.vue
+++ b/viewer/src/views/PanelLeft.vue
@@ -18,25 +18,81 @@
18--> 18-->
19 19
20<template> 20<template>
21 <div class="flex-column"> 21 <div class="flex-column sidebar">
22 <h1>{{$t('panelLeft.mode')}}</h1> 22 <ld-tag-input
23 <ld-mode-radio /> 23 :search-filters.sync="searchFilters"
24 <h1>{{$t('panelLeft.filters')}}</h1> 24 :tags-index="$galleryStore.tagsIndex"
25 <ld-tag-input /> 25 @onkeyenter-empty="search"
26 <h1>{{$t('panelLeft.propositions')}}</h1> 26 />
27 <ld-proposition /> 27 <ld-command-search @clear="clear" @search="search" />
28 <h1 class="title">{{$t('panelLeft.propositions')}}</h1>
29 <div class="scrollbar no-scroll-x">
30 <ld-proposition
31 v-for="(category) in $galleryStore.tagsCategories"
32 :key="category.tag"
33 :category="$galleryStore.tagsIndex[category.tag]"
34 :show-category="$galleryStore.tagsCategories.length > 1"
35 :search-filters.sync="searchFilters"
36 :tags-index="category.index"
37 :current-tags="currentTags()"
38 />
39 </div>
28 </div> 40 </div>
29</template> 41</template>
30 42
31<script lang="ts"> 43<script lang="ts">
32import { Component, Vue, Prop } from "vue-property-decorator"; 44import { Component, Vue, Prop, Watch } from "vue-property-decorator";
45import { Dictionary, Route } from "vue-router/types/router";
46import Navigation from "@/services/navigation";
47import IndexFactory from "@/services/indexfactory";
33 48
34@Component 49@Component
35export default class PanelLeft extends Vue {} 50export default class PanelLeft extends Vue {
51 searchFilters: Tag.Search[] = [];
52
53 mounted() {
54 this.restoreSearchFilters(this.$route);
55 }
56
57 clear() {
58 this.searchFilters = [];
59 this.search();
60 }
61
62 search() {
63 const lastDirectory = Navigation.getLastDirectory(this.$galleryStore.currentItemPath);
64 this.$router.push({ path: lastDirectory.path, query: this.serializeSearch() }).catch(err => {
65 if (err.name !== "NavigationDuplicated") throw err;
66 });
67 }
68
69 serializeSearch() {
70 let query: Dictionary<null> = {};
71 this.searchFilters.forEach(filter => (query[filter.display] = null));
72 return query;
73 }
74
75 currentTags() {
76 return this.$galleryStore.currentItem?.tags ?? [];
77 }
78
79 @Watch("$route")
80 restoreSearchFilters(route: Route) {
81 const query = Object.keys(route.query);
82 if (query.length > 0) this.$galleryStore.search(query).then(search => (this.searchFilters = [...search]));
83 }
84}
36</script> 85</script>
37 86
38<style lang="scss"> 87<style lang="scss">
39.label { 88@import "~@/assets/scss/theme.scss";
40 color: white; 89
90.sidebar {
91 .title {
92 background-color: $proposed-category-bgcolor;
93 padding: 0.2em 0.5em;
94 margin: 0 0 1px 0;
95 font-variant: small-caps;
96 }
41} 97}
42</style> 98</style>