aboutsummaryrefslogtreecommitdiff
path: root/viewer/src/components/LdProposition.vue
diff options
context:
space:
mode:
Diffstat (limited to 'viewer/src/components/LdProposition.vue')
-rw-r--r--viewer/src/components/LdProposition.vue52
1 files changed, 45 insertions, 7 deletions
diff --git a/viewer/src/components/LdProposition.vue b/viewer/src/components/LdProposition.vue
index fe3af07..aa44943 100644
--- a/viewer/src/components/LdProposition.vue
+++ b/viewer/src/components/LdProposition.vue
@@ -20,7 +20,7 @@
20 20
21<template> 21<template>
22 <div class="proposition"> 22 <div class="proposition">
23 <h2 v-if="showCategory && proposedTags.length" class="subtitle category">{{title}}</h2> 23 <h2 v-if="showCategory && Object.keys(propositions).length" class="subtitle category">{{ title }}</h2>
24 <div v-for="proposed in proposedTags" :key="proposed.rawTag"> 24 <div v-for="proposed in proposedTags" :key="proposed.rawTag">
25 <a 25 <a
26 class="operation-btns link" 26 class="operation-btns link"
@@ -42,15 +42,19 @@
42 class="operation-tag link" 42 class="operation-tag link"
43 :title="$t('tag-propositions.intersection')" 43 :title="$t('tag-propositions.intersection')"
44 @click="add(Operation.INTERSECTION, proposed.rawTag)" 44 @click="add(Operation.INTERSECTION, proposed.rawTag)"
45 >{{proposed.rawTag}}</a> 45 >{{ proposed.rawTag }}</a
46 >
46 47
47 <div class="disabled" :title="$t('tag-propositions.item-count')">{{proposed.count}}</div> 48 <div class="disabled" :title="$t('tag-propositions.item-count')">{{ proposed.count }}</div>
49 </div>
50 <div v-if="showMoreCount > 0" class="showmore" @click="limit += showMoreCount">
51 {{ $t("tag-propositions.showmore", [showMoreCount]) }}<fa-icon icon="angle-double-down" />
48 </div> 52 </div>
49 </div> 53 </div>
50</template> 54</template>
51 55
52<script lang="ts"> 56<script lang="ts">
53import { Component, Vue, Prop, PropSync } from "vue-property-decorator"; 57import { Component, Vue, Prop, PropSync, Watch } from "vue-property-decorator";
54import { Operation } from "@/@types/Operation"; 58import { Operation } from "@/@types/Operation";
55 59
56@Component 60@Component
@@ -61,12 +65,26 @@ export default class LdProposition extends Vue {
61 @Prop({ required: true }) readonly tagsIndex!: Tag.Index; 65 @Prop({ required: true }) readonly tagsIndex!: Tag.Index;
62 @PropSync("searchFilters", { type: Array, required: true }) model!: Tag.Search[]; 66 @PropSync("searchFilters", { type: Array, required: true }) model!: Tag.Search[];
63 67
68 readonly INITIAL_TAG_DISPLAY_LIMIT = this.getInitialTagDisplayLimit();
69
70 limit: number = this.INITIAL_TAG_DISPLAY_LIMIT;
71
72 getInitialTagDisplayLimit() {
73 const limit = this.$galleryStore.config?.initialTagDisplayLimit ?? 10;
74 return limit >= 0 ? limit : 1000;
75 }
76
77 @Watch("$route")
78 onRouteChange() {
79 this.limit = this.INITIAL_TAG_DISPLAY_LIMIT;
80 }
81
64 get Operation() { 82 get Operation() {
65 return Operation; 83 return Operation;
66 } 84 }
67 85
68 get proposedTags() { 86 get propositions(): Record<string, number> {
69 let propositions: { [index: string]: number } = {}; 87 const propositions: Record<string, number> = {};
70 if (this.model.length > 0) { 88 if (this.model.length > 0) {
71 // Tags count from current search 89 // Tags count from current search
72 this.extractDistinctItems(this.model) 90 this.extractDistinctItems(this.model)
@@ -82,12 +100,20 @@ export default class LdProposition extends Vue {
82 .filter(Boolean) 100 .filter(Boolean)
83 .forEach(tagindex => (propositions[tagindex.tag] = tagindex.items.length)); 101 .forEach(tagindex => (propositions[tagindex.tag] = tagindex.items.length));
84 } 102 }
103 return propositions;
104 }
85 105
86 return Object.entries(propositions) 106 get proposedTags() {
107 return Object.entries(this.propositions)
87 .sort((a, b) => b[1] - a[1]) 108 .sort((a, b) => b[1] - a[1])
109 .slice(0, this.limit)
88 .map(entry => ({ rawTag: entry[0], count: entry[1] })); 110 .map(entry => ({ rawTag: entry[0], count: entry[1] }));
89 } 111 }
90 112
113 get showMoreCount(): number {
114 return Object.keys(this.propositions).length - Object.keys(this.proposedTags).length;
115 }
116
91 get title() { 117 get title() {
92 return this.category?.tag ?? this.$t("panelLeft.propositions.other"); 118 return this.category?.tag ?? this.$t("panelLeft.propositions.other");
93 } 119 }
@@ -137,5 +163,17 @@ export default class LdProposition extends Vue {
137 cursor: pointer; 163 cursor: pointer;
138 } 164 }
139 } 165 }
166 .showmore {
167 display: block;
168 text-align: right;
169 color: $palette-300;
170 cursor: pointer;
171 > svg {
172 margin-left: 10px;
173 }
174 &:hover {
175 color: $link-hover;
176 }
177 }
140} 178}
141</style> 179</style>