Skip to content
Open
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
43 changes: 1 addition & 42 deletions src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,7 @@
<NcContent v-else appName="notes" :contentClass="{loading: loading.notes}">
<NcAppNavigation :class="{loading: loading.notes, 'icon-error': error}">
<template #list>
<NcAppNavigationNew
v-show="!loading.notes && !error"
:text="t('notes', 'New category')"
@click="onNewCategory"
@dragover="onNewCategoryDragOver"
@drop="onNewCategoryDrop"
>
<template #icon>
<FolderPlusIcon :size="20" />
</template>
</NcAppNavigationNew>
<CategoriesList :loading="loading.notes" />
<CategoriesList :loading="loading.notes" :disabled="!!error" />
</template>

<template #footer>
Expand Down Expand Up @@ -51,15 +40,12 @@

<script>
import { showSuccess, TOAST_PERMANENT_TIMEOUT, TOAST_UNDO_TIMEOUT } from '@nextcloud/dialogs'
import { emit } from '@nextcloud/event-bus'
import { loadState } from '@nextcloud/initial-state'
import NcAppContent from '@nextcloud/vue/components/NcAppContent'
import NcAppNavigation from '@nextcloud/vue/components/NcAppNavigation'
import NcAppNavigationItem from '@nextcloud/vue/components/NcAppNavigationItem'
import NcAppNavigationNew from '@nextcloud/vue/components/NcAppNavigationNew'
import NcContent from '@nextcloud/vue/components/NcContent'
import CogIcon from 'vue-material-design-icons/CogOutline.vue'
import FolderPlusIcon from 'vue-material-design-icons/FolderPlusOutline.vue'
import AppSettings from './components/AppSettings.vue'
import CategoriesList from './components/CategoriesList.vue'
import EditorHint from './components/Modal/EditorHint.vue'
Expand All @@ -68,7 +54,6 @@ import { config } from './config.js'
import logger from './Logger.js'
import { fetchNotes, noteExists, undoDeleteNote } from './NotesService.js'
import store from './store.js'
import { getDraggedNoteId, isNoteDrag } from './Util.js'

import '@nextcloud/dialogs/style.css'

Expand All @@ -82,11 +67,9 @@ export default {
EditorHint,
NcAppContent,
NcAppNavigation,
NcAppNavigationNew,
NcAppNavigationItem,
NcContent,
NoteShareSidebar,
FolderPlusIcon,
},

data() {
Expand Down Expand Up @@ -235,30 +218,6 @@ export default {
this.settingsVisible = true
},

onNewCategory() {
emit('notes:category:new')
},

onNewCategoryDragOver(event) {
if (!isNoteDrag(event)) {
return
}
event.preventDefault()
if (event.dataTransfer) {
event.dataTransfer.dropEffect = 'move'
}
},

onNewCategoryDrop(event) {
const noteId = getDraggedNoteId(event, (noteId) => store.notes.getNote(noteId))
if (noteId === null) {
return
}
event.preventDefault()
event.stopPropagation()
emit('notes:category:new', { noteId })
},

onNoteDeleted(note) {
this.deletedNotes.push(note)
this.clearUndoTimer()
Expand Down
74 changes: 73 additions & 1 deletion src/components/CategoriesList.vue
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,35 @@
</template>
</NcAppNavigationItem>

<NcAppNavigationCaption v-show="!loading" :name="t('notes', 'Categories')" />
<!--
The "New category" action sits inline next to the caption. Dropping a
note anywhere on the caption row also starts a new category with that
note in it, which is what the former full-width button offered — the
row is a far easier drop target than the icon alone.
-->
<NcAppNavigationCaption v-if="!disabled"
v-show="!loading"
:name="t('notes', 'Categories')"
:inline="1"
:class="{ 'drop-over-caption': dragOverNewCategory }"
@dragover="onNewCategoryDragOver($event)"
Comment on lines +36 to +41
@dragleave="onNewCategoryDragLeave($event)"
@drop="onNewCategoryDrop($event)"
>
<template #actions>
<!--
Rendered inline by NcActions, so it becomes a single icon button
whose accessible name and tooltip are the action text.
-->
<NcActionButton @click="startNewCategory()">
<template #icon>
<FolderPlusIcon :size="20" />
</template>
{{ t('notes', 'New category') }}
</NcActionButton>
</template>
</NcAppNavigationCaption>
<NcAppNavigationCaption v-else v-show="!loading" :name="t('notes', 'Categories')" />
Comment on lines +36 to +58

<NcAppNavigationItem
v-if="newCategoryDraft"
Expand Down Expand Up @@ -106,6 +134,7 @@ import NcCounterBubble from '@nextcloud/vue/components/NcCounterBubble'
import DeleteIcon from 'vue-material-design-icons/Delete.vue'
import FolderIcon from 'vue-material-design-icons/Folder.vue'
import FolderOutlineIcon from 'vue-material-design-icons/FolderOutline.vue'
import FolderPlusIcon from 'vue-material-design-icons/FolderPlusOutline.vue'
import HistoryIcon from 'vue-material-design-icons/History.vue'
import { deleteCategory as deleteCategoryRequest, getCategories, renameCategory as renameCategoryRequest, setCategory } from '../NotesService.js'
import store from '../store.js'
Expand All @@ -122,16 +151,20 @@ export default {
NcCounterBubble,
FolderIcon,
FolderOutlineIcon,
FolderPlusIcon,
HistoryIcon,
},

props: {
loading: Boolean,
/** Hides the "New category" action, e.g. while the note list failed to load */
disabled: Boolean,
},
Comment on lines 158 to 162

data() {
return {
dragOverCategory: null,
dragOverNewCategory: false,
dragOverAllNotes: false,
newCategoryDraft: false,
newCategoryMonitor: null,
Expand Down Expand Up @@ -179,6 +212,37 @@ export default {
})
},

onNewCategoryDragOver(event) {
if (!isNoteDrag(event)) {
return
}
event.preventDefault()
if (event.dataTransfer) {
event.dataTransfer.dropEffect = 'move'
}
this.dragOverNewCategory = true
},

onNewCategoryDragLeave(event) {
// dragleave also fires when moving onto a child element, so ignore
// events that are still inside the caption row
if (event.currentTarget?.contains(event.relatedTarget)) {
return
}
this.dragOverNewCategory = false
},

onNewCategoryDrop(event) {
this.dragOverNewCategory = false
const noteId = getDraggedNoteId(event, (noteId) => store.notes.getNote(noteId))
if (noteId === null) {
return
}
event.preventDefault()
event.stopPropagation()
this.startNewCategory({ noteId })
},

stopNewCategoryMonitor() {
if (this.newCategoryMonitor) {
cancelAnimationFrame(this.newCategoryMonitor)
Expand Down Expand Up @@ -459,6 +523,14 @@ export default {
outline-offset: -2px;
}

/* The caption is not an .app-navigation-entry, so it needs its own drop hint. */
.app-navigation-caption.drop-over-caption {
background-color: var(--color-primary-element-light);
outline: 2px dashed var(--color-primary-element);
outline-offset: -2px;
border-radius: var(--border-radius-element, var(--border-radius-large));
}

.app-navigation-entry-wrapper.category-no-actions:deep(.app-navigation-entry__counter-wrapper) {
margin-inline-end: calc(var(--default-grid-baseline) * 2 + var(--default-clickable-area));
}
Expand Down
Loading