+ use Shift + Enter to create and add another +
@@ -47,6 +46,15 @@ }, }); + const api = useUserApi(); + const toast = useNotifier(); + + const locationsStore = useLocationStore(); + const locations = computed(() => locationsStore.allLocations); + + const labelStore = useLabelStore(); + const labels = computed(() => labelStore.labels); + const route = useRoute(); const labelId = computed(() => { @@ -63,16 +71,7 @@ return null; }); - const api = useUserApi(); - const toast = useNotifier(); - - const locationsStore = useLocationStore(); - const locations = computed(() => locationsStore.allLocations); - - const labelStore = useLabelStore(); - const labels = computed(() => labelStore.labels); - - const submitBtn = ref(null); + const nameInput = ref
+ use Shift +
+ use Shift + Enter to create and add another +
- use Shift +
use Shift + Enter to create and add another
@@ -71,9 +69,15 @@ const api = useUserApi(); const toast = useNotifier(); - async function create(close: boolean) { + const { shift } = useMagicKeys(); + + async function create(close = true) { loading.value = true; + if (shift.value) { + close = false; + } + const { data, error } = await api.locations.create({ name: form.name, description: form.description, @@ -94,16 +98,4 @@ navigateTo(`/location/${data.id}`); } } - - async function keySubmit(e: KeyboardEvent) { - // Shift + Enter - if (e.shiftKey && e.key === "Enter") { - e.preventDefault(); - await create(false); - focused.value = true; - } else if (e.key === "Enter") { - e.preventDefault(); - await create(true); - } - } diff --git a/frontend/composables/use-events.ts b/frontend/composables/use-events.ts deleted file mode 100644 index 92c8cdd..0000000 --- a/frontend/composables/use-events.ts +++ /dev/null @@ -1,38 +0,0 @@ -export enum EventTypes { - // ClearStores event is used to inform the stores that _all_ the data they are using - // is now out of date and they should refresh - This is used when the user makes large - // changes to the data such as bulk actions or importing a CSV file - InvalidStores, -} - -export type EventFn = () => void; - -export interface IEventBus { - on(event: EventTypes, fn: EventFn, key: string): void; - off(event: EventTypes, key: string): void; - emit(event: EventTypes): void; -} - -class EventBus implements IEventBus { - private listeners: Record