From 2104d1ea4b1c30a9201bfaa427a469828706df6c Mon Sep 17 00:00:00 2001 From: konrad Date: Wed, 4 Mar 2020 19:27:27 +0000 Subject: [PATCH] Input length validation for new tasks, lists and namespaces (#70) Fix input validation for new tasks Better layout for input validation for new lists Add input length validation for new namepaces Add input length validation for new lists Add input length validation for new tasks Co-authored-by: kolaente Reviewed-on: https://kolaente.dev/vikunja/frontend/pulls/70 --- src/components/lists/NewList.vue | 39 +++++++++++++------- src/components/namespaces/NewNamespace.vue | 42 +++++++++++++++------- src/components/tasks/ShowListTasks.vue | 28 ++++++++++----- 3 files changed, 76 insertions(+), 33 deletions(-) diff --git a/src/components/lists/NewList.vue b/src/components/lists/NewList.vue index 1b6bd7ea8..78a371713 100644 --- a/src/components/lists/NewList.vue +++ b/src/components/lists/NewList.vue @@ -5,21 +5,29 @@

Create a new list

-
-
-

- -

-

- -

-
-
+ Add + +

+ +

+ Please specify at least three characters. +

@@ -33,6 +41,7 @@ name: "NewList", data() { return { + showError: false, list: ListModel, listService: ListService, } @@ -50,6 +59,12 @@ }, methods: { newList() { + if (this.list.title.length < 3) { + this.showError = true + return + } + this.showError = false + this.list.namespaceID = this.$route.params.id this.listService.create(this.list) .then(response => { diff --git a/src/components/namespaces/NewNamespace.vue b/src/components/namespaces/NewNamespace.vue index df007a328..d5fc60e61 100644 --- a/src/components/namespaces/NewNamespace.vue +++ b/src/components/namespaces/NewNamespace.vue @@ -5,22 +5,31 @@

Create a new namespace

-
-
-

- -

-

- -

-
-
-

What's a namespace?

+ Add + +

+ +

+ Please specify at least five characters. +

+

+ What's a namespace?

@@ -34,6 +43,7 @@ name: "NewNamespace", data() { return { + showError: false, namespace: NamespaceModel, namespaceService: NamespaceService, } @@ -51,6 +61,12 @@ }, methods: { newNamespace() { + if (this.namespace.name.length <= 4) { + this.showError = true + return + } + this.showError = false + this.namespaceService.create(this.namespace) .then(() => { this.$parent.loadNamespaces() diff --git a/src/components/tasks/ShowListTasks.vue b/src/components/tasks/ShowListTasks.vue index 5b6a5e7c3..d248ca423 100644 --- a/src/components/tasks/ShowListTasks.vue +++ b/src/components/tasks/ShowListTasks.vue @@ -31,24 +31,28 @@ -
-
+ +
+

- +

-

- +

+ Please specify at least three characters. +

+
@@ -154,6 +158,8 @@ taskEditTask: TaskModel, newTaskText: '', + showError: false, + showTaskSearch: false, searchTerm: '', } @@ -188,6 +194,12 @@ this.loadTasks(page) }, addTask() { + if (this.newTaskText.length < 3) { + this.showError = true + return + } + this.showError = false + let task = new TaskModel({text: this.newTaskText, listID: this.$route.params.id}) this.taskService.create(task) .then(r => {