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.vue39
1 files changed, 23 insertions, 16 deletions
diff --git a/viewer/src/components/LdProposition.vue b/viewer/src/components/LdProposition.vue
index aa44943..07b27f5 100644
--- a/viewer/src/components/LdProposition.vue
+++ b/viewer/src/components/LdProposition.vue
@@ -19,11 +19,14 @@
19--> 19-->
20 20
21<template> 21<template>
22 <div class="proposition"> 22 <div :class="$style.proposition">
23 <h2 v-if="showCategory && Object.keys(propositions).length" class="subtitle category">{{ title }}</h2> 23 <h2 v-if="showCategory && Object.keys(propositions).length" :class="[$style.subtitle, $style.category]">
24 {{ title }}
25 </h2>
24 <div v-for="proposed in proposedTags" :key="proposed.rawTag"> 26 <div v-for="proposed in proposedTags" :key="proposed.rawTag">
25 <a 27 <a
26 class="operation-btns link" 28 class="link"
29 :class="$style.operationBtns"
27 :title="$t('tag-propositions.substraction')" 30 :title="$t('tag-propositions.substraction')"
28 @click="add(Operation.SUBSTRACTION, proposed.rawTag)" 31 @click="add(Operation.SUBSTRACTION, proposed.rawTag)"
29 > 32 >
@@ -31,7 +34,8 @@
31 </a> 34 </a>
32 35
33 <a 36 <a
34 class="operation-btns link" 37 class="link"
38 :class="$style.operationBtns"
35 :title="$t('tag-propositions.addition')" 39 :title="$t('tag-propositions.addition')"
36 @click="add(Operation.ADDITION, proposed.rawTag)" 40 @click="add(Operation.ADDITION, proposed.rawTag)"
37 > 41 >
@@ -39,7 +43,8 @@
39 </a> 43 </a>
40 44
41 <a 45 <a
42 class="operation-tag link" 46 class="link"
47 :class="$style.operationTag"
43 :title="$t('tag-propositions.intersection')" 48 :title="$t('tag-propositions.intersection')"
44 @click="add(Operation.INTERSECTION, proposed.rawTag)" 49 @click="add(Operation.INTERSECTION, proposed.rawTag)"
45 >{{ proposed.rawTag }}</a 50 >{{ proposed.rawTag }}</a
@@ -47,23 +52,25 @@
47 52
48 <div class="disabled" :title="$t('tag-propositions.item-count')">{{ proposed.count }}</div> 53 <div class="disabled" :title="$t('tag-propositions.item-count')">{{ proposed.count }}</div>
49 </div> 54 </div>
50 <div v-if="showMoreCount > 0" class="showmore" @click="limit += showMoreCount"> 55 <div v-if="showMoreCount > 0" :class="$style.showmore" @click="limit += showMoreCount">
51 {{ $t("tag-propositions.showmore", [showMoreCount]) }}<fa-icon icon="angle-double-down" /> 56 {{ $t("tag-propositions.showmore", [showMoreCount]) }}<fa-icon icon="angle-double-down" />
52 </div> 57 </div>
53 </div> 58 </div>
54</template> 59</template>
55 60
56<script lang="ts"> 61<script lang="ts">
57import { Component, Vue, Prop, PropSync, Watch } from "vue-property-decorator"; 62import { Item, RawTag } from "@/@types/gallery";
58import { Operation } from "@/@types/Operation"; 63import { Operation } from "@/@types/Operation";
64import { TagIndex, TagNode, TagSearch } from "@/@types/tag";
65import { Component, Prop, PropSync, Vue, Watch } from "vue-property-decorator";
59 66
60@Component 67@Component
61export default class LdProposition extends Vue { 68export default class LdProposition extends Vue {
62 @Prop() readonly category?: Tag.Node; 69 @Prop() readonly category?: TagNode;
63 @Prop({ type: Boolean, required: true }) readonly showCategory!: boolean; 70 @Prop({ type: Boolean, required: true }) readonly showCategory!: boolean;
64 @Prop({ type: Array, required: true }) readonly currentTags!: string[]; 71 @Prop({ type: Array, required: true }) readonly currentTags!: string[];
65 @Prop({ required: true }) readonly tagsIndex!: Tag.Index; 72 @Prop({ required: true }) readonly tagsIndex!: TagIndex;
66 @PropSync("searchFilters", { type: Array, required: true }) model!: Tag.Search[]; 73 @PropSync("searchFilters", { type: Array, required: true }) model!: TagSearch[];
67 74
68 readonly INITIAL_TAG_DISPLAY_LIMIT = this.getInitialTagDisplayLimit(); 75 readonly INITIAL_TAG_DISPLAY_LIMIT = this.getInitialTagDisplayLimit();
69 76
@@ -118,16 +125,16 @@ export default class LdProposition extends Vue {
118 return this.category?.tag ?? this.$t("panelLeft.propositions.other"); 125 return this.category?.tag ?? this.$t("panelLeft.propositions.other");
119 } 126 }
120 127
121 extractDistinctItems(currentTags: Tag.Search[]): Gallery.Item[] { 128 extractDistinctItems(currentTags: TagSearch[]): Item[] {
122 return [...new Set(currentTags.flatMap(tag => tag.items))]; 129 return [...new Set(currentTags.flatMap(tag => tag.items))];
123 } 130 }
124 131
125 rightmost(tag: Gallery.RawTag): Gallery.RawTag { 132 rightmost(tag: RawTag): RawTag {
126 const dot = tag.lastIndexOf(":"); 133 const dot = tag.lastIndexOf(":");
127 return dot <= 0 ? tag : tag.substr(dot + 1); 134 return dot <= 0 ? tag : tag.substr(dot + 1);
128 } 135 }
129 136
130 add(operation: Operation, rawTag: Gallery.RawTag) { 137 add(operation: Operation, rawTag: RawTag) {
131 const node = this.tagsIndex[rawTag]; 138 const node = this.tagsIndex[rawTag];
132 const display = this.category ? `${operation}${this.category.tag}:${node.tag}` : `${operation}${node.tag}`; 139 const display = this.category ? `${operation}${this.category.tag}:${node.tag}` : `${operation}${node.tag}`;
133 this.model.push({ ...node, parent: this.category, operation, display }); 140 this.model.push({ ...node, parent: this.category, operation, display });
@@ -135,7 +142,7 @@ export default class LdProposition extends Vue {
135} 142}
136</script> 143</script>
137 144
138<style lang="scss"> 145<style lang="scss" module>
139@import "~@/assets/scss/theme.scss"; 146@import "~@/assets/scss/theme.scss";
140 147
141.proposition { 148.proposition {
@@ -151,14 +158,14 @@ export default class LdProposition extends Vue {
151 display: flex; 158 display: flex;
152 align-items: center; 159 align-items: center;
153 padding-right: 7px; 160 padding-right: 7px;
154 .operation-tag { 161 .operationTag {
155 text-overflow: ellipsis; 162 text-overflow: ellipsis;
156 white-space: nowrap; 163 white-space: nowrap;
157 overflow: hidden; 164 overflow: hidden;
158 flex-grow: 1; 165 flex-grow: 1;
159 cursor: pointer; 166 cursor: pointer;
160 } 167 }
161 .operation-btns { 168 .operationBtns {
162 padding: 2px 7px; 169 padding: 2px 7px;
163 cursor: pointer; 170 cursor: pointer;
164 } 171 }