Skip to content
Snippets Groups Projects
Commit f7b586de authored by Paul Pestov's avatar Paul Pestov
Browse files

feat: add landing message to search page

parent 71f8d73f
No related branches found
No related tags found
1 merge request!70feat: add landing message to search page
...@@ -12,10 +12,23 @@ ...@@ -12,10 +12,23 @@
<code class="font-weight-black">{{ distinctManuscripts }}</code> {{ 'Manuscript' | numerus(distinctManuscripts) }}. <code class="font-weight-black">{{ distinctManuscripts }}</code> {{ 'Manuscript' | numerus(distinctManuscripts) }}.
</p> </p>
<v-alert
v-if="showPlaceholder"
border="left"
colored-border
color="secondary accent-4"
elevation="1"
>
<!-- TODO: provide translation -->
Please use the form above to enter a and search for a term of your choice.
</v-alert>
<SearchResultEmpty v-if="showNoResult" :message="message" />
<div <div
v-if="loading" v-if="loading"
class="loading-wrapper py-10" class="loading-wrapper py-10"
> >
<v-progress-circular <v-progress-circular
color="primary" color="primary"
indeterminate indeterminate
...@@ -67,6 +80,8 @@ export default { ...@@ -67,6 +80,8 @@ export default {
query: null, query: null,
size: 20, size: 20,
total: 0, total: 0,
showPlaceholder: false,
showNoResult: false,
}; };
}, },
watch:{ watch:{
...@@ -80,6 +95,8 @@ export default { ...@@ -80,6 +95,8 @@ export default {
mounted(){ mounted(){
if(this.$route.query?.searchTerm) { if(this.$route.query?.searchTerm) {
this.onSearchInput(this.$route.query.searchTerm); this.onSearchInput(this.$route.query.searchTerm);
} else {
this.showPlaceholder = true;
} }
}, },
computed: { computed: {
...@@ -103,21 +120,21 @@ export default { ...@@ -103,21 +120,21 @@ export default {
onSearchInput(query) { onSearchInput(query) {
this.query = query; this.query = query;
this.page = 1; this.page = 1;
this.resetList();
this.showPlaceholder = false;
this.showNoResult = false;
this.search(this.query.trim(), 0, this.size); this.search(this.query.trim(), 0, this.size);
if (this.$route.query.searchTerm !== query) { if (this.$route.query.searchTerm !== query) {
this.$router.push({ query: { ...this.$route.query, searchTerm:query } }); this.$router.push({ query: { ...this.$route.query, searchTerm:query } });
}; }
}, },
async search(value, from, size) { async search(value, from, size) {
this.hitCounter = from + 1; this.hitCounter = from + 1;
try { try {
this.items = [];
this.total = 0;
this.distinctSheets = 0;
this.loading = true; this.loading = true;
const searchResponse = await apiService.search(value, from, size); const searchResponse = await apiService.search(value, from, size);
...@@ -132,13 +149,14 @@ export default { ...@@ -132,13 +149,14 @@ export default {
this.total = searchResponse.hits?.total?.matches || 0; this.total = searchResponse.hits?.total?.matches || 0;
} }
// Toggle no result message on top of result list
this.showNoResult = this.total === 0;
// TODO: make string translable // TODO: make string translable
if (!this.invalid) this.message = `No search results found for <code>${this.query}</code>.`; if (!this.invalid) this.message = `No search results found for <code>${this.query}</code>.`;
} catch(error) { } catch(error) {
this.items = []; this.resetList();
this.distinctSheets = 0; this.showNoResult = true;
this.total = 0;
this.message = 'Please enter a valid search term.'; this.message = 'Please enter a valid search term.';
} finally { } finally {
this.loading = false; this.loading = false;
...@@ -151,6 +169,11 @@ export default { ...@@ -151,6 +169,11 @@ export default {
behavior: 'smooth', behavior: 'smooth',
}); });
}, },
resetList() {
this.items = [];
this.distinctSheets = 0;
this.total = 0;
}
}, },
}; };
</script> </script>
......
...@@ -27,8 +27,6 @@ ...@@ -27,8 +27,6 @@
</v-list-item-content> </v-list-item-content>
</v-list-item> </v-list-item>
</v-list> </v-list>
<SearchResultEmpty :message="message" v-else-if="query !== null" />
</div> </div>
</template> </template>
...@@ -47,11 +45,6 @@ export default { ...@@ -47,11 +45,6 @@ export default {
mixins: [ mixins: [
pathUrl, pathUrl,
], ],
computed: {
viewerBaseUrl() {
return process.env.VUE_APP_BASE_URL_VIEWER;
},
},
props: { props: {
hitCounter: { hitCounter: {
type: Number, type: Number,
...@@ -61,14 +54,6 @@ export default { ...@@ -61,14 +54,6 @@ export default {
type: Array, type: Array,
default: () => [], default: () => [],
}, },
message: {
type: String,
default: () => '',
},
query: {
type: String,
default: () => null,
},
}, },
computed: { computed: {
viewerBaseUrl() { viewerBaseUrl() {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment