changeset 1716:99be34d8f37a

client: merge
author Bernhard Reiter <bernhard@intevation.de>
date Tue, 08 Jan 2019 16:59:04 +0100
parents dd9d90cae683 (current diff) 1b25e7a3a92e (diff)
children 6646ba22c94a
files
diffstat 2 files changed, 50 insertions(+), 19 deletions(-) [+]
line wrap: on
line diff
--- a/client/src/components/importschedule/Importscheduledetail.vue	Tue Jan 08 16:58:09 2019 +0100
+++ b/client/src/components/importschedule/Importscheduledetail.vue	Tue Jan 08 16:59:04 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");
     }
   },
--- a/client/src/store/imports.js	Tue Jan 08 16:58:09 2019 +0100
+++ b/client/src/store/imports.js	Tue Jan 08 16:59:04 2019 +0100
@@ -31,6 +31,27 @@
   MONTHLY: "monthly"
 };
 
+const initializeCurrentSchedule = () => {
+  return {
+    importType: null,
+    schedule: null,
+    import_: null,
+    importSource: null,
+    eMailNotification: false,
+    scheduled: false,
+    easyCron: true,
+    cronMode: "",
+    minutes: null,
+    month: null,
+    hour: null,
+    day: null,
+    dayOfMonth: null,
+    simple: null,
+    url: null,
+    insecure: false
+  };
+};
+
 // initial state
 const init = () => {
   return {
@@ -38,6 +59,7 @@
     staging: [],
     schedules: [],
     importScheduleDetailVisible: false,
+    currentSchedule: initializeCurrentSchedule(),
     importToReview: null
   };
 };
@@ -47,6 +69,9 @@
   namespaced: true,
   state: init(),
   mutations: {
+    clearCurrentSchedule: state => {
+      state.currentSchedule = initializeCurrentSchedule();
+    },
     deleteSchedule: (state, index) => {
       state.schedules.splice(index, 1);
     },