Merge pull request #7551 from rekonder/aj_SCI_10697

Fix loading full view for global search results [SCI-10697]
This commit is contained in:
aignatov-bio 2024-05-14 11:41:13 +02:00 committed by GitHub
commit 65a78f6213
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -112,8 +112,10 @@ export default {
loadData() {
if (this.query.length < 2) return;
if (this.loading && this.page) return;
if (this.loading && this.page && !(this.selected && !this.fullDataLoaded)) return;
const fullView = this.selected;
const currentPage = this.page;
this.loading = true;
axios.get(this.searchUrl, {
params: {
@ -121,21 +123,26 @@ export default {
sort: this.sort,
filters: this.filters,
group: this.group,
preview: !this.selected,
page: this.page
preview: !fullView,
page: currentPage
}
})
.then((response) => {
if (this.selected) this.fullDataLoaded = true;
if (this.selected === fullView && this.page === currentPage) {
this.results = this.results.concat(response.data.data);
this.total = response.data.meta.total;
this.disabled = response.data.meta.disabled;
this.loading = false;
this.page = response.data.meta.next_page;
}
})
.finally(() => {
if (this.selected === fullView) {
this.loading = false;
this.$emit('updated');
}
});
}
}