hardlounge/client/components/Windows/Settings.vue

57 lines
1.2 KiB
Vue
Raw Permalink Normal View History

2019-02-18 09:18:32 +00:00
<template>
2019-08-03 19:03:45 +00:00
<div id="settings" class="window" role="tabpanel" aria-label="Settings">
2019-02-18 09:18:32 +00:00
<div class="header">
<SidebarToggle />
2019-02-18 09:18:32 +00:00
</div>
<Navigation />
<div class="container">
<form ref="settingsForm" autocomplete="off" @change="onChange" @submit.prevent>
<router-view></router-view>
</form>
</div>
2019-02-18 09:18:32 +00:00
</div>
</template>
<script lang="ts">
import {defineComponent} from "vue";
import SidebarToggle from "../SidebarToggle.vue";
import Navigation from "../Settings/Navigation.vue";
import {useStore} from "../../js/store";
2019-11-15 19:13:26 +00:00
export default defineComponent({
2019-02-18 09:18:32 +00:00
name: "Settings",
components: {
SidebarToggle,
Navigation,
},
setup() {
const store = useStore();
const onChange = (event: Event) => {
2019-08-03 19:03:45 +00:00
const ignore = ["old_password", "new_password", "verify_password"];
2019-02-18 09:18:32 +00:00
const name = (event.target as HTMLInputElement).name;
2019-02-18 09:18:32 +00:00
if (ignore.includes(name)) {
return;
}
let value: boolean | string;
if ((event.target as HTMLInputElement).type === "checkbox") {
value = (event.target as HTMLInputElement).checked;
} else {
value = (event.target as HTMLInputElement).value;
}
void store.dispatch("settings/update", {name, value, sync: true});
};
return {
onChange,
};
2019-02-18 09:18:32 +00:00
},
});
2019-02-18 09:18:32 +00:00
</script>