2020-09-13 17:35:32 +02:00
|
|
|
<template>
|
2020-11-01 17:03:06 +01:00
|
|
|
<card-form
|
|
|
|
:title="$t('tools_webadmin_settings')" icon="cog"
|
|
|
|
no-footer
|
|
|
|
>
|
|
|
|
<template v-for="(field, fname) in fields">
|
|
|
|
<form-field
|
|
|
|
v-bind="field" v-model="self[fname]" :key="fname"
|
2020-09-13 17:35:32 +02:00
|
|
|
/>
|
2020-11-01 17:03:06 +01:00
|
|
|
<hr :key="fname + 'hr'">
|
|
|
|
</template>
|
|
|
|
</card-form>
|
2020-09-13 17:35:32 +02:00
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
2020-11-01 17:03:06 +01:00
|
|
|
// FIXME move into helpers ?
|
|
|
|
// Dynamicly generate computed properties from store with get/set and automatic commit/dispatch
|
|
|
|
function mapStoreGetSet (props = [], action = 'commit') {
|
|
|
|
return props.reduce((obj, prop) => {
|
|
|
|
obj[prop] = {
|
|
|
|
get () {
|
|
|
|
return this.$store.getters[prop]
|
|
|
|
},
|
|
|
|
set (value) {
|
|
|
|
const key = (action === 'commit' ? 'SET_' : 'UPDATE_') + prop.toUpperCase()
|
|
|
|
this.$store[action](key, value)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return obj
|
|
|
|
}, {})
|
|
|
|
}
|
2020-09-13 17:35:32 +02:00
|
|
|
|
|
|
|
export default {
|
|
|
|
name: 'ToolWebadmin',
|
|
|
|
|
2020-11-01 17:03:06 +01:00
|
|
|
data () {
|
|
|
|
return {
|
|
|
|
// Hacky way to be able to dynamicly point to a computed property `self['computedProp']`
|
|
|
|
self: this,
|
|
|
|
|
|
|
|
fields: {
|
|
|
|
locale: {
|
2020-11-25 18:23:52 +01:00
|
|
|
label: this.$i18n.t('tools_webadmin.language'),
|
2020-11-01 17:03:06 +01:00
|
|
|
component: 'SelectItem',
|
|
|
|
props: { id: 'locale', choices: [] }
|
|
|
|
},
|
|
|
|
|
|
|
|
fallbackLocale: {
|
2020-11-25 18:23:52 +01:00
|
|
|
label: this.$i18n.t('tools_webadmin.fallback_language'),
|
|
|
|
description: this.$i18n.t('tools_webadmin.fallback_language_description'),
|
2020-11-01 17:03:06 +01:00
|
|
|
component: 'SelectItem',
|
|
|
|
props: { id: 'fallback-locale', choices: [] }
|
|
|
|
},
|
|
|
|
|
|
|
|
cache: {
|
|
|
|
id: 'cache',
|
|
|
|
label: this.$i18n.t('tools_webadmin.cache'),
|
|
|
|
description: this.$i18n.t('tools_webadmin.cache_description'),
|
|
|
|
component: 'CheckboxItem',
|
|
|
|
props: { labels: { true: 'enabled', false: 'disabled' } }
|
|
|
|
},
|
|
|
|
|
|
|
|
transitions: {
|
|
|
|
id: 'transitions',
|
|
|
|
label: this.$i18n.t('tools_webadmin.transitions'),
|
|
|
|
component: 'CheckboxItem',
|
|
|
|
props: { labels: { true: 'enabled', false: 'disabled' } }
|
|
|
|
}
|
|
|
|
|
|
|
|
// experimental: added in `created()`
|
2020-09-13 17:35:32 +02:00
|
|
|
}
|
2020-11-01 17:03:06 +01:00
|
|
|
}
|
|
|
|
},
|
2020-10-08 23:58:09 +02:00
|
|
|
|
2020-11-01 17:03:06 +01:00
|
|
|
computed: {
|
|
|
|
// Those are set/get computed properties
|
|
|
|
...mapStoreGetSet(['locale', 'fallbackLocale'], 'dispatch'),
|
|
|
|
...mapStoreGetSet(['cache', 'transitions', 'experimental'])
|
|
|
|
},
|
2020-10-08 23:58:09 +02:00
|
|
|
|
2020-11-01 17:03:06 +01:00
|
|
|
created () {
|
|
|
|
const availableLocales = this.$store.getters.availableLocales
|
|
|
|
this.fields.locale.props.choices = availableLocales
|
|
|
|
this.fields.fallbackLocale.props.choices = availableLocales
|
|
|
|
if (process.env.NODE_ENV === 'development') {
|
|
|
|
this.fields.experimental = {
|
|
|
|
id: 'experimental',
|
|
|
|
label: this.$i18n.t('tools_webadmin.experimental'),
|
|
|
|
description: this.$i18n.t('tools_webadmin.experimental_description'),
|
|
|
|
component: 'CheckboxItem',
|
|
|
|
props: { labels: { true: 'enabled', false: 'disabled' } }
|
2020-10-08 15:15:44 +02:00
|
|
|
}
|
2020-09-13 17:35:32 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
</script>
|