2024-08-24 22:02:33 +00:00
|
|
|
<template>
|
|
|
|
<div
|
|
|
|
v-for="setting in settings"
|
|
|
|
:key="setting.id + '-sidebar'"
|
|
|
|
:id="setting.id + '-sidebar'"
|
|
|
|
class="card clickable"
|
|
|
|
@click="setView(setting.id + '-main')"
|
|
|
|
:class="{ 'active-settings': active(setting.id + '-main') }"
|
|
|
|
>
|
2024-09-16 21:01:16 +00:00
|
|
|
<div v-if="shouldShow(setting)" class="card-wrapper">{{ setting.label }}</div>
|
2024-08-24 22:02:33 +00:00
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
|
|
|
import { state, getters, mutations } from "@/store";
|
|
|
|
import { settings } from "@/utils/constants";
|
2024-09-16 21:01:16 +00:00
|
|
|
import { router } from "@/router";
|
2024-08-24 22:02:33 +00:00
|
|
|
|
|
|
|
export default {
|
|
|
|
name: "SidebarSettings",
|
|
|
|
data() {
|
|
|
|
return {
|
2024-09-16 21:01:16 +00:00
|
|
|
settings, // Initialize the settings array in data
|
2024-08-24 22:02:33 +00:00
|
|
|
};
|
|
|
|
},
|
|
|
|
computed: {
|
|
|
|
currentHash: () => getters.currentHash(),
|
|
|
|
},
|
|
|
|
methods: {
|
2024-09-16 21:01:16 +00:00
|
|
|
shouldShow(setting) {
|
|
|
|
const perm = setting?.perm || {};
|
|
|
|
// Check if all keys in setting.perm exist in state.user.perm and have truthy values
|
|
|
|
return Object.keys(perm).every((key) => state.user.perm[key]);
|
|
|
|
},
|
2024-08-24 22:02:33 +00:00
|
|
|
active: (view) => state.activeSettingsView === view,
|
|
|
|
setView(view) {
|
2024-09-16 21:01:16 +00:00
|
|
|
if (state.route.path != "/settings") {
|
|
|
|
router.push({ path: "/settings", hash: "#" + view }, () => {});
|
|
|
|
} else {
|
|
|
|
mutations.setActiveSettingsView(view);
|
|
|
|
}
|
2024-08-24 22:02:33 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
};
|
|
|
|
</script>
|
|
|
|
<style>
|
|
|
|
.active-settings {
|
|
|
|
font-weight: bold;
|
|
|
|
/* border-color: white; */
|
|
|
|
border-style: solid;
|
|
|
|
}
|
|
|
|
</style>
|