Skip to content

Commit

Permalink
fixup! Category: Add new category button to create new folders in cur…
Browse files Browse the repository at this point in the history
…rent notes path for categories.
  • Loading branch information
juliusknorr committed Nov 7, 2023
1 parent 2134307 commit 7593066
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 35 deletions.
5 changes: 3 additions & 2 deletions src/NotesService.js
Original file line number Diff line number Diff line change
Expand Up @@ -341,7 +341,7 @@ export const setFavorite = (noteId, favorite) => {

export const findCategory = (categoryName) => {
return axios
.get(generateRemoteUrl(`dav/files/${getCurrentUser().uid}/${store.state.app.settings.notesPath}${categoryName}`))
.get(generateRemoteUrl(`dav/files/${getCurrentUser().uid}/${store.state.app.settings.notesPath}/${categoryName}`))
.then(response => {
return categoryName
})
Expand All @@ -360,10 +360,11 @@ export const createCategory = (categoryName) => {
// Axios MKCOL workaround: https://github.com/axios/axios/issues/2220
return axios
.request({
url: generateRemoteUrl(`dav/files/${getCurrentUser().uid}/${store.state.app.settings.notesPath}${categoryName}`),
url: generateRemoteUrl(`dav/files/${getCurrentUser().uid}/${store.state.app.settings.notesPath}/${categoryName}`),
method: 'MKCOL',
})
.then(response => {
store.commit('addCategory', categoryName)
return categoryName
})
.catch(err => {
Expand Down
56 changes: 23 additions & 33 deletions src/components/CategoriesList.vue
Original file line number Diff line number Diff line change
@@ -1,37 +1,5 @@
<template>
<Fragment>

<NcAppNavigationItem
:title="title"
class="app-navigation-noclose separator-below"
:class="{ 'category-header': selectedCategory !== null }"
:open.sync="open"
:menu-open.sync="menuOpen"
:allow-collapse="true"
@click.prevent.stop="onToggleCategories"
>
<template #menu-icon>
<AddIcon :size="20" @click="onToggleNewCategory" />
</template>
<template #actions>
<NcActionText>
<template #icon>
<ErrorIcon v-if="createCategoryError" :size="20" />
<AddIcon v-else-if="!createCategoryError" :size="20" />
</template>
{{ createCategoryError ? createCategoryError : t('notes', 'Create a new category') }}
</NcActionText>
<NcActionInput
icon=""
:value="t('notes', 'Category name')"
@submit.prevent.stop="createNewCategory"
>
<template #icon>
<FolderIcon :size="20" />
</template>
</NcActionInput>
</template>

<FolderIcon slot="icon" :size="20" />
<NcAppNavigationItem
:title="t('notes', 'All notes')"
Expand All @@ -44,7 +12,29 @@
</NcAppNavigationCounter>
</NcAppNavigationItem>

<NcAppNavigationCaption :title="t('notes', 'Categories')" />
<NcAppNavigationCaption :title="t('notes', 'Categories')">
<template #actionsTriggerIcon>
<AddIcon slot="icon" :size="20" />
</template>
<template #actions>
<NcActionText>
<template #icon>
<ErrorIcon v-if="createCategoryError" :size="20" />
<AddIcon v-else-if="!createCategoryError" :size="20" />
</template>
{{ createCategoryError ? createCategoryError : t('notes', 'Create a new category') }}
</NcActionText>
<NcActionInput
icon=""
:value="t('notes', 'Category name')"
@submit.prevent.stop="createNewCategory"
>
<template #icon>
<FolderIcon :size="20" />
</template>
</NcActionInput>
</template>
</NcAppNavigationCaption>

<NcAppNavigationItem v-for="category in categories"
:key="category.name"
Expand Down
4 changes: 4 additions & 0 deletions src/store/notes.js
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,10 @@ const mutations = {
state.categories = categories
},

addCategory(state, category) {
state.categories.push(category)
},

setSelectedCategory(state, category) {
state.selectedCategory = category
},
Expand Down

0 comments on commit 7593066

Please sign in to comment.