Introduced ProfileStore
Corrected All Links to DataStore
This commit is contained in:
BIN
RechteDoku.xlsx
Normal file
BIN
RechteDoku.xlsx
Normal file
Binary file not shown.
2
app.vue
2
app.vue
@@ -6,8 +6,6 @@ const tenants = (await supabase.from("tenants").select()).data
|
|||||||
const dataStore = useDataStore()
|
const dataStore = useDataStore()
|
||||||
const viewport = useViewport()
|
const viewport = useViewport()
|
||||||
|
|
||||||
console.log("1.")
|
|
||||||
|
|
||||||
/*watch(viewport.breakpoint, (newBreakpoint, oldBreakpoint) => {
|
/*watch(viewport.breakpoint, (newBreakpoint, oldBreakpoint) => {
|
||||||
console.log('Breakpoint updated:', oldBreakpoint, '->', newBreakpoint)
|
console.log('Breakpoint updated:', oldBreakpoint, '->', newBreakpoint)
|
||||||
})*/
|
})*/
|
||||||
|
|||||||
@@ -3,6 +3,7 @@
|
|||||||
const toast = useToast()
|
const toast = useToast()
|
||||||
const supabase = useSupabaseClient()
|
const supabase = useSupabaseClient()
|
||||||
const dataStore = useDataStore()
|
const dataStore = useDataStore()
|
||||||
|
const profileStore = useProfileStore()
|
||||||
const router = useRouter()
|
const router = useRouter()
|
||||||
const props = defineProps({
|
const props = defineProps({
|
||||||
documentData: {
|
documentData: {
|
||||||
@@ -61,7 +62,7 @@ const createVendorInvoice = async () => {
|
|||||||
.from("incominginvoices")
|
.from("incominginvoices")
|
||||||
.insert([{
|
.insert([{
|
||||||
document: documentData.id,
|
document: documentData.id,
|
||||||
tenant: dataStore.currentTenant
|
tenant: profileStore.currentTenant
|
||||||
}])
|
}])
|
||||||
.select()
|
.select()
|
||||||
if(vendorInvoiceError) {
|
if(vendorInvoiceError) {
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ const props = defineProps({
|
|||||||
const {type, elementId} = props
|
const {type, elementId} = props
|
||||||
|
|
||||||
const dataStore = useDataStore()
|
const dataStore = useDataStore()
|
||||||
|
const profileStore = useProfileStore()
|
||||||
const tags = dataStore.getDocumentTags
|
const tags = dataStore.getDocumentTags
|
||||||
|
|
||||||
const uploadModalOpen = ref(false)
|
const uploadModalOpen = ref(false)
|
||||||
@@ -19,7 +20,7 @@ const uploadInProgress = ref(false)
|
|||||||
const fileUploadFormData = ref({
|
const fileUploadFormData = ref({
|
||||||
tags: ["Dokument"],
|
tags: ["Dokument"],
|
||||||
project: null,
|
project: null,
|
||||||
tenant: dataStore.currentTenant
|
tenant: profileStore.currentTenant
|
||||||
})
|
})
|
||||||
|
|
||||||
const openModal = () => {
|
const openModal = () => {
|
||||||
|
|||||||
@@ -46,6 +46,7 @@ defineShortcuts({
|
|||||||
|
|
||||||
const router = useRouter()
|
const router = useRouter()
|
||||||
const dataStore = useDataStore()
|
const dataStore = useDataStore()
|
||||||
|
const profileStore = useProfileStore()
|
||||||
|
|
||||||
const dataType = dataStore.dataTypes[type]
|
const dataType = dataStore.dataTypes[type]
|
||||||
|
|
||||||
@@ -81,7 +82,7 @@ const filteredRows = computed(() => {
|
|||||||
} else if(useRole().checkRight(type)){
|
} else if(useRole().checkRight(type)){
|
||||||
console.log("Only Righty to show Own")
|
console.log("Only Righty to show Own")
|
||||||
console.log(tempItems)
|
console.log(tempItems)
|
||||||
tempItems = tempItems.filter(item => item.profiles.includes(dataStore.activeProfile.id))
|
tempItems = tempItems.filter(item => item.profiles.includes(profileStore.activeProfile.id))
|
||||||
} else {
|
} else {
|
||||||
console.log("No Right to Show")
|
console.log("No Right to Show")
|
||||||
tempItems = []
|
tempItems = []
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ const { metaSymbol } = useShortcuts()
|
|||||||
|
|
||||||
const shortcuts = ref(false)
|
const shortcuts = ref(false)
|
||||||
const dataStore = useDataStore()
|
const dataStore = useDataStore()
|
||||||
|
const profileStore = useProfileStore()
|
||||||
const query = ref('')
|
const query = ref('')
|
||||||
const supabase = useSupabaseClient()
|
const supabase = useSupabaseClient()
|
||||||
const toast = useToast()
|
const toast = useToast()
|
||||||
@@ -101,12 +102,12 @@ const filteredCategories = computed(() => {
|
|||||||
|
|
||||||
const contactRequestData = ref({
|
const contactRequestData = ref({
|
||||||
source: "helpSlideover",
|
source: "helpSlideover",
|
||||||
tenant: dataStore.currentTenant,
|
tenant: profileStore.currentTenant,
|
||||||
message: "",
|
message: "",
|
||||||
title: "",
|
title: "",
|
||||||
contactName: dataStore.activeProfile.fullName,
|
contactName: profileStore.activeProfile.fullName,
|
||||||
contactTel: dataStore.activeProfile.phoneMobile || dataStore.activeProfile.phoneHome,
|
contactTel: profileStore.activeProfile.phoneMobile || profileStore.activeProfile.phoneHome,
|
||||||
contactMail: dataStore.activeProfile.email,
|
contactMail: profileStore.activeProfile.email,
|
||||||
contactType: "Hilfe",
|
contactType: "Hilfe",
|
||||||
currentPath: router.currentRoute
|
currentPath: router.currentRoute
|
||||||
})
|
})
|
||||||
@@ -125,12 +126,12 @@ const addContactRequest = async () => {
|
|||||||
const resetContactRequest = () => {
|
const resetContactRequest = () => {
|
||||||
contactRequestData.value = {
|
contactRequestData.value = {
|
||||||
source: "helpSlideover",
|
source: "helpSlideover",
|
||||||
tenant: dataStore.currentTenant,
|
tenant: profileStore.currentTenant,
|
||||||
message: "",
|
message: "",
|
||||||
title: "",
|
title: "",
|
||||||
contactName: dataStore.activeProfile.fullName,
|
contactName: profileStore.activeProfile.fullName,
|
||||||
contactTel: dataStore.activeProfile.phoneMobile || dataStore.activeProfile.phoneHome,
|
contactTel: profileStore.activeProfile.phoneMobile || profileStore.activeProfile.phoneHome,
|
||||||
contactMail: dataStore.activeProfile.email,
|
contactMail: profileStore.activeProfile.email,
|
||||||
contactType: "Hilfe"
|
contactType: "Hilfe"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ const props = defineProps({
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
const { metaSymbol } = useShortcuts()
|
const { metaSymbol } = useShortcuts()
|
||||||
const dataStore = useDataStore()
|
const profileStore = useProfileStore()
|
||||||
const user = useSupabaseUser()
|
const user = useSupabaseUser()
|
||||||
const supabase = useSupabaseClient()
|
const supabase = useSupabaseClient()
|
||||||
const toast = useToast()
|
const toast = useToast()
|
||||||
@@ -79,13 +79,13 @@ const addHistoryItemData = ref({
|
|||||||
|
|
||||||
const addHistoryItem = async () => {
|
const addHistoryItem = async () => {
|
||||||
console.log(addHistoryItemData.value)
|
console.log(addHistoryItemData.value)
|
||||||
addHistoryItemData.value.createdBy = dataStore.activeProfile.id
|
addHistoryItemData.value.createdBy = profileStore.activeProfile.id
|
||||||
|
|
||||||
addHistoryItemData.value[type] = elementId
|
addHistoryItemData.value[type] = elementId
|
||||||
|
|
||||||
const {data,error} = await supabase
|
const {data,error} = await supabase
|
||||||
.from("historyitems")
|
.from("historyitems")
|
||||||
.insert([{...addHistoryItemData.value, tenant: dataStore.currentTenant}])
|
.insert([{...addHistoryItemData.value, tenant: profileStore.currentTenant}])
|
||||||
.select()
|
.select()
|
||||||
|
|
||||||
if(error) {
|
if(error) {
|
||||||
@@ -100,9 +100,9 @@ const addHistoryItem = async () => {
|
|||||||
let rawUsername = i[1]
|
let rawUsername = i[1]
|
||||||
|
|
||||||
return {
|
return {
|
||||||
tenant: dataStore.currentTenant,
|
tenant: profileStore.currentTenant,
|
||||||
profile: profiles.find(x => x.username === rawUsername).id,
|
profile: profiles.find(x => x.username === rawUsername).id,
|
||||||
initiatingProfile: dataStore.activeProfile.id,
|
initiatingProfile: profileStore.activeProfile.id,
|
||||||
title: "Sie wurden im Logbuch erwähnt",
|
title: "Sie wurden im Logbuch erwähnt",
|
||||||
link: `/${type}s/show/${elementId}`,
|
link: `/${type}s/show/${elementId}`,
|
||||||
message: addHistoryItemData.value.text
|
message: addHistoryItemData.value.text
|
||||||
@@ -198,11 +198,11 @@ const renderText = (text) => {
|
|||||||
:src="colorMode.value === 'light' ? '/Logo.png' : '/Logo_Dark.png' "
|
:src="colorMode.value === 'light' ? '/Logo.png' : '/Logo_Dark.png' "
|
||||||
/>
|
/>
|
||||||
<UAvatar
|
<UAvatar
|
||||||
:alt="dataStore.getProfileById(item.createdBy).fullName"
|
:alt="profileStore.getProfileById(item.createdBy).fullName"
|
||||||
v-else
|
v-else
|
||||||
/>
|
/>
|
||||||
<div>
|
<div>
|
||||||
<h3 v-if="item.createdBy">{{dataStore.getProfileById(item.createdBy) ? dataStore.getProfileById(item.createdBy).fullName : ""}}</h3>
|
<h3 v-if="item.createdBy">{{profileStore.getProfileById(item.createdBy) ? profileStore.getProfileById(item.createdBy).fullName : ""}}</h3>
|
||||||
<h3 v-else>FEDEO Bot</h3>
|
<h3 v-else>FEDEO Bot</h3>
|
||||||
<span v-html="renderText(item.text)"/><br>
|
<span v-html="renderText(item.text)"/><br>
|
||||||
<span class="text-gray-500">{{dayjs(item.created_at).format("DD.MM.YY HH:mm")}}</span>
|
<span class="text-gray-500">{{dayjs(item.created_at).format("DD.MM.YY HH:mm")}}</span>
|
||||||
|
|||||||
@@ -1,13 +1,10 @@
|
|||||||
<script setup>
|
<script setup>
|
||||||
import {useRole} from "~/composables/useRole.js";
|
import {useRole} from "~/composables/useRole.js";
|
||||||
|
|
||||||
const dataStore = useDataStore()
|
const profileStore = useProfileStore()
|
||||||
const route = useRoute()
|
const route = useRoute()
|
||||||
|
|
||||||
const role = useRole()
|
const role = useRole()
|
||||||
console.log(role)
|
|
||||||
console.log(role.checkRight("projects"))
|
|
||||||
|
|
||||||
const links = computed(() => {
|
const links = computed(() => {
|
||||||
return [
|
return [
|
||||||
{
|
{
|
||||||
@@ -26,17 +23,17 @@ const links = computed(() => {
|
|||||||
to: "/tasks",
|
to: "/tasks",
|
||||||
icon: "i-heroicons-rectangle-stack"
|
icon: "i-heroicons-rectangle-stack"
|
||||||
},
|
},
|
||||||
... dataStore.ownTenant.features.planningBoard ? [{
|
... profileStore.ownTenant.features.planningBoard ? [{
|
||||||
label: "Plantafel",
|
label: "Plantafel",
|
||||||
to: "/calendar/timeline",
|
to: "/calendar/timeline",
|
||||||
icon: "i-heroicons-calendar-days"
|
icon: "i-heroicons-calendar-days"
|
||||||
}] : [],
|
}] : [],
|
||||||
... dataStore.ownTenant.features.calendar ? [{
|
... profileStore.ownTenant.features.calendar ? [{
|
||||||
label: "Kalender",
|
label: "Kalender",
|
||||||
to: "/calendar/grid",
|
to: "/calendar/grid",
|
||||||
icon: "i-heroicons-calendar-days"
|
icon: "i-heroicons-calendar-days"
|
||||||
}] : [],
|
}] : [],
|
||||||
... dataStore.ownTenant.features.calendar ? [{
|
... profileStore.ownTenant.features.calendar ? [{
|
||||||
label: "Termine",
|
label: "Termine",
|
||||||
to: "/events",
|
to: "/events",
|
||||||
icon: "i-heroicons-calendar-days"
|
icon: "i-heroicons-calendar-days"
|
||||||
@@ -68,7 +65,7 @@ const links = computed(() => {
|
|||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
... dataStore.ownTenant.features.contacts ? [{
|
... profileStore.ownTenant.features.contacts ? [{
|
||||||
label: "Kontakte",
|
label: "Kontakte",
|
||||||
defaultOpen: false,
|
defaultOpen: false,
|
||||||
icon: "i-heroicons-user-group",
|
icon: "i-heroicons-user-group",
|
||||||
@@ -95,12 +92,12 @@ const links = computed(() => {
|
|||||||
defaultOpen:false,
|
defaultOpen:false,
|
||||||
icon: "i-heroicons-user-group",
|
icon: "i-heroicons-user-group",
|
||||||
children: [
|
children: [
|
||||||
... dataStore.ownTenant.features.timeTracking ? [{
|
... profileStore.ownTenant.features.timeTracking ? [{
|
||||||
label: "Zeiterfassung",
|
label: "Zeiterfassung",
|
||||||
to: "/employees/timetracking",
|
to: "/employees/timetracking",
|
||||||
icon: "i-heroicons-clock"
|
icon: "i-heroicons-clock"
|
||||||
}] : [],
|
}] : [],
|
||||||
... dataStore.ownTenant.features.workingTimeTracking ? [{
|
... profileStore.ownTenant.features.workingTimeTracking ? [{
|
||||||
label: "Anwesenheiten",
|
label: "Anwesenheiten",
|
||||||
to: "/workingtimes",
|
to: "/workingtimes",
|
||||||
icon: "i-heroicons-clock"
|
icon: "i-heroicons-clock"
|
||||||
@@ -112,7 +109,7 @@ const links = computed(() => {
|
|||||||
},
|
},
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
... dataStore.ownTenant.features.accounting ? [{
|
... profileStore.ownTenant.features.accounting ? [{
|
||||||
label: "Buchhaltung",
|
label: "Buchhaltung",
|
||||||
defaultOpen: false,
|
defaultOpen: false,
|
||||||
icon: "i-heroicons-chart-bar-square",
|
icon: "i-heroicons-chart-bar-square",
|
||||||
|
|||||||
@@ -1,30 +1,29 @@
|
|||||||
<script setup>
|
<script setup>
|
||||||
const dataStore = useDataStore()
|
const dataStore = useDataStore()
|
||||||
|
const profileStore = useProfileStore()
|
||||||
const supabase = useSupabaseClient()
|
const supabase = useSupabaseClient()
|
||||||
//const tenants = ref(dataStore.getOwnProfile ? dataStore.getOwnProfile.tenants : [])
|
|
||||||
//const tenant = ref(dataStore.currentTenant)
|
|
||||||
|
|
||||||
const selectedProfile = ref(dataStore.activeProfile.id)
|
const selectedProfile = ref(profileStore.activeProfile.id)
|
||||||
|
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<USelectMenu
|
<USelectMenu
|
||||||
:options="dataStore.ownProfiles"
|
:options="profileStore.ownProfiles"
|
||||||
value-attribute="id"
|
value-attribute="id"
|
||||||
class="w-40"
|
class="w-40"
|
||||||
@change="dataStore.changeProfile(selectedProfile)"
|
@change="profileStore.changeProfile(selectedProfile)"
|
||||||
v-model="selectedProfile"
|
v-model="selectedProfile"
|
||||||
>
|
>
|
||||||
<UButton color="gray" variant="ghost" :class="[open && 'bg-gray-50 dark:bg-gray-800']" class="w-full">
|
<UButton color="gray" variant="ghost" :class="[open && 'bg-gray-50 dark:bg-gray-800']" class="w-full">
|
||||||
<UAvatar :alt="dataStore.tenants.find(i => dataStore.getProfileById(selectedProfile).tenant === i.id).name" size="md" />
|
<UAvatar :alt="profileStore.tenants.find(i => profileStore.profiles.find(i => i.id === selectedProfile).tenant === i.id).name" size="md" />
|
||||||
|
|
||||||
<span class="truncate text-gray-900 dark:text-white font-semibold">{{dataStore.tenants.find(i => dataStore.getProfileById(selectedProfile).tenant === i.id).name}}</span>
|
<span class="truncate text-gray-900 dark:text-white font-semibold">{{profileStore.tenants.find(i => profileStore.profiles.find(i => i.id === selectedProfile).tenant === i.id).name}}</span>
|
||||||
</UButton>
|
</UButton>
|
||||||
|
|
||||||
<template #option="{option}">
|
<template #option="{option}">
|
||||||
{{dataStore.tenants.find(i => i.id === option.tenant).name}}
|
{{profileStore.tenants.find(i => i.id === option.tenant).name}}
|
||||||
</template>
|
</template>
|
||||||
</USelectMenu>
|
</USelectMenu>
|
||||||
</template>
|
</template>
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
<script setup>
|
<script setup>
|
||||||
|
|
||||||
const dataStore = useDataStore()
|
const profileStore = useProfileStore()
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -9,11 +9,11 @@ const dataStore = useDataStore()
|
|||||||
<template>
|
<template>
|
||||||
<div class="w-1/2 mx-auto">
|
<div class="w-1/2 mx-auto">
|
||||||
<p class="text-2xl mb-5 text-center">Bitte wähle dein gewünschtes Profil</p>
|
<p class="text-2xl mb-5 text-center">Bitte wähle dein gewünschtes Profil</p>
|
||||||
<div v-for="profile in dataStore.ownProfiles" class="flex justify-between my-3">
|
<div v-for="profile in profileStore.ownProfiles" class="flex justify-between my-3">
|
||||||
{{dataStore.tenants.find(i => i.id === profile.tenant).name}}
|
{{profileStore.tenants.find(i => i.id === profile.tenant).name}}
|
||||||
<UButton
|
<UButton
|
||||||
variant="outline"
|
variant="outline"
|
||||||
@click="dataStore.changeProfile(profile.id)"
|
@click="profileStore.changeProfile(profile.id)"
|
||||||
>Auswählen</UButton>
|
>Auswählen</UButton>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -1,9 +1,10 @@
|
|||||||
<script setup lang="ts">
|
<script setup>
|
||||||
const { isHelpSlideoverOpen } = useDashboard()
|
const { isHelpSlideoverOpen } = useDashboard()
|
||||||
const { isDashboardSearchModalOpen } = useUIState()
|
const { isDashboardSearchModalOpen } = useUIState()
|
||||||
const { metaSymbol } = useShortcuts()
|
const { metaSymbol } = useShortcuts()
|
||||||
const user = useSupabaseUser()
|
const user = useSupabaseUser()
|
||||||
const dataStore = useDataStore()
|
const dataStore = useDataStore()
|
||||||
|
const profileStore = useProfileStore()
|
||||||
const supabase = useSupabaseClient()
|
const supabase = useSupabaseClient()
|
||||||
const router = useRouter()
|
const router = useRouter()
|
||||||
|
|
||||||
@@ -15,13 +16,13 @@ const items = computed(() => [
|
|||||||
}], [{
|
}], [{
|
||||||
label: 'Mein Profil',
|
label: 'Mein Profil',
|
||||||
icon: 'i-heroicons-user',
|
icon: 'i-heroicons-user',
|
||||||
to: `/profiles/show/${dataStore.activeProfile.id}`
|
to: `/profiles/show/${profileStore.activeProfile.id}`
|
||||||
},{
|
},{
|
||||||
label: 'Abmelden',
|
label: 'Abmelden',
|
||||||
icon: 'i-heroicons-arrow-left-on-rectangle',
|
icon: 'i-heroicons-arrow-left-on-rectangle',
|
||||||
click: async () => {
|
click: async () => {
|
||||||
await supabase.auth.signOut()
|
await supabase.auth.signOut()
|
||||||
await dataStore.clearStore()
|
//await dataStore.clearStore()
|
||||||
await router.push('/login')
|
await router.push('/login')
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -32,9 +33,9 @@ const items = computed(() => [
|
|||||||
<template>
|
<template>
|
||||||
<UDropdown mode="hover" :items="items" :ui="{ width: 'w-full', item: { disabled: 'cursor-text select-text' } }" :popper="{ strategy: 'absolute', placement: 'top' }" class="w-full">
|
<UDropdown mode="hover" :items="items" :ui="{ width: 'w-full', item: { disabled: 'cursor-text select-text' } }" :popper="{ strategy: 'absolute', placement: 'top' }" class="w-full">
|
||||||
<template #default="{ open }">
|
<template #default="{ open }">
|
||||||
<UButton color="gray" variant="ghost" class="w-full" :label="dataStore.activeProfile.fullName" :class="[open && 'bg-gray-50 dark:bg-gray-800']">
|
<UButton color="gray" variant="ghost" class="w-full" :label="profileStore.activeProfile.fullName" :class="[open && 'bg-gray-50 dark:bg-gray-800']">
|
||||||
<template #leading>
|
<template #leading>
|
||||||
<UAvatar :alt="dataStore.activeProfile ? dataStore.activeProfile.fullName : ''" size="xs" />
|
<UAvatar :alt="profileStore.activeProfile ? profileStore.activeProfile.fullName : ''" size="xs" />
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<template #trailing>
|
<template #trailing>
|
||||||
@@ -49,7 +50,7 @@ const items = computed(() => [
|
|||||||
Angemeldet als
|
Angemeldet als
|
||||||
</p>
|
</p>
|
||||||
<p class="truncate font-medium text-gray-900 dark:text-white">
|
<p class="truncate font-medium text-gray-900 dark:text-white">
|
||||||
{{dataStore.activeProfile.email}}
|
{{profileStore.activeProfile.email}}
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|||||||
@@ -6,13 +6,14 @@ dayjs.extend(customParseFormat)
|
|||||||
|
|
||||||
const supabase = useSupabaseClient()
|
const supabase = useSupabaseClient()
|
||||||
const dataStore = useDataStore()
|
const dataStore = useDataStore()
|
||||||
|
const profileStore = useProfileStore()
|
||||||
|
|
||||||
let incomeData = ref({})
|
let incomeData = ref({})
|
||||||
let expenseData = ref({})
|
let expenseData = ref({})
|
||||||
|
|
||||||
const setup = async () => {
|
const setup = async () => {
|
||||||
let incomeRawData = (await supabase.from("createddocuments").select().eq("tenant",dataStore.currentTenant).in('type',['invoices'])).data
|
let incomeRawData = (await supabase.from("createddocuments").select().eq("tenant",profileStore.currentTenant).in('type',['invoices'])).data
|
||||||
let expenseRawData =(await supabase.from("incominginvoices").select().eq("tenant",dataStore.currentTenant)).data
|
let expenseRawData =(await supabase.from("incominginvoices").select().eq("tenant",profileStore.currentTenant)).data
|
||||||
|
|
||||||
expenseRawData = expenseRawData.filter(i => i.date).map(i => {
|
expenseRawData = expenseRawData.filter(i => i.date).map(i => {
|
||||||
let amount = 0
|
let amount = 0
|
||||||
|
|||||||
@@ -3,8 +3,9 @@ export const useNumberRange = (resourceType) => {
|
|||||||
const supabase = useSupabaseClient()
|
const supabase = useSupabaseClient()
|
||||||
|
|
||||||
const dataStore = useDataStore()
|
const dataStore = useDataStore()
|
||||||
|
const profileStore = useProfileStore()
|
||||||
|
|
||||||
const numberRanges = dataStore.ownTenant.numberRanges
|
const numberRanges = profileStore.ownTenant.numberRanges
|
||||||
|
|
||||||
const numberRange = numberRanges[resourceType]
|
const numberRange = numberRanges[resourceType]
|
||||||
|
|
||||||
@@ -19,7 +20,7 @@ export const useNumberRange = (resourceType) => {
|
|||||||
const {data,error} = await supabase
|
const {data,error} = await supabase
|
||||||
.from("tenants")
|
.from("tenants")
|
||||||
.update({numberRanges: newNumberRanges})
|
.update({numberRanges: newNumberRanges})
|
||||||
.eq('id',dataStore.currentTenant)
|
.eq('id',profileStore.currentTenant)
|
||||||
|
|
||||||
|
|
||||||
dataStore.fetchOwnTenant()
|
dataStore.fetchOwnTenant()
|
||||||
|
|||||||
@@ -4,9 +4,10 @@ import Handlebars from "handlebars";
|
|||||||
export const usePrintLabel = async (printServerId,printerName , rawZPL ) => {
|
export const usePrintLabel = async (printServerId,printerName , rawZPL ) => {
|
||||||
const supabase = useSupabaseClient()
|
const supabase = useSupabaseClient()
|
||||||
const dataStore = useDataStore()
|
const dataStore = useDataStore()
|
||||||
|
const profileStore = useProfileStore()
|
||||||
|
|
||||||
await supabase.from("printJobs").insert({
|
await supabase.from("printJobs").insert({
|
||||||
tenant: dataStore.currentTenant,
|
tenant: profileStore.currentTenant,
|
||||||
rawContent: rawZPL,
|
rawContent: rawZPL,
|
||||||
printerName: printerName,
|
printerName: printerName,
|
||||||
printServer: printServerId
|
printServer: printServerId
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
|
|
||||||
|
|
||||||
export const useRole = () => {
|
export const useRole = () => {
|
||||||
const dataStore = useDataStore()
|
const profileStore = useProfileStore()
|
||||||
|
|
||||||
|
|
||||||
const generalAvailableRights = ref({
|
const generalAvailableRights = ref({
|
||||||
@@ -178,7 +178,7 @@ export const useRole = () => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
let role = dataStore.activeProfile.role
|
let role = profileStore.activeProfile.role
|
||||||
|
|
||||||
const checkRight = (right) => {
|
const checkRight = (right) => {
|
||||||
let rightsToCheck = [right]
|
let rightsToCheck = [right]
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
export const useSupabaseSelect = async (relation,select = '*', sortColumn = null, ascending = true) => {
|
export const useSupabaseSelect = async (relation,select = '*', sortColumn = null, ascending = true) => {
|
||||||
const supabase = useSupabaseClient()
|
const supabase = useSupabaseClient()
|
||||||
const dataStore = useDataStore()
|
const profileStore = useProfileStore()
|
||||||
let data = null
|
let data = null
|
||||||
|
|
||||||
|
|
||||||
@@ -10,13 +10,13 @@ export const useSupabaseSelect = async (relation,select = '*', sortColumn = null
|
|||||||
data = (await supabase
|
data = (await supabase
|
||||||
.from(relation)
|
.from(relation)
|
||||||
.select(select)
|
.select(select)
|
||||||
.eq("tenant", dataStore.currentTenant)
|
.eq("tenant", profileStore.currentTenant)
|
||||||
.order(sortColumn, {ascending: ascending})).data
|
.order(sortColumn, {ascending: ascending})).data
|
||||||
} else {
|
} else {
|
||||||
data = (await supabase
|
data = (await supabase
|
||||||
.from(relation)
|
.from(relation)
|
||||||
.select(select)
|
.select(select)
|
||||||
.eq("tenant", dataStore.currentTenant)).data
|
.eq("tenant", profileStore.currentTenant)).data
|
||||||
}
|
}
|
||||||
|
|
||||||
return data
|
return data
|
||||||
@@ -24,7 +24,8 @@ export const useSupabaseSelect = async (relation,select = '*', sortColumn = null
|
|||||||
|
|
||||||
export const useSupabaseSelectDocuments = async (select = '*', sortColumn = null, folderPath = "_") => {
|
export const useSupabaseSelectDocuments = async (select = '*', sortColumn = null, folderPath = "_") => {
|
||||||
const supabase = useSupabaseClient()
|
const supabase = useSupabaseClient()
|
||||||
const dataStore = useDataStore()
|
const profileStore = useProfileStore()
|
||||||
|
|
||||||
let data = null
|
let data = null
|
||||||
|
|
||||||
|
|
||||||
@@ -32,13 +33,13 @@ export const useSupabaseSelectDocuments = async (select = '*', sortColumn = null
|
|||||||
data = (await supabase
|
data = (await supabase
|
||||||
.from("documents")
|
.from("documents")
|
||||||
.select(select)
|
.select(select)
|
||||||
.eq("tenant", dataStore.currentTenant)
|
.eq("tenant", profileStore.currentTenant)
|
||||||
.order(sortColumn, {ascending: true})).data
|
.order(sortColumn, {ascending: true})).data
|
||||||
} else {
|
} else {
|
||||||
data = (await supabase
|
data = (await supabase
|
||||||
.from("documents")
|
.from("documents")
|
||||||
.select(select)
|
.select(select)
|
||||||
.eq("tenant", dataStore.currentTenant)).data
|
.eq("tenant", profileStore.currentTenant)).data
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -68,7 +69,7 @@ export const useSupabaseSelectDocuments = async (select = '*', sortColumn = null
|
|||||||
|
|
||||||
export const useSupabaseSelectSingle = async (relation,idToEq,select = '*' ) => {
|
export const useSupabaseSelectSingle = async (relation,idToEq,select = '*' ) => {
|
||||||
const supabase = useSupabaseClient()
|
const supabase = useSupabaseClient()
|
||||||
const dataStore = useDataStore()
|
const profileStore = useProfileStore()
|
||||||
let data = null
|
let data = null
|
||||||
|
|
||||||
|
|
||||||
@@ -76,14 +77,14 @@ export const useSupabaseSelectSingle = async (relation,idToEq,select = '*' ) =>
|
|||||||
data = (await supabase
|
data = (await supabase
|
||||||
.from(relation)
|
.from(relation)
|
||||||
.select(select)
|
.select(select)
|
||||||
.eq("tenant", dataStore.currentTenant)
|
.eq("tenant", profileStore.currentTenant)
|
||||||
.eq("id",idToEq)
|
.eq("id",idToEq)
|
||||||
.single()).data
|
.single()).data
|
||||||
} else {
|
} else {
|
||||||
data = (await supabase
|
data = (await supabase
|
||||||
.from(relation)
|
.from(relation)
|
||||||
.select(select)
|
.select(select)
|
||||||
.eq("tenant", dataStore.currentTenant)
|
.eq("tenant", profileStore.currentTenant)
|
||||||
.single()).data
|
.single()).data
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -3,398 +3,20 @@
|
|||||||
|
|
||||||
import MainNav from "~/components/MainNav.vue";
|
import MainNav from "~/components/MainNav.vue";
|
||||||
import dayjs from "dayjs";
|
import dayjs from "dayjs";
|
||||||
|
import {useProfileStore} from "~/stores/profile.js";
|
||||||
|
|
||||||
const dataStore = useDataStore()
|
const dataStore = useDataStore()
|
||||||
|
const profileStore = useProfileStore()
|
||||||
const colorMode = useColorMode()
|
const colorMode = useColorMode()
|
||||||
const { isHelpSlideoverOpen } = useDashboard()
|
const { isHelpSlideoverOpen } = useDashboard()
|
||||||
const supabase = useSupabaseClient()
|
const supabase = useSupabaseClient()
|
||||||
const router = useRouter()
|
const router = useRouter()
|
||||||
const route = useRoute()
|
const route = useRoute()
|
||||||
|
|
||||||
console.log("2.")
|
profileStore.initializeData((await supabase.auth.getUser()).data.user.id)
|
||||||
|
|
||||||
dataStore.initializeData((await supabase.auth.getUser()).data.user.id)
|
|
||||||
|
|
||||||
const month = dayjs().format("MM")
|
const month = dayjs().format("MM")
|
||||||
|
|
||||||
|
|
||||||
/*const isLight = computed({
|
|
||||||
get() {
|
|
||||||
return colorMode.value !== 'dark'
|
|
||||||
},
|
|
||||||
set() {
|
|
||||||
colorMode.preference = colorMode.value === 'dark' ? 'light' : 'dark'
|
|
||||||
}
|
|
||||||
})
|
|
||||||
|
|
||||||
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: "Belege",
|
|
||||||
to: "/receipts",
|
|
||||||
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: "E-Mail",
|
|
||||||
to: "/email",
|
|
||||||
icon: "i-heroicons-envelope"
|
|
||||||
},
|
|
||||||
]
|
|
||||||
},/!*
|
|
||||||
{
|
|
||||||
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: "Anwesenheiten",
|
|
||||||
to: "/workingtimes",
|
|
||||||
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"
|
|
||||||
}, {
|
|
||||||
label: "Inventar",
|
|
||||||
to: "/inventoryitems",
|
|
||||||
icon: "i-heroicons-puzzle-piece"
|
|
||||||
},
|
|
||||||
]
|
|
||||||
},
|
|
||||||
]*/
|
|
||||||
|
|
||||||
//const activeFeatures = dataStore.tenants.find(dataStore.currentTenant).features
|
|
||||||
|
|
||||||
let links = computed(() => {
|
|
||||||
return [
|
|
||||||
{
|
|
||||||
id: 'dashboard',
|
|
||||||
label: "Dashboard",
|
|
||||||
to: "/",
|
|
||||||
icon: "i-heroicons-home"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
label: "Organisation",
|
|
||||||
icon: "i-heroicons-rectangle-stack",
|
|
||||||
defaultOpen: false,
|
|
||||||
children: [
|
|
||||||
{
|
|
||||||
label: "Aufgaben",
|
|
||||||
to: "/tasks",
|
|
||||||
icon: "i-heroicons-rectangle-stack"
|
|
||||||
},
|
|
||||||
... dataStore.ownTenant.features.planningBoard ? [{
|
|
||||||
label: "Plantafel",
|
|
||||||
to: "/calendar/timeline",
|
|
||||||
icon: "i-heroicons-calendar-days"
|
|
||||||
}] : [],
|
|
||||||
... dataStore.ownTenant.features.calendar ? [{
|
|
||||||
label: "Kalender",
|
|
||||||
to: "/calendar/grid",
|
|
||||||
icon: "i-heroicons-calendar-days"
|
|
||||||
}] : [],
|
|
||||||
... dataStore.ownTenant.features.calendar ? [{
|
|
||||||
label: "Termine",
|
|
||||||
to: "/events",
|
|
||||||
icon: "i-heroicons-calendar-days"
|
|
||||||
}] : [],
|
|
||||||
{
|
|
||||||
label: "Dokumente",
|
|
||||||
to: "/documents",
|
|
||||||
icon: "i-heroicons-document"
|
|
||||||
},
|
|
||||||
]
|
|
||||||
},
|
|
||||||
/*{
|
|
||||||
label: "E-Mail",
|
|
||||||
to: "/email",
|
|
||||||
icon: "i-heroicons-envelope"
|
|
||||||
},*/
|
|
||||||
... dataStore.ownTenant.features.contacts ? [{
|
|
||||||
label: "Kontakte",
|
|
||||||
defaultOpen: false,
|
|
||||||
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: "Mitarbeiter",
|
|
||||||
defaultOpen:false,
|
|
||||||
icon: "i-heroicons-user-group",
|
|
||||||
children: [
|
|
||||||
... dataStore.ownTenant.features.timeTracking ? [{
|
|
||||||
label: "Zeiterfassung",
|
|
||||||
to: "/employees/timetracking",
|
|
||||||
icon: "i-heroicons-clock"
|
|
||||||
}] : [],
|
|
||||||
... dataStore.ownTenant.features.workingTimeTracking ? [{
|
|
||||||
label: "Anwesenheiten",
|
|
||||||
to: "/workingtimes",
|
|
||||||
icon: "i-heroicons-clock"
|
|
||||||
}] : [],
|
|
||||||
{
|
|
||||||
label: "Abwesenheiten",
|
|
||||||
to: "/absenceRequests",
|
|
||||||
icon: "i-heroicons-document-text"
|
|
||||||
},
|
|
||||||
]
|
|
||||||
},
|
|
||||||
... dataStore.ownTenant.features.accounting ? [{
|
|
||||||
label: "Buchhaltung",
|
|
||||||
defaultOpen: false,
|
|
||||||
icon: "i-heroicons-chart-bar-square",
|
|
||||||
children: [
|
|
||||||
{
|
|
||||||
label: "Ausgangsbelege",
|
|
||||||
to: "/createDocument",
|
|
||||||
icon: "i-heroicons-document-text"
|
|
||||||
},{
|
|
||||||
label: "Eingangsbelege",
|
|
||||||
to: "/incomingInvoices",
|
|
||||||
icon: "i-heroicons-document-text"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
label: "Bank",
|
|
||||||
to: "/banking",
|
|
||||||
icon: "i-heroicons-document-text"
|
|
||||||
},
|
|
||||||
]
|
|
||||||
},] : [],
|
|
||||||
... dataStore.ownTenant.features.inventory ? [{
|
|
||||||
label: "Lager",
|
|
||||||
icon: "i-heroicons-puzzle-piece",
|
|
||||||
defaultOpen: false,
|
|
||||||
children: [
|
|
||||||
{
|
|
||||||
label: "Vorgänge",
|
|
||||||
to: "/inventory",
|
|
||||||
icon: "i-heroicons-square-3-stack-3d"
|
|
||||||
},{
|
|
||||||
label: "Bestände",
|
|
||||||
to: "/inventory/stocks",
|
|
||||||
icon: "i-heroicons-square-3-stack-3d"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
label: "Lagerplätze",
|
|
||||||
to: "/spaces",
|
|
||||||
icon: "i-heroicons-square-3-stack-3d"
|
|
||||||
},
|
|
||||||
]
|
|
||||||
},] : [],
|
|
||||||
{
|
|
||||||
label: "Inventar",
|
|
||||||
to: "/inventoryitems",
|
|
||||||
icon: "i-heroicons-puzzle-piece"
|
|
||||||
},
|
|
||||||
... dataStore.ownTenant.features.vehicles ? [{
|
|
||||||
label: "Fahrzeuge",
|
|
||||||
to: "/vehicles",
|
|
||||||
icon: "i-heroicons-truck",
|
|
||||||
}] : [],
|
|
||||||
{
|
|
||||||
label: "Stammdaten",
|
|
||||||
defaultOpen: false,
|
|
||||||
icon: "i-heroicons-clipboard-document",
|
|
||||||
children: [
|
|
||||||
{
|
|
||||||
label: "Artikelstamm",
|
|
||||||
to: "/products",
|
|
||||||
icon: "i-heroicons-puzzle-piece"
|
|
||||||
},{
|
|
||||||
label: "Leistungsstamm",
|
|
||||||
to: "/services",
|
|
||||||
icon: "i-heroicons-puzzle-piece"
|
|
||||||
},
|
|
||||||
|
|
||||||
]
|
|
||||||
},
|
|
||||||
... dataStore.ownTenant.features.projects ? [{
|
|
||||||
label: "Projekte",
|
|
||||||
to: "/projects",
|
|
||||||
icon: "i-heroicons-clipboard-document-check"
|
|
||||||
},] : [],
|
|
||||||
... dataStore.ownTenant.features.contracts ? [{
|
|
||||||
label: "Verträge",
|
|
||||||
to: "/contracts",
|
|
||||||
icon: "i-heroicons-clipboard-document"
|
|
||||||
}] : [],
|
|
||||||
... dataStore.ownTenant.features.objects ? [{
|
|
||||||
label: "Objekte",
|
|
||||||
to: "/plants",
|
|
||||||
icon: "i-heroicons-clipboard-document"
|
|
||||||
},] : [],
|
|
||||||
|
|
||||||
{
|
|
||||||
label: "Einstellungen",
|
|
||||||
defaultOpen: false,
|
|
||||||
icon: "i-heroicons-cog-8-tooth",
|
|
||||||
children: [
|
|
||||||
{
|
|
||||||
label: "Nummernkreise",
|
|
||||||
to: "/settings/numberRanges",
|
|
||||||
icon: "i-heroicons-clipboard-document-list"
|
|
||||||
},{
|
|
||||||
label: "Mitarbeiter",
|
|
||||||
to: "/profiles",
|
|
||||||
icon: "i-heroicons-clipboard-document-list"
|
|
||||||
},{
|
|
||||||
label: "Bankkonten",
|
|
||||||
to: "/settings/banking",
|
|
||||||
icon: "i-heroicons-clipboard-document-list"
|
|
||||||
},{
|
|
||||||
label: "Text Vorlagen",
|
|
||||||
to: "/settings/texttemplates",
|
|
||||||
icon: "i-heroicons-clipboard-document-list"
|
|
||||||
},{
|
|
||||||
label: "Eigene Felder",
|
|
||||||
to: "/settings/ownfields",
|
|
||||||
icon: "i-heroicons-clipboard-document-list"
|
|
||||||
},{
|
|
||||||
label: "Firmeneinstellungen",
|
|
||||||
to: "/settings/tenant",
|
|
||||||
icon: "i-heroicons-clipboard-document-list"
|
|
||||||
},{
|
|
||||||
label: "Reparaturprozesse",
|
|
||||||
to: "/repairs/prozess/",
|
|
||||||
icon: "i-heroicons-bars-3-solid"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
]
|
|
||||||
})
|
|
||||||
|
|
||||||
const actions = [
|
const actions = [
|
||||||
{
|
{
|
||||||
id: 'new-customer',
|
id: 'new-customer',
|
||||||
@@ -489,7 +111,7 @@ const footerLinks = [/*{
|
|||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<UDashboardLayout v-if="dataStore.loaded">
|
<UDashboardLayout v-if="profileStore.loaded">
|
||||||
|
|
||||||
<UDashboardPanel :width="250" :resizable="{ min: 200, max: 300 }" collapsible>
|
<UDashboardPanel :width="250" :resizable="{ min: 200, max: 300 }" collapsible>
|
||||||
<UDashboardNavbar class="!border-transparent" :ui="{ left: 'flex-1' }">
|
<UDashboardNavbar class="!border-transparent" :ui="{ left: 'flex-1' }">
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ definePageMeta({
|
|||||||
})
|
})
|
||||||
|
|
||||||
const dataStore = useDataStore()
|
const dataStore = useDataStore()
|
||||||
|
const profileStore = useProfileStore()
|
||||||
const route = useRoute()
|
const route = useRoute()
|
||||||
const router = useRouter()
|
const router = useRouter()
|
||||||
const toast = useToast()
|
const toast = useToast()
|
||||||
@@ -110,7 +111,7 @@ setupPage()
|
|||||||
<UCard class="mt-5">
|
<UCard class="mt-5">
|
||||||
<div v-if="item.label === 'Informationen'">
|
<div v-if="item.label === 'Informationen'">
|
||||||
<div class="truncate">
|
<div class="truncate">
|
||||||
<p>Mitarbeiter: {{dataStore.profiles.find(item => item.id === itemInfo.user) ? dataStore.profiles.find(item => item.id === itemInfo.user).fullName : ""}}</p>
|
<p>Mitarbeiter: {{profileStore.profiles.find(item => item.id === itemInfo.user) ? profileStore.profiles.find(item => item.id === itemInfo.user).fullName : ""}}</p>
|
||||||
<p>Start: {{dayjs(itemInfo.start).format("DD.MM.YYYY")}}</p>
|
<p>Start: {{dayjs(itemInfo.start).format("DD.MM.YYYY")}}</p>
|
||||||
<p>Ende: {{dayjs(itemInfo.end).format("DD.MM.YYYY")}}</p>
|
<p>Ende: {{dayjs(itemInfo.end).format("DD.MM.YYYY")}}</p>
|
||||||
<p>Grund: {{itemInfo.reason}}</p>
|
<p>Grund: {{itemInfo.reason}}</p>
|
||||||
@@ -151,14 +152,14 @@ setupPage()
|
|||||||
>
|
>
|
||||||
<USelectMenu
|
<USelectMenu
|
||||||
v-model="itemInfo.user"
|
v-model="itemInfo.user"
|
||||||
:options="dataStore.profiles"
|
:options="profileStore.profiles"
|
||||||
option-attribute="fullName"
|
option-attribute="fullName"
|
||||||
value-attribute="id"
|
value-attribute="id"
|
||||||
searchable
|
searchable
|
||||||
:search-attributes="['fullName']"
|
:search-attributes="['fullName']"
|
||||||
>
|
>
|
||||||
<template #label>
|
<template #label>
|
||||||
{{dataStore.getProfileById(itemInfo.user) ? dataStore.getProfileById(itemInfo.user).fullName : "Mitarbeiter auswählen"}}
|
{{profileStore.getProfileById(itemInfo.user) ? profileStore.getProfileById(itemInfo.user).fullName : "Mitarbeiter auswählen"}}
|
||||||
</template>
|
</template>
|
||||||
</USelectMenu>
|
</USelectMenu>
|
||||||
</UFormGroup>
|
</UFormGroup>
|
||||||
|
|||||||
@@ -61,7 +61,7 @@
|
|||||||
</span>
|
</span>
|
||||||
</template>
|
</template>
|
||||||
<template #user-data="{row}">
|
<template #user-data="{row}">
|
||||||
{{dataStore.profiles.find(profile => profile.id === row.user) ? dataStore.profiles.find(profile => profile.id === row.user).fullName : ""}}
|
{{profileStore.profiles.find(profile => profile.id === row.user) ? profileStore.profiles.find(profile => profile.id === row.user).fullName : ""}}
|
||||||
</template>
|
</template>
|
||||||
</UTable>
|
</UTable>
|
||||||
</template>
|
</template>
|
||||||
@@ -84,6 +84,7 @@ defineShortcuts({
|
|||||||
})
|
})
|
||||||
|
|
||||||
const dataStore = useDataStore()
|
const dataStore = useDataStore()
|
||||||
|
const profileStore = useProfileStore()
|
||||||
const router = useRouter()
|
const router = useRouter()
|
||||||
|
|
||||||
const templateColumns = [
|
const templateColumns = [
|
||||||
|
|||||||
@@ -20,6 +20,7 @@ defineShortcuts({
|
|||||||
})
|
})
|
||||||
|
|
||||||
const dataStore = useDataStore()
|
const dataStore = useDataStore()
|
||||||
|
const profileStore = useProfileStore()
|
||||||
const router = useRouter()
|
const router = useRouter()
|
||||||
const supabase = useSupabaseClient()
|
const supabase = useSupabaseClient()
|
||||||
|
|
||||||
@@ -27,7 +28,7 @@ const bankstatements = ref([])
|
|||||||
|
|
||||||
|
|
||||||
const setupPage = async () => {
|
const setupPage = async () => {
|
||||||
bankstatements.value = (await supabase.from("bankstatements").select("*, statementallocations(*)").eq('tenant', dataStore.currentTenant).order("date", {ascending:false})).data
|
bankstatements.value = (await supabase.from("bankstatements").select("*, statementallocations(*)").eq('tenant', profileStore.currentTenant).order("date", {ascending:false})).data
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -14,6 +14,7 @@ defineShortcuts({
|
|||||||
})
|
})
|
||||||
|
|
||||||
const dataStore = useDataStore()
|
const dataStore = useDataStore()
|
||||||
|
const profileStore = useProfileStore()
|
||||||
const route = useRoute()
|
const route = useRoute()
|
||||||
const router = useRouter()
|
const router = useRouter()
|
||||||
const mode = ref(route.params.mode || "show")
|
const mode = ref(route.params.mode || "show")
|
||||||
@@ -132,7 +133,7 @@ const saveAllocations = async () => {
|
|||||||
const saveAllocation = async (allocation) => {
|
const saveAllocation = async (allocation) => {
|
||||||
const {data,error} = await supabase.from("statementallocations").insert({
|
const {data,error} = await supabase.from("statementallocations").insert({
|
||||||
...allocation,
|
...allocation,
|
||||||
tenant: dataStore.currentTenant
|
tenant: profileStore.currentTenant
|
||||||
}).select()
|
}).select()
|
||||||
|
|
||||||
if(data) {
|
if(data) {
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ const supabase = useSupabaseClient()
|
|||||||
const user = useSupabaseUser()
|
const user = useSupabaseUser()
|
||||||
|
|
||||||
const dataStore = useDataStore()
|
const dataStore = useDataStore()
|
||||||
|
const profileStore = useProfileStore()
|
||||||
const selectedChat = ref({})
|
const selectedChat = ref({})
|
||||||
const messageText = ref("")
|
const messageText = ref("")
|
||||||
|
|
||||||
@@ -24,8 +25,8 @@ const messageText = ref("")
|
|||||||
@click="selectedChat = chat"
|
@click="selectedChat = chat"
|
||||||
>
|
>
|
||||||
<UAlert
|
<UAlert
|
||||||
:title="chat.title ? chat.title : chat.members.map(i => { if(i !== user.id) return dataStore.getProfileById(i).fullName}).join(' ')"
|
:title="chat.title ? chat.title : chat.members.map(i => { if(i !== user.id) return profileStore.getProfileById(i).fullName}).join(' ')"
|
||||||
:avatar="{alt: chat.members.map(i => { if(i !== user.id) return dataStore.getProfileById(i).fullName}).join(' ')}"
|
:avatar="{alt: chat.members.map(i => { if(i !== user.id) return profileStore.getProfileById(i).fullName}).join(' ')}"
|
||||||
:color="selectedChat.id === chat.id ? 'primary' : 'white'"
|
:color="selectedChat.id === chat.id ? 'primary' : 'white'"
|
||||||
variant="outline"
|
variant="outline"
|
||||||
>
|
>
|
||||||
@@ -49,13 +50,13 @@ const messageText = ref("")
|
|||||||
{{message.text}}
|
{{message.text}}
|
||||||
</div>
|
</div>
|
||||||
<UAvatar
|
<UAvatar
|
||||||
:alt="dataStore.getProfileById(message.origin) ? dataStore.getProfileById(message.origin).fullName : ''"
|
:alt="profileStore.getProfileById(message.origin) ? profileStore.getProfileById(message.origin).fullName : ''"
|
||||||
size="md"
|
size="md"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
<div class="flex justify-start mb-4" v-else>
|
<div class="flex justify-start mb-4" v-else>
|
||||||
<UAvatar
|
<UAvatar
|
||||||
:alt="dataStore.getProfileById(message.origin) ? dataStore.getProfileById(message.origin).fullName : ''"
|
:alt="profileStore.getProfileById(message.origin) ? profileStore.getProfileById(message.origin).fullName : ''"
|
||||||
size="md"
|
size="md"
|
||||||
/>
|
/>
|
||||||
<div
|
<div
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
<script setup>
|
<script setup>
|
||||||
|
|
||||||
const dataStore = useDataStore()
|
const profileStore = useProfileStore()
|
||||||
const supabase = useSupabaseClient()
|
const supabase = useSupabaseClient()
|
||||||
|
|
||||||
const profiles = ref([])
|
const profiles = ref([])
|
||||||
@@ -10,14 +10,14 @@ const selectedProfiles = ref([])
|
|||||||
|
|
||||||
const setup = async () => {
|
const setup = async () => {
|
||||||
profiles.value = await useSupabaseSelect("profiles")
|
profiles.value = await useSupabaseSelect("profiles")
|
||||||
selectedProfiles.value = [dataStore.activeProfile.id]
|
selectedProfiles.value = [profileStore.activeProfile.id]
|
||||||
}
|
}
|
||||||
|
|
||||||
setup()
|
setup()
|
||||||
|
|
||||||
const createChat = async () => {
|
const createChat = async () => {
|
||||||
const {data,error} = await supabase.from("chats").insert({
|
const {data,error} = await supabase.from("chats").insert({
|
||||||
tenant: dataStore.currentTenant,
|
tenant: profileStore.currentTenant,
|
||||||
name: itemInfo.value.name
|
name: itemInfo.value.name
|
||||||
}).select()
|
}).select()
|
||||||
|
|
||||||
@@ -105,7 +105,7 @@ const createChat = async () => {
|
|||||||
:search-attributes="['fullName']"
|
:search-attributes="['fullName']"
|
||||||
>
|
>
|
||||||
<template #label>
|
<template #label>
|
||||||
{{selectedProfiles.length > 0 ? selectedProfiles.map(i => dataStore.getProfileById(i).fullName).join(", ") : "Keine Benutzer ausgewählt"}}
|
{{selectedProfiles.length > 0 ? selectedProfiles.map(i => profileStore.getProfileById(i).fullName).join(", ") : "Keine Benutzer ausgewählt"}}
|
||||||
</template>
|
</template>
|
||||||
</USelectMenu>
|
</USelectMenu>
|
||||||
</UFormGroup>
|
</UFormGroup>
|
||||||
|
|||||||
@@ -13,17 +13,17 @@ defineShortcuts({
|
|||||||
})
|
})
|
||||||
|
|
||||||
const itemInfo = ref({})
|
const itemInfo = ref({})
|
||||||
const dataStore = useDataStore()
|
const profileStore = useProfileStore()
|
||||||
const supabase = useSupabaseClient()
|
const supabase = useSupabaseClient()
|
||||||
|
|
||||||
const setup = async () => {
|
const setup = async () => {
|
||||||
itemInfo.value = await useSupabaseSelectSingle("chats",useRoute().params.id,"*, profiles(*), chatmessages(*)")
|
itemInfo.value = await useSupabaseSelectSingle("chats",useRoute().params.id,"*, profiles(*), chatmessages(*)")
|
||||||
|
|
||||||
let unseenMessages = itemInfo.value.chatmessages.filter(i => !i.seenBy.includes(dataStore.activeProfile.id))
|
let unseenMessages = itemInfo.value.chatmessages.filter(i => !i.seenBy.includes(profileStore.activeProfile.id))
|
||||||
|
|
||||||
|
|
||||||
for await (const message of unseenMessages){
|
for await (const message of unseenMessages){
|
||||||
await supabase.from("chatmessages").update({seenBy: [...message.seenBy, dataStore.activeProfile.id]}).eq("id",message.id)
|
await supabase.from("chatmessages").update({seenBy: [...message.seenBy, profileStore.activeProfile.id]}).eq("id",message.id)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -34,11 +34,11 @@ const messageText = ref("")
|
|||||||
const sendMessage = async () => {
|
const sendMessage = async () => {
|
||||||
if(messageText.value.length > 0) {
|
if(messageText.value.length > 0) {
|
||||||
const message = {
|
const message = {
|
||||||
origin: dataStore.activeProfile.id,
|
origin: profileStore.activeProfile.id,
|
||||||
destinationchat: itemInfo.value.id,
|
destinationchat: itemInfo.value.id,
|
||||||
text: messageText.value,
|
text: messageText.value,
|
||||||
tenant: dataStore.currentTenant,
|
tenant: profileStore.currentTenant,
|
||||||
seenBy: [dataStore.activeProfile.id]
|
seenBy: [profileStore.activeProfile.id]
|
||||||
}
|
}
|
||||||
|
|
||||||
const {data,error} = await supabase.from("chatmessages").insert(message)
|
const {data,error} = await supabase.from("chatmessages").insert(message)
|
||||||
@@ -49,11 +49,11 @@ const sendMessage = async () => {
|
|||||||
//Reset
|
//Reset
|
||||||
messageText.value = ""
|
messageText.value = ""
|
||||||
//Create Notifications
|
//Create Notifications
|
||||||
let notifications = itemInfo.value.profiles.filter(i => i.id !== dataStore.activeProfile.id).map(i => {
|
let notifications = itemInfo.value.profiles.filter(i => i.id !== profileStore.activeProfile.id).map(i => {
|
||||||
return {
|
return {
|
||||||
tenant: dataStore.currentTenant,
|
tenant: profileStore.currentTenant,
|
||||||
profile: i.id,
|
profile: i.id,
|
||||||
initiatingProfile: dataStore.activeProfile.id,
|
initiatingProfile: profileStore.activeProfile.id,
|
||||||
title: `Sie haben eine neue Nachricht im Chat ${itemInfo.value.name}`,
|
title: `Sie haben eine neue Nachricht im Chat ${itemInfo.value.name}`,
|
||||||
link: `/chats/show/${itemInfo.value.id}`,
|
link: `/chats/show/${itemInfo.value.id}`,
|
||||||
message: message.text
|
message: message.text
|
||||||
@@ -88,13 +88,13 @@ const sendMessage = async () => {
|
|||||||
</UDashboardNavbar>
|
</UDashboardNavbar>
|
||||||
<div class="scrollList p-5">
|
<div class="scrollList p-5">
|
||||||
<UAlert
|
<UAlert
|
||||||
:color="message.seenBy.includes(dataStore.activeProfile.id) ? 'white' : 'primary'"
|
:color="message.seenBy.includes(profileStore.activeProfile.id) ? 'white' : 'primary'"
|
||||||
:variant="message.seenBy.includes(dataStore.activeProfile.id) ? 'solid' : 'outline'"
|
:variant="message.seenBy.includes(profileStore.activeProfile.id) ? 'solid' : 'outline'"
|
||||||
class="my-2"
|
class="my-2"
|
||||||
v-for="message in itemInfo.chatmessages"
|
v-for="message in itemInfo.chatmessages"
|
||||||
:description="message.text"
|
:description="message.text"
|
||||||
:avatar="{ alt: dataStore.getProfileById(message.origin).fullName }"
|
:avatar="{ alt: profileStore.getProfileById(message.origin).fullName }"
|
||||||
:title="`${dataStore.getProfileById(message.origin).fullName} - ${isToday(new Date(message.created_at)) ? dayjs(message.created_at).format('HH:mm') : dayjs(message.created_at).format('DD.MM.YYYY HH:mm')}`"
|
:title="`${profileStore.getProfileById(message.origin).fullName} - ${isToday(new Date(message.created_at)) ? dayjs(message.created_at).format('HH:mm') : dayjs(message.created_at).format('DD.MM.YYYY HH:mm')}`"
|
||||||
/>
|
/>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ import dayjs from "dayjs"
|
|||||||
|
|
||||||
const supabase = useSupabaseClient()
|
const supabase = useSupabaseClient()
|
||||||
const dataStore = useDataStore()
|
const dataStore = useDataStore()
|
||||||
|
const profileStore = useProfileStore()
|
||||||
const router = useRouter()
|
const router = useRouter()
|
||||||
|
|
||||||
|
|
||||||
@@ -10,7 +11,7 @@ const items = ref([])
|
|||||||
|
|
||||||
const setup = async () => {
|
const setup = async () => {
|
||||||
|
|
||||||
items.value = (await supabase.from("historyitems").select().like('text',`%@${dataStore.activeProfile.username}%`)/*.textSearch("text", `'@${dataStore.activeProfile.username}'`)*/.order("created_at")).data
|
items.value = (await supabase.from("historyitems").select().like('text',`%@${profileStore.activeProfile.username}%`)/*.textSearch("text", `'@${profileStore.activeProfile.username}'`)*/.order("created_at")).data
|
||||||
}
|
}
|
||||||
|
|
||||||
const navigateToHistoryItem = (item) => {
|
const navigateToHistoryItem = (item) => {
|
||||||
|
|||||||
@@ -23,6 +23,7 @@ defineShortcuts({
|
|||||||
})
|
})
|
||||||
|
|
||||||
const dataStore = useDataStore()
|
const dataStore = useDataStore()
|
||||||
|
const profileStore = useProfileStore()
|
||||||
const route = useRoute()
|
const route = useRoute()
|
||||||
const router = useRouter()
|
const router = useRouter()
|
||||||
const toast = useToast()
|
const toast = useToast()
|
||||||
@@ -33,7 +34,8 @@ const openTab = ref(0)
|
|||||||
//Working
|
//Working
|
||||||
const mode = ref(route.params.mode || "show")
|
const mode = ref(route.params.mode || "show")
|
||||||
const itemInfo = ref({
|
const itemInfo = ref({
|
||||||
active: true
|
active: true,
|
||||||
|
profiles: [profileStore.activeProfile.id]
|
||||||
})
|
})
|
||||||
const oldItemInfo = ref({})
|
const oldItemInfo = ref({})
|
||||||
|
|
||||||
@@ -300,6 +302,23 @@ setupPage()
|
|||||||
</template>
|
</template>
|
||||||
</UPopover>
|
</UPopover>
|
||||||
</UFormGroup>
|
</UFormGroup>
|
||||||
|
<UFormGroup
|
||||||
|
label="Berechtige Benutzer:"
|
||||||
|
>
|
||||||
|
<USelectMenu
|
||||||
|
v-model="itemInfo.profiles"
|
||||||
|
:options="profileStore.profiles"
|
||||||
|
option-attribute="fullName"
|
||||||
|
value-attribute="id"
|
||||||
|
searchable
|
||||||
|
multiple
|
||||||
|
:search-attributes="['fullName']"
|
||||||
|
>
|
||||||
|
<template #label>
|
||||||
|
{{itemInfo.profiles.length > 0 ? itemInfo.profiles.map(i => profileStore.getProfileById(i).fullName).join(", ") : "Kein Benutzer ausgewählt"}}
|
||||||
|
</template>
|
||||||
|
</USelectMenu>
|
||||||
|
</UFormGroup>
|
||||||
<UFormGroup
|
<UFormGroup
|
||||||
label="Notizen:"
|
label="Notizen:"
|
||||||
>
|
>
|
||||||
@@ -307,6 +326,7 @@ setupPage()
|
|||||||
v-model="itemInfo.notes"
|
v-model="itemInfo.notes"
|
||||||
/>
|
/>
|
||||||
</UFormGroup>
|
</UFormGroup>
|
||||||
|
|
||||||
</UForm>
|
</UForm>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
|
|||||||
@@ -24,6 +24,7 @@ defineShortcuts({
|
|||||||
})
|
})
|
||||||
|
|
||||||
const dataStore = useDataStore()
|
const dataStore = useDataStore()
|
||||||
|
const profileStore = useProfileStore()
|
||||||
const route = useRoute()
|
const route = useRoute()
|
||||||
const router = useRouter()
|
const router = useRouter()
|
||||||
const toast = useToast()
|
const toast = useToast()
|
||||||
@@ -215,7 +216,7 @@ setupPage()
|
|||||||
<td colspan="2"><span class="font-bold">Eigene Felder:</span></td>
|
<td colspan="2"><span class="font-bold">Eigene Felder:</span></td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr v-for="fieldKey in Object.keys(itemInfo.ownFields)">
|
<tr v-for="fieldKey in Object.keys(itemInfo.ownFields)">
|
||||||
<td>{{dataStore.ownTenant.ownFields.contracts.find(i => i.key === fieldKey).label}}</td>
|
<td>{{profileStore.ownTenant.ownFields.contracts.find(i => i.key === fieldKey).label}}</td>
|
||||||
<td>{{itemInfo.ownFields[fieldKey]}}</td>
|
<td>{{itemInfo.ownFields[fieldKey]}}</td>
|
||||||
</tr>
|
</tr>
|
||||||
</table>
|
</table>
|
||||||
@@ -491,14 +492,14 @@ setupPage()
|
|||||||
</UFormGroup>
|
</UFormGroup>
|
||||||
|
|
||||||
<div
|
<div
|
||||||
v-if="dataStore.ownTenant.ownFields"
|
v-if="profileStore.ownTenant.ownFields"
|
||||||
>
|
>
|
||||||
<UDivider
|
<UDivider
|
||||||
class="mt-3"
|
class="mt-3"
|
||||||
>Eigene Felder</UDivider>
|
>Eigene Felder</UDivider>
|
||||||
|
|
||||||
<UFormGroup
|
<UFormGroup
|
||||||
v-for="field in dataStore.ownTenant.ownFields.contracts"
|
v-for="field in profileStore.ownTenant.ownFields.contracts"
|
||||||
:key="field.key"
|
:key="field.key"
|
||||||
:label="field.label"
|
:label="field.label"
|
||||||
>
|
>
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import {useNumberRange} from "~/composables/useNumberRange.js";
|
|||||||
import { v4 as uuidv4 } from 'uuid';
|
import { v4 as uuidv4 } from 'uuid';
|
||||||
|
|
||||||
const dataStore = useDataStore()
|
const dataStore = useDataStore()
|
||||||
|
const profileStore = useProfileStore()
|
||||||
const user = useSupabaseUser()
|
const user = useSupabaseUser()
|
||||||
const route = useRoute()
|
const route = useRoute()
|
||||||
const router = useRouter()
|
const router = useRouter()
|
||||||
@@ -37,7 +38,7 @@ const itemInfo = ref({
|
|||||||
deliveryDateType: "Lieferdatum",
|
deliveryDateType: "Lieferdatum",
|
||||||
dateOfPerformance: null,
|
dateOfPerformance: null,
|
||||||
paymentDays: 7,
|
paymentDays: 7,
|
||||||
createdBy: dataStore.activeProfile.id,
|
createdBy: profileStore.activeProfile.id,
|
||||||
title: null,
|
title: null,
|
||||||
description: null,
|
description: null,
|
||||||
startText: null,
|
startText: null,
|
||||||
@@ -45,7 +46,7 @@ const itemInfo = ref({
|
|||||||
rows: [
|
rows: [
|
||||||
|
|
||||||
],
|
],
|
||||||
contactPerson: dataStore.activeProfile.id,
|
contactPerson: profileStore.activeProfile.id,
|
||||||
contactPersonName: null,
|
contactPersonName: null,
|
||||||
contactTel: null,
|
contactTel: null,
|
||||||
contactEMail: null,
|
contactEMail: null,
|
||||||
@@ -74,6 +75,7 @@ const servicecategories = ref([])
|
|||||||
const selectedServicecategorie = ref(null)
|
const selectedServicecategorie = ref(null)
|
||||||
const customers = ref([])
|
const customers = ref([])
|
||||||
const contacts = ref([])
|
const contacts = ref([])
|
||||||
|
const texttemplates = ref([])
|
||||||
|
|
||||||
const loaded = ref(false)
|
const loaded = ref(false)
|
||||||
const setupPage = async () => {
|
const setupPage = async () => {
|
||||||
@@ -87,6 +89,7 @@ const setupPage = async () => {
|
|||||||
productcategories.value = (await useSupabaseSelect("productcategories","*"))
|
productcategories.value = (await useSupabaseSelect("productcategories","*"))
|
||||||
customers.value = (await useSupabaseSelect("customers","*","customerNumber"))
|
customers.value = (await useSupabaseSelect("customers","*","customerNumber"))
|
||||||
contacts.value = (await useSupabaseSelect("contacts","*"))
|
contacts.value = (await useSupabaseSelect("contacts","*"))
|
||||||
|
texttemplates.value = (await useSupabaseSelect("texttemplates","*"))
|
||||||
if(productcategories.value.length > 0) selectedProductcategorie.value = productcategories.value[0].id
|
if(productcategories.value.length > 0) selectedProductcategorie.value = productcategories.value[0].id
|
||||||
if(servicecategories.value.length > 0) selectedServicecategorie.value = servicecategories.value[0].id
|
if(servicecategories.value.length > 0) selectedServicecategorie.value = servicecategories.value[0].id
|
||||||
|
|
||||||
@@ -216,8 +219,8 @@ const setDocumentTypeConfig = (withTexts = false) => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if(withTexts) {
|
if(withTexts) {
|
||||||
itemInfo.value.startText = dataStore.getTextTemplatesByDocumentType(itemInfo.value.type).find(i => i.default && i.pos === "startText").text
|
itemInfo.value.startText = texttemplates.value.find(i => i.documentType === itemInfo.value.type && i.default && i.pos === "startText").text
|
||||||
itemInfo.value.endText = dataStore.getTextTemplatesByDocumentType(itemInfo.value.type).find(i => i.default && i.pos === "endText").text
|
itemInfo.value.endText = texttemplates.value.find(i => i.documentType === itemInfo.value.type && i.default && i.pos === "endText").text
|
||||||
}
|
}
|
||||||
|
|
||||||
itemInfo.value.letterhead = letterheads.value[0].id
|
itemInfo.value.letterhead = letterheads.value[0].id
|
||||||
@@ -310,7 +313,7 @@ const addPosition = (mode) => {
|
|||||||
discountPercent: 0
|
discountPercent: 0
|
||||||
}
|
}
|
||||||
|
|
||||||
itemInfo.value.rows.push({...rowData, ...dataStore.ownTenant.extraModules.includes("agriculture") ? {agriculture: {}}: {}})
|
itemInfo.value.rows.push({...rowData, ...profileStore.ownTenant.extraModules.includes("agriculture") ? {agriculture: {}}: {}})
|
||||||
|
|
||||||
} else if(mode === 'normal'){
|
} else if(mode === 'normal'){
|
||||||
itemInfo.value.rows.push({
|
itemInfo.value.rows.push({
|
||||||
@@ -334,7 +337,7 @@ const addPosition = (mode) => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
//Push Agriculture Holder only if Module is activated
|
//Push Agriculture Holder only if Module is activated
|
||||||
itemInfo.value.rows.push({...rowData, ...dataStore.ownTenant.extraModules.includes("agriculture") ? {agriculture: {}}: {}})
|
itemInfo.value.rows.push({...rowData, ...profileStore.ownTenant.extraModules.includes("agriculture") ? {agriculture: {}}: {}})
|
||||||
} else if(mode === "pagebreak") {
|
} else if(mode === "pagebreak") {
|
||||||
itemInfo.value.rows.push({
|
itemInfo.value.rows.push({
|
||||||
id: uuidv4(),
|
id: uuidv4(),
|
||||||
@@ -373,7 +376,7 @@ const removePosition = (id) => {
|
|||||||
|
|
||||||
const getRowMargin = (row) => {
|
const getRowMargin = (row) => {
|
||||||
if(row.mode === "normal" && row.product) {
|
if(row.mode === "normal" && row.product) {
|
||||||
let purchasePrice = dataStore.getProductById(row.product).purchasePrice || 0
|
let purchasePrice = products.value.find(i => i.id === row.product).purchasePrice || 0
|
||||||
return row.price - purchasePrice
|
return row.price - purchasePrice
|
||||||
} else {
|
} else {
|
||||||
return 0
|
return 0
|
||||||
@@ -530,9 +533,9 @@ const getDocumentData = () => {
|
|||||||
|
|
||||||
let customerData = dataStore.getCustomerById(itemInfo.value.customer)
|
let customerData = dataStore.getCustomerById(itemInfo.value.customer)
|
||||||
let contactData = dataStore.getContactById(itemInfo.value.contact)
|
let contactData = dataStore.getContactById(itemInfo.value.contact)
|
||||||
let businessInfo = dataStore.ownTenant.businessInfo
|
let businessInfo = profileStore.ownTenant.businessInfo
|
||||||
|
|
||||||
if(dataStore.ownTenant.extraModules.includes("agriculture")) {
|
if(profileStore.ownTenant.extraModules.includes("agriculture")) {
|
||||||
itemInfo.value.rows.forEach(row => {
|
itemInfo.value.rows.forEach(row => {
|
||||||
if(row.agriculture && row.agriculture.dieselUsage) {
|
if(row.agriculture && row.agriculture.dieselUsage) {
|
||||||
row.agriculture.description = `${row.agriculture.dieselUsage} L Diesel zu ${renderCurrency(row.agriculture.dieselPrice)}/L verbraucht ${row.description ? "\n" + row.description : ""}`
|
row.agriculture.description = `${row.agriculture.dieselUsage} L Diesel zu ${renderCurrency(row.agriculture.dieselPrice)}/L verbraucht ${row.description ? "\n" + row.description : ""}`
|
||||||
@@ -555,7 +558,7 @@ const getDocumentData = () => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if(!['pagebreak','title','text'].includes(row.mode)) {
|
if(!['pagebreak','title','text'].includes(row.mode)) {
|
||||||
if(row.mode === 'normal') row.text = dataStore.getProductById(row.product).name
|
if(row.mode === 'normal') row.text = products.value.find(i => i.id === row.product).name
|
||||||
if(row.mode === 'service') row.text = dataStore.getServiceById(row.service).name
|
if(row.mode === 'service') row.text = dataStore.getServiceById(row.service).name
|
||||||
|
|
||||||
|
|
||||||
@@ -630,7 +633,7 @@ const getDocumentData = () => {
|
|||||||
const showDocument = ref(false)
|
const showDocument = ref(false)
|
||||||
const uri = ref("")
|
const uri = ref("")
|
||||||
const generateDocument = async () => {
|
const generateDocument = async () => {
|
||||||
const ownTenant = dataStore.ownTenant
|
const ownTenant = profileStore.ownTenant
|
||||||
const path = letterheads.value.find(i => i.id === itemInfo.value.letterhead).path
|
const path = letterheads.value.find(i => i.id === itemInfo.value.letterhead).path
|
||||||
|
|
||||||
|
|
||||||
@@ -717,7 +720,7 @@ const saveDocument = async (state) => {
|
|||||||
setDocumentTypeConfig(false)
|
setDocumentTypeConfig(false)
|
||||||
}
|
}
|
||||||
|
|
||||||
if(dataStore.ownTenant.extraModules.includes("agriculture")) {
|
if(profileStore.ownTenant.extraModules.includes("agriculture")) {
|
||||||
itemInfo.value.rows.forEach(row => {
|
itemInfo.value.rows.forEach(row => {
|
||||||
if(row.agriculture && row.agriculture.dieselUsage) {
|
if(row.agriculture && row.agriculture.dieselUsage) {
|
||||||
row.agriculture.description = `${row.agriculture.dieselUsage} L Diesel zu ${renderCurrency(row.agriculture.dieselPrice)}/L verbraucht ${row.description ? "\n" + row.description : ""}`
|
row.agriculture.description = `${row.agriculture.dieselUsage} L Diesel zu ${renderCurrency(row.agriculture.dieselPrice)}/L verbraucht ${row.description ? "\n" + row.description : ""}`
|
||||||
@@ -1193,7 +1196,7 @@ setupPage()
|
|||||||
label="Ansprechpartner:"
|
label="Ansprechpartner:"
|
||||||
>
|
>
|
||||||
<USelectMenu
|
<USelectMenu
|
||||||
:options="dataStore.profiles"
|
:options="profileStore.profiles"
|
||||||
v-model="itemInfo.contactPerson"
|
v-model="itemInfo.contactPerson"
|
||||||
option-attribute="fullName"
|
option-attribute="fullName"
|
||||||
value-attribute="id"
|
value-attribute="id"
|
||||||
@@ -1464,12 +1467,12 @@ setupPage()
|
|||||||
searchable-placeholder="Suche ..."
|
searchable-placeholder="Suche ..."
|
||||||
:search-attributes="['name']"
|
:search-attributes="['name']"
|
||||||
v-model="row.product"
|
v-model="row.product"
|
||||||
@change="row.unit = dataStore.getProductById(row.product).unit,
|
@change="row.unit = products.find(i => i.id === row.product).unit,
|
||||||
row.price = (dataStore.getProductById(row.product).sellingPrice || 0),
|
row.price = (products.find(i => i.id === row.product).sellingPrice || 0),
|
||||||
row.description = dataStore.getProductById(row.product).description"
|
row.description = products.find(i => i.id === row.product).description"
|
||||||
>
|
>
|
||||||
<template #label>
|
<template #label>
|
||||||
<span class="truncate">{{row.product ? dataStore.getProductById(row.product).name : "Kein Produkt ausgewählt" }}</span>
|
<span class="truncate">{{row.product ? products.find(i => i.id === row.product).name : "Kein Produkt ausgewählt" }}</span>
|
||||||
</template>
|
</template>
|
||||||
</USelectMenu>
|
</USelectMenu>
|
||||||
<UButton
|
<UButton
|
||||||
@@ -1503,9 +1506,9 @@ setupPage()
|
|||||||
:empty-state="{ icon: 'i-heroicons-circle-stack-20-solid', label: 'Keine Artikel anzuzeigen' }"
|
:empty-state="{ icon: 'i-heroicons-circle-stack-20-solid', label: 'Keine Artikel anzuzeigen' }"
|
||||||
@select=" (i) => {
|
@select=" (i) => {
|
||||||
row.product = i.id
|
row.product = i.id
|
||||||
row.unit = dataStore.getProductById(row.product).unit,
|
row.unit = products.find(i => i.id === row.product).unit,
|
||||||
row.price = (dataStore.getProductById(row.product).sellingPrice || 0),
|
row.price = (products.find(i => i.id === row.product).sellingPrice || 0),
|
||||||
row.description = dataStore.getProductById(row.product).description
|
row.description = products.find(i => i.id === row.product).description
|
||||||
showProductSelectionModal = false}"
|
showProductSelectionModal = false}"
|
||||||
>
|
>
|
||||||
|
|
||||||
@@ -1514,9 +1517,6 @@ setupPage()
|
|||||||
</UModal>
|
</UModal>
|
||||||
</InputGroup>
|
</InputGroup>
|
||||||
|
|
||||||
<!--
|
|
||||||
{{dataStore.getProductById(66)}}
|
|
||||||
-->
|
|
||||||
</td>
|
</td>
|
||||||
<td
|
<td
|
||||||
class="w-120"
|
class="w-120"
|
||||||
|
|||||||
@@ -280,10 +280,6 @@ const isPaid = (item) => {
|
|||||||
let amountPaid = 0
|
let amountPaid = 0
|
||||||
item.statementallocations.forEach(allocation => amountPaid += allocation.amount)
|
item.statementallocations.forEach(allocation => amountPaid += allocation.amount)
|
||||||
|
|
||||||
console.log(item.documentNumber)
|
|
||||||
console.log(amountPaid)
|
|
||||||
console.log(calculateDocSum(item))
|
|
||||||
|
|
||||||
return Number(amountPaid.toFixed(2)) === Number(calculateDocSum(item))
|
return Number(amountPaid.toFixed(2)) === Number(calculateDocSum(item))
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ defineShortcuts({
|
|||||||
const supabase = useSupabaseClient()
|
const supabase = useSupabaseClient()
|
||||||
|
|
||||||
const dataStore = useDataStore()
|
const dataStore = useDataStore()
|
||||||
|
const profileStore = useProfileStore()
|
||||||
const route = useRoute()
|
const route = useRoute()
|
||||||
const router = useRouter()
|
const router = useRouter()
|
||||||
|
|
||||||
@@ -26,7 +27,7 @@ const setupPage = async () => {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
currentTenant.value = (await supabase.from("tenants").select().eq("id",dataStore.currentTenant).single()).data
|
currentTenant.value = (await supabase.from("tenants").select().eq("id",profileStore.currentTenant).single()).data
|
||||||
console.log(currentTenant.value)
|
console.log(currentTenant.value)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -23,10 +23,9 @@ defineShortcuts({
|
|||||||
})
|
})
|
||||||
|
|
||||||
const dataStore = useDataStore()
|
const dataStore = useDataStore()
|
||||||
|
const profileStore = useProfileStore()
|
||||||
const route = useRoute()
|
const route = useRoute()
|
||||||
const router = useRouter()
|
const router = useRouter()
|
||||||
const toast = useToast()
|
|
||||||
const id = ref(route.params.id ? route.params.id : null )
|
|
||||||
|
|
||||||
const openTab = ref(0)
|
const openTab = ref(0)
|
||||||
|
|
||||||
@@ -39,7 +38,8 @@ const itemInfo = ref({
|
|||||||
country: "Deutschland"
|
country: "Deutschland"
|
||||||
},
|
},
|
||||||
active: true,
|
active: true,
|
||||||
isCompany: true
|
isCompany: true,
|
||||||
|
profiles: [profileStore.activeProfile.id]
|
||||||
})
|
})
|
||||||
const oldItemInfo = ref({})
|
const oldItemInfo = ref({})
|
||||||
|
|
||||||
@@ -356,6 +356,23 @@ setupPage()
|
|||||||
v-model="itemInfo.infoData.ustid"
|
v-model="itemInfo.infoData.ustid"
|
||||||
/>
|
/>
|
||||||
</UFormGroup>
|
</UFormGroup>
|
||||||
|
<UFormGroup
|
||||||
|
label="Berechtigte Benutzer:"
|
||||||
|
>
|
||||||
|
<USelectMenu
|
||||||
|
v-model="itemInfo.profiles"
|
||||||
|
:options="profileStore.profiles"
|
||||||
|
option-attribute="fullName"
|
||||||
|
value-attribute="id"
|
||||||
|
searchable
|
||||||
|
multiple
|
||||||
|
:search-attributes="['fullName']"
|
||||||
|
>
|
||||||
|
<template #label>
|
||||||
|
{{itemInfo.profiles.length > 0 ? itemInfo.profiles.map(i => profileStore.getProfileById(i).fullName).join(", ") : "Kein Benutzer ausgewählt"}}
|
||||||
|
</template>
|
||||||
|
</USelectMenu>
|
||||||
|
</UFormGroup>
|
||||||
</UForm>
|
</UForm>
|
||||||
</UDashboardPanelContent>
|
</UDashboardPanelContent>
|
||||||
|
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ definePageMeta({
|
|||||||
|
|
||||||
|
|
||||||
const dataStore = useDataStore()
|
const dataStore = useDataStore()
|
||||||
|
const profileStore = useProfileStore()
|
||||||
const supabase = useSupabaseClient()
|
const supabase = useSupabaseClient()
|
||||||
const route = useRoute()
|
const route = useRoute()
|
||||||
const router = useRouter()
|
const router = useRouter()
|
||||||
@@ -81,7 +82,7 @@ const filteredTimes = computed(() => {
|
|||||||
//Functions
|
//Functions
|
||||||
const setupPage = () => {
|
const setupPage = () => {
|
||||||
if(mode.value === "show" || mode.value === "edit"){
|
if(mode.value === "show" || mode.value === "edit"){
|
||||||
currentItem = dataStore.getProfileById(useRoute().params.id)
|
currentItem = profileStore.getProfileById(useRoute().params.id)
|
||||||
}
|
}
|
||||||
|
|
||||||
itemInfo.value = currentItem
|
itemInfo.value = currentItem
|
||||||
@@ -337,7 +338,7 @@ setupPage()
|
|||||||
<div class="text-right">{{dayjs(row.end).format("HH:mm")}}</div>
|
<div class="text-right">{{dayjs(row.end).format("HH:mm")}}</div>
|
||||||
</template>
|
</template>
|
||||||
<template #user-data="{row}">
|
<template #user-data="{row}">
|
||||||
{{dataStore.getProfileById(row.user) ? dataStore.getProfileById(row.user).fullName : ""}}
|
{{profileStore.getProfileById(row.user) ? profileStore.getProfileById(row.user).fullName : ""}}
|
||||||
</template>
|
</template>
|
||||||
<template #duration-data="{row}">
|
<template #duration-data="{row}">
|
||||||
<div class="text-right">{{ getDuration(row).composed}} Std</div>
|
<div class="text-right">{{ getDuration(row).composed}} Std</div>
|
||||||
@@ -8,6 +8,7 @@ definePageMeta({
|
|||||||
middleware: "auth"
|
middleware: "auth"
|
||||||
})
|
})
|
||||||
const dataStore = useDataStore()
|
const dataStore = useDataStore()
|
||||||
|
const profileStore = useProfileStore()
|
||||||
const supabase = useSupabaseClient()
|
const supabase = useSupabaseClient()
|
||||||
const user = useSupabaseUser()
|
const user = useSupabaseUser()
|
||||||
const toast = useToast()
|
const toast = useToast()
|
||||||
@@ -21,7 +22,7 @@ const uploadInProgress = ref(false)
|
|||||||
const fileUploadFormData = ref({
|
const fileUploadFormData = ref({
|
||||||
tags: ["Eingang"],
|
tags: ["Eingang"],
|
||||||
path: "",
|
path: "",
|
||||||
tenant: dataStore.currentTenant,
|
tenant: profileStore.currentTenant,
|
||||||
folder: null
|
folder: null
|
||||||
})
|
})
|
||||||
|
|
||||||
@@ -163,7 +164,7 @@ const uploadFiles = async (files) => {
|
|||||||
uploadInProgress.value = true;
|
uploadInProgress.value = true;
|
||||||
|
|
||||||
if(files) {
|
if(files) {
|
||||||
await dataStore.uploadFiles({tags: ["Ablage"],tenant: dataStore.currentTenant,folder: currentFolder.value.id}, files, true)
|
await dataStore.uploadFiles({tags: ["Ablage"],tenant: profileStore.currentTenant,folder: currentFolder.value.id}, files, true)
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
await dataStore.uploadFiles(fileUploadFormData.value, document.getElementById("fileUploadInput").files, true)
|
await dataStore.uploadFiles(fileUploadFormData.value, document.getElementById("fileUploadInput").files, true)
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
const supabase = useSupabaseClient()
|
const supabase = useSupabaseClient()
|
||||||
const dataStore = useDataStore()
|
const dataStore = useDataStore()
|
||||||
|
const profileStore = useProfileStore()
|
||||||
|
|
||||||
|
|
||||||
const selectedTab = ref(0)
|
const selectedTab = ref(0)
|
||||||
@@ -12,7 +13,7 @@ const accountData = ref(null)
|
|||||||
const availableAccounts = ref(null)
|
const availableAccounts = ref(null)
|
||||||
const selectedAccount = ref(null)
|
const selectedAccount = ref(null)
|
||||||
const setupPage = async () => {
|
const setupPage = async () => {
|
||||||
availableAccounts.value = (await supabase.from("emailAccounts").select("*").contains("profiles",[dataStore.activeProfile.id])).data
|
availableAccounts.value = (await supabase.from("emailAccounts").select("*").contains("profiles",[profileStore.activeProfile.id])).data
|
||||||
console.log(availableAccounts.value)
|
console.log(availableAccounts.value)
|
||||||
|
|
||||||
if(availableAccounts.value.length > 0) {
|
if(availableAccounts.value.length > 0) {
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
const supabase = useSupabaseClient()
|
const supabase = useSupabaseClient()
|
||||||
const dataStore = useDataStore()
|
const dataStore = useDataStore()
|
||||||
|
const profileStore = useProfileStore()
|
||||||
const route = useRoute()
|
const route = useRoute()
|
||||||
const router = useRouter()
|
const router = useRouter()
|
||||||
const toast = useToast()
|
const toast = useToast()
|
||||||
@@ -29,7 +30,7 @@ const setupPage = async () => {
|
|||||||
} else {
|
} else {
|
||||||
emailData.value.account = emailAccounts.value[0].id
|
emailData.value.account = emailAccounts.value[0].id
|
||||||
|
|
||||||
preloadedContent.value = `<p></p><p></p><p></p>${dataStore.activeProfile.emailSignature}`
|
preloadedContent.value = `<p></p><p></p><p></p>${profileStore.activeProfile.emailSignature}`
|
||||||
|
|
||||||
//Check Query
|
//Check Query
|
||||||
if(route.query.to) emailData.value.to = route.query.to
|
if(route.query.to) emailData.value.to = route.query.to
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ definePageMeta({
|
|||||||
})
|
})
|
||||||
|
|
||||||
const dataStore = useDataStore()
|
const dataStore = useDataStore()
|
||||||
|
const profileStore = useProfileStore()
|
||||||
const supabase = useSupabaseClient()
|
const supabase = useSupabaseClient()
|
||||||
const user = useSupabaseUser()
|
const user = useSupabaseUser()
|
||||||
const toast = useToast()
|
const toast = useToast()
|
||||||
@@ -111,7 +112,7 @@ const startTime = async () => {
|
|||||||
console.log("started")
|
console.log("started")
|
||||||
timeInfo.value.user = user.value.id
|
timeInfo.value.user = user.value.id
|
||||||
timeInfo.value.start = new Date().toISOString()
|
timeInfo.value.start = new Date().toISOString()
|
||||||
timeInfo.value.tenant = dataStore.currentTenant
|
timeInfo.value.tenant = profileStore.currentTenant
|
||||||
|
|
||||||
const {data,error} = await supabase
|
const {data,error} = await supabase
|
||||||
.from("times")
|
.from("times")
|
||||||
@@ -162,7 +163,7 @@ if(dataStore.times.find(time => time.user == user.value.id && !time.end)) {
|
|||||||
const createTime = async () => {
|
const createTime = async () => {
|
||||||
const {data,error} = await supabase
|
const {data,error} = await supabase
|
||||||
.from("times")
|
.from("times")
|
||||||
.insert({...itemInfo.value, tenant: dataStore.currentTenant})
|
.insert({...itemInfo.value, tenant: profileStore.currentTenant})
|
||||||
.select()
|
.select()
|
||||||
|
|
||||||
if(error) {
|
if(error) {
|
||||||
@@ -241,13 +242,13 @@ const setState = async (newState) => {
|
|||||||
</UButton>
|
</UButton>
|
||||||
<USelectMenu
|
<USelectMenu
|
||||||
v-if="dataStore.hasRight('viewTimes')"
|
v-if="dataStore.hasRight('viewTimes')"
|
||||||
:options="dataStore.profiles"
|
:options="profileStore.profiles"
|
||||||
option-attribute="fullName"
|
option-attribute="fullName"
|
||||||
value-attribute="id"
|
value-attribute="id"
|
||||||
v-model="filterUser"
|
v-model="filterUser"
|
||||||
>
|
>
|
||||||
<template #label>
|
<template #label>
|
||||||
{{dataStore.getProfileById(filterUser) ? dataStore.getProfileById(filterUser).fullName : "Kein Benutzer ausgewählt"}}
|
{{profileStore.getProfileById(filterUser) ? profileStore.getProfileById(filterUser).fullName : "Kein Benutzer ausgewählt"}}
|
||||||
</template>
|
</template>
|
||||||
</USelectMenu>
|
</USelectMenu>
|
||||||
</template>
|
</template>
|
||||||
@@ -339,14 +340,14 @@ const setState = async (newState) => {
|
|||||||
label="Benutzer:"
|
label="Benutzer:"
|
||||||
>
|
>
|
||||||
<USelectMenu
|
<USelectMenu
|
||||||
:options="dataStore.profiles"
|
:options="profileStore.profiles"
|
||||||
v-model="itemInfo.user"
|
v-model="itemInfo.user"
|
||||||
option-attribute="fullName"
|
option-attribute="fullName"
|
||||||
value-attribute="id"
|
value-attribute="id"
|
||||||
:disabled="(configTimeMode === 'create' ? false : itemInfo.state !== 'Entwurf') || (!dataStore.hasRight('createTime') || !dataStore.hasRight('createOwnTime'))"
|
:disabled="(configTimeMode === 'create' ? false : itemInfo.state !== 'Entwurf') || (!dataStore.hasRight('createTime') || !dataStore.hasRight('createOwnTime'))"
|
||||||
>
|
>
|
||||||
<template #label>
|
<template #label>
|
||||||
{{dataStore.profiles.find(profile => profile.id === itemInfo.user) ? dataStore.profiles.find(profile => profile.id === itemInfo.user).fullName : "Benutzer auswählen"}}
|
{{profileStore.profiles.find(profile => profile.id === itemInfo.user) ? profileStore.profiles.find(profile => profile.id === itemInfo.user).fullName : "Benutzer auswählen"}}
|
||||||
</template>
|
</template>
|
||||||
</USelectMenu>
|
</USelectMenu>
|
||||||
</UFormGroup>
|
</UFormGroup>
|
||||||
@@ -444,7 +445,7 @@ const setState = async (newState) => {
|
|||||||
>{{row.state}}</span>
|
>{{row.state}}</span>
|
||||||
</template>
|
</template>
|
||||||
<template #user-data="{row}">
|
<template #user-data="{row}">
|
||||||
{{dataStore.profiles.find(profile => profile.id === row.user) ? dataStore.profiles.find(profile => profile.id === row.user).fullName : row.user }}
|
{{profileStore.profiles.find(profile => profile.id === row.user) ? profileStore.profiles.find(profile => profile.id === row.user).fullName : row.user }}
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<template #start-data="{row}">
|
<template #start-data="{row}">
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import dayjs from "dayjs";
|
|||||||
const route = useRoute()
|
const route = useRoute()
|
||||||
const router = useRouter()
|
const router = useRouter()
|
||||||
const dataStore = useDataStore()
|
const dataStore = useDataStore()
|
||||||
|
const profileStore = useProfileStore()
|
||||||
|
|
||||||
const mode = ref(route.params.mode || "show")
|
const mode = ref(route.params.mode || "show")
|
||||||
|
|
||||||
@@ -13,7 +14,7 @@ const itemInfo = ref({
|
|||||||
})
|
})
|
||||||
const oldItemInfo = ref({})
|
const oldItemInfo = ref({})
|
||||||
|
|
||||||
const resourceToAdd = ref(dataStore.activeProfile.id)
|
const resourceToAdd = ref(profileStore.activeProfile.id)
|
||||||
/*const mapResources = () => {
|
/*const mapResources = () => {
|
||||||
console.log(itemInfo.value.resources)
|
console.log(itemInfo.value.resources)
|
||||||
itemInfo.value.resources.map(resource => {
|
itemInfo.value.resources.map(resource => {
|
||||||
|
|||||||
@@ -18,7 +18,7 @@
|
|||||||
title="Anwesenheiten"
|
title="Anwesenheiten"
|
||||||
v-if="dataStore.getStartedWorkingTimes().length > 0"
|
v-if="dataStore.getStartedWorkingTimes().length > 0"
|
||||||
>
|
>
|
||||||
<p v-for="time in dataStore.getStartedWorkingTimes()"><UIcon name="i-heroicons-check"/>{{dataStore.getProfileById(time.profile).fullName}}</p>
|
<p v-for="time in dataStore.getStartedWorkingTimes()"><UIcon name="i-heroicons-check"/>{{profileStore.getProfileById(time.profile).fullName}}</p>
|
||||||
</UDashboardCard>
|
</UDashboardCard>
|
||||||
|
|
||||||
<!--TODO: Fix Card Table overflowing <UDashboardCard
|
<!--TODO: Fix Card Table overflowing <UDashboardCard
|
||||||
@@ -27,7 +27,7 @@
|
|||||||
class="w-1/2 h-1/2"
|
class="w-1/2 h-1/2"
|
||||||
>
|
>
|
||||||
<UTable
|
<UTable
|
||||||
:rows="dataStore.tasks.filter(i => i.categorie !== 'Erledigt' && (i.profile === dataStore.activeProfile.id ||!i.profile))"
|
:rows="dataStore.tasks.filter(i => i.categorie !== 'Erledigt' && (i.profile === profileStore.activeProfile.id ||!i.profile))"
|
||||||
@select="(row) => router.push(`/tasks/show/${row.id}`)"
|
@select="(row) => router.push(`/tasks/show/${row.id}`)"
|
||||||
:columns="[
|
:columns="[
|
||||||
{
|
{
|
||||||
@@ -69,6 +69,7 @@ definePageMeta({
|
|||||||
})
|
})
|
||||||
|
|
||||||
const dataStore = useDataStore()
|
const dataStore = useDataStore()
|
||||||
|
const profileStore = useProfileStore()
|
||||||
const toast = useToast()
|
const toast = useToast()
|
||||||
const router = useRouter()
|
const router = useRouter()
|
||||||
|
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ definePageMeta({
|
|||||||
})
|
})
|
||||||
|
|
||||||
const dataStore = useDataStore()
|
const dataStore = useDataStore()
|
||||||
|
const profileStore = useProfileStore()
|
||||||
const supabase = useSupabaseClient()
|
const supabase = useSupabaseClient()
|
||||||
const router = useRouter()
|
const router = useRouter()
|
||||||
const mode = ref("incoming")
|
const mode = ref("incoming")
|
||||||
@@ -41,8 +42,8 @@ const createMovement = async () => {
|
|||||||
spaceId: inventoryChangeData.value.destinationSpaceId,
|
spaceId: inventoryChangeData.value.destinationSpaceId,
|
||||||
projectId: inventoryChangeData.value.destinationProjectId,
|
projectId: inventoryChangeData.value.destinationProjectId,
|
||||||
quantity: inventoryChangeData.value.quantity,
|
quantity: inventoryChangeData.value.quantity,
|
||||||
profileId: dataStore.activeProfile.id,
|
profileId: profileStore.activeProfile.id,
|
||||||
tenant: dataStore.currentTenant
|
tenant: profileStore.currentTenant
|
||||||
}
|
}
|
||||||
|
|
||||||
movements.push(movement)
|
movements.push(movement)
|
||||||
@@ -61,8 +62,8 @@ const createMovement = async () => {
|
|||||||
spaceId: inventoryChangeData.value.sourceSpaceId,
|
spaceId: inventoryChangeData.value.sourceSpaceId,
|
||||||
projectId: inventoryChangeData.value.sourceProjectId,
|
projectId: inventoryChangeData.value.sourceProjectId,
|
||||||
quantity: inventoryChangeData.value.quantity * -1,
|
quantity: inventoryChangeData.value.quantity * -1,
|
||||||
profileId: dataStore.activeProfile.id,
|
profileId: profileStore.activeProfile.id,
|
||||||
tenant: dataStore.currentTenant
|
tenant: profileStore.currentTenant
|
||||||
}
|
}
|
||||||
|
|
||||||
movements.push(movement)
|
movements.push(movement)
|
||||||
@@ -72,16 +73,16 @@ const createMovement = async () => {
|
|||||||
spaceId: inventoryChangeData.value.sourceSpaceId,
|
spaceId: inventoryChangeData.value.sourceSpaceId,
|
||||||
projectId: inventoryChangeData.value.sourceProjectId,
|
projectId: inventoryChangeData.value.sourceProjectId,
|
||||||
quantity: inventoryChangeData.value.quantity * -1,
|
quantity: inventoryChangeData.value.quantity * -1,
|
||||||
profileId: dataStore.activeProfile.id,
|
profileId: profileStore.activeProfile.id,
|
||||||
tenant: dataStore.currentTenant
|
tenant: profileStore.currentTenant
|
||||||
}
|
}
|
||||||
let inMovement = {
|
let inMovement = {
|
||||||
productId: inventoryChangeData.value.productId,
|
productId: inventoryChangeData.value.productId,
|
||||||
spaceId: inventoryChangeData.value.destinationSpaceId,
|
spaceId: inventoryChangeData.value.destinationSpaceId,
|
||||||
projectId: inventoryChangeData.value.destinationProjectId,
|
projectId: inventoryChangeData.value.destinationProjectId,
|
||||||
quantity: inventoryChangeData.value.quantity,
|
quantity: inventoryChangeData.value.quantity,
|
||||||
profileId: dataStore.activeProfile.id,
|
profileId: profileStore.activeProfile.id,
|
||||||
tenant: dataStore.currentTenant
|
tenant: profileStore.currentTenant
|
||||||
}
|
}
|
||||||
|
|
||||||
movements.push(outMovement)
|
movements.push(outMovement)
|
||||||
|
|||||||
@@ -1,5 +1,7 @@
|
|||||||
<script setup >
|
<script setup >
|
||||||
|
|
||||||
|
import {useProfileStore} from "~/stores/profile.js";
|
||||||
|
|
||||||
definePageMeta({
|
definePageMeta({
|
||||||
layout: "notLoggedIn"
|
layout: "notLoggedIn"
|
||||||
})
|
})
|
||||||
@@ -8,8 +10,8 @@ const supabase = useSupabaseClient()
|
|||||||
const user = useSupabaseUser()
|
const user = useSupabaseUser()
|
||||||
const router = useRouter()
|
const router = useRouter()
|
||||||
const colorMode = useColorMode()
|
const colorMode = useColorMode()
|
||||||
const dataStore = useDataStore()
|
|
||||||
const toast = useToast()
|
const toast = useToast()
|
||||||
|
const profileStore = useProfileStore()
|
||||||
|
|
||||||
const isLight = computed({
|
const isLight = computed({
|
||||||
get () {
|
get () {
|
||||||
@@ -61,7 +63,7 @@ const onSubmit = async (data) => {
|
|||||||
|
|
||||||
} else {
|
} else {
|
||||||
//console.log("Login Successful")
|
//console.log("Login Successful")
|
||||||
dataStore.initializeData(user.id)
|
profileStore.initializeData(user.id)
|
||||||
router.push("/")
|
router.push("/")
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -20,9 +20,6 @@ const id = ref(route.params.id ? route.params.id : null )
|
|||||||
//Working
|
//Working
|
||||||
const mode = ref(route.params.mode || "show")
|
const mode = ref(route.params.mode || "show")
|
||||||
const itemInfo = ref({
|
const itemInfo = ref({
|
||||||
description: {
|
|
||||||
html: ""
|
|
||||||
}
|
|
||||||
})
|
})
|
||||||
|
|
||||||
const tabItems = [
|
const tabItems = [
|
||||||
@@ -105,7 +102,7 @@ setupPage()
|
|||||||
Erstellen
|
Erstellen
|
||||||
</UButton>
|
</UButton>
|
||||||
<UButton
|
<UButton
|
||||||
@click="router.push(itemInfo.id ? `/plants/show/${itemInfo.value.id}` : `/plants/`)"
|
@click="router.push(itemInfo.id ? `/plants/show/${itemInfo.id}` : `/plants/`)"
|
||||||
color="red"
|
color="red"
|
||||||
class="ml-2"
|
class="ml-2"
|
||||||
v-if="mode === 'edit' || mode === 'create'"
|
v-if="mode === 'edit' || mode === 'create'"
|
||||||
@@ -144,7 +141,7 @@ setupPage()
|
|||||||
</tr>
|
</tr>
|
||||||
</table>
|
</table>
|
||||||
</div>
|
</div>
|
||||||
<div v-if="itemInfo.description.html">
|
<div v-if="itemInfo.description">
|
||||||
<p>Notizen:</p>
|
<p>Notizen:</p>
|
||||||
<span v-html="itemInfo.description.html"></span>
|
<span v-html="itemInfo.description.html"></span>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -25,6 +25,7 @@ defineShortcuts({
|
|||||||
})
|
})
|
||||||
|
|
||||||
const dataStore = useDataStore()
|
const dataStore = useDataStore()
|
||||||
|
const profileStore = useProfileStore()
|
||||||
const supabase = useSupabaseClient()
|
const supabase = useSupabaseClient()
|
||||||
const route = useRoute()
|
const route = useRoute()
|
||||||
const router = useRouter()
|
const router = useRouter()
|
||||||
@@ -270,7 +271,7 @@ setupPage()
|
|||||||
>
|
>
|
||||||
<USelectMenu
|
<USelectMenu
|
||||||
v-model="itemInfo.tags"
|
v-model="itemInfo.tags"
|
||||||
:options="dataStore.ownTenant.tags.products"
|
:options="profileStore.ownTenant.tags.products"
|
||||||
multiple
|
multiple
|
||||||
>
|
>
|
||||||
<template #label>
|
<template #label>
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
<script setup>
|
<script setup>
|
||||||
const dataStore = useDataStore()
|
const dataStore = useDataStore()
|
||||||
|
const profileStore = useProfileStore()
|
||||||
const router = useRouter()
|
const router = useRouter()
|
||||||
|
|
||||||
|
|
||||||
@@ -35,7 +36,7 @@
|
|||||||
</UDashboardNavbar>
|
</UDashboardNavbar>
|
||||||
|
|
||||||
<UTable
|
<UTable
|
||||||
:rows="dataStore.profiles"
|
:rows="profileStore.profiles"
|
||||||
@select="(item) => router.push(`/profiles/show/${item.id}`)"
|
@select="(item) => router.push(`/profiles/show/${item.id}`)"
|
||||||
:columns="columns"
|
:columns="columns"
|
||||||
>
|
>
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ dayjs.extend(isoWeek)
|
|||||||
dayjs.extend(isBetween)
|
dayjs.extend(isBetween)
|
||||||
|
|
||||||
const dataStore = useDataStore()
|
const dataStore = useDataStore()
|
||||||
|
const profileStore = useProfileStore()
|
||||||
const route = useRoute()
|
const route = useRoute()
|
||||||
const router = useRouter()
|
const router = useRouter()
|
||||||
const supabase = useSupabaseClient()
|
const supabase = useSupabaseClient()
|
||||||
@@ -33,7 +34,7 @@ const setupPage = async () => {
|
|||||||
|
|
||||||
setupPage()
|
setupPage()
|
||||||
|
|
||||||
const emailSignature = ref(dataStore.activeProfile.emailSignature)
|
const emailSignature = ref(profileStore.activeProfile.emailSignature)
|
||||||
const tiptapLoaded = ref(false)
|
const tiptapLoaded = ref(false)
|
||||||
const contentSaved = ref(true)
|
const contentSaved = ref(true)
|
||||||
const contentChanged = async (content) => {
|
const contentChanged = async (content) => {
|
||||||
@@ -49,7 +50,7 @@ const contentChanged = async (content) => {
|
|||||||
|
|
||||||
|
|
||||||
const saveSignature = async () => {
|
const saveSignature = async () => {
|
||||||
const {data,error} = await supabase.from("profiles").update({emailSignature: emailSignature.value}).eq("id", dataStore.activeProfile.id)
|
const {data,error} = await supabase.from("profiles").update({emailSignature: emailSignature.value}).eq("id", profileStore.activeProfile.id)
|
||||||
|
|
||||||
if(error) {
|
if(error) {
|
||||||
toast.add({title: "Fehler beim Speichern der Signatur", color:"rose"})
|
toast.add({title: "Fehler beim Speichern der Signatur", color:"rose"})
|
||||||
@@ -66,8 +67,8 @@ const addToNewsletter = async () => {
|
|||||||
url: "https://newsletter.fedeo.io/api/public/subscription",
|
url: "https://newsletter.fedeo.io/api/public/subscription",
|
||||||
method: "post",
|
method: "post",
|
||||||
data: {
|
data: {
|
||||||
email: dataStore.activeProfile.email,
|
email: profileStore.activeProfile.email,
|
||||||
name: dataStore.activeProfile.name,
|
name: profileStore.activeProfile.name,
|
||||||
list_uuids: ["b97453fd-14b2-4b25-8f9b-b83847317ea3"],
|
list_uuids: ["b97453fd-14b2-4b25-8f9b-b83847317ea3"],
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -227,12 +228,12 @@ const isLight = computed({
|
|||||||
</UFormGroup>
|
</UFormGroup>
|
||||||
</InputGroup>
|
</InputGroup>
|
||||||
|
|
||||||
<UDivider class="my-5" v-if="dataStore.activeProfile.id === itemInfo.id">
|
<UDivider class="my-5" v-if="profileStore.activeProfile.id === itemInfo.id">
|
||||||
Helligkeitseinstellung
|
Helligkeitseinstellung
|
||||||
</UDivider>
|
</UDivider>
|
||||||
|
|
||||||
<UButton
|
<UButton
|
||||||
v-if="dataStore.activeProfile.id === itemInfo.id"
|
v-if="profileStore.activeProfile.id === itemInfo.id"
|
||||||
:icon="isLight ? 'i-heroicons-moon-20-solid' : 'i-heroicons-sun-20-solid'"
|
:icon="isLight ? 'i-heroicons-moon-20-solid' : 'i-heroicons-sun-20-solid'"
|
||||||
color="white"
|
color="white"
|
||||||
variant="outline"
|
variant="outline"
|
||||||
|
|||||||
@@ -23,6 +23,7 @@ defineShortcuts({
|
|||||||
})
|
})
|
||||||
|
|
||||||
const dataStore = useDataStore()
|
const dataStore = useDataStore()
|
||||||
|
const profileStore = useProfileStore()
|
||||||
const supabase = useSupabaseClient()
|
const supabase = useSupabaseClient()
|
||||||
const user = useSupabaseUser()
|
const user = useSupabaseUser()
|
||||||
const route = useRoute()
|
const route = useRoute()
|
||||||
@@ -90,11 +91,9 @@ const mode = ref(route.params.mode || "show")
|
|||||||
const itemInfo = ref({
|
const itemInfo = ref({
|
||||||
name: "",
|
name: "",
|
||||||
customer: 0,
|
customer: 0,
|
||||||
users: [dataStore.activeProfile.id]
|
profiles: [profileStore.activeProfile.id]
|
||||||
})
|
})
|
||||||
const oldItemInfo = ref({})
|
const oldItemInfo = ref({})
|
||||||
const tags = dataStore.getDocumentTags
|
|
||||||
const phasesTemplates = ref([])
|
|
||||||
|
|
||||||
const plants = ref([])
|
const plants = ref([])
|
||||||
const contracts = ref([])
|
const contracts = ref([])
|
||||||
@@ -180,7 +179,7 @@ const changeActivePhase = async (key) => {
|
|||||||
if(p.key === key) {
|
if(p.key === key) {
|
||||||
p.active = true
|
p.active = true
|
||||||
p.activated_at = dayjs().format()
|
p.activated_at = dayjs().format()
|
||||||
p.activated_by = dataStore.activeProfile.id
|
p.activated_by = profileStore.activeProfile.id
|
||||||
phaseLabel = p.label
|
phaseLabel = p.label
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -191,8 +190,8 @@ const changeActivePhase = async (key) => {
|
|||||||
|
|
||||||
await supabase.from("projects").update({phases: item.phases}).eq("id",item.id)
|
await supabase.from("projects").update({phases: item.phases}).eq("id",item.id)
|
||||||
const {error} = await supabase.from("historyitems").insert({
|
const {error} = await supabase.from("historyitems").insert({
|
||||||
createdBy: dataStore.activeProfile.id,
|
createdBy: profileStore.activeProfile.id,
|
||||||
tenant: dataStore.currentTenant,
|
tenant: profileStore.currentTenant,
|
||||||
text: `Aktive Phase zu "${phaseLabel}" gewechselt`,
|
text: `Aktive Phase zu "${phaseLabel}" gewechselt`,
|
||||||
project: item.id
|
project: item.id
|
||||||
})
|
})
|
||||||
@@ -304,8 +303,8 @@ const invoiceDeliveryNotes = () => {
|
|||||||
<h1 class="font-bold text-lg mb-3">Beteiligte Benutzer:</h1>
|
<h1 class="font-bold text-lg mb-3">Beteiligte Benutzer:</h1>
|
||||||
<UAlert
|
<UAlert
|
||||||
v-for="projectUser in itemInfo.profiles"
|
v-for="projectUser in itemInfo.profiles"
|
||||||
:avatar="{ alt: dataStore.getProfileById(projectUser).fullName }"
|
:avatar="{ alt: profileStore.getProfileById(projectUser).fullName }"
|
||||||
:title="dataStore.getProfileById(projectUser).fullName"
|
:title="profileStore.getProfileById(projectUser).fullName"
|
||||||
class="mb-3"
|
class="mb-3"
|
||||||
|
|
||||||
/>
|
/>
|
||||||
@@ -378,7 +377,7 @@ const invoiceDeliveryNotes = () => {
|
|||||||
|
|
||||||
<div>
|
<div>
|
||||||
<p v-if="item.activated_at" class="text-black">Aktiviert am: {{dayjs(item.activated_at).format("DD.MM.YY HH:mm")}} Uhr</p>
|
<p v-if="item.activated_at" class="text-black">Aktiviert am: {{dayjs(item.activated_at).format("DD.MM.YY HH:mm")}} Uhr</p>
|
||||||
<p v-if="item.activated_by" class="text-black">Aktiviert durch: {{dataStore.getProfileById(item.activated_by).fullName}}</p>
|
<p v-if="item.activated_by" class="text-black">Aktiviert durch: {{profileStore.getProfileById(item.activated_by).fullName}}</p>
|
||||||
<p v-if="item.description" class="text-black">Beschreibung: {{item.description}}</p>
|
<p v-if="item.description" class="text-black">Beschreibung: {{item.description}}</p>
|
||||||
</div>
|
</div>
|
||||||
</UCard>
|
</UCard>
|
||||||
@@ -406,7 +405,7 @@ const invoiceDeliveryNotes = () => {
|
|||||||
|
|
||||||
>
|
>
|
||||||
<template #user-data="{row}">
|
<template #user-data="{row}">
|
||||||
{{dataStore.profiles.find(i => i.id === row.user) ? dataStore.profiles.find(i => i.id === row.user).fullName : ""}}
|
{{profileStore.profiles.find(i => i.id === row.user) ? profileStore.profiles.find(i => i.id === row.user).fullName : ""}}
|
||||||
</template>
|
</template>
|
||||||
</UTable>
|
</UTable>
|
||||||
</UCard>
|
</UCard>
|
||||||
@@ -462,7 +461,7 @@ const invoiceDeliveryNotes = () => {
|
|||||||
<span v-if="row.type === 'deliveryNotes'">Lieferschein</span>
|
<span v-if="row.type === 'deliveryNotes'">Lieferschein</span>
|
||||||
</template>
|
</template>
|
||||||
<template #createdBy-data="{row}">
|
<template #createdBy-data="{row}">
|
||||||
{{dataStore.getProfileById(row.createdBy).fullName}}
|
{{profileStore.getProfileById(row.createdBy).fullName}}
|
||||||
</template>
|
</template>
|
||||||
</UTable>
|
</UTable>
|
||||||
|
|
||||||
@@ -482,7 +481,7 @@ const invoiceDeliveryNotes = () => {
|
|||||||
:empty-state="{ icon: 'i-heroicons-clock', label: 'Noch keine Zeiten in diesem Projekt' }"
|
:empty-state="{ icon: 'i-heroicons-clock', label: 'Noch keine Zeiten in diesem Projekt' }"
|
||||||
>
|
>
|
||||||
<template #user-data="{row}">
|
<template #user-data="{row}">
|
||||||
{{dataStore.profiles.find(profile => profile.id === row.user) ? dataStore.profiles.find(profile => profile.id === row.user).fullName : row.user }}
|
{{profileStore.profiles.find(profile => profile.id === row.user) ? profileStore.profiles.find(profile => profile.id === row.user).fullName : row.user }}
|
||||||
</template>
|
</template>
|
||||||
<template #duration-data="{row}">
|
<template #duration-data="{row}">
|
||||||
{{(row.start && row.end) ? `${String(dayjs(row.end).diff(row.start,'hour',true).toFixed(2)).replace(".",",")} h` : ""}}
|
{{(row.start && row.end) ? `${String(dayjs(row.end).diff(row.start,'hour',true).toFixed(2)).replace(".",",")} h` : ""}}
|
||||||
@@ -640,11 +639,11 @@ const invoiceDeliveryNotes = () => {
|
|||||||
|
|
||||||
|
|
||||||
<UFormGroup
|
<UFormGroup
|
||||||
label="Beteiligte Benutzer:"
|
label="Berechtigte Benutzer:"
|
||||||
>
|
>
|
||||||
<USelectMenu
|
<USelectMenu
|
||||||
v-model="itemInfo.profiles"
|
v-model="itemInfo.profiles"
|
||||||
:options="dataStore.profiles"
|
:options="profileStore.profiles"
|
||||||
option-attribute="fullName"
|
option-attribute="fullName"
|
||||||
value-attribute="id"
|
value-attribute="id"
|
||||||
searchable
|
searchable
|
||||||
@@ -652,7 +651,7 @@ const invoiceDeliveryNotes = () => {
|
|||||||
:search-attributes="['fullName']"
|
:search-attributes="['fullName']"
|
||||||
>
|
>
|
||||||
<template #label>
|
<template #label>
|
||||||
{{itemInfo.profiles.length > 0 ? itemInfo.profiles.map(i => dataStore.getProfileById(i).fullName).join(", ") : "Kein Benutzer ausgewählt"}}
|
{{itemInfo.profiles.length > 0 ? itemInfo.profiles.map(i => profileStore.getProfileById(i).fullName).join(", ") : "Kein Benutzer ausgewählt"}}
|
||||||
</template>
|
</template>
|
||||||
</USelectMenu>
|
</USelectMenu>
|
||||||
</UFormGroup>
|
</UFormGroup>
|
||||||
|
|||||||
@@ -20,6 +20,7 @@ defineShortcuts({
|
|||||||
})
|
})
|
||||||
|
|
||||||
const dataStore = useDataStore()
|
const dataStore = useDataStore()
|
||||||
|
const profileStore = useProfileStore()
|
||||||
const route = useRoute()
|
const route = useRoute()
|
||||||
const router = useRouter()
|
const router = useRouter()
|
||||||
const toast = useToast()
|
const toast = useToast()
|
||||||
@@ -210,7 +211,7 @@ setupPage()
|
|||||||
>
|
>
|
||||||
<USelectMenu
|
<USelectMenu
|
||||||
v-model="itemInfo.tags"
|
v-model="itemInfo.tags"
|
||||||
:options="dataStore.ownTenant.tags.products"
|
:options="profileStore.ownTenant.tags.products"
|
||||||
multiple
|
multiple
|
||||||
/>
|
/>
|
||||||
</UFormGroup>
|
</UFormGroup>
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
<script setup>
|
<script setup>
|
||||||
const dataStore = useDataStore()
|
const dataStore = useDataStore()
|
||||||
|
const profileStore = useProfileStore()
|
||||||
const route = useRoute()
|
const route = useRoute()
|
||||||
const supabase = useSupabaseClient()
|
const supabase = useSupabaseClient()
|
||||||
const toast = useToast()
|
const toast = useToast()
|
||||||
@@ -43,7 +44,7 @@ const generateLink = async () => {
|
|||||||
body: {
|
body: {
|
||||||
method: "generateLink",
|
method: "generateLink",
|
||||||
institutionId: bankData.value.id,
|
institutionId: bankData.value.id,
|
||||||
tenant: dataStore.currentTenant
|
tenant: profileStore.currentTenant
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
@@ -62,7 +63,7 @@ const addAccount = async (account) => {
|
|||||||
accountId: account.id,
|
accountId: account.id,
|
||||||
ownerName: account.owner_name,
|
ownerName: account.owner_name,
|
||||||
iban: account.iban,
|
iban: account.iban,
|
||||||
tenant: dataStore.currentTenant,
|
tenant: profileStore.currentTenant,
|
||||||
bankId: account.institution_id
|
bankId: account.institution_id
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
import axios from "axios"
|
import axios from "axios"
|
||||||
const supabase = useSupabaseClient()
|
const supabase = useSupabaseClient()
|
||||||
const dataStore = useDataStore()
|
const dataStore = useDataStore()
|
||||||
|
const profileStore = useProfileStore()
|
||||||
|
|
||||||
const createEMailAddress = ref("")
|
const createEMailAddress = ref("")
|
||||||
const createEMailType = ref("imap")
|
const createEMailType = ref("imap")
|
||||||
@@ -22,7 +23,7 @@ const createAccount = async () => {
|
|||||||
body: {
|
body: {
|
||||||
emailAddress: createEMailAddress.value,
|
emailAddress: createEMailAddress.value,
|
||||||
accountType: createEMailType.value,
|
accountType: createEMailType.value,
|
||||||
profile: dataStore.activeProfile.id
|
profile: profileStore.activeProfile.id
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ definePageMeta({
|
|||||||
middleware: "auth"
|
middleware: "auth"
|
||||||
})
|
})
|
||||||
const dataStore = useDataStore()
|
const dataStore = useDataStore()
|
||||||
|
const profileStore = useProfileStore()
|
||||||
const supabase = useSupabaseClient()
|
const supabase = useSupabaseClient()
|
||||||
const router = useRouter()
|
const router = useRouter()
|
||||||
|
|
||||||
@@ -71,14 +72,14 @@ const isLight = computed({
|
|||||||
/>
|
/>
|
||||||
<InputGroup>
|
<InputGroup>
|
||||||
<UBadge
|
<UBadge
|
||||||
v-for="tag in dataStore.ownTenant.tags.documents"
|
v-for="tag in profileStore.ownTenant.tags.documents"
|
||||||
>
|
>
|
||||||
{{tag}}
|
{{tag}}
|
||||||
</UBadge>
|
</UBadge>
|
||||||
</InputGroup>
|
</InputGroup>
|
||||||
|
|
||||||
|
|
||||||
{{dataStore.ownTenant.tags}}
|
{{profileStore.ownTenant.tags}}
|
||||||
</div>
|
</div>
|
||||||
</UCard>
|
</UCard>
|
||||||
|
|
||||||
|
|||||||
@@ -87,6 +87,7 @@ defineShortcuts({
|
|||||||
const router = useRouter()
|
const router = useRouter()
|
||||||
const supabase = useSupabaseClient()
|
const supabase = useSupabaseClient()
|
||||||
const dataStore = useDataStore()
|
const dataStore = useDataStore()
|
||||||
|
const profileStore = useProfileStore()
|
||||||
const mode = useRoute().params.mode
|
const mode = useRoute().params.mode
|
||||||
const openTab = ref(0)
|
const openTab = ref(0)
|
||||||
|
|
||||||
@@ -106,7 +107,7 @@ const renderDemoZPL = () => {
|
|||||||
|
|
||||||
const printLabel = async () => {
|
const printLabel = async () => {
|
||||||
await supabase.from("printJobs").insert({
|
await supabase.from("printJobs").insert({
|
||||||
tenant: dataStore.currentTenant,
|
tenant: profileStore.currentTenant,
|
||||||
rawContent: useGenerateZPL(itemInfo.value.handlebarsZPL,{barcode:"XXX"}),
|
rawContent: useGenerateZPL(itemInfo.value.handlebarsZPL,{barcode:"XXX"}),
|
||||||
printerName: "ZD411",
|
printerName: "ZD411",
|
||||||
printServer: "0dbe30f3-3008-4cde-8a7c-e785b1c22bfc"
|
printServer: "0dbe30f3-3008-4cde-8a7c-e785b1c22bfc"
|
||||||
|
|||||||
@@ -5,6 +5,8 @@ definePageMeta({
|
|||||||
|
|
||||||
const supabase = useSupabaseClient()
|
const supabase = useSupabaseClient()
|
||||||
const dataStore = useDataStore()
|
const dataStore = useDataStore()
|
||||||
|
const profileStore = useProfileStore()
|
||||||
|
const profileStore = useProfileStore()
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -38,14 +40,14 @@ const resources = {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const numberRanges = ref(dataStore.ownTenant.numberRanges)
|
const numberRanges = ref(profileStore.ownTenant.numberRanges)
|
||||||
|
|
||||||
const updateNumberRanges = async (range) => {
|
const updateNumberRanges = async (range) => {
|
||||||
|
|
||||||
const {data,error} = await supabase
|
const {data,error} = await supabase
|
||||||
.from("tenants")
|
.from("tenants")
|
||||||
.update({numberRanges: numberRanges.value})
|
.update({numberRanges: numberRanges.value})
|
||||||
.eq('id',dataStore.currentTenant)
|
.eq('id',profileStore.currentTenant)
|
||||||
|
|
||||||
await dataStore.fetchOwnTenant()
|
await dataStore.fetchOwnTenant()
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,12 +16,6 @@ const setupPage = async () => {
|
|||||||
>
|
>
|
||||||
|
|
||||||
</UDashboardNavbar>
|
</UDashboardNavbar>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
{{dataStore.ownTenant.ownFields}}
|
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<style scoped>
|
<style scoped>
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
<script setup>
|
<script setup>
|
||||||
|
|
||||||
const dataStore = useDataStore()
|
const dataStore = useDataStore()
|
||||||
|
const profileStore = useProfileStore()
|
||||||
const supabase = useSupabaseClient()
|
const supabase = useSupabaseClient()
|
||||||
|
|
||||||
const itemInfo = ref({
|
const itemInfo = ref({
|
||||||
@@ -10,17 +11,17 @@ const itemInfo = ref({
|
|||||||
})
|
})
|
||||||
|
|
||||||
const setupPage = async () => {
|
const setupPage = async () => {
|
||||||
itemInfo.value = (await supabase.from("tenants").select().eq("id",dataStore.currentTenant).single()).data
|
itemInfo.value = (await supabase.from("tenants").select().eq("id",profileStore.currentTenant).single()).data
|
||||||
console.log(itemInfo.value)
|
console.log(itemInfo.value)
|
||||||
}
|
}
|
||||||
|
|
||||||
const features = ref(dataStore.ownTenant.features)
|
const features = ref(profileStore.ownTenant.features)
|
||||||
const businessInfo = ref(dataStore.ownTenant.businessInfo)
|
const businessInfo = ref(profileStore.ownTenant.businessInfo)
|
||||||
|
|
||||||
const updateTenant = async (newData) => {
|
const updateTenant = async (newData) => {
|
||||||
const {data,error} = await supabase.from("tenants")
|
const {data,error} = await supabase.from("tenants")
|
||||||
.update(newData)
|
.update(newData)
|
||||||
.eq("id",dataStore.currentTenant)
|
.eq("id",profileStore.currentTenant)
|
||||||
.select()
|
.select()
|
||||||
|
|
||||||
if (error) console.log(error)
|
if (error) console.log(error)
|
||||||
|
|||||||
@@ -79,7 +79,7 @@ function getSpaceProductCount(productId) {
|
|||||||
/*
|
/*
|
||||||
const printSpaceLabel = async () => {
|
const printSpaceLabel = async () => {
|
||||||
axios
|
axios
|
||||||
.post(`http://${dataStore.ownTenant.value.labelPrinterIp}/pstprnt`, `^XA^FO10,20^BCN,100^FD${itemInfo.value.spaceNumber}^XZ` )
|
.post(`http://${profileStore.ownTenant.value.labelPrinterIp}/pstprnt`, `^XA^FO10,20^BCN,100^FD${itemInfo.value.spaceNumber}^XZ` )
|
||||||
.then(console.log)
|
.then(console.log)
|
||||||
.catch(console.log)
|
.catch(console.log)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ definePageMeta({
|
|||||||
})
|
})
|
||||||
|
|
||||||
const dataStore = useDataStore()
|
const dataStore = useDataStore()
|
||||||
|
const profileStore = useProfileStore()
|
||||||
const route = useRoute()
|
const route = useRoute()
|
||||||
const router = useRouter()
|
const router = useRouter()
|
||||||
const toast = useToast()
|
const toast = useToast()
|
||||||
@@ -12,7 +13,7 @@ const id = ref(route.params.id ? route.params.id : null )
|
|||||||
//Working
|
//Working
|
||||||
const mode = ref(route.params.mode || "show")
|
const mode = ref(route.params.mode || "show")
|
||||||
const itemInfo = ref({
|
const itemInfo = ref({
|
||||||
profile: dataStore.activeProfile.id
|
profile: profileStore.activeProfile.id
|
||||||
})
|
})
|
||||||
const oldItemInfo = ref({})
|
const oldItemInfo = ref({})
|
||||||
const categories = ["Offen", "In Bearbeitung", "Dringed", "Erledigt"]
|
const categories = ["Offen", "In Bearbeitung", "Dringed", "Erledigt"]
|
||||||
@@ -148,7 +149,7 @@ setupPage()
|
|||||||
>
|
>
|
||||||
<USelectMenu
|
<USelectMenu
|
||||||
v-model="itemInfo.profile"
|
v-model="itemInfo.profile"
|
||||||
:options="dataStore.profiles"
|
:options="profileStore.profiles"
|
||||||
option-attribute="fullName"
|
option-attribute="fullName"
|
||||||
value-attribute="id"
|
value-attribute="id"
|
||||||
searchable-placeholder="Suche..."
|
searchable-placeholder="Suche..."
|
||||||
@@ -156,7 +157,7 @@ setupPage()
|
|||||||
:search-attributes="['fullName']"
|
:search-attributes="['fullName']"
|
||||||
>
|
>
|
||||||
<template #label>
|
<template #label>
|
||||||
{{dataStore.getProfileById(itemInfo.profile) ? dataStore.getProfileById(itemInfo.profile).fullName : "Kein Benutzer ausgewählt"}}
|
{{profileStore.getProfileById(itemInfo.profile) ? profileStore.getProfileById(itemInfo.profile).fullName : "Kein Benutzer ausgewählt"}}
|
||||||
</template>
|
</template>
|
||||||
</USelectMenu>
|
</USelectMenu>
|
||||||
</UFormGroup>
|
</UFormGroup>
|
||||||
|
|||||||
@@ -64,7 +64,7 @@
|
|||||||
{{row.created_at ? dayjs(row.created_at).format("DD.MM.YY HH:mm") : ''}}
|
{{row.created_at ? dayjs(row.created_at).format("DD.MM.YY HH:mm") : ''}}
|
||||||
</template>
|
</template>
|
||||||
<template #user-data="{row}">
|
<template #user-data="{row}">
|
||||||
{{dataStore.profiles.find(i => i.id === row.user) ? dataStore.profiles.find(i => i.id === row.user).fullName : ""}}
|
{{profileStore.profiles.find(i => i.id === row.user) ? profileStore.profiles.find(i => i.id === row.user).fullName : ""}}
|
||||||
</template>
|
</template>
|
||||||
<template #project-data="{row}">
|
<template #project-data="{row}">
|
||||||
{{dataStore.projects.find(i => i.id === row.project) ? dataStore.projects.find(i => i.id === row.project).name : ""}}
|
{{dataStore.projects.find(i => i.id === row.project) ? dataStore.projects.find(i => i.id === row.project).name : ""}}
|
||||||
@@ -86,6 +86,7 @@ definePageMeta({
|
|||||||
})
|
})
|
||||||
|
|
||||||
const dataStore = useDataStore()
|
const dataStore = useDataStore()
|
||||||
|
const profileStore = useProfileStore()
|
||||||
const router = useRouter()
|
const router = useRouter()
|
||||||
|
|
||||||
defineShortcuts({
|
defineShortcuts({
|
||||||
|
|||||||
@@ -23,6 +23,7 @@ defineShortcuts({
|
|||||||
})
|
})
|
||||||
|
|
||||||
const dataStore = useDataStore()
|
const dataStore = useDataStore()
|
||||||
|
const profileStore = useProfileStore()
|
||||||
const route = useRoute()
|
const route = useRoute()
|
||||||
const router = useRouter()
|
const router = useRouter()
|
||||||
const toast = useToast()
|
const toast = useToast()
|
||||||
@@ -205,7 +206,7 @@ setupPage()
|
|||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td>Fahrer:</td>
|
<td>Fahrer:</td>
|
||||||
<td>{{dataStore.profiles.find(profile => profile.id === itemInfo.driver) ? dataStore.profiles.find(profile => profile.id === itemInfo.driver).fullName : 'Kein Fahrer gewählt'}}</td>
|
<td>{{profileStore.profiles.find(profile => profile.id === itemInfo.driver) ? profileStore.profiles.find(profile => profile.id === itemInfo.driver).fullName : 'Kein Fahrer gewählt'}}</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td>Tankvolumen:</td>
|
<td>Tankvolumen:</td>
|
||||||
@@ -334,13 +335,13 @@ setupPage()
|
|||||||
>
|
>
|
||||||
<USelectMenu
|
<USelectMenu
|
||||||
v-model="itemInfo.driver"
|
v-model="itemInfo.driver"
|
||||||
:options="[{id: null, fullName: 'Kein Fahrer'},...dataStore.profiles]"
|
:options="[{id: null, fullName: 'Kein Fahrer'},...profileStore.profiles]"
|
||||||
option-attribute="fullName"
|
option-attribute="fullName"
|
||||||
value-attribute="id"
|
value-attribute="id"
|
||||||
|
|
||||||
>
|
>
|
||||||
<template #label>
|
<template #label>
|
||||||
{{dataStore.profiles.find(profile => profile.id === itemInfo.driver) ? dataStore.profiles.find(profile => profile.id === itemInfo.driver).fullName : 'Kein Fahrer ausgewählt'}}
|
{{profileStore.profiles.find(profile => profile.id === itemInfo.driver) ? profileStore.profiles.find(profile => profile.id === itemInfo.driver).fullName : 'Kein Fahrer ausgewählt'}}
|
||||||
</template>
|
</template>
|
||||||
</USelectMenu>
|
</USelectMenu>
|
||||||
</UFormGroup>
|
</UFormGroup>
|
||||||
|
|||||||
23
pages/vendors/[mode]/[[id]].vue
vendored
23
pages/vendors/[mode]/[[id]].vue
vendored
@@ -21,10 +21,9 @@ defineShortcuts({
|
|||||||
})
|
})
|
||||||
|
|
||||||
const dataStore = useDataStore()
|
const dataStore = useDataStore()
|
||||||
|
const profileStore = useProfileStore()
|
||||||
const route = useRoute()
|
const route = useRoute()
|
||||||
const router = useRouter()
|
const router = useRouter()
|
||||||
const toast = useToast()
|
|
||||||
const id = ref(route.params.id ? route.params.id : null )
|
|
||||||
const openTab = ref(0)
|
const openTab = ref(0)
|
||||||
let currentItem = ref(null)
|
let currentItem = ref(null)
|
||||||
|
|
||||||
@@ -33,7 +32,8 @@ let currentItem = ref(null)
|
|||||||
//Working
|
//Working
|
||||||
const mode = ref(route.params.mode || "show")
|
const mode = ref(route.params.mode || "show")
|
||||||
const itemInfo = ref({
|
const itemInfo = ref({
|
||||||
infoData: {}
|
infoData: {},
|
||||||
|
profiles: [profileStore.activeProfile.id]
|
||||||
})
|
})
|
||||||
const oldItemInfo = ref({})
|
const oldItemInfo = ref({})
|
||||||
|
|
||||||
@@ -266,6 +266,23 @@ setupPage()
|
|||||||
v-model="itemInfo.infoData.ustid"
|
v-model="itemInfo.infoData.ustid"
|
||||||
/>
|
/>
|
||||||
</UFormGroup>
|
</UFormGroup>
|
||||||
|
<UFormGroup
|
||||||
|
label="Berechtigte Benutzer:"
|
||||||
|
>
|
||||||
|
<USelectMenu
|
||||||
|
v-model="itemInfo.profiles"
|
||||||
|
:options="profileStore.profiles"
|
||||||
|
option-attribute="fullName"
|
||||||
|
value-attribute="id"
|
||||||
|
searchable
|
||||||
|
multipledataStore
|
||||||
|
:search-attributes="['fullName']"
|
||||||
|
>
|
||||||
|
<template #label>
|
||||||
|
{{itemInfo.profiles.length > 0 ? itemInfo.profiles.map(i => profileStore.getProfileById(i).fullName).join(", ") : "Kein Benutzer ausgewählt"}}
|
||||||
|
</template>
|
||||||
|
</USelectMenu>
|
||||||
|
</UFormGroup>
|
||||||
</UForm>
|
</UForm>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ import dayjs from "dayjs";
|
|||||||
|
|
||||||
|
|
||||||
const dataStore = useDataStore()
|
const dataStore = useDataStore()
|
||||||
|
const profileStore = useProfileStore()
|
||||||
const route = useRoute()
|
const route = useRoute()
|
||||||
const router = useRouter()
|
const router = useRouter()
|
||||||
const toast = useToast()
|
const toast = useToast()
|
||||||
@@ -12,7 +13,7 @@ const mode = ref(route.params.mode || "show")
|
|||||||
const itemInfo = ref({
|
const itemInfo = ref({
|
||||||
startDate: new Date(),
|
startDate: new Date(),
|
||||||
endDate: new Date(),
|
endDate: new Date(),
|
||||||
profile: dataStore.activeProfile.id
|
profile: profileStore.activeProfile.id
|
||||||
})
|
})
|
||||||
const oldItemInfo = ref({})
|
const oldItemInfo = ref({})
|
||||||
|
|
||||||
@@ -88,7 +89,7 @@ setupPage()
|
|||||||
label="Mitarbeiter:"
|
label="Mitarbeiter:"
|
||||||
>
|
>
|
||||||
<USelectMenu
|
<USelectMenu
|
||||||
:options="dataStore.profiles"
|
:options="profileStore.profiles"
|
||||||
v-model="itemInfo.profile"
|
v-model="itemInfo.profile"
|
||||||
option-attribute="fullName"
|
option-attribute="fullName"
|
||||||
value-attribute="id"
|
value-attribute="id"
|
||||||
|
|||||||
@@ -15,6 +15,7 @@ dayjs.extend(isSameOrBefore)
|
|||||||
|
|
||||||
|
|
||||||
const dataStore = useDataStore()
|
const dataStore = useDataStore()
|
||||||
|
const profileStore = useProfileStore()
|
||||||
const supabase = useSupabaseClient()
|
const supabase = useSupabaseClient()
|
||||||
const route = useRoute()
|
const route = useRoute()
|
||||||
const router = useRouter()
|
const router = useRouter()
|
||||||
@@ -27,7 +28,7 @@ const absencerequests = ref([])
|
|||||||
|
|
||||||
|
|
||||||
const setupPage = async () => {
|
const setupPage = async () => {
|
||||||
if(route.params.id) itemInfo.value = dataStore.getProfileById(route.params.id)
|
if(route.params.id) itemInfo.value = profileStore.getProfileById(route.params.id)
|
||||||
if(itemInfo.value.id) oldItemInfo.value = JSON.parse(JSON.stringify(itemInfo.value))
|
if(itemInfo.value.id) oldItemInfo.value = JSON.parse(JSON.stringify(itemInfo.value))
|
||||||
workingtimes.value = (await supabase.from("workingtimes").select().eq("profile",itemInfo.value.id).order("startDate",{ascending:false})).data
|
workingtimes.value = (await supabase.from("workingtimes").select().eq("profile",itemInfo.value.id).order("startDate",{ascending:false})).data
|
||||||
absencerequests.value = (await supabase.from("absencerequests").select().eq("user",itemInfo.value.id).order("start",{ascending: false})).data
|
absencerequests.value = (await supabase.from("absencerequests").select().eq("user",itemInfo.value.id).order("start",{ascending: false})).data
|
||||||
@@ -177,13 +178,13 @@ const getDuration = (time) => {
|
|||||||
const showDocument = ref(false)
|
const showDocument = ref(false)
|
||||||
const uri = ref("")
|
const uri = ref("")
|
||||||
const generateDocument = async () => {
|
const generateDocument = async () => {
|
||||||
const ownTenant = dataStore.ownTenant
|
const ownTenant = profileStore.ownTenant
|
||||||
const path = ownTenant.letterheadConfig["workingTimesEvaluation"]
|
const path = ownTenant.letterheadConfig["workingTimesEvaluation"]
|
||||||
|
|
||||||
const {data,error} = await supabase.storage.from("files").download(path)
|
const {data,error} = await supabase.storage.from("files").download(path)
|
||||||
|
|
||||||
uri.value = await useCreateWorkingTimesPdf({
|
uri.value = await useCreateWorkingTimesPdf({
|
||||||
profile: dataStore.getProfileById(route.params.id).fullName,
|
profile: profileStore.getProfileById(route.params.id).fullName,
|
||||||
...workingTimeInfo.value}, await data.arrayBuffer())
|
...workingTimeInfo.value}, await data.arrayBuffer())
|
||||||
//alert(uri.value)
|
//alert(uri.value)
|
||||||
showDocument.value = true
|
showDocument.value = true
|
||||||
@@ -345,7 +346,7 @@ changeRange()
|
|||||||
]"
|
]"
|
||||||
>
|
>
|
||||||
<template #profile-data="{row}">
|
<template #profile-data="{row}">
|
||||||
{{dataStore.profiles.find(profile => profile.id === row.profile) ? dataStore.profiles.find(profile => profile.id === row.profile).fullName : row.profile }}
|
{{profileStore.profiles.find(profile => profile.id === row.profile) ? profileStore.profiles.find(profile => profile.id === row.profile).fullName : row.profile }}
|
||||||
</template>
|
</template>
|
||||||
<template #approved-data="{row}">
|
<template #approved-data="{row}">
|
||||||
<span v-if="row.approved" class="text-primary-500">Ja</span>
|
<span v-if="row.approved" class="text-primary-500">Ja</span>
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ definePageMeta({
|
|||||||
})
|
})
|
||||||
|
|
||||||
const dataStore = useDataStore()
|
const dataStore = useDataStore()
|
||||||
|
const profileStore = useProfileStore()
|
||||||
const supabase = useSupabaseClient()
|
const supabase = useSupabaseClient()
|
||||||
const user = useSupabaseUser()
|
const user = useSupabaseUser()
|
||||||
const toast = useToast()
|
const toast = useToast()
|
||||||
@@ -22,7 +23,7 @@ const timeInfo = ref({
|
|||||||
notes: null,
|
notes: null,
|
||||||
})
|
})
|
||||||
|
|
||||||
const filterUser = ref(dataStore.activeProfile.id || "")
|
const filterUser = ref(profileStore.activeProfile.id || "")
|
||||||
|
|
||||||
const workingtimes = ref([])
|
const workingtimes = ref([])
|
||||||
|
|
||||||
@@ -43,15 +44,6 @@ const filteredRows = computed(() => {
|
|||||||
|
|
||||||
times = times.filter(i => i.profile === filterUser.value)
|
times = times.filter(i => i.profile === filterUser.value)
|
||||||
|
|
||||||
/*if(dataStore.hasRight('viewTimes')) {
|
|
||||||
if(filterUser.value !== "") {
|
|
||||||
times = times.filter(i => i.profile === filterUser.value)
|
|
||||||
}
|
|
||||||
} else if(dataStore.hasRight('viewOwnTimes')) {
|
|
||||||
times = times.filter(i => i.profile === dataStore.getOwnProfile.id)
|
|
||||||
} else {
|
|
||||||
times = []
|
|
||||||
}*/
|
|
||||||
|
|
||||||
return times/*.map(i => {
|
return times/*.map(i => {
|
||||||
return {
|
return {
|
||||||
@@ -115,16 +107,15 @@ const columns = [
|
|||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|
||||||
console.log(dataStore.workingtimes)
|
|
||||||
|
|
||||||
const runningTimeInfo = ref({})
|
const runningTimeInfo = ref({})
|
||||||
|
|
||||||
const startTime = async () => {
|
const startTime = async () => {
|
||||||
console.log("started")
|
console.log("started")
|
||||||
timeInfo.value = {
|
timeInfo.value = {
|
||||||
profile: dataStore.activeProfile.id,
|
profile: profileStore.activeProfile.id,
|
||||||
startDate: dayjs(),
|
startDate: dayjs(),
|
||||||
tenant: dataStore.currentTenant,
|
tenant: profileStore.currentTenant,
|
||||||
state: "Im Web gestartet"
|
state: "Im Web gestartet"
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -137,7 +128,7 @@ const startTime = async () => {
|
|||||||
} else if(data) {
|
} else if(data) {
|
||||||
//timeInfo.value = data[0]
|
//timeInfo.value = data[0]
|
||||||
await dataStore.fetchWorkingTimes()
|
await dataStore.fetchWorkingTimes()
|
||||||
runningTimeInfo.value = timeInfo.value//dataStore.times.find(time => time.profile === dataStore.activeProfile.id && !time.endDate)
|
runningTimeInfo.value = timeInfo.value//dataStore.times.find(time => time.profile === profileStore.activeProfile.id && !time.endDate)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -161,8 +152,8 @@ const stopStartedTime = async () => {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(dataStore.workingtimes.find(time => time.profile === dataStore.activeProfile.id && !time.endDate)) {
|
if(dataStore.workingtimes.find(time => time.profile === profileStore.activeProfile.id && !time.endDate)) {
|
||||||
runningTimeInfo.value = dataStore.workingtimes.find(time => time.profile === dataStore.activeProfile.id && !time.end)
|
runningTimeInfo.value = dataStore.workingtimes.find(time => time.profile === profileStore.activeProfile.id && !time.end)
|
||||||
}
|
}
|
||||||
|
|
||||||
const getDuration = (time) => {
|
const getDuration = (time) => {
|
||||||
@@ -216,14 +207,14 @@ const expand = ref({
|
|||||||
<template #left>
|
<template #left>
|
||||||
|
|
||||||
<USelectMenu
|
<USelectMenu
|
||||||
:options="dataStore.profiles"
|
:options="profileStore.profiles"
|
||||||
option-attribute="fullName"
|
option-attribute="fullName"
|
||||||
value-attribute="id"
|
value-attribute="id"
|
||||||
v-model="filterUser"
|
v-model="filterUser"
|
||||||
@change="setupPage"
|
@change="setupPage"
|
||||||
>
|
>
|
||||||
<template #label>
|
<template #label>
|
||||||
{{dataStore.getProfileById(filterUser) ? dataStore.getProfileById(filterUser).fullName : "Kein Benutzer ausgewählt"}}
|
{{profileStore.getProfileById(filterUser) ? profileStore.getProfileById(filterUser).fullName : "Kein Benutzer ausgewählt"}}
|
||||||
</template>
|
</template>
|
||||||
</USelectMenu>
|
</USelectMenu>
|
||||||
<UButton
|
<UButton
|
||||||
@@ -337,7 +328,7 @@ const expand = ref({
|
|||||||
|
|
||||||
</div>
|
</div>
|
||||||
<div class="px-4 pb-4" v-else>
|
<div class="px-4 pb-4" v-else>
|
||||||
<p><span class="font-bold">Mitarbeitende/r:</span> {{dataStore.getProfileById(row.profile).fullName}}</p>
|
<p><span class="font-bold">Mitarbeitende/r:</span> {{profileStore.getProfileById(row.profile).fullName}}</p>
|
||||||
<p><span class="font-bold">Start:</span> {{dayjs(row.startDate).format("DD.MM.YYYY HH:mm")}}</p>
|
<p><span class="font-bold">Start:</span> {{dayjs(row.startDate).format("DD.MM.YYYY HH:mm")}}</p>
|
||||||
<p><span class="font-bold">Ende:</span> {{dayjs(row.endDate).format("DD.MM.YYYY HH:mm")}}</p>
|
<p><span class="font-bold">Ende:</span> {{dayjs(row.endDate).format("DD.MM.YYYY HH:mm")}}</p>
|
||||||
<p><span class="font-bold">Genehmigt:</span> {{row.approved ? "Ja" : "Nein"}}</p>
|
<p><span class="font-bold">Genehmigt:</span> {{row.approved ? "Ja" : "Nein"}}</p>
|
||||||
@@ -345,7 +336,7 @@ const expand = ref({
|
|||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
<template #profile-data="{row}">
|
<template #profile-data="{row}">
|
||||||
{{dataStore.profiles.find(profile => profile.id === row.profile) ? dataStore.profiles.find(profile => profile.id === row.profile).fullName : row.profile }}
|
{{profileStore.profiles.find(profile => profile.id === row.profile) ? profileStore.profiles.find(profile => profile.id === row.profile).fullName : row.profile }}
|
||||||
</template>
|
</template>
|
||||||
<template #approved-data="{row}">
|
<template #approved-data="{row}">
|
||||||
<span v-if="row.approved" class="text-primary-500">Ja</span>
|
<span v-if="row.approved" class="text-primary-500">Ja</span>
|
||||||
|
|||||||
385
stores/data.js
385
stores/data.js
@@ -18,6 +18,7 @@ import unit from "~/components/columnRenderings/unit.vue";
|
|||||||
export const useDataStore = defineStore('data', () => {
|
export const useDataStore = defineStore('data', () => {
|
||||||
|
|
||||||
const supabase = useSupabaseClient()
|
const supabase = useSupabaseClient()
|
||||||
|
const profileStore = useProfileStore()
|
||||||
const user = useSupabaseUser()
|
const user = useSupabaseUser()
|
||||||
const toast = useToast()
|
const toast = useToast()
|
||||||
const router = useRouter()
|
const router = useRouter()
|
||||||
@@ -477,28 +478,6 @@ export const useDataStore = defineStore('data', () => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
const loaded = ref(false)
|
|
||||||
const showProfileSelection = ref(false)
|
|
||||||
const ownTenant = ref({
|
|
||||||
calendarConfig: {
|
|
||||||
eventTypes: []
|
|
||||||
},
|
|
||||||
timeConfig: {
|
|
||||||
timeTypes: []
|
|
||||||
},
|
|
||||||
tags: {
|
|
||||||
documents: [] ,
|
|
||||||
products: []
|
|
||||||
},
|
|
||||||
measures: []
|
|
||||||
})
|
|
||||||
|
|
||||||
|
|
||||||
const profiles = ref([])
|
|
||||||
const ownProfiles = ref([])
|
|
||||||
const activeProfile = ref([])
|
|
||||||
const tenants = ref([])
|
|
||||||
const currentTenant = ref(null)
|
|
||||||
const events = ref([])
|
const events = ref([])
|
||||||
const customers = ref([])
|
const customers = ref([])
|
||||||
const tasks = ref([])
|
const tasks = ref([])
|
||||||
@@ -520,7 +499,6 @@ export const useDataStore = defineStore('data', () => {
|
|||||||
const bankstatements = ref([])
|
const bankstatements = ref([])
|
||||||
const bankrequisitions = ref([])
|
const bankrequisitions = ref([])
|
||||||
const historyItems = ref([])
|
const historyItems = ref([])
|
||||||
const numberRanges = ref([])
|
|
||||||
const notifications = ref([])
|
const notifications = ref([])
|
||||||
const absencerequests = ref([])
|
const absencerequests = ref([])
|
||||||
const accounts = ref([])
|
const accounts = ref([])
|
||||||
@@ -538,125 +516,7 @@ export const useDataStore = defineStore('data', () => {
|
|||||||
const servicecategories =ref([])
|
const servicecategories =ref([])
|
||||||
const resources =ref([])
|
const resources =ref([])
|
||||||
|
|
||||||
|
|
||||||
/*const rights = ref({
|
|
||||||
createUser: {label: "Benutzer erstellen"},
|
|
||||||
modifyUser: {label: "Benutzer bearbeiten"},
|
|
||||||
deactivateUser: {label: "Benutzer sperren"},
|
|
||||||
createProject: {label: "Projekt erstellen"},
|
|
||||||
viewOwnProjects: {label: "Eigene Projekte sehen"},
|
|
||||||
viewAllProjects: {label: "Alle Projekte sehen"},
|
|
||||||
createTask: {label: "Aufgabe erstellen"},
|
|
||||||
viewOwnTasks: {label:"Eigene Aufgaben sehen"},
|
|
||||||
viewAllTasks: {label: "Alle Aufgaben sehen"},
|
|
||||||
trackOwnTime: {label:"Eigene Zeite erfassen"},
|
|
||||||
createOwnTime: {label:"Eigene Zeiten erstellen"},
|
|
||||||
createTime: {label:"Zeiten erstellen"},
|
|
||||||
viewOwnTimes: {label:"Eigene Zeiten anzeigen"},
|
|
||||||
viewTimes: {label:"Zeiten anzeigen"},
|
|
||||||
})*/
|
|
||||||
|
|
||||||
/*const roles = ref([
|
|
||||||
{
|
|
||||||
key: "tenantAdmin",
|
|
||||||
label: "Firmenadministrator",
|
|
||||||
rights: [
|
|
||||||
...Object.keys(rights.value)
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
key:"worker",
|
|
||||||
label: "Monteur",
|
|
||||||
rights: [
|
|
||||||
"viewOwnProjects",
|
|
||||||
"createTasks",
|
|
||||||
"viewOwnTasks",
|
|
||||||
"viewOwnTimes",
|
|
||||||
"createOwnTime"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
key:"manager",
|
|
||||||
label: "Vorarbeiter",
|
|
||||||
rights: [
|
|
||||||
"createProjects",
|
|
||||||
"viewOwnProjects",
|
|
||||||
"createTasks",
|
|
||||||
"viewOwnTasks",
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
key:"booker",
|
|
||||||
label: "Buchhalter",
|
|
||||||
rights: [
|
|
||||||
"createTasks",
|
|
||||||
"viewOwnTasks",
|
|
||||||
"createTime",
|
|
||||||
"viewAllTimes"
|
|
||||||
]
|
|
||||||
}
|
|
||||||
])*/
|
|
||||||
|
|
||||||
async function initializeData (userId) {
|
|
||||||
|
|
||||||
let profileconnections = (await supabase.from("profileconnections").select()).data
|
|
||||||
let profiles = (await supabase.from("profiles").select("*, role(*)")).data
|
|
||||||
let activeProfileConnection = profileconnections.find(i => i.active)
|
|
||||||
if(activeProfileConnection) {
|
|
||||||
activeProfile.value = profiles.find(i => i.id === activeProfileConnection.profile_id)
|
|
||||||
currentTenant.value = activeProfile.value.tenant
|
|
||||||
|
|
||||||
await fetchData()
|
|
||||||
|
|
||||||
//loaded.value = true
|
|
||||||
|
|
||||||
} else {
|
|
||||||
await fetchOwnProfiles()
|
|
||||||
await fetchTenants()
|
|
||||||
showProfileSelection.value = true
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
async function changeProfile(newActiveProfileId) {
|
|
||||||
loaded.value = false
|
|
||||||
|
|
||||||
let profileconnections = (await supabase.from("profileconnections").select()).data
|
|
||||||
|
|
||||||
let oldActiveProfileConnection = profileconnections.find(i => i.active)
|
|
||||||
|
|
||||||
const {error} = await supabase.from("profileconnections").update({active: true}).eq("profile_id", newActiveProfileId)
|
|
||||||
|
|
||||||
if(error) {
|
|
||||||
console.log(error)
|
|
||||||
} else {
|
|
||||||
if(oldActiveProfileConnection){
|
|
||||||
const {error} = await supabase.from("profileconnections").update({active: false}).eq("profile_id", oldActiveProfileConnection.profile_id)
|
|
||||||
}
|
|
||||||
|
|
||||||
reloadNuxtApp({
|
|
||||||
path:"/",
|
|
||||||
ttl: 10000
|
|
||||||
})
|
|
||||||
|
|
||||||
/*await clearStore()
|
|
||||||
await fetchData()
|
|
||||||
router.push("/")
|
|
||||||
loaded.value = true*/
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
async function fetchData () {
|
async function fetchData () {
|
||||||
await fetchOwnProfiles()
|
|
||||||
await fetchProfiles()
|
|
||||||
|
|
||||||
await fetchTenants()
|
|
||||||
await fetchOwnTenant()
|
|
||||||
|
|
||||||
//loaded.value = true
|
|
||||||
await fetchDocuments()
|
await fetchDocuments()
|
||||||
await fetchEvents()
|
await fetchEvents()
|
||||||
await fetchTasks()
|
await fetchTasks()
|
||||||
@@ -678,7 +538,6 @@ export const useDataStore = defineStore('data', () => {
|
|||||||
await fetchBankStatements()
|
await fetchBankStatements()
|
||||||
await fetchBankRequisitions()
|
await fetchBankRequisitions()
|
||||||
await fetchHistoryItems()
|
await fetchHistoryItems()
|
||||||
await fetchNumberRanges()
|
|
||||||
await fetchNotifications()
|
await fetchNotifications()
|
||||||
await fetchAbsenceRequests()
|
await fetchAbsenceRequests()
|
||||||
await fetchAccounts()
|
await fetchAccounts()
|
||||||
@@ -695,18 +554,9 @@ export const useDataStore = defineStore('data', () => {
|
|||||||
await fetchServices()
|
await fetchServices()
|
||||||
await fetchServiceCategories()
|
await fetchServiceCategories()
|
||||||
await fetchResources()
|
await fetchResources()
|
||||||
loaded.value = true
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function clearStore () {
|
function clearStore () {
|
||||||
console.log("Clear")
|
|
||||||
loaded.value = false
|
|
||||||
ownTenant.value = {}
|
|
||||||
profiles.value = []
|
|
||||||
ownProfiles.value = []
|
|
||||||
tenants.value = []
|
|
||||||
events.value= []
|
events.value= []
|
||||||
customers.value= []
|
customers.value= []
|
||||||
tasks.value= []
|
tasks.value= []
|
||||||
@@ -728,7 +578,6 @@ export const useDataStore = defineStore('data', () => {
|
|||||||
bankstatements.value= []
|
bankstatements.value= []
|
||||||
bankrequisitions.value= []
|
bankrequisitions.value= []
|
||||||
historyItems.value = []
|
historyItems.value = []
|
||||||
numberRanges.value = []
|
|
||||||
notifications.value = []
|
notifications.value = []
|
||||||
absencerequests.value = []
|
absencerequests.value = []
|
||||||
accounts.value = []
|
accounts.value = []
|
||||||
@@ -747,16 +596,6 @@ export const useDataStore = defineStore('data', () => {
|
|||||||
resources.value = []
|
resources.value = []
|
||||||
}
|
}
|
||||||
|
|
||||||
/*function hasRight (right) {
|
|
||||||
const role = profiles.value.find(i => i.id === activeProfile.value.id).role
|
|
||||||
const grantedRights = roles.value.find(i => i.key === role).rights
|
|
||||||
|
|
||||||
if(grantedRights.includes(right)){
|
|
||||||
return true
|
|
||||||
} else return false
|
|
||||||
|
|
||||||
}*/
|
|
||||||
|
|
||||||
var deepDiffMapper = function () {
|
var deepDiffMapper = function () {
|
||||||
return {
|
return {
|
||||||
VALUE_CREATED: 'created',
|
VALUE_CREATED: 'created',
|
||||||
@@ -831,8 +670,6 @@ export const useDataStore = defineStore('data', () => {
|
|||||||
}
|
}
|
||||||
}();
|
}();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
const generateHistoryItems = async (dataType,newData, oldData=null) => {
|
const generateHistoryItems = async (dataType,newData, oldData=null) => {
|
||||||
//console.log(oldData)
|
//console.log(oldData)
|
||||||
//console.log(newData)
|
//console.log(newData)
|
||||||
@@ -1022,7 +859,7 @@ export const useDataStore = defineStore('data', () => {
|
|||||||
createdBy: activeProfile.value.id,
|
createdBy: activeProfile.value.id,
|
||||||
oldVal: prop.data.o,
|
oldVal: prop.data.o,
|
||||||
newVal: prop.data.n,
|
newVal: prop.data.n,
|
||||||
tenant: currentTenant.value
|
tenant: profileStore.currentTenant
|
||||||
}
|
}
|
||||||
|
|
||||||
historyItem[dataTypes[dataType].historyItemHolder] = newData.id
|
historyItem[dataTypes[dataType].historyItemHolder] = newData.id
|
||||||
@@ -1056,7 +893,7 @@ export const useDataStore = defineStore('data', () => {
|
|||||||
let historyItem = {
|
let historyItem = {
|
||||||
text: `${dataTypes[dataType].labelSingle} erstellt`,
|
text: `${dataTypes[dataType].labelSingle} erstellt`,
|
||||||
createdBy: activeProfile.value.id,
|
createdBy: activeProfile.value.id,
|
||||||
tenant: currentTenant.value
|
tenant: profileStore.currentTenant
|
||||||
}
|
}
|
||||||
|
|
||||||
historyItem[dataTypes[dataType].historyItemHolder] = newData.id
|
historyItem[dataTypes[dataType].historyItemHolder] = newData.id
|
||||||
@@ -1075,38 +912,14 @@ export const useDataStore = defineStore('data', () => {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//Realtime Update
|
|
||||||
/*const channelA = supabase
|
|
||||||
.channel('schema-db-changes')
|
|
||||||
.on(
|
|
||||||
'postgres_changes',
|
|
||||||
{
|
|
||||||
event: '*',
|
|
||||||
schema: 'public',
|
|
||||||
},
|
|
||||||
(payload) => {
|
|
||||||
//console.log(payload)
|
|
||||||
|
|
||||||
/!*if(payload.eventType === 'INSERT') {
|
|
||||||
const c = payload.table + '.value.push(' + JSON.stringify(payload.new) + ')'
|
|
||||||
eval(c)
|
|
||||||
} else if(payload.eventType === 'UPDATE'){
|
|
||||||
const c = payload.table + '.value[' + payload.table + '.value.findIndex(i => i.id === ' + JSON.stringify(payload.old.id) + ')] = ' + JSON.stringify(payload.new)
|
|
||||||
eval(c)
|
|
||||||
}*!/
|
|
||||||
}
|
|
||||||
)
|
|
||||||
.subscribe()*/
|
|
||||||
|
|
||||||
async function createNewItem (dataType,data){
|
async function createNewItem (dataType,data){
|
||||||
if(typeOf(data) === 'object') {
|
if(typeOf(data) === 'object') {
|
||||||
data = {...data, tenant: currentTenant.value}
|
data = {...data, tenant: profileStore.currentTenant}
|
||||||
} else if(typeOf(data) === 'array') {
|
} else if(typeOf(data) === 'array') {
|
||||||
data.map(i => {
|
data.map(i => {
|
||||||
return {
|
return {
|
||||||
...i,
|
...i,
|
||||||
tenant: currentTenant.value
|
tenant: profileStore.currentTenant
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@@ -1226,7 +1039,7 @@ export const useDataStore = defineStore('data', () => {
|
|||||||
const {data, error} = await supabase
|
const {data, error} = await supabase
|
||||||
.storage
|
.storage
|
||||||
.from("files")
|
.from("files")
|
||||||
.upload(`${currentTenant.value}/${file.name}`, file, {upsert: upsert})
|
.upload(`${profileStore.currentTenant}/${file.name}`, file, {upsert: upsert})
|
||||||
|
|
||||||
if (error) {
|
if (error) {
|
||||||
console.log(error)
|
console.log(error)
|
||||||
@@ -1246,7 +1059,7 @@ export const useDataStore = defineStore('data', () => {
|
|||||||
} else if (data) {
|
} else if (data) {
|
||||||
const returnPath = data.path
|
const returnPath = data.path
|
||||||
|
|
||||||
documentsToInsert.push({...formData, path: returnPath, tenant: currentTenant.value})
|
documentsToInsert.push({...formData, path: returnPath, tenant: profileStore.currentTenant})
|
||||||
}
|
}
|
||||||
|
|
||||||
//console.log(data)
|
//console.log(data)
|
||||||
@@ -1285,95 +1098,72 @@ export const useDataStore = defineStore('data', () => {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async function fetchOwnTenant () {
|
|
||||||
ownTenant.value = (await supabase.from("tenants").select().eq('id', currentTenant.value).single()).data
|
|
||||||
}
|
|
||||||
|
|
||||||
async function fetchProfiles () {
|
|
||||||
profiles.value = (await supabase.from("profiles").select().eq("tenant",currentTenant.value).order("lastName")).data
|
|
||||||
}
|
|
||||||
|
|
||||||
async function fetchOwnProfiles () {
|
|
||||||
let profiles = (await supabase.from("profiles").select().order("fullName")).data
|
|
||||||
let conns = (await supabase.from("profileconnections").select()).data.map(i => i.profile_id)
|
|
||||||
//console.log(conns)
|
|
||||||
//console.log(profiles.filter(i => conns.includes(i.id)))
|
|
||||||
ownProfiles.value = profiles.filter(i => conns.includes(i.id))
|
|
||||||
}
|
|
||||||
|
|
||||||
async function fetchTenants () {
|
|
||||||
tenants.value = (await supabase.from("tenants").select()).data
|
|
||||||
}
|
|
||||||
|
|
||||||
async function fetchBankAccounts () {
|
async function fetchBankAccounts () {
|
||||||
bankAccounts.value = (await supabase.from("bankaccounts").select().eq('tenant', currentTenant.value)).data
|
bankAccounts.value = (await supabase.from("bankaccounts").select().eq('tenant', profileStore.currentTenant)).data
|
||||||
}
|
}
|
||||||
async function fetchBankStatements () {
|
async function fetchBankStatements () {
|
||||||
bankstatements.value = (await supabase.from("bankstatements").select().eq('tenant', currentTenant.value).order("date", {ascending:false})).data
|
bankstatements.value = (await supabase.from("bankstatements").select().eq('tenant', profileStore.currentTenant).order("date", {ascending:false})).data
|
||||||
}
|
}
|
||||||
async function fetchBankRequisitions () {
|
async function fetchBankRequisitions () {
|
||||||
bankrequisitions.value = (await supabase.from("bankrequisitions").select().eq('status', "LN")).data
|
bankrequisitions.value = (await supabase.from("bankrequisitions").select().eq('status', "LN")).data
|
||||||
}
|
}
|
||||||
async function fetchEvents () {
|
async function fetchEvents () {
|
||||||
events.value = (await supabase.from("events").select().eq('tenant', currentTenant.value)).data
|
events.value = (await supabase.from("events").select().eq('tenant', profileStore.currentTenant)).data
|
||||||
}
|
}
|
||||||
async function fetchContracts () {
|
async function fetchContracts () {
|
||||||
contracts.value = (await supabase.from("contracts").select().eq('tenant', currentTenant.value)).data
|
contracts.value = (await supabase.from("contracts").select().eq('tenant', profileStore.currentTenant)).data
|
||||||
}
|
}
|
||||||
async function fetchContacts () {
|
async function fetchContacts () {
|
||||||
contacts.value = (await supabase.from("contacts").select().eq('tenant', currentTenant.value)).data
|
contacts.value = (await supabase.from("contacts").select().eq('tenant', profileStore.currentTenant)).data
|
||||||
}
|
}
|
||||||
async function fetchCustomers () {
|
async function fetchCustomers () {
|
||||||
customers.value = (await supabase.from("customers").select().eq('tenant', currentTenant.value).order("customerNumber", {ascending:true})).data
|
customers.value = (await supabase.from("customers").select().eq('tenant', profileStore.currentTenant).order("customerNumber", {ascending:true})).data
|
||||||
}
|
}
|
||||||
async function fetchTasks () {
|
async function fetchTasks () {
|
||||||
tasks.value = (await supabase.from("tasks").select().eq('tenant', currentTenant.value)).data
|
tasks.value = (await supabase.from("tasks").select().eq('tenant', profileStore.currentTenant)).data
|
||||||
}
|
}
|
||||||
async function fetchForms () {
|
async function fetchForms () {
|
||||||
forms.value = (await supabase.from("forms").select().eq('tenant', currentTenant.value)).data
|
forms.value = (await supabase.from("forms").select().eq('tenant', profileStore.currentTenant)).data
|
||||||
}
|
}
|
||||||
async function fetchFormSubmits () {
|
async function fetchFormSubmits () {
|
||||||
formSubmits.value = (await supabase.from("formSubmits").select().eq('tenant', currentTenant.value)).data
|
formSubmits.value = (await supabase.from("formSubmits").select().eq('tenant', profileStore.currentTenant)).data
|
||||||
}
|
}
|
||||||
async function fetchProducts () {
|
async function fetchProducts () {
|
||||||
products.value = (await supabase.from("products").select().eq('tenant', currentTenant.value)).data
|
products.value = (await supabase.from("products").select().eq('tenant', profileStore.currentTenant)).data
|
||||||
}
|
}
|
||||||
async function fetchUnits () {
|
async function fetchUnits () {
|
||||||
units.value = (await supabase.from("units").select()).data
|
units.value = (await supabase.from("units").select()).data
|
||||||
}
|
}
|
||||||
async function fetchProjects () {
|
async function fetchProjects () {
|
||||||
projects.value = (await supabase.from("projects").select().eq("tenant",currentTenant.value)).data
|
projects.value = (await supabase.from("projects").select().eq("tenant",profileStore.currentTenant)).data
|
||||||
}
|
}
|
||||||
async function fetchSpaces () {
|
async function fetchSpaces () {
|
||||||
spaces.value = (await supabase.from("spaces").select().eq('tenant', currentTenant.value).order("spaceNumber", {ascending:true})).data
|
spaces.value = (await supabase.from("spaces").select().eq('tenant', profileStore.currentTenant).order("spaceNumber", {ascending:true})).data
|
||||||
}
|
}
|
||||||
async function fetchMovements () {
|
async function fetchMovements () {
|
||||||
movements.value = (await supabase.from("movements").select().eq('tenant', currentTenant.value)).data
|
movements.value = (await supabase.from("movements").select().eq('tenant', profileStore.currentTenant)).data
|
||||||
}
|
}
|
||||||
async function fetchVehicles () {
|
async function fetchVehicles () {
|
||||||
vehicles.value = (await supabase.from("vehicles").select().eq('tenant', currentTenant.value)).data
|
vehicles.value = (await supabase.from("vehicles").select().eq('tenant', profileStore.currentTenant)).data
|
||||||
}
|
}
|
||||||
async function fetchTimes () {
|
async function fetchTimes () {
|
||||||
times.value = (await supabase.from("times").select().eq('tenant', currentTenant.value).order("start", {ascending:false})).data
|
times.value = (await supabase.from("times").select().eq('tenant', profileStore.currentTenant).order("start", {ascending:false})).data
|
||||||
}
|
}
|
||||||
async function fetchHistoryItems () {
|
async function fetchHistoryItems () {
|
||||||
|
|
||||||
historyItems.value = (await supabase.from("historyitems").select().eq('tenant', currentTenant.value)).data
|
historyItems.value = (await supabase.from("historyitems").select().eq('tenant', profileStore.currentTenant)).data
|
||||||
}
|
}
|
||||||
async function fetchVendors () {
|
async function fetchVendors () {
|
||||||
vendors.value = (await supabase.from("vendors").select().eq('tenant', currentTenant.value).order("vendorNumber", {ascending:true})).data
|
vendors.value = (await supabase.from("vendors").select().eq('tenant', profileStore.currentTenant).order("vendorNumber", {ascending:true})).data
|
||||||
}
|
}
|
||||||
async function fetchIncomingInvoices () {
|
async function fetchIncomingInvoices () {
|
||||||
incominginvoices.value = (await supabase.from("incominginvoices").select().eq('tenant', currentTenant.value)).data
|
incominginvoices.value = (await supabase.from("incominginvoices").select().eq('tenant', profileStore.currentTenant)).data
|
||||||
}
|
|
||||||
async function fetchNumberRanges () {
|
|
||||||
numberRanges.value = (await supabase.from("numberranges").select().eq('tenant', currentTenant.value)).data
|
|
||||||
}
|
}
|
||||||
async function fetchNotifications () {
|
async function fetchNotifications () {
|
||||||
notifications.value = (await supabase.from("notifications").select().eq('tenant', currentTenant.value).order("created_at", {ascending: false})).data
|
notifications.value = (await supabase.from("notifications").select().eq('tenant', profileStore.currentTenant).order("created_at", {ascending: false})).data
|
||||||
}
|
}
|
||||||
async function fetchAbsenceRequests () {
|
async function fetchAbsenceRequests () {
|
||||||
absencerequests.value = (await supabase.from("absencerequests").select().eq('tenant', currentTenant.value)).data
|
absencerequests.value = (await supabase.from("absencerequests").select().eq('tenant', profileStore.currentTenant)).data
|
||||||
}
|
}
|
||||||
async function fetchAccounts () {
|
async function fetchAccounts () {
|
||||||
accounts.value = (await supabase.from("accounts").select()).data
|
accounts.value = (await supabase.from("accounts").select()).data
|
||||||
@@ -1382,51 +1172,51 @@ export const useDataStore = defineStore('data', () => {
|
|||||||
taxTypes.value = (await supabase.from("taxtypes").select()).data
|
taxTypes.value = (await supabase.from("taxtypes").select()).data
|
||||||
}
|
}
|
||||||
async function fetchPlants () {
|
async function fetchPlants () {
|
||||||
plants.value = (await supabase.from("plants").select().eq('tenant', currentTenant.value)).data
|
plants.value = (await supabase.from("plants").select().eq('tenant', profileStore.currentTenant)).data
|
||||||
}
|
}
|
||||||
async function fetchInventoryItems () {
|
async function fetchInventoryItems () {
|
||||||
inventoryitems.value = (await supabase.from("inventoryitems").select().eq('tenant', currentTenant.value)).data
|
inventoryitems.value = (await supabase.from("inventoryitems").select().eq('tenant', profileStore.currentTenant)).data
|
||||||
}
|
}
|
||||||
async function fetchChats() {
|
async function fetchChats() {
|
||||||
chats.value = (await supabase.from("chats").select()).data
|
chats.value = (await supabase.from("chats").select()).data
|
||||||
}
|
}
|
||||||
async function fetchMessages() {
|
async function fetchMessages() {
|
||||||
messages.value = (await supabase.from("messages").select().eq('tenant', currentTenant.value).order('created_at', {ascending:true})).data
|
messages.value = (await supabase.from("messages").select().eq('tenant', profileStore.currentTenant).order('created_at', {ascending:true})).data
|
||||||
}
|
}
|
||||||
async function fetchCreatedDocuments() {
|
async function fetchCreatedDocuments() {
|
||||||
createddocuments.value = (await supabase.from("createddocuments").select().eq('tenant', currentTenant.value).order('created_at', {ascending:true})).data
|
createddocuments.value = (await supabase.from("createddocuments").select().eq('tenant', profileStore.currentTenant).order('created_at', {ascending:true})).data
|
||||||
}
|
}
|
||||||
|
|
||||||
async function fetchWorkingTimes() {
|
async function fetchWorkingTimes() {
|
||||||
workingtimes.value = (await supabase.from("workingtimes").select().eq('tenant', currentTenant.value).order('created_at', {ascending:true})).data
|
workingtimes.value = (await supabase.from("workingtimes").select().eq('tenant', profileStore.currentTenant).order('created_at', {ascending:true})).data
|
||||||
}
|
}
|
||||||
|
|
||||||
async function fetchPhasesTemplates() {
|
async function fetchPhasesTemplates() {
|
||||||
phasesTemplates.value = (await supabase.from("phasesTemplates").select().eq('tenant', currentTenant.value).order('created_at', {ascending:true})).data
|
phasesTemplates.value = (await supabase.from("phasesTemplates").select().eq('tenant', profileStore.currentTenant).order('created_at', {ascending:true})).data
|
||||||
}
|
}
|
||||||
|
|
||||||
async function fetchEmailAccounts() {
|
async function fetchEmailAccounts() {
|
||||||
emailAccounts.value = (await supabase.from("emailAccounts").select().eq('tenant', currentTenant.value)).data
|
emailAccounts.value = (await supabase.from("emailAccounts").select().eq('tenant', profileStore.currentTenant)).data
|
||||||
}
|
}
|
||||||
|
|
||||||
async function fetchTextTemplates() {
|
async function fetchTextTemplates() {
|
||||||
texttemplates.value = (await supabase.from("texttemplates").select().eq('tenant', currentTenant.value)).data
|
texttemplates.value = (await supabase.from("texttemplates").select().eq('tenant', profileStore.currentTenant)).data
|
||||||
}
|
}
|
||||||
|
|
||||||
async function fetchServices() {
|
async function fetchServices() {
|
||||||
services.value = (await supabase.from("services").select().eq('tenant', currentTenant.value)).data
|
services.value = (await supabase.from("services").select().eq('tenant', profileStore.currentTenant)).data
|
||||||
}
|
}
|
||||||
|
|
||||||
async function fetchServiceCategories() {
|
async function fetchServiceCategories() {
|
||||||
servicecategories.value = (await supabase.from("servicecategories").select().eq('tenant', currentTenant.value)).data
|
servicecategories.value = (await supabase.from("servicecategories").select().eq('tenant', profileStore.currentTenant)).data
|
||||||
}
|
}
|
||||||
|
|
||||||
async function fetchResources() {
|
async function fetchResources() {
|
||||||
resources.value = (await supabase.from("resources").select().eq('tenant', currentTenant.value)).data
|
resources.value = (await supabase.from("resources").select().eq('tenant', profileStore.currentTenant)).data
|
||||||
}
|
}
|
||||||
|
|
||||||
async function fetchDocuments () {
|
async function fetchDocuments () {
|
||||||
let tempDocuments = (await supabase.from("documents").select().eq('tenant', currentTenant.value)).data
|
let tempDocuments = (await supabase.from("documents").select().eq('tenant', profileStore.currentTenant)).data
|
||||||
|
|
||||||
if(tempDocuments.length > 0){
|
if(tempDocuments.length > 0){
|
||||||
let paths = []
|
let paths = []
|
||||||
@@ -1482,22 +1272,17 @@ export const useDataStore = defineStore('data', () => {
|
|||||||
return tasks.value.filter(task => task.categorie != "Erledigt").length
|
return tasks.value.filter(task => task.categorie != "Erledigt").length
|
||||||
})
|
})
|
||||||
|
|
||||||
const getOwnProfile = computed(() => {
|
|
||||||
return profiles.value.find(i => i.id === user.value.id)
|
|
||||||
|
|
||||||
})
|
|
||||||
|
|
||||||
const getMovementsBySpace = computed(() => (spaceId) => {
|
const getMovementsBySpace = computed(() => (spaceId) => {
|
||||||
return movements.value.filter(movement => movement.spaceId === spaceId)
|
return movements.value.filter(movement => movement.spaceId === spaceId)
|
||||||
})
|
})
|
||||||
|
|
||||||
const getContactsByCustomerId = computed(() => (customerId) => {
|
async function getContactsByCustomerId (itemId) {
|
||||||
return contacts.value.filter(item => item.customer === customerId)
|
return (await supabase.from("contacts").select().eq("customer", itemId)).data
|
||||||
})
|
}
|
||||||
|
|
||||||
const getProjectsByCustomerId = computed(() => (customerId) => {
|
async function getProjectsByCustomerId (itemId) {
|
||||||
return projects.value.filter(item => item.customer === customerId)
|
return (await supabase.from("projects").select().eq("customer",itemId)).data
|
||||||
})
|
}
|
||||||
|
|
||||||
const getPlantsByCustomerId = computed(() => (customerId) => {
|
const getPlantsByCustomerId = computed(() => (customerId) => {
|
||||||
return plants.value.filter(item => item.customer === customerId)
|
return plants.value.filter(item => item.customer === customerId)
|
||||||
@@ -1673,7 +1458,7 @@ export const useDataStore = defineStore('data', () => {
|
|||||||
|
|
||||||
const getResources = computed(() => {
|
const getResources = computed(() => {
|
||||||
return [
|
return [
|
||||||
...profiles.value.filter(i => i.tenant === currentTenant.value).map(profile => {
|
...profiles.value.filter(i => i.tenant === profileStore.currentTenant).map(profile => {
|
||||||
return {
|
return {
|
||||||
type: 'Mitarbeiter',
|
type: 'Mitarbeiter',
|
||||||
title: profile.fullName,
|
title: profile.fullName,
|
||||||
@@ -1699,7 +1484,7 @@ export const useDataStore = defineStore('data', () => {
|
|||||||
|
|
||||||
const getResourcesList = computed(() => {
|
const getResourcesList = computed(() => {
|
||||||
return [
|
return [
|
||||||
...profiles.value.filter(i => i.tenant === currentTenant.value).map(profile => {
|
...profiles.value.filter(i => i.tenant === profileStore.currentTenant).map(profile => {
|
||||||
return {
|
return {
|
||||||
type: 'Mitarbeiter',
|
type: 'Mitarbeiter',
|
||||||
title: profile.fullName,
|
title: profile.fullName,
|
||||||
@@ -1886,10 +1671,6 @@ export const useDataStore = defineStore('data', () => {
|
|||||||
return absencerequests.value.find(item => item.id === itemId)
|
return absencerequests.value.find(item => item.id === itemId)
|
||||||
})
|
})
|
||||||
|
|
||||||
const getProfileById = computed(() => (itemId) => {
|
|
||||||
return profiles.value.find(item => item.id === itemId)
|
|
||||||
})
|
|
||||||
|
|
||||||
const getAccountById = computed(() => (accountId) => {
|
const getAccountById = computed(() => (accountId) => {
|
||||||
return accounts.value.find(item => item.id === accountId)
|
return accounts.value.find(item => item.id === accountId)
|
||||||
})
|
})
|
||||||
@@ -1910,34 +1691,9 @@ export const useDataStore = defineStore('data', () => {
|
|||||||
return bankAccounts.value.find(item => item.id === itemId)
|
return bankAccounts.value.find(item => item.id === itemId)
|
||||||
})
|
})
|
||||||
|
|
||||||
const getEventById = computed(() => (itemId) => {
|
|
||||||
return events.value.find(item => item.id === itemId)
|
|
||||||
})
|
|
||||||
|
|
||||||
const getWorkingTimeById = computed(() => (itemId) => {
|
const getWorkingTimeById = computed(() => (itemId) => {
|
||||||
return workingtimes.value.find(item => item.id === itemId)
|
return workingtimes.value.find(item => item.id === itemId)
|
||||||
})
|
})
|
||||||
|
|
||||||
/*const getOpenDocuments = computed(() => (itemId) => {
|
|
||||||
|
|
||||||
let items = createddocuments.value.filter(i => i.type === "invoices" || i.type === "advanceInvoices")
|
|
||||||
items = items.filter(i => bankstatements.value.filter(x => x.assignments.find(y => y.type === 'createdDocument' && y.id === i.id)).length === 0)
|
|
||||||
|
|
||||||
/!*let finalItems = []
|
|
||||||
items.forEach(item => {
|
|
||||||
if(bankstatements.value.filter(i => i.assignments.find(x => x.id === item.id))){
|
|
||||||
finalItems.push(item)
|
|
||||||
}
|
|
||||||
|
|
||||||
})
|
|
||||||
|
|
||||||
return finalItems*!/
|
|
||||||
|
|
||||||
return items
|
|
||||||
|
|
||||||
//return createddocuments.value.filter(i => (i.type === "invoices" || i.type === "advanceInvoices") && !bankstatements.value.some(x => x.amount -))
|
|
||||||
|
|
||||||
})*/
|
|
||||||
const getOpenIncomingInvoices = computed(() => (itemId) => {
|
const getOpenIncomingInvoices = computed(() => (itemId) => {
|
||||||
|
|
||||||
return incominginvoices.value.filter(i => bankstatements.value.filter(x => x.assignments.find(y => y.type === 'incomingInvoice' && y.id === i.id)).length === 0)
|
return incominginvoices.value.filter(i => bankstatements.value.filter(x => x.assignments.find(y => y.type === 'incomingInvoice' && y.id === i.id)).length === 0)
|
||||||
@@ -1967,22 +1723,11 @@ export const useDataStore = defineStore('data', () => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
return {
|
return {
|
||||||
//General
|
|
||||||
currentTenant,
|
|
||||||
loaded,
|
|
||||||
showProfileSelection,
|
|
||||||
ownTenant,
|
|
||||||
initializeData,
|
|
||||||
changeProfile,
|
|
||||||
uploadFiles,
|
uploadFiles,
|
||||||
generateHistoryItems,
|
generateHistoryItems,
|
||||||
dataTypes,
|
dataTypes,
|
||||||
|
|
||||||
//Data
|
//Data
|
||||||
profiles,
|
|
||||||
ownProfiles,
|
|
||||||
activeProfile,
|
|
||||||
tenants,
|
|
||||||
events,
|
events,
|
||||||
customers,
|
customers,
|
||||||
tasks,
|
tasks,
|
||||||
@@ -2004,7 +1749,6 @@ export const useDataStore = defineStore('data', () => {
|
|||||||
bankstatements,
|
bankstatements,
|
||||||
bankrequisitions,
|
bankrequisitions,
|
||||||
historyItems,
|
historyItems,
|
||||||
numberRanges,
|
|
||||||
notifications,
|
notifications,
|
||||||
absencerequests,
|
absencerequests,
|
||||||
accounts,
|
accounts,
|
||||||
@@ -2027,42 +1771,12 @@ export const useDataStore = defineStore('data', () => {
|
|||||||
updateItem,
|
updateItem,
|
||||||
fetchData,
|
fetchData,
|
||||||
clearStore,
|
clearStore,
|
||||||
fetchOwnTenant,
|
|
||||||
fetchProfiles,
|
|
||||||
fetchOwnProfiles,
|
|
||||||
fetchBankAccounts,
|
|
||||||
fetchBankStatements,
|
|
||||||
fetchBankRequisitions,
|
|
||||||
fetchEvents,
|
|
||||||
fetchContracts,
|
|
||||||
fetchContacts,
|
|
||||||
fetchCustomers,
|
|
||||||
fetchTasks,
|
|
||||||
fetchForms,
|
|
||||||
fetchFormSubmits,
|
|
||||||
fetchProducts,
|
|
||||||
fetchUnits,
|
|
||||||
fetchProjects,
|
|
||||||
fetchSpaces,
|
|
||||||
fetchMovements,
|
|
||||||
fetchVehicles,
|
|
||||||
fetchTimes,
|
fetchTimes,
|
||||||
fetchHistoryItems,
|
|
||||||
fetchVendors,
|
|
||||||
fetchIncomingInvoices,
|
fetchIncomingInvoices,
|
||||||
fetchNumberRanges,
|
|
||||||
fetchNotifications,
|
|
||||||
fetchDocuments,
|
fetchDocuments,
|
||||||
fetchAbsenceRequests,
|
|
||||||
fetchPlants,
|
|
||||||
fetchInventoryItems,
|
|
||||||
fetchChats,
|
|
||||||
fetchMessages,
|
|
||||||
fetchWorkingTimes,
|
fetchWorkingTimes,
|
||||||
addHistoryItem,
|
|
||||||
//Getters
|
//Getters
|
||||||
getOpenTasksCount,
|
getOpenTasksCount,
|
||||||
getOwnProfile,
|
|
||||||
getMovementsBySpace,
|
getMovementsBySpace,
|
||||||
getContactsByCustomerId,
|
getContactsByCustomerId,
|
||||||
getProjectsByCustomerId,
|
getProjectsByCustomerId,
|
||||||
@@ -2115,17 +1829,12 @@ export const useDataStore = defineStore('data', () => {
|
|||||||
getTaskById,
|
getTaskById,
|
||||||
getAbsenceRequestById,
|
getAbsenceRequestById,
|
||||||
getProjectById,
|
getProjectById,
|
||||||
getProfileById,
|
|
||||||
getAccountById,
|
getAccountById,
|
||||||
getPlantById,
|
getPlantById,
|
||||||
getCreatedDocumentById,
|
getCreatedDocumentById,
|
||||||
getInventoryItemById,
|
getInventoryItemById,
|
||||||
getBankAccountById,
|
getBankAccountById,
|
||||||
getEventById,
|
|
||||||
getWorkingTimeById,
|
getWorkingTimeById,
|
||||||
//getOpenDocuments,
|
|
||||||
getOpenIncomingInvoices
|
getOpenIncomingInvoices
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
})
|
})
|
||||||
150
stores/profile.js
Normal file
150
stores/profile.js
Normal file
@@ -0,0 +1,150 @@
|
|||||||
|
import {defineStore} from 'pinia'
|
||||||
|
|
||||||
|
// @ts-ignore
|
||||||
|
export const useProfileStore = defineStore('profile', () => {
|
||||||
|
|
||||||
|
const supabase = useSupabaseClient()
|
||||||
|
const dataStore = useDataStore()
|
||||||
|
const user = useSupabaseUser()
|
||||||
|
const toast = useToast()
|
||||||
|
const router = useRouter()
|
||||||
|
|
||||||
|
const loaded = ref(false)
|
||||||
|
const showProfileSelection = ref(false)
|
||||||
|
const ownTenant = ref({
|
||||||
|
calendarConfig: {
|
||||||
|
eventTypes: []
|
||||||
|
},
|
||||||
|
timeConfig: {
|
||||||
|
timeTypes: []
|
||||||
|
},
|
||||||
|
tags: {
|
||||||
|
documents: [] ,
|
||||||
|
products: []
|
||||||
|
},
|
||||||
|
measures: []
|
||||||
|
})
|
||||||
|
|
||||||
|
|
||||||
|
const profiles = ref([])
|
||||||
|
const ownProfiles = ref([])
|
||||||
|
const activeProfile = ref([])
|
||||||
|
const tenants = ref([])
|
||||||
|
const currentTenant = ref(null)
|
||||||
|
|
||||||
|
|
||||||
|
async function initializeData (userId) {
|
||||||
|
|
||||||
|
let profileconnections = (await supabase.from("profileconnections").select()).data
|
||||||
|
let profiles = (await supabase.from("profiles").select("*, role(*)")).data
|
||||||
|
let activeProfileConnection = profileconnections.find(i => i.active)
|
||||||
|
if(activeProfileConnection) {
|
||||||
|
toast.add({title: 'Aktives Profil ausgewählt'})
|
||||||
|
console.log("Active Profile selected")
|
||||||
|
activeProfile.value = profiles.find(i => i.id === activeProfileConnection.profile_id)
|
||||||
|
currentTenant.value = activeProfile.value.tenant
|
||||||
|
|
||||||
|
await fetchData()
|
||||||
|
await dataStore.fetchData()
|
||||||
|
} else {
|
||||||
|
toast.add({title: 'Kein aktives Profil', color: 'orange'})
|
||||||
|
await fetchOwnProfiles()
|
||||||
|
await fetchTenants()
|
||||||
|
showProfileSelection.value = true
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
async function changeProfile(newActiveProfileId) {
|
||||||
|
loaded.value = false
|
||||||
|
|
||||||
|
let profileconnections = (await supabase.from("profileconnections").select()).data
|
||||||
|
|
||||||
|
let oldActiveProfileConnection = profileconnections.find(i => i.active)
|
||||||
|
|
||||||
|
const {error} = await supabase.from("profileconnections").update({active: true}).eq("profile_id", newActiveProfileId)
|
||||||
|
|
||||||
|
if(error) {
|
||||||
|
console.log(error)
|
||||||
|
} else {
|
||||||
|
if(oldActiveProfileConnection){
|
||||||
|
const {error} = await supabase.from("profileconnections").update({active: false}).eq("profile_id", oldActiveProfileConnection.profile_id)
|
||||||
|
}
|
||||||
|
|
||||||
|
reloadNuxtApp({
|
||||||
|
path:"/",
|
||||||
|
ttl: 10000
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async function fetchData () {
|
||||||
|
await fetchOwnProfiles()
|
||||||
|
await fetchProfiles()
|
||||||
|
|
||||||
|
await fetchTenants()
|
||||||
|
await fetchOwnTenant()
|
||||||
|
|
||||||
|
loaded.value = true
|
||||||
|
console.log("Finished Loading")
|
||||||
|
}
|
||||||
|
|
||||||
|
function clearStore () {
|
||||||
|
loaded.value = false
|
||||||
|
ownTenant.value = {}
|
||||||
|
profiles.value = []
|
||||||
|
ownProfiles.value = []
|
||||||
|
tenants.value = []
|
||||||
|
}
|
||||||
|
|
||||||
|
async function fetchOwnTenant () {
|
||||||
|
ownTenant.value = (await supabase.from("tenants").select().eq('id', currentTenant.value).single()).data
|
||||||
|
}
|
||||||
|
|
||||||
|
async function fetchProfiles () {
|
||||||
|
profiles.value = (await supabase.from("profiles").select().eq("tenant",currentTenant.value).order("lastName")).data
|
||||||
|
}
|
||||||
|
|
||||||
|
async function fetchOwnProfiles () {
|
||||||
|
let profiles = (await supabase.from("profiles").select().order("fullName")).data
|
||||||
|
let conns = (await supabase.from("profileconnections").select()).data.map(i => i.profile_id)
|
||||||
|
ownProfiles.value = profiles.filter(i => conns.includes(i.id))
|
||||||
|
}
|
||||||
|
|
||||||
|
async function fetchTenants () {
|
||||||
|
tenants.value = (await supabase.from("tenants").select()).data
|
||||||
|
}
|
||||||
|
|
||||||
|
const getOwnProfile = computed(() => {
|
||||||
|
return profiles.value.find(i => i.id === user.value.id)
|
||||||
|
|
||||||
|
})
|
||||||
|
|
||||||
|
const getProfileById = computed(() => (itemId) => {
|
||||||
|
return profiles.value.find(item => item.id === itemId)
|
||||||
|
})
|
||||||
|
|
||||||
|
return {
|
||||||
|
//General
|
||||||
|
currentTenant,
|
||||||
|
loaded,
|
||||||
|
showProfileSelection,
|
||||||
|
ownTenant,
|
||||||
|
initializeData,
|
||||||
|
changeProfile,
|
||||||
|
|
||||||
|
//Data
|
||||||
|
profiles,
|
||||||
|
ownProfiles,
|
||||||
|
activeProfile,
|
||||||
|
tenants,
|
||||||
|
fetchData,
|
||||||
|
clearStore,
|
||||||
|
fetchOwnTenant,
|
||||||
|
getOwnProfile,
|
||||||
|
getProfileById
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
})
|
||||||
Reference in New Issue
Block a user