From 4a7984ee9475c0ca7372f8bf8f7169fd9fa2b8ff Mon Sep 17 00:00:00 2001
From: MattIPv4 <me@mattcowley.co.uk>
Date: Thu, 4 Jun 2020 15:16:33 +0100
Subject: [PATCH] Add computed default for path

---
 .../templates/domain_sections/server.vue          | 15 +++++++++++++++
 1 file changed, 15 insertions(+)

diff --git a/src/nginxconfig/templates/domain_sections/server.vue b/src/nginxconfig/templates/domain_sections/server.vue
index c0b2917..1c76b49 100644
--- a/src/nginxconfig/templates/domain_sections/server.vue
+++ b/src/nginxconfig/templates/domain_sections/server.vue
@@ -159,6 +159,7 @@ THE SOFTWARE.
         },
         path: {
             default: '',
+            computed: '/var/www/example.com', // No default value, but a default computed
             enabled: true,
         },
         documentRoot: {
@@ -223,6 +224,11 @@ THE SOFTWARE.
                     if (!data.computed.trim()) {
                         data.computed = data.default;
                     }
+
+                    // Ensure there is a default path
+                    if (!this.$props.data.path.value.trim()) {
+                        this.$props.data.path.computed = `/var/www/${data.computed}`;
+                    }
                 },
                 deep: true,
             },
@@ -240,6 +246,15 @@ THE SOFTWARE.
                 },
                 deep: true,
             },
+            // Ensure there is a default path
+            '$props.data.path': {
+                handler(data) {
+                    if (!data.computed.trim()) {
+                        data.computed = `/var/www/${this.$props.data.domain.computed}`;
+                    }
+                },
+                deep: true,
+            },
         },
     };
 </script>