Search series/all
This commit is contained in:
parent
0587faf352
commit
d235672bfe
24
search.html
24
search.html
@ -31,29 +31,29 @@
|
|||||||
<h3>Recherche</h3>
|
<h3>Recherche</h3>
|
||||||
</div>
|
</div>
|
||||||
<div class="panel-body">
|
<div class="panel-body">
|
||||||
<form>
|
<form id="searchForm">
|
||||||
<div class="form-group">
|
<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>
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label>Parmi</label><br/>
|
<label>Parmi</label><br/>
|
||||||
<label class="radio-inline">
|
<label class="radio-inline">
|
||||||
<input type="radio" name="which" value="books" checked> livres
|
<input type="radio" value="books" v-model="which"> livres
|
||||||
</label>
|
</label>
|
||||||
<label class="radio-inline">
|
<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>
|
||||||
<label class="radio-inline">
|
<label class="radio-inline">
|
||||||
<input type="radio" name="which" value="series" disabled> series
|
<input type="radio" value="series" v-model="which"> series
|
||||||
</label>
|
</label>
|
||||||
<label class="radio-inline">
|
<label class="radio-inline">
|
||||||
<input type="radio" name="which" value="all" disabled> tous
|
<input type="radio" value="all" v-model="which"> tous
|
||||||
</label>
|
</label>
|
||||||
</div>
|
</div>
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<div class="checkbox">
|
<div class="checkbox">
|
||||||
<label>
|
<label>
|
||||||
<input type="checkbox" id="all" disabled> Tous les mots
|
<input type="checkbox" v-model="all" disabled> Tous les mots
|
||||||
</label>
|
</label>
|
||||||
<p class="help-block">Cocher pour rechercher les élements contenant tous les mots saisis</p>
|
<p class="help-block">Cocher pour rechercher les élements contenant tous les mots saisis</p>
|
||||||
</div>
|
</div>
|
||||||
@ -72,6 +72,16 @@
|
|||||||
<li v-if="books.length < booksCount" class="list-unstyled">...</li>
|
<li v-if="books.length < booksCount" class="list-unstyled">...</li>
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</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>
|
</div>
|
||||||
<script src="js/vue.min.js"></script>
|
<script src="js/vue.min.js"></script>
|
||||||
<script src="js/search.min.js"></script>
|
<script src="js/search.min.js"></script>
|
||||||
|
33
search.js
33
search.js
@ -5,7 +5,11 @@ var app = new Vue({
|
|||||||
authors: [],
|
authors: [],
|
||||||
books: [],
|
books: [],
|
||||||
series: [],
|
series: [],
|
||||||
booksCount: 0
|
booksCount: 0,
|
||||||
|
seriesCount: 0,
|
||||||
|
q: '',
|
||||||
|
which: 'all',
|
||||||
|
all: false
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
urlParse: function() {
|
urlParse: function() {
|
||||||
@ -68,29 +72,48 @@ var app = new Vue({
|
|||||||
searchBooks: function() {
|
searchBooks: function() {
|
||||||
this.sendQuery(this.searchParams('cgi-bin/bouquins/books'), this.stdError, this.searchBooksSuccess);
|
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() {
|
searchAll: function() {
|
||||||
this.clear();
|
this.clear();
|
||||||
this.searchBooks();
|
this.searchBooks();
|
||||||
|
this.searchSeries();
|
||||||
},
|
},
|
||||||
clear: function() {
|
clear: function() {
|
||||||
this.authors = [];
|
this.authors = [];
|
||||||
this.books = [];
|
this.books = [];
|
||||||
this.series = [];
|
this.series = [];
|
||||||
this.booksCount = 0;
|
this.booksCount = 0;
|
||||||
|
this.seriesCount = 0;
|
||||||
},
|
},
|
||||||
searchFull: function() {
|
searchFull: function() {
|
||||||
if (document.getElementById("q").value) {
|
if (this.q) {
|
||||||
|
this.terms = this.q.split(' ');
|
||||||
|
switch (this.which) {
|
||||||
|
case 'all':
|
||||||
|
this.searchAll();
|
||||||
|
break;
|
||||||
|
case 'books':
|
||||||
this.clear();
|
this.clear();
|
||||||
this.terms = document.getElementById("q").value.split(' ');
|
|
||||||
// TODO criteria
|
|
||||||
this.searchBooks();
|
this.searchBooks();
|
||||||
|
break;
|
||||||
|
case 'series':
|
||||||
|
this.clear();
|
||||||
|
this.searchSeries();
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
searchUrl: function() {
|
searchUrl: function() {
|
||||||
if (this.urlParams.q) {
|
if (this.urlParams.q) {
|
||||||
this.terms = this.urlParams.q.split(' ');
|
this.terms = this.urlParams.q.split(' ');
|
||||||
this.searchAll();
|
this.searchAll();
|
||||||
document.getElementById("q").value = this.urlParams.q;
|
this.q = this.urlParams.q;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
Loading…
Reference in New Issue
Block a user