diff --git a/frontend/pages/item/[id]/index.vue b/frontend/pages/item/[id]/index.vue index 9271675..1056984 100644 --- a/frontend/pages/item/[id]/index.vue +++ b/frontend/pages/item/[id]/index.vue @@ -360,24 +360,6 @@ return v; }); - const confirm = useConfirm(); - - async function deleteItem() { - const confirmed = await confirm.open("Are you sure you want to delete this item?"); - - if (!confirmed.data) { - return; - } - - const { error } = await api.items.delete(itemId.value); - if (error) { - toast.error("Failed to delete item"); - return; - } - toast.success("Item deleted"); - navigateTo("/home"); - } - const refDialog = ref(); const dialoged = reactive({ src: "", @@ -480,10 +462,6 @@ {{ t.name }} - - - Delete - diff --git a/frontend/pages/item/[id]/index/edit.vue b/frontend/pages/item/[id]/index/edit.vue index 7479df7..ffb33a5 100644 --- a/frontend/pages/item/[id]/index/edit.vue +++ b/frontend/pages/item/[id]/index/edit.vue @@ -361,6 +361,44 @@ const { query, results } = useItemSearch(api, { immediate: false }); const parent = ref(); + + async function deleteItem() { + const confirmed = await confirm.open("Are you sure you want to delete this item?"); + + if (!confirmed.data) { + return; + } + + const { error } = await api.items.delete(itemId.value); + if (error) { + toast.error("Failed to delete item"); + return; + } + toast.success("Item deleted"); + navigateTo("/home"); + } + + async function keyboardSave(e: KeyboardEvent) { + // Cmd + S + if (e.metaKey && e.key === "s") { + e.preventDefault(); + await saveItem(); + } + + // Ctrl + S + if (e.ctrlKey && e.key === "s") { + e.preventDefault(); + await saveItem(); + } + } + + onMounted(() => { + window.addEventListener("keydown", keyboardSave); + }); + + onUnmounted(() => { + window.removeEventListener("keydown", keyboardSave); + });