Search authors, num results
This commit is contained in:
parent
48910f40ae
commit
3eeefa0fec
27
search.html
27
search.html
@ -41,7 +41,7 @@
|
||||
<input type="radio" value="books" v-model="which"> livres
|
||||
</label>
|
||||
<label class="radio-inline">
|
||||
<input type="radio" value="authors" v-model="which" disabled> auteurs
|
||||
<input type="radio" value="authors" v-model="which"> auteurs
|
||||
</label>
|
||||
<label class="radio-inline">
|
||||
<input type="radio" value="series" v-model="which"> series
|
||||
@ -50,6 +50,21 @@
|
||||
<input type="radio" value="all" v-model="which"> tous
|
||||
</label>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label>Nombre de resultats</label><br/>
|
||||
<label class="radio-inline">
|
||||
<input type="radio" value="10" v-model="perpage"> 10
|
||||
</label>
|
||||
<label class="radio-inline">
|
||||
<input type="radio" value="20" v-model="perpage"> 20
|
||||
</label>
|
||||
<label class="radio-inline">
|
||||
<input type="radio" value="50" v-model="perpage"> 50
|
||||
</label>
|
||||
<label class="radio-inline">
|
||||
<input type="radio" value="100" v-model="perpage"> 100
|
||||
</label>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<div class="checkbox">
|
||||
<label>
|
||||
@ -72,6 +87,16 @@
|
||||
<li v-if="books.length < booksCount" class="list-unstyled">...</li>
|
||||
</ul>
|
||||
</div>
|
||||
<div v-if="authors.length > 0">
|
||||
<h2>{{ authorsCount }} <template v-if="authorsCount>1">auteurs</template><template v-else>auteur</template></h2>
|
||||
<ul>
|
||||
<li v-for="author in authors" class="list-unstyled">
|
||||
<span class="glyphicon glyphicon-user"></span>
|
||||
<a :href="'authors.html?id='+author.id">{{ author.name }}</a>
|
||||
</li>
|
||||
<li v-if="authors.length < authorsCount" class="list-unstyled">...</li>
|
||||
</ul>
|
||||
</div>
|
||||
<div v-if="series.length > 0">
|
||||
<h2>{{ seriesCount }} <template v-if="seriesCount>1">series</template><template v-else>serie</template></h2>
|
||||
<ul>
|
||||
|
29
search.js
29
search.js
@ -5,11 +5,13 @@ var app = new Vue({
|
||||
authors: [],
|
||||
books: [],
|
||||
series: [],
|
||||
authorsCount: 0,
|
||||
booksCount: 0,
|
||||
seriesCount: 0,
|
||||
q: '',
|
||||
which: 'all',
|
||||
all: false
|
||||
all: false,
|
||||
perpage: 10
|
||||
},
|
||||
methods: {
|
||||
urlParse: function() {
|
||||
@ -51,20 +53,21 @@ var app = new Vue({
|
||||
},
|
||||
searchParams: function(url) {
|
||||
var res = url;
|
||||
var first = true;
|
||||
res += '?perpage=' + this.perpage;
|
||||
for (var i=0; i<this.terms.length; i++) {
|
||||
var t = this.terms[i];
|
||||
if (t.trim()) {
|
||||
if (first) {
|
||||
first = false;
|
||||
res += '?';
|
||||
} else
|
||||
res += '&';
|
||||
res += 'term=' + encodeURIComponent(t.trim());
|
||||
}
|
||||
if (t.trim())
|
||||
res += '&term=' + encodeURIComponent(t.trim());
|
||||
}
|
||||
return res;
|
||||
},
|
||||
searchAuthorsSuccess: function(res) {
|
||||
this.authorsCount = res.count;
|
||||
this.authors = res.authors;
|
||||
},
|
||||
searchAuthors: function() {
|
||||
this.sendQuery(this.searchParams('cgi-bin/bouquins/authors'), this.stdError, this.searchAuthorsSuccess);
|
||||
},
|
||||
searchBooksSuccess: function(res) {
|
||||
this.booksCount = res.count;
|
||||
this.books = res.books;
|
||||
@ -81,6 +84,7 @@ var app = new Vue({
|
||||
},
|
||||
searchAll: function() {
|
||||
this.clear();
|
||||
this.searchAuthors();
|
||||
this.searchBooks();
|
||||
this.searchSeries();
|
||||
},
|
||||
@ -88,6 +92,7 @@ var app = new Vue({
|
||||
this.authors = [];
|
||||
this.books = [];
|
||||
this.series = [];
|
||||
this.authorsCount = 0;
|
||||
this.booksCount = 0;
|
||||
this.seriesCount = 0;
|
||||
},
|
||||
@ -98,6 +103,10 @@ var app = new Vue({
|
||||
case 'all':
|
||||
this.searchAll();
|
||||
break;
|
||||
case 'authors':
|
||||
this.clear();
|
||||
this.searchAuthors();
|
||||
break;
|
||||
case 'books':
|
||||
this.clear();
|
||||
this.searchBooks();
|
||||
|
Loading…
Reference in New Issue
Block a user