|
| 1 | +<template> |
| 2 | + <Fragment class="app-navigation-noclose separator-below"> |
| 3 | + <AppNavigationItem |
| 4 | + :title="t('notes', 'All notes')" |
| 5 | + icon="icon-recent" |
| 6 | + :class="{ active: null === selectedCategory }" |
| 7 | + @click.prevent.stop="onSelectCategory(null)" |
| 8 | + > |
| 9 | + <AppNavigationCounter slot="counter"> |
| 10 | + {{ numNotes }} |
| 11 | + </AppNavigationCounter> |
| 12 | + </AppNavigationItem> |
| 13 | + |
| 14 | + <AppNavigationItem v-for="category in categories" |
| 15 | + :key="category.name" |
| 16 | + :title="categoryTitle(category.name)" |
| 17 | + :icon="category.name === '' ? 'icon-emptyfolder' : 'icon-files'" |
| 18 | + :class="{ active: category.name === selectedCategory }" |
| 19 | + @click.prevent.stop="onSelectCategory(category.name)" |
| 20 | + > |
| 21 | + <AppNavigationCounter slot="counter"> |
| 22 | + {{ category.count }} |
| 23 | + </AppNavigationCounter> |
| 24 | + </AppNavigationItem> |
| 25 | + |
| 26 | + <AppNavigationSpacer v-if="showSpacer" class="separator-above" /> |
| 27 | + </Fragment> |
| 28 | +</template> |
| 29 | + |
| 30 | +<script> |
| 31 | +import { |
| 32 | + AppNavigationItem, |
| 33 | + AppNavigationCounter, |
| 34 | + AppNavigationSpacer, |
| 35 | +} from '@nextcloud/vue' |
| 36 | +import { Fragment } from 'vue-fragment' |
| 37 | +
|
| 38 | +import { getCategories } from '../NotesService' |
| 39 | +import { categoryLabel } from '../Util' |
| 40 | +
|
| 41 | +import store from '../store' |
| 42 | +
|
| 43 | +export default { |
| 44 | + name: 'NavigationCategoriesList', |
| 45 | +
|
| 46 | + components: { |
| 47 | + Fragment, |
| 48 | + AppNavigationItem, |
| 49 | + AppNavigationCounter, |
| 50 | + AppNavigationSpacer, |
| 51 | + }, |
| 52 | +
|
| 53 | + props: { |
| 54 | + selectedCategory: { |
| 55 | + type: String, |
| 56 | + default: null, |
| 57 | + }, |
| 58 | + showSpacer: { |
| 59 | + type: Boolean, |
| 60 | + default: false, |
| 61 | + }, |
| 62 | + }, |
| 63 | +
|
| 64 | + computed: { |
| 65 | + numNotes() { |
| 66 | + return store.getters.numNotes() |
| 67 | + }, |
| 68 | +
|
| 69 | + categories() { |
| 70 | + return getCategories(1, true) |
| 71 | + }, |
| 72 | + }, |
| 73 | +
|
| 74 | + methods: { |
| 75 | + categoryTitle(category) { |
| 76 | + return categoryLabel(category) |
| 77 | + }, |
| 78 | +
|
| 79 | + onSelectCategory(category) { |
| 80 | + this.$emit('category-selected', category) |
| 81 | + }, |
| 82 | + }, |
| 83 | +} |
| 84 | +</script> |
| 85 | +<style scoped> |
| 86 | +.separator-above { |
| 87 | + border-top: 1px solid var(--color-border); |
| 88 | +} |
| 89 | +</style> |
0 commit comments