From 2f1e2a70fd08da3bae644c1bef3b66653b89eb00 Mon Sep 17 00:00:00 2001 From: Meutel Date: Sat, 5 Aug 2017 16:44:05 +0200 Subject: [PATCH] Vue components books list --- assets/js/index.js | 119 +++++++++++++++++++++++++++++++++++++++++-- bouquins/bouquins.go | 66 +++++++++++++++--------- templates/index.html | 30 ++++++----- 3 files changed, 171 insertions(+), 44 deletions(-) diff --git a/assets/js/index.js b/assets/js/index.js index bfbd0b4..c21301e 100644 --- a/assets/js/index.js +++ b/assets/js/index.js @@ -1,11 +1,62 @@ Vue.component('results', { template: '#results-template', - props: ['results', 'cols'], + props: ['results', 'cols','sort_by','order_desc'], methods: { sortBy: function(col) { } } }); +Vue.component('result-cell', { + render: function(h) { + return h('td', this.cellContent(h)); + }, + props: ['item', 'col'], + methods: { + bookUrl: function(id) { + return '/books/' + id; + }, + authorUrl: function(id) { + return '/authors/' + id; + }, + seriesUrl: function(id) { + return '/series/' + id; + }, + link: function(h, icon, text, url) { + return [ + h('span',{ attrs: { class: 'glyphicon glyphicon-'+icon } },''), + ' ', + h('a', { attrs: { href: url } }, text) + ]; + }, + badge: function(h, num) { + return h('span', { attrs: { class: 'badge' } }, num); + }, + cellContent: function(h) { + switch (this.col.id) { + case 'title': + return this.link(h, 'book', this.item.title, this.bookUrl(this.item.id)); + case 'authors': + var elts = []; + var authors = this.item.authors; + for (i=0;i
- +