aboutsummaryrefslogblamecommitdiff
path: root/resources/js/components/call-sign-description.vue
blob: b0dca4d39c8a60c8c29cbd2668ce79fb8d57a405 (plain) (tree)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
          













                                                                                                



                




























                                                                                      

         
<template>
  <div>
    <div class="form-group">
        <label for="special-call">Special Callsign:</label>
        <select class="form-control" id="special-call" v-model="selected" name="scall" required>
          <option v-for="option in options" :value="option.sign" v-text="option.sign"></option>
        </select> 
    </div>

    <div class="card mb-3">
      <div class="card-body pb-1">
        <div class="card-text" v-html="description"></div>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  mounted() {
    this.$store.dispatch('fillSigns').then(() => {
      try {
        this.$store.dispatch('setSelectedSign', this.$store.getters.getSigns[0].sign);
      }
      catch {
        console.log('No call signs!');
      }
    });
  },
  computed: {
    options() {
      return this.$store.getters.getSigns;
    },
    selected: {
      get() {
        return this.$store.getters.getSelectedSign;
      },
      set(value) {
        this.$store.dispatch('setSelectedSign', value);
      }
    },
    description() {
      for (let i = 0; i < this.options.length; i++)
        if (this.options[i].sign === this.selected)
          return this.options[i].description;
      return '';
    }
  }
}
</script>