correted Error with new Time Creation
made Times Editable created field for user filter
This commit is contained in:
@@ -23,19 +23,22 @@ const timeInfo = ref({
|
|||||||
type: null
|
type: null
|
||||||
})
|
})
|
||||||
|
|
||||||
|
const filterUser = ref(user.value.id || "")
|
||||||
|
|
||||||
|
|
||||||
const filteredRows = computed(() => {
|
const filteredRows = computed(() => {
|
||||||
|
|
||||||
if(user.value && dataStore.times) {
|
if(filterUser.value !== "" && dataStore.times) {
|
||||||
return dataStore.times.filter(time => time.user === user.value.id)
|
return dataStore.times.filter(time => time.user === filterUser.value)
|
||||||
} else {
|
} else {
|
||||||
return []
|
return dataStore.times
|
||||||
}
|
}
|
||||||
|
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
const createTimeInfo = ref({
|
const itemInfo = ref({
|
||||||
user: "",
|
user: "",
|
||||||
start: new Date(),
|
start: new Date(),
|
||||||
end: "",
|
end: "",
|
||||||
@@ -84,7 +87,8 @@ const columns = [
|
|||||||
]
|
]
|
||||||
|
|
||||||
const runningTimeInfo = ref({})
|
const runningTimeInfo = ref({})
|
||||||
const showAddTimeModal = ref(false)
|
const showConfigTimeModal = ref(false)
|
||||||
|
const configTimeMode = ref("create")
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -101,7 +105,7 @@ const startTime = async () => {
|
|||||||
if(error) {
|
if(error) {
|
||||||
console.log(error)
|
console.log(error)
|
||||||
} else if(data) {
|
} else if(data) {
|
||||||
timeInfo.value = data[0]
|
//timeInfo.value = data[0]
|
||||||
await dataStore.fetchTimes()
|
await dataStore.fetchTimes()
|
||||||
runningTimeInfo.value = dataStore.times.find(time => time.user === user.value.id && !time.end)
|
runningTimeInfo.value = dataStore.times.find(time => time.user === user.value.id && !time.end)
|
||||||
}
|
}
|
||||||
@@ -142,20 +146,35 @@ if(dataStore.times.find(time => time.user == user.value.id && !time.end)) {
|
|||||||
const createTime = async () => {
|
const createTime = async () => {
|
||||||
const {data,error} = await supabase
|
const {data,error} = await supabase
|
||||||
.from("times")
|
.from("times")
|
||||||
.insert([createTimeInfo.value])
|
.insert([itemInfo.value])
|
||||||
.select()
|
.select()
|
||||||
|
|
||||||
if(error) {
|
if(error) {
|
||||||
console.log(error)
|
console.log(error)
|
||||||
} else if(data) {
|
} else if(data) {
|
||||||
createTimeInfo.value = {}
|
itemInfo.value = {}
|
||||||
toast.add({title: "Zeit erfolgreich erstellt"})
|
toast.add({title: "Zeit erfolgreich erstellt"})
|
||||||
showAddTimeModal.value = false
|
showConfigTimeModal.value = false
|
||||||
await dataStore.fetchTimes()
|
await dataStore.fetchTimes()
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const updateTime = async () => {
|
||||||
|
const {error} = await supabase
|
||||||
|
.from("times")
|
||||||
|
.update(itemInfo.value)
|
||||||
|
.eq('id',itemInfo.value.id)
|
||||||
|
|
||||||
|
if(error) {
|
||||||
|
console.log(error)
|
||||||
|
}
|
||||||
|
|
||||||
|
toast.add({title: "Zeit erfolgreich gespeichert"})
|
||||||
|
showConfigTimeModal.value = false
|
||||||
|
await dataStore.fetchTimes()
|
||||||
|
}
|
||||||
|
|
||||||
const format = (date) => {
|
const format = (date) => {
|
||||||
let dateFormat = dayjs(date).format("DD.MM.YY HH:mm")
|
let dateFormat = dayjs(date).format("DD.MM.YY HH:mm")
|
||||||
|
|
||||||
@@ -164,28 +183,35 @@ const format = (date) => {
|
|||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<div class="flex items-center gap-1">
|
<InputGroup>
|
||||||
<UButton
|
<UButton
|
||||||
class="controlButton"
|
|
||||||
@click="startTime"
|
@click="startTime"
|
||||||
:disabled="runningTimeInfo.id"
|
:disabled="runningTimeInfo.id"
|
||||||
>
|
>
|
||||||
Start
|
Start
|
||||||
</UButton>
|
</UButton>
|
||||||
<UButton
|
<UButton
|
||||||
class="controlButton"
|
|
||||||
@click="stopStartedTime"
|
@click="stopStartedTime"
|
||||||
:disabled="!runningTimeInfo.id"
|
:disabled="!runningTimeInfo.id"
|
||||||
>
|
>
|
||||||
Stop
|
Stop
|
||||||
</UButton>
|
</UButton>
|
||||||
<UButton
|
<UButton
|
||||||
class="controlButton"
|
@click="configTimeMode = 'create'; itemInfo = {start: new Date(), end: new Date()}; showConfigTimeModal = true"
|
||||||
@click="showAddTimeModal = true"
|
|
||||||
>
|
>
|
||||||
Erstellen
|
Erstellen
|
||||||
</UButton>
|
</UButton>
|
||||||
</div>
|
<USelectMenu
|
||||||
|
:options="dataStore.profiles"
|
||||||
|
option-attribute="fullName"
|
||||||
|
value-attribute="id"
|
||||||
|
v-model="filterUser"
|
||||||
|
>
|
||||||
|
<template #label>
|
||||||
|
{{dataStore.getProfileById(filterUser) ? dataStore.getProfileById(filterUser).fullName : "Kein Benutzer ausgewählt"}}
|
||||||
|
</template>
|
||||||
|
</USelectMenu>
|
||||||
|
</InputGroup>
|
||||||
|
|
||||||
<div v-if="runningTimeInfo.id" class="mt-3">
|
<div v-if="runningTimeInfo.id" class="mt-3">
|
||||||
|
|
||||||
@@ -232,18 +258,17 @@ const format = (date) => {
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<UModal
|
<UModal
|
||||||
v-model="showAddTimeModal"
|
v-model="showConfigTimeModal"
|
||||||
>
|
>
|
||||||
<UCard>
|
<UCard>
|
||||||
<template #header>
|
<template #header>
|
||||||
Zeiteintrag erstellen
|
Zeiteintrag {{configTimeMode === 'create' ? "erstellen" : "bearbeiten"}}
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<UFormGroup
|
<UFormGroup
|
||||||
label="Start:"
|
label="Start:"
|
||||||
>
|
>
|
||||||
<VueDatePicker
|
<VueDatePicker
|
||||||
v-model="createTimeInfo.start"
|
v-model="itemInfo.start"
|
||||||
locale="de"
|
locale="de"
|
||||||
cancel-text="Abbrechen"
|
cancel-text="Abbrechen"
|
||||||
select-text="Auswählen"
|
select-text="Auswählen"
|
||||||
@@ -258,7 +283,7 @@ const format = (date) => {
|
|||||||
label="Ende:"
|
label="Ende:"
|
||||||
>
|
>
|
||||||
<VueDatePicker
|
<VueDatePicker
|
||||||
v-model="createTimeInfo.end"
|
v-model="itemInfo.end"
|
||||||
locale="de"
|
locale="de"
|
||||||
cancel-text="Abbrechen"
|
cancel-text="Abbrechen"
|
||||||
select-text="Auswählen"
|
select-text="Auswählen"
|
||||||
@@ -281,12 +306,12 @@ const format = (date) => {
|
|||||||
>
|
>
|
||||||
<USelectMenu
|
<USelectMenu
|
||||||
:options="dataStore.profiles"
|
:options="dataStore.profiles"
|
||||||
v-model="createTimeInfo.user"
|
v-model="itemInfo.user"
|
||||||
option-attribute="firstName"
|
option-attribute="fullName"
|
||||||
value-attribute="id"
|
value-attribute="id"
|
||||||
>
|
>
|
||||||
<template #label>
|
<template #label>
|
||||||
{{dataStore.profiles.find(profile => profile.id === createTimeInfo.user) ? dataStore.profiles.find(profile => profile.id === createTimeInfo.user).firstName : "Benutzer auswählen"}}
|
{{dataStore.profiles.find(profile => profile.id === itemInfo.user) ? dataStore.profiles.find(profile => profile.id === itemInfo.user).firstName : "Benutzer auswählen"}}
|
||||||
</template>
|
</template>
|
||||||
</USelectMenu>
|
</USelectMenu>
|
||||||
</UFormGroup>
|
</UFormGroup>
|
||||||
@@ -295,12 +320,15 @@ const format = (date) => {
|
|||||||
>
|
>
|
||||||
<USelectMenu
|
<USelectMenu
|
||||||
:options="dataStore.projects"
|
:options="dataStore.projects"
|
||||||
v-model="createTimeInfo.projectId"
|
v-model="itemInfo.projectId"
|
||||||
option-attribute="name"
|
option-attribute="name"
|
||||||
value-attribute="id"
|
value-attribute="id"
|
||||||
|
searchable
|
||||||
|
searchable-placeholder="Suche..."
|
||||||
|
:search-attributes="['name']"
|
||||||
>
|
>
|
||||||
<template #label>
|
<template #label>
|
||||||
{{dataStore.projects.find(project => project.id === createTimeInfo.projectId) ? dataStore.projects.find(project => project.id === createTimeInfo.projectId).name : "Projekt auswählen"}}
|
{{dataStore.projects.find(project => project.id === itemInfo.projectId) ? dataStore.projects.find(project => project.id === itemInfo.projectId).name : "Projekt auswählen"}}
|
||||||
</template>
|
</template>
|
||||||
</USelectMenu>
|
</USelectMenu>
|
||||||
</UFormGroup>
|
</UFormGroup>
|
||||||
@@ -308,13 +336,13 @@ const format = (date) => {
|
|||||||
label="Typ:"
|
label="Typ:"
|
||||||
>
|
>
|
||||||
<USelectMenu
|
<USelectMenu
|
||||||
v-model="runningTimeInfo.type"
|
v-model="itemInfo.type"
|
||||||
:options="timeTypes"
|
:options="timeTypes"
|
||||||
option-attribute="label"
|
option-attribute="label"
|
||||||
value-attribute="label"
|
value-attribute="label"
|
||||||
>
|
>
|
||||||
<template #label>
|
<template #label>
|
||||||
{{runningTimeInfo.type ? runningTimeInfo.type : "Kategorie auswählen"}}
|
{{itemInfo.type ? itemInfo.type : "Kategorie auswählen"}}
|
||||||
</template>
|
</template>
|
||||||
</USelectMenu>
|
</USelectMenu>
|
||||||
</UFormGroup>
|
</UFormGroup>
|
||||||
@@ -322,7 +350,7 @@ const format = (date) => {
|
|||||||
label="Notizen:"
|
label="Notizen:"
|
||||||
>
|
>
|
||||||
<UTextarea
|
<UTextarea
|
||||||
v-model="createTimeInfo.notes"
|
v-model="itemInfo.notes"
|
||||||
/>
|
/>
|
||||||
</UFormGroup>
|
</UFormGroup>
|
||||||
|
|
||||||
@@ -330,9 +358,16 @@ const format = (date) => {
|
|||||||
<template #footer>
|
<template #footer>
|
||||||
<UButton
|
<UButton
|
||||||
@click="createTime"
|
@click="createTime"
|
||||||
|
v-if="configTimeMode === 'create'"
|
||||||
>
|
>
|
||||||
Erstellen
|
Erstellen
|
||||||
</UButton>
|
</UButton>
|
||||||
|
<UButton
|
||||||
|
@click="updateTime"
|
||||||
|
v-else-if="configTimeMode === 'edit'"
|
||||||
|
>
|
||||||
|
Speichern
|
||||||
|
</UButton>
|
||||||
</template>
|
</template>
|
||||||
</UCard>
|
</UCard>
|
||||||
</UModal>
|
</UModal>
|
||||||
@@ -344,6 +379,9 @@ const format = (date) => {
|
|||||||
:columns="columns"
|
:columns="columns"
|
||||||
:rows="filteredRows"
|
:rows="filteredRows"
|
||||||
:empty-state="{ icon: 'i-heroicons-circle-stack-20-solid', label: 'Noch keine Einträge' }"
|
:empty-state="{ icon: 'i-heroicons-circle-stack-20-solid', label: 'Noch keine Einträge' }"
|
||||||
|
@select="(row) => {configTimeMode = 'edit';
|
||||||
|
itemInfo = row;
|
||||||
|
showConfigTimeModal = true}"
|
||||||
>
|
>
|
||||||
<template #user-data="{row}">
|
<template #user-data="{row}">
|
||||||
{{dataStore.profiles.find(profile => profile.id === row.user) ? dataStore.profiles.find(profile => profile.id === row.user).fullName : row.user }}
|
{{dataStore.profiles.find(profile => profile.id === row.user) ? dataStore.profiles.find(profile => profile.id === row.user).fullName : row.user }}
|
||||||
@@ -365,7 +403,5 @@ const format = (date) => {
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<style scoped>
|
<style scoped>
|
||||||
.controlButton {
|
|
||||||
margin-right: 1em;
|
|
||||||
}
|
|
||||||
</style>
|
</style>
|
||||||
Reference in New Issue
Block a user