feat/update-gottesdienste #5
@ -5,9 +5,9 @@ val logback_version: String by project
|
|||||||
val exposed_version: String by project
|
val exposed_version: String by project
|
||||||
val h2_version: String by project
|
val h2_version: String by project
|
||||||
plugins {
|
plugins {
|
||||||
kotlin("jvm") version "1.9.0"
|
kotlin("jvm") version "2.1.20"
|
||||||
id("io.ktor.plugin") version "2.3.3"
|
id("io.ktor.plugin") version "3.1.1"
|
||||||
kotlin("plugin.serialization") version "1.9.0"
|
kotlin("plugin.serialization") version "2.1.20"
|
||||||
id("com.palantir.docker") version "0.35.0"
|
id("com.palantir.docker") version "0.35.0"
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -45,7 +45,7 @@ dependencies {
|
|||||||
implementation("io.github.cdimascio:dotenv-kotlin:6.4.1")
|
implementation("io.github.cdimascio:dotenv-kotlin:6.4.1")
|
||||||
implementation("at.favre.lib:bcrypt:0.10.2")
|
implementation("at.favre.lib:bcrypt:0.10.2")
|
||||||
|
|
||||||
testImplementation("io.ktor:ktor-server-tests-jvm")
|
testImplementation("io.ktor:ktor-server-test-host")
|
||||||
testImplementation("org.jetbrains.kotlin:kotlin-test-junit:$kotlin_version")
|
testImplementation("org.jetbrains.kotlin:kotlin-test-junit:$kotlin_version")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -1,5 +1,7 @@
|
|||||||
distributionBase=GRADLE_USER_HOME
|
distributionBase=GRADLE_USER_HOME
|
||||||
distributionPath=wrapper/dists
|
distributionPath=wrapper/dists
|
||||||
distributionUrl=https\://services.gradle.org/distributions/gradle-7.5.1-bin.zip
|
distributionUrl=https\://services.gradle.org/distributions/gradle-8.10-bin.zip
|
||||||
|
networkTimeout=10000
|
||||||
|
validateDistributionUrl=true
|
||||||
zipStoreBase=GRADLE_USER_HOME
|
zipStoreBase=GRADLE_USER_HOME
|
||||||
zipStorePath=wrapper/dists
|
zipStorePath=wrapper/dists
|
||||||
|
|||||||
@ -7,7 +7,7 @@ const props = withDefaults(defineProps<{
|
|||||||
label?: string,
|
label?: string,
|
||||||
disabled?: boolean,
|
disabled?: boolean,
|
||||||
type?: string,
|
type?: string,
|
||||||
dateFormat?: "string" | "number",
|
dateFormat?: "string" | "number" | "date",
|
||||||
focus?: boolean
|
focus?: boolean
|
||||||
}>(), {
|
}>(), {
|
||||||
dateFormat: "string"
|
dateFormat: "string"
|
||||||
@ -45,7 +45,9 @@ function leading(val) {
|
|||||||
|
|
||||||
function getValue(){
|
function getValue(){
|
||||||
if(props.type == "date" && props.dateFormat == "number") {
|
if(props.type == "date" && props.dateFormat == "number") {
|
||||||
console.log(props.value)
|
const date = new Date(props.value)
|
||||||
|
return leading(date.getFullYear()) + "-" + zeros(date.getMonth() + 1) + "-" + zeros(date.getDate())
|
||||||
|
} if(props.type == "date" && props.dateFormat == "date") {
|
||||||
const date = new Date(props.value)
|
const date = new Date(props.value)
|
||||||
return leading(date.getFullYear()) + "-" + zeros(date.getMonth() + 1) + "-" + zeros(date.getDate())
|
return leading(date.getFullYear()) + "-" + zeros(date.getMonth() + 1) + "-" + zeros(date.getDate())
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@ -15,7 +15,7 @@ const props = defineProps<{
|
|||||||
edit: boolean,
|
edit: boolean,
|
||||||
smallMode: boolean
|
smallMode: boolean
|
||||||
}>()
|
}>()
|
||||||
const emit = defineEmits(["toggleMark", "added", "delete", "endEdit", "resetPassword", "deleteMinistrant", "createMinistrant", "editMinistrant"])
|
const emit = defineEmits(["toggleMark", "added", "delete", "edit", "endEdit", "resetPassword", "deleteMinistrant", "createMinistrant", "editMinistrant"])
|
||||||
const openEditUser = ref<number>(-1)
|
const openEditUser = ref<number>(-1)
|
||||||
const miniCopy = reactive<{ data?: SimplifiedMinistrant }>({})
|
const miniCopy = reactive<{ data?: SimplifiedMinistrant }>({})
|
||||||
const data = reactive({
|
const data = reactive({
|
||||||
@ -131,7 +131,12 @@ function getAmount(mid: number, value: number): number {
|
|||||||
|
|
||||||
<tr v-if="props.edit" class="no-print">
|
<tr v-if="props.edit" class="no-print">
|
||||||
<th></th>
|
<th></th>
|
||||||
<th v-for="godi in props.gottesdienste"><i @click="$emit('delete', godi.id)">delete</i></th>
|
<th v-for="godi in props.gottesdienste"><i @click="$emit('delete', godi.id)" style="cursor: pointer">delete</i></th>
|
||||||
|
</tr>
|
||||||
|
|
||||||
|
<tr v-if="props.edit" class="no-print">
|
||||||
|
<th></th>
|
||||||
|
<th v-for="godi in props.gottesdienste"><i @click="$emit('edit', godi.id)" style="cursor: pointer">edit</i></th>
|
||||||
</tr>
|
</tr>
|
||||||
|
|
||||||
<tr>
|
<tr>
|
||||||
|
|||||||
@ -7,8 +7,8 @@ import {onMounted, ref, toRaw} from "vue";
|
|||||||
import type {Gottesdienst, GottesdienstGroup} from "@/models/models";
|
import type {Gottesdienst, GottesdienstGroup} from "@/models/models";
|
||||||
import {onKeyPress} from "@/composables/enter";
|
import {onKeyPress} from "@/composables/enter";
|
||||||
interface CreateGottesdienstDialogProps extends DialogControls {
|
interface CreateGottesdienstDialogProps extends DialogControls {
|
||||||
onCreate: (Gottesdienst) => (Promise<any> | undefined),
|
onCreate: (arg0: Gottesdienst) => (Promise<any> | undefined),
|
||||||
godi?: Gottesdienst,
|
gottesdienst?: Gottesdienst,
|
||||||
planId: number
|
planId: number
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -16,18 +16,33 @@ onKeyPress("Enter", create)
|
|||||||
|
|
||||||
const props = defineProps<CreateGottesdienstDialogProps>()
|
const props = defineProps<CreateGottesdienstDialogProps>()
|
||||||
|
|
||||||
const date = ref("")
|
const godi = ref(formatGottesdienst(props.gottesdienst))
|
||||||
const time = ref("")
|
|
||||||
|
|
||||||
const godi = ref(props.godi ?? {
|
const date = ref(props.gottesdienst ? formatDateString(props.gottesdienst.date) : "")
|
||||||
|
const time = ref(props.gottesdienst ? formatTimeString(props.gottesdienst.date) : "")
|
||||||
|
|
||||||
|
let submitted = false
|
||||||
|
|
||||||
|
function formatGottesdienst(gottesdienst: Gottesdienst) {
|
||||||
|
return gottesdienst ? {
|
||||||
|
...gottesdienst,
|
||||||
|
attendance: formatTimeString(gottesdienst.attendance)
|
||||||
|
} : {
|
||||||
planId: props.planId,
|
planId: props.planId,
|
||||||
date: "",
|
date: "",
|
||||||
attendance: "",
|
attendance: "",
|
||||||
name: "",
|
name: "",
|
||||||
id: -1
|
id: -1
|
||||||
})
|
}
|
||||||
|
}
|
||||||
|
|
||||||
let submitted = false
|
function formatDateString(date: Date) {
|
||||||
|
return (new Date(date)).toISOString().split('T')[0];
|
||||||
|
}
|
||||||
|
|
||||||
|
function formatTimeString(date: Date) {
|
||||||
|
return (new Date(date)).toTimeString().slice(0, 5);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
async function create(){
|
async function create(){
|
||||||
@ -44,6 +59,7 @@ async function create(){
|
|||||||
submitted = false
|
submitted = false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
@ -51,8 +67,8 @@ async function create(){
|
|||||||
<Dialog class="dialog">
|
<Dialog class="dialog">
|
||||||
<h3>Gottesdienst {{ godi.id == -1 ? "erstellen" : "bearbeiten"}}</h3>
|
<h3>Gottesdienst {{ godi.id == -1 ? "erstellen" : "bearbeiten"}}</h3>
|
||||||
<Input class="input" v-model:value="godi.name" label="Name" focus/>
|
<Input class="input" v-model:value="godi.name" label="Name" focus/>
|
||||||
<Input class="input" v-model:value="date" type="date" label="Datum"/>
|
<Input class="input" v-model:value="date" date-format="string" type="date" label="Datum"/>
|
||||||
<Input class="input" v-model:value="time" type="time" label="Um"/>
|
<Input class="input" v-model:value="time" date-format="string" type="time" label="Um"/>
|
||||||
<Input class="input" v-model:value="godi.attendance" type="time" label="Anwesenheit"/>
|
<Input class="input" v-model:value="godi.attendance" type="time" label="Anwesenheit"/>
|
||||||
<div class="buttons" style="display: flex; justify-content: end; margin-top: 20px;">
|
<div class="buttons" style="display: flex; justify-content: end; margin-top: 20px;">
|
||||||
<button @click="onDismiss">Abbrechen</button>
|
<button @click="onDismiss">Abbrechen</button>
|
||||||
|
|||||||
@ -87,6 +87,22 @@ export namespace API {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export async function addGottesdienstNew(gottesdienst: Gottesdienst) {
|
||||||
|
return api("/gottesdienste", "PUT", {
|
||||||
|
...gottesdienst,
|
||||||
|
date: gottesdienst.date.getTime(),
|
||||||
|
attendance: gottesdienst.attendance.getTime()
|
||||||
|
}).then(data => data.json())
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function updateGottesdienst(gottesdienst: Gottesdienst) {
|
||||||
|
return api("/gottesdienste", "PATCH", {
|
||||||
|
...gottesdienst,
|
||||||
|
date: gottesdienst.date.getTime(),
|
||||||
|
attendance: gottesdienst.attendance.getTime()
|
||||||
|
}).then(res => res.status == 200)
|
||||||
|
}
|
||||||
|
|
||||||
export async function getMinistranten() {
|
export async function getMinistranten() {
|
||||||
return api("/ministranten", "GET").then(res => res.json())
|
return api("/ministranten", "GET").then(res => res.json())
|
||||||
}
|
}
|
||||||
|
|||||||
@ -88,21 +88,27 @@ const sortedGottesdienste = computed(() => {
|
|||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
async function createGottesdienst(){
|
async function createGottesdienst(gottesdienstId?: number){
|
||||||
|
let gottesdienstRef = plan.gottesdienste.find(gottesdienst => gottesdienst.id == gottesdienstId)
|
||||||
|
let gottesdienst = gottesdienstRef ? Object.assign({}, toRaw(gottesdienstRef)) : null;
|
||||||
Dialogs.createDialog(CreateGottesdienstDialog, {
|
Dialogs.createDialog(CreateGottesdienstDialog, {
|
||||||
onPositive() {},
|
onPositive() {},
|
||||||
onNegative() {},
|
onNegative() {},
|
||||||
onDismiss() {}
|
onDismiss() {}
|
||||||
}, {
|
}, {
|
||||||
planId: parseInt(planId.value as string),
|
gottesdienst,
|
||||||
|
planId: parseInt(planId.value as unknown),
|
||||||
async onCreate(godi: Gottesdienst) {
|
async onCreate(godi: Gottesdienst) {
|
||||||
const newGodi = await API.addGottesdienst(
|
if(godi.id == -1) {
|
||||||
godi.name,
|
const newGodi = await API.addGottesdienstNew(godi)
|
||||||
godi.date,
|
godi.id = newGodi.id
|
||||||
godi.attendance,
|
plan.gottesdienste.push(godi)
|
||||||
godi.planId
|
} else {
|
||||||
)
|
await API.updateGottesdienst(godi)
|
||||||
plan.gottesdienste.push(newGodi)
|
const index = plan.gottesdienste.findIndex(g => g.id == godi.id)
|
||||||
|
plan.gottesdienste.splice(index, 1)
|
||||||
|
plan.gottesdienste.push(godi)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@ -293,6 +299,7 @@ async function createMinistrant(ministrantId?: number) {
|
|||||||
:small-mode="editPlanAdmin"
|
:small-mode="editPlanAdmin"
|
||||||
@added="addGodi"
|
@added="addGodi"
|
||||||
@delete="deleteGottedienst"
|
@delete="deleteGottedienst"
|
||||||
|
@edit="createGottesdienst"
|
||||||
@toggle-mark="toggleMark"
|
@toggle-mark="toggleMark"
|
||||||
@end-edit="editPlanAdmin = false"
|
@end-edit="editPlanAdmin = false"
|
||||||
@reset-password="resetPassword"
|
@reset-password="resetPassword"
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user