2023-01-24 00:14:50 +00:00
|
|
|
<template>
|
|
|
|
<section>
|
|
|
|
<div class="content">
|
2023-02-02 18:06:55 +00:00
|
|
|
<p class="title is-5">Steuerung</p>
|
2023-01-24 00:14:50 +00:00
|
|
|
<ul>
|
2023-02-02 23:16:44 +00:00
|
|
|
<li>Linksklick: Türchen auswählen</li>
|
|
|
|
<li>Tastatur [0]-[9], [Rücktaste]: Tag eingeben</li>
|
|
|
|
<li>Tastatur [Enter]: Tag speichern</li>
|
|
|
|
<li>Tastatur [Esc]: Eingabe Abbrechen</li>
|
|
|
|
<li>Tastatur [Entf]: Tag entfernen</li>
|
2023-01-24 00:14:50 +00:00
|
|
|
</ul>
|
|
|
|
</div>
|
|
|
|
<figure class="image">
|
|
|
|
<img src="@/assets/adventskalender.jpg" />
|
|
|
|
<ThouCanvas>
|
2023-02-02 18:06:55 +00:00
|
|
|
<template v-for="(door, index) in doors" :key="`door-${index}`">
|
|
|
|
<SVGRectText
|
|
|
|
v-if="door.day >= 0"
|
|
|
|
:text="String(door.day)"
|
|
|
|
:rectangle="door.position"
|
|
|
|
/>
|
|
|
|
<SVGRect
|
|
|
|
:rectangle="door.position"
|
2023-02-02 23:16:44 +00:00
|
|
|
:focused="index === focused"
|
|
|
|
@click.left="click_door(index)"
|
2023-02-02 18:06:55 +00:00
|
|
|
/>
|
2023-01-24 11:35:45 +00:00
|
|
|
</template>
|
2023-01-24 00:14:50 +00:00
|
|
|
</ThouCanvas>
|
|
|
|
</figure>
|
|
|
|
</section>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script lang="ts">
|
|
|
|
import { Options, Vue } from "vue-class-component";
|
2023-02-02 15:29:26 +00:00
|
|
|
import { Door } from "./calendar";
|
2023-01-24 00:14:50 +00:00
|
|
|
|
|
|
|
import ThouCanvas from "../rects/ThouCanvas.vue";
|
2023-01-25 11:39:58 +00:00
|
|
|
import SVGRect from "../rects/SVGRect.vue";
|
|
|
|
import SVGRectText from "../rects/SVGRectText.vue";
|
2023-01-24 00:14:50 +00:00
|
|
|
|
|
|
|
@Options({
|
|
|
|
components: {
|
|
|
|
ThouCanvas,
|
2023-01-25 11:39:58 +00:00
|
|
|
SVGRect,
|
|
|
|
SVGRectText,
|
2023-01-24 00:14:50 +00:00
|
|
|
},
|
|
|
|
props: {
|
2023-02-02 15:29:26 +00:00
|
|
|
doors: Array,
|
2023-01-24 00:14:50 +00:00
|
|
|
},
|
2023-02-02 15:29:26 +00:00
|
|
|
emits: ["update:doors"],
|
2023-01-24 00:14:50 +00:00
|
|
|
})
|
2023-01-24 23:19:25 +00:00
|
|
|
export default class extends Vue {
|
2023-02-02 15:29:26 +00:00
|
|
|
private doors!: Door[];
|
2023-02-02 23:16:44 +00:00
|
|
|
private focused = -1;
|
|
|
|
|
|
|
|
private click_door(index: number) {
|
|
|
|
if (this.focused >= 0) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
this.focused = index;
|
|
|
|
|
|
|
|
const listener = (() => {
|
|
|
|
let old_day = this.doors[index].day;
|
|
|
|
let num_input = "";
|
|
|
|
|
|
|
|
return (event: KeyboardEvent) => {
|
|
|
|
if (event.key >= "0" && event.key <= "9") {
|
|
|
|
// number input
|
|
|
|
|
|
|
|
num_input += event.key;
|
|
|
|
this.doors[this.focused].day = Number(num_input);
|
|
|
|
} else if (event.key === "Backspace") {
|
|
|
|
// remove char
|
|
|
|
|
|
|
|
num_input = num_input.slice(0, -1);
|
|
|
|
this.doors[this.focused].day = Number(num_input);
|
|
|
|
} else if (event.key === "Enter") {
|
|
|
|
// accept
|
|
|
|
|
|
|
|
this.focused = -1;
|
|
|
|
window.removeEventListener("keydown", listener);
|
|
|
|
} else if (event.key === "Escape") {
|
|
|
|
// abort
|
|
|
|
|
|
|
|
this.doors[this.focused].day = old_day;
|
|
|
|
this.focused = -1;
|
|
|
|
window.removeEventListener("keydown", listener);
|
|
|
|
} else if (event.key === "Delete") {
|
|
|
|
// delete
|
|
|
|
|
|
|
|
this.doors[this.focused].day = -1;
|
|
|
|
this.focused = -1;
|
|
|
|
window.removeEventListener("keydown", listener);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
})();
|
|
|
|
|
|
|
|
window.addEventListener("keydown", listener);
|
|
|
|
}
|
2023-01-24 00:14:50 +00:00
|
|
|
|
|
|
|
public beforeUnmount() {
|
2023-02-02 15:29:26 +00:00
|
|
|
this.$emit("update:doors", this.doors);
|
2023-01-24 00:14:50 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<style lang="scss" scoped>
|
|
|
|
section > figure {
|
|
|
|
user-select: none;
|
2023-02-02 23:16:44 +00:00
|
|
|
|
|
|
|
svg > rect {
|
|
|
|
cursor: pointer;
|
|
|
|
}
|
2023-01-24 00:14:50 +00:00
|
|
|
}
|
|
|
|
</style>
|