From 4826b8d444db4f95baeead504fb816e7322ff026 Mon Sep 17 00:00:00 2001
From: Mateja <mail@matejamaric.com>
Date: Sun, 21 Mar 2021 23:11:56 +0100
Subject: Add error handling to `call-sign-description.vue` component.

---
 resources/js/components/call-sign-description.vue | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

(limited to 'resources/js/components/call-sign-description.vue')

diff --git a/resources/js/components/call-sign-description.vue b/resources/js/components/call-sign-description.vue
index 30cd37d..7ab8b64 100644
--- a/resources/js/components/call-sign-description.vue
+++ b/resources/js/components/call-sign-description.vue
@@ -2,7 +2,7 @@
   <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>
+        <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>
@@ -17,10 +17,16 @@
 
 <script>
 export default {
+  props: [ 'name', 'old', 'isInvalid' ],
   mounted() {
     this.$store.dispatch('pullSigns').then(() => {
       try {
-        this.$store.dispatch('setSelectedSign', this.$store.getters.getSigns[0].sign);
+        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!');
-- 
cgit v1.2.3

