# HG changeset patch # User Thomas Junk # Date 1546963080 -3600 # Node ID 1b25e7a3a92e9e35ca16dd4798db5fadab50630b # Parent d4702b0ff15f4726c713d65ab944d4a7a79c2085 importschedule: manage initial data from detailsview via store diff -r d4702b0ff15f -r 1b25e7a3a92e client/src/components/importschedule/Importscheduledetail.vue --- 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"); } }, diff -r d4702b0ff15f -r 1b25e7a3a92e client/src/store/imports.js --- a/client/src/store/imports.js Tue Jan 08 16:07:25 2019 +0100 +++ b/client/src/store/imports.js Tue Jan 08 16:58:00 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); },