aboutsummaryrefslogtreecommitdiff
path: root/viewer/src/components/LdTagInput.vue
blob: 4edc1ce8c54a9988fbf1622b221d415e88081206 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
<template>
  <b-taginput
    v-model="$uiStore.currentTags"
    :placeholder="$t('tagInput.placeholder')"
    autocomplete
    :data="filteredTags"
    field="tag"
    type="is-black"
    size="is-large"
    class="panelTagInput"
    @typing="getFilteredTags"
  >
    <template slot-scope="props">{{props.option.tag}} ({{props.option.items.length}})</template>
    <template slot="empty">{{$t('tagInput.nomatch')}}</template>
  </b-taginput>
</template>

<script lang="ts">
import { Component, Vue } from "vue-property-decorator";

@Component
export default class LdTagInput extends Vue {
  filteredTags: Tag.Node[] = [];

  getFilteredTags(filter: string) {
    const tags = this.$galleryStore.tags;
    if (tags && filter)
      this.filteredTags = Object.values(tags)
        .filter(node => node.tag.includes(filter))
        .sort((a, b) => b.items.length - a.items.length);
    else this.filteredTags = [];
  }
}
</script>

<style lang="scss">
.panelTagInput .autocomplete .dropdown-content {
  max-height: 300px;
}
</style>