diff client/src/components/importschedule/Importscheduledetail.vue @ 1714:1b25e7a3a92e

importschedule: manage initial data from detailsview via store
author Thomas Junk <thomas.junk@intevation.de>
date Tue, 08 Jan 2019 16:58:00 +0100
parents d4702b0ff15f
children 79a18eb1672b
line wrap: on
line diff
--- a/client/src/components/importschedule/Importscheduledetail.vue	Tue Jan 08 16:07:25 2019 +0100
+++ b/client/src/components/importschedule/Importscheduledetail.vue	Tue Jan 08 16:58:00 2019 +0100
@@ -370,7 +370,13 @@
     11: app.$gettext("November"),
     12: app.$gettext("December")
   },
+  mounted() {
+    this.initialize();
+  },
   watch: {
+    currentSchedule() {
+      this.initialize();
+    },
     cronString() {
       if (this.isWeekly(this.cronString)) {
         this.simple = "weekly";
@@ -386,7 +392,7 @@
     }
   },
   computed: {
-    ...mapState("imports", ["importScheduleDetailVisible"]),
+    ...mapState("imports", ["importScheduleDetailVisible", "currentSchedule"]),
     isURLRequired() {
       if (this.import_ === this.$options.IMPORTTYPES.BOTTLENECK) return true;
       return false;
@@ -411,29 +417,29 @@
     }
   },
   methods: {
+    initialize() {
+      this.importType = this.currentSchedule.importType;
+      this.schedule = this.currentSchedule.schedule;
+      this.import_ = this.currentSchedule.import_;
+      this.importSource = this.currentSchedule.importSource;
+      this.eMailNotification = this.currentSchedule.eMailNotification;
+      this.easyCron = this.currentSchedule.easyCron;
+      this.cronMode = this.currentSchedule.cronMode;
+      this.minutes = this.currentSchedule.minutes;
+      this.month = this.currentSchedule.month;
+      this.hour = this.currentSchedule.hour;
+      this.day = this.currentSchedule.day;
+      this.dayOfMonth = this.currentSchedule.dayOfMonth;
+      this.simple = this.currentSchedule.simple;
+      this.url = this.currentSchedule.url;
+      this.insecure = this.currentSchedule.insecure;
+    },
     isWeekly(cron) {
       return /\d{1,2} \d{1,2} \* \* \d{1}/.test(cron);
     },
     isMonthly(cron) {
       return /\d{1,2} \d{1,2} \d{1,2} \* \*/.test(cron);
     },
-    initialize() {
-      this.importType = null;
-      this.schedule = null;
-      this.import_ = null;
-      this.importSource = null;
-      this.eMailNotification = false;
-      this.easyCron = true;
-      this.cronMode = "";
-      this.minutes = null;
-      this.month = null;
-      this.hour = null;
-      this.day = null;
-      this.dayOfMonth = null;
-      this.simple = null;
-      this.url = null;
-      this.insecure = false;
-    },
     clearInputs() {
       this.minutes = null;
       this.month = null;
@@ -477,7 +483,7 @@
       });
     },
     closeDetailview() {
-      this.initialize();
+      this.$store.commit("imports/clearCurrentSchedule");
       this.$store.commit("imports/setImportScheduleDetailInvisible");
     }
   },