Initial work on highlighting changed settings. Some refactoring to
simplify addition of new settings
This commit is contained in:
parent
0c0722a092
commit
a463959a36
7 changed files with 161 additions and 111 deletions
57
src/components/settings_modal/helpers/boolean_setting.vue
Normal file
57
src/components/settings_modal/helpers/boolean_setting.vue
Normal file
|
@ -0,0 +1,57 @@
|
|||
<template>
|
||||
<label
|
||||
class="BooleanSetting"
|
||||
>
|
||||
<Checkbox
|
||||
:checked="state"
|
||||
@change="update"
|
||||
:disabled="disabled"
|
||||
>
|
||||
<span
|
||||
v-if="!!$slots.default"
|
||||
class="label"
|
||||
>
|
||||
<slot />
|
||||
</span>
|
||||
</Checkbox>
|
||||
<span v-if="isChanged">
|
||||
<strong>CHANGED</strong>
|
||||
</span>
|
||||
</label>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { get, set } from 'lodash'
|
||||
import Checkbox from 'src/components/checkbox/checkbox.vue'
|
||||
export default {
|
||||
props: [
|
||||
'path',
|
||||
'disabled'
|
||||
],
|
||||
components: {
|
||||
Checkbox
|
||||
},
|
||||
computed: {
|
||||
pathDefault () {
|
||||
const [firstSegment, ...rest] = this.path.split('.')
|
||||
return [firstSegment + 'DefaultValue', ...rest].join('.')
|
||||
},
|
||||
state () {
|
||||
return get(this.$parent, this.path)
|
||||
},
|
||||
isChanged () {
|
||||
return get(this.$parent, this.path) !== get(this.$parent, this.pathDefault)
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
update (e) {
|
||||
set(this.$parent, this.path, e)
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="scss">
|
||||
.BooleanSetting {
|
||||
}
|
||||
</style>
|
|
@ -1,29 +1,16 @@
|
|||
import {
|
||||
instanceDefaultProperties,
|
||||
multiChoiceProperties,
|
||||
defaultState as configDefaultState
|
||||
} from 'src/modules/config.js'
|
||||
import { defaultState as configDefaultState } from 'src/modules/config.js'
|
||||
|
||||
const SharedComputedObject = () => ({
|
||||
user () {
|
||||
return this.$store.state.users.currentUser
|
||||
},
|
||||
// Getting localized values for instance-default properties
|
||||
...instanceDefaultProperties
|
||||
.filter(key => multiChoiceProperties.includes(key))
|
||||
// Getting values for default properties
|
||||
...Object.keys(configDefaultState)
|
||||
.map(key => [
|
||||
key + 'DefaultValue',
|
||||
function () {
|
||||
return this.$store.getters.instanceDefaultConfig[key]
|
||||
}
|
||||
])
|
||||
.reduce((acc, [key, value]) => ({ ...acc, [key]: value }), {}),
|
||||
...instanceDefaultProperties
|
||||
.filter(key => !multiChoiceProperties.includes(key))
|
||||
.map(key => [
|
||||
key + 'LocalizedValue',
|
||||
function () {
|
||||
return this.$t('settings.values.' + this.$store.getters.instanceDefaultConfig[key])
|
||||
console.log(this.$store.getters.defaultConfig)
|
||||
return this.$store.getters.defaultConfig[key]
|
||||
}
|
||||
])
|
||||
.reduce((acc, [key, value]) => ({ ...acc, [key]: value }), {}),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue