forked from mirrors/homebox
feat: WebSocket based implementation of server sent events for cache busting (#527)
* rough implementation of WS based event system for server side notifications of mutation * fix test construction * fix deadlock on event bus * disable linter error * add item mutation events * remove old event bus code * refactor event system to use composables * refresh items table when new item is added * fix create form errors * cleanup unnecessary calls * fix importer erorrs + limit fn calls on import
This commit is contained in:
parent
cceec06148
commit
2cbcc8bb1d
31 changed files with 458 additions and 208 deletions
|
@ -1,14 +1,14 @@
|
|||
<template>
|
||||
<BaseModal v-model="modal">
|
||||
<template #title> Create Item </template>
|
||||
<div @keyup="keySubmit">
|
||||
<form @submit.prevent="create()">
|
||||
<LocationSelector v-model="form.location" />
|
||||
<FormTextField ref="nameInput" v-model="form.name" :trigger-focus="focused" :autofocus="true" label="Item Name" />
|
||||
<FormTextArea v-model="form.description" label="Item Description" />
|
||||
<FormMultiselect v-model="form.labels" label="Labels" :items="labels ?? []" />
|
||||
<div class="modal-action">
|
||||
<div class="flex justify-center">
|
||||
<BaseButton class="rounded-r-none" :loading="loading" @click="create(true)">
|
||||
<BaseButton class="rounded-r-none" :loading="loading" type="submit">
|
||||
<template #icon>
|
||||
<Icon name="mdi-package-variant" class="swap-off h-5 w-5" />
|
||||
<Icon name="mdi-package-variant-closed" class="swap-on h-5 w-5" />
|
||||
|
@ -21,13 +21,13 @@
|
|||
</label>
|
||||
<ul tabindex="0" class="dropdown-content menu p-2 shadow bg-base-100 rounded-box w-64">
|
||||
<li>
|
||||
<button type="button" @click.prevent="create(false)">Create and Add Another</button>
|
||||
<button type="button" @click="create(false)">Create and Add Another</button>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
<p class="text-sm text-center mt-4">
|
||||
use <kbd class="kbd kbd-xs">Shift</kbd> + <kbd class="kbd kbd-xs"> Enter </kbd> to create and add another
|
||||
</p>
|
||||
|
@ -84,6 +84,8 @@
|
|||
labels: [] as LabelOut[],
|
||||
});
|
||||
|
||||
const { shift } = useMagicKeys();
|
||||
|
||||
whenever(
|
||||
() => modal.value,
|
||||
() => {
|
||||
|
@ -102,11 +104,15 @@
|
|||
}
|
||||
);
|
||||
|
||||
async function create(close = false) {
|
||||
async function create(close = true) {
|
||||
if (!form.location) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (shift.value) {
|
||||
close = false;
|
||||
}
|
||||
|
||||
const out: ItemCreate = {
|
||||
parentId: null,
|
||||
name: form.name,
|
||||
|
@ -135,18 +141,4 @@
|
|||
navigateTo(`/item/${data.id}`);
|
||||
}
|
||||
}
|
||||
|
||||
async function keySubmit(e: KeyboardEvent) {
|
||||
// Shift + Enter
|
||||
if (e.shiftKey && e.key === "Enter") {
|
||||
console.log("Shift + Enter");
|
||||
e.preventDefault();
|
||||
await create(false);
|
||||
focused.value = true;
|
||||
} else if (e.key === "Enter") {
|
||||
e.preventDefault();
|
||||
console.log("Enter");
|
||||
await create(true);
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue