From 7172e8a384aef44d890fe5ae9c7ea3928533420b Mon Sep 17 00:00:00 2001 From: mslaursen Date: Sat, 9 Aug 2025 02:30:49 +0200 Subject: [PATCH 1/2] update(Frontend v2): Input validation --- frontend/src/components/steps/ProjectNameStep.vue | 8 ++------ frontend/src/utils/validation.ts | 10 ++++++++++ 2 files changed, 12 insertions(+), 6 deletions(-) create mode 100644 frontend/src/utils/validation.ts diff --git a/frontend/src/components/steps/ProjectNameStep.vue b/frontend/src/components/steps/ProjectNameStep.vue index bf33c64..f811efd 100644 --- a/frontend/src/components/steps/ProjectNameStep.vue +++ b/frontend/src/components/steps/ProjectNameStep.vue @@ -5,7 +5,6 @@
-
{{ localProjectName.length }} / 50
@@ -154,6 +155,8 @@ import { useModalStore } from "@/stores/useModalStore" import AddEnumValueModal from "@/components/modal/AddEnumValueModal.vue" import EditEnumValueModal from "@/components/modal/EditEnumValueModal.vue" import type { EnumT, EnumValue } from "@/types/types" +import { isValidEnumName, warningMessages } from "@/utils/validation" +import { showDangerToast } from "@/utils/toast" const projectStore = useProjectStore() const modalStore = useModalStore() @@ -188,6 +191,10 @@ const selectEnum = (e: EnumT) => { const createEnum = () => { const name = newEnumName.value.trim() if (name === "") return + if (!isValidEnumName(name)) { + showDangerToast(warningMessages.enumName) + return + } const newEnum = projectStore.addEnum(name) newEnumName.value = "" selectEnum(newEnum) @@ -210,20 +217,19 @@ const handleEditToggle = (enumItem: EnumT) => { } else { editingEnumName.value = enumItem.name editedEnumName.value = enumItem.name - nextTick(() => { - if (enumNameInput.value) { - enumNameInput.value.focus() - } - }) } } const saveEnumName = (enumItem: EnumT) => { const newName = editedEnumName.value.trim() if (newName && newName !== enumItem.name) { - projectStore.updateEnumName(enumItem.name, newName) - if (selectedEnum.value?.name === enumItem.name) { - selectedEnum.value.name = newName + if (!isValidEnumName(newName)) { + showDangerToast(warningMessages.enumName) + } else { + projectStore.updateEnumName(enumItem.name, newName) + if (selectedEnum.value?.name === enumItem.name) { + selectedEnum.value.name = newName + } } } editingEnumName.value = null diff --git a/frontend/src/components/schema_editor/SchemaEditor.vue b/frontend/src/components/schema_editor/SchemaEditor.vue index f85dd96..f0d22b9 100644 --- a/frontend/src/components/schema_editor/SchemaEditor.vue +++ b/frontend/src/components/schema_editor/SchemaEditor.vue @@ -2,7 +2,6 @@
-
#