bugfix addPersons

This commit is contained in:
Julie Lenaerts 2022-01-31 18:33:29 +01:00
parent b42ae76bdf
commit a4457664d4

View File

@ -195,18 +195,18 @@ export default {
setTimeout(function() { setTimeout(function() {
if (query === "") { if (query === "") {
this.loadSuggestions([]); this.loadSuggestions([]);
return; return;
} }
if (query === this.search.query) { if (query === this.search.query) {
if (this.currentSearchQueryController !== undefined) { if (this.currentSearchQueryController !== undefined) {
this.currentSearchQueryController.abort() this.currentSearchQueryController.abort()
} }
this.currentSearchQueryController = new AbortController(); this.currentSearchQueryController = new AbortController();
searchEntities({ query, options: this.options }, this.currentSearchQueryController) searchEntities({ query, options: this.options }, this.currentSearchQueryController)
.then(suggested => new Promise((resolve, reject) => { .then(suggested => new Promise((resolve, reject) => {
this.loadSuggestions(suggested.results); this.loadSuggestions(suggested.results);
resolve(); resolve();
})); }));
} }
}.bind(this), query.length > 3 ? 300 : 700); }.bind(this), query.length > 3 ? 300 : 700);
@ -241,13 +241,14 @@ export default {
return item.result.type + item.result.id; return item.result.type + item.result.id;
}, },
addPriorSuggestion() { addPriorSuggestion() {
//console.log('addPriorSuggestion', this.hasPriorSuggestion); // console.log('prior suggestion', this.priorSuggestion);
if (this.hasPriorSuggestion) { if (this.hasPriorSuggestion) {
console.log('addPriorSuggestion',); // console.log('addPriorSuggestion',);
this.suggested.unshift(this.priorSuggestion); this.suggested.unshift(this.priorSuggestion);
this.selected.unshift(this.priorSuggestion); this.selected.unshift(this.priorSuggestion);
console.log('reset priorSuggestion'); // console.log('selected', this.selected);
// console.log('suggested', this.suggested);
this.newPriorSuggestion(null); this.newPriorSuggestion(null);
} }
}, },
@ -260,13 +261,14 @@ export default {
result: entity result: entity
} }
this.search.priorSuggestion = suggestion; this.search.priorSuggestion = suggestion;
console.log('search priorSuggestion', this.search.priorSuggestion); // console.log('search priorSuggestion', this.search.priorSuggestion);
this.addPriorSuggestion(suggestion)
} else { } else {
this.search.priorSuggestion = {}; this.search.priorSuggestion = {};
} }
}, },
saveFormOnTheFly({ type, data }) { saveFormOnTheFly({ type, data }) {
console.log('saveFormOnTheFly from addPersons, type', type, ', data', data); // console.log('saveFormOnTheFly from addPersons, type', type, ', data', data);
if (type === 'person') { if (type === 'person') {
makeFetch('POST', '/api/1.0/person/person.json', data) makeFetch('POST', '/api/1.0/person/person.json', data)
.then(response => { .then(response => {
@ -276,10 +278,10 @@ export default {
.catch((error) => { .catch((error) => {
if (error.name === 'ValidationException') { if (error.name === 'ValidationException') {
for (let v of error.violations) { for (let v of error.violations) {
this.$toast.open({message: v }); this.$toast.open({message: v });
} }
} else { } else {
this.$toast.open({message: 'An error occurred'}); this.$toast.open({message: 'An error occurred'});
} }
}) })
} }
@ -292,10 +294,10 @@ export default {
.catch((error) => { .catch((error) => {
if (error.name === 'ValidationException') { if (error.name === 'ValidationException') {
for (let v of error.violations) { for (let v of error.violations) {
this.$toast.open({message: v }); this.$toast.open({message: v });
} }
} else { } else {
this.$toast.open({message: 'An error occurred'}); this.$toast.open({message: 'An error occurred'});
} }
}) })
} }