From 15df9577f4bc1427873eb6277fa21769caded5da Mon Sep 17 00:00:00 2001 From: Angelina Filippova Date: Sat, 7 Mar 2020 16:02:13 +0300 Subject: [PATCH] Fix wrapping cron tab settings before sending them to BE --- .../components/inputComponents/CrontabInput.vue | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/src/views/settings/components/inputComponents/CrontabInput.vue b/src/views/settings/components/inputComponents/CrontabInput.vue index 1f6f3af1..f3f16d26 100644 --- a/src/views/settings/components/inputComponents/CrontabInput.vue +++ b/src/views/settings/components/inputComponents/CrontabInput.vue @@ -59,12 +59,18 @@ export default { return this.setting.suggestions.find(suggestion => suggestion[1] === worker)[0] }, update(value, worker) { - const updatedValue = { - ...this.$store.state.settings.settings[this.settingGroup.group][this.settingGroup.key][this.setting.key], - [worker]: value - } + const currentValue = this.$store.state.settings.settings[this.settingGroup.group][this.settingGroup.key][this.setting.key] + const updatedValue = { ...currentValue, [worker]: value } + const updatedValueWithType = Object.keys(currentValue).reduce((acc, key) => { + if (key === worker) { + return { ...acc, [key]: ['reversed_tuple', value] } + } else { + return { ...acc, [key]: ['reversed_tuple', currentValue[key]] } + } + }, {}) + this.$store.dispatch('UpdateSettings', - { group: this.settingGroup.group, key: this.settingGroup.key, input: this.setting.key, value: updatedValue, type: 'reversed_tuple' } + { group: this.settingGroup.group, key: this.settingGroup.key, input: this.setting.key, value: updatedValueWithType, type: this.setting.type } ) this.$store.dispatch('UpdateState', { group: this.settingGroup.group, key: this.settingGroup.key, input: this.setting.key, value: updatedValue }