2022-03-07 20:02:53 -05:00
|
|
|
import { get, set } from 'lodash'
|
|
|
|
import ModifiedIndicator from './modified_indicator.vue'
|
|
|
|
export default {
|
|
|
|
components: {
|
|
|
|
ModifiedIndicator
|
|
|
|
},
|
|
|
|
props: {
|
|
|
|
path: String,
|
|
|
|
disabled: Boolean,
|
2022-03-14 09:31:24 +02:00
|
|
|
min: Number,
|
2022-03-29 00:02:02 +03:00
|
|
|
expert: [Number, String]
|
2022-03-07 20:02:53 -05:00
|
|
|
},
|
|
|
|
computed: {
|
|
|
|
pathDefault () {
|
|
|
|
const [firstSegment, ...rest] = this.path.split('.')
|
|
|
|
return [firstSegment + 'DefaultValue', ...rest].join('.')
|
|
|
|
},
|
|
|
|
state () {
|
|
|
|
const value = get(this.$parent, this.path)
|
|
|
|
if (value === undefined) {
|
|
|
|
return this.defaultState
|
|
|
|
} else {
|
|
|
|
return value
|
|
|
|
}
|
|
|
|
},
|
|
|
|
defaultState () {
|
|
|
|
return get(this.$parent, this.pathDefault)
|
|
|
|
},
|
|
|
|
isChanged () {
|
|
|
|
return this.state !== this.defaultState
|
2022-03-14 09:31:24 +02:00
|
|
|
},
|
|
|
|
matchesExpertLevel () {
|
|
|
|
return (this.expert || 0) <= this.$parent.expertLevel
|
2022-03-07 20:02:53 -05:00
|
|
|
}
|
|
|
|
},
|
|
|
|
methods: {
|
|
|
|
update (e) {
|
|
|
|
set(this.$parent, this.path, parseInt(e.target.value))
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|