BulmaDrawer remove prop state

This commit is contained in:
Jörn-Michael Miehe 2023-09-14 12:51:30 +00:00
parent 610a7838c0
commit 0498a722b1
4 changed files with 30 additions and 50 deletions

View file

@ -1,12 +1,7 @@
<template> <template>
<MultiModal ref="multi_modal" /> <MultiModal ref="multi_modal" />
<BulmaDrawer <BulmaDrawer header="Kalender-Assistent" @open="on_open" refreshable>
header="Kalender-Assistent"
:state="drawer_state"
@open="on_open"
refreshable
>
<div class="card-content"> <div class="card-content">
<div class="content"> <div class="content">
<h4>Zuordnung Buchstaben</h4> <h4>Zuordnung Buchstaben</h4>
@ -53,7 +48,7 @@ import { Options, Vue } from "vue-class-component";
import MultiModal from "../MultiModal.vue"; import MultiModal from "../MultiModal.vue";
import BulmaButton from "../bulma/Button.vue"; import BulmaButton from "../bulma/Button.vue";
import BulmaDrawer, { DrawerState } from "../bulma/Drawer.vue"; import BulmaDrawer from "../bulma/Drawer.vue";
@Options({ @Options({
components: { components: {
@ -63,8 +58,6 @@ import BulmaDrawer, { DrawerState } from "../bulma/Drawer.vue";
}, },
}) })
export default class extends Vue { export default class extends Vue {
public drawer_state = DrawerState.Loading;
public day_parts: DayStrModel[] = []; public day_parts: DayStrModel[] = [];
public day_image_names: DayStrModel[] = []; public day_image_names: DayStrModel[] = [];
@ -72,9 +65,7 @@ export default class extends Vue {
multi_modal: MultiModal; multi_modal: MultiModal;
}; };
public on_open(): void { public on_open(ready: () => void, fail: () => void): void {
this.drawer_state = DrawerState.Loading;
Promise.all([ Promise.all([
this.$advent22.api_get<DayStrModel[]>("admin/day_parts"), this.$advent22.api_get<DayStrModel[]>("admin/day_parts"),
this.$advent22.api_get<DayStrModel[]>("admin/day_image_names"), this.$advent22.api_get<DayStrModel[]>("admin/day_image_names"),
@ -83,9 +74,9 @@ export default class extends Vue {
this.day_parts = day_parts; this.day_parts = day_parts;
this.day_image_names = day_image_names; this.day_image_names = day_image_names;
this.drawer_state = DrawerState.Ready; ready();
}) })
.catch(() => (this.drawer_state = DrawerState.Failed)); .catch(fail);
} }
public door_click(day: number) { public door_click(day: number) {

View file

@ -1,10 +1,5 @@
<template> <template>
<BulmaDrawer <BulmaDrawer header="Konfiguration" @open="on_open" refreshable>
header="Konfiguration"
:state="drawer_state"
@open="on_open"
refreshable
>
<div class="card-content"> <div class="card-content">
<div class="columns"> <div class="columns">
<div class="column is-one-third"> <div class="column is-one-third">
@ -128,7 +123,7 @@
import { ConfigModel, DayStrModel, DoorsSaved } from "@/lib/api"; import { ConfigModel, DayStrModel, DoorsSaved } from "@/lib/api";
import { Options, Vue } from "vue-class-component"; import { Options, Vue } from "vue-class-component";
import BulmaDrawer, { DrawerState } from "../bulma/Drawer.vue"; import BulmaDrawer from "../bulma/Drawer.vue";
import BulmaSecret from "../bulma/Secret.vue"; import BulmaSecret from "../bulma/Secret.vue";
interface Credentials { interface Credentials {
@ -143,8 +138,6 @@ interface Credentials {
}, },
}) })
export default class extends Vue { export default class extends Vue {
public drawer_state = DrawerState.Loading;
public config_model: ConfigModel = { public config_model: ConfigModel = {
puzzle: { puzzle: {
title: "Advent22", title: "Advent22",
@ -174,9 +167,7 @@ export default class extends Vue {
public dav_credentials: Credentials = { username: "", password: "" }; public dav_credentials: Credentials = { username: "", password: "" };
public ui_credentials: Credentials = { username: "", password: "" }; public ui_credentials: Credentials = { username: "", password: "" };
public on_open(): void { public on_open(ready: () => void, fail: () => void): void {
this.drawer_state = DrawerState.Loading;
Promise.all([ Promise.all([
this.$advent22.api_get<ConfigModel>("admin/config_model"), this.$advent22.api_get<ConfigModel>("admin/config_model"),
this.$advent22.api_get<DayStrModel[]>("admin/day_parts"), this.$advent22.api_get<DayStrModel[]>("admin/day_parts"),
@ -187,9 +178,9 @@ export default class extends Vue {
this.day_parts = day_parts; this.day_parts = day_parts;
this.num_user_doors = user_doors.length; this.num_user_doors = user_doors.length;
this.drawer_state = DrawerState.Ready; ready();
}) })
.catch(() => (this.drawer_state = DrawerState.Failed)); .catch(fail);
} }
public load_dav_credentials(): void { public load_dav_credentials(): void {

View file

@ -1,9 +1,5 @@
<template> <template>
<BulmaDrawer <BulmaDrawer header="Türchen bearbeiten" @open="on_open">
header="Türchen bearbeiten"
:state="drawer_state"
@open="on_open"
>
<div class="is-flex is-align-items-center is-justify-content-space-between"> <div class="is-flex is-align-items-center is-justify-content-space-between">
<BulmaButton <BulmaButton
:disabled="current_step === 0" :disabled="current_step === 0"
@ -59,7 +55,7 @@ import { Options, Vue } from "vue-class-component";
import Calendar from "../Calendar.vue"; import Calendar from "../Calendar.vue";
import BulmaBreadcrumbs, { Step } from "../bulma/Breadcrumbs.vue"; import BulmaBreadcrumbs, { Step } from "../bulma/Breadcrumbs.vue";
import BulmaButton from "../bulma/Button.vue"; import BulmaButton from "../bulma/Button.vue";
import BulmaDrawer, { DrawerState } from "../bulma/Drawer.vue"; import BulmaDrawer from "../bulma/Drawer.vue";
import DoorChooser from "../editor/DoorChooser.vue"; import DoorChooser from "../editor/DoorChooser.vue";
import DoorPlacer from "../editor/DoorPlacer.vue"; import DoorPlacer from "../editor/DoorPlacer.vue";
@ -74,8 +70,6 @@ import DoorPlacer from "../editor/DoorPlacer.vue";
}, },
}) })
export default class extends Vue { export default class extends Vue {
public drawer_state = DrawerState.Loading;
public readonly steps: Step[] = [ public readonly steps: Step[] = [
{ label: "Platzieren", icon: "fa-solid fa-crosshairs" }, { label: "Platzieren", icon: "fa-solid fa-crosshairs" },
{ label: "Ordnen", icon: "fa-solid fa-list-ol" }, { label: "Ordnen", icon: "fa-solid fa-list-ol" },
@ -87,8 +81,8 @@ export default class extends Vue {
public loading_doors = false; public loading_doors = false;
public saving_doors = false; public saving_doors = false;
private load_doors(): Promise<DoorsSaved> { private load_doors(): Promise<void> {
return new Promise<DoorsSaved>((resolve, reject) => { return new Promise<void>((resolve, reject) => {
this.$advent22 this.$advent22
.api_get<DoorsSaved>("admin/doors") .api_get<DoorsSaved>("admin/doors")
.then((data) => { .then((data) => {
@ -98,8 +92,7 @@ export default class extends Vue {
this.doors.push(Door.load(value)); this.doors.push(Door.load(value));
} }
this.drawer_state = DrawerState.Ready; resolve();
resolve(data);
}) })
.catch((error) => { .catch((error) => {
alert(this.$advent22.format_user_error(error)); alert(this.$advent22.format_user_error(error));
@ -126,10 +119,10 @@ export default class extends Vue {
}); });
} }
public on_open(): void { public on_open(ready: () => void, fail: () => void): void {
this.drawer_state = DrawerState.Loading; console.log(ready, fail);
this.load_doors().catch(() => (this.drawer_state = DrawerState.Failed)); this.load_doors().then(ready).catch(fail);
} }
public on_download() { public on_download() {

View file

@ -49,11 +49,7 @@ export enum DrawerState {
@Options({ @Options({
props: { props: {
header: { header: String,
type: String,
default: "",
},
state: DrawerState,
refreshable: { refreshable: {
type: Boolean, type: Boolean,
default: false, default: false,
@ -63,14 +59,23 @@ export enum DrawerState {
}) })
export default class extends Vue { export default class extends Vue {
public header!: string; public header!: string;
public state!: DrawerState;
public refreshable!: boolean; public refreshable!: boolean;
public is_open = false; public is_open = false;
public state = DrawerState.Loading;
public toggle() { public toggle() {
this.is_open = !this.is_open; this.is_open = !this.is_open;
if (this.is_open) this.$emit("open");
if (this.is_open) {
this.state = DrawerState.Loading;
this.$emit(
"open",
() => (this.state = DrawerState.Ready),
() => (this.state = DrawerState.Failed),
);
}
} }
public refresh() { public refresh() {