-
Notifications
You must be signed in to change notification settings - Fork 24
/
BookList.vue
72 lines (70 loc) · 2.2 KB
/
BookList.vue
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
<template>
<div>
<item-list ref="itemList"
searchPlaceholder="Search for book title or author"
addPrompt="Add Book"
removeHeader="Removing Book"
downloadPrompt="Download Books"
uploadPrompt="Upload Books">
<div class="table-responsive">
<table class="table table-striped">
<thead>
<tr>
<th v-if="my" style="width: 10%"></th>
<th style="width: 15%">Completed</th>
<th style="width: 8%">Kind</th>
<th style="width: 25%">Author</th>
<th>Title</th>
</tr>
</thead>
<tbody>
<tr v-for="book in items" :key="book._id">
<td v-if="my">
<div class="input-group-btn">
<router-link :to="book._id" append class="btn btn-default" title="Edit Book">
<i class="glyphicon glyphicon-pencil"></i>
</router-link>
<a @click="remove(book)" class="btn btn-default" title="Remove Book">
<i class="glyphicon glyphicon-remove"></i>
</a>
</div>
</td>
<td>{{ book.completed | date }}</td>
<td>{{ book.mode }}</td>
<td>{{ book.author }}</td>
<td>{{ book.title }}</td>
</tr>
</tbody>
</table>
</div>
</item-list>
</div>
</template>
<script>
import ItemList from '../ItemList'
import { mapGetters, mapMutations } from 'vuex'
export default {
props: ['uid', 'name'],
components: { ItemList },
computed: {
...mapGetters('items', ['my', 'items'])
},
methods: {
...mapMutations('items', ['select']),
...mapMutations('notification', ['setStatus']),
remove (book) {
this.$refs.itemList.openConfirm(book)
}
},
created () {
this.select({ hobby: 'books', uid: this.uid })
},
mounted () {
const status = this.my ? 'My books' : `${this.name}'s books`
this.setStatus(status)
},
beforeDestroy () {
this.setStatus('')
}
}
</script>