implement ChoiceSetting for settings modal similar to BooleanSetting
This commit is contained in:
parent
3870a30aea
commit
1f0ac68fcd
6 changed files with 103 additions and 52 deletions
34
src/components/settings_modal/helpers/choice_setting.js
Normal file
34
src/components/settings_modal/helpers/choice_setting.js
Normal file
|
@ -0,0 +1,34 @@
|
|||
import { get, set } from 'lodash'
|
||||
import Select from 'src/components/select/select.vue'
|
||||
import ModifiedIndicator from './modified_indicator.vue'
|
||||
export default {
|
||||
components: {
|
||||
Select,
|
||||
ModifiedIndicator
|
||||
},
|
||||
props: [
|
||||
'path',
|
||||
'disabled',
|
||||
'options'
|
||||
],
|
||||
computed: {
|
||||
pathDefault () {
|
||||
const [firstSegment, ...rest] = this.path.split('.')
|
||||
return [firstSegment + 'DefaultValue', ...rest].join('.')
|
||||
},
|
||||
state () {
|
||||
return get(this.$parent, this.path)
|
||||
},
|
||||
defaultState () {
|
||||
return get(this.$parent, this.pathDefault)
|
||||
},
|
||||
isChanged () {
|
||||
return get(this.$parent, this.path) !== get(this.$parent, this.pathDefault)
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
update (e) {
|
||||
set(this.$parent, this.path, e)
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue