forked from kompetenzinventar/ki-frontend
This commit is contained in:
@ -53,10 +53,13 @@
|
||||
</div>
|
||||
</template>
|
||||
<script>
|
||||
import RequestMixin from "@/mixins/request.mixin"
|
||||
|
||||
import ProfileList from "@/components/ProfileList";
|
||||
|
||||
export default {
|
||||
name: "AutoComplete",
|
||||
mixins: [RequestMixin],
|
||||
components: {
|
||||
ProfileList,
|
||||
},
|
||||
@ -80,31 +83,6 @@ export default {
|
||||
};
|
||||
},
|
||||
methods: {
|
||||
async search() {
|
||||
try {
|
||||
const request = await this.axios.get(
|
||||
`${this.apiUrl}/${this.type}s?search=${this.searchText}`,
|
||||
{
|
||||
headers: {
|
||||
Authorization: `Bearer ${localStorage.getItem("token")}`,
|
||||
},
|
||||
}
|
||||
);
|
||||
if (request.status === 200) {
|
||||
this.searchResults = request.data[`${this.type}s`];
|
||||
if (
|
||||
!this.values
|
||||
.map((item) => item[this.type].name.toLowerCase())
|
||||
.includes(this.searchText.toLowerCase())
|
||||
) {
|
||||
this.searchResults.unshift({ name: this.searchText });
|
||||
}
|
||||
}
|
||||
} catch (error) {
|
||||
console.error();
|
||||
this.showErrorMessage = true;
|
||||
}
|
||||
},
|
||||
addResult(result = false) {
|
||||
if (!result) result = this.searchResults[0];
|
||||
if (
|
||||
|
Reference in New Issue
Block a user