Creation modal quality of life changes (#467)

Co-authored-by: Matt Kilgore <tankerkiller125@users.noreply.github.com>
Co-authored-by: Tonya <tonya@tokia.dev>
This commit is contained in:
Corknut
2025-01-26 07:43:45 -05:00
committed by GitHub
parent 96d88c5728
commit fca7d24268
8 changed files with 139 additions and 55 deletions

View File

@@ -2,6 +2,7 @@
<BaseModal v-model="modal">
<template #title>{{ $t("components.location.create_modal.title") }}</template>
<form @submit.prevent="create()">
<LocationSelector v-model="form.parent" />
<FormTextField
ref="locationNameRef"
v-model="form.name"
@@ -17,7 +18,6 @@
:label="$t('components.location.create_modal.location_description')"
:max-length="1000"
/>
<LocationSelector v-model="form.parent" />
<div class="modal-action">
<div class="flex justify-center">
<BaseButton class="rounded-r-none" type="submit" :loading="loading">{{ $t("global.create") }}</BaseButton>
@@ -59,10 +59,23 @@
parent: null as LocationSummary | null,
});
whenever(
watch(
() => modal.value,
() => {
focused.value = true;
open => {
if (open) {
useTimeoutFn(() => {
focused.value = true;
}, 50);
if (locationId.value) {
const found = locations.value.find(l => l.id === locationId.value);
if (found) {
form.parent = found;
}
}
} else {
focused.value = false;
}
}
);
@@ -77,8 +90,20 @@
const api = useUserApi();
const toast = useNotifier();
const locationsStore = useLocationStore();
const locations = computed(() => locationsStore.allLocations);
const route = useRoute();
const { shift } = useMagicKeys();
const locationId = computed(() => {
if (route.fullPath.includes("/location/")) {
return route.params.id;
}
return null;
});
async function create(close = true) {
if (loading.value) {
toast.error("Already creating a location");