33 :title =" title"
44 :active =" isSelected"
55 :to =" { name: 'note', params: { noteId: note.id.toString() } }"
6+ @update:menuOpen =" onMenuChange"
67 @click =" onNoteSelected(note.id)"
78 >
89 <template #subtitle >
3031 {{ actionFavoriteText }}
3132 </NcActionButton >
3233
34+ <NcActionButton v-if =" !showCategorySelect" @click =" showCategorySelect = true" >
35+ <template #icon >
36+ <FolderIcon :size =" 20" />
37+ </template >
38+ {{ categoryTitle }}
39+ </NcActionButton >
40+ <NcActionInput
41+ v-else
42+ :value =" note.category"
43+ type =" multiselect"
44+ label =" label"
45+ track-by =" id"
46+ :multiple =" false"
47+ :options =" categories"
48+ :disabled =" loading.category"
49+ :taggable =" true"
50+ @input =" onCategoryChange"
51+ @search-change =" onCategoryChange"
52+ >
53+ <template #icon >
54+ <FolderIcon :size =" 20" />
55+ </template >
56+ {{ t('notes', 'Change category') }}
57+ </NcActionInput >
58+
3359 <NcActionButton v-if =" !renaming" @click =" startRenaming" >
3460 <PencilIcon slot =" icon" :size =" 20" />
3561 {{ t('notes', 'Rename') }}
4571 <PencilIcon slot =" icon" :size =" 20" />
4672 </NcActionInput >
4773
48- <NcActionButton v-if =" !note.readonly" :icon =" actionDeleteIcon" @click =" onDeleteNote" >
49- {{ t('notes', 'Delete note') }}
50- </NcActionButton >
51-
5274 <NcActionSeparator />
5375
54- <NcActionButton icon = " icon-files-dark " @click =" onCategorySelected " >
55- {{ actionCategoryText }}
76+ <NcActionButton v-if = " !note.readonly " : icon= " actionDeleteIcon " @click =" onDeleteNote " >
77+ {{ t('notes', 'Delete note') }}
5678 </NcActionButton >
5779 </template >
5880 </NcListItem >
6284import { NcListItem , NcActionButton , NcActionSeparator , NcActionInput } from ' @nextcloud/vue'
6385import AlertOctagonIcon from ' vue-material-design-icons/AlertOctagon.vue'
6486import FileDocumentOutlineIcon from ' vue-material-design-icons/FileDocumentOutline.vue'
87+ import FolderIcon from ' vue-material-design-icons/Folder.vue'
6588import PencilIcon from ' vue-material-design-icons/Pencil.vue'
6689import StarIcon from ' vue-material-design-icons/Star.vue'
6790import { categoryLabel , routeIsNewNote } from ' ../Util.js'
6891import { showError } from ' @nextcloud/dialogs'
69- import { setFavorite , setTitle , fetchNote , deleteNote } from ' ../NotesService.js'
92+ import { setFavorite , setTitle , fetchNote , deleteNote , setCategory } from ' ../NotesService.js'
7093
7194export default {
7295 name: ' NoteItem' ,
7396
7497 components: {
7598 AlertOctagonIcon,
7699 FileDocumentOutlineIcon,
100+ FolderIcon,
77101 NcActionButton,
78102 NcListItem,
79103 StarIcon,
@@ -93,9 +117,11 @@ export default {
93117 return {
94118 loading: {
95119 note: false ,
120+ category: false ,
96121 },
97122 newTitle: ' ' ,
98123 renaming: false ,
124+ showCategorySelect: false ,
99125 }
100126 },
101127
@@ -128,8 +154,24 @@ export default {
128154 actionDeleteIcon () {
129155 return ' icon-delete' + (this .loading .delete ? ' loading' : ' ' )
130156 },
157+ categories () {
158+ return [
159+ {
160+ id: ' ' ,
161+ label: categoryLabel (' ' ),
162+ },
163+ ... this .$store .getters .getCategories (0 , false ).map ((category ) => ({
164+ id: category,
165+ label: categoryLabel (category),
166+ })),
167+ ]
168+ },
131169 },
132170 methods: {
171+ onMenuChange (state ) {
172+ this .actionsOpen = state
173+ this .showCategorySelect = false
174+ },
133175 onNoteSelected (noteId ) {
134176 this .$emit (' note-selected' , noteId)
135177 },
@@ -155,6 +197,15 @@ export default {
155197 onInputChange (event ) {
156198 this .newTitle = event .target .value .toString ()
157199 },
200+ async onCategoryChange (result ) {
201+ this .showCategorySelect = false
202+ const category = result? .id ?? result? .label ?? null
203+ if (category !== null && this .note .category !== category) {
204+ this .loading .category = true
205+ await setCategory (this .note .id , category)
206+ this .loading .category = false
207+ }
208+ },
158209 async onRename () {
159210 const newTitle = this .newTitle .toString ()
160211 if (! newTitle) {
@@ -171,7 +222,6 @@ export default {
171222 })
172223 .finally (() => {
173224 this .loading .note = false
174- this .renaming = false
175225 })
176226
177227 if (routeIsNewNote (this .$route )) {
0 commit comments