Changed STore Type and corrected all Pages
Added HistoryDisplay.vue Added NumberRanges
This commit is contained in:
@@ -2,288 +2,424 @@ import {defineStore} from 'pinia'
|
||||
|
||||
import {createClient} from '@supabase/supabase-js'
|
||||
|
||||
const supabase = createClient('https://uwppvcxflrcsibuzsbil.supabase.co','eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6InV3cHB2Y3hmbHJjc2lidXpzYmlsIiwicm9sZSI6ImFub24iLCJpYXQiOjE3MDA5MzgxOTQsImV4cCI6MjAxNjUxNDE5NH0.CkxYSQH0uLfwx9GVUlO6AYMU2FMLAxGMrwEKvyPv7Oo')
|
||||
//const supabase = createClient('https://uwppvcxflrcsibuzsbil.supabase.co','eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6InV3cHB2Y3hmbHJjc2lidXpzYmlsIiwicm9sZSI6ImFub24iLCJpYXQiOjE3MDA5MzgxOTQsImV4cCI6MjAxNjUxNDE5NH0.CkxYSQH0uLfwx9GVUlO6AYMU2FMLAxGMrwEKvyPv7Oo')
|
||||
|
||||
// @ts-ignore
|
||||
export const useDataStore = defineStore('data', {
|
||||
state: () => ({
|
||||
loaded: false,
|
||||
ownTenant: {
|
||||
calendarConfig: {
|
||||
eventTypes: [] as any[]
|
||||
},
|
||||
timeConfig: {
|
||||
timeTypes: [] as any[]
|
||||
},
|
||||
tags: {
|
||||
documents: [] as any[],
|
||||
export const useDataStore = defineStore('data', () => {
|
||||
|
||||
const supabase = useSupabaseClient()
|
||||
const user = useSupabaseUser()
|
||||
const toast = useToast()
|
||||
|
||||
const loaded = ref(false)
|
||||
const ownTenant = ref({
|
||||
calendarConfig: {
|
||||
eventTypes: [] as any[]
|
||||
},
|
||||
timeConfig: {
|
||||
timeTypes: [] as any[]
|
||||
},
|
||||
tags: {
|
||||
documents: [] as any[],
|
||||
products: [] as any[]
|
||||
}
|
||||
},
|
||||
profiles: [] as any[],
|
||||
events: [] as any[],
|
||||
customers: [] as any[],
|
||||
tasks: [] as any[],
|
||||
projects: [] as any[],
|
||||
documents: [] as any[],
|
||||
spaces: [] as any[],
|
||||
units: [] as any[],
|
||||
times: [] as any[],
|
||||
products: [] as any[],
|
||||
movements: [] as any[],
|
||||
forms: [] as any[],
|
||||
contracts: [] as any[],
|
||||
jobs: [] as any[],
|
||||
formSubmits: [] as any[],
|
||||
contacts: [] as any[],
|
||||
vehicles: [] as any[],
|
||||
vendors: [] as any[],
|
||||
vendorInvoices: [] as any[],
|
||||
bankAccounts: [] as any[],
|
||||
bankStatements: [] as any[]
|
||||
}),
|
||||
actions: {
|
||||
async fetchData() {
|
||||
this.fetchDocuments()
|
||||
await this.fetchOwnTenant()
|
||||
await this.fetchProfiles()
|
||||
await this.fetchEvents()
|
||||
await this.fetchTasks()
|
||||
await this.fetchProjects()
|
||||
await this.fetchTimes()
|
||||
await this.fetchJobs()
|
||||
this.loaded = true
|
||||
|
||||
|
||||
await this.fetchCustomers()
|
||||
await this.fetchContracts()
|
||||
await this.fetchContacts()
|
||||
await this.fetchForms()
|
||||
await this.fetchFormSubmits()
|
||||
await this.fetchProducts()
|
||||
await this.fetchUnits()
|
||||
//await this.fetchDocuments()
|
||||
await this.fetchMovements()
|
||||
await this.fetchSpaces()
|
||||
await this.fetchVehicles()
|
||||
await this.fetchVendors()
|
||||
await this.fetchVendorInvoices()
|
||||
await this.fetchBankAccounts()
|
||||
await this.fetchBankStatements()
|
||||
|
||||
|
||||
},
|
||||
async clearStore() {
|
||||
console.log("Clear")
|
||||
this.loaded = false
|
||||
this.ownTenant = {}
|
||||
this.profiles= []
|
||||
this.events= []
|
||||
this.customers= []
|
||||
this.tasks= []
|
||||
this.projects= []
|
||||
this.documents= []
|
||||
this.spaces= []
|
||||
this.units= []
|
||||
this.times= []
|
||||
this.products= []
|
||||
this.movements= []
|
||||
this.forms= []
|
||||
this.contracts= []
|
||||
this.jobs= []
|
||||
this.formSubmits= []
|
||||
this.contacts= []
|
||||
this.vehicles= []
|
||||
this.vendors= []
|
||||
this.vendorInvoices= []
|
||||
this.bankAccounts= []
|
||||
this.bankStatements= []
|
||||
},
|
||||
async fetchOwnTenant() {
|
||||
//TODO: Tenant ID Dynamisch machen
|
||||
// @ts-ignore
|
||||
this.ownTenant = (await supabase.from("tenants").select().eq('id', 1)).data[0]
|
||||
},
|
||||
async fetchProfiles() {
|
||||
// @ts-ignore
|
||||
this.profiles = (await supabase.from("profiles").select()).data
|
||||
},
|
||||
async fetchBankAccounts() {
|
||||
// @ts-ignore
|
||||
this.bankAccounts = (await supabase.from("bankAccounts").select()).data
|
||||
},
|
||||
async fetchBankStatements() {
|
||||
// @ts-ignore
|
||||
this.bankStatements = (await supabase.from("bankStatements").select()).data
|
||||
},
|
||||
async fetchEvents() {
|
||||
// @ts-ignore
|
||||
this.events = (await supabase.from("events").select()).data
|
||||
},
|
||||
async fetchContracts() {
|
||||
// @ts-ignore
|
||||
this.contracts = (await supabase.from("contracts").select()).data
|
||||
},
|
||||
async fetchContacts() {
|
||||
// @ts-ignore
|
||||
this.contacts = (await supabase.from("contacts").select()).data
|
||||
},
|
||||
async fetchCustomers() {
|
||||
// @ts-ignore
|
||||
this.customers = (await supabase.from("customers").select().order('customerNumber', {ascending: true})).data
|
||||
},
|
||||
async fetchTasks() {
|
||||
// @ts-ignore
|
||||
this.tasks = (await supabase.from("tasks").select()).data
|
||||
},
|
||||
async fetchForms() {
|
||||
// @ts-ignore
|
||||
this.forms = (await supabase.from("forms").select()).data
|
||||
},
|
||||
async fetchFormSubmits() {
|
||||
// @ts-ignore
|
||||
this.formSubmits = (await supabase.from("formSubmits").select()).data
|
||||
},
|
||||
async fetchProducts() {
|
||||
// @ts-ignore
|
||||
this.products = (await supabase.from("products").select().order('id',{ascending: true})).data
|
||||
},
|
||||
async fetchUnits() {
|
||||
// @ts-ignore
|
||||
this.units = (await supabase.from("units").select()).data
|
||||
},
|
||||
async fetchProjects() {
|
||||
// @ts-ignore
|
||||
this.projects = (await supabase.from("projects").select()).data
|
||||
},
|
||||
async fetchSpaces() {
|
||||
// @ts-ignore
|
||||
this.spaces = (await supabase.from("spaces").select().order('spaceNumber', {ascending: true})).data
|
||||
},
|
||||
async fetchMovements() {
|
||||
// @ts-ignore
|
||||
this.movements = (await supabase.from("movements").select()).data
|
||||
},
|
||||
async fetchVehicles() {
|
||||
// @ts-ignore
|
||||
this.vehicles = (await supabase.from("vehicles").select()).data
|
||||
},
|
||||
async fetchTimes() {
|
||||
// @ts-ignore
|
||||
this.times = (await supabase.from("times").select()).data
|
||||
},
|
||||
async fetchJobs() {
|
||||
// @ts-ignore
|
||||
this.jobs = (await supabase.from("jobs").select()).data
|
||||
},
|
||||
async fetchVendors() {
|
||||
// @ts-ignore
|
||||
this.vendors = (await supabase.from("vendors").select().order('vendorNumber',{ascending: true})).data
|
||||
},
|
||||
async fetchVendorInvoices() {
|
||||
// @ts-ignore
|
||||
this.vendorInvoices = (await supabase.from("vendorInvoices").select()).data
|
||||
},
|
||||
async fetchDocuments() {
|
||||
// @ts-ignore
|
||||
this.documents = (await supabase.from("documents").select()).data
|
||||
|
||||
for(const [index,doc] of this.documents.entries()){
|
||||
// @ts-ignore
|
||||
this.documents[index].url = (await supabase.storage.from('files').createSignedUrl(doc.path, 60 * 60)).data.signedUrl
|
||||
}
|
||||
}
|
||||
},
|
||||
getters: {
|
||||
getProfileById: (state) => (userUid:string) => state.profiles.find(profile => profile.id === userUid),
|
||||
getOpenTasksCount: (state) => state.tasks.filter(task => task.categorie != "Erledigt").length,
|
||||
movementsBySpace: (state) => (spaceId:number) => state.movements.filter(move => move.spaceId === spaceId),
|
||||
getStockByProductId: (state) => (productId:number) => {
|
||||
let movements = state.movements.filter((movement:any) => movement.productId === productId)
|
||||
})
|
||||
const profiles = ref([])
|
||||
const events = ref([])
|
||||
const customers = ref([])
|
||||
const tasks = ref([])
|
||||
const projects = ref([])
|
||||
const documents = ref([])
|
||||
const spaces = ref([])
|
||||
const units = ref([])
|
||||
const times = ref([])
|
||||
const products = ref([])
|
||||
const movements = ref([])
|
||||
const forms = ref([])
|
||||
const contracts = ref([])
|
||||
const jobs = ref([])
|
||||
const formSubmits = ref([])
|
||||
const contacts = ref([])
|
||||
const vehicles = ref([])
|
||||
const vendors = ref([])
|
||||
const vendorInvoices = ref([])
|
||||
const bankAccounts = ref([])
|
||||
const bankStatements = ref([])
|
||||
const historyItems = ref([])
|
||||
const numberRanges = ref([])
|
||||
|
||||
let count = 0
|
||||
|
||||
movements.forEach(movement => count += movement.quantity)
|
||||
|
||||
return count
|
||||
|
||||
},
|
||||
getProductById: (state) => (productId:number) => state.products.find(product => product.id === productId),
|
||||
getVendorById: (state) => (itemId:number) => state.vendors.find(item => item.id === itemId),
|
||||
getVendorInvoiceById: (state) => (itemId:number) => state.vendorInvoices.find(item => item.id === itemId),
|
||||
getContractById: (state) => (itemId:number) => state.contracts.find(item => item.id === itemId),
|
||||
getContactById: (state) => (itemId:number) => state.contacts.find(item => item.id === itemId),
|
||||
getVehicleById: (state) => (itemId:number) => state.vehicles.find(item => item.id === itemId),
|
||||
getDocumentById: (state) => (itemId:number) => state.documents.find(item => item.id === itemId),
|
||||
getSpaceById: (state) => (itemId:number) => state.spaces.find(item => item.id === itemId),
|
||||
getProjectById: (state) => (projectId:number) => {
|
||||
let project = state.projects.find(project => project.id === projectId)
|
||||
|
||||
let projectHours = 0
|
||||
|
||||
let projectTimes = state.times.filter(time => time.projectId === projectId)
|
||||
projectTimes.forEach(time => projectHours += time.duration)
|
||||
|
||||
project.projectHours = projectHours
|
||||
|
||||
return project
|
||||
|
||||
},
|
||||
getCustomerById: (state) => (customerId:number) => state.customers.find(customer => customer.id === customerId),
|
||||
getJobById: (state) => (jobId:number) => state.jobs.find(job => job.id === jobId),
|
||||
getContactsByCustomerId: (state) => (customerId) => state.contacts.filter(contact => contact.customer === customerId),
|
||||
getTimesByProjectId: (state) => (projectId:number) => {
|
||||
let times = state.times.filter(time => time.projectId === projectId)
|
||||
console.log(times.length)
|
||||
|
||||
/*const mapNumRange = (num, inMin, inMax, outMin, outMax) =>
|
||||
((num - inMin) * (outMax - outMin)) / (inMax - inMin) + outMin;
|
||||
|
||||
times.forEach((time,index) => {
|
||||
times[index].duration = Math.round(mapNumRange(Math.abs(new Date(time.end) - new Date(time.start))/1000/60,0,60,0,1)*100)/100
|
||||
|
||||
})*/
|
||||
|
||||
return times
|
||||
|
||||
},
|
||||
getDocumentsByProjectId:(state) => (itemId: number) => state.documents.filter(item => item.project == itemId ),
|
||||
getFormSubmitsWithLabelProp: (state) => (state.formSubmits.map(submit => {return{...submit, label: submit.id}})),
|
||||
getResources: (state) => {
|
||||
return [
|
||||
...state.profiles.map(profile => {
|
||||
return {
|
||||
type: 'person',
|
||||
title: profile.firstName + ' ' + profile.lastName,
|
||||
id: profile.id
|
||||
}
|
||||
}),
|
||||
...state.vehicles.map(vehicle => {
|
||||
return {
|
||||
type: 'vehicle',
|
||||
title: vehicle.licensePlate,
|
||||
id: vehicle.licensePlate
|
||||
}
|
||||
})
|
||||
]
|
||||
},
|
||||
getEvents: (state) => {
|
||||
|
||||
return [
|
||||
...state.events.map(event => {
|
||||
let eventColor = state.ownTenant.calendarConfig.eventTypes.find(type => type.label === event.type).color
|
||||
|
||||
return {
|
||||
...event,
|
||||
borderColor: eventColor,
|
||||
textColor: eventColor,
|
||||
backgroundColor: "black"
|
||||
}
|
||||
}),
|
||||
]
|
||||
},
|
||||
getEventTypes: (state) => state.ownTenant.calendarConfig.eventTypes,
|
||||
getTimeTypes: (state) => state.ownTenant.timeConfig.timeTypes,
|
||||
getDocumentTags: (state) => state.ownTenant.tags.documents,
|
||||
async function fetchData () {
|
||||
fetchDocuments()
|
||||
await fetchOwnTenant()
|
||||
await fetchProfiles()
|
||||
await fetchEvents()
|
||||
await fetchTasks()
|
||||
await fetchProjects()
|
||||
await fetchTimes()
|
||||
await fetchJobs()
|
||||
await fetchCustomers()
|
||||
await fetchContracts()
|
||||
await fetchContacts()
|
||||
await fetchForms()
|
||||
await fetchFormSubmits()
|
||||
await fetchProducts()
|
||||
await fetchUnits()
|
||||
//await fetchDocuments()
|
||||
await fetchMovements()
|
||||
await fetchSpaces()
|
||||
await fetchVehicles()
|
||||
await fetchVendors()
|
||||
await fetchVendorInvoices()
|
||||
await fetchBankAccounts()
|
||||
await fetchBankStatements()
|
||||
await fetchHistoryItems()
|
||||
await fetchNumberRanges()
|
||||
loaded.value = true
|
||||
}
|
||||
|
||||
function clearStore () {
|
||||
console.log("Clear")
|
||||
loaded.value = false
|
||||
ownTenant.value = {}
|
||||
profiles.value= []
|
||||
events.value= []
|
||||
customers.value= []
|
||||
tasks.value= []
|
||||
projects.value= []
|
||||
documents.value= []
|
||||
spaces.value= []
|
||||
units.value= []
|
||||
times.value= []
|
||||
products.value= []
|
||||
movements.value= []
|
||||
forms.value= []
|
||||
contracts.value= []
|
||||
jobs.value= []
|
||||
formSubmits.value= []
|
||||
contacts.value= []
|
||||
vehicles.value= []
|
||||
vendors.value= []
|
||||
vendorInvoices.value= []
|
||||
bankAccounts.value= []
|
||||
bankStatements.value= []
|
||||
historyItems.value = []
|
||||
numberRanges.value = []
|
||||
}
|
||||
|
||||
async function fetchOwnTenant () {
|
||||
ownTenant.value = (await supabase.from("tenants").select().eq('id', user.value?.app_metadata.tenant)).data[0]
|
||||
}
|
||||
|
||||
async function fetchProfiles () {
|
||||
profiles.value = (await supabase.from("profiles").select()).data
|
||||
}
|
||||
async function fetchBankAccounts () {
|
||||
bankAccounts.value = (await supabase.from("bankAccounts").select()).data
|
||||
}
|
||||
async function fetchBankStatements () {
|
||||
bankStatements.value = (await supabase.from("bankStatements").select()).data
|
||||
}
|
||||
async function fetchEvents () {
|
||||
events.value = (await supabase.from("events").select()).data
|
||||
}
|
||||
async function fetchContracts () {
|
||||
contracts.value = (await supabase.from("contracts").select()).data
|
||||
}
|
||||
async function fetchContacts () {
|
||||
contacts.value = (await supabase.from("contacts").select()).data
|
||||
}
|
||||
async function fetchCustomers () {
|
||||
customers.value = (await supabase.from("customers").select().order("customerNumber", {ascending:true})).data
|
||||
}
|
||||
async function fetchTasks () {
|
||||
tasks.value = (await supabase.from("tasks").select()).data
|
||||
}
|
||||
async function fetchForms () {
|
||||
forms.value = (await supabase.from("forms").select()).data
|
||||
}
|
||||
async function fetchFormSubmits () {
|
||||
formSubmits.value = (await supabase.from("formSubmits").select()).data
|
||||
}
|
||||
async function fetchProducts () {
|
||||
products.value = (await supabase.from("products").select()).data
|
||||
}
|
||||
async function fetchUnits () {
|
||||
units.value = (await supabase.from("units").select()).data
|
||||
}
|
||||
async function fetchProjects () {
|
||||
projects.value = (await supabase.from("projects").select()).data
|
||||
}
|
||||
async function fetchSpaces () {
|
||||
spaces.value = (await supabase.from("spaces").select()).data
|
||||
}
|
||||
async function fetchMovements () {
|
||||
movements.value = (await supabase.from("movements").select()).data
|
||||
}
|
||||
async function fetchVehicles () {
|
||||
vehicles.value = (await supabase.from("vehicles").select()).data
|
||||
}
|
||||
async function fetchTimes () {
|
||||
times.value = (await supabase.from("times").select()).data
|
||||
}
|
||||
async function fetchJobs () {
|
||||
jobs.value = (await supabase.from("jobs").select()).data
|
||||
}
|
||||
async function fetchHistoryItems () {
|
||||
historyItems.value = (await supabase.from("historyItems").select()).data
|
||||
}
|
||||
async function fetchVendors () {
|
||||
vendors.value = (await supabase.from("vendors").select()).data
|
||||
}
|
||||
async function fetchVendorInvoices () {
|
||||
vendorInvoices.value = (await supabase.from("vendorInvoices").select()).data
|
||||
}
|
||||
async function fetchNumberRanges () {
|
||||
numberRanges.value = (await supabase.from("numberRanges").select()).data
|
||||
}
|
||||
|
||||
async function fetchDocuments () {
|
||||
documents.value = (await supabase.from("documents").select()).data
|
||||
|
||||
for(const [index,doc] of documents.value.entries()){
|
||||
// @ts-ignore
|
||||
documents.value[index].url = (await supabase.storage.from('files').createSignedUrl(doc.path, 60 * 60)).data.signedUrl
|
||||
}
|
||||
}
|
||||
|
||||
async function addHistoryItem(text: String, user: String, elementId: String, resourceType: String) {
|
||||
let data = {
|
||||
user: user,
|
||||
text: text
|
||||
}
|
||||
|
||||
if(resourceType === "customers") {
|
||||
data.customer = elementId
|
||||
}
|
||||
|
||||
const {data:insertData,error:insertError} = await supabase
|
||||
.from("historyItems")
|
||||
.insert([addHistoryItemData.value])
|
||||
.select()
|
||||
|
||||
if(insertError) {
|
||||
console.log(insertError)
|
||||
} else {
|
||||
toast.add({title: "Eintrag erfolgreich erstellt"})
|
||||
await fetchHistoryItems()
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//Getters
|
||||
|
||||
const getOpenTasksCount = computed(() => {
|
||||
return tasks.value.filter(task => task.categorie != "Erledigt").length
|
||||
})
|
||||
|
||||
const getMovementsBySpace = computed(() => (spaceId:string) => {
|
||||
return movements.value.filter(movement => movement.spaceId === spaceId)
|
||||
})
|
||||
|
||||
const getContactsByCustomerId = computed(() => (customerId:string) => {
|
||||
return contacts.value.filter(item => item.customer === customerId)
|
||||
})
|
||||
|
||||
const getDocumentsByProjectId = computed(() => (projectId:string) => {
|
||||
return documents.value.filter(item => item.project === projectId)
|
||||
})
|
||||
|
||||
const getTimesByProjectId = computed(() => (projectId:string) => {
|
||||
return times.value.filter(time => time.projectId === projectId)
|
||||
})
|
||||
|
||||
const getHistoryItemsByCustomer = computed(() => (customerId:string) => {
|
||||
return historyItems.value.filter(item => item.customer === customerId)
|
||||
})
|
||||
|
||||
const getEventTypes = computed(() => {
|
||||
return ownTenant.value.calendarConfig.eventTypes
|
||||
})
|
||||
|
||||
const getTimeTypes = computed(() => {
|
||||
return ownTenant.value.timeConfig.timeTypes
|
||||
})
|
||||
|
||||
const getDocumentTags = computed(() => {
|
||||
return ownTenant.value.tags.documents
|
||||
})
|
||||
|
||||
const getResources = computed(() => {
|
||||
return [
|
||||
...profiles.value.map(profile => {
|
||||
return {
|
||||
type: 'person',
|
||||
title: profile.fullName,
|
||||
id: profile.id
|
||||
}
|
||||
}),
|
||||
...vehicles.value.map(vehicle => {
|
||||
return {
|
||||
type: 'vehicle',
|
||||
title: vehicle.licensePlate,
|
||||
id: vehicle.licensePlate
|
||||
}
|
||||
})
|
||||
]
|
||||
})
|
||||
|
||||
const getEvents = computed(() => {
|
||||
return [
|
||||
...events.value.map(event => {
|
||||
let eventColor = ownTenant.value.calendarConfig.eventTypes.find(type => type.label === event.type).color
|
||||
|
||||
return {
|
||||
...event,
|
||||
borderColor: eventColor,
|
||||
textColor: eventColor,
|
||||
backgroundColor: "black"
|
||||
}
|
||||
}),
|
||||
]
|
||||
})
|
||||
|
||||
|
||||
//Get Item By Id
|
||||
const getProductById = computed(() => (itemId:string) => {
|
||||
return products.value.find(item => item.id === itemId)
|
||||
})
|
||||
|
||||
const getVendorById = computed(() => (itemId:string) => {
|
||||
return vendors.value.find(item => item.id === itemId)
|
||||
})
|
||||
|
||||
const getVendorInvoiceById = computed(() => (itemId:string) => {
|
||||
return vendorInvoices.value.find(item => item.id === itemId)
|
||||
})
|
||||
|
||||
const getContractById = computed(() => (itemId:string) => {
|
||||
return contracts.value.find(item => item.id === itemId)
|
||||
})
|
||||
|
||||
const getContactById = computed(() => (itemId:string) => {
|
||||
return contacts.value.find(item => item.id === itemId)
|
||||
})
|
||||
|
||||
const getVehiclesById = computed(() => (itemId:string) => {
|
||||
return vehicles.value.find(item => item.id === itemId)
|
||||
})
|
||||
|
||||
const getDocumentById = computed(() => (itemId:string) => {
|
||||
return documents.value.find(item => item.id === itemId)
|
||||
})
|
||||
|
||||
const getSpaceById = computed(() => (itemId:string) => {
|
||||
return spaces.value.find(item => item.id === itemId)
|
||||
})
|
||||
|
||||
const getCustomerById = computed(() => (itemId:number) => {
|
||||
return customers.value.find(item => item.id === itemId)
|
||||
})
|
||||
|
||||
const getJobById = computed(() => (itemId:string) => {
|
||||
return jobs.value.find(item => item.id === itemId)
|
||||
})
|
||||
|
||||
const getProfileById = computed(() => (itemId:string) => {
|
||||
return profiles.value.find(item => item.id === itemId)
|
||||
})
|
||||
|
||||
const getProjectById = computed(() => (itemId:string) => {
|
||||
let project = projects.value.find(project => project.id === itemId)
|
||||
|
||||
let projectHours = 0
|
||||
|
||||
let projectTimes = times.value.filter(time => time.projectId === itemId)
|
||||
projectTimes.forEach(time => projectHours += time.duration)
|
||||
|
||||
project.projectHours = projectHours
|
||||
|
||||
return project
|
||||
})
|
||||
|
||||
return {
|
||||
loaded,
|
||||
ownTenant,
|
||||
profiles,
|
||||
events,
|
||||
customers,
|
||||
tasks,
|
||||
projects,
|
||||
documents,
|
||||
spaces,
|
||||
units,
|
||||
times,
|
||||
products,
|
||||
movements,
|
||||
forms,
|
||||
contracts,
|
||||
jobs,
|
||||
formSubmits,
|
||||
contacts,
|
||||
vehicles,
|
||||
vendors,
|
||||
vendorInvoices,
|
||||
bankAccounts,
|
||||
bankStatements,
|
||||
historyItems,
|
||||
numberRanges,
|
||||
//Functions
|
||||
fetchData,
|
||||
clearStore,
|
||||
fetchOwnTenant,
|
||||
fetchProfiles,
|
||||
fetchBankAccounts,
|
||||
fetchBankStatements,
|
||||
fetchEvents,
|
||||
fetchContracts,
|
||||
fetchContacts,
|
||||
fetchCustomers,
|
||||
fetchTasks,
|
||||
fetchForms,
|
||||
fetchFormSubmits,
|
||||
fetchProducts,
|
||||
fetchUnits,
|
||||
fetchProjects,
|
||||
fetchSpaces,
|
||||
fetchMovements,
|
||||
fetchVehicles,
|
||||
fetchTimes,
|
||||
fetchJobs,
|
||||
fetchHistoryItems,
|
||||
fetchVendors,
|
||||
fetchVendorInvoices,
|
||||
fetchNumberRanges,
|
||||
fetchDocuments,
|
||||
addHistoryItem,
|
||||
//Getters
|
||||
getOpenTasksCount,
|
||||
getMovementsBySpace,
|
||||
getContactsByCustomerId,
|
||||
getDocumentsByProjectId,
|
||||
getTimesByProjectId,
|
||||
getHistoryItemsByCustomer,
|
||||
getEventTypes,
|
||||
getTimeTypes,
|
||||
getDocumentTags,
|
||||
getResources,
|
||||
getEvents,
|
||||
getProductById,
|
||||
getVendorById,
|
||||
getVendorInvoiceById,
|
||||
getContractById,
|
||||
getContactById,
|
||||
getVehiclesById,
|
||||
getDocumentById,
|
||||
getSpaceById,
|
||||
getCustomerById,
|
||||
getJobById,
|
||||
getProjectById,
|
||||
getProfileById
|
||||
}
|
||||
|
||||
|
||||
})
|
||||
Reference in New Issue
Block a user