From 7476d4d4991f0821778f87835f2f8e61603aa83c Mon Sep 17 00:00:00 2001 From: Jiiks Date: Mon, 22 Jan 2018 22:25:55 +0200 Subject: [PATCH] Make switches functional --- .../modules/ui/vue/components/BdSettings.vue | 21 ++++++++++++++++--- .../ui/vue/components/bd/CoreSettings.vue | 4 +++- .../vue/components/templates/BdSettings.html | 2 +- 3 files changed, 22 insertions(+), 5 deletions(-) diff --git a/client/src/modules/ui/vue/components/BdSettings.vue b/client/src/modules/ui/vue/components/BdSettings.vue index 0f23757d..d1674692 100644 --- a/client/src/modules/ui/vue/components/BdSettings.vue +++ b/client/src/modules/ui/vue/components/BdSettings.vue @@ -52,7 +52,21 @@ return item.id === this.activeIndex; } - const methods = { itemOnClick, animatingContent, activeContent }; + function enableSetting(cat, id) { + switch (cat) { + case 'core': + return this.coreSettings.find(setting => setting.id === id).enabled = true; + } + } + + function disableSetting(cat, id) { + switch (cat) { + case 'core': + return this.coreSettings.find(setting => setting.id === id).enabled = false; + } + } + + const methods = { itemOnClick, animatingContent, activeContent, enableSetting, disableSetting }; export default { components, @@ -64,12 +78,13 @@ activeIndex: -1, lastActiveIndex: -1, animating: false, - first: true + first: true, + settings: Settings.getSettings } }, computed: { coreSettings: function () { - return (Settings.getSettings.find(settingset => settingset.id === 'core')).settings; + return this.settings.find(settingset => settingset.id === 'core').settings; } }, updated: function () { diff --git a/client/src/modules/ui/vue/components/bd/CoreSettings.vue b/client/src/modules/ui/vue/components/bd/CoreSettings.vue index e6218b44..d2eb4b8f 100644 --- a/client/src/modules/ui/vue/components/bd/CoreSettings.vue +++ b/client/src/modules/ui/vue/components/bd/CoreSettings.vue @@ -15,6 +15,8 @@ /*Methods*/ function settingOnClick(setting) { + if (setting.enabled) return this.disableSetting('core', setting.id); + this.enableSetting('core', setting.id); } const methods = { settingOnClick }; @@ -22,6 +24,6 @@ export default { components, methods, - props: ['settings'] + props: ['settings', 'enableSetting', 'disableSetting'] } \ No newline at end of file diff --git a/client/src/modules/ui/vue/components/templates/BdSettings.html b/client/src/modules/ui/vue/components/templates/BdSettings.html index 8ff25acf..599d09b9 100644 --- a/client/src/modules/ui/vue/components/templates/BdSettings.html +++ b/client/src/modules/ui/vue/components/templates/BdSettings.html @@ -9,7 +9,7 @@
- +