forked from kompetenzinventar/ki-frontend
update profile edit view
This commit is contained in:
@ -37,6 +37,11 @@ export default {
|
||||
}
|
||||
},
|
||||
async search() {
|
||||
if (!this.searchText) {
|
||||
this.searchResults = []
|
||||
return
|
||||
}
|
||||
|
||||
try {
|
||||
const response = await fetch(`${this.apiUrl}/${this.type}s?search=${this.searchText}`, {
|
||||
headers: {
|
||||
@ -52,15 +57,16 @@ export default {
|
||||
}
|
||||
|
||||
const responseData = await response.json()
|
||||
this.searchResults = responseData[`${this.type}s`];
|
||||
const searchResults = responseData[`${this.type}s`];
|
||||
|
||||
if (
|
||||
!this.values
|
||||
.map((item) => item[this.type].name.toLowerCase())
|
||||
.includes(this.searchText.toLowerCase())
|
||||
!searchResults.map((item) => item.name.toLowerCase())
|
||||
.includes(this.searchText.toLowerCase())
|
||||
) {
|
||||
this.searchResults.unshift({ name: this.searchText });
|
||||
searchResults.unshift({ name: this.searchText });
|
||||
}
|
||||
|
||||
this.searchResults = searchResults
|
||||
} catch (error) {
|
||||
console.error();
|
||||
this.showErrorMessage = true;
|
||||
|
Reference in New Issue
Block a user