-
Notifications
You must be signed in to change notification settings - Fork 133
/
CategoriesList.vue
90 lines (78 loc) · 2.16 KB
/
CategoriesList.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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
<template>
<Fragment>
<NcAppNavigationItem
:title="t('notes', 'All notes')"
:class="{ active: selectedCategory === null }"
@click.prevent.stop="onSelectCategory(null)"
>
<HistoryIcon slot="icon" :size="20" />
<NcAppNavigationCounter slot="counter">
{{ numNotes }}
</NcAppNavigationCounter>
</NcAppNavigationItem>
<NcAppNavigationCaption :title="t('notes', 'Categories')" />
<NcAppNavigationItem v-for="category in categories"
:key="category.name"
:title="categoryTitle(category.name)"
:icon="category.name === '' ? 'icon-emptyfolder' : 'icon-files'"
:class="{ active: category.name === selectedCategory }"
@click.prevent.stop="onSelectCategory(category.name)"
>
<FolderOutlineIcon v-if="category.name === ''" slot="icon" :size="20" />
<FolderIcon v-else slot="icon" :size="20" />
<NcAppNavigationCounter slot="counter">
{{ category.count }}
</NcAppNavigationCounter>
</NcAppNavigationItem>
</Fragment>
</template>
<script>
import {
NcAppNavigationItem,
NcAppNavigationCaption,
NcAppNavigationCounter,
} from '@nextcloud/vue'
import { Fragment } from 'vue-fragment'
import FolderIcon from 'vue-material-design-icons/Folder.vue'
import FolderOutlineIcon from 'vue-material-design-icons/FolderOutline.vue'
import HistoryIcon from 'vue-material-design-icons/History.vue'
import { getCategories } from '../NotesService.js'
import { categoryLabel } from '../Util.js'
import store from '../store.js'
export default {
name: 'CategoriesList',
components: {
Fragment,
NcAppNavigationItem,
NcAppNavigationCaption,
NcAppNavigationCounter,
FolderIcon,
FolderOutlineIcon,
HistoryIcon,
},
computed: {
numNotes() {
return store.getters.numNotes()
},
categories() {
return getCategories(1, true)
},
selectedCategory() {
return store.getters.getSelectedCategory()
},
},
methods: {
categoryTitle(category) {
return categoryLabel(category)
},
onSelectCategory(category) {
store.commit('setSelectedCategory', category)
},
},
}
</script>
<style scoped>
.app-navigation-entry-wrapper.active:deep(.app-navigation-entry) {
background-color: var(--color-primary-element-light) !important;
}
</style>