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 viewport = useViewport()
|
||||
|
||||
console.log("1.")
|
||||
|
||||
/*watch(viewport.breakpoint, (newBreakpoint, oldBreakpoint) => {
|
||||
console.log('Breakpoint updated:', oldBreakpoint, '->', newBreakpoint)
|
||||
})*/
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
const toast = useToast()
|
||||
const supabase = useSupabaseClient()
|
||||
const dataStore = useDataStore()
|
||||
const profileStore = useProfileStore()
|
||||
const router = useRouter()
|
||||
const props = defineProps({
|
||||
documentData: {
|
||||
@@ -61,7 +62,7 @@ const createVendorInvoice = async () => {
|
||||
.from("incominginvoices")
|
||||
.insert([{
|
||||
document: documentData.id,
|
||||
tenant: dataStore.currentTenant
|
||||
tenant: profileStore.currentTenant
|
||||
}])
|
||||
.select()
|
||||
if(vendorInvoiceError) {
|
||||
|
||||
@@ -12,6 +12,7 @@ const props = defineProps({
|
||||
const {type, elementId} = props
|
||||
|
||||
const dataStore = useDataStore()
|
||||
const profileStore = useProfileStore()
|
||||
const tags = dataStore.getDocumentTags
|
||||
|
||||
const uploadModalOpen = ref(false)
|
||||
@@ -19,7 +20,7 @@ const uploadInProgress = ref(false)
|
||||
const fileUploadFormData = ref({
|
||||
tags: ["Dokument"],
|
||||
project: null,
|
||||
tenant: dataStore.currentTenant
|
||||
tenant: profileStore.currentTenant
|
||||
})
|
||||
|
||||
const openModal = () => {
|
||||
|
||||
@@ -46,6 +46,7 @@ defineShortcuts({
|
||||
|
||||
const router = useRouter()
|
||||
const dataStore = useDataStore()
|
||||
const profileStore = useProfileStore()
|
||||
|
||||
const dataType = dataStore.dataTypes[type]
|
||||
|
||||
@@ -81,7 +82,7 @@ const filteredRows = computed(() => {
|
||||
} else if(useRole().checkRight(type)){
|
||||
console.log("Only Righty to show Own")
|
||||
console.log(tempItems)
|
||||
tempItems = tempItems.filter(item => item.profiles.includes(dataStore.activeProfile.id))
|
||||
tempItems = tempItems.filter(item => item.profiles.includes(profileStore.activeProfile.id))
|
||||
} else {
|
||||
console.log("No Right to Show")
|
||||
tempItems = []
|
||||
|
||||
@@ -4,6 +4,7 @@ const { metaSymbol } = useShortcuts()
|
||||
|
||||
const shortcuts = ref(false)
|
||||
const dataStore = useDataStore()
|
||||
const profileStore = useProfileStore()
|
||||
const query = ref('')
|
||||
const supabase = useSupabaseClient()
|
||||
const toast = useToast()
|
||||
@@ -101,12 +102,12 @@ const filteredCategories = computed(() => {
|
||||
|
||||
const contactRequestData = ref({
|
||||
source: "helpSlideover",
|
||||
tenant: dataStore.currentTenant,
|
||||
tenant: profileStore.currentTenant,
|
||||
message: "",
|
||||
title: "",
|
||||
contactName: dataStore.activeProfile.fullName,
|
||||
contactTel: dataStore.activeProfile.phoneMobile || dataStore.activeProfile.phoneHome,
|
||||
contactMail: dataStore.activeProfile.email,
|
||||
contactName: profileStore.activeProfile.fullName,
|
||||
contactTel: profileStore.activeProfile.phoneMobile || profileStore.activeProfile.phoneHome,
|
||||
contactMail: profileStore.activeProfile.email,
|
||||
contactType: "Hilfe",
|
||||
currentPath: router.currentRoute
|
||||
})
|
||||
@@ -125,12 +126,12 @@ const addContactRequest = async () => {
|
||||
const resetContactRequest = () => {
|
||||
contactRequestData.value = {
|
||||
source: "helpSlideover",
|
||||
tenant: dataStore.currentTenant,
|
||||
tenant: profileStore.currentTenant,
|
||||
message: "",
|
||||
title: "",
|
||||
contactName: dataStore.activeProfile.fullName,
|
||||
contactTel: dataStore.activeProfile.phoneMobile || dataStore.activeProfile.phoneHome,
|
||||
contactMail: dataStore.activeProfile.email,
|
||||
contactName: profileStore.activeProfile.fullName,
|
||||
contactTel: profileStore.activeProfile.phoneMobile || profileStore.activeProfile.phoneHome,
|
||||
contactMail: profileStore.activeProfile.email,
|
||||
contactType: "Hilfe"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,7 +14,7 @@ const props = defineProps({
|
||||
}
|
||||
})
|
||||
const { metaSymbol } = useShortcuts()
|
||||
const dataStore = useDataStore()
|
||||
const profileStore = useProfileStore()
|
||||
const user = useSupabaseUser()
|
||||
const supabase = useSupabaseClient()
|
||||
const toast = useToast()
|
||||
@@ -79,13 +79,13 @@ const addHistoryItemData = ref({
|
||||
|
||||
const addHistoryItem = async () => {
|
||||
console.log(addHistoryItemData.value)
|
||||
addHistoryItemData.value.createdBy = dataStore.activeProfile.id
|
||||
addHistoryItemData.value.createdBy = profileStore.activeProfile.id
|
||||
|
||||
addHistoryItemData.value[type] = elementId
|
||||
|
||||
const {data,error} = await supabase
|
||||
.from("historyitems")
|
||||
.insert([{...addHistoryItemData.value, tenant: dataStore.currentTenant}])
|
||||
.insert([{...addHistoryItemData.value, tenant: profileStore.currentTenant}])
|
||||
.select()
|
||||
|
||||
if(error) {
|
||||
@@ -100,9 +100,9 @@ const addHistoryItem = async () => {
|
||||
let rawUsername = i[1]
|
||||
|
||||
return {
|
||||
tenant: dataStore.currentTenant,
|
||||
tenant: profileStore.currentTenant,
|
||||
profile: profiles.find(x => x.username === rawUsername).id,
|
||||
initiatingProfile: dataStore.activeProfile.id,
|
||||
initiatingProfile: profileStore.activeProfile.id,
|
||||
title: "Sie wurden im Logbuch erwähnt",
|
||||
link: `/${type}s/show/${elementId}`,
|
||||
message: addHistoryItemData.value.text
|
||||
@@ -198,11 +198,11 @@ const renderText = (text) => {
|
||||
:src="colorMode.value === 'light' ? '/Logo.png' : '/Logo_Dark.png' "
|
||||
/>
|
||||
<UAvatar
|
||||
:alt="dataStore.getProfileById(item.createdBy).fullName"
|
||||
:alt="profileStore.getProfileById(item.createdBy).fullName"
|
||||
v-else
|
||||
/>
|
||||
<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>
|
||||
<span v-html="renderText(item.text)"/><br>
|
||||
<span class="text-gray-500">{{dayjs(item.created_at).format("DD.MM.YY HH:mm")}}</span>
|
||||
|
||||
@@ -1,13 +1,10 @@
|
||||
<script setup>
|
||||
import {useRole} from "~/composables/useRole.js";
|
||||
|
||||
const dataStore = useDataStore()
|
||||
const profileStore = useProfileStore()
|
||||
const route = useRoute()
|
||||
|
||||
const role = useRole()
|
||||
console.log(role)
|
||||
console.log(role.checkRight("projects"))
|
||||
|
||||
const links = computed(() => {
|
||||
return [
|
||||
{
|
||||
@@ -26,17 +23,17 @@ const links = computed(() => {
|
||||
to: "/tasks",
|
||||
icon: "i-heroicons-rectangle-stack"
|
||||
},
|
||||
... dataStore.ownTenant.features.planningBoard ? [{
|
||||
... profileStore.ownTenant.features.planningBoard ? [{
|
||||
label: "Plantafel",
|
||||
to: "/calendar/timeline",
|
||||
icon: "i-heroicons-calendar-days"
|
||||
}] : [],
|
||||
... dataStore.ownTenant.features.calendar ? [{
|
||||
... profileStore.ownTenant.features.calendar ? [{
|
||||
label: "Kalender",
|
||||
to: "/calendar/grid",
|
||||
icon: "i-heroicons-calendar-days"
|
||||
}] : [],
|
||||
... dataStore.ownTenant.features.calendar ? [{
|
||||
... profileStore.ownTenant.features.calendar ? [{
|
||||
label: "Termine",
|
||||
to: "/events",
|
||||
icon: "i-heroicons-calendar-days"
|
||||
@@ -68,7 +65,7 @@ const links = computed(() => {
|
||||
}
|
||||
]
|
||||
},
|
||||
... dataStore.ownTenant.features.contacts ? [{
|
||||
... profileStore.ownTenant.features.contacts ? [{
|
||||
label: "Kontakte",
|
||||
defaultOpen: false,
|
||||
icon: "i-heroicons-user-group",
|
||||
@@ -95,12 +92,12 @@ const links = computed(() => {
|
||||
defaultOpen:false,
|
||||
icon: "i-heroicons-user-group",
|
||||
children: [
|
||||
... dataStore.ownTenant.features.timeTracking ? [{
|
||||
... profileStore.ownTenant.features.timeTracking ? [{
|
||||
label: "Zeiterfassung",
|
||||
to: "/employees/timetracking",
|
||||
icon: "i-heroicons-clock"
|
||||
}] : [],
|
||||
... dataStore.ownTenant.features.workingTimeTracking ? [{
|
||||
... profileStore.ownTenant.features.workingTimeTracking ? [{
|
||||
label: "Anwesenheiten",
|
||||
to: "/workingtimes",
|
||||
icon: "i-heroicons-clock"
|
||||
@@ -112,7 +109,7 @@ const links = computed(() => {
|
||||
},
|
||||
]
|
||||
},
|
||||
... dataStore.ownTenant.features.accounting ? [{
|
||||
... profileStore.ownTenant.features.accounting ? [{
|
||||
label: "Buchhaltung",
|
||||
defaultOpen: false,
|
||||
icon: "i-heroicons-chart-bar-square",
|
||||
|
||||
@@ -1,30 +1,29 @@
|
||||
<script setup>
|
||||
const dataStore = useDataStore()
|
||||
const profileStore = useProfileStore()
|
||||
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>
|
||||
|
||||
<template>
|
||||
<USelectMenu
|
||||
:options="dataStore.ownProfiles"
|
||||
:options="profileStore.ownProfiles"
|
||||
value-attribute="id"
|
||||
class="w-40"
|
||||
@change="dataStore.changeProfile(selectedProfile)"
|
||||
@change="profileStore.changeProfile(selectedProfile)"
|
||||
v-model="selectedProfile"
|
||||
>
|
||||
<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>
|
||||
|
||||
<template #option="{option}">
|
||||
{{dataStore.tenants.find(i => i.id === option.tenant).name}}
|
||||
{{profileStore.tenants.find(i => i.id === option.tenant).name}}
|
||||
</template>
|
||||
</USelectMenu>
|
||||
</template>
|
||||
@@ -1,6 +1,6 @@
|
||||
<script setup>
|
||||
|
||||
const dataStore = useDataStore()
|
||||
const profileStore = useProfileStore()
|
||||
|
||||
|
||||
|
||||
@@ -9,11 +9,11 @@ const dataStore = useDataStore()
|
||||
<template>
|
||||
<div class="w-1/2 mx-auto">
|
||||
<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">
|
||||
{{dataStore.tenants.find(i => i.id === profile.tenant).name}}
|
||||
<div v-for="profile in profileStore.ownProfiles" class="flex justify-between my-3">
|
||||
{{profileStore.tenants.find(i => i.id === profile.tenant).name}}
|
||||
<UButton
|
||||
variant="outline"
|
||||
@click="dataStore.changeProfile(profile.id)"
|
||||
@click="profileStore.changeProfile(profile.id)"
|
||||
>Auswählen</UButton>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -1,9 +1,10 @@
|
||||
<script setup lang="ts">
|
||||
<script setup>
|
||||
const { isHelpSlideoverOpen } = useDashboard()
|
||||
const { isDashboardSearchModalOpen } = useUIState()
|
||||
const { metaSymbol } = useShortcuts()
|
||||
const user = useSupabaseUser()
|
||||
const dataStore = useDataStore()
|
||||
const profileStore = useProfileStore()
|
||||
const supabase = useSupabaseClient()
|
||||
const router = useRouter()
|
||||
|
||||
@@ -15,13 +16,13 @@ const items = computed(() => [
|
||||
}], [{
|
||||
label: 'Mein Profil',
|
||||
icon: 'i-heroicons-user',
|
||||
to: `/profiles/show/${dataStore.activeProfile.id}`
|
||||
to: `/profiles/show/${profileStore.activeProfile.id}`
|
||||
},{
|
||||
label: 'Abmelden',
|
||||
icon: 'i-heroicons-arrow-left-on-rectangle',
|
||||
click: async () => {
|
||||
await supabase.auth.signOut()
|
||||
await dataStore.clearStore()
|
||||
//await dataStore.clearStore()
|
||||
await router.push('/login')
|
||||
|
||||
}
|
||||
@@ -32,9 +33,9 @@ const items = computed(() => [
|
||||
<template>
|
||||
<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 }">
|
||||
<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>
|
||||
<UAvatar :alt="dataStore.activeProfile ? dataStore.activeProfile.fullName : ''" size="xs" />
|
||||
<UAvatar :alt="profileStore.activeProfile ? profileStore.activeProfile.fullName : ''" size="xs" />
|
||||
</template>
|
||||
|
||||
<template #trailing>
|
||||
@@ -49,7 +50,7 @@ const items = computed(() => [
|
||||
Angemeldet als
|
||||
</p>
|
||||
<p class="truncate font-medium text-gray-900 dark:text-white">
|
||||
{{dataStore.activeProfile.email}}
|
||||
{{profileStore.activeProfile.email}}
|
||||
</p>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
@@ -6,13 +6,14 @@ dayjs.extend(customParseFormat)
|
||||
|
||||
const supabase = useSupabaseClient()
|
||||
const dataStore = useDataStore()
|
||||
const profileStore = useProfileStore()
|
||||
|
||||
let incomeData = ref({})
|
||||
let expenseData = ref({})
|
||||
|
||||
const setup = async () => {
|
||||
let incomeRawData = (await supabase.from("createddocuments").select().eq("tenant",dataStore.currentTenant).in('type',['invoices'])).data
|
||||
let expenseRawData =(await supabase.from("incominginvoices").select().eq("tenant",dataStore.currentTenant)).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",profileStore.currentTenant)).data
|
||||
|
||||
expenseRawData = expenseRawData.filter(i => i.date).map(i => {
|
||||
let amount = 0
|
||||
|
||||
@@ -3,8 +3,9 @@ export const useNumberRange = (resourceType) => {
|
||||
const supabase = useSupabaseClient()
|
||||
|
||||
const dataStore = useDataStore()
|
||||
const profileStore = useProfileStore()
|
||||
|
||||
const numberRanges = dataStore.ownTenant.numberRanges
|
||||
const numberRanges = profileStore.ownTenant.numberRanges
|
||||
|
||||
const numberRange = numberRanges[resourceType]
|
||||
|
||||
@@ -19,7 +20,7 @@ export const useNumberRange = (resourceType) => {
|
||||
const {data,error} = await supabase
|
||||
.from("tenants")
|
||||
.update({numberRanges: newNumberRanges})
|
||||
.eq('id',dataStore.currentTenant)
|
||||
.eq('id',profileStore.currentTenant)
|
||||
|
||||
|
||||
dataStore.fetchOwnTenant()
|
||||
|
||||
@@ -4,9 +4,10 @@ import Handlebars from "handlebars";
|
||||
export const usePrintLabel = async (printServerId,printerName , rawZPL ) => {
|
||||
const supabase = useSupabaseClient()
|
||||
const dataStore = useDataStore()
|
||||
const profileStore = useProfileStore()
|
||||
|
||||
await supabase.from("printJobs").insert({
|
||||
tenant: dataStore.currentTenant,
|
||||
tenant: profileStore.currentTenant,
|
||||
rawContent: rawZPL,
|
||||
printerName: printerName,
|
||||
printServer: printServerId
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
|
||||
|
||||
export const useRole = () => {
|
||||
const dataStore = useDataStore()
|
||||
const profileStore = useProfileStore()
|
||||
|
||||
|
||||
const generalAvailableRights = ref({
|
||||
@@ -178,7 +178,7 @@ export const useRole = () => {
|
||||
})
|
||||
|
||||
|
||||
let role = dataStore.activeProfile.role
|
||||
let role = profileStore.activeProfile.role
|
||||
|
||||
const checkRight = (right) => {
|
||||
let rightsToCheck = [right]
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
export const useSupabaseSelect = async (relation,select = '*', sortColumn = null, ascending = true) => {
|
||||
const supabase = useSupabaseClient()
|
||||
const dataStore = useDataStore()
|
||||
const profileStore = useProfileStore()
|
||||
let data = null
|
||||
|
||||
|
||||
@@ -10,13 +10,13 @@ export const useSupabaseSelect = async (relation,select = '*', sortColumn = null
|
||||
data = (await supabase
|
||||
.from(relation)
|
||||
.select(select)
|
||||
.eq("tenant", dataStore.currentTenant)
|
||||
.eq("tenant", profileStore.currentTenant)
|
||||
.order(sortColumn, {ascending: ascending})).data
|
||||
} else {
|
||||
data = (await supabase
|
||||
.from(relation)
|
||||
.select(select)
|
||||
.eq("tenant", dataStore.currentTenant)).data
|
||||
.eq("tenant", profileStore.currentTenant)).data
|
||||
}
|
||||
|
||||
return data
|
||||
@@ -24,7 +24,8 @@ export const useSupabaseSelect = async (relation,select = '*', sortColumn = null
|
||||
|
||||
export const useSupabaseSelectDocuments = async (select = '*', sortColumn = null, folderPath = "_") => {
|
||||
const supabase = useSupabaseClient()
|
||||
const dataStore = useDataStore()
|
||||
const profileStore = useProfileStore()
|
||||
|
||||
let data = null
|
||||
|
||||
|
||||
@@ -32,13 +33,13 @@ export const useSupabaseSelectDocuments = async (select = '*', sortColumn = null
|
||||
data = (await supabase
|
||||
.from("documents")
|
||||
.select(select)
|
||||
.eq("tenant", dataStore.currentTenant)
|
||||
.eq("tenant", profileStore.currentTenant)
|
||||
.order(sortColumn, {ascending: true})).data
|
||||
} else {
|
||||
data = (await supabase
|
||||
.from("documents")
|
||||
.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 = '*' ) => {
|
||||
const supabase = useSupabaseClient()
|
||||
const dataStore = useDataStore()
|
||||
const profileStore = useProfileStore()
|
||||
let data = null
|
||||
|
||||
|
||||
@@ -76,14 +77,14 @@ export const useSupabaseSelectSingle = async (relation,idToEq,select = '*' ) =>
|
||||
data = (await supabase
|
||||
.from(relation)
|
||||
.select(select)
|
||||
.eq("tenant", dataStore.currentTenant)
|
||||
.eq("tenant", profileStore.currentTenant)
|
||||
.eq("id",idToEq)
|
||||
.single()).data
|
||||
} else {
|
||||
data = (await supabase
|
||||
.from(relation)
|
||||
.select(select)
|
||||
.eq("tenant", dataStore.currentTenant)
|
||||
.eq("tenant", profileStore.currentTenant)
|
||||
.single()).data
|
||||
}
|
||||
|
||||
|
||||
@@ -3,398 +3,20 @@
|
||||
|
||||
import MainNav from "~/components/MainNav.vue";
|
||||
import dayjs from "dayjs";
|
||||
import {useProfileStore} from "~/stores/profile.js";
|
||||
|
||||
const dataStore = useDataStore()
|
||||
const profileStore = useProfileStore()
|
||||
const colorMode = useColorMode()
|
||||
const { isHelpSlideoverOpen } = useDashboard()
|
||||
const supabase = useSupabaseClient()
|
||||
const router = useRouter()
|
||||
const route = useRoute()
|
||||
|
||||
console.log("2.")
|
||||
|
||||
dataStore.initializeData((await supabase.auth.getUser()).data.user.id)
|
||||
profileStore.initializeData((await supabase.auth.getUser()).data.user.id)
|
||||
|
||||
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 = [
|
||||
{
|
||||
id: 'new-customer',
|
||||
@@ -489,7 +111,7 @@ const footerLinks = [/*{
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<UDashboardLayout v-if="dataStore.loaded">
|
||||
<UDashboardLayout v-if="profileStore.loaded">
|
||||
|
||||
<UDashboardPanel :width="250" :resizable="{ min: 200, max: 300 }" collapsible>
|
||||
<UDashboardNavbar class="!border-transparent" :ui="{ left: 'flex-1' }">
|
||||
|
||||
@@ -7,6 +7,7 @@ definePageMeta({
|
||||
})
|
||||
|
||||
const dataStore = useDataStore()
|
||||
const profileStore = useProfileStore()
|
||||
const route = useRoute()
|
||||
const router = useRouter()
|
||||
const toast = useToast()
|
||||
@@ -110,7 +111,7 @@ setupPage()
|
||||
<UCard class="mt-5">
|
||||
<div v-if="item.label === 'Informationen'">
|
||||
<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>Ende: {{dayjs(itemInfo.end).format("DD.MM.YYYY")}}</p>
|
||||
<p>Grund: {{itemInfo.reason}}</p>
|
||||
@@ -151,14 +152,14 @@ setupPage()
|
||||
>
|
||||
<USelectMenu
|
||||
v-model="itemInfo.user"
|
||||
:options="dataStore.profiles"
|
||||
:options="profileStore.profiles"
|
||||
option-attribute="fullName"
|
||||
value-attribute="id"
|
||||
searchable
|
||||
:search-attributes="['fullName']"
|
||||
>
|
||||
<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>
|
||||
</USelectMenu>
|
||||
</UFormGroup>
|
||||
|
||||
@@ -61,7 +61,7 @@
|
||||
</span>
|
||||
</template>
|
||||
<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>
|
||||
</UTable>
|
||||
</template>
|
||||
@@ -84,6 +84,7 @@ defineShortcuts({
|
||||
})
|
||||
|
||||
const dataStore = useDataStore()
|
||||
const profileStore = useProfileStore()
|
||||
const router = useRouter()
|
||||
|
||||
const templateColumns = [
|
||||
|
||||
@@ -20,6 +20,7 @@ defineShortcuts({
|
||||
})
|
||||
|
||||
const dataStore = useDataStore()
|
||||
const profileStore = useProfileStore()
|
||||
const router = useRouter()
|
||||
const supabase = useSupabaseClient()
|
||||
|
||||
@@ -27,7 +28,7 @@ const bankstatements = ref([])
|
||||
|
||||
|
||||
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 profileStore = useProfileStore()
|
||||
const route = useRoute()
|
||||
const router = useRouter()
|
||||
const mode = ref(route.params.mode || "show")
|
||||
@@ -132,7 +133,7 @@ const saveAllocations = async () => {
|
||||
const saveAllocation = async (allocation) => {
|
||||
const {data,error} = await supabase.from("statementallocations").insert({
|
||||
...allocation,
|
||||
tenant: dataStore.currentTenant
|
||||
tenant: profileStore.currentTenant
|
||||
}).select()
|
||||
|
||||
if(data) {
|
||||
|
||||
@@ -11,6 +11,7 @@ const supabase = useSupabaseClient()
|
||||
const user = useSupabaseUser()
|
||||
|
||||
const dataStore = useDataStore()
|
||||
const profileStore = useProfileStore()
|
||||
const selectedChat = ref({})
|
||||
const messageText = ref("")
|
||||
|
||||
@@ -24,8 +25,8 @@ const messageText = ref("")
|
||||
@click="selectedChat = chat"
|
||||
>
|
||||
<UAlert
|
||||
:title="chat.title ? chat.title : 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 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 profileStore.getProfileById(i).fullName}).join(' ')}"
|
||||
:color="selectedChat.id === chat.id ? 'primary' : 'white'"
|
||||
variant="outline"
|
||||
>
|
||||
@@ -49,13 +50,13 @@ const messageText = ref("")
|
||||
{{message.text}}
|
||||
</div>
|
||||
<UAvatar
|
||||
:alt="dataStore.getProfileById(message.origin) ? dataStore.getProfileById(message.origin).fullName : ''"
|
||||
:alt="profileStore.getProfileById(message.origin) ? profileStore.getProfileById(message.origin).fullName : ''"
|
||||
size="md"
|
||||
/>
|
||||
</div>
|
||||
<div class="flex justify-start mb-4" v-else>
|
||||
<UAvatar
|
||||
:alt="dataStore.getProfileById(message.origin) ? dataStore.getProfileById(message.origin).fullName : ''"
|
||||
:alt="profileStore.getProfileById(message.origin) ? profileStore.getProfileById(message.origin).fullName : ''"
|
||||
size="md"
|
||||
/>
|
||||
<div
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<script setup>
|
||||
|
||||
const dataStore = useDataStore()
|
||||
const profileStore = useProfileStore()
|
||||
const supabase = useSupabaseClient()
|
||||
|
||||
const profiles = ref([])
|
||||
@@ -10,14 +10,14 @@ const selectedProfiles = ref([])
|
||||
|
||||
const setup = async () => {
|
||||
profiles.value = await useSupabaseSelect("profiles")
|
||||
selectedProfiles.value = [dataStore.activeProfile.id]
|
||||
selectedProfiles.value = [profileStore.activeProfile.id]
|
||||
}
|
||||
|
||||
setup()
|
||||
|
||||
const createChat = async () => {
|
||||
const {data,error} = await supabase.from("chats").insert({
|
||||
tenant: dataStore.currentTenant,
|
||||
tenant: profileStore.currentTenant,
|
||||
name: itemInfo.value.name
|
||||
}).select()
|
||||
|
||||
@@ -105,7 +105,7 @@ const createChat = async () => {
|
||||
:search-attributes="['fullName']"
|
||||
>
|
||||
<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>
|
||||
</USelectMenu>
|
||||
</UFormGroup>
|
||||
|
||||
@@ -13,17 +13,17 @@ defineShortcuts({
|
||||
})
|
||||
|
||||
const itemInfo = ref({})
|
||||
const dataStore = useDataStore()
|
||||
const profileStore = useProfileStore()
|
||||
const supabase = useSupabaseClient()
|
||||
|
||||
const setup = async () => {
|
||||
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){
|
||||
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 () => {
|
||||
if(messageText.value.length > 0) {
|
||||
const message = {
|
||||
origin: dataStore.activeProfile.id,
|
||||
origin: profileStore.activeProfile.id,
|
||||
destinationchat: itemInfo.value.id,
|
||||
text: messageText.value,
|
||||
tenant: dataStore.currentTenant,
|
||||
seenBy: [dataStore.activeProfile.id]
|
||||
tenant: profileStore.currentTenant,
|
||||
seenBy: [profileStore.activeProfile.id]
|
||||
}
|
||||
|
||||
const {data,error} = await supabase.from("chatmessages").insert(message)
|
||||
@@ -49,11 +49,11 @@ const sendMessage = async () => {
|
||||
//Reset
|
||||
messageText.value = ""
|
||||
//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 {
|
||||
tenant: dataStore.currentTenant,
|
||||
tenant: profileStore.currentTenant,
|
||||
profile: i.id,
|
||||
initiatingProfile: dataStore.activeProfile.id,
|
||||
initiatingProfile: profileStore.activeProfile.id,
|
||||
title: `Sie haben eine neue Nachricht im Chat ${itemInfo.value.name}`,
|
||||
link: `/chats/show/${itemInfo.value.id}`,
|
||||
message: message.text
|
||||
@@ -88,13 +88,13 @@ const sendMessage = async () => {
|
||||
</UDashboardNavbar>
|
||||
<div class="scrollList p-5">
|
||||
<UAlert
|
||||
:color="message.seenBy.includes(dataStore.activeProfile.id) ? 'white' : 'primary'"
|
||||
:variant="message.seenBy.includes(dataStore.activeProfile.id) ? 'solid' : 'outline'"
|
||||
:color="message.seenBy.includes(profileStore.activeProfile.id) ? 'white' : 'primary'"
|
||||
:variant="message.seenBy.includes(profileStore.activeProfile.id) ? 'solid' : 'outline'"
|
||||
class="my-2"
|
||||
v-for="message in itemInfo.chatmessages"
|
||||
:description="message.text"
|
||||
:avatar="{ alt: dataStore.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')}`"
|
||||
:avatar="{ alt: profileStore.getProfileById(message.origin).fullName }"
|
||||
: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>
|
||||
|
||||
@@ -3,6 +3,7 @@ import dayjs from "dayjs"
|
||||
|
||||
const supabase = useSupabaseClient()
|
||||
const dataStore = useDataStore()
|
||||
const profileStore = useProfileStore()
|
||||
const router = useRouter()
|
||||
|
||||
|
||||
@@ -10,7 +11,7 @@ const items = ref([])
|
||||
|
||||
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) => {
|
||||
|
||||
@@ -23,6 +23,7 @@ defineShortcuts({
|
||||
})
|
||||
|
||||
const dataStore = useDataStore()
|
||||
const profileStore = useProfileStore()
|
||||
const route = useRoute()
|
||||
const router = useRouter()
|
||||
const toast = useToast()
|
||||
@@ -33,7 +34,8 @@ const openTab = ref(0)
|
||||
//Working
|
||||
const mode = ref(route.params.mode || "show")
|
||||
const itemInfo = ref({
|
||||
active: true
|
||||
active: true,
|
||||
profiles: [profileStore.activeProfile.id]
|
||||
})
|
||||
const oldItemInfo = ref({})
|
||||
|
||||
@@ -300,6 +302,23 @@ setupPage()
|
||||
</template>
|
||||
</UPopover>
|
||||
</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
|
||||
label="Notizen:"
|
||||
>
|
||||
@@ -307,6 +326,7 @@ setupPage()
|
||||
v-model="itemInfo.notes"
|
||||
/>
|
||||
</UFormGroup>
|
||||
|
||||
</UForm>
|
||||
</template>
|
||||
|
||||
|
||||
@@ -24,6 +24,7 @@ defineShortcuts({
|
||||
})
|
||||
|
||||
const dataStore = useDataStore()
|
||||
const profileStore = useProfileStore()
|
||||
const route = useRoute()
|
||||
const router = useRouter()
|
||||
const toast = useToast()
|
||||
@@ -215,7 +216,7 @@ setupPage()
|
||||
<td colspan="2"><span class="font-bold">Eigene Felder:</span></td>
|
||||
</tr>
|
||||
<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>
|
||||
</tr>
|
||||
</table>
|
||||
@@ -491,14 +492,14 @@ setupPage()
|
||||
</UFormGroup>
|
||||
|
||||
<div
|
||||
v-if="dataStore.ownTenant.ownFields"
|
||||
v-if="profileStore.ownTenant.ownFields"
|
||||
>
|
||||
<UDivider
|
||||
class="mt-3"
|
||||
>Eigene Felder</UDivider>
|
||||
|
||||
<UFormGroup
|
||||
v-for="field in dataStore.ownTenant.ownFields.contracts"
|
||||
v-for="field in profileStore.ownTenant.ownFields.contracts"
|
||||
:key="field.key"
|
||||
:label="field.label"
|
||||
>
|
||||
|
||||
@@ -5,6 +5,7 @@ import {useNumberRange} from "~/composables/useNumberRange.js";
|
||||
import { v4 as uuidv4 } from 'uuid';
|
||||
|
||||
const dataStore = useDataStore()
|
||||
const profileStore = useProfileStore()
|
||||
const user = useSupabaseUser()
|
||||
const route = useRoute()
|
||||
const router = useRouter()
|
||||
@@ -37,7 +38,7 @@ const itemInfo = ref({
|
||||
deliveryDateType: "Lieferdatum",
|
||||
dateOfPerformance: null,
|
||||
paymentDays: 7,
|
||||
createdBy: dataStore.activeProfile.id,
|
||||
createdBy: profileStore.activeProfile.id,
|
||||
title: null,
|
||||
description: null,
|
||||
startText: null,
|
||||
@@ -45,7 +46,7 @@ const itemInfo = ref({
|
||||
rows: [
|
||||
|
||||
],
|
||||
contactPerson: dataStore.activeProfile.id,
|
||||
contactPerson: profileStore.activeProfile.id,
|
||||
contactPersonName: null,
|
||||
contactTel: null,
|
||||
contactEMail: null,
|
||||
@@ -74,6 +75,7 @@ const servicecategories = ref([])
|
||||
const selectedServicecategorie = ref(null)
|
||||
const customers = ref([])
|
||||
const contacts = ref([])
|
||||
const texttemplates = ref([])
|
||||
|
||||
const loaded = ref(false)
|
||||
const setupPage = async () => {
|
||||
@@ -87,6 +89,7 @@ const setupPage = async () => {
|
||||
productcategories.value = (await useSupabaseSelect("productcategories","*"))
|
||||
customers.value = (await useSupabaseSelect("customers","*","customerNumber"))
|
||||
contacts.value = (await useSupabaseSelect("contacts","*"))
|
||||
texttemplates.value = (await useSupabaseSelect("texttemplates","*"))
|
||||
if(productcategories.value.length > 0) selectedProductcategorie.value = productcategories.value[0].id
|
||||
if(servicecategories.value.length > 0) selectedServicecategorie.value = servicecategories.value[0].id
|
||||
|
||||
@@ -216,8 +219,8 @@ const setDocumentTypeConfig = (withTexts = false) => {
|
||||
}
|
||||
|
||||
if(withTexts) {
|
||||
itemInfo.value.startText = dataStore.getTextTemplatesByDocumentType(itemInfo.value.type).find(i => i.default && i.pos === "startText").text
|
||||
itemInfo.value.endText = dataStore.getTextTemplatesByDocumentType(itemInfo.value.type).find(i => i.default && i.pos === "endText").text
|
||||
itemInfo.value.startText = texttemplates.value.find(i => i.documentType === itemInfo.value.type && i.default && i.pos === "startText").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
|
||||
@@ -310,7 +313,7 @@ const addPosition = (mode) => {
|
||||
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'){
|
||||
itemInfo.value.rows.push({
|
||||
@@ -334,7 +337,7 @@ const addPosition = (mode) => {
|
||||
}
|
||||
|
||||
//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") {
|
||||
itemInfo.value.rows.push({
|
||||
id: uuidv4(),
|
||||
@@ -373,7 +376,7 @@ const removePosition = (id) => {
|
||||
|
||||
const getRowMargin = (row) => {
|
||||
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
|
||||
} else {
|
||||
return 0
|
||||
@@ -530,9 +533,9 @@ const getDocumentData = () => {
|
||||
|
||||
let customerData = dataStore.getCustomerById(itemInfo.value.customer)
|
||||
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 => {
|
||||
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 : ""}`
|
||||
@@ -555,7 +558,7 @@ const getDocumentData = () => {
|
||||
}
|
||||
|
||||
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
|
||||
|
||||
|
||||
@@ -630,7 +633,7 @@ const getDocumentData = () => {
|
||||
const showDocument = ref(false)
|
||||
const uri = ref("")
|
||||
const generateDocument = async () => {
|
||||
const ownTenant = dataStore.ownTenant
|
||||
const ownTenant = profileStore.ownTenant
|
||||
const path = letterheads.value.find(i => i.id === itemInfo.value.letterhead).path
|
||||
|
||||
|
||||
@@ -717,7 +720,7 @@ const saveDocument = async (state) => {
|
||||
setDocumentTypeConfig(false)
|
||||
}
|
||||
|
||||
if(dataStore.ownTenant.extraModules.includes("agriculture")) {
|
||||
if(profileStore.ownTenant.extraModules.includes("agriculture")) {
|
||||
itemInfo.value.rows.forEach(row => {
|
||||
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 : ""}`
|
||||
@@ -1193,7 +1196,7 @@ setupPage()
|
||||
label="Ansprechpartner:"
|
||||
>
|
||||
<USelectMenu
|
||||
:options="dataStore.profiles"
|
||||
:options="profileStore.profiles"
|
||||
v-model="itemInfo.contactPerson"
|
||||
option-attribute="fullName"
|
||||
value-attribute="id"
|
||||
@@ -1464,12 +1467,12 @@ setupPage()
|
||||
searchable-placeholder="Suche ..."
|
||||
:search-attributes="['name']"
|
||||
v-model="row.product"
|
||||
@change="row.unit = dataStore.getProductById(row.product).unit,
|
||||
row.price = (dataStore.getProductById(row.product).sellingPrice || 0),
|
||||
row.description = dataStore.getProductById(row.product).description"
|
||||
@change="row.unit = products.find(i => i.id === row.product).unit,
|
||||
row.price = (products.find(i => i.id === row.product).sellingPrice || 0),
|
||||
row.description = products.find(i => i.id === row.product).description"
|
||||
>
|
||||
<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>
|
||||
</USelectMenu>
|
||||
<UButton
|
||||
@@ -1503,9 +1506,9 @@ setupPage()
|
||||
:empty-state="{ icon: 'i-heroicons-circle-stack-20-solid', label: 'Keine Artikel anzuzeigen' }"
|
||||
@select=" (i) => {
|
||||
row.product = i.id
|
||||
row.unit = dataStore.getProductById(row.product).unit,
|
||||
row.price = (dataStore.getProductById(row.product).sellingPrice || 0),
|
||||
row.description = dataStore.getProductById(row.product).description
|
||||
row.unit = products.find(i => i.id === row.product).unit,
|
||||
row.price = (products.find(i => i.id === row.product).sellingPrice || 0),
|
||||
row.description = products.find(i => i.id === row.product).description
|
||||
showProductSelectionModal = false}"
|
||||
>
|
||||
|
||||
@@ -1514,9 +1517,6 @@ setupPage()
|
||||
</UModal>
|
||||
</InputGroup>
|
||||
|
||||
<!--
|
||||
{{dataStore.getProductById(66)}}
|
||||
-->
|
||||
</td>
|
||||
<td
|
||||
class="w-120"
|
||||
|
||||
@@ -280,10 +280,6 @@ const isPaid = (item) => {
|
||||
let amountPaid = 0
|
||||
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))
|
||||
}
|
||||
</script>
|
||||
|
||||
@@ -12,6 +12,7 @@ defineShortcuts({
|
||||
const supabase = useSupabaseClient()
|
||||
|
||||
const dataStore = useDataStore()
|
||||
const profileStore = useProfileStore()
|
||||
const route = useRoute()
|
||||
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)
|
||||
|
||||
}
|
||||
|
||||
@@ -23,10 +23,9 @@ defineShortcuts({
|
||||
})
|
||||
|
||||
const dataStore = useDataStore()
|
||||
const profileStore = useProfileStore()
|
||||
const route = useRoute()
|
||||
const router = useRouter()
|
||||
const toast = useToast()
|
||||
const id = ref(route.params.id ? route.params.id : null )
|
||||
|
||||
const openTab = ref(0)
|
||||
|
||||
@@ -39,7 +38,8 @@ const itemInfo = ref({
|
||||
country: "Deutschland"
|
||||
},
|
||||
active: true,
|
||||
isCompany: true
|
||||
isCompany: true,
|
||||
profiles: [profileStore.activeProfile.id]
|
||||
})
|
||||
const oldItemInfo = ref({})
|
||||
|
||||
@@ -356,6 +356,23 @@ setupPage()
|
||||
v-model="itemInfo.infoData.ustid"
|
||||
/>
|
||||
</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>
|
||||
</UDashboardPanelContent>
|
||||
|
||||
|
||||
@@ -11,6 +11,7 @@ definePageMeta({
|
||||
|
||||
|
||||
const dataStore = useDataStore()
|
||||
const profileStore = useProfileStore()
|
||||
const supabase = useSupabaseClient()
|
||||
const route = useRoute()
|
||||
const router = useRouter()
|
||||
@@ -81,7 +82,7 @@ const filteredTimes = computed(() => {
|
||||
//Functions
|
||||
const setupPage = () => {
|
||||
if(mode.value === "show" || mode.value === "edit"){
|
||||
currentItem = dataStore.getProfileById(useRoute().params.id)
|
||||
currentItem = profileStore.getProfileById(useRoute().params.id)
|
||||
}
|
||||
|
||||
itemInfo.value = currentItem
|
||||
@@ -337,7 +338,7 @@ setupPage()
|
||||
<div class="text-right">{{dayjs(row.end).format("HH:mm")}}</div>
|
||||
</template>
|
||||
<template #user-data="{row}">
|
||||
{{dataStore.getProfileById(row.user) ? dataStore.getProfileById(row.user).fullName : ""}}
|
||||
{{profileStore.getProfileById(row.user) ? profileStore.getProfileById(row.user).fullName : ""}}
|
||||
</template>
|
||||
<template #duration-data="{row}">
|
||||
<div class="text-right">{{ getDuration(row).composed}} Std</div>
|
||||
@@ -8,6 +8,7 @@ definePageMeta({
|
||||
middleware: "auth"
|
||||
})
|
||||
const dataStore = useDataStore()
|
||||
const profileStore = useProfileStore()
|
||||
const supabase = useSupabaseClient()
|
||||
const user = useSupabaseUser()
|
||||
const toast = useToast()
|
||||
@@ -21,7 +22,7 @@ const uploadInProgress = ref(false)
|
||||
const fileUploadFormData = ref({
|
||||
tags: ["Eingang"],
|
||||
path: "",
|
||||
tenant: dataStore.currentTenant,
|
||||
tenant: profileStore.currentTenant,
|
||||
folder: null
|
||||
})
|
||||
|
||||
@@ -163,7 +164,7 @@ const uploadFiles = async (files) => {
|
||||
uploadInProgress.value = true;
|
||||
|
||||
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 {
|
||||
await dataStore.uploadFiles(fileUploadFormData.value, document.getElementById("fileUploadInput").files, true)
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
const supabase = useSupabaseClient()
|
||||
const dataStore = useDataStore()
|
||||
const profileStore = useProfileStore()
|
||||
|
||||
|
||||
const selectedTab = ref(0)
|
||||
@@ -12,7 +13,7 @@ const accountData = ref(null)
|
||||
const availableAccounts = ref(null)
|
||||
const selectedAccount = ref(null)
|
||||
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)
|
||||
|
||||
if(availableAccounts.value.length > 0) {
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
const supabase = useSupabaseClient()
|
||||
const dataStore = useDataStore()
|
||||
const profileStore = useProfileStore()
|
||||
const route = useRoute()
|
||||
const router = useRouter()
|
||||
const toast = useToast()
|
||||
@@ -29,7 +30,7 @@ const setupPage = async () => {
|
||||
} else {
|
||||
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
|
||||
if(route.query.to) emailData.value.to = route.query.to
|
||||
|
||||
@@ -9,6 +9,7 @@ definePageMeta({
|
||||
})
|
||||
|
||||
const dataStore = useDataStore()
|
||||
const profileStore = useProfileStore()
|
||||
const supabase = useSupabaseClient()
|
||||
const user = useSupabaseUser()
|
||||
const toast = useToast()
|
||||
@@ -111,7 +112,7 @@ const startTime = async () => {
|
||||
console.log("started")
|
||||
timeInfo.value.user = user.value.id
|
||||
timeInfo.value.start = new Date().toISOString()
|
||||
timeInfo.value.tenant = dataStore.currentTenant
|
||||
timeInfo.value.tenant = profileStore.currentTenant
|
||||
|
||||
const {data,error} = await supabase
|
||||
.from("times")
|
||||
@@ -162,7 +163,7 @@ if(dataStore.times.find(time => time.user == user.value.id && !time.end)) {
|
||||
const createTime = async () => {
|
||||
const {data,error} = await supabase
|
||||
.from("times")
|
||||
.insert({...itemInfo.value, tenant: dataStore.currentTenant})
|
||||
.insert({...itemInfo.value, tenant: profileStore.currentTenant})
|
||||
.select()
|
||||
|
||||
if(error) {
|
||||
@@ -241,13 +242,13 @@ const setState = async (newState) => {
|
||||
</UButton>
|
||||
<USelectMenu
|
||||
v-if="dataStore.hasRight('viewTimes')"
|
||||
:options="dataStore.profiles"
|
||||
:options="profileStore.profiles"
|
||||
option-attribute="fullName"
|
||||
value-attribute="id"
|
||||
v-model="filterUser"
|
||||
>
|
||||
<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>
|
||||
</USelectMenu>
|
||||
</template>
|
||||
@@ -339,14 +340,14 @@ const setState = async (newState) => {
|
||||
label="Benutzer:"
|
||||
>
|
||||
<USelectMenu
|
||||
:options="dataStore.profiles"
|
||||
:options="profileStore.profiles"
|
||||
v-model="itemInfo.user"
|
||||
option-attribute="fullName"
|
||||
value-attribute="id"
|
||||
:disabled="(configTimeMode === 'create' ? false : itemInfo.state !== 'Entwurf') || (!dataStore.hasRight('createTime') || !dataStore.hasRight('createOwnTime'))"
|
||||
>
|
||||
<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>
|
||||
</USelectMenu>
|
||||
</UFormGroup>
|
||||
@@ -444,7 +445,7 @@ const setState = async (newState) => {
|
||||
>{{row.state}}</span>
|
||||
</template>
|
||||
<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 #start-data="{row}">
|
||||
|
||||
@@ -4,6 +4,7 @@ import dayjs from "dayjs";
|
||||
const route = useRoute()
|
||||
const router = useRouter()
|
||||
const dataStore = useDataStore()
|
||||
const profileStore = useProfileStore()
|
||||
|
||||
const mode = ref(route.params.mode || "show")
|
||||
|
||||
@@ -13,7 +14,7 @@ const itemInfo = ref({
|
||||
})
|
||||
const oldItemInfo = ref({})
|
||||
|
||||
const resourceToAdd = ref(dataStore.activeProfile.id)
|
||||
const resourceToAdd = ref(profileStore.activeProfile.id)
|
||||
/*const mapResources = () => {
|
||||
console.log(itemInfo.value.resources)
|
||||
itemInfo.value.resources.map(resource => {
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
title="Anwesenheiten"
|
||||
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>
|
||||
|
||||
<!--TODO: Fix Card Table overflowing <UDashboardCard
|
||||
@@ -27,7 +27,7 @@
|
||||
class="w-1/2 h-1/2"
|
||||
>
|
||||
<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}`)"
|
||||
:columns="[
|
||||
{
|
||||
@@ -69,6 +69,7 @@ definePageMeta({
|
||||
})
|
||||
|
||||
const dataStore = useDataStore()
|
||||
const profileStore = useProfileStore()
|
||||
const toast = useToast()
|
||||
const router = useRouter()
|
||||
|
||||
|
||||
@@ -4,6 +4,7 @@ definePageMeta({
|
||||
})
|
||||
|
||||
const dataStore = useDataStore()
|
||||
const profileStore = useProfileStore()
|
||||
const supabase = useSupabaseClient()
|
||||
const router = useRouter()
|
||||
const mode = ref("incoming")
|
||||
@@ -41,8 +42,8 @@ const createMovement = async () => {
|
||||
spaceId: inventoryChangeData.value.destinationSpaceId,
|
||||
projectId: inventoryChangeData.value.destinationProjectId,
|
||||
quantity: inventoryChangeData.value.quantity,
|
||||
profileId: dataStore.activeProfile.id,
|
||||
tenant: dataStore.currentTenant
|
||||
profileId: profileStore.activeProfile.id,
|
||||
tenant: profileStore.currentTenant
|
||||
}
|
||||
|
||||
movements.push(movement)
|
||||
@@ -61,8 +62,8 @@ const createMovement = async () => {
|
||||
spaceId: inventoryChangeData.value.sourceSpaceId,
|
||||
projectId: inventoryChangeData.value.sourceProjectId,
|
||||
quantity: inventoryChangeData.value.quantity * -1,
|
||||
profileId: dataStore.activeProfile.id,
|
||||
tenant: dataStore.currentTenant
|
||||
profileId: profileStore.activeProfile.id,
|
||||
tenant: profileStore.currentTenant
|
||||
}
|
||||
|
||||
movements.push(movement)
|
||||
@@ -72,16 +73,16 @@ const createMovement = async () => {
|
||||
spaceId: inventoryChangeData.value.sourceSpaceId,
|
||||
projectId: inventoryChangeData.value.sourceProjectId,
|
||||
quantity: inventoryChangeData.value.quantity * -1,
|
||||
profileId: dataStore.activeProfile.id,
|
||||
tenant: dataStore.currentTenant
|
||||
profileId: profileStore.activeProfile.id,
|
||||
tenant: profileStore.currentTenant
|
||||
}
|
||||
let inMovement = {
|
||||
productId: inventoryChangeData.value.productId,
|
||||
spaceId: inventoryChangeData.value.destinationSpaceId,
|
||||
projectId: inventoryChangeData.value.destinationProjectId,
|
||||
quantity: inventoryChangeData.value.quantity,
|
||||
profileId: dataStore.activeProfile.id,
|
||||
tenant: dataStore.currentTenant
|
||||
profileId: profileStore.activeProfile.id,
|
||||
tenant: profileStore.currentTenant
|
||||
}
|
||||
|
||||
movements.push(outMovement)
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
<script setup >
|
||||
|
||||
import {useProfileStore} from "~/stores/profile.js";
|
||||
|
||||
definePageMeta({
|
||||
layout: "notLoggedIn"
|
||||
})
|
||||
@@ -8,8 +10,8 @@ const supabase = useSupabaseClient()
|
||||
const user = useSupabaseUser()
|
||||
const router = useRouter()
|
||||
const colorMode = useColorMode()
|
||||
const dataStore = useDataStore()
|
||||
const toast = useToast()
|
||||
const profileStore = useProfileStore()
|
||||
|
||||
const isLight = computed({
|
||||
get () {
|
||||
@@ -61,7 +63,7 @@ const onSubmit = async (data) => {
|
||||
|
||||
} else {
|
||||
//console.log("Login Successful")
|
||||
dataStore.initializeData(user.id)
|
||||
profileStore.initializeData(user.id)
|
||||
router.push("/")
|
||||
|
||||
|
||||
|
||||
@@ -20,9 +20,6 @@ const id = ref(route.params.id ? route.params.id : null )
|
||||
//Working
|
||||
const mode = ref(route.params.mode || "show")
|
||||
const itemInfo = ref({
|
||||
description: {
|
||||
html: ""
|
||||
}
|
||||
})
|
||||
|
||||
const tabItems = [
|
||||
@@ -105,7 +102,7 @@ setupPage()
|
||||
Erstellen
|
||||
</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"
|
||||
class="ml-2"
|
||||
v-if="mode === 'edit' || mode === 'create'"
|
||||
@@ -144,7 +141,7 @@ setupPage()
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
<div v-if="itemInfo.description.html">
|
||||
<div v-if="itemInfo.description">
|
||||
<p>Notizen:</p>
|
||||
<span v-html="itemInfo.description.html"></span>
|
||||
</div>
|
||||
|
||||
@@ -25,6 +25,7 @@ defineShortcuts({
|
||||
})
|
||||
|
||||
const dataStore = useDataStore()
|
||||
const profileStore = useProfileStore()
|
||||
const supabase = useSupabaseClient()
|
||||
const route = useRoute()
|
||||
const router = useRouter()
|
||||
@@ -270,7 +271,7 @@ setupPage()
|
||||
>
|
||||
<USelectMenu
|
||||
v-model="itemInfo.tags"
|
||||
:options="dataStore.ownTenant.tags.products"
|
||||
:options="profileStore.ownTenant.tags.products"
|
||||
multiple
|
||||
>
|
||||
<template #label>
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
<script setup>
|
||||
const dataStore = useDataStore()
|
||||
const profileStore = useProfileStore()
|
||||
const router = useRouter()
|
||||
|
||||
|
||||
@@ -35,7 +36,7 @@
|
||||
</UDashboardNavbar>
|
||||
|
||||
<UTable
|
||||
:rows="dataStore.profiles"
|
||||
:rows="profileStore.profiles"
|
||||
@select="(item) => router.push(`/profiles/show/${item.id}`)"
|
||||
:columns="columns"
|
||||
>
|
||||
|
||||
@@ -12,6 +12,7 @@ dayjs.extend(isoWeek)
|
||||
dayjs.extend(isBetween)
|
||||
|
||||
const dataStore = useDataStore()
|
||||
const profileStore = useProfileStore()
|
||||
const route = useRoute()
|
||||
const router = useRouter()
|
||||
const supabase = useSupabaseClient()
|
||||
@@ -33,7 +34,7 @@ const setupPage = async () => {
|
||||
|
||||
setupPage()
|
||||
|
||||
const emailSignature = ref(dataStore.activeProfile.emailSignature)
|
||||
const emailSignature = ref(profileStore.activeProfile.emailSignature)
|
||||
const tiptapLoaded = ref(false)
|
||||
const contentSaved = ref(true)
|
||||
const contentChanged = async (content) => {
|
||||
@@ -49,7 +50,7 @@ const contentChanged = async (content) => {
|
||||
|
||||
|
||||
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) {
|
||||
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",
|
||||
method: "post",
|
||||
data: {
|
||||
email: dataStore.activeProfile.email,
|
||||
name: dataStore.activeProfile.name,
|
||||
email: profileStore.activeProfile.email,
|
||||
name: profileStore.activeProfile.name,
|
||||
list_uuids: ["b97453fd-14b2-4b25-8f9b-b83847317ea3"],
|
||||
|
||||
}
|
||||
@@ -227,12 +228,12 @@ const isLight = computed({
|
||||
</UFormGroup>
|
||||
</InputGroup>
|
||||
|
||||
<UDivider class="my-5" v-if="dataStore.activeProfile.id === itemInfo.id">
|
||||
<UDivider class="my-5" v-if="profileStore.activeProfile.id === itemInfo.id">
|
||||
Helligkeitseinstellung
|
||||
</UDivider>
|
||||
|
||||
<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'"
|
||||
color="white"
|
||||
variant="outline"
|
||||
|
||||
@@ -23,6 +23,7 @@ defineShortcuts({
|
||||
})
|
||||
|
||||
const dataStore = useDataStore()
|
||||
const profileStore = useProfileStore()
|
||||
const supabase = useSupabaseClient()
|
||||
const user = useSupabaseUser()
|
||||
const route = useRoute()
|
||||
@@ -90,11 +91,9 @@ const mode = ref(route.params.mode || "show")
|
||||
const itemInfo = ref({
|
||||
name: "",
|
||||
customer: 0,
|
||||
users: [dataStore.activeProfile.id]
|
||||
profiles: [profileStore.activeProfile.id]
|
||||
})
|
||||
const oldItemInfo = ref({})
|
||||
const tags = dataStore.getDocumentTags
|
||||
const phasesTemplates = ref([])
|
||||
|
||||
const plants = ref([])
|
||||
const contracts = ref([])
|
||||
@@ -180,7 +179,7 @@ const changeActivePhase = async (key) => {
|
||||
if(p.key === key) {
|
||||
p.active = true
|
||||
p.activated_at = dayjs().format()
|
||||
p.activated_by = dataStore.activeProfile.id
|
||||
p.activated_by = profileStore.activeProfile.id
|
||||
phaseLabel = p.label
|
||||
}
|
||||
|
||||
@@ -191,8 +190,8 @@ const changeActivePhase = async (key) => {
|
||||
|
||||
await supabase.from("projects").update({phases: item.phases}).eq("id",item.id)
|
||||
const {error} = await supabase.from("historyitems").insert({
|
||||
createdBy: dataStore.activeProfile.id,
|
||||
tenant: dataStore.currentTenant,
|
||||
createdBy: profileStore.activeProfile.id,
|
||||
tenant: profileStore.currentTenant,
|
||||
text: `Aktive Phase zu "${phaseLabel}" gewechselt`,
|
||||
project: item.id
|
||||
})
|
||||
@@ -304,8 +303,8 @@ const invoiceDeliveryNotes = () => {
|
||||
<h1 class="font-bold text-lg mb-3">Beteiligte Benutzer:</h1>
|
||||
<UAlert
|
||||
v-for="projectUser in itemInfo.profiles"
|
||||
:avatar="{ alt: dataStore.getProfileById(projectUser).fullName }"
|
||||
:title="dataStore.getProfileById(projectUser).fullName"
|
||||
:avatar="{ alt: profileStore.getProfileById(projectUser).fullName }"
|
||||
:title="profileStore.getProfileById(projectUser).fullName"
|
||||
class="mb-3"
|
||||
|
||||
/>
|
||||
@@ -378,7 +377,7 @@ const invoiceDeliveryNotes = () => {
|
||||
|
||||
<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_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>
|
||||
</div>
|
||||
</UCard>
|
||||
@@ -406,7 +405,7 @@ const invoiceDeliveryNotes = () => {
|
||||
|
||||
>
|
||||
<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>
|
||||
</UTable>
|
||||
</UCard>
|
||||
@@ -462,7 +461,7 @@ const invoiceDeliveryNotes = () => {
|
||||
<span v-if="row.type === 'deliveryNotes'">Lieferschein</span>
|
||||
</template>
|
||||
<template #createdBy-data="{row}">
|
||||
{{dataStore.getProfileById(row.createdBy).fullName}}
|
||||
{{profileStore.getProfileById(row.createdBy).fullName}}
|
||||
</template>
|
||||
</UTable>
|
||||
|
||||
@@ -482,7 +481,7 @@ const invoiceDeliveryNotes = () => {
|
||||
:empty-state="{ icon: 'i-heroicons-clock', label: 'Noch keine Zeiten in diesem Projekt' }"
|
||||
>
|
||||
<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 #duration-data="{row}">
|
||||
{{(row.start && row.end) ? `${String(dayjs(row.end).diff(row.start,'hour',true).toFixed(2)).replace(".",",")} h` : ""}}
|
||||
@@ -640,11 +639,11 @@ const invoiceDeliveryNotes = () => {
|
||||
|
||||
|
||||
<UFormGroup
|
||||
label="Beteiligte Benutzer:"
|
||||
label="Berechtigte Benutzer:"
|
||||
>
|
||||
<USelectMenu
|
||||
v-model="itemInfo.profiles"
|
||||
:options="dataStore.profiles"
|
||||
:options="profileStore.profiles"
|
||||
option-attribute="fullName"
|
||||
value-attribute="id"
|
||||
searchable
|
||||
@@ -652,7 +651,7 @@ const invoiceDeliveryNotes = () => {
|
||||
:search-attributes="['fullName']"
|
||||
>
|
||||
<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>
|
||||
</USelectMenu>
|
||||
</UFormGroup>
|
||||
|
||||
@@ -20,6 +20,7 @@ defineShortcuts({
|
||||
})
|
||||
|
||||
const dataStore = useDataStore()
|
||||
const profileStore = useProfileStore()
|
||||
const route = useRoute()
|
||||
const router = useRouter()
|
||||
const toast = useToast()
|
||||
@@ -210,7 +211,7 @@ setupPage()
|
||||
>
|
||||
<USelectMenu
|
||||
v-model="itemInfo.tags"
|
||||
:options="dataStore.ownTenant.tags.products"
|
||||
:options="profileStore.ownTenant.tags.products"
|
||||
multiple
|
||||
/>
|
||||
</UFormGroup>
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
<script setup>
|
||||
const dataStore = useDataStore()
|
||||
const profileStore = useProfileStore()
|
||||
const route = useRoute()
|
||||
const supabase = useSupabaseClient()
|
||||
const toast = useToast()
|
||||
@@ -43,7 +44,7 @@ const generateLink = async () => {
|
||||
body: {
|
||||
method: "generateLink",
|
||||
institutionId: bankData.value.id,
|
||||
tenant: dataStore.currentTenant
|
||||
tenant: profileStore.currentTenant
|
||||
}
|
||||
})
|
||||
|
||||
@@ -62,7 +63,7 @@ const addAccount = async (account) => {
|
||||
accountId: account.id,
|
||||
ownerName: account.owner_name,
|
||||
iban: account.iban,
|
||||
tenant: dataStore.currentTenant,
|
||||
tenant: profileStore.currentTenant,
|
||||
bankId: account.institution_id
|
||||
}
|
||||
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
import axios from "axios"
|
||||
const supabase = useSupabaseClient()
|
||||
const dataStore = useDataStore()
|
||||
const profileStore = useProfileStore()
|
||||
|
||||
const createEMailAddress = ref("")
|
||||
const createEMailType = ref("imap")
|
||||
@@ -22,7 +23,7 @@ const createAccount = async () => {
|
||||
body: {
|
||||
emailAddress: createEMailAddress.value,
|
||||
accountType: createEMailType.value,
|
||||
profile: dataStore.activeProfile.id
|
||||
profile: profileStore.activeProfile.id
|
||||
}
|
||||
})
|
||||
|
||||
|
||||
@@ -3,6 +3,7 @@ definePageMeta({
|
||||
middleware: "auth"
|
||||
})
|
||||
const dataStore = useDataStore()
|
||||
const profileStore = useProfileStore()
|
||||
const supabase = useSupabaseClient()
|
||||
const router = useRouter()
|
||||
|
||||
@@ -71,14 +72,14 @@ const isLight = computed({
|
||||
/>
|
||||
<InputGroup>
|
||||
<UBadge
|
||||
v-for="tag in dataStore.ownTenant.tags.documents"
|
||||
v-for="tag in profileStore.ownTenant.tags.documents"
|
||||
>
|
||||
{{tag}}
|
||||
</UBadge>
|
||||
</InputGroup>
|
||||
|
||||
|
||||
{{dataStore.ownTenant.tags}}
|
||||
{{profileStore.ownTenant.tags}}
|
||||
</div>
|
||||
</UCard>
|
||||
|
||||
|
||||
@@ -87,6 +87,7 @@ defineShortcuts({
|
||||
const router = useRouter()
|
||||
const supabase = useSupabaseClient()
|
||||
const dataStore = useDataStore()
|
||||
const profileStore = useProfileStore()
|
||||
const mode = useRoute().params.mode
|
||||
const openTab = ref(0)
|
||||
|
||||
@@ -106,7 +107,7 @@ const renderDemoZPL = () => {
|
||||
|
||||
const printLabel = async () => {
|
||||
await supabase.from("printJobs").insert({
|
||||
tenant: dataStore.currentTenant,
|
||||
tenant: profileStore.currentTenant,
|
||||
rawContent: useGenerateZPL(itemInfo.value.handlebarsZPL,{barcode:"XXX"}),
|
||||
printerName: "ZD411",
|
||||
printServer: "0dbe30f3-3008-4cde-8a7c-e785b1c22bfc"
|
||||
|
||||
@@ -5,6 +5,8 @@ definePageMeta({
|
||||
|
||||
const supabase = useSupabaseClient()
|
||||
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 {data,error} = await supabase
|
||||
.from("tenants")
|
||||
.update({numberRanges: numberRanges.value})
|
||||
.eq('id',dataStore.currentTenant)
|
||||
.eq('id',profileStore.currentTenant)
|
||||
|
||||
await dataStore.fetchOwnTenant()
|
||||
}
|
||||
|
||||
@@ -16,12 +16,6 @@ const setupPage = async () => {
|
||||
>
|
||||
|
||||
</UDashboardNavbar>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
{{dataStore.ownTenant.ownFields}}
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
<script setup>
|
||||
|
||||
const dataStore = useDataStore()
|
||||
const profileStore = useProfileStore()
|
||||
const supabase = useSupabaseClient()
|
||||
|
||||
const itemInfo = ref({
|
||||
@@ -10,17 +11,17 @@ const itemInfo = ref({
|
||||
})
|
||||
|
||||
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)
|
||||
}
|
||||
|
||||
const features = ref(dataStore.ownTenant.features)
|
||||
const businessInfo = ref(dataStore.ownTenant.businessInfo)
|
||||
const features = ref(profileStore.ownTenant.features)
|
||||
const businessInfo = ref(profileStore.ownTenant.businessInfo)
|
||||
|
||||
const updateTenant = async (newData) => {
|
||||
const {data,error} = await supabase.from("tenants")
|
||||
.update(newData)
|
||||
.eq("id",dataStore.currentTenant)
|
||||
.eq("id",profileStore.currentTenant)
|
||||
.select()
|
||||
|
||||
if (error) console.log(error)
|
||||
|
||||
@@ -79,7 +79,7 @@ function getSpaceProductCount(productId) {
|
||||
/*
|
||||
const printSpaceLabel = async () => {
|
||||
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)
|
||||
.catch(console.log)
|
||||
}
|
||||
|
||||
@@ -4,6 +4,7 @@ definePageMeta({
|
||||
})
|
||||
|
||||
const dataStore = useDataStore()
|
||||
const profileStore = useProfileStore()
|
||||
const route = useRoute()
|
||||
const router = useRouter()
|
||||
const toast = useToast()
|
||||
@@ -12,7 +13,7 @@ const id = ref(route.params.id ? route.params.id : null )
|
||||
//Working
|
||||
const mode = ref(route.params.mode || "show")
|
||||
const itemInfo = ref({
|
||||
profile: dataStore.activeProfile.id
|
||||
profile: profileStore.activeProfile.id
|
||||
})
|
||||
const oldItemInfo = ref({})
|
||||
const categories = ["Offen", "In Bearbeitung", "Dringed", "Erledigt"]
|
||||
@@ -148,7 +149,7 @@ setupPage()
|
||||
>
|
||||
<USelectMenu
|
||||
v-model="itemInfo.profile"
|
||||
:options="dataStore.profiles"
|
||||
:options="profileStore.profiles"
|
||||
option-attribute="fullName"
|
||||
value-attribute="id"
|
||||
searchable-placeholder="Suche..."
|
||||
@@ -156,7 +157,7 @@ setupPage()
|
||||
:search-attributes="['fullName']"
|
||||
>
|
||||
<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>
|
||||
</USelectMenu>
|
||||
</UFormGroup>
|
||||
|
||||
@@ -64,7 +64,7 @@
|
||||
{{row.created_at ? dayjs(row.created_at).format("DD.MM.YY HH:mm") : ''}}
|
||||
</template>
|
||||
<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 #project-data="{row}">
|
||||
{{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 profileStore = useProfileStore()
|
||||
const router = useRouter()
|
||||
|
||||
defineShortcuts({
|
||||
|
||||
@@ -23,6 +23,7 @@ defineShortcuts({
|
||||
})
|
||||
|
||||
const dataStore = useDataStore()
|
||||
const profileStore = useProfileStore()
|
||||
const route = useRoute()
|
||||
const router = useRouter()
|
||||
const toast = useToast()
|
||||
@@ -205,7 +206,7 @@ setupPage()
|
||||
</tr>
|
||||
<tr>
|
||||
<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>
|
||||
<td>Tankvolumen:</td>
|
||||
@@ -334,13 +335,13 @@ setupPage()
|
||||
>
|
||||
<USelectMenu
|
||||
v-model="itemInfo.driver"
|
||||
:options="[{id: null, fullName: 'Kein Fahrer'},...dataStore.profiles]"
|
||||
:options="[{id: null, fullName: 'Kein Fahrer'},...profileStore.profiles]"
|
||||
option-attribute="fullName"
|
||||
value-attribute="id"
|
||||
|
||||
>
|
||||
<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>
|
||||
</USelectMenu>
|
||||
</UFormGroup>
|
||||
|
||||
23
pages/vendors/[mode]/[[id]].vue
vendored
23
pages/vendors/[mode]/[[id]].vue
vendored
@@ -21,10 +21,9 @@ defineShortcuts({
|
||||
})
|
||||
|
||||
const dataStore = useDataStore()
|
||||
const profileStore = useProfileStore()
|
||||
const route = useRoute()
|
||||
const router = useRouter()
|
||||
const toast = useToast()
|
||||
const id = ref(route.params.id ? route.params.id : null )
|
||||
const openTab = ref(0)
|
||||
let currentItem = ref(null)
|
||||
|
||||
@@ -33,7 +32,8 @@ let currentItem = ref(null)
|
||||
//Working
|
||||
const mode = ref(route.params.mode || "show")
|
||||
const itemInfo = ref({
|
||||
infoData: {}
|
||||
infoData: {},
|
||||
profiles: [profileStore.activeProfile.id]
|
||||
})
|
||||
const oldItemInfo = ref({})
|
||||
|
||||
@@ -266,6 +266,23 @@ setupPage()
|
||||
v-model="itemInfo.infoData.ustid"
|
||||
/>
|
||||
</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>
|
||||
</template>
|
||||
|
||||
|
||||
@@ -3,6 +3,7 @@ import dayjs from "dayjs";
|
||||
|
||||
|
||||
const dataStore = useDataStore()
|
||||
const profileStore = useProfileStore()
|
||||
const route = useRoute()
|
||||
const router = useRouter()
|
||||
const toast = useToast()
|
||||
@@ -12,7 +13,7 @@ const mode = ref(route.params.mode || "show")
|
||||
const itemInfo = ref({
|
||||
startDate: new Date(),
|
||||
endDate: new Date(),
|
||||
profile: dataStore.activeProfile.id
|
||||
profile: profileStore.activeProfile.id
|
||||
})
|
||||
const oldItemInfo = ref({})
|
||||
|
||||
@@ -88,7 +89,7 @@ setupPage()
|
||||
label="Mitarbeiter:"
|
||||
>
|
||||
<USelectMenu
|
||||
:options="dataStore.profiles"
|
||||
:options="profileStore.profiles"
|
||||
v-model="itemInfo.profile"
|
||||
option-attribute="fullName"
|
||||
value-attribute="id"
|
||||
|
||||
@@ -15,6 +15,7 @@ dayjs.extend(isSameOrBefore)
|
||||
|
||||
|
||||
const dataStore = useDataStore()
|
||||
const profileStore = useProfileStore()
|
||||
const supabase = useSupabaseClient()
|
||||
const route = useRoute()
|
||||
const router = useRouter()
|
||||
@@ -27,7 +28,7 @@ const absencerequests = ref([])
|
||||
|
||||
|
||||
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))
|
||||
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
|
||||
@@ -177,13 +178,13 @@ const getDuration = (time) => {
|
||||
const showDocument = ref(false)
|
||||
const uri = ref("")
|
||||
const generateDocument = async () => {
|
||||
const ownTenant = dataStore.ownTenant
|
||||
const ownTenant = profileStore.ownTenant
|
||||
const path = ownTenant.letterheadConfig["workingTimesEvaluation"]
|
||||
|
||||
const {data,error} = await supabase.storage.from("files").download(path)
|
||||
|
||||
uri.value = await useCreateWorkingTimesPdf({
|
||||
profile: dataStore.getProfileById(route.params.id).fullName,
|
||||
profile: profileStore.getProfileById(route.params.id).fullName,
|
||||
...workingTimeInfo.value}, await data.arrayBuffer())
|
||||
//alert(uri.value)
|
||||
showDocument.value = true
|
||||
@@ -345,7 +346,7 @@ changeRange()
|
||||
]"
|
||||
>
|
||||
<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 #approved-data="{row}">
|
||||
<span v-if="row.approved" class="text-primary-500">Ja</span>
|
||||
|
||||
@@ -9,6 +9,7 @@ definePageMeta({
|
||||
})
|
||||
|
||||
const dataStore = useDataStore()
|
||||
const profileStore = useProfileStore()
|
||||
const supabase = useSupabaseClient()
|
||||
const user = useSupabaseUser()
|
||||
const toast = useToast()
|
||||
@@ -22,7 +23,7 @@ const timeInfo = ref({
|
||||
notes: null,
|
||||
})
|
||||
|
||||
const filterUser = ref(dataStore.activeProfile.id || "")
|
||||
const filterUser = ref(profileStore.activeProfile.id || "")
|
||||
|
||||
const workingtimes = ref([])
|
||||
|
||||
@@ -43,15 +44,6 @@ const filteredRows = computed(() => {
|
||||
|
||||
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 {
|
||||
@@ -115,16 +107,15 @@ const columns = [
|
||||
}
|
||||
]
|
||||
|
||||
console.log(dataStore.workingtimes)
|
||||
|
||||
const runningTimeInfo = ref({})
|
||||
|
||||
const startTime = async () => {
|
||||
console.log("started")
|
||||
timeInfo.value = {
|
||||
profile: dataStore.activeProfile.id,
|
||||
profile: profileStore.activeProfile.id,
|
||||
startDate: dayjs(),
|
||||
tenant: dataStore.currentTenant,
|
||||
tenant: profileStore.currentTenant,
|
||||
state: "Im Web gestartet"
|
||||
}
|
||||
|
||||
@@ -137,7 +128,7 @@ const startTime = async () => {
|
||||
} else if(data) {
|
||||
//timeInfo.value = data[0]
|
||||
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)) {
|
||||
runningTimeInfo.value = dataStore.workingtimes.find(time => time.profile === dataStore.activeProfile.id && !time.end)
|
||||
if(dataStore.workingtimes.find(time => time.profile === profileStore.activeProfile.id && !time.endDate)) {
|
||||
runningTimeInfo.value = dataStore.workingtimes.find(time => time.profile === profileStore.activeProfile.id && !time.end)
|
||||
}
|
||||
|
||||
const getDuration = (time) => {
|
||||
@@ -216,14 +207,14 @@ const expand = ref({
|
||||
<template #left>
|
||||
|
||||
<USelectMenu
|
||||
:options="dataStore.profiles"
|
||||
:options="profileStore.profiles"
|
||||
option-attribute="fullName"
|
||||
value-attribute="id"
|
||||
v-model="filterUser"
|
||||
@change="setupPage"
|
||||
>
|
||||
<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>
|
||||
</USelectMenu>
|
||||
<UButton
|
||||
@@ -337,7 +328,7 @@ const expand = ref({
|
||||
|
||||
</div>
|
||||
<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">Ende:</span> {{dayjs(row.endDate).format("DD.MM.YYYY HH:mm")}}</p>
|
||||
<p><span class="font-bold">Genehmigt:</span> {{row.approved ? "Ja" : "Nein"}}</p>
|
||||
@@ -345,7 +336,7 @@ const expand = ref({
|
||||
</div>
|
||||
</template>
|
||||
<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 #approved-data="{row}">
|
||||
<span v-if="row.approved" class="text-primary-500">Ja</span>
|
||||
|
||||
387
stores/data.js
387
stores/data.js
@@ -18,6 +18,7 @@ import unit from "~/components/columnRenderings/unit.vue";
|
||||
export const useDataStore = defineStore('data', () => {
|
||||
|
||||
const supabase = useSupabaseClient()
|
||||
const profileStore = useProfileStore()
|
||||
const user = useSupabaseUser()
|
||||
const toast = useToast()
|
||||
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 customers = ref([])
|
||||
const tasks = ref([])
|
||||
@@ -520,7 +499,6 @@ export const useDataStore = defineStore('data', () => {
|
||||
const bankstatements = ref([])
|
||||
const bankrequisitions = ref([])
|
||||
const historyItems = ref([])
|
||||
const numberRanges = ref([])
|
||||
const notifications = ref([])
|
||||
const absencerequests = ref([])
|
||||
const accounts = ref([])
|
||||
@@ -538,126 +516,8 @@ export const useDataStore = defineStore('data', () => {
|
||||
const servicecategories =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 () {
|
||||
await fetchOwnProfiles()
|
||||
await fetchProfiles()
|
||||
|
||||
await fetchTenants()
|
||||
await fetchOwnTenant()
|
||||
|
||||
//loaded.value = true
|
||||
await fetchDocuments()
|
||||
await fetchDocuments()
|
||||
await fetchEvents()
|
||||
await fetchTasks()
|
||||
await fetchProjects()
|
||||
@@ -678,7 +538,6 @@ export const useDataStore = defineStore('data', () => {
|
||||
await fetchBankStatements()
|
||||
await fetchBankRequisitions()
|
||||
await fetchHistoryItems()
|
||||
await fetchNumberRanges()
|
||||
await fetchNotifications()
|
||||
await fetchAbsenceRequests()
|
||||
await fetchAccounts()
|
||||
@@ -695,18 +554,9 @@ export const useDataStore = defineStore('data', () => {
|
||||
await fetchServices()
|
||||
await fetchServiceCategories()
|
||||
await fetchResources()
|
||||
loaded.value = true
|
||||
|
||||
|
||||
}
|
||||
|
||||
function clearStore () {
|
||||
console.log("Clear")
|
||||
loaded.value = false
|
||||
ownTenant.value = {}
|
||||
profiles.value = []
|
||||
ownProfiles.value = []
|
||||
tenants.value = []
|
||||
events.value= []
|
||||
customers.value= []
|
||||
tasks.value= []
|
||||
@@ -728,7 +578,6 @@ export const useDataStore = defineStore('data', () => {
|
||||
bankstatements.value= []
|
||||
bankrequisitions.value= []
|
||||
historyItems.value = []
|
||||
numberRanges.value = []
|
||||
notifications.value = []
|
||||
absencerequests.value = []
|
||||
accounts.value = []
|
||||
@@ -747,16 +596,6 @@ export const useDataStore = defineStore('data', () => {
|
||||
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 () {
|
||||
return {
|
||||
VALUE_CREATED: 'created',
|
||||
@@ -831,8 +670,6 @@ export const useDataStore = defineStore('data', () => {
|
||||
}
|
||||
}();
|
||||
|
||||
|
||||
|
||||
const generateHistoryItems = async (dataType,newData, oldData=null) => {
|
||||
//console.log(oldData)
|
||||
//console.log(newData)
|
||||
@@ -1022,7 +859,7 @@ export const useDataStore = defineStore('data', () => {
|
||||
createdBy: activeProfile.value.id,
|
||||
oldVal: prop.data.o,
|
||||
newVal: prop.data.n,
|
||||
tenant: currentTenant.value
|
||||
tenant: profileStore.currentTenant
|
||||
}
|
||||
|
||||
historyItem[dataTypes[dataType].historyItemHolder] = newData.id
|
||||
@@ -1056,7 +893,7 @@ export const useDataStore = defineStore('data', () => {
|
||||
let historyItem = {
|
||||
text: `${dataTypes[dataType].labelSingle} erstellt`,
|
||||
createdBy: activeProfile.value.id,
|
||||
tenant: currentTenant.value
|
||||
tenant: profileStore.currentTenant
|
||||
}
|
||||
|
||||
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){
|
||||
if(typeOf(data) === 'object') {
|
||||
data = {...data, tenant: currentTenant.value}
|
||||
data = {...data, tenant: profileStore.currentTenant}
|
||||
} else if(typeOf(data) === 'array') {
|
||||
data.map(i => {
|
||||
return {
|
||||
...i,
|
||||
tenant: currentTenant.value
|
||||
tenant: profileStore.currentTenant
|
||||
}
|
||||
})
|
||||
}
|
||||
@@ -1226,7 +1039,7 @@ export const useDataStore = defineStore('data', () => {
|
||||
const {data, error} = await supabase
|
||||
.storage
|
||||
.from("files")
|
||||
.upload(`${currentTenant.value}/${file.name}`, file, {upsert: upsert})
|
||||
.upload(`${profileStore.currentTenant}/${file.name}`, file, {upsert: upsert})
|
||||
|
||||
if (error) {
|
||||
console.log(error)
|
||||
@@ -1246,7 +1059,7 @@ export const useDataStore = defineStore('data', () => {
|
||||
} else if (data) {
|
||||
const returnPath = data.path
|
||||
|
||||
documentsToInsert.push({...formData, path: returnPath, tenant: currentTenant.value})
|
||||
documentsToInsert.push({...formData, path: returnPath, tenant: profileStore.currentTenant})
|
||||
}
|
||||
|
||||
//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 () {
|
||||
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 () {
|
||||
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 () {
|
||||
bankrequisitions.value = (await supabase.from("bankrequisitions").select().eq('status', "LN")).data
|
||||
}
|
||||
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 () {
|
||||
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 () {
|
||||
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 () {
|
||||
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 () {
|
||||
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 () {
|
||||
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 () {
|
||||
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 () {
|
||||
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 () {
|
||||
units.value = (await supabase.from("units").select()).data
|
||||
}
|
||||
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 () {
|
||||
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 () {
|
||||
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 () {
|
||||
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 () {
|
||||
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 () {
|
||||
|
||||
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 () {
|
||||
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 () {
|
||||
incominginvoices.value = (await supabase.from("incominginvoices").select().eq('tenant', currentTenant.value)).data
|
||||
}
|
||||
async function fetchNumberRanges () {
|
||||
numberRanges.value = (await supabase.from("numberranges").select().eq('tenant', currentTenant.value)).data
|
||||
incominginvoices.value = (await supabase.from("incominginvoices").select().eq('tenant', profileStore.currentTenant)).data
|
||||
}
|
||||
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 () {
|
||||
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 () {
|
||||
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
|
||||
}
|
||||
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 () {
|
||||
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() {
|
||||
chats.value = (await supabase.from("chats").select()).data
|
||||
}
|
||||
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() {
|
||||
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() {
|
||||
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() {
|
||||
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() {
|
||||
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() {
|
||||
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() {
|
||||
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() {
|
||||
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() {
|
||||
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 () {
|
||||
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){
|
||||
let paths = []
|
||||
@@ -1482,22 +1272,17 @@ export const useDataStore = defineStore('data', () => {
|
||||
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) => {
|
||||
return movements.value.filter(movement => movement.spaceId === spaceId)
|
||||
})
|
||||
|
||||
const getContactsByCustomerId = computed(() => (customerId) => {
|
||||
return contacts.value.filter(item => item.customer === customerId)
|
||||
})
|
||||
async function getContactsByCustomerId (itemId) {
|
||||
return (await supabase.from("contacts").select().eq("customer", itemId)).data
|
||||
}
|
||||
|
||||
const getProjectsByCustomerId = computed(() => (customerId) => {
|
||||
return projects.value.filter(item => item.customer === customerId)
|
||||
})
|
||||
async function getProjectsByCustomerId (itemId) {
|
||||
return (await supabase.from("projects").select().eq("customer",itemId)).data
|
||||
}
|
||||
|
||||
const getPlantsByCustomerId = computed(() => (customerId) => {
|
||||
return plants.value.filter(item => item.customer === customerId)
|
||||
@@ -1673,7 +1458,7 @@ export const useDataStore = defineStore('data', () => {
|
||||
|
||||
const getResources = computed(() => {
|
||||
return [
|
||||
...profiles.value.filter(i => i.tenant === currentTenant.value).map(profile => {
|
||||
...profiles.value.filter(i => i.tenant === profileStore.currentTenant).map(profile => {
|
||||
return {
|
||||
type: 'Mitarbeiter',
|
||||
title: profile.fullName,
|
||||
@@ -1699,7 +1484,7 @@ export const useDataStore = defineStore('data', () => {
|
||||
|
||||
const getResourcesList = computed(() => {
|
||||
return [
|
||||
...profiles.value.filter(i => i.tenant === currentTenant.value).map(profile => {
|
||||
...profiles.value.filter(i => i.tenant === profileStore.currentTenant).map(profile => {
|
||||
return {
|
||||
type: 'Mitarbeiter',
|
||||
title: profile.fullName,
|
||||
@@ -1886,10 +1671,6 @@ export const useDataStore = defineStore('data', () => {
|
||||
return absencerequests.value.find(item => item.id === itemId)
|
||||
})
|
||||
|
||||
const getProfileById = computed(() => (itemId) => {
|
||||
return profiles.value.find(item => item.id === itemId)
|
||||
})
|
||||
|
||||
const getAccountById = computed(() => (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)
|
||||
})
|
||||
|
||||
const getEventById = computed(() => (itemId) => {
|
||||
return events.value.find(item => item.id === itemId)
|
||||
})
|
||||
|
||||
const getWorkingTimeById = computed(() => (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) => {
|
||||
|
||||
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 {
|
||||
//General
|
||||
currentTenant,
|
||||
loaded,
|
||||
showProfileSelection,
|
||||
ownTenant,
|
||||
initializeData,
|
||||
changeProfile,
|
||||
uploadFiles,
|
||||
generateHistoryItems,
|
||||
dataTypes,
|
||||
|
||||
//Data
|
||||
profiles,
|
||||
ownProfiles,
|
||||
activeProfile,
|
||||
tenants,
|
||||
events,
|
||||
customers,
|
||||
tasks,
|
||||
@@ -2004,7 +1749,6 @@ export const useDataStore = defineStore('data', () => {
|
||||
bankstatements,
|
||||
bankrequisitions,
|
||||
historyItems,
|
||||
numberRanges,
|
||||
notifications,
|
||||
absencerequests,
|
||||
accounts,
|
||||
@@ -2027,42 +1771,12 @@ export const useDataStore = defineStore('data', () => {
|
||||
updateItem,
|
||||
fetchData,
|
||||
clearStore,
|
||||
fetchOwnTenant,
|
||||
fetchProfiles,
|
||||
fetchOwnProfiles,
|
||||
fetchBankAccounts,
|
||||
fetchBankStatements,
|
||||
fetchBankRequisitions,
|
||||
fetchEvents,
|
||||
fetchContracts,
|
||||
fetchContacts,
|
||||
fetchCustomers,
|
||||
fetchTasks,
|
||||
fetchForms,
|
||||
fetchFormSubmits,
|
||||
fetchProducts,
|
||||
fetchUnits,
|
||||
fetchProjects,
|
||||
fetchSpaces,
|
||||
fetchMovements,
|
||||
fetchVehicles,
|
||||
fetchTimes,
|
||||
fetchHistoryItems,
|
||||
fetchVendors,
|
||||
fetchIncomingInvoices,
|
||||
fetchNumberRanges,
|
||||
fetchNotifications,
|
||||
fetchDocuments,
|
||||
fetchAbsenceRequests,
|
||||
fetchPlants,
|
||||
fetchInventoryItems,
|
||||
fetchChats,
|
||||
fetchMessages,
|
||||
fetchWorkingTimes,
|
||||
addHistoryItem,
|
||||
//Getters
|
||||
getOpenTasksCount,
|
||||
getOwnProfile,
|
||||
getMovementsBySpace,
|
||||
getContactsByCustomerId,
|
||||
getProjectsByCustomerId,
|
||||
@@ -2115,17 +1829,12 @@ export const useDataStore = defineStore('data', () => {
|
||||
getTaskById,
|
||||
getAbsenceRequestById,
|
||||
getProjectById,
|
||||
getProfileById,
|
||||
getAccountById,
|
||||
getPlantById,
|
||||
getCreatedDocumentById,
|
||||
getInventoryItemById,
|
||||
getBankAccountById,
|
||||
getEventById,
|
||||
getWorkingTimeById,
|
||||
//getOpenDocuments,
|
||||
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