Skip to content

Added option to have all categories always visible in the navigation list #839

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions l10n/de_DE.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ OC.L10N.register(
"File extension for new notes" : "Dateiendung für neue Notizen",
"Display mode for notes" : "Anzeigemodus für Notizen",
"User defined" : "Benutzerdefiniert",
"Always show all categories" : "Immer alle Kategorien anzeigen",
"Collapse categories" : "Kategorien einklappen",
"Open in edit mode" : "Im Bearbeitungsmodus öffnen",
"Open in preview mode" : "Im Vorschaumodus öffnen",
"No notes yet" : "Noch keine Notizen vorhanden",
Expand Down
2 changes: 2 additions & 0 deletions l10n/de_DE.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
"File extension for new notes" : "Dateiendung für neue Notizen",
"Display mode for notes" : "Anzeigemodus für Notizen",
"User defined" : "Benutzerdefiniert",
"Always show all categories" : "Immer alle Kategorien anzeigen",
"Collapse categories" : "Kategorien einklappen",
"Open in edit mode" : "Im Bearbeitungsmodus öffnen",
"Open in preview mode" : "Im Vorschaumodus öffnen",
"No notes yet" : "Noch keine Notizen vorhanden",
Expand Down
1 change: 1 addition & 0 deletions lib/Service/SettingsService.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ public function __construct(
return implode(DIRECTORY_SEPARATOR, $path);
},
],
'categoriesMode' => $this->getListAttrs('visible', 'collapsed'),
'noteMode' => $this->getListAttrs('edit', 'preview'),
'customSuffix' => [
'default' => '.txt',
Expand Down
14 changes: 14 additions & 0 deletions src/components/AppSettings.vue
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,16 @@
@change="onChangeSettings"
>
</div>
<div class="settings-block">
<p class="settings-hint">
<label for="categoriesMode">{{ t('notes', 'Display mode for categories') }}</label>
</p>
<select id="categoriesMode" v-model="settings.categoriesMode" @change="onChangeSettings">
<option v-for="mode in categoriesModes" :key="mode.value" :value="mode.value">
{{ mode.label }}
</option>
</select>
</div>
<div class="settings-block">
<p class="settings-hint">
<label for="noteMode">{{ t('notes', 'Display mode for notes') }}</label>
Expand Down Expand Up @@ -67,6 +77,10 @@ export default {
{ value: '.md', label: '.md' },
{ value: 'custom', label: t('notes', 'User defined') },
],
categoriesModes: [
{ value: 'visible', label: t('notes', 'Always show all categories') },
{ value: 'collapsed', label: t('notes', 'Collapse categories') },
],
noteModes: [
{ value: 'edit', label: t('notes', 'Open in edit mode') },
{ value: 'preview', label: t('notes', 'Open in preview mode') },
Expand Down
39 changes: 6 additions & 33 deletions src/components/NavigationCategoriesItem.vue
Original file line number Diff line number Diff line change
Expand Up @@ -8,46 +8,27 @@
:allow-collapse="true"
@click.prevent.stop="onToggleCategories"
>
<AppNavigationItem
:title="t('notes', 'All notes')"
icon="icon-recent"
@click.prevent.stop="onSelectCategory(null)"
>
<AppNavigationCounter slot="counter">
{{ numNotes }}
</AppNavigationCounter>
</AppNavigationItem>

<AppNavigationItem v-for="category in categories"
:key="category.name"
:title="categoryTitle(category.name)"
:icon="category.name === '' ? 'icon-emptyfolder' : 'icon-files'"
@click.prevent.stop="onSelectCategory(category.name)"
>
<AppNavigationCounter slot="counter">
{{ category.count }}
</AppNavigationCounter>
</AppNavigationItem>
<NavigationCategoriesList
:selected-category="selectedCategory"
@category-selected="onSelectCategory"
/>
</AppNavigationItem>
</template>

<script>
import {
AppNavigationItem,
AppNavigationCounter,
} from '@nextcloud/vue'

import { getCategories } from '../NotesService'
import { categoryLabel } from '../Util'

import store from '../store'
import NavigationCategoriesList from './NavigationCategoriesList.vue'

export default {
name: 'NavigationCategoriesItem',

components: {
AppNavigationItem,
AppNavigationCounter,
NavigationCategoriesList,
},

props: {
Expand All @@ -64,14 +45,6 @@ export default {
},

computed: {
numNotes() {
return store.getters.numNotes()
},

categories() {
return getCategories(1, true)
},

title() {
return this.selectedCategory === null ? this.t('notes', 'Categories') : categoryLabel(this.selectedCategory)
},
Expand Down
89 changes: 89 additions & 0 deletions src/components/NavigationCategoriesList.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
<template>
<Fragment class="app-navigation-noclose separator-below">
<AppNavigationItem
:title="t('notes', 'All notes')"
icon="icon-recent"
:class="{ active: null === selectedCategory }"
@click.prevent.stop="onSelectCategory(null)"
>
<AppNavigationCounter slot="counter">
{{ numNotes }}
</AppNavigationCounter>
</AppNavigationItem>

<AppNavigationItem 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)"
>
<AppNavigationCounter slot="counter">
{{ category.count }}
</AppNavigationCounter>
</AppNavigationItem>

<AppNavigationSpacer v-if="showSpacer" class="separator-above" />
</Fragment>
</template>

<script>
import {
AppNavigationItem,
AppNavigationCounter,
AppNavigationSpacer,
} from '@nextcloud/vue'
import { Fragment } from 'vue-fragment'

import { getCategories } from '../NotesService'
import { categoryLabel } from '../Util'

import store from '../store'

export default {
name: 'NavigationCategoriesList',

components: {
Fragment,
AppNavigationItem,
AppNavigationCounter,
AppNavigationSpacer,
},

props: {
selectedCategory: {
type: String,
default: null,
},
showSpacer: {
type: Boolean,
default: false,
},
},

computed: {
numNotes() {
return store.getters.numNotes()
},

categories() {
return getCategories(1, true)
},
},

methods: {
categoryTitle(category) {
return categoryLabel(category)
},

onSelectCategory(category) {
this.$emit('category-selected', category)
},
},
}
</script>
<style scoped>
.separator-above {
border-top: 1px solid var(--color-border);
}
</style>
15 changes: 14 additions & 1 deletion src/components/NavigationList.vue
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,18 @@
<Fragment>
<!-- collapsible categories -->
<NavigationCategoriesItem
v-if="numNotes"
v-if="numNotes && showCollapsed"
:selected-category="category"
@category-selected="$emit('category-selected', $event)"
/>

<NavigationCategoriesList
v-if="numNotes && !showCollapsed"
:selected-category="category"
:show-spacer="true"
@category-selected="$emit('category-selected', $event)"
/>

<!-- list of notes -->
<template v-for="item in noteItems">
<AppNavigationCaption v-if="category!==null && category!==item.category"
Expand Down Expand Up @@ -45,6 +52,7 @@ import { Fragment } from 'vue-fragment'

import { categoryLabel } from '../Util'
import NavigationCategoriesItem from './NavigationCategoriesItem'
import NavigationCategoriesList from './NavigationCategoriesList'
import NavigationNoteItem from './NavigationNoteItem'
import store from '../store'

Expand All @@ -58,6 +66,7 @@ export default {
AppNavigationItem,
Fragment,
NavigationCategoriesItem,
NavigationCategoriesList,
NavigationNoteItem,
},

Expand Down Expand Up @@ -86,6 +95,10 @@ export default {
},

computed: {
showCollapsed() {
return store.state.app.settings.categoriesMode === 'collapsed'
},

numNotes() {
return store.getters.numNotes()
},
Expand Down