Changes in RLS and Tenants

Many Changes in Invoice Editor
Page Loading Rebuilt
Started Rights Management
This commit is contained in:
2024-01-30 21:18:46 +01:00
parent 3167b6a20a
commit fe74e7d91b
13 changed files with 885 additions and 527 deletions

View File

@@ -3,47 +3,20 @@
import GlobalSearch from "~/components/GlobalSearch.vue";
const supabase = useSupabaseClient()
const user = useSupabaseUser()
//console.log(user.value)
const router = useRouter()
const route = useRoute()
const colorMode = useColorMode()
const supabase = useSupabaseClient()
const tenants = (await supabase.from("tenants").select()).data
const dataStore = useDataStore()
const isLight = computed({
get () {
return colorMode.value !== 'dark'
},
set () {
colorMode.preference = colorMode.value === 'dark' ? 'light' : 'dark'
}
})
const userProfile = (user.value ? dataStore.getProfileById(user.value.id) : {})
//console.log(userProfile)
const showUserMenu = ref(false)
const userMenuItems = ref([
{
label: "Profil",
badge: dataStore.notifications.filter(item => item.read).length,
icon: "i-heroicons-user-20-solid"
},
{
label: "Nummernkreise",
icon: "i-heroicons-cog-8-tooth",
to: "/settings/numberRanges"
},
{
label: 'Benutzer',
icon: 'i-heroicons-user-group',
to: "/users"
}
])
@@ -56,151 +29,9 @@ watch(viewport.breakpoint, (newBreakpoint, oldBreakpoint) => {
})
dataStore.fetchData()
dataStore.initializeData()
const navLinks = [
{
label: "Home",
to: "/",
icon: 'i-heroicons-home'
},
{
label: "Kontakte",
icon: 'i-heroicons-user-group',
children: [
{
label: "Kunden",
to: "/customers",
icon: "i-heroicons-user-group"
},
{
label: "Lieferanten",
to: "/vendors",
icon: "i-heroicons-truck"
},
{
label: "Ansprechpartner",
to: "/contacts",
icon: "i-heroicons-user-group"
},
]
},
{
label: "Buchhaltung",
icon: 'i-heroicons-document-chart-bar',
children: [
{
label: "Eingangsrechnungen",
to: "/incominginvoices",
icon: "i-heroicons-document-text"
},
/*{
label: "Ausgangsrechnungen",
to: "/customerinvoices",
icon: "i-heroicons-document-text"
},*/
{
label: "Bank",
to: "/banking",
icon: "i-heroicons-currency-euro"
},
]
},
{
label: "Aufträge",
icon: "i-heroicons-square-3-stack-3d",
children: [
{
label: "Projekte",
to: "/projects",
icon: "i-heroicons-clipboard-document-check"
},
{
label: "Verträge",
to: "/contracts",
icon: "i-heroicons-clipboard-document"
},
{
label: "Objekte",
to: "/plants",
icon: "i-heroicons-clipboard-document"
},
]
},
{
label: "Verwaltung",
icon: "i-heroicons-square-3-stack-3d",
children: [
{
label: "Aufgaben",
to: "/tasks",
icon: "i-heroicons-rectangle-stack"
},
{
label: "Plantafel",
to: "/calendar/timeline",
icon: "i-heroicons-calendar-days"
},
{
label: "Kalender",
to: "/calendar/grid",
icon: "i-heroicons-calendar-days"
},
{
label: "Dokumente",
to: "/documents",
icon: "i-heroicons-document"
},
]
},
{
label: "Chat",
to: "/chat",
icon:'i-heroicons-chat-bubble-left-right'
},
{
label: "Mitarbeiter",
icon: 'i-heroicons-user',
children: [
{
label: "Zeiterfassung",
to: "/employees/timetracking",
icon: "i-heroicons-clock"
},
{
label: "Abwesenheiten",
to: "/absenceRequests",
icon: "i-heroicons-document-text"
}
]
},
{
label: "Lager",
icon: 'i-heroicons-home',
children: [
{
label: "Steuerung",
to: "/inventory",
icon: "i-heroicons-square-3-stack-3d"
},
{
label: "Artikelstamm",
to: "/products",
icon: "i-heroicons-puzzle-piece"
},
{
label: "Lagerplätze",
to: "/spaces",
icon: "i-heroicons-square-3-stack-3d"
},
{
label: "Fahrzeuge",
to: "/vehicles",
icon: "i-heroicons-truck"
},
]
},
]
const linksForBreadcrumbs = ref([])
@@ -209,8 +40,8 @@ const linksForBreadcrumbs = ref([])
const userTenant = ref({})
if(user) userTenant.value = tenants.find(tenant => tenant.id === user.value.app_metadata.tenant)
//const userTenant = ref({})
//if(user) userTenant.value = tenants.find(tenant => tenant.id === user.value.app_metadata.tenant)
@@ -275,189 +106,10 @@ const items = [
</script>
<template>
<UHeader :links="navLinks" :to="null">
<template #logo>
<div id="logo">
<img
:src="!isLight ? '/spaces.svg' : '/spaces_hell.svg'"
alt="Logo"
/>
</div>
</template>
<template #panel>
<UNavigationTree :links="navLinks"/>
</template>
<template #right>
<!-- <ClientOnly>
<UButton
:icon="!isLight ? 'i-heroicons-moon-20-solid' : 'i-heroicons-sun-20-solid'"
color="gray"
variant="ghost"
aria-label="Theme"
@click="isLight = !isLight"
/>
<template #fallback>
<div class="w-8 h-8" />
</template>
</ClientOnly>-->
<GlobalSearch/>
<!-- <UPopover :popper="{placement: 'bottom-start'}">
<ClientOnly>
<UChip
:show="dataStore.notifications.filter(notification => !notification.read).length > 0"
inset
>
<UButton
icon="i-heroicons-envelope-20-solid"
variant="ghost"
color="gray"
class="mx-2"
/>
</UChip>
<template #fallback>
<div class="w-8 h-8" />
</template>
</ClientOnly>
<template #panel>
<div class="w-60 p-3">
<UAlert
class="mb-3"
v-for="(notification,index) in dataStore.notifications"
:color="!notification.read ? 'primary' : 'grey'"
variant="outline"
:description="notification.text"
:title="notification.title"
/>
</div>
</template>
</UPopover>-->
<UButton
@click="showUserMenu = true"
variant="ghost"
color="gray"
>
<UAvatar
:alt="userProfile ? userProfile.firstName + ' ' + userProfile.lastName : '' "
icon="i-heroicons-user-20-solid"
:chip-color="dataStore.notifications.filter(item => !item.read).length > 0 ? 'primary' : null"
/>
</UButton>
<USlideover
v-model="showUserMenu"
>
<UCard
class="h-full"
>
<UDivider
class="my-3"
label="Menü"
/>
<UVerticalNavigation
:links="userMenuItems"
/>
<UDivider
class="my-3"
label="Benachrichtigungen"
/>
<UAlert
class="mb-3"
v-for="(notification) in dataStore.notifications"
:color="!notification.read ? 'primary' : 'white'"
:variant="!notification.read ? 'outline' : 'soft'"
:description="notification.text"
:title="notification.title"
:close-button="!notification.read ? { icon: 'i-heroicons-x-mark-20-solid', color: 'gray', variant: 'link', padded: false } : null"
@close="async () => {
const {error} = await supabase.from('notifications').update({read:true}).eq('id', notification.id)
if(error) console.log(error)
dataStore.fetchNotifications()
}"
/>
<template #footer>
<InputGroup>
<UButton
:icon="!isLight ? 'i-heroicons-moon-20-solid' : 'i-heroicons-sun-20-solid'"
color="white"
variant="outline"
aria-label="Theme"
@click="isLight = !isLight"
/>
<UButton
color="rose"
variant="outline"
@click="async () => {
showUserMenu = false
await supabase.auth.signOut()
await dataStore.clearStore()
await router.push('/login')
}"
>
Ausloggen
</UButton>
</InputGroup>
</template>
</UCard>
</USlideover>
<!-- <UDropdown :items="items" :ui="{ item: { disabled: 'cursor-text select-text' } }" :popper="{ placement: 'bottom-start' }">
<UAvatar
:alt="userProfile ? userProfile.firstName + ' ' + userProfile.lastName : '' "
icon="i-heroicons-user-20-solid"
/>
<template #account="{ item }">
<div class="text-left">
<p>
Eingeloggt als
</p>
<p class="truncate font-medium text-gray-900 dark:text-white">
{{ item.label }}
</p>
</div>
</template>
<template #item="{ item }">
<span class="truncate">{{ item.label }}</span>
<UIcon :name="item.icon" class="flex-shrink-0 h-4 w-4 text-gray-400 dark:text-gray-500 ms-auto" />
</template>
</UDropdown>-->
</template>
</UHeader>
<UDivider />
<div class="m-3" id="contentContainer">
<NuxtLayout>
<NuxtPage/>
</NuxtLayout>
</div>
<NuxtLayout>
<NuxtPage/>
</NuxtLayout>
<!-- <UFooter>
<template #left>
<p class="text-gray-500 dark:text-gray-400 text-sm">
@@ -472,11 +124,9 @@ const items = [
</template>
</UFooter>-->
<UNotifications/>
<VitePwaManifest/>
<!-- <UCard id="page">
<template #header>
<div id="menu">
@@ -490,7 +140,7 @@ const items = [
&lt;!&ndash;<router-link to="/customers" class="mr-2"><UButton>Kunden</UButton></router-link>
<router-link to="/projects" class="mr-2"><UButton>Projekte</UButton></router-link>
-
<router-link to="/incominginvoices" class="mr-2"><UButton>Eingangsrechnungen</UButton></router-link>
<router-link to="/receipts" class="mr-2"><UButton>Eingangsrechnungen</UButton></router-link>
<router-link to="/timetracking" class="mr-2"><UButton>Zeiterfassung</UButton></router-link>
<router-link to="/products" class="mr-2"><UButton>Artikel</UButton></router-link>