pleroma-fe/src/components/settings_modal/helpers/choice_setting.js
Henry Jameson e95412a03c fix BooleanSetting and ChoiceSetting not working properly on initial
launch as anon visitor (would show all as changed, empty selects)
2021-05-31 14:16:37 +03:00

35 lines
805 B
JavaScript

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) || get(this.$parent, this.pathDefault)
},
defaultState () {
return get(this.$parent, this.pathDefault)
},
isChanged () {
return this.state !== undefined && this.state !== this.defaultState
}
},
methods: {
update (e) {
set(this.$parent, this.path, e)
}
}
}