bugfix tags

main
HerrHase 2 years ago
parent 11ea3291bb
commit 355ddf08d0

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

@ -109,7 +109,17 @@ class AppsDatabase extends DatabaseHandler {
} }
return this.db.put(data) 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) return this.findOneById(response._id)
}).catch((error) => { }).catch((error) => {
@ -251,7 +261,6 @@ class AppsDatabase extends DatabaseHandler {
} }
return this.db.find(query).then(async (documents) => { return this.db.find(query).then(async (documents) => {
console.log(documents.docs)
return documents.docs return documents.docs
}).catch((error) => { }).catch((error) => {

Loading…
Cancel
Save