aboutsummaryrefslogtreecommitdiff
path: root/resources/js/components/call-sign-filter.vue
blob: 0ba8b4df05d2a257ac31cd0e0c1c535cfc762a63 (plain) (blame)
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
41
42
43
44
<template>
  <div>
    <label for="call-sign">Filter by special callsign: </label>
    <select id="call-sign" v-model="selected">
      <option value="all">All</option>
      <option v-for="option in options" :key="option.id" :value="option.sign" v-text="option.sign"></option>
    </select>

    <div class="card mb-3" v-if="showDescriptions && (selected !== 'all')">
      <div class="card-body pb-1">
        <div class="card-text" v-html="description"></div>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  props: ['showDescriptions'],
  mounted() {
    this.$store.dispatch('pullSigns');
  },
  computed: {
    selected: {
      get() {
        return this.$store.getters.getSelectedSign;
      },
      set(value) {
        this.$store.dispatch('setSelectedSign', value);
        this.$emit('sign-changed');
      }
    },
    options() {
      return this.$store.getters.getSigns;
    },
    description() {
      for (let i = 0; i < this.options.length; i++)
        if (this.options[i].sign === this.selected)
          return this.options[i].description;
      return '';
    }
  }
}
</script>