@conduction/nextcloud-vue 0.1.0-beta.4 → 0.1.0-beta.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (68) hide show
  1. package/dist/nextcloud-vue.cjs +67614 -0
  2. package/dist/nextcloud-vue.cjs.js +9554 -8980
  3. package/dist/nextcloud-vue.cjs.js.map +1 -1
  4. package/dist/nextcloud-vue.cjs.map +1 -0
  5. package/dist/nextcloud-vue.css +1231 -1231
  6. package/dist/nextcloud-vue.esm.js +9554 -8980
  7. package/dist/nextcloud-vue.esm.js.map +1 -1
  8. package/package.json +11 -4
  9. package/src/components/CnActionsBar/CnActionsBar.vue +235 -235
  10. package/src/components/CnAdvancedFormDialog/CnAdvancedFormDialog.vue +579 -579
  11. package/src/components/CnAdvancedFormDialog/CnDataTab.vue +217 -217
  12. package/src/components/CnAdvancedFormDialog/CnMetadataTab.vue +121 -121
  13. package/src/components/CnAdvancedFormDialog/CnPropertiesTab.vue +418 -418
  14. package/src/components/CnAdvancedFormDialog/CnPropertyValueCell.vue +247 -247
  15. package/src/components/CnCardGrid/CnCardGrid.vue +152 -152
  16. package/src/components/CnCellRenderer/CnCellRenderer.vue +132 -132
  17. package/src/components/CnChartWidget/CnChartWidget.vue +320 -320
  18. package/src/components/CnConfigurationCard/CnConfigurationCard.vue +77 -77
  19. package/src/components/CnCopyDialog/CnCopyDialog.vue +250 -250
  20. package/src/components/CnDashboardGrid/CnDashboardGrid.vue +225 -225
  21. package/src/components/CnDashboardPage/CnDashboardPage.vue +390 -390
  22. package/src/components/CnDataTable/CnDataTable.vue +349 -349
  23. package/src/components/CnDeleteDialog/CnDeleteDialog.vue +170 -170
  24. package/src/components/CnDetailCard/CnDetailCard.vue +214 -214
  25. package/src/components/CnDetailPage/CnDetailPage.vue +285 -281
  26. package/src/components/CnFacetSidebar/CnFacetSidebar.vue +231 -231
  27. package/src/components/CnFilterBar/CnFilterBar.vue +152 -152
  28. package/src/components/CnFormDialog/CnFormDialog.vue +302 -11
  29. package/src/components/CnIcon/CnIcon.vue +89 -89
  30. package/src/components/CnIndexPage/CnIndexPage.vue +884 -874
  31. package/src/components/CnIndexSidebar/CnIndexSidebar.vue +503 -503
  32. package/src/components/CnItemCard/CnItemCard.vue +132 -132
  33. package/src/components/CnKpiGrid/CnKpiGrid.vue +89 -89
  34. package/src/components/CnMassActionBar/CnMassActionBar.vue +160 -160
  35. package/src/components/CnMassCopyDialog/CnMassCopyDialog.vue +320 -320
  36. package/src/components/CnMassDeleteDialog/CnMassDeleteDialog.vue +238 -238
  37. package/src/components/CnMassExportDialog/CnMassExportDialog.vue +190 -190
  38. package/src/components/CnMassImportDialog/CnMassImportDialog.vue +491 -491
  39. package/src/components/CnNoteCard/CnNoteCard.vue +149 -149
  40. package/src/components/CnNotesCard/CnNotesCard.vue +413 -413
  41. package/src/components/CnObjectCard/CnObjectCard.vue +292 -292
  42. package/src/components/CnObjectSidebar/CnObjectSidebar.vue +876 -876
  43. package/src/components/CnPageHeader/CnPageHeader.vue +57 -57
  44. package/src/components/CnPagination/CnPagination.vue +252 -252
  45. package/src/components/CnRegisterMapping/CnRegisterMapping.vue +792 -792
  46. package/src/components/CnRowActions/CnRowActions.vue +95 -73
  47. package/src/components/CnSchemaFormDialog/CnSchemaConfigurationTab.vue +226 -226
  48. package/src/components/CnSchemaFormDialog/CnSchemaFormDialog.vue +787 -787
  49. package/src/components/CnSchemaFormDialog/CnSchemaPropertiesTab.vue +305 -305
  50. package/src/components/CnSchemaFormDialog/CnSchemaPropertyActions.vue +1398 -1398
  51. package/src/components/CnSchemaFormDialog/CnSchemaSecurityTab.vue +236 -236
  52. package/src/components/CnSettingsCard/CnSettingsCard.vue +92 -92
  53. package/src/components/CnSettingsSection/CnSettingsSection.vue +266 -266
  54. package/src/components/CnStatsBlock/CnStatsBlock.vue +420 -420
  55. package/src/components/CnStatusBadge/CnStatusBadge.vue +77 -77
  56. package/src/components/CnTabbedFormDialog/CnTabbedFormDialog.vue +540 -540
  57. package/src/components/CnTasksCard/CnTasksCard.vue +373 -373
  58. package/src/components/CnTileWidget/CnTileWidget.vue +159 -159
  59. package/src/components/CnTimelineStages/CnTimelineStages.vue +292 -292
  60. package/src/components/CnUserActionMenu/CnUserActionMenu.vue +435 -435
  61. package/src/components/CnVersionInfoCard/CnVersionInfoCard.vue +312 -312
  62. package/src/components/CnWidgetRenderer/CnWidgetRenderer.vue +180 -180
  63. package/src/components/CnWidgetWrapper/CnWidgetWrapper.vue +211 -211
  64. package/src/index.js +1 -1
  65. package/src/types/notification.d.ts +13 -13
  66. package/src/types/organisation.d.ts +15 -15
  67. package/src/types/schema.d.ts +13 -13
  68. package/src/types/task.d.ts +6 -6
@@ -1,413 +1,413 @@
1
- <!--
2
- CnNotesCard — Inline notes card for detail pages.
3
-
4
- Displays up to 5 recent notes with author, content, and timestamp.
5
- Includes an add-note form and integrates CnUserActionMenu on author names.
6
- Wraps CnDetailCard for consistent styling.
7
- -->
8
- <template>
9
- <CnDetailCard :title="titleLabel" :icon="CommentTextOutline" :collapsible="collapsible">
10
- <div class="cn-notes-card">
11
- <!-- Add note input -->
12
- <div class="cn-notes-card__add-form">
13
- <textarea
14
- v-model="newNoteText"
15
- class="cn-notes-card__textarea"
16
- :placeholder="addNotePlaceholder"
17
- rows="2"
18
- @keydown.enter.ctrl.prevent="submitNote"
19
- @keydown.enter.meta.prevent="submitNote" />
20
- <NcButton
21
- type="primary"
22
- :disabled="!newNoteText.trim() || noteSaving"
23
- @click="submitNote">
24
- <template #icon>
25
- <Send :size="20" />
26
- </template>
27
- {{ addNoteLabel }}
28
- </NcButton>
29
- </div>
30
-
31
- <!-- Loading state -->
32
- <NcLoadingIcon v-if="loading" />
33
-
34
- <!-- Empty state -->
35
- <div v-else-if="allNotes.length === 0" class="cn-notes-card__empty">
36
- {{ noNotesLabel }}
37
- </div>
38
-
39
- <!-- Notes list (last 5) -->
40
- <div v-else class="cn-notes-card__list">
41
- <div
42
- v-for="note in displayedNotes"
43
- :key="note.id"
44
- class="cn-notes-card__note">
45
- <div class="cn-notes-card__note-header">
46
- <CnUserActionMenu
47
- v-if="!isCurrentUser(note)"
48
- :user-id="getNoteAuthorId(note)"
49
- :display-name="getNoteAuthorName(note)">
50
- <strong class="cn-notes-card__author">{{ getNoteAuthorName(note) }}</strong>
51
- </CnUserActionMenu>
52
- <strong v-else class="cn-notes-card__author cn-notes-card__author--self">
53
- {{ getNoteAuthorName(note) }}
54
- </strong>
55
- <span class="cn-notes-card__time">{{ formatDate(note.creationDateTime || note.created) }}</span>
56
- </div>
57
- <p class="cn-notes-card__body">{{ note.message || note.content }}</p>
58
- <NcButton
59
- v-if="canDeleteNote(note)"
60
- type="tertiary-no-background"
61
- class="cn-notes-card__delete-btn"
62
- :aria-label="deleteLabel"
63
- @click="confirmDelete(note)">
64
- <template #icon>
65
- <Delete :size="16" />
66
- </template>
67
- </NcButton>
68
- </div>
69
- </div>
70
- </div>
71
-
72
- <!-- Footer: "Show all" link -->
73
- <template v-if="allNotes.length > maxDisplay" #footer>
74
- <button
75
- class="cn-notes-card__show-all"
76
- @click="$emit('show-all')">
77
- {{ showAllLabel }} ({{ allNotes.length }})
78
- </button>
79
- </template>
80
- </CnDetailCard>
81
- </template>
82
-
83
- <script>
84
- import { NcButton, NcLoadingIcon } from '@nextcloud/vue'
85
- import CommentTextOutline from 'vue-material-design-icons/CommentTextOutline.vue'
86
- import Send from 'vue-material-design-icons/Send.vue'
87
- import Delete from 'vue-material-design-icons/Delete.vue'
88
-
89
- import CnDetailCard from '../CnDetailCard/CnDetailCard.vue'
90
- import CnUserActionMenu from '../CnUserActionMenu/CnUserActionMenu.vue'
91
- import { buildHeaders } from '../../utils/index.js'
92
-
93
- /**
94
- * CnNotesCard — Inline notes widget for detail pages.
95
- *
96
- * Shows up to 5 recent notes with add/delete functionality.
97
- * Integrates CnUserActionMenu on author names for quick communication.
98
- *
99
- * @example Basic usage
100
- * <CnNotesCard
101
- * register-id="uuid-register"
102
- * schema-id="uuid-schema"
103
- * object-id="uuid-object" />
104
- *
105
- * @example With sidebar sync
106
- * <CnNotesCard
107
- * register-id="reg"
108
- * schema-id="schema"
109
- * object-id="obj"
110
- * @note-added="refreshNotes"
111
- * @note-deleted="refreshNotes"
112
- * @show-all="openSidebarNotesTab" />
113
- */
114
- export default {
115
- name: 'CnNotesCard',
116
-
117
- components: {
118
- CnDetailCard,
119
- CnUserActionMenu,
120
- NcButton,
121
- NcLoadingIcon,
122
- Send,
123
- Delete,
124
- },
125
-
126
- props: {
127
- /** OpenRegister register ID */
128
- registerId: {
129
- type: String,
130
- required: true,
131
- },
132
- /** OpenRegister schema ID */
133
- schemaId: {
134
- type: String,
135
- required: true,
136
- },
137
- /** Object UUID */
138
- objectId: {
139
- type: String,
140
- required: true,
141
- },
142
- /** Base API URL for OpenRegister */
143
- apiBase: {
144
- type: String,
145
- default: '/apps/openregister/api',
146
- },
147
- /** Maximum number of notes to display */
148
- maxDisplay: {
149
- type: Number,
150
- default: 5,
151
- },
152
- /** Whether the card is collapsible */
153
- collapsible: {
154
- type: Boolean,
155
- default: false,
156
- },
157
-
158
- // --- Pre-translated labels ---
159
- titleLabel: { type: String, default: 'Notes' },
160
- addNoteLabel: { type: String, default: 'Add note' },
161
- addNotePlaceholder: { type: String, default: 'Write a note...' },
162
- noNotesLabel: { type: String, default: 'No notes yet' },
163
- showAllLabel: { type: String, default: 'Show all' },
164
- deleteLabel: { type: String, default: 'Delete note' },
165
- },
166
-
167
- emits: ['note-added', 'note-deleted', 'show-all'],
168
-
169
- data() {
170
- return {
171
- CommentTextOutline,
172
- allNotes: [],
173
- loading: false,
174
- newNoteText: '',
175
- noteSaving: false,
176
- deleteConfirmId: null,
177
- }
178
- },
179
-
180
- computed: {
181
- displayedNotes() {
182
- // Reverse chronological, limited to maxDisplay
183
- const sorted = [...this.allNotes].sort((a, b) => {
184
- const dateA = new Date(a.creationDateTime || a.created || 0)
185
- const dateB = new Date(b.creationDateTime || b.created || 0)
186
- return dateB - dateA
187
- })
188
- return sorted.slice(0, this.maxDisplay)
189
- },
190
- },
191
-
192
- watch: {
193
- objectId: {
194
- immediate: true,
195
- handler(newId) {
196
- if (newId && this.registerId && this.schemaId) {
197
- this.fetchNotes()
198
- }
199
- },
200
- },
201
- },
202
-
203
- methods: {
204
- getNoteAuthorId(note) {
205
- return note.actorId || note.author || ''
206
- },
207
-
208
- getNoteAuthorName(note) {
209
- return note.actorDisplayName || note.author || 'Unknown'
210
- },
211
-
212
- isCurrentUser(note) {
213
- const authorId = this.getNoteAuthorId(note)
214
- const currentUser = typeof OC !== 'undefined' ? OC?.currentUser : null
215
- return authorId === currentUser
216
- },
217
-
218
- canDeleteNote(note) {
219
- return this.isCurrentUser(note)
220
- },
221
-
222
- async fetchNotes() {
223
- if (!this.registerId || !this.schemaId || !this.objectId) return
224
- this.loading = true
225
- try {
226
- const url = `${this.apiBase}/objects/${this.registerId}/${this.schemaId}/${this.objectId}/notes`
227
- const response = await fetch(url, { headers: buildHeaders() })
228
- if (response.ok) {
229
- const data = await response.json()
230
- this.allNotes = data.results || data || []
231
- }
232
- } catch (err) {
233
- console.error('CnNotesCard: Failed to fetch notes', err)
234
- } finally {
235
- this.loading = false
236
- }
237
- },
238
-
239
- async submitNote() {
240
- if (!this.newNoteText.trim() || this.noteSaving) return
241
- this.noteSaving = true
242
- try {
243
- const url = `${this.apiBase}/objects/${this.registerId}/${this.schemaId}/${this.objectId}/notes`
244
- const response = await fetch(url, {
245
- method: 'POST',
246
- headers: buildHeaders(),
247
- body: JSON.stringify({ message: this.newNoteText.trim() }),
248
- })
249
- if (response.ok) {
250
- this.newNoteText = ''
251
- await this.fetchNotes()
252
- this.$emit('note-added')
253
- } else {
254
- this.showError('Failed to add note')
255
- }
256
- } catch (err) {
257
- console.error('CnNotesCard: Failed to add note', err)
258
- this.showError('Failed to add note')
259
- } finally {
260
- this.noteSaving = false
261
- }
262
- },
263
-
264
- async confirmDelete(note) {
265
- // Simple inline confirmation — delete directly
266
- try {
267
- const url = `${this.apiBase}/objects/${this.registerId}/${this.schemaId}/${this.objectId}/notes/${note.id}`
268
- const response = await fetch(url, {
269
- method: 'DELETE',
270
- headers: buildHeaders(),
271
- })
272
- if (response.ok) {
273
- this.allNotes = this.allNotes.filter(n => n.id !== note.id)
274
- this.$emit('note-deleted')
275
- }
276
- } catch (err) {
277
- console.error('CnNotesCard: Failed to delete note', err)
278
- }
279
- },
280
-
281
- formatDate(dateStr) {
282
- if (!dateStr) return ''
283
- try {
284
- return new Date(dateStr).toLocaleString(undefined, {
285
- year: 'numeric',
286
- month: 'short',
287
- day: 'numeric',
288
- hour: '2-digit',
289
- minute: '2-digit',
290
- })
291
- } catch {
292
- return dateStr
293
- }
294
- },
295
-
296
- showError(message) {
297
- try {
298
- // eslint-disable-next-line n/no-missing-import
299
- import('@nextcloud/dialogs').then(({ showError }) => {
300
- showError(message)
301
- })
302
- } catch {
303
- console.error(message)
304
- }
305
- },
306
- },
307
- }
308
- </script>
309
-
310
- <style scoped>
311
- .cn-notes-card__add-form {
312
- margin-bottom: 12px;
313
- }
314
-
315
- .cn-notes-card__textarea {
316
- width: 100%;
317
- padding: 8px;
318
- border: 1px solid var(--color-border);
319
- border-radius: var(--border-radius);
320
- resize: vertical;
321
- font-family: inherit;
322
- font-size: 13px;
323
- margin-bottom: 8px;
324
- background: var(--color-main-background);
325
- color: var(--color-main-text);
326
- box-sizing: border-box;
327
- }
328
-
329
- .cn-notes-card__textarea:focus {
330
- border-color: var(--color-primary-element);
331
- outline: none;
332
- }
333
-
334
- .cn-notes-card__empty {
335
- text-align: center;
336
- padding: 16px 12px;
337
- color: var(--color-text-maxcontrast);
338
- font-size: 13px;
339
- }
340
-
341
- .cn-notes-card__list {
342
- display: flex;
343
- flex-direction: column;
344
- }
345
-
346
- .cn-notes-card__note {
347
- padding: 10px 0;
348
- border-bottom: 1px solid var(--color-border);
349
- position: relative;
350
- }
351
-
352
- .cn-notes-card__note:last-child {
353
- border-bottom: none;
354
- }
355
-
356
- .cn-notes-card__note-header {
357
- display: flex;
358
- justify-content: space-between;
359
- align-items: baseline;
360
- margin-bottom: 4px;
361
- }
362
-
363
- .cn-notes-card__author {
364
- font-size: 13px;
365
- }
366
-
367
- .cn-notes-card__author--self {
368
- color: var(--color-main-text);
369
- }
370
-
371
- .cn-notes-card__time {
372
- font-size: 11px;
373
- color: var(--color-text-maxcontrast);
374
- flex-shrink: 0;
375
- margin-left: 8px;
376
- }
377
-
378
- .cn-notes-card__body {
379
- font-size: 13px;
380
- margin: 0;
381
- white-space: pre-wrap;
382
- word-break: break-word;
383
- padding-right: 32px;
384
- }
385
-
386
- .cn-notes-card__delete-btn {
387
- position: absolute;
388
- top: 8px;
389
- right: -4px;
390
- opacity: 0;
391
- transition: opacity 0.15s ease;
392
- }
393
-
394
- .cn-notes-card__note:hover .cn-notes-card__delete-btn {
395
- opacity: 1;
396
- }
397
-
398
- .cn-notes-card__show-all {
399
- background: none;
400
- border: none;
401
- color: var(--color-primary-element);
402
- font-size: 13px;
403
- font-weight: 500;
404
- cursor: pointer;
405
- padding: 0;
406
- width: 100%;
407
- text-align: center;
408
- }
409
-
410
- .cn-notes-card__show-all:hover {
411
- text-decoration: underline;
412
- }
413
- </style>
1
+ <!--
2
+ CnNotesCard — Inline notes card for detail pages.
3
+
4
+ Displays up to 5 recent notes with author, content, and timestamp.
5
+ Includes an add-note form and integrates CnUserActionMenu on author names.
6
+ Wraps CnDetailCard for consistent styling.
7
+ -->
8
+ <template>
9
+ <CnDetailCard :title="titleLabel" :icon="CommentTextOutline" :collapsible="collapsible">
10
+ <div class="cn-notes-card">
11
+ <!-- Add note input -->
12
+ <div class="cn-notes-card__add-form">
13
+ <textarea
14
+ v-model="newNoteText"
15
+ class="cn-notes-card__textarea"
16
+ :placeholder="addNotePlaceholder"
17
+ rows="2"
18
+ @keydown.enter.ctrl.prevent="submitNote"
19
+ @keydown.enter.meta.prevent="submitNote" />
20
+ <NcButton
21
+ type="primary"
22
+ :disabled="!newNoteText.trim() || noteSaving"
23
+ @click="submitNote">
24
+ <template #icon>
25
+ <Send :size="20" />
26
+ </template>
27
+ {{ addNoteLabel }}
28
+ </NcButton>
29
+ </div>
30
+
31
+ <!-- Loading state -->
32
+ <NcLoadingIcon v-if="loading" />
33
+
34
+ <!-- Empty state -->
35
+ <div v-else-if="allNotes.length === 0" class="cn-notes-card__empty">
36
+ {{ noNotesLabel }}
37
+ </div>
38
+
39
+ <!-- Notes list (last 5) -->
40
+ <div v-else class="cn-notes-card__list">
41
+ <div
42
+ v-for="note in displayedNotes"
43
+ :key="note.id"
44
+ class="cn-notes-card__note">
45
+ <div class="cn-notes-card__note-header">
46
+ <CnUserActionMenu
47
+ v-if="!isCurrentUser(note)"
48
+ :user-id="getNoteAuthorId(note)"
49
+ :display-name="getNoteAuthorName(note)">
50
+ <strong class="cn-notes-card__author">{{ getNoteAuthorName(note) }}</strong>
51
+ </CnUserActionMenu>
52
+ <strong v-else class="cn-notes-card__author cn-notes-card__author--self">
53
+ {{ getNoteAuthorName(note) }}
54
+ </strong>
55
+ <span class="cn-notes-card__time">{{ formatDate(note.creationDateTime || note.created) }}</span>
56
+ </div>
57
+ <p class="cn-notes-card__body">{{ note.message || note.content }}</p>
58
+ <NcButton
59
+ v-if="canDeleteNote(note)"
60
+ type="tertiary-no-background"
61
+ class="cn-notes-card__delete-btn"
62
+ :aria-label="deleteLabel"
63
+ @click="confirmDelete(note)">
64
+ <template #icon>
65
+ <Delete :size="16" />
66
+ </template>
67
+ </NcButton>
68
+ </div>
69
+ </div>
70
+ </div>
71
+
72
+ <!-- Footer: "Show all" link -->
73
+ <template v-if="allNotes.length > maxDisplay" #footer>
74
+ <button
75
+ class="cn-notes-card__show-all"
76
+ @click="$emit('show-all')">
77
+ {{ showAllLabel }} ({{ allNotes.length }})
78
+ </button>
79
+ </template>
80
+ </CnDetailCard>
81
+ </template>
82
+
83
+ <script>
84
+ import { NcButton, NcLoadingIcon } from '@nextcloud/vue'
85
+ import CommentTextOutline from 'vue-material-design-icons/CommentTextOutline.vue'
86
+ import Send from 'vue-material-design-icons/Send.vue'
87
+ import Delete from 'vue-material-design-icons/Delete.vue'
88
+
89
+ import CnDetailCard from '../CnDetailCard/CnDetailCard.vue'
90
+ import CnUserActionMenu from '../CnUserActionMenu/CnUserActionMenu.vue'
91
+ import { buildHeaders } from '../../utils/index.js'
92
+
93
+ /**
94
+ * CnNotesCard — Inline notes widget for detail pages.
95
+ *
96
+ * Shows up to 5 recent notes with add/delete functionality.
97
+ * Integrates CnUserActionMenu on author names for quick communication.
98
+ *
99
+ * @example Basic usage
100
+ * <CnNotesCard
101
+ * register-id="uuid-register"
102
+ * schema-id="uuid-schema"
103
+ * object-id="uuid-object" />
104
+ *
105
+ * @example With sidebar sync
106
+ * <CnNotesCard
107
+ * register-id="reg"
108
+ * schema-id="schema"
109
+ * object-id="obj"
110
+ * @note-added="refreshNotes"
111
+ * @note-deleted="refreshNotes"
112
+ * @show-all="openSidebarNotesTab" />
113
+ */
114
+ export default {
115
+ name: 'CnNotesCard',
116
+
117
+ components: {
118
+ CnDetailCard,
119
+ CnUserActionMenu,
120
+ NcButton,
121
+ NcLoadingIcon,
122
+ Send,
123
+ Delete,
124
+ },
125
+
126
+ props: {
127
+ /** OpenRegister register ID */
128
+ registerId: {
129
+ type: String,
130
+ required: true,
131
+ },
132
+ /** OpenRegister schema ID */
133
+ schemaId: {
134
+ type: String,
135
+ required: true,
136
+ },
137
+ /** Object UUID */
138
+ objectId: {
139
+ type: String,
140
+ required: true,
141
+ },
142
+ /** Base API URL for OpenRegister */
143
+ apiBase: {
144
+ type: String,
145
+ default: '/apps/openregister/api',
146
+ },
147
+ /** Maximum number of notes to display */
148
+ maxDisplay: {
149
+ type: Number,
150
+ default: 5,
151
+ },
152
+ /** Whether the card is collapsible */
153
+ collapsible: {
154
+ type: Boolean,
155
+ default: false,
156
+ },
157
+
158
+ // --- Pre-translated labels ---
159
+ titleLabel: { type: String, default: 'Notes' },
160
+ addNoteLabel: { type: String, default: 'Add note' },
161
+ addNotePlaceholder: { type: String, default: 'Write a note...' },
162
+ noNotesLabel: { type: String, default: 'No notes yet' },
163
+ showAllLabel: { type: String, default: 'Show all' },
164
+ deleteLabel: { type: String, default: 'Delete note' },
165
+ },
166
+
167
+ emits: ['note-added', 'note-deleted', 'show-all'],
168
+
169
+ data() {
170
+ return {
171
+ CommentTextOutline,
172
+ allNotes: [],
173
+ loading: false,
174
+ newNoteText: '',
175
+ noteSaving: false,
176
+ deleteConfirmId: null,
177
+ }
178
+ },
179
+
180
+ computed: {
181
+ displayedNotes() {
182
+ // Reverse chronological, limited to maxDisplay
183
+ const sorted = [...this.allNotes].sort((a, b) => {
184
+ const dateA = new Date(a.creationDateTime || a.created || 0)
185
+ const dateB = new Date(b.creationDateTime || b.created || 0)
186
+ return dateB - dateA
187
+ })
188
+ return sorted.slice(0, this.maxDisplay)
189
+ },
190
+ },
191
+
192
+ watch: {
193
+ objectId: {
194
+ immediate: true,
195
+ handler(newId) {
196
+ if (newId && this.registerId && this.schemaId) {
197
+ this.fetchNotes()
198
+ }
199
+ },
200
+ },
201
+ },
202
+
203
+ methods: {
204
+ getNoteAuthorId(note) {
205
+ return note.actorId || note.author || ''
206
+ },
207
+
208
+ getNoteAuthorName(note) {
209
+ return note.actorDisplayName || note.author || 'Unknown'
210
+ },
211
+
212
+ isCurrentUser(note) {
213
+ const authorId = this.getNoteAuthorId(note)
214
+ const currentUser = typeof OC !== 'undefined' ? OC?.currentUser : null
215
+ return authorId === currentUser
216
+ },
217
+
218
+ canDeleteNote(note) {
219
+ return this.isCurrentUser(note)
220
+ },
221
+
222
+ async fetchNotes() {
223
+ if (!this.registerId || !this.schemaId || !this.objectId) return
224
+ this.loading = true
225
+ try {
226
+ const url = `${this.apiBase}/objects/${this.registerId}/${this.schemaId}/${this.objectId}/notes`
227
+ const response = await fetch(url, { headers: buildHeaders() })
228
+ if (response.ok) {
229
+ const data = await response.json()
230
+ this.allNotes = data.results || data || []
231
+ }
232
+ } catch (err) {
233
+ console.error('CnNotesCard: Failed to fetch notes', err)
234
+ } finally {
235
+ this.loading = false
236
+ }
237
+ },
238
+
239
+ async submitNote() {
240
+ if (!this.newNoteText.trim() || this.noteSaving) return
241
+ this.noteSaving = true
242
+ try {
243
+ const url = `${this.apiBase}/objects/${this.registerId}/${this.schemaId}/${this.objectId}/notes`
244
+ const response = await fetch(url, {
245
+ method: 'POST',
246
+ headers: buildHeaders(),
247
+ body: JSON.stringify({ message: this.newNoteText.trim() }),
248
+ })
249
+ if (response.ok) {
250
+ this.newNoteText = ''
251
+ await this.fetchNotes()
252
+ this.$emit('note-added')
253
+ } else {
254
+ this.showError('Failed to add note')
255
+ }
256
+ } catch (err) {
257
+ console.error('CnNotesCard: Failed to add note', err)
258
+ this.showError('Failed to add note')
259
+ } finally {
260
+ this.noteSaving = false
261
+ }
262
+ },
263
+
264
+ async confirmDelete(note) {
265
+ // Simple inline confirmation — delete directly
266
+ try {
267
+ const url = `${this.apiBase}/objects/${this.registerId}/${this.schemaId}/${this.objectId}/notes/${note.id}`
268
+ const response = await fetch(url, {
269
+ method: 'DELETE',
270
+ headers: buildHeaders(),
271
+ })
272
+ if (response.ok) {
273
+ this.allNotes = this.allNotes.filter(n => n.id !== note.id)
274
+ this.$emit('note-deleted')
275
+ }
276
+ } catch (err) {
277
+ console.error('CnNotesCard: Failed to delete note', err)
278
+ }
279
+ },
280
+
281
+ formatDate(dateStr) {
282
+ if (!dateStr) return ''
283
+ try {
284
+ return new Date(dateStr).toLocaleString(undefined, {
285
+ year: 'numeric',
286
+ month: 'short',
287
+ day: 'numeric',
288
+ hour: '2-digit',
289
+ minute: '2-digit',
290
+ })
291
+ } catch {
292
+ return dateStr
293
+ }
294
+ },
295
+
296
+ showError(message) {
297
+ try {
298
+ // eslint-disable-next-line n/no-missing-import
299
+ import('@nextcloud/dialogs').then(({ showError }) => {
300
+ showError(message)
301
+ })
302
+ } catch {
303
+ console.error(message)
304
+ }
305
+ },
306
+ },
307
+ }
308
+ </script>
309
+
310
+ <style scoped>
311
+ .cn-notes-card__add-form {
312
+ margin-bottom: 12px;
313
+ }
314
+
315
+ .cn-notes-card__textarea {
316
+ width: 100%;
317
+ padding: 8px;
318
+ border: 1px solid var(--color-border);
319
+ border-radius: var(--border-radius);
320
+ resize: vertical;
321
+ font-family: inherit;
322
+ font-size: 13px;
323
+ margin-bottom: 8px;
324
+ background: var(--color-main-background);
325
+ color: var(--color-main-text);
326
+ box-sizing: border-box;
327
+ }
328
+
329
+ .cn-notes-card__textarea:focus {
330
+ border-color: var(--color-primary-element);
331
+ outline: none;
332
+ }
333
+
334
+ .cn-notes-card__empty {
335
+ text-align: center;
336
+ padding: 16px 12px;
337
+ color: var(--color-text-maxcontrast);
338
+ font-size: 13px;
339
+ }
340
+
341
+ .cn-notes-card__list {
342
+ display: flex;
343
+ flex-direction: column;
344
+ }
345
+
346
+ .cn-notes-card__note {
347
+ padding: 10px 0;
348
+ border-bottom: 1px solid var(--color-border);
349
+ position: relative;
350
+ }
351
+
352
+ .cn-notes-card__note:last-child {
353
+ border-bottom: none;
354
+ }
355
+
356
+ .cn-notes-card__note-header {
357
+ display: flex;
358
+ justify-content: space-between;
359
+ align-items: baseline;
360
+ margin-bottom: 4px;
361
+ }
362
+
363
+ .cn-notes-card__author {
364
+ font-size: 13px;
365
+ }
366
+
367
+ .cn-notes-card__author--self {
368
+ color: var(--color-main-text);
369
+ }
370
+
371
+ .cn-notes-card__time {
372
+ font-size: 11px;
373
+ color: var(--color-text-maxcontrast);
374
+ flex-shrink: 0;
375
+ margin-left: 8px;
376
+ }
377
+
378
+ .cn-notes-card__body {
379
+ font-size: 13px;
380
+ margin: 0;
381
+ white-space: pre-wrap;
382
+ word-break: break-word;
383
+ padding-right: 32px;
384
+ }
385
+
386
+ .cn-notes-card__delete-btn {
387
+ position: absolute;
388
+ top: 8px;
389
+ right: -4px;
390
+ opacity: 0;
391
+ transition: opacity 0.15s ease;
392
+ }
393
+
394
+ .cn-notes-card__note:hover .cn-notes-card__delete-btn {
395
+ opacity: 1;
396
+ }
397
+
398
+ .cn-notes-card__show-all {
399
+ background: none;
400
+ border: none;
401
+ color: var(--color-primary-element);
402
+ font-size: 13px;
403
+ font-weight: 500;
404
+ cursor: pointer;
405
+ padding: 0;
406
+ width: 100%;
407
+ text-align: center;
408
+ }
409
+
410
+ .cn-notes-card__show-all:hover {
411
+ text-decoration: underline;
412
+ }
413
+ </style>