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 <k@knt.li> Reviewed-on: https://kolaente.dev/vikunja/frontend/pulls/70
This commit is contained in:
parent
fe6c859150
commit
2104d1ea4b
3 changed files with 76 additions and 33 deletions
|
@ -5,21 +5,29 @@
|
||||||
</icon>
|
</icon>
|
||||||
</a>
|
</a>
|
||||||
<h3>Create a new list</h3>
|
<h3>Create a new list</h3>
|
||||||
<form @submit.prevent="newList" @keyup.esc="back()">
|
<div class="field is-grouped">
|
||||||
<div class="field is-grouped">
|
<p class="control is-expanded" :class="{ 'is-loading': listService.loading}">
|
||||||
<p class="control is-expanded" :class="{ 'is-loading': listService.loading}">
|
<input v-focus
|
||||||
<input v-focus class="input" :class="{ 'disabled': listService.loading}" v-model="list.title" type="text" placeholder="The list's name goes here...">
|
class="input"
|
||||||
</p>
|
:class="{ 'disabled': listService.loading}"
|
||||||
<p class="control">
|
v-model="list.title"
|
||||||
<button type="submit" class="button is-success noshadow">
|
type="text"
|
||||||
|
placeholder="The list's name goes here..."
|
||||||
|
@keyup.esc="back()"
|
||||||
|
@keyup.enter="newList()"/>
|
||||||
|
</p>
|
||||||
|
<p class="control">
|
||||||
|
<button class="button is-success noshadow" @click="newList()" :disabled="list.title.length < 3">
|
||||||
<span class="icon is-small">
|
<span class="icon is-small">
|
||||||
<icon icon="plus"/>
|
<icon icon="plus"/>
|
||||||
</span>
|
</span>
|
||||||
Add
|
Add
|
||||||
</button>
|
</button>
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
</form>
|
<p class="help is-danger" v-if="showError && list.title.length < 3">
|
||||||
|
Please specify at least three characters.
|
||||||
|
</p>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
|
@ -33,6 +41,7 @@
|
||||||
name: "NewList",
|
name: "NewList",
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
|
showError: false,
|
||||||
list: ListModel,
|
list: ListModel,
|
||||||
listService: ListService,
|
listService: ListService,
|
||||||
}
|
}
|
||||||
|
@ -50,6 +59,12 @@
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
newList() {
|
newList() {
|
||||||
|
if (this.list.title.length < 3) {
|
||||||
|
this.showError = true
|
||||||
|
return
|
||||||
|
}
|
||||||
|
this.showError = false
|
||||||
|
|
||||||
this.list.namespaceID = this.$route.params.id
|
this.list.namespaceID = this.$route.params.id
|
||||||
this.listService.create(this.list)
|
this.listService.create(this.list)
|
||||||
.then(response => {
|
.then(response => {
|
||||||
|
|
|
@ -5,22 +5,31 @@
|
||||||
</icon>
|
</icon>
|
||||||
</a>
|
</a>
|
||||||
<h3>Create a new namespace</h3>
|
<h3>Create a new namespace</h3>
|
||||||
<form @submit.prevent="newNamespace" @keyup.esc="back()">
|
<div class="field is-grouped">
|
||||||
<div class="field is-grouped">
|
<p class="control is-expanded" v-bind:class="{ 'is-loading': namespaceService.loading}">
|
||||||
<p class="control is-expanded" v-bind:class="{ 'is-loading': namespaceService.loading}">
|
<input v-focus
|
||||||
<input v-focus class="input" v-bind:class="{ 'disabled': namespaceService.loading}" v-model="namespace.name" type="text" placeholder="The namespace's name goes here...">
|
class="input"
|
||||||
</p>
|
v-bind:class="{ 'disabled': namespaceService.loading}"
|
||||||
<p class="control">
|
v-model="namespace.name"
|
||||||
<button type="submit" class="button is-success noshadow">
|
type="text"
|
||||||
|
@keyup.enter="newNamespace()"
|
||||||
|
@keyup.esc="back()"
|
||||||
|
placeholder="The namespace's name goes here..."/>
|
||||||
|
</p>
|
||||||
|
<p class="control">
|
||||||
|
<button class="button is-success noshadow" @click="newNamespace()" :disabled="namespace.name.length <= 5">
|
||||||
<span class="icon is-small">
|
<span class="icon is-small">
|
||||||
<icon icon="plus"/>
|
<icon icon="plus"/>
|
||||||
</span>
|
</span>
|
||||||
Add
|
Add
|
||||||
</button>
|
</button>
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
</form>
|
<p class="help is-danger" v-if="showError && namespace.name.length <= 5">
|
||||||
<p class="small" v-tooltip.bottom="'A namespace is a collection of lists you can share and use to organize your lists with.<br/>In fact, every list belongs to a namepace.'">What's a namespace?</p>
|
Please specify at least five characters.
|
||||||
|
</p>
|
||||||
|
<p class="small" v-tooltip.bottom="'A namespace is a collection of lists you can share and use to organize your lists with.<br/>In fact, every list belongs to a namepace.'">
|
||||||
|
What's a namespace?</p>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
|
@ -34,6 +43,7 @@
|
||||||
name: "NewNamespace",
|
name: "NewNamespace",
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
|
showError: false,
|
||||||
namespace: NamespaceModel,
|
namespace: NamespaceModel,
|
||||||
namespaceService: NamespaceService,
|
namespaceService: NamespaceService,
|
||||||
}
|
}
|
||||||
|
@ -51,6 +61,12 @@
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
newNamespace() {
|
newNamespace() {
|
||||||
|
if (this.namespace.name.length <= 4) {
|
||||||
|
this.showError = true
|
||||||
|
return
|
||||||
|
}
|
||||||
|
this.showError = false
|
||||||
|
|
||||||
this.namespaceService.create(this.namespace)
|
this.namespaceService.create(this.namespace)
|
||||||
.then(() => {
|
.then(() => {
|
||||||
this.$parent.loadNamespaces()
|
this.$parent.loadNamespaces()
|
||||||
|
|
|
@ -31,24 +31,28 @@
|
||||||
</span>
|
</span>
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
<form @submit.prevent="addTask()">
|
|
||||||
<div class="field is-grouped task-add">
|
<div class="field task-add">
|
||||||
|
<div class="field is-grouped">
|
||||||
<p class="control has-icons-left is-expanded" :class="{ 'is-loading': taskService.loading}">
|
<p class="control has-icons-left is-expanded" :class="{ 'is-loading': taskService.loading}">
|
||||||
<input v-focus class="input" :class="{ 'disabled': taskService.loading}" v-model="newTaskText" type="text" placeholder="Add a new task...">
|
<input v-focus class="input" :class="{ 'disabled': taskService.loading}" v-model="newTaskText" type="text" placeholder="Add a new task..." @keyup.enter="addTask()"/>
|
||||||
<span class="icon is-small is-left">
|
<span class="icon is-small is-left">
|
||||||
<icon icon="tasks"/>
|
<icon icon="tasks"/>
|
||||||
</span>
|
</span>
|
||||||
</p>
|
</p>
|
||||||
<p class="control">
|
<p class="control">
|
||||||
<button type="submit" class="button is-success">
|
<button class="button is-success" :disabled="newTaskText.length < 3" @click="addTask()">
|
||||||
<span class="icon is-small">
|
<span class="icon is-small">
|
||||||
<icon icon="plus"/>
|
<icon icon="plus"/>
|
||||||
</span>
|
</span>
|
||||||
Add
|
Add
|
||||||
</button>
|
</button>
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
</form>
|
<p class="help is-danger" v-if="showError && newTaskText.length < 3">
|
||||||
|
Please specify at least three characters.
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
|
||||||
<div class="columns">
|
<div class="columns">
|
||||||
<div class="column">
|
<div class="column">
|
||||||
|
@ -154,6 +158,8 @@
|
||||||
taskEditTask: TaskModel,
|
taskEditTask: TaskModel,
|
||||||
newTaskText: '',
|
newTaskText: '',
|
||||||
|
|
||||||
|
showError: false,
|
||||||
|
|
||||||
showTaskSearch: false,
|
showTaskSearch: false,
|
||||||
searchTerm: '',
|
searchTerm: '',
|
||||||
}
|
}
|
||||||
|
@ -188,6 +194,12 @@
|
||||||
this.loadTasks(page)
|
this.loadTasks(page)
|
||||||
},
|
},
|
||||||
addTask() {
|
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})
|
let task = new TaskModel({text: this.newTaskText, listID: this.$route.params.id})
|
||||||
this.taskService.create(task)
|
this.taskService.create(task)
|
||||||
.then(r => {
|
.then(r => {
|
||||||
|
|
Loading…
Reference in a new issue