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.vue35
1 files changed, 19 insertions, 16 deletions
diff --git a/viewer/src/components/LdProposition.vue b/viewer/src/components/LdProposition.vue
index 395611f..7f6521f 100644
--- a/viewer/src/components/LdProposition.vue
+++ b/viewer/src/components/LdProposition.vue
@@ -25,13 +25,17 @@
25 class="operation-btns link" 25 class="operation-btns link"
26 :title="$t('tag-propositions.substraction')" 26 :title="$t('tag-propositions.substraction')"
27 @click="add(Operation.SUBSTRACTION, proposed.rawTag)" 27 @click="add(Operation.SUBSTRACTION, proposed.rawTag)"
28 ><fa-icon icon="minus" alt="[-]" /></a> 28 >
29 <fa-icon icon="minus" alt="[-]" />
30 </a>
29 31
30 <a 32 <a
31 class="operation-btns link" 33 class="operation-btns link"
32 :title="$t('tag-propositions.addition')" 34 :title="$t('tag-propositions.addition')"
33 @click="add(Operation.ADDITION, proposed.rawTag)" 35 @click="add(Operation.ADDITION, proposed.rawTag)"
34 ><fa-icon icon="plus" alt="[+]" /></a> 36 >
37 <fa-icon icon="plus" alt="[+]" />
38 </a>
35 39
36 <a 40 <a
37 class="operation-tag link" 41 class="operation-tag link"
@@ -39,39 +43,39 @@
39 @click="add(Operation.INTERSECTION, proposed.rawTag)" 43 @click="add(Operation.INTERSECTION, proposed.rawTag)"
40 >{{proposed.rawTag}}</a> 44 >{{proposed.rawTag}}</a>
41 45
42 <div 46 <div class="disabled" :title="$t('tag-propositions.item-count')">{{proposed.count}}</div>
43 class="disabled"
44 :title="$t('tag-propositions.item-count')"
45 >{{proposed.count}}</div>
46 </div> 47 </div>
47 </div> 48 </div>
48</template> 49</template>
49 50
50<script lang="ts"> 51<script lang="ts">
51import { Component, Vue } from "vue-property-decorator"; 52import { Component, Vue, Model, Prop } from "vue-property-decorator";
52import { Operation } from "@/@types/Operation"; 53import { Operation } from "@/@types/Operation";
53 54
54@Component 55@Component
55export default class LdProposition extends Vue { 56export default class LdProposition extends Vue {
57 @Prop({ type: Array, required: true }) readonly currentTags!: string[];
58 @Prop({ required: true }) readonly tagsIndex!: Tag.Index;
59 @Model() model!: Tag.Search[];
60
56 get Operation() { 61 get Operation() {
57 return Operation; 62 return Operation;
58 } 63 }
59 64
60 get proposedTags() { 65 get proposedTags() {
61 const currentTags = this.$uiStore.currentTags;
62 let propositions: { [index: string]: number } = {}; 66 let propositions: { [index: string]: number } = {};
63 if (currentTags.length > 0) { 67 if (this.model.length > 0) {
64 // Tags count from current search 68 // Tags count from current search
65 this.extractDistinctItems(currentTags) 69 this.extractDistinctItems(this.model)
66 .flatMap(item => item.tags) 70 .flatMap(item => item.tags)
67 .map(this.rightmost) 71 .map(this.rightmost)
68 .filter(rawTag => !currentTags.find(currentTag => currentTag.tag === rawTag)) 72 .filter(rawTag => !this.model.find(search => search.tag === rawTag))
69 .forEach(rawTag => (propositions[rawTag] = (propositions[rawTag] ?? 0) + 1)); 73 .forEach(rawTag => (propositions[rawTag] = (propositions[rawTag] ?? 0) + 1));
70 } else { 74 } else {
71 // Tags count from the current directory 75 // Tags count from the current directory
72 this.$galleryStore.currentItem?.tags 76 this.currentTags
73 .flatMap(tag => tag.split(".")) 77 .flatMap(tag => tag.split("."))
74 .map(tag => this.$galleryStore.tags[tag]) // FIXME: Folders with the same name are merged in the index 78 .map(tag => this.tagsIndex[tag])
75 .forEach(tagindex => (propositions[tagindex.tag] = tagindex.items.length)); 79 .forEach(tagindex => (propositions[tagindex.tag] = tagindex.items.length));
76 } 80 }
77 81
@@ -90,10 +94,9 @@ export default class LdProposition extends Vue {
90 } 94 }
91 95
92 add(operation: Operation, rawTag: Gallery.RawTag) { 96 add(operation: Operation, rawTag: Gallery.RawTag) {
93 const node = this.$galleryStore.tags[rawTag]; 97 const node = this.tagsIndex[rawTag];
94 const search: Tag.Search = { ...node, operation, display: `${operation}${node.tag}` }; 98 const search: Tag.Search = { ...node, operation, display: `${operation}${node.tag}` };
95 this.$uiStore.currentTags.push(search); 99 this.model.push(search);
96 setTimeout(() => this.$uiStore.setModeSearch()); // Give time for the UI to display the Tag change
97 } 100 }
98} 101}
99</script> 102</script>