🔧 ui: minor code cleanups

This commit is contained in:
Jörn-Michael Miehe 2025-12-28 16:39:24 +00:00
parent 4bab74b852
commit 956d373b28
6 changed files with 19 additions and 39 deletions

View file

@ -16,7 +16,7 @@
ref="username_input"
class="input"
type="text"
v-model="username"
v-model="creds[0]"
/>
</div>
</div>
@ -24,7 +24,7 @@
<div class="field">
<label class="label">Passwort</label>
<div class="control">
<input class="input" type="password" v-model="password" />
<input class="input" type="password" v-model="creds[1]" />
</div>
</div>
</section>
@ -33,13 +33,13 @@
<BulmaButton
class="is-success"
@click.left="submit"
:icon="['fas', 'fa-unlock']"
:icon="['fas', 'fa-unlock']"
text="Login"
/>
<BulmaButton
class="is-danger"
@click.left="cancel"
:icon="['fas', 'fa-circle-xmark']"
:icon="['fas', 'fa-circle-xmark']"
text="Abbrechen"
/>
</footer>
@ -60,11 +60,10 @@ const emit = defineEmits<{
(event: "cancel"): void;
}>();
const username = ref("");
const password = ref("");
const creds = ref<Credentials>(["", ""]);
function submit(): void {
emit("submit", [username.value, password.value]);
emit("submit", creds.value);
}
function cancel(): void {

View file

@ -39,7 +39,6 @@ export type HMultiModal = {
show_image(src: string, caption: string): void;
show_loading(): void;
hide(): void;
dismiss(): void;
};
const emit = defineEmits<{
@ -65,7 +64,6 @@ onMounted(() => {
state.value = { show: "loading" };
},
hide,
dismiss,
});
const on_keydown = (e: KeyboardEvent) => {

View file

@ -254,7 +254,7 @@ async function on_open(): Promise<void> {
API.request<DoorSaved[]>("admin/doors"),
]);
void store_update;
void store_update; // discard value
admin_config_model.value = new_admin_config_model;
doors.value = new_doors;
}

View file

@ -50,26 +50,20 @@ const preview_visible = computed(() => state.value.kind !== "idle");
function pop_door(point: Vector2D): VueLike<Door> | undefined {
const idx = model.value.findIndex((rect) => rect.position.contains(point));
if (idx === -1) {
return;
}
if (idx === -1) return;
return model.value.splice(idx, 1)[0];
}
function draw_start(event: MouseEvent, point: Vector2D): void {
if (preview_visible.value) {
return;
}
if (preview_visible.value) return;
preview.value = new Rectangle(point, point);
state.value = { kind: "drawing" };
}
function draw_finish(): void {
if (state.value.kind !== "drawing") {
return;
}
if (state.value.kind !== "drawing") return;
if (preview.value.area >= MIN_RECT_AREA) {
model.value.push(new Door(preview.value));
@ -79,15 +73,11 @@ function draw_finish(): void {
}
function drag_start(event: MouseEvent, point: Vector2D): void {
if (preview_visible.value) {
return;
}
if (preview_visible.value) return;
const drag_door = pop_door(point);
if (drag_door === undefined) {
return;
}
if (drag_door === undefined) return;
preview.value = drag_door.position;
@ -95,9 +85,7 @@ function drag_start(event: MouseEvent, point: Vector2D): void {
}
function drag_finish(): void {
if (state.value.kind !== "dragging") {
return;
}
if (state.value.kind !== "dragging") return;
model.value.push(new Door(preview.value, state.value.door.day));
@ -114,9 +102,7 @@ function on_mousemove(event: MouseEvent, point: Vector2D): void {
}
function remove_rect(event: MouseEvent, point: Vector2D): void {
if (preview_visible.value) {
return;
}
if (preview_visible.value) return;
pop_door(point);
}

View file

@ -41,9 +41,7 @@ function toggle_editing(): void {
}
function on_click(event: MouseEvent): void {
if (!(event.target instanceof HTMLDivElement)) {
return;
}
if (!(event.target instanceof HTMLDivElement)) return;
if (editing.value) {
unwrap_vuelike(model.value).day = day_str.value;
@ -58,9 +56,7 @@ function on_click(event: MouseEvent): void {
}
function on_keydown(event: KeyboardEvent): void {
if (!editing.value) {
return;
}
if (!editing.value) return;
if (event.key === "Enter") {
unwrap_vuelike(model.value).day = day_str.value;

View file

@ -76,7 +76,7 @@ export const advent22Store = defineStore({
API.request<DoorSaved[]>("user/doors"),
API.request<number | null>("user/next_door"),
]);
is_admin; // discard value
void is_admin; // discard value
document.title = site_config.title;
@ -116,7 +116,8 @@ export const advent22Store = defineStore({
},
logout() {
return this.login(["", ""]);
API.creds = { username: "", password: "" };
this.is_admin = false;
},
toggle_touch_device(): void {