ff-admin/src/components/admin/management/role/RoleListItem.vue

55 lines
1.9 KiB
Vue
Raw Normal View History

2024-09-01 14:54:49 +02:00
<template>
<div class="flex flex-col h-fit w-full border border-primary rounded-md">
<div class="bg-primary p-2 text-white flex flex-row justify-between items-center">
2024-09-18 09:58:29 +02:00
<p>{{ role.role }} <small v-if="role.permissions.admin">(Admin)</small></p>
2024-09-02 15:57:03 +02:00
<div class="flex flex-row">
<RouterLink
2025-02-15 11:26:34 +01:00
v-if="can('admin', 'management', 'role')"
2025-02-15 11:41:27 +01:00
:to="{ name: 'admin-management-role-permission', params: { id: role.id } }"
2024-09-02 15:57:03 +02:00
>
<WrenchScrewdriverIcon class="w-5 h-5 p-1 box-content cursor-pointer" />
</RouterLink>
<RouterLink
2025-02-15 11:26:34 +01:00
v-if="can('update', 'management', 'role')"
2025-02-15 11:41:27 +01:00
:to="{ name: 'admin-management-role-edit', params: { id: role.id } }"
2024-09-02 15:57:03 +02:00
>
<PencilIcon class="w-5 h-5 p-1 box-content cursor-pointer" />
</RouterLink>
2025-02-15 11:26:34 +01:00
<div v-if="can('delete', 'management', 'role')" @click="openDeleteModal">
2024-09-02 15:57:03 +02:00
<TrashIcon class="w-5 h-5 p-1 box-content cursor-pointer" />
</div>
</div>
2024-09-01 14:54:49 +02:00
</div>
</div>
</template>
<script setup lang="ts">
2024-09-01 19:19:48 +02:00
import { defineComponent, defineAsyncComponent, markRaw, type PropType } from "vue";
2024-09-01 14:54:49 +02:00
import { mapState, mapActions } from "pinia";
2024-09-02 15:57:03 +02:00
import { PencilIcon, WrenchScrewdriverIcon, TrashIcon } from "@heroicons/vue/24/outline";
2025-02-15 11:08:09 +01:00
import type { RoleViewModel } from "@/viewmodels/admin/management/role.models";
2024-09-02 15:57:03 +02:00
import { RouterLink } from "vue-router";
import { useAbilityStore } from "@/stores/ability";
2024-09-01 19:19:48 +02:00
import { useModalStore } from "@/stores/modal";
2024-09-01 14:54:49 +02:00
</script>
<script lang="ts">
export default defineComponent({
props: {
role: { type: Object as PropType<RoleViewModel>, default: {} },
},
2024-09-02 15:57:03 +02:00
computed: {
...mapState(useAbilityStore, ["can"]),
2024-09-01 14:54:49 +02:00
},
2024-09-01 19:19:48 +02:00
methods: {
...mapActions(useModalStore, ["openModal"]),
2024-09-02 15:57:03 +02:00
openDeleteModal() {
2024-09-01 19:19:48 +02:00
this.openModal(
2025-02-15 11:08:09 +01:00
markRaw(defineAsyncComponent(() => import("@/components/admin/management/role/DeleteRoleModal.vue"))),
2024-09-01 19:19:48 +02:00
this.role.id
);
},
},
2024-09-01 14:54:49 +02:00
});
</script>