Fix sort bug

This commit is contained in:
Meutel 2017-08-05 20:11:15 +02:00
parent 992918a65b
commit 297d54fdc1
2 changed files with 8 additions and 8 deletions

View File

@ -146,22 +146,22 @@ var index = new Vue({
switch (type) { switch (type) {
case 'books': case 'books':
this.cols = [ this.cols = [
{ id: 'title', name: 'Titre', sortable: true }, { id: 'title', name: 'Titre', sort: 'title' },
{ id: 'authors', name: 'Auteur(s)' }, { id: 'authors', name: 'Auteur(s)' },
{ id: 'series', name: 'Serie' } { id: 'series', name: 'Serie' }
]; ];
break; break;
case 'series': case 'series':
this.cols = [ this.cols = [
{ id: 'serie_name', name: 'Nom', sortable: true }, { id: 'serie_name', name: 'Nom', sort: 'name' },
{ id: 'count', name: 'Livre(s)' }, { id: 'count', name: 'Livre(s)' },
{ id: 'authors', name: 'Auteur(s)' } { id: 'authors', name: 'Auteur(s)' }
]; ];
break; break;
case 'authors': case 'authors':
this.cols = [ this.cols = [
{ id: 'author_name', name: 'Nom', sortable: true }, { id: 'author_name', name: 'Nom', sort: 'name' },
{ id: 'count', name: 'Livre(s)' } { id: 'count', name: 'Livre(s)' }
]; ];
break; break;
} }

View File

@ -18,8 +18,8 @@
<tbody> <tbody>
<tr> <tr>
<th v-for="col in cols"> <th v-for="col in cols">
<template v-if="col.sortable"> <template v-if="col.sort">
<a href="#" @click="sortBy(col.id)">{{ "{{" }}col.name{{ "}}" }}</a> <a href="#" @click="sortBy(col.sort)">{{ "{{" }}col.name{{ "}}" }}</a>
<span v-if="sort_by == col.id" :class="['glyphicon', { 'glyphicon-chevron-up': order_desc , 'glyphicon-chevron-down': !order_desc}]"></span> <span v-if="sort_by == col.id" :class="['glyphicon', { 'glyphicon-chevron-up': order_desc , 'glyphicon-chevron-down': !order_desc}]"></span>
</template> </template>
<template v-else>{{ "{{" }}col.name{{ "}}" }}</template> <template v-else>{{ "{{" }}col.name{{ "}}" }}</template>