Changed Tasks List

Created Time creation
Added VueDatepicker Package
This commit is contained in:
2023-12-21 16:04:52 +01:00
parent cc636ce040
commit e792ed39c9
6 changed files with 234 additions and 169 deletions

View File

@@ -57,25 +57,41 @@ const navLinks = [
] ]
}, },
{ {
label: "Aufgaben", label: "Aufträge",
to: "/tasks", icon: "i-heroicons-square-3-stack-3d",
icon: "i-heroicons-rectangle-stack" children: [
{
label: "Projekte",
to: "/projects",
icon: "i-heroicons-clipboard-document-check"
},
{
label: "Jobs",
to: "/jobs",
icon: "i-heroicons-square-3-stack-3d"
},
{
label: "Verträge",
to: "/contracts",
icon: "i-heroicons-clipboard-document"
},
]
}, },
{ {
label: "Plantafel", label: "Planung",
to: "/planningBoard", icon: "i-heroicons-square-3-stack-3d",
icon: "i-heroicons-calendar-days" children: [
}, {
label: "Aufgaben",
{ to: "/tasks",
label: "Projekte", icon: "i-heroicons-rectangle-stack"
to: "/projects", },
icon: "i-heroicons-clipboard-document-check" {
}, label: "Plantafel",
{ to: "/planningBoard",
label: "Jobs", icon: "i-heroicons-calendar-days"
to: "/jobs", },
icon: "i-heroicons-square-3-stack-3d" ]
}, },
{ {
label: "Dokumente", label: "Dokumente",
@@ -219,7 +235,7 @@ const items = [
/> />
<img <img
v-else v-else
src="/spaces_hell.svg" src="/spaces.svg"
alt="Logo Dunkel" alt="Logo Dunkel"
/> />
</div> </div>

View File

@@ -7,6 +7,9 @@ export default defineNuxtConfig({
extends: [ extends: [
'@nuxt/ui-pro' '@nuxt/ui-pro'
], ],
build: {
transpile: ['@vuepic/vue-datepicker']
},
modules: [ modules: [
'@pinia/nuxt', '@pinia/nuxt',
'@nuxt/ui', '@nuxt/ui',

View File

@@ -34,6 +34,7 @@
"@pinia/nuxt": "^0.5.1", "@pinia/nuxt": "^0.5.1",
"@popperjs/core": "^2.11.8", "@popperjs/core": "^2.11.8",
"@vicons/ionicons5": "^0.12.0", "@vicons/ionicons5": "^0.12.0",
"@vuepic/vue-datepicker": "^7.4.0",
"@zip.js/zip.js": "^2.7.32", "@zip.js/zip.js": "^2.7.32",
"axios": "^1.6.2", "axios": "^1.6.2",
"buffer": "^6.0.3", "buffer": "^6.0.3",
@@ -45,6 +46,6 @@
"pinia": "^2.1.7", "pinia": "^2.1.7",
"socket.io-client": "^4.7.2", "socket.io-client": "^4.7.2",
"uuidv4": "^6.2.13", "uuidv4": "^6.2.13",
"v-calendar": "^3.1.2", "v-calendar": "^3.1.2"
} }
} }

View File

@@ -23,7 +23,7 @@ const onSubmit = async () => {
alert(error.toString()) alert(error.toString())
} else { } else {
console.log("Login Successful") console.log("Login Successful")
await fetchData() fetchData()
router.push("/") router.push("/")

View File

@@ -86,148 +86,126 @@
/> />
</UFormGroup> </UFormGroup>
<UFormGroup
label="Benutzer ändern:"
>
<USelectMenu
:options="profiles"
@change="updateTask"
v-model="taskData.user"
option-attribute="firstName"
value-attribute="id"
>
<template #label>
{{profiles.find(profile => profile.id === taskData.user) ? profiles.find(profile => profile.id === taskData.user).firstName : 'Kein Benutzer ausgewählt'}}
</template>
</USelectMenu>
</UFormGroup>
</template> </template>
</UCard> </UCard>
</UModal> </UModal>
<div id="menuBar"> <div class="flex items-center gap-1">
<UButton <UButton @click="showCreateTask = true">+ Aufgabe</UButton>
class="mb-3 mr-3"
@click="showCreateTask = true" <UInput
> v-model="searchString"
+ Aufgabe placeholder="Suche..."
</UButton> />
<!-- <USelectMenu
:options="usersForList" <UCheckbox
v-model="usersSelected" label="Erledigte Anzeigen"
multiple v-model="showDoneTasks"
placeholder="Benutzer" />
class="w-40"
v-on:change="filterTasks"
>
<template #label>
<span v-if="usersSelected.length" class="truncate">{{ usersSelected.join(', ') }}</span>
<span v-else>Benutzer auswählen</span>
</template>
</USelectMenu>-->
</div> </div>
<div v-if="viewport.isLessThan('tablet')" class="scrollList"> <UTable
<a :rows="filteredRows"
v-for="task in tasks.filter(item => item.categorie != 'Erledigt')" :columns="taskColumns"
> @select="inspectTask"
<UCard class="listItem"> >
<template #header> <template #created_at-data="{row}">
<UBadge>{{task.categorie}}</UBadge> {{task.name}} {{ dayjs(row.created_at).format("DD.MM.YY HH:mm") }}
</template> </template>
{{task.description}} <template #user-data="{row}">
{{profiles.find(profile => profile.id === row.user ) ? profiles.find(profile => profile.id === row.user ).firstName : row.user}}
</UCard> </template>
</a> </UTable>
</div>
<div v-else>
<div id="taskCatList">
<div id="catNew">
<h3>Offene Aufgaben</h3>
<div class="taskScrollList" v-if="tasks.length > 0">
<a
v-for="taskNew in tasks.filter(task => task.categorie == 'Offen')"
@click="inspectTask(taskNew)"
>
<UCard class="listItem">
{{taskNew.name}}
<UBadge
v-for="user in taskNew.users"
class="mr-2"
>
{{user}}
</UBadge>
</UCard>
</a>
</div>
</div>
<div id="catInProgress">
<h3>Aufgaben in Bearbeitung</h3>
<div class="taskScrollList" v-if="tasks.length > 0">
<a
v-for="taskNew in tasks.filter(task => task.categorie == 'In Bearbeitung')"
@click="inspectTask(taskNew)"
>
<UCard class="listItem">
{{taskNew.name}}
<UBadge
v-for="user in taskNew.users"
class="mr-2"
>
{{user}}
</UBadge>
</UCard>
</a>
</div>
</div>
<div id="catUrgent">
<h3>Dringende Aufgaben</h3>
<div class="taskScrollList" v-if="tasks.length > 0">
<a
v-for="taskNew in tasks.filter(task => task.categorie == 'Dringend')"
@click="inspectTask(taskNew)"
>
<UCard class="listItem">
{{taskNew.name}}
<UBadge
v-for="user in taskNew.users"
class="mr-2"
>
{{user}}
</UBadge>
</UCard>
</a>
</div>
</div>
</div>
</div>
</UPage> </UPage>
</template> </template>
<script setup> <script setup>
import * as dayjs from "dayjs";
definePageMeta({ definePageMeta({
middleware: "auth", middleware: "auth",
}) })
const viewport = useViewport()
watch(viewport.breakpoint, (newBreakpoint, oldBreakpoint) => {
console.log('Breakpoint updated:', oldBreakpoint, '->', newBreakpoint)
})
const toast = useToast() const toast = useToast()
const supabase = useSupabaseClient() const supabase = useSupabaseClient()
const {tasks} = storeToRefs(useDataStore()) const {tasks, profiles} = storeToRefs(useDataStore())
const {fetchTasks} = useDataStore() const {fetchTasks} = useDataStore()
let refTasks = ref([]) const taskColumns = [
{
key:"created_at",
label: "Erstellt am:",
sortable: true
},
{
key:"name",
label: "Name:",
sortable: true
},
{
key:"user",
label: "Benutzer:",
sortable: true
},
{
key:"description",
label: "Beschreibung:",
sortable: true
},
{
key:"categorie",
label: "Kategorie:",
sortable: true
}
]
const showDoneTasks = ref(false)
const searchString = ref("")
const filteredRows = computed(() => {
let usersForList = [] let filteredTasks = tasks.value.filter(task => !showDoneTasks.value ? task.categorie !== "Erledigt" : task.categorie === "Erledigt")
//users.forEach(user => usersForList.push(user.username))
const usersSelected = ref([])
usersSelected.value = usersForList
if(!searchString.value) {
return filteredTasks
}
return filteredTasks.filter(item => {
return Object.values(item).some((value) => {
return String(value).toLowerCase().includes(searchString.value.toLowerCase())
})
})
})
const showCreateTask = ref(false) const showCreateTask = ref(false)
const taskCategories = ["Offen","In Bearbeitung", "Dringend","Erledigt"] const taskCategories = ["Offen","In Bearbeitung", "Dringend","Erledigt"]
const createTaskData = ref({ const createTaskData = ref({
name: "", name: "",
description: "", description: "",
categorie: "Offen" categorie: "Offen",
user: ""
/*users: ["86e67794-0ea8-41b0-985a-1072e84f56e9"]*/ /*users: ["86e67794-0ea8-41b0-985a-1072e84f56e9"]*/
}) })
@@ -269,31 +247,11 @@ const updateTask = async () => {
} }
const inspectTask = (task) => { const inspectTask = (task) => {
taskData.value = task taskData.value = task
showTaskModal.value = true showTaskModal.value = true
} }
const filterTasks = () => {
refTasks.value = tasks.filter(task => usersSelected.value.some(user => (task.users ? (task.users.includes(user)) : true )))
}
const finishTask = async () => {
console.log("Start")
const {error} = await supabase
.from("tasks")
.update({categorie: "Erledigt"})
.eq('id',taskData.value.id)
//console.log(data)
console.log(error)
showTaskModal.value = false
fetchTasks()
}
//filterTasks()
</script> </script>
<style scoped> <style scoped>

View File

@@ -1,5 +1,8 @@
<script setup> <script setup>
import * as dayjs from "dayjs"; import * as dayjs from "dayjs";
import VueDatePicker from '@vuepic/vue-datepicker'
import '@vuepic/vue-datepicker/dist/main.css'
definePageMeta({ definePageMeta({
middleware: "auth" middleware: "auth"
@@ -21,6 +24,15 @@ const timeInfo = ref({
type: null type: null
}) })
const createTimeInfo = ref({
user: "",
start: new Date(),
end: "",
notes: null,
projectId: null,
type: null
})
const columns = [ const columns = [
{ {
@@ -80,9 +92,6 @@ const startTime = async () => {
runningTimeInfo.value = times.value.find(time => time.user == user.value.id && !time.end) runningTimeInfo.value = times.value.find(time => time.user == user.value.id && !time.end)
} }
console.log(data)
console.log(error)
} }
const stopStartedTime = async () => { const stopStartedTime = async () => {
@@ -115,6 +124,30 @@ if(times.value.find(time => time.user == user.value.id && !time.end)) {
runningTimeInfo.value = times.value.find(time => time.user == user.value.id && !time.end) runningTimeInfo.value = times.value.find(time => time.user == user.value.id && !time.end)
} }
const createTime = async () => {
const {data,error} = await supabase
.from("times")
.insert([createTimeInfo.value])
.select()
if(error) {
console.log(error)
} else if(data) {
createTimeInfo.value = {}
toast.add({title: "Zeit erfolgreich erstellt"})
showAddTimeModal.value = false
await fetchTimes()
}
}
const format = (date) => {
let dateFormat = dayjs(date).format("DD.MM.YY HH:mm")
return `${dateFormat}`;
}
const selectStartedTime = () => { const selectStartedTime = () => {
runningTimeInfo.value = times.value.find(time => time.user == user.value.id && !time.end) runningTimeInfo.value = times.value.find(time => time.user == user.value.id && !time.end)
} }
@@ -166,44 +199,95 @@ const selectStartedTime = () => {
<UFormGroup <UFormGroup
label="Start:" label="Start:"
> >
<VueDatePicker
v-model="createTimeInfo.start"
locale="de"
cancel-text="Abbrechen"
select-text="Auswählen"
now-button-label="Jetzt"
text-input="MM.dd.yyyy HH:mm"
:dark="useColorMode().value !== 'light'"
:format="format"
:preview-format="format"
/>
</UFormGroup> </UFormGroup>
<UFormGroup <UFormGroup
label="Ende:" label="Ende:"
> >
<VueDatePicker
v-model="createTimeInfo.end"
locale="de"
cancel-text="Abbrechen"
select-text="Auswählen"
now-button-label="Jetzt"
text-input="MM.dd.yyyy HH:mm"
:dark="useColorMode().value !== 'light'"
:format="format"
:preview-format="format"
/>
</UFormGroup> </UFormGroup>
<UFormGroup <!-- <UFormGroup
label="Dauer:" label="Dauer:"
> >
<UInput <UInput
/> />
</UFormGroup> </UFormGroup>-->
<UFormGroup <UFormGroup
label="Benutzer:" label="Benutzer:"
> >
<USelectMenu/> <USelectMenu
:options="profiles"
v-model="createTimeInfo.user"
option-attribute="firstName"
value-attribute="id"
>
<template #label>
{{profiles.find(profile => profile.id === createTimeInfo.user) ? profiles.find(profile => profile.id === createTimeInfo.user).firstName : "Benutzer auswählen"}}
</template>
</USelectMenu>
</UFormGroup> </UFormGroup>
<UFormGroup <UFormGroup
label="Projekt:" label="Projekt:"
> >
<USelectMenu/> <USelectMenu
:options="projects"
v-model="createTimeInfo.projectId"
option-attribute="name"
value-attribute="id"
>
<template #label>
{{projects.find(project => project.id === createTimeInfo.projectId) ? projects.find(project => project.id === createTimeInfo.projectId).name : "Projekt auswählen"}}
</template>
</USelectMenu>
</UFormGroup> </UFormGroup>
<UFormGroup <UFormGroup
label="Typ:" label="Typ:"
> >
<USelectMenu/> <USelectMenu
v-model="runningTimeInfo.type"
:options="timeTypes"
option-attribute="label"
value-attribute="label"
>
<template #label>
{{runningTimeInfo.type ? runningTimeInfo.type : "Kategorie auswählen"}}
</template>
</USelectMenu>
</UFormGroup> </UFormGroup>
<UFormGroup <UFormGroup
label="Notizen:" label="Notizen:"
> >
<UTextarea/> <UTextarea
v-model="createTimeInfo.notes"
/>
</UFormGroup> </UFormGroup>
<template #footer> <template #footer>
<UButton> <UButton
@click="createTime"
>
Erstellen Erstellen
</UButton> </UButton>
</template> </template>
@@ -212,15 +296,12 @@ const selectStartedTime = () => {
<div> <div>
<div class="mt-3">
Aktuelle gestarteter Eintrag:
{{runningTimeInfo.id ? runningTimeInfo : "Keine Zeit gestartet"}}
<div v-if="runningTimeInfo.id" class="mt-3">
</div> Start: {{dayjs(runningTimeInfo.start).format("DD.MM.YY HH:mm")}}
<div v-if="runningTimeInfo.id">
<UFormGroup <UFormGroup
label="Notizen:" label="Notizen:"
> >
@@ -239,8 +320,7 @@ const selectStartedTime = () => {
v-model="runningTimeInfo.projectId" v-model="runningTimeInfo.projectId"
> >
<template #label> <template #label>
<span v-if="runningTimeInfo.projectId">{{ projects.find(project => project.id === runningTimeInfo.projectId) ? projects.find(project => project.id === runningTimeInfo.projectId).name : "" }}</span> {{ projects.find(project => project.id === runningTimeInfo.projectId) ? projects.find(project => project.id === runningTimeInfo.projectId).name : "Projekt auswählen" }}
<span v-else>Projekt auswählen</span>
</template> </template>
</USelectMenu> </USelectMenu>
</UFormGroup> </UFormGroup>
@@ -253,7 +333,11 @@ const selectStartedTime = () => {
:options="timeTypes" :options="timeTypes"
option-attribute="label" option-attribute="label"
value-attribute="label" value-attribute="label"
/> >
<template #label>
{{runningTimeInfo.type ? runningTimeInfo.type : "Kategorie auswählen"}}
</template>
</USelectMenu>
</UFormGroup> </UFormGroup>
</div> </div>
@@ -281,6 +365,9 @@ const selectStartedTime = () => {
<template #end-data="{row}"> <template #end-data="{row}">
{{dayjs(row.end).format("DD.MM.YY HH:mm")}} {{dayjs(row.end).format("DD.MM.YY HH:mm")}}
</template> </template>
<template #projectId-data="{row}">
{{projects.find(project => project.id === row.projectId) ? projects.find(project => project.id === row.projectId).name : ""}}
</template>
</UTable> </UTable>
</div> </div>