3
3
:title =" title"
4
4
:active =" isSelected"
5
5
:to =" { name: 'note', params: { noteId: note.id.toString() } }"
6
+ @update:menuOpen =" onMenuChange"
6
7
@click =" onNoteSelected(note.id)"
7
8
>
8
9
<template #subtitle >
30
31
{{ actionFavoriteText }}
31
32
</NcActionButton >
32
33
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
+
33
59
<NcActionButton v-if =" !renaming" @click =" startRenaming" >
34
60
<PencilIcon slot =" icon" :size =" 20" />
35
61
{{ t('notes', 'Rename') }}
45
71
<PencilIcon slot =" icon" :size =" 20" />
46
72
</NcActionInput >
47
73
48
- <NcActionButton v-if =" !note.readonly" :icon =" actionDeleteIcon" @click =" onDeleteNote" >
49
- {{ t('notes', 'Delete note') }}
50
- </NcActionButton >
51
-
52
74
<NcActionSeparator />
53
75
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') }}
56
78
</NcActionButton >
57
79
</template >
58
80
</NcListItem >
62
84
import { NcListItem , NcActionButton , NcActionSeparator , NcActionInput } from ' @nextcloud/vue'
63
85
import AlertOctagonIcon from ' vue-material-design-icons/AlertOctagon.vue'
64
86
import FileDocumentOutlineIcon from ' vue-material-design-icons/FileDocumentOutline.vue'
87
+ import FolderIcon from ' vue-material-design-icons/Folder.vue'
65
88
import PencilIcon from ' vue-material-design-icons/Pencil.vue'
66
89
import StarIcon from ' vue-material-design-icons/Star.vue'
67
90
import { categoryLabel , routeIsNewNote } from ' ../Util.js'
68
91
import { showError } from ' @nextcloud/dialogs'
69
- import { setFavorite , setTitle , fetchNote , deleteNote } from ' ../NotesService.js'
92
+ import { setFavorite , setTitle , fetchNote , deleteNote , setCategory } from ' ../NotesService.js'
70
93
71
94
export default {
72
95
name: ' NoteItem' ,
73
96
74
97
components: {
75
98
AlertOctagonIcon,
76
99
FileDocumentOutlineIcon,
100
+ FolderIcon,
77
101
NcActionButton,
78
102
NcListItem,
79
103
StarIcon,
@@ -93,9 +117,11 @@ export default {
93
117
return {
94
118
loading: {
95
119
note: false ,
120
+ category: false ,
96
121
},
97
122
newTitle: ' ' ,
98
123
renaming: false ,
124
+ showCategorySelect: false ,
99
125
}
100
126
},
101
127
@@ -128,8 +154,24 @@ export default {
128
154
actionDeleteIcon () {
129
155
return ' icon-delete' + (this .loading .delete ? ' loading' : ' ' )
130
156
},
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
+ },
131
169
},
132
170
methods: {
171
+ onMenuChange (state ) {
172
+ this .actionsOpen = state
173
+ this .showCategorySelect = false
174
+ },
133
175
onNoteSelected (noteId ) {
134
176
this .$emit (' note-selected' , noteId)
135
177
},
@@ -155,6 +197,15 @@ export default {
155
197
onInputChange (event ) {
156
198
this .newTitle = event .target .value .toString ()
157
199
},
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
+ },
158
209
async onRename () {
159
210
const newTitle = this .newTitle .toString ()
160
211
if (! newTitle) {
@@ -171,7 +222,6 @@ export default {
171
222
})
172
223
.finally (() => {
173
224
this .loading .note = false
174
- this .renaming = false
175
225
})
176
226
177
227
if (routeIsNewNote (this .$route )) {
0 commit comments