aboutsummaryrefslogtreecommitdiff
path: root/src/components/settings_modal/helpers/boolean_setting.js
diff options
context:
space:
mode:
authorShpuld Shpuldson <shp@cock.li>2021-08-08 16:14:22 +0300
committerShpuld Shpuldson <shp@cock.li>2021-08-08 16:14:22 +0300
commitcc170aa3ecffa75004760fc6d02bd87373132f7d (patch)
tree7d187ff11219399318f7482e0bc032cb20d025b9 /src/components/settings_modal/helpers/boolean_setting.js
parentc3fcbbd918ddef4e3f574a464fd10f4899bb2dce (diff)
parent425919a0d292b79869ebefd2a4d52ed4db45d319 (diff)
Update master with 2.4.0
Diffstat (limited to 'src/components/settings_modal/helpers/boolean_setting.js')
-rw-r--r--src/components/settings_modal/helpers/boolean_setting.js38
1 files changed, 38 insertions, 0 deletions
diff --git a/src/components/settings_modal/helpers/boolean_setting.js b/src/components/settings_modal/helpers/boolean_setting.js
new file mode 100644
index 00000000..5c52f697
--- /dev/null
+++ b/src/components/settings_modal/helpers/boolean_setting.js
@@ -0,0 +1,38 @@
+import { get, set } from 'lodash'
+import Checkbox from 'src/components/checkbox/checkbox.vue'
+import ModifiedIndicator from './modified_indicator.vue'
+export default {
+ components: {
+ Checkbox,
+ ModifiedIndicator
+ },
+ props: [
+ 'path',
+ 'disabled'
+ ],
+ 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
+ }
+ },
+ methods: {
+ update (e) {
+ set(this.$parent, this.path, e)
+ }
+ }
+}