bugfix tags

main
HerrHase 2 years ago
parent 11ea3291bb
commit 355ddf08d0

@ -142,10 +142,8 @@
for (let i = 0; i < this.state.tags.length; i++) {
if (value === this.state.tags[i]) {
inArray = true
this.state.errors.push('Already added')
this.update()
break
}
}
@ -153,14 +151,13 @@
// if value is not already in data and longer than zero chars
if (inArray === false && value.length > 0) {
this.state.tags.push(value)
this.update()
this.$('input').value = ''
} else if (value.length === 0) {
this.state.errors.push('Required!')
this.update()
}
this.update()
// adding focus to input
this.$('input').focus();
}

@ -109,7 +109,17 @@ class AppsDatabase extends DatabaseHandler {
}
return this.db.put(data)
.then((response) => {
.then(async (response) => {
const tagsDatabase = new TagsDatabase()
// if tags are in data update tags also in database
if (data.tags && data.tags.length > 0) {
tagsDatabase.update(data.tags)
} else {
await tagsDatabase.removeNotNeeded()
}
return this.findOneById(response._id)
}).catch((error) => {
@ -251,7 +261,6 @@ class AppsDatabase extends DatabaseHandler {
}
return this.db.find(query).then(async (documents) => {
console.log(documents.docs)
return documents.docs
}).catch((error) => {

Loading…
Cancel
Save