This commit is contained in:
Hubert Van De Walle 2020-04-23 00:36:47 +02:00
parent 74aeb711f0
commit 22cbaec879

View File

@ -9,10 +9,12 @@
<v-toolbar-title>Create a note</v-toolbar-title> <v-toolbar-title>Create a note</v-toolbar-title>
</v-toolbar> </v-toolbar>
<v-alert v-if="conflict" type="error">
A note with the same title already exists
</v-alert>
<v-form <v-form
ref="form" ref="form"
v-model="valid"
lazy-validation lazy-validation
> >
<v-card-text> <v-card-text>
@ -54,24 +56,33 @@
title: '', title: '',
tags: [] tags: []
}, },
possibleTags: [] possibleTags: [],
conflict: false
}), }),
methods: { methods: {
createNote() { createNote() {
this.conflict = false
this.$axios.post(`/notes/${this.form.title}`, { this.$axios.post(`/notes/${this.form.title}`, {
tags: this.form.tags tags: this.form.tags
}).then(data => { }).then(_ => {
console.log(data) this.$router.push("/notes")
} }
).catch(e => { ).catch(e => {
console.log(e) if (e.response && e.response.status === 409) {
this.conflict = true
} else {
console.log("??")
}
}) })
} }
}, },
mounted() { mounted() {
this.$axios.get("/tags") this.$axios.get("/tags")
.then(e => console.log(e.data)) .then(e => this.possibleTags = e.data)
.catch(e => {
console.log(e)
})
} }
} }
</script> </script>