Remove old editing interface
Remove broken placeholder event editing interface that did not take account to access permissions or events having multiple solts.
This commit is contained in:
parent
8d0d2400d3
commit
e7dc00db54
5 changed files with 0 additions and 198 deletions
|
@ -1,113 +0,0 @@
|
||||||
<template>
|
|
||||||
<details>
|
|
||||||
<summary>Admin Edit</summary>
|
|
||||||
<h3>Create Event</h3>
|
|
||||||
<form method="post" action="/api/create-event">
|
|
||||||
<label>
|
|
||||||
Id:
|
|
||||||
<input type="text" name="id" required />
|
|
||||||
</label>
|
|
||||||
<label>
|
|
||||||
Name:
|
|
||||||
<input type="text" name="name" required />
|
|
||||||
</label>
|
|
||||||
<label>
|
|
||||||
Description:
|
|
||||||
<textarea name="description" />
|
|
||||||
</label>
|
|
||||||
<label>
|
|
||||||
Start:
|
|
||||||
<input type="datetime-local" name="start" required />
|
|
||||||
</label>
|
|
||||||
<label>
|
|
||||||
End:
|
|
||||||
<input type="datetime-local" name="end" required/>
|
|
||||||
</label>
|
|
||||||
<label>
|
|
||||||
Location
|
|
||||||
<select name="location">
|
|
||||||
<option
|
|
||||||
v-for="location in schedule.locations"
|
|
||||||
:key="location.id"
|
|
||||||
:value="location.id"
|
|
||||||
>{{ location.name }} </option>
|
|
||||||
</select>
|
|
||||||
</label>
|
|
||||||
<button type="submit">Create</button>
|
|
||||||
</form>
|
|
||||||
<h3>Edit Event</h3>
|
|
||||||
<form method="post" action="/api/modify-event">
|
|
||||||
<label>
|
|
||||||
Event
|
|
||||||
<select name="id" @change="onChange" ref="eventSelect">
|
|
||||||
<option
|
|
||||||
v-for="event in schedule.events"
|
|
||||||
:key="event.id"
|
|
||||||
:value="event.id"
|
|
||||||
>{{ event.name }}</option>
|
|
||||||
</select>
|
|
||||||
</label>
|
|
||||||
<label>
|
|
||||||
Name:
|
|
||||||
<input type="text" name="name" required />
|
|
||||||
</label>
|
|
||||||
<label>
|
|
||||||
Description:
|
|
||||||
<textarea name="description" />
|
|
||||||
</label>
|
|
||||||
<label>
|
|
||||||
Start:
|
|
||||||
<input type="datetime-local" name="start" required />
|
|
||||||
</label>
|
|
||||||
<label>
|
|
||||||
End:
|
|
||||||
<input type="datetime-local" name="end" required />
|
|
||||||
</label>
|
|
||||||
<label>
|
|
||||||
Location
|
|
||||||
<select name="location">
|
|
||||||
<option
|
|
||||||
v-for="location in schedule.locations"
|
|
||||||
:key="location.id"
|
|
||||||
:value="location.id"
|
|
||||||
>{{ location.name }} </option>
|
|
||||||
</select>
|
|
||||||
</label>
|
|
||||||
<button type="submit">Edit</button>
|
|
||||||
<button type="submit" formaction="/api/delete-event">Delete</button>
|
|
||||||
</form>
|
|
||||||
</details>
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<script lang="ts" setup>
|
|
||||||
const schedule = await useSchedule();
|
|
||||||
const eventSelect = useTemplateRef("eventSelect");
|
|
||||||
|
|
||||||
function onChange(event: any) {
|
|
||||||
const newEvent = schedule.value.events.find(e => e.id === event.target.value);
|
|
||||||
if (!newEvent)
|
|
||||||
return;
|
|
||||||
const form = event.target.form!;
|
|
||||||
for (const element of form.elements as any) {
|
|
||||||
if (element.name === "name") {
|
|
||||||
element.value = newEvent.name;
|
|
||||||
} else if (element.name === "description") {
|
|
||||||
element.value = newEvent.description;
|
|
||||||
} else if (element.name === "start") {
|
|
||||||
element.value = newEvent.slots[0].start.replace("Z", "");
|
|
||||||
} else if (element.name === "end") {
|
|
||||||
element.value = newEvent.slots[0].end.replace("Z", "");
|
|
||||||
} else if (element.name === "location") {
|
|
||||||
element.value = newEvent.slots[0].locations[0];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
onMounted(() => {
|
|
||||||
onChange({ target: eventSelect.value });
|
|
||||||
})
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<style>
|
|
||||||
|
|
||||||
</style>
|
|
|
@ -41,7 +41,6 @@
|
||||||
</select>
|
</select>
|
||||||
</label>
|
</label>
|
||||||
<Timetable :schedule :eventSlotFilter :shiftSlotFilter />
|
<Timetable :schedule :eventSlotFilter :shiftSlotFilter />
|
||||||
<EventsEdit />
|
|
||||||
<h2>Events</h2>
|
<h2>Events</h2>
|
||||||
<EventCard v-for="event in schedule.events.filter(e => e.slots.some(eventSlotFilter))" :event/>
|
<EventCard v-for="event in schedule.events.filter(e => e.slots.some(eventSlotFilter))" :event/>
|
||||||
<h2>Locations</h2>
|
<h2>Locations</h2>
|
||||||
|
|
|
@ -1,31 +0,0 @@
|
||||||
import { Schedule } from "~/shared/types/schedule";
|
|
||||||
import { broadcastUpdate } from "~/server/streams";
|
|
||||||
import { sendPush } from "~/server/web-push";
|
|
||||||
import { readSchedule, writeSchedule } from "~/server/database";
|
|
||||||
|
|
||||||
export default defineEventHandler(async (event) => {
|
|
||||||
const formData = await readFormData(event);
|
|
||||||
const schedule: Schedule = await readSchedule();
|
|
||||||
const id = formData.get("id") as string;
|
|
||||||
const name = formData.get("name") as string;
|
|
||||||
const description = formData.get("description") as string;
|
|
||||||
const start = formData.get("start") as string;
|
|
||||||
const end = formData.get("end") as string;
|
|
||||||
const location = formData.get("location") as string;
|
|
||||||
schedule.events.push({
|
|
||||||
name,
|
|
||||||
id,
|
|
||||||
description,
|
|
||||||
slots: [
|
|
||||||
{
|
|
||||||
id: `${id}-1`,
|
|
||||||
start: start + "Z",
|
|
||||||
end: end + "Z",
|
|
||||||
locations: [location],
|
|
||||||
}
|
|
||||||
]
|
|
||||||
});
|
|
||||||
await broadcastUpdate(schedule);
|
|
||||||
await writeSchedule(schedule);
|
|
||||||
await sendPush(event, "New event", `${name} will start at ${start}`);
|
|
||||||
});
|
|
|
@ -1,16 +0,0 @@
|
||||||
import { Schedule } from "~/shared/types/schedule";
|
|
||||||
import { broadcastUpdate } from "~/server/streams";
|
|
||||||
import { readSchedule, writeSchedule } from "~/server/database";
|
|
||||||
|
|
||||||
export default defineEventHandler(async (event) => {
|
|
||||||
const formData = await readFormData(event);
|
|
||||||
const schedule: Schedule = await readSchedule();
|
|
||||||
const id = formData.get("id") as string;
|
|
||||||
const index = schedule.events.findIndex(event => event.id === id);
|
|
||||||
if (index === -1) {
|
|
||||||
throw Error("No such event");
|
|
||||||
}
|
|
||||||
schedule.events.splice(index, 1);
|
|
||||||
await broadcastUpdate(schedule);
|
|
||||||
await writeSchedule(schedule);
|
|
||||||
});
|
|
|
@ -1,37 +0,0 @@
|
||||||
import { Schedule } from "~/shared/types/schedule";
|
|
||||||
import { broadcastUpdate } from "~/server/streams";
|
|
||||||
import { sendPush } from "~/server/web-push";
|
|
||||||
import { readSchedule, writeSchedule } from "~/server/database";
|
|
||||||
|
|
||||||
export default defineEventHandler(async (event) => {
|
|
||||||
const formData = await readFormData(event);
|
|
||||||
const schedule: Schedule = await readSchedule();
|
|
||||||
const id = formData.get("id") as string;
|
|
||||||
const name = formData.get("name") as string;
|
|
||||||
const description = formData.get("description") as string;
|
|
||||||
const start = formData.get("start") as string;
|
|
||||||
const end = formData.get("end") as string;
|
|
||||||
const location = formData.get("location") as string;
|
|
||||||
const index = schedule.events.findIndex(event => event.id === id);
|
|
||||||
if (index === -1) {
|
|
||||||
throw Error("No such event");
|
|
||||||
}
|
|
||||||
const timeChanged = schedule.events[index].slots[0].start !== start + "Z";
|
|
||||||
schedule.events[index] = {
|
|
||||||
name,
|
|
||||||
id,
|
|
||||||
description,
|
|
||||||
slots: [
|
|
||||||
{
|
|
||||||
id: `${id}-1`,
|
|
||||||
start: start + "Z",
|
|
||||||
end: end + "Z",
|
|
||||||
locations: [location],
|
|
||||||
}
|
|
||||||
]
|
|
||||||
};
|
|
||||||
await broadcastUpdate(schedule);
|
|
||||||
await writeSchedule(schedule);
|
|
||||||
if (timeChanged)
|
|
||||||
await sendPush(event, `New time for ${name}`, `${name} will now start at ${start}`);
|
|
||||||
});
|
|
Loading…
Add table
Add a link
Reference in a new issue