@conduction/nextcloud-vue 0.1.0-beta.11 → 0.1.0-beta.12

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