2020-09-30 22:43:07 +00:00
|
|
|
<template>
|
|
|
|
<label
|
|
|
|
class="BooleanSetting"
|
|
|
|
>
|
|
|
|
<Checkbox
|
|
|
|
:checked="state"
|
|
|
|
@change="update"
|
|
|
|
:disabled="disabled"
|
2020-10-17 19:28:49 +00:00
|
|
|
>
|
2020-09-30 22:43:07 +00:00
|
|
|
<span
|
|
|
|
v-if="!!$slots.default"
|
|
|
|
class="label"
|
|
|
|
>
|
|
|
|
<slot />
|
|
|
|
</span>
|
2020-10-17 19:28:49 +00:00
|
|
|
<ModifiedIcon :changed="isChanged" />
|
2020-09-30 22:43:07 +00:00
|
|
|
</Checkbox>
|
|
|
|
</label>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
|
|
|
import { get, set } from 'lodash'
|
|
|
|
import Checkbox from 'src/components/checkbox/checkbox.vue'
|
2020-10-17 19:28:49 +00:00
|
|
|
import ModifiedIcon from './modified_icon.vue'
|
2020-09-30 22:43:07 +00:00
|
|
|
export default {
|
|
|
|
props: [
|
|
|
|
'path',
|
|
|
|
'disabled'
|
|
|
|
],
|
|
|
|
components: {
|
2020-10-17 19:28:49 +00:00
|
|
|
Checkbox,
|
|
|
|
ModifiedIcon
|
2020-09-30 22:43:07 +00:00
|
|
|
},
|
|
|
|
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>
|