Skip to content
Snippets Groups Projects
Commit fc29c072 authored by schneider210's avatar schneider210
Browse files

feat: add circular progress to the search list

renders unless the promise returned by axios is fulfilled; shows search results otherwise
parent 7f4c06e8
No related branches found
No related tags found
1 merge request!60loading indicator for search
Pipeline #219375 passed
...@@ -6,7 +6,13 @@ ...@@ -6,7 +6,13 @@
class="text-overline mb-0" class="text-overline mb-0"
>{{total}} Results</p> >{{total}} Results</p>
<SearchResultList :items="items" /> <v-progress-circular
v-if="loading"
color="primary"
indeterminate
/>
<SearchResultList v-else :items="items" />
<div <div
class="text-center" class="text-center"
...@@ -34,11 +40,12 @@ export default { ...@@ -34,11 +40,12 @@ export default {
}, },
data() { data() {
return { return {
query: '',
items: [], items: [],
loading: false,
page: 1,
query: '',
size: 20, size: 20,
total: 0, total: 0,
page: 1,
} }
}, },
watch:{ watch:{
...@@ -53,6 +60,7 @@ export default { ...@@ -53,6 +60,7 @@ export default {
page: function() { page: function() {
const from = this.size * (this.page - 1); const from = this.size * (this.page - 1);
this.search(this.query, from, this.size); this.search(this.query, from, this.size);
this.loading = true;
} }
}, },
computed: { computed: {
...@@ -67,13 +75,16 @@ export default { ...@@ -67,13 +75,16 @@ export default {
this.search(this.query, 0, this.size) this.search(this.query, 0, this.size)
}, },
async search(value, from, size) { async search(value, from, size) {
this.loading = true;
const searchResponse = await apiService.search(value, from, size); const searchResponse = await apiService.search(value, from, size);
if (searchResponse) { if (searchResponse) {
this.loading = false;
const items = searchResponse.hits?.hits; const items = searchResponse.hits?.hits;
if (items) { if (items) {
this.total = searchResponse.hits?.total.value || 0; this.total = searchResponse.hits?.total.value || 0;
this.items = items.map(x=>({...x, searchTerm: value})); this.items = items.map(x => ({ ...x, searchTerm: value }));
} }
} }
}, },
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment