display user permissions

This commit is contained in:
Julian Krauser 2024-11-20 10:13:10 +01:00
parent 6f135af4a6
commit 8f23a688cb
4 changed files with 55 additions and 5 deletions

View file

@ -1,5 +1,8 @@
<template> <template>
<div class="flex flex-col gap-2 max-w-2xl mx-auto w-full select-none"> <div
class="flex flex-col gap-2 max-w-2xl mx-auto w-full select-none"
:class="disableEdit ? ' pointer-events-none opacity-60 bg-gray-100/50' : ''"
>
<div class="flex flex-row gap-2 h-fit w-full border border-gray-300 rounded-md p-2"> <div class="flex flex-row gap-2 h-fit w-full border border-gray-300 rounded-md p-2">
<input type="checkbox" name="admin" id="admin" class="cursor-pointer" :checked="isAdmin" @change="toggleAdmin" /> <input type="checkbox" name="admin" id="admin" class="cursor-pointer" :checked="isAdmin" @change="toggleAdmin" />
<label for="admin" class="cursor-pointer">Administratorrecht</label> <label for="admin" class="cursor-pointer">Administratorrecht</label>
@ -8,7 +11,7 @@
v-for="section in sections" v-for="section in sections"
:key="section" :key="section"
class="flex flex-col gap-2 h-fit w-full border border-primary rounded-md" class="flex flex-col gap-2 h-fit w-full border border-primary rounded-md"
:class="isAdmin ? ' pointer-events-none opacity-60 bg-gray-100' : ''" :class="isAdmin && !disableEdit ? ' pointer-events-none opacity-60 bg-gray-100' : ''"
> >
<div class="bg-primary p-2 text-white flex flex-row justify-between items-center"> <div class="bg-primary p-2 text-white flex flex-row justify-between items-center">
<p>Abschnitt: {{ section }}</p> <p>Abschnitt: {{ section }}</p>
@ -65,7 +68,7 @@
</div> </div>
</div> </div>
</div> </div>
<div class="flex flex-row gap-2 self-end pt-4"> <div v-if="!disableEdit" class="flex flex-row gap-2 self-end pt-4">
<button primary-outline class="!w-fit" @click="reset" :disabled="canSaveOrReset">verwerfen</button> <button primary-outline class="!w-fit" @click="reset" :disabled="canSaveOrReset">verwerfen</button>
<button primary class="!w-fit" @click="submit" :disabled="status == 'loading' || canSaveOrReset"> <button primary class="!w-fit" @click="submit" :disabled="status == 'loading' || canSaveOrReset">
speichern speichern
@ -109,6 +112,10 @@ export default defineComponent({
type: [Object, String, null] as PropType<null | "loading" | { status: "success" | "failed"; message?: string }>, type: [Object, String, null] as PropType<null | "loading" | { status: "success" | "failed"; message?: string }>,
default: null, default: null,
}, },
disableEdit: {
type: Boolean,
default: false,
},
}, },
watch: { watch: {
permissions() { permissions() {

View file

@ -471,6 +471,11 @@ const router = createRouter({
name: "account-logindata", name: "account-logindata",
component: () => import("@/views/account/LoginData.vue"), component: () => import("@/views/account/LoginData.vue"),
}, },
{
path: "permission",
name: "account-permission",
component: () => import("@/views/account/Permission.vue"),
},
{ {
path: ":pathMatch(.*)*", path: ":pathMatch(.*)*",
name: "account-404", name: "account-404",

View file

@ -0,0 +1,31 @@
<template>
<MainTemplate :useStagedOverviewLink="false">
<template #topBar>
<div class="flex flex-row items-center justify-between pt-5 pb-3 px-7">
<h1 class="font-bold text-xl h-8">Meine Berechtigungen</h1>
</div>
</template>
<template #main>
<Permission :permissions="permissions" :disableEdit="true" />
</template>
</MainTemplate>
</template>
<script setup lang="ts">
import { defineComponent, markRaw, defineAsyncComponent } from "vue";
import { mapActions, mapState } from "pinia";
import MainTemplate from "@/templates/Main.vue";
import Permission from "@/components/admin/Permission.vue";
import { useAbilityStore } from "@/stores/ability";
</script>
<script lang="ts">
export default defineComponent({
data() {
return {};
},
computed: {
...mapState(useAbilityStore, ["permissions"]),
},
});
</script>

View file

@ -1,8 +1,8 @@
<template> <template>
<SidebarLayout> <SidebarLayout>
<template #sidebar> <template #sidebar>
<SidebarTemplate mainTitle="Mein Account" topTitle="Mitgliederverwaltung" :showTopList="true"> <SidebarTemplate mainTitle="Mein Account" topTitle="Mitgliederverwaltung" :showTopList="isOwner">
<template #topList> <template v-if="isOwner" #topList>
<RoutingLink title="Administration" :link="{ name: 'account' }" :active="activeRouteName == 'account'" /> <RoutingLink title="Administration" :link="{ name: 'account' }" :active="activeRouteName == 'account'" />
</template> </template>
<template #list> <template #list>
@ -12,6 +12,11 @@
:link="{ name: 'account-logindata' }" :link="{ name: 'account-logindata' }"
:active="activeRouteName == 'account-logindata'" :active="activeRouteName == 'account-logindata'"
/> />
<RoutingLink
title="Meine Berechtigungen"
:link="{ name: 'account-permission' }"
:active="activeRouteName == 'account-permission'"
/>
</template> </template>
</SidebarTemplate> </SidebarTemplate>
</template> </template>
@ -28,11 +33,13 @@ import SidebarLayout from "@/layouts/Sidebar.vue";
import SidebarTemplate from "@/templates/Sidebar.vue"; import SidebarTemplate from "@/templates/Sidebar.vue";
import RoutingLink from "@/components/admin/RoutingLink.vue"; import RoutingLink from "@/components/admin/RoutingLink.vue";
import { RouterView } from "vue-router"; import { RouterView } from "vue-router";
import { useAbilityStore } from "@/stores/ability";
</script> </script>
<script lang="ts"> <script lang="ts">
export default defineComponent({ export default defineComponent({
computed: { computed: {
...mapState(useAbilityStore, ["isOwner"]),
activeRouteName() { activeRouteName() {
return this.$route.name; return this.$route.name;
}, },