Make switches functional

This commit is contained in:
Jiiks 2018-01-22 22:25:55 +02:00
parent 23cde9cb9f
commit 7476d4d499
3 changed files with 22 additions and 5 deletions

View File

@ -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 () {

View File

@ -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']
}
</script>

View File

@ -9,7 +9,7 @@
</Sidebar>
<ContentColumn slot="content">
<div :class="{active: activeContent('core'), animating: animatingContent('core')}">
<CoreSettings :settings="coreSettings"/>
<CoreSettings :settings="coreSettings" :enableSetting="enableSetting" :disableSetting="disableSetting"/>
</div>
<div :class="{active: activeContent('ui'), animating: animatingContent('ui')}">
<UISettings />