aboutsummaryrefslogtreecommitdiff
path: root/resources/js/components/call-sign-description.vue
diff options
context:
space:
mode:
authorMateja Marić <mail@matejamaric.com>2021-03-22 15:21:40 +0100
committerGitHub <noreply@github.com>2021-03-22 15:21:40 +0100
commit6ab102bc4be617255d5eab77faebb1cada65b370 (patch)
tree09fcff5953cc6ca3702335e717ca72f865124d1c /resources/js/components/call-sign-description.vue
parent21e9e94e76a21516edc3d1e4d0462a0ba75aafa4 (diff)
parentdb976a9fb0434df0095ea9f1b8858213d57e7535 (diff)
downloadyota-laravel-master.tar.gz
yota-laravel-master.zip
Merge pull request #4 from MatejaMaric/use-vueHEADv2.0.0master
Use Vue.js and Vuex.
Diffstat (limited to 'resources/js/components/call-sign-description.vue')
-rw-r--r--resources/js/components/call-sign-description.vue56
1 files changed, 56 insertions, 0 deletions
diff --git a/resources/js/components/call-sign-description.vue b/resources/js/components/call-sign-description.vue
new file mode 100644
index 0000000..7ab8b64
--- /dev/null
+++ b/resources/js/components/call-sign-description.vue
@@ -0,0 +1,56 @@
+<template>
+ <div>
+ <div class="form-group">
+ <label for="special-call">Special Callsign:</label>
+ <select class="form-control" :class="{ 'is-invalid': isInvalid }" id="special-call" v-model="selected" :name="name" required>
+ <option v-for="option in options" :key="option.id" :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 {
+ props: [ 'name', 'old', 'isInvalid' ],
+ mounted() {
+ this.$store.dispatch('pullSigns').then(() => {
+ try {
+ if (this.old) {
+ this.$store.dispatch('setSelectedSign', this.old);
+ }
+ else {
+ 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>