From 3dea59dc60b719687b0265a445b1da8559d2b407 Mon Sep 17 00:00:00 2001 From: Matthieu Jouis Date: Thu, 3 Oct 2024 11:41:40 +0200 Subject: [PATCH] alert user that adding item when no view is selected is impossible --- frontend/src/views/ProjectView.vue | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/frontend/src/views/ProjectView.vue b/frontend/src/views/ProjectView.vue index 116bd96ea..9e05157ee 100644 --- a/frontend/src/views/ProjectView.vue +++ b/frontend/src/views/ProjectView.vue @@ -36,13 +36,19 @@ function onFocusMode() { isInFocusMode.value = !isInFocusMode.value; } +function displayItem(key: string) { + if (projectStore.currentView) { + projectStore.displayKey(projectStore.currentView, key); + } else { + toastsStore.addToast("No view selected", "error"); + } +} + function onItemDrop(event: DragEvent) { isDropIndicatorVisible.value = false; if (event.dataTransfer) { const key = event.dataTransfer.getData("key"); - if (projectStore.currentView) { - projectStore.displayKey(projectStore.currentView, key); - } + displayItem(key); } } @@ -59,9 +65,7 @@ function onDragLeave(event: DragEvent) { } function onItemSelected(key: string) { - if (projectStore.currentView) { - projectStore.displayKey(projectStore.currentView, key); - } + displayItem(key); } function onViewSelected(view: string) {