Add a button to choose to query inventaire from search
This commit is contained in:
@@ -15,6 +15,12 @@
|
||||
authorId: Number
|
||||
});
|
||||
|
||||
const forceSearchInventaire = ref(false);
|
||||
|
||||
const searchInventaire = computed(() => {
|
||||
return forceSearchInventaire.value || (data.value !== null && data.value['inventaire'])
|
||||
});
|
||||
|
||||
let data = ref(null);
|
||||
let error = ref(null);
|
||||
|
||||
@@ -27,9 +33,11 @@
|
||||
|
||||
|
||||
function fetchData(searchTerm, authorId) {
|
||||
data.value = null;
|
||||
error.value = null;
|
||||
if (searchTerm != null) {
|
||||
const lang = navigator.language.substring(0,2);
|
||||
getSearchBooks(data, error, searchTerm, lang, limit, offset.value);
|
||||
getSearchBooks(data, error, searchTerm, lang, forceSearchInventaire.value, limit, offset.value);
|
||||
} else if (authorId != null) {
|
||||
getAuthorBooks(data, error, authorId, limit, offset.value);
|
||||
}
|
||||
@@ -46,15 +54,26 @@
|
||||
fetchData(props.searchterm, props.authorId);
|
||||
}
|
||||
|
||||
function toggleSearchInventaire() {
|
||||
pageNumber.value = 1;
|
||||
forceSearchInventaire.value = !forceSearchInventaire.value;
|
||||
fetchData(props.searchterm, props.authorId)
|
||||
window.scrollTo(0,0);
|
||||
}
|
||||
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="booksearch my-2">
|
||||
<h1 class="title" v-if="data && data.inventaire">{{$t('searchbook.importinventaire')}}</h1>
|
||||
<div v-if="error">{{$t('searchbook.error', {error: error.message})}}</div>
|
||||
<div v-else-if="data && data.books && data.books.length > 0">
|
||||
<div class="booksearchlist" v-for="book in data.books" :key="book.id">
|
||||
<BookListElement v-bind="book" />
|
||||
</div>
|
||||
<div v-if="!searchInventaire || forceSearchInventaire" class="box container clickable has-background-dark" @click="toggleSearchInventaire">
|
||||
<div class="is-size-4">{{searchInventaire ? $t('searchbook.backtosearch') : $t('searchbook.searchinventaire')}}</div>
|
||||
</div>
|
||||
<Pagination
|
||||
:pageNumber="pageNumber"
|
||||
:pageTotal="pageTotal"
|
||||
@@ -66,5 +85,10 @@
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<style scoped></style>
|
||||
<style scoped>
|
||||
|
||||
.clickable {
|
||||
cursor:pointer
|
||||
}
|
||||
</style>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user