Skip to content

Commit

Permalink
fix: basic preferences changed
Browse files Browse the repository at this point in the history
  • Loading branch information
agalwood committed Jul 4, 2019
1 parent e06888e commit 571499c
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions src/renderer/components/Preference/Basic.vue
Original file line number Diff line number Diff line change
Expand Up @@ -203,10 +203,12 @@
data: function () {
const { locale } = this.$store.state.preference.config
const form = initialForm(this.$store.state.preference.config)
const formOriginal = cloneDeep(form)
return {
form,
formLabelWidth: calcFormLabelWidth(locale),
formOriginal: cloneDeep(form),
formOriginal,
locales: availableLanguages,
rules: {},
speedOptions: this.buildSpeedOptions()
Expand Down Expand Up @@ -271,6 +273,13 @@
onDirectorySelected (dir) {
this.form.dir = dir
},
syncFormConfig () {
this.$store.dispatch('preference/fetchPreference')
.then((config) => {
this.form = initialForm(config)
this.formOriginal = cloneDeep(this.form)
})
},
submitForm (formName) {
this.$refs[formName].validate((valid) => {
if (!valid) {
Expand All @@ -288,6 +297,7 @@
this.$store.dispatch('preference/save', data)
.then(() => {
this.$store.dispatch('app/fetchEngineOptions')
this.syncFormConfig()
this.$msg.success(this.$t('preferences.save-success-message'))
})
.catch(() => {
Expand All @@ -304,7 +314,7 @@
})
},
resetForm (formName) {
this.form = initialForm(this.$store.state.preference.config)
this.syncFormConfig()
}
}
}
Expand Down

0 comments on commit 571499c

Please sign in to comment.