mirror of
https://code.lenaisten.de/Lenaisten/advent22.git
synced 2024-12-23 21:22:59 +00:00
Door opening logic into Calendar component
This commit is contained in:
parent
ce29116e88
commit
6f09010d0d
2 changed files with 11 additions and 27 deletions
|
@ -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);
|
||||
});
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
|
|
@ -3,7 +3,6 @@
|
|||
style="cursor: pointer"
|
||||
:variant="visible ? 'primary' : undefined"
|
||||
:rectangle="door.position"
|
||||
@click.left="on_click"
|
||||
>
|
||||
<div class="has-text-danger">{{ door.day }}</div>
|
||||
</SVGRect>
|
||||
|
@ -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));
|
||||
});
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
|
Loading…
Reference in a new issue