ff-admin/src/components/admin/user/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
v-if="can('admin', 'user', 'role')"
2024-09-02 15:57:03 +02:00
:to="{ name: 'admin-user-role-permission', params: { id: role.id } }"
>
<WrenchScrewdriverIcon class="w-5 h-5 p-1 box-content cursor-pointer" />
</RouterLink>
<RouterLink
v-if="can('update', 'user', 'role')"
:to="{ name: 'admin-user-role-edit', params: { id: role.id } }"
>
<PencilIcon class="w-5 h-5 p-1 box-content cursor-pointer" />
</RouterLink>
2024-11-24 15:31:08 +01:00
<div v-if="can('delete', 'user', '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-01-02 18:28:13 +01:00
import type { RoleViewModel } from "@/viewmodels/admin/user/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(
2024-09-02 15:57:03 +02:00
markRaw(defineAsyncComponent(() => import("@/components/admin/user/role/DeleteRoleModal.vue"))),
2024-09-01 19:19:48 +02:00
this.role.id
);
},
},
2024-09-01 14:54:49 +02:00
});
</script>