added policy system and self LOA management
This commit is contained in:
@@ -16,7 +16,7 @@ import {
|
||||
DropdownMenuTrigger,
|
||||
} from "@/components/ui/dropdown-menu"
|
||||
import { Ellipsis } from "lucide-vue-next";
|
||||
import { cancelLOA, extendLOA, getAllLOAs } from "@/api/loa";
|
||||
import { cancelLOA, extendLOA, getAllLOAs, getMyLOAs } from "@/api/loa";
|
||||
import { onMounted, ref, computed } from "vue";
|
||||
import { LOARequest } from "@shared/types/loa";
|
||||
import Dialog from "../ui/dialog/Dialog.vue";
|
||||
@@ -31,7 +31,11 @@ import {
|
||||
CalendarDate,
|
||||
getLocalTimeZone,
|
||||
} from "@internationalized/date"
|
||||
import { el } from "@fullcalendar/core/internal-common";
|
||||
|
||||
const props = defineProps<{
|
||||
adminMode?: boolean
|
||||
}>()
|
||||
|
||||
const LOAList = ref<LOARequest[]>([]);
|
||||
|
||||
@@ -40,9 +44,11 @@ onMounted(async () => {
|
||||
});
|
||||
|
||||
async function loadLOAs() {
|
||||
// const unsort = await getAllLOAs();
|
||||
// LOAList.value = sortByStartDate(unsort);
|
||||
LOAList.value = await getAllLOAs();
|
||||
if (props.adminMode) {
|
||||
LOAList.value = await getAllLOAs();
|
||||
} else {
|
||||
LOAList.value = await getMyLOAs();
|
||||
}
|
||||
}
|
||||
|
||||
function formatDate(date: Date): string {
|
||||
@@ -76,7 +82,7 @@ function sortByStartDate(loas: LOARequest[]): LOARequest[] {
|
||||
}
|
||||
|
||||
async function cancelAndReload(id: number) {
|
||||
await cancelLOA(id, true);
|
||||
await cancelLOA(id, props.adminMode);
|
||||
await loadLOAs();
|
||||
}
|
||||
|
||||
@@ -160,11 +166,17 @@ async function commitExtend() {
|
||||
<Ellipsis></Ellipsis>
|
||||
</DropdownMenuTrigger>
|
||||
<DropdownMenuContent>
|
||||
<DropdownMenuItem v-if="!post.closed" @click="isExtending = true; targetLOA = post">
|
||||
<DropdownMenuItem v-if="!post.closed && props.adminMode"
|
||||
@click="isExtending = true; targetLOA = post">
|
||||
Extend
|
||||
</DropdownMenuItem>
|
||||
<DropdownMenuItem :variant="'destructive'" @click="cancelAndReload(post.id)">End
|
||||
<DropdownMenuItem v-if="!post.closed" :variant="'destructive'"
|
||||
@click="cancelAndReload(post.id)">End
|
||||
</DropdownMenuItem>
|
||||
<!-- Fallback: no actions available -->
|
||||
<p v-if="post.closed || (!props.adminMode && post.closed)" class="p-2 text-center text-sm">
|
||||
No actions
|
||||
</p>
|
||||
</DropdownMenuContent>
|
||||
</DropdownMenu>
|
||||
</TableCell>
|
||||
|
||||
Reference in New Issue
Block a user