aboutsummaryrefslogtreecommitdiff
path: root/src/components/settings_modal/helpers/boolean_setting.js
diff options
context:
space:
mode:
authorHenry Jameson <me@hjkos.com>2023-03-12 14:32:13 +0200
committerHenry Jameson <me@hjkos.com>2023-03-12 14:36:49 +0200
commitaf0cd5422304d7b2111739d85c279b3fa175a853 (patch)
treec082ac704adc18e0d187166a8acb817d59969e29 /src/components/settings_modal/helpers/boolean_setting.js
parent8abaf8fa375d8453b2284fbf529cd03ff565bcd4 (diff)
serverSideConfig renamed into profileSettingConfig to avoid confusion
with serverSideStorage, reduced overall need for SharedComputedObject in settings tabs, moved copypaste code of "setting" type of helpers into a separate file.
Diffstat (limited to 'src/components/settings_modal/helpers/boolean_setting.js')
-rw-r--r--src/components/settings_modal/helpers/boolean_setting.js53
1 files changed, 5 insertions, 48 deletions
diff --git a/src/components/settings_modal/helpers/boolean_setting.js b/src/components/settings_modal/helpers/boolean_setting.js
index 2e6992cb..078cc5ff 100644
--- a/src/components/settings_modal/helpers/boolean_setting.js
+++ b/src/components/settings_modal/helpers/boolean_setting.js
@@ -1,56 +1,13 @@
-import { get, set } from 'lodash'
import Checkbox from 'src/components/checkbox/checkbox.vue'
import ModifiedIndicator from './modified_indicator.vue'
-import ServerSideIndicator from './server_side_indicator.vue'
+import ProfileSettingIndicator from './profile_setting_indicator.vue'
+import Setting from './setting.js'
+
export default {
components: {
Checkbox,
ModifiedIndicator,
- ServerSideIndicator
+ ProfileSettingIndicator
},
- props: [
- 'path',
- 'disabled',
- 'expert'
- ],
- 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)
- },
- isServerSide () {
- return this.path.startsWith('serverSide_')
- },
- isChanged () {
- return !this.path.startsWith('serverSide_') && this.state !== this.defaultState
- },
- matchesExpertLevel () {
- return (this.expert || 0) <= this.$parent.expertLevel
- }
- },
- methods: {
- update (e) {
- const [firstSegment, ...rest] = this.path.split('.')
- set(this.$parent, this.path, e)
- // Updating nested properties does not trigger update on its parent.
- // probably still not as reliable, but works for depth=1 at least
- if (rest.length > 0) {
- set(this.$parent, firstSegment, { ...get(this.$parent, firstSegment) })
- }
- },
- reset () {
- set(this.$parent, this.path, this.defaultState)
- }
- }
+ ...Setting
}