mirror of
https://github.com/solidtime-io/solidtime.git
synced 2026-08-18 13:12:16 +01:00
add e2e tests for employee restrictions
This commit is contained in:
@@ -1,31 +1,58 @@
|
||||
<script setup lang="ts">
|
||||
import { router } from '@inertiajs/vue3';
|
||||
import TabBar from '@/Components/Common/TabBar/TabBar.vue';
|
||||
import TabBarItem from '@/Components/Common/TabBar/TabBarItem.vue';
|
||||
import { canViewReport } from '@/utils/permissions';
|
||||
import { computed } from 'vue';
|
||||
defineProps<{
|
||||
import TabBar from '@/Components/Common/TabBar/TabBar.vue';
|
||||
import TabBarItem from '@/Components/Common/TabBar/TabBarItem.vue';
|
||||
|
||||
const props = defineProps<{
|
||||
active: 'reporting' | 'detailed' | 'shared';
|
||||
}>();
|
||||
|
||||
const showSharedReports = computed(() => canViewReport());
|
||||
|
||||
const tabs = computed(() => {
|
||||
const items = [
|
||||
{ value: 'reporting', label: 'Overview', href: route('reporting') },
|
||||
{ value: 'detailed', label: 'Detailed', href: route('reporting.detailed') },
|
||||
];
|
||||
if (showSharedReports.value) {
|
||||
items.push({
|
||||
value: 'shared',
|
||||
label: 'Shared',
|
||||
href: route('reporting.shared'),
|
||||
});
|
||||
}
|
||||
return items;
|
||||
});
|
||||
|
||||
function hrefForTab(value: string) {
|
||||
return tabs.value.find((tab) => tab.value === value)?.href;
|
||||
}
|
||||
|
||||
function onTabChange(value: string | number) {
|
||||
const href = hrefForTab(String(value));
|
||||
if (href) {
|
||||
router.visit(href);
|
||||
}
|
||||
}
|
||||
|
||||
function onTabHover(value: string) {
|
||||
const href = hrefForTab(value);
|
||||
if (href) {
|
||||
router.prefetch(href, {}, { cacheFor: '1m' });
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<TabBar :model-value="active">
|
||||
<TabBarItem value="reporting" @click="router.visit(route('reporting'))"
|
||||
>Overview</TabBarItem
|
||||
>
|
||||
<TabBarItem value="detailed" @click="router.visit(route('reporting.detailed'))"
|
||||
>Detailed</TabBarItem
|
||||
>
|
||||
<TabBar :default-value="props.active" @update:model-value="onTabChange">
|
||||
<TabBarItem
|
||||
v-if="showSharedReports"
|
||||
value="shared"
|
||||
@click="router.visit(route('reporting.shared'))"
|
||||
>Shared</TabBarItem
|
||||
>
|
||||
v-for="tab in tabs"
|
||||
:key="tab.value"
|
||||
:value="tab.value"
|
||||
@mouseenter="onTabHover(tab.value)">
|
||||
{{ tab.label }}
|
||||
</TabBarItem>
|
||||
</TabBar>
|
||||
</template>
|
||||
|
||||
<style scoped></style>
|
||||
|
||||
Reference in New Issue
Block a user