advent22/ui/src/components/door_map/DoorChooser.vue

69 lines
1.6 KiB
Vue
Raw Normal View History

2023-01-24 00:14:50 +00:00
<template>
<section>
<div class="content">
<ul>
<li>Linksklick: Türchen auswählen</li>
</ul>
</div>
<figure class="image">
<img src="@/assets/adventskalender.jpg" />
<ThouCanvas>
<Rect
v-for="(rect, index) in rectangles"
2023-01-24 23:17:10 +00:00
:key="`rect-${index}`"
2023-01-24 00:14:50 +00:00
:rectangle="rect"
@click.left="choose_rect(index)"
/>
2023-01-24 11:35:45 +00:00
<template
2023-01-24 00:14:50 +00:00
v-for="(rect, index) in rectangles_chosen"
2023-01-24 23:17:10 +00:00
:key="`rect_chosen-${index}`"
2023-01-24 11:35:45 +00:00
>
<Rect :rectangle="rect" :focused="true" />
<RectText :rectangle="rect" :text="String(index)" />
</template>
2023-01-24 00:14:50 +00:00
</ThouCanvas>
</figure>
</section>
</template>
<script lang="ts">
import { Options, Vue } from "vue-class-component";
import { Rectangle } from "../rects/rectangles";
import ThouCanvas from "../rects/ThouCanvas.vue";
import Rect from "../rects/Rect.vue";
2023-01-24 11:35:45 +00:00
import RectText from "../rects/RectText.vue";
2023-01-24 00:14:50 +00:00
@Options({
components: {
ThouCanvas,
Rect,
2023-01-24 11:35:45 +00:00
RectText,
2023-01-24 00:14:50 +00:00
},
props: {
rectangles: Array,
},
emits: ["update:rectangles"],
})
export default class DoorChooser extends Vue {
private rectangles!: Rectangle[];
private rectangles_chosen: Rectangle[] = [];
public choose_rect(index: number) {
this.rectangles_chosen.push(this.rectangles.splice(index, 1)[0]);
}
public beforeUnmount() {
this.$emit(
"update:rectangles",
this.rectangles.concat(this.rectangles_chosen)
);
}
}
</script>
<style lang="scss" scoped>
section > figure {
user-select: none;
}
</style>