Implement duplication and deletion of timetables

This commit is contained in:
2023-06-18 15:04:51 +02:00
parent f19d43396c
commit 956058eef9
2 changed files with 36 additions and 2 deletions

View File

@ -1,6 +1,14 @@
<script setup>
import TimetableCard from "@/components/settings/timetable-card.vue";
import { timetables, localTimetables, timetableId } from "@/store";
import { toRaw } from "vue";
function copyTimetable(timetable) {
const newTimetable = structuredClone(toRaw(timetable));
newTimetable.title = "Copy of " + timetable.title;
newTimetable.id = new Date().getTime();
localTimetables.value.push(newTimetable);
}
</script>
<template>
@ -13,6 +21,13 @@ import { timetables, localTimetables, timetableId } from "@/store";
:selected="timetableId == timetable.id"
:editable="true"
@click="timetableId = timetable.id"
@copy="copyTimetable(timetable)"
@delete="
localTimetables.splice(
localTimetables.findIndex((e) => e.id == timetable.id),
1
)
"
/>
</div>
<h2>{{ $t("settings.heading.remoteTimetables") }}</h2>
@ -24,6 +39,7 @@ import { timetables, localTimetables, timetableId } from "@/store";
:selected="timetableId == timetable.id"
:editable="false"
@click="timetableId = timetable.id"
@copy="copyTimetable(timetable)"
/>
</div>
</template>