Search series/all

This commit is contained in:
Meutel 2017-01-15 15:25:49 +01:00
parent 0587faf352
commit d235672bfe
2 changed files with 47 additions and 14 deletions

View File

@ -31,29 +31,29 @@
<h3>Recherche</h3>
</div>
<div class="panel-body">
<form>
<form id="searchForm">
<div class="form-group">
<input id="q" type="text" class="form-control" placeholder="Recherche">
<input type="text" class="form-control" placeholder="Recherche" v-model="q">
</div>
<div class="form-group">
<label>Parmi</label><br/>
<label class="radio-inline">
<input type="radio" name="which" value="books" checked> livres
<input type="radio" value="books" v-model="which"> livres
</label>
<label class="radio-inline">
<input type="radio" name="which" value="authors" disabled> auteurs
<input type="radio" value="authors" v-model="which" disabled> auteurs
</label>
<label class="radio-inline">
<input type="radio" name="which" value="series" disabled> series
<input type="radio" value="series" v-model="which"> series
</label>
<label class="radio-inline">
<input type="radio" name="which" value="all" disabled> tous
<input type="radio" value="all" v-model="which"> tous
</label>
</div>
<div class="form-group">
<div class="checkbox">
<label>
<input type="checkbox" id="all" disabled> Tous les mots
<input type="checkbox" v-model="all" disabled> Tous les mots
</label>
<p class="help-block">Cocher pour rechercher les élements contenant tous les mots saisis</p>
</div>
@ -72,6 +72,16 @@
<li v-if="books.length < booksCount" 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>
<li v-for="serie in series" class="list-unstyled">
<span class="glyphicon glyphicon-list"></span>
<a :href="'series.html?id='+serie.id">{{ serie.name }}</a>
</li>
<li v-if="series.length < seriesCount" class="list-unstyled">...</li>
</ul>
</div>
</div>
<script src="js/vue.min.js"></script>
<script src="js/search.min.js"></script>

View File

@ -5,7 +5,11 @@ var app = new Vue({
authors: [],
books: [],
series: [],
booksCount: 0
booksCount: 0,
seriesCount: 0,
q: '',
which: 'all',
all: false
},
methods: {
urlParse: function() {
@ -68,29 +72,48 @@ var app = new Vue({
searchBooks: function() {
this.sendQuery(this.searchParams('cgi-bin/bouquins/books'), this.stdError, this.searchBooksSuccess);
},
searchSeriesSuccess: function(res) {
this.seriesCount = res.count;
this.series = res.series;
},
searchSeries: function() {
this.sendQuery(this.searchParams('cgi-bin/bouquins/series'), this.stdError, this.searchSeriesSuccess);
},
searchAll: function() {
this.clear();
this.searchBooks();
this.searchSeries();
},
clear: function() {
this.authors = [];
this.books = [];
this.series = [];
this.booksCount = 0;
this.seriesCount = 0;
},
searchFull: function() {
if (document.getElementById("q").value) {
this.clear();
this.terms = document.getElementById("q").value.split(' ');
// TODO criteria
this.searchBooks();
if (this.q) {
this.terms = this.q.split(' ');
switch (this.which) {
case 'all':
this.searchAll();
break;
case 'books':
this.clear();
this.searchBooks();
break;
case 'series':
this.clear();
this.searchSeries();
break;
}
}
},
searchUrl: function() {
if (this.urlParams.q) {
this.terms = this.urlParams.q.split(' ');
this.searchAll();
document.getElementById("q").value = this.urlParams.q;
this.q = this.urlParams.q;
}
}
},