mirror of
https://github.com/hay-kot/homebox.git
synced 2024-12-18 13:06:32 +00:00
feat: redirect to item on create (#121)
* redirect on create * change to text area
This commit is contained in:
parent
4a9d21d604
commit
c722495fdd
3 changed files with 7 additions and 3 deletions
|
@ -10,7 +10,7 @@
|
||||||
:autofocus="true"
|
:autofocus="true"
|
||||||
label="Item Name"
|
label="Item Name"
|
||||||
/>
|
/>
|
||||||
<FormTextField v-model="form.description" label="Item Description" />
|
<FormTextArea v-model="form.description" label="Item Description" />
|
||||||
<FormMultiselect v-model="form.labels" label="Labels" :items="labels ?? []" />
|
<FormMultiselect v-model="form.labels" label="Labels" :items="labels ?? []" />
|
||||||
<div class="modal-action">
|
<div class="modal-action">
|
||||||
<BaseButton ref="submitBtn" type="submit" :loading="loading">
|
<BaseButton ref="submitBtn" type="submit" :loading="loading">
|
||||||
|
@ -81,13 +81,14 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
const out: ItemCreate = {
|
const out: ItemCreate = {
|
||||||
|
parentId: undefined,
|
||||||
name: form.name,
|
name: form.name,
|
||||||
description: form.description,
|
description: form.description,
|
||||||
locationId: form.location.id as string,
|
locationId: form.location.id as string,
|
||||||
labelIds: form.labels.map(l => l.id) as string[],
|
labelIds: form.labels.map(l => l.id) as string[],
|
||||||
};
|
};
|
||||||
|
|
||||||
const { error } = await api.items.create(out);
|
const { error, data } = await api.items.create(out);
|
||||||
if (error) {
|
if (error) {
|
||||||
toast.error("Couldn't create item");
|
toast.error("Couldn't create item");
|
||||||
return;
|
return;
|
||||||
|
@ -95,5 +96,6 @@
|
||||||
|
|
||||||
toast.success("Item created");
|
toast.success("Item created");
|
||||||
reset();
|
reset();
|
||||||
|
navigateTo(`/item/${data.id}`);
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
|
@ -54,7 +54,7 @@
|
||||||
const toast = useNotifier();
|
const toast = useNotifier();
|
||||||
|
|
||||||
async function create() {
|
async function create() {
|
||||||
const { error } = await api.labels.create(form);
|
const { error, data } = await api.labels.create(form);
|
||||||
if (error) {
|
if (error) {
|
||||||
toast.error("Couldn't create label");
|
toast.error("Couldn't create label");
|
||||||
return;
|
return;
|
||||||
|
@ -62,5 +62,6 @@
|
||||||
|
|
||||||
toast.success("Label created");
|
toast.success("Label created");
|
||||||
reset();
|
reset();
|
||||||
|
navigateTo(`/label/${data.id}`);
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
|
@ -64,5 +64,6 @@
|
||||||
toast.success("Location created");
|
toast.success("Location created");
|
||||||
}
|
}
|
||||||
reset();
|
reset();
|
||||||
|
navigateTo(`/location/${data.id}`);
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
Loading…
Reference in a new issue