mirror of
https://code.lenaisten.de/Lenaisten/advent22.git
synced 2024-11-23 08:13:01 +00:00
DoorMapEditor fully usable
This commit is contained in:
parent
3ab2a56172
commit
63f05c1fb9
2 changed files with 114 additions and 38 deletions
29
ui/src/components/BulmaDrawer.vue
Normal file
29
ui/src/components/BulmaDrawer.vue
Normal file
|
@ -0,0 +1,29 @@
|
||||||
|
<template>
|
||||||
|
<div class="panel">
|
||||||
|
<p class="panel-heading is-unselectable" @click="is_open = !is_open">
|
||||||
|
<span class="icon-text">
|
||||||
|
<span class="icon has-text-link">
|
||||||
|
<font-awesome-icon
|
||||||
|
:icon="'fa-solid fa-caret-' + (is_open ? 'down' : 'right')"
|
||||||
|
/>
|
||||||
|
</span>
|
||||||
|
<span><slot name="heading" /></span>
|
||||||
|
</span>
|
||||||
|
</p>
|
||||||
|
<slot v-if="is_open" name="default" />
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script lang="ts">
|
||||||
|
import { Vue } from "vue-class-component";
|
||||||
|
|
||||||
|
export default class extends Vue {
|
||||||
|
public is_open = false;
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style scoped>
|
||||||
|
div.panel > .panel-heading {
|
||||||
|
cursor: pointer;
|
||||||
|
}
|
||||||
|
</style>
|
|
@ -1,18 +1,51 @@
|
||||||
<template>
|
<template>
|
||||||
<div class="panel">
|
<BulmaDrawer>
|
||||||
<p class="panel-heading" @click="is_open = !is_open">
|
<template v-slot:heading>Türchen bearbeiten</template>
|
||||||
<span class="icon-text">
|
|
||||||
<span class="icon has-text-link">
|
|
||||||
<font-awesome-icon v-if="is_open" icon="fa-solid fa-caret-down" />
|
|
||||||
<font-awesome-icon v-else icon="fa-solid fa-caret-right" />
|
|
||||||
</span>
|
|
||||||
<span>Türchen bearbeiten</span>
|
|
||||||
</span>
|
|
||||||
</p>
|
|
||||||
|
|
||||||
<template v-if="is_open">
|
<template v-slot:default>
|
||||||
<div class="panel-tabs">
|
<div class="panel-tabs">
|
||||||
<BulmaBreadcrumbs :steps="steps" v-model="current_step" />
|
<BulmaBreadcrumbs :steps="steps" v-model="current_step" class="mb-0" />
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="panel-block is-flex is-justify-content-space-between">
|
||||||
|
<BulmaButton
|
||||||
|
:disabled="current_step === 0"
|
||||||
|
class="is-success"
|
||||||
|
icon="fa-solid fa-backward"
|
||||||
|
@click="current_step--"
|
||||||
|
>
|
||||||
|
Zurück
|
||||||
|
</BulmaButton>
|
||||||
|
<BulmaButton
|
||||||
|
class="is-danger"
|
||||||
|
icon="fa-solid fa-trash"
|
||||||
|
@click="on_discard"
|
||||||
|
>
|
||||||
|
Löschen
|
||||||
|
</BulmaButton>
|
||||||
|
<BulmaButton
|
||||||
|
class="is-danger"
|
||||||
|
icon="fa-solid fa-cloud-arrow-down"
|
||||||
|
@click="on_download"
|
||||||
|
>
|
||||||
|
Laden
|
||||||
|
</BulmaButton>
|
||||||
|
<BulmaButton
|
||||||
|
v-if="current_step !== 2"
|
||||||
|
class="is-success"
|
||||||
|
icon="fa-solid fa-forward"
|
||||||
|
@click="current_step++"
|
||||||
|
>
|
||||||
|
Weiter
|
||||||
|
</BulmaButton>
|
||||||
|
<BulmaButton
|
||||||
|
v-else
|
||||||
|
class="is-success"
|
||||||
|
icon="fa-solid fa-cloud-arrow-up"
|
||||||
|
@click="on_upload"
|
||||||
|
>
|
||||||
|
Speichern
|
||||||
|
</BulmaButton>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="panel-block">
|
<div class="panel-block">
|
||||||
|
@ -20,22 +53,15 @@
|
||||||
<DoorChooser v-if="current_step === 1" v-model:doors="doors" />
|
<DoorChooser v-if="current_step === 1" v-model:doors="doors" />
|
||||||
<Calendar v-if="current_step === 2" :doors="doors" />
|
<Calendar v-if="current_step === 2" :doors="doors" />
|
||||||
</div>
|
</div>
|
||||||
|
</template>
|
||||||
|
</BulmaDrawer>
|
||||||
|
</template>
|
||||||
|
|
||||||
<div v-if="current_step === 2" class="panel-block">
|
<style scoped>
|
||||||
<BulmaButton class="is-success is-fullwidth" @click.left="load_doors">
|
div.panel-block.is-flex button {
|
||||||
Laden
|
min-width: 150px;
|
||||||
</BulmaButton>
|
}
|
||||||
<BulmaButton
|
</style>
|
||||||
class="is-success is-fullwidth"
|
|
||||||
icon="fa-solid fa-crosshairs"
|
|
||||||
@click.left="save_doors"
|
|
||||||
>
|
|
||||||
Speichern
|
|
||||||
</BulmaButton>
|
|
||||||
</div>
|
|
||||||
</template>
|
|
||||||
</div>
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { Door, DoorsSaved } from "@/lib/door";
|
import { Door, DoorsSaved } from "@/lib/door";
|
||||||
|
@ -43,6 +69,7 @@ import { Options, Vue } from "vue-class-component";
|
||||||
|
|
||||||
import BulmaBreadcrumbs, { Step } from "./BulmaBreadcrumbs.vue";
|
import BulmaBreadcrumbs, { Step } from "./BulmaBreadcrumbs.vue";
|
||||||
import BulmaButton from "./BulmaButton.vue";
|
import BulmaButton from "./BulmaButton.vue";
|
||||||
|
import BulmaDrawer from "./BulmaDrawer.vue";
|
||||||
import Calendar from "./Calendar.vue";
|
import Calendar from "./Calendar.vue";
|
||||||
import DoorChooser from "./calendar/editor/DoorChooser.vue";
|
import DoorChooser from "./calendar/editor/DoorChooser.vue";
|
||||||
import DoorPlacer from "./calendar/editor/DoorPlacer.vue";
|
import DoorPlacer from "./calendar/editor/DoorPlacer.vue";
|
||||||
|
@ -51,6 +78,7 @@ import DoorPlacer from "./calendar/editor/DoorPlacer.vue";
|
||||||
components: {
|
components: {
|
||||||
BulmaBreadcrumbs,
|
BulmaBreadcrumbs,
|
||||||
BulmaButton,
|
BulmaButton,
|
||||||
|
BulmaDrawer,
|
||||||
DoorPlacer,
|
DoorPlacer,
|
||||||
DoorChooser,
|
DoorChooser,
|
||||||
Calendar,
|
Calendar,
|
||||||
|
@ -62,12 +90,11 @@ export default class extends Vue {
|
||||||
{ label: "Ordnen", icon: "fa-solid fa-list-ol" },
|
{ label: "Ordnen", icon: "fa-solid fa-list-ol" },
|
||||||
{ label: "Überprüfen", icon: "fa-solid fa-check" },
|
{ label: "Überprüfen", icon: "fa-solid fa-check" },
|
||||||
];
|
];
|
||||||
public is_open = false;
|
|
||||||
public current_step = 0;
|
public current_step = 0;
|
||||||
public doors: Door[] = [];
|
public doors: Door[] = [];
|
||||||
|
|
||||||
public load_doors() {
|
private load_doors(): Promise<void | DoorsSaved> {
|
||||||
this.$advent22.api_get<DoorsSaved>("/general/doors").then((data) => {
|
return this.$advent22.api_get<DoorsSaved>("/general/doors").then((data) => {
|
||||||
this.doors.length = 0;
|
this.doors.length = 0;
|
||||||
|
|
||||||
for (const value of data) {
|
for (const value of data) {
|
||||||
|
@ -76,7 +103,7 @@ export default class extends Vue {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public save_doors() {
|
private save_doors(): Promise<void> {
|
||||||
const data: DoorsSaved = [];
|
const data: DoorsSaved = [];
|
||||||
|
|
||||||
for (const door of this.doors) {
|
for (const door of this.doors) {
|
||||||
|
@ -87,14 +114,34 @@ export default class extends Vue {
|
||||||
data.push(door.save());
|
data.push(door.save());
|
||||||
}
|
}
|
||||||
|
|
||||||
this.$advent22.api_put("/general/doors", data);
|
return this.$advent22.api_put("/general/doors", data);
|
||||||
|
}
|
||||||
|
|
||||||
|
public mounted(): void {
|
||||||
|
this.load_doors().catch((reason) => alert(`Fehler: ${reason}`));
|
||||||
|
}
|
||||||
|
|
||||||
|
public on_download() {
|
||||||
|
if (confirm("Aktuelle Änderungen verwerfen und Status vom Server laden?")) {
|
||||||
|
this.load_doors()
|
||||||
|
.then(() => alert("Erfolgeich!"))
|
||||||
|
.catch((reason) => alert(`Fehler: ${reason}`));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public on_discard() {
|
||||||
|
if (confirm("Alle Türchen löschen? (nur lokal)")) {
|
||||||
|
// empty `doors` array
|
||||||
|
this.doors.length = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public on_upload() {
|
||||||
|
if (confirm("Aktuelle Änderungen an den Server schicken?")) {
|
||||||
|
this.save_doors()
|
||||||
|
.then(() => alert("Erfolgeich!"))
|
||||||
|
.catch((reason) => alert(`Fehler: ${reason}`));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style scoped>
|
|
||||||
div.panel > .panel-heading {
|
|
||||||
cursor: pointer;
|
|
||||||
user-select: none;
|
|
||||||
}
|
|
||||||
</style>
|
|
||||||
|
|
Loading…
Reference in a new issue