diff --git a/resources/views/components/search-view.blade.php b/resources/views/components/search-view.blade.php
index f431b02..985ce9d 100644
--- a/resources/views/components/search-view.blade.php
+++ b/resources/views/components/search-view.blade.php
@@ -1,6 +1,6 @@
-
+
-
+
+
{{ $results }}
+
+
Load more
-
+
@@ -44,13 +55,15 @@
number: 1,
size: 12,
morePages: false,
- searchTerm: '{{ $defaultSearch ?? null }}',
+ searchTerm: null,
+ searching: false,
filterTags: [],
resetPagination() {
this.number = 1;
this.morePages = false;
},
loadMore() {
+ this.searching = true;
let url = `{{ $route }}?page[number]=${this.number}&page[size]=${this.size}`;
if (this.searchTerm) {
url += `&filter[search]=${this.searchTerm}`;
@@ -59,7 +72,6 @@
fetch(url)
.then(response => response.json())
.then(data => {
- this.results = [];
this.results = [...this.results, ...data.data.map(result => result.attributes)];
if (this.number < data.meta.page['last-page']) {
this.morePages = true;
@@ -67,9 +79,11 @@
} else {
this.morePages = false;
}
+ this.searching = false;
});
},
search(e) {
+ this.results = [];
this.resetPagination();
if (e.target.value !== '') {
this.searchTerm = e.target.value;
@@ -80,6 +94,7 @@
this.loadMore();
},
updateFilters(e) {
+ this.results = [];
this.resetPagination();
const newTag = e.target.text;
if (this.filterTags.includes(newTag)) {