From 6f09010d0da3864cf2d30b2f7d72e5ebb6c76e2b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rn-Michael=20Miehe?= Date: Fri, 27 Oct 2023 15:37:21 +0000 Subject: [PATCH] Door opening logic into Calendar component --- ui/src/components/Calendar.vue | 25 +++++++++------------ ui/src/components/calendar/CalendarDoor.vue | 13 ----------- 2 files changed, 11 insertions(+), 27 deletions(-) diff --git a/ui/src/components/Calendar.vue b/ui/src/components/Calendar.vue index 441fcd9..566ac96 100644 --- a/ui/src/components/Calendar.vue +++ b/ui/src/components/Calendar.vue @@ -25,9 +25,7 @@ :key="`door-${index}`" :door="door" :visible="show_doors" - @doorClick="door_click" - @doorSuccess="door_success" - @doorFailure="door_failure" + @click="door_click(door.day)" @touch="door_hover(door.day)" @mouseover="door_hover(door.day)" @touchend="door_unhover" @@ -78,20 +76,19 @@ export default class extends Vue { this.figure_caption = this.idle_caption; } - public door_click() { + public door_click(day: number) { if (this.multi_modal === undefined) return; this.multi_modal.show_progress(); - } - public door_success(day: number, image_src: string) { - if (this.multi_modal === undefined) return; - this.multi_modal.show_image(image_src, this.$advent22.name_door(day)); - } - - public door_failure(msg: string) { - alert(msg); - if (this.multi_modal === undefined) return; - this.multi_modal.set_active(false); + this.$advent22 + .api_get_blob(`user/image_${day}`) + .then((image_src) => { + this.multi_modal!.show_image(image_src, this.$advent22.name_door(day)); + }) + .catch((error) => { + alert(error); + this.multi_modal!.set_active(false); + }); } } diff --git a/ui/src/components/calendar/CalendarDoor.vue b/ui/src/components/calendar/CalendarDoor.vue index 532fb56..f01d5a7 100644 --- a/ui/src/components/calendar/CalendarDoor.vue +++ b/ui/src/components/calendar/CalendarDoor.vue @@ -3,7 +3,6 @@ style="cursor: pointer" :variant="visible ? 'primary' : undefined" :rectangle="door.position" - @click.left="on_click" >
{{ door.day }}
@@ -26,21 +25,9 @@ import SVGRect from "./SVGRect.vue"; default: false, }, }, - emits: ["doorClick", "doorSuccess", "doorFailure"], }) export default class extends Vue { public door!: Door; public visible!: boolean; - - public on_click() { - this.$emit("doorClick"); - - this.$advent22 - .api_get_blob(`user/image_${this.door.day}`) - .then((data) => this.$emit("doorSuccess", this.door.day, data)) - .catch((error) => { - this.$emit("doorFailure", this.$advent22.format_user_error(error)); - }); - } }