Rebuild Times in Projects

Added Icons
Rebuild Time Duration
This commit is contained in:
2023-12-07 12:14:19 +01:00
parent 36371f94e8
commit 5182959881
6 changed files with 118 additions and 17 deletions

View File

@@ -49,7 +49,8 @@ const navLinks = [
},
{
label: "Artikel",
to: "/products"
to: "/products",
icon: "i-heroicons-puzzle-piece"
},
{
label: "Dokumente",
@@ -58,7 +59,8 @@ const navLinks = [
},
{
label: "Inventar",
to: "/inventory"
to: "/inventory",
icon: "i-heroicons-square-3-stack-3d"
}
]

View File

@@ -55,6 +55,9 @@ const calendarOptions = reactive({
newEventData.value.end = info.endStr
openNewEventModal.value = true
},
eventClick: function (info){
console.log(info)
},
resourceGroupField: "type",
resources: resources,
nowIndicator:true

View File

@@ -6,12 +6,11 @@ definePageMeta({
const supabase = useSupabaseClient()
const route = useRoute()
const {getProjectById, getFormSubmitsWithLabelProp} = useDataStore()
const {forms, formSubmits} = storeToRefs(useDataStore())
const {getProjectById, getFormSubmitsWithLabelProp, getTimesByProjectId} = useDataStore()
const {forms, formSubmits, times} = storeToRefs(useDataStore())
const currentProject = getProjectById(Number(route.params.id))
const formSubmissionsComposed = getFormSubmitsWithLabelProp
const formModalOpen = ref(false)
const newFormSubmissionData = ref({
@@ -20,6 +19,28 @@ const newFormSubmissionData = ref({
submitted: false
})
const timeTableRows = [
{
key:"user",
label: "Benutzer"
},{
key:"start",
label: "Start"
},{
key:"end",
label:"Ende"
},{
key:"duration",
label: "Dauer"
},{
key: "type",
label: "Typ"
},{
key:"notes",
label: "Notizen"
},
]
const addNewFormSubmission = async () => {
//Add Form Submission
const {data:insertData,error:insertError} = await supabase
@@ -227,7 +248,11 @@ const phaseInfo = ref({
<client-only><editor-js v-model="newProjectDescription" /></client-only>
</div>
<div v-else-if="item.key === 'timetracking'" class="space-y-3">
<p>Hier wird aktuell noch gearbeitet</p>
Projekt Zeit: {{currentProject.projectHours.toString().replace(".",":")}} Stunden
<UTable
:rows="getTimesByProjectId(currentProject.id)"
:columns="timeTableRows"
/>
</div>
<div v-else-if="item.key === 'material'" class="space-y-3">
<p>Hier wird aktuell noch gearbeitet</p>

View File

@@ -1,7 +1,16 @@
<template>
<div id="main">
<div id="left">
<!-- TODO: Projekt Auflistung überarbeiten, Rechte Seite wird nicht genutzt -->
<UTable
:rows="projects"
:columns="projectColumns"
@select="selectProject"
/>
<!-- <div id="left">
<UButton @click="showCreateProject = true">+ Projekt</UButton>
<UModal v-model="showCreateProject">
<UCard>
@@ -46,11 +55,18 @@
</UCard>
</UModal>
<router-link v-for="item in projects" :to="`/projects/${item.id}`">
<UTable
:rows="projects"
@select="selectCustomer"
/>
&lt;!&ndash; <router-link v-for="item in projects" :to="`/projects/${item.id}`">
<UCard class="listItem">
<UBadge>{{item.id}}</UBadge> {{item.name}}
</UCard>
</router-link>
</router-link>&ndash;&gt;
</div>
@@ -67,15 +83,15 @@
Notizen: <br>
{{selectedItem.notes}}
<!-- Lieferantenrechnungen: <br>
&lt;!&ndash; Lieferantenrechnungen: <br>
<UTable :rows="dataStore.getVendorInvoicesByProjectId(selectedItem.id)"></UTable>
{{dataStore.getVendorInvoicesByProjectId(selectedItem.id)}}-->
{{dataStore.getVendorInvoicesByProjectId(selectedItem.id)}}&ndash;&gt;
</UCard>
</div>
</div>-->
</div>
@@ -88,10 +104,33 @@ definePageMeta({
})
const supabase = useSupabaseClient()
const router = useRouter()
const {projects,customers} = storeToRefs(useDataStore())
const {fetchProjects} = useDataStore()
const projectColumns = [
{
key: 'name',
label: "Name.",
sortable: true
},
{
key: "customer",
label: "Kundennummer",
sortable: true
},
{
key: "notes",
label: "Notizen",
sortable: true
}
]
const selectProject = (project) => {
router.push(`/projects/${project.id} `)
}
//const projects = (await supabase.from("projects").select()).data
//const customers = (await supabase.from("customers").select()).data
@@ -125,7 +164,7 @@ const createProject = async () => {
</script>
<style scoped>
#main {
/*#main {
display: flex;
flex-direction: row;
}
@@ -136,5 +175,5 @@ const createProject = async () => {
#right {
width: 60vw;
padding-left: 3vw;
}
}*/
</style>

View File

@@ -52,6 +52,11 @@ const stopStartedTime = async () => {
runningTimeInfo.value.end = new Date().toISOString()
const mapNumRange = (num, inMin, inMax, outMin, outMax) =>
((num - inMin) * (outMax - outMin)) / (inMax - inMin) + outMin;
runningTimeInfo.value.duration = Math.round(mapNumRange(Math.abs(new Date(runningTimeInfo.value.end) - new Date(runningTimeInfo.value.start))/1000/60,0,60,0,1)*100)/100
const {data,error} = await supabase
.from("times")
.update(runningTimeInfo.value)

View File

@@ -122,8 +122,35 @@ export const useDataStore = defineStore('data', {
getOpenTasksCount: (state) => state.tasks.filter(task => task.categorie != "Erledigt").length,
movementsBySpace: (state) => (spaceId:number) => state.movements.filter(move => move.spaceId === spaceId),
getProductById: (state) => (productId:number) => state.products.find(product => product.id === productId),
getProjectById: (state) => (projectId:number) => state.projects.find(project => project.id === projectId),
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),
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
},
getFormSubmitsWithLabelProp: (state) => (state.formSubmits.map(submit => {return{...submit, label: submit.id}})),
getResources: (state) => {
return [