Fix appSettings not being saved to db in Options view

This commit is contained in:
Bubka 2023-10-04 13:06:32 +02:00
parent 15733f0b38
commit 82b1e039e6

View File

@ -2,6 +2,7 @@
import SettingTabs from '@/layouts/SettingTabs.vue'
import groupService from '@/services/groupService'
import userPreferenceService from '@/services/userPreferenceService'
import appSettingService from '@/services/appSettingService'
import { useUserStore } from '@/stores/user'
import { useAppSettingsStore } from '@/stores/appSettings'
import { useNotifyStore } from '@/stores/notify'
@ -82,9 +83,13 @@
})
appSettings.$subscribe((mutation) => {
appSettingService.update(mutation.events.key, mutation.events.newValue).then(response => {
if (mutation.type == 'patch object') {
for (const property in mutation.payload) {
appSettingService.update(property, mutation.payload[property].value).then(response => {
useNotifyStore().info({ type: 'is-success', text: trans('settings.forms.setting_saved') })
})
}
}
})
onMounted(() => {
@ -105,6 +110,7 @@
notify.clear()
}
})
</script>
<template>
@ -169,12 +175,12 @@
<h4 class="title is-4 pt-4 has-text-grey-light">{{ $t('settings.administration') }}</h4>
<div class="is-size-7-mobile block" v-html="$t('settings.administration_legend')"></div>
<!-- Check for update -->
<FormCheckbox v-model="appSettings.checkForUpdate" fieldName="checkForUpdate" label="commons.check_for_update" help="commons.check_for_update_help" />
<FormCheckbox v-model="appSettings.checkForUpdate" @update:modelValue="(val) => appSettings.$patch({checkForUpdate: val})" fieldName="checkForUpdate" label="commons.check_for_update" help="commons.check_for_update_help" />
<VersionChecker />
<!-- protect db -->
<FormCheckbox v-model="appSettings.useEncryption" fieldName="useEncryption" label="settings.forms.use_encryption.label" help="settings.forms.use_encryption.help" />
<FormCheckbox v-model="appSettings.useEncryption" @update:modelValue="(val) => appSettings.$patch({useEncryption: val})" fieldName="useEncryption" label="settings.forms.use_encryption.label" help="settings.forms.use_encryption.help" />
<!-- disable registration -->
<FormCheckbox v-model="appSettings.disableRegistration" fieldName="disableRegistration" label="settings.forms.disable_registration.label" help="settings.forms.disable_registration.help" />
<FormCheckbox v-model="appSettings.disableRegistration" @update:modelValue="(val) => appSettings.$patch({disableRegistration: val})" fieldName="disableRegistration" label="settings.forms.disable_registration.label" help="settings.forms.disable_registration.help" />
</div>
</form>
</FormWrapper>