|
@@ -8,6 +8,8 @@ export default {
|
|
|
path: String,
|
|
|
disabled: Boolean,
|
|
|
min: Number,
|
|
|
+ step: Number,
|
|
|
+ truncate: Number,
|
|
|
expert: [Number, String]
|
|
|
},
|
|
|
computed: {
|
|
@@ -15,8 +17,11 @@ export default {
|
|
|
const [firstSegment, ...rest] = this.path.split('.')
|
|
|
return [firstSegment + 'DefaultValue', ...rest].join('.')
|
|
|
},
|
|
|
+ parent () {
|
|
|
+ return this.$parent.$parent
|
|
|
+ },
|
|
|
state () {
|
|
|
- const value = get(this.$parent, this.path)
|
|
|
+ const value = get(this.parent, this.path)
|
|
|
if (value === undefined) {
|
|
|
return this.defaultState
|
|
|
} else {
|
|
@@ -24,21 +29,28 @@ export default {
|
|
|
}
|
|
|
},
|
|
|
defaultState () {
|
|
|
- return get(this.$parent, this.pathDefault)
|
|
|
+ return get(this.parent, this.pathDefault)
|
|
|
},
|
|
|
isChanged () {
|
|
|
return this.state !== this.defaultState
|
|
|
},
|
|
|
matchesExpertLevel () {
|
|
|
- return (this.expert || 0) <= this.$parent.expertLevel
|
|
|
+ return (this.expert || 0) <= this.parent.expertLevel
|
|
|
}
|
|
|
},
|
|
|
methods: {
|
|
|
+ truncateValue (value) {
|
|
|
+ if (!this.truncate) {
|
|
|
+ return value
|
|
|
+ }
|
|
|
+
|
|
|
+ return Math.trunc(value / this.truncate) * this.truncate
|
|
|
+ },
|
|
|
update (e) {
|
|
|
- set(this.$parent, this.path, parseInt(e.target.value))
|
|
|
+ set(this.parent, this.path, this.truncateValue(parseFloat(e.target.value)))
|
|
|
},
|
|
|
reset () {
|
|
|
- set(this.$parent, this.path, this.defaultState)
|
|
|
+ set(this.parent, this.path, this.defaultState)
|
|
|
}
|
|
|
}
|
|
|
}
|