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

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 (208) hide show
  1. package/README.md +226 -0
  2. package/css/index.css +5 -0
  3. package/dist/nextcloud-vue.cjs.js +79416 -7715
  4. package/dist/nextcloud-vue.cjs.js.map +1 -1
  5. package/dist/nextcloud-vue.css +3583 -504
  6. package/dist/nextcloud-vue.esm.js +79343 -7692
  7. package/dist/nextcloud-vue.esm.js.map +1 -1
  8. package/l10n/en.json +164 -0
  9. package/l10n/nl.json +164 -0
  10. package/package.json +104 -63
  11. package/src/components/CnActionsBar/CnActionsBar.vue +254 -0
  12. package/src/components/CnActionsBar/index.js +1 -0
  13. package/src/components/CnAdvancedFormDialog/CnAdvancedFormDialog.vue +570 -0
  14. package/src/components/CnAdvancedFormDialog/CnDataTab.vue +217 -0
  15. package/src/components/CnAdvancedFormDialog/CnMetadataTab.vue +121 -0
  16. package/src/components/CnAdvancedFormDialog/CnPropertiesTab.vue +422 -0
  17. package/src/components/CnAdvancedFormDialog/CnPropertyValueCell.vue +247 -0
  18. package/src/components/CnAdvancedFormDialog/index.js +1 -0
  19. package/src/components/CnCard/CnCard.vue +415 -0
  20. package/src/components/CnCard/index.js +1 -0
  21. package/src/components/CnCardGrid/CnCardGrid.vue +156 -152
  22. package/src/components/CnCardGrid/index.js +1 -1
  23. package/src/components/CnCellRenderer/CnCellRenderer.vue +132 -132
  24. package/src/components/CnCellRenderer/index.js +1 -1
  25. package/src/components/CnChartWidget/CnChartWidget.vue +346 -0
  26. package/src/components/CnChartWidget/index.js +1 -0
  27. package/src/components/CnConfigurationCard/CnConfigurationCard.vue +77 -77
  28. package/src/components/CnConfigurationCard/index.js +1 -1
  29. package/src/components/CnContextMenu/CnContextMenu.vue +142 -0
  30. package/src/components/CnContextMenu/index.js +1 -0
  31. package/src/components/CnCopyDialog/CnCopyDialog.vue +266 -0
  32. package/src/components/CnCopyDialog/index.js +1 -0
  33. package/src/components/CnDashboardGrid/CnDashboardGrid.vue +229 -0
  34. package/src/components/CnDashboardGrid/index.js +1 -0
  35. package/src/components/CnDashboardPage/CnDashboardPage.vue +397 -0
  36. package/src/components/CnDashboardPage/index.js +1 -0
  37. package/src/components/CnDataTable/CnDataTable.vue +362 -354
  38. package/src/components/CnDataTable/index.js +1 -1
  39. package/src/components/CnDeleteDialog/CnDeleteDialog.vue +177 -0
  40. package/src/components/CnDeleteDialog/index.js +1 -0
  41. package/src/components/CnDetailCard/CnDetailCard.vue +225 -0
  42. package/src/components/CnDetailCard/index.js +1 -0
  43. package/src/components/CnDetailGrid/CnDetailGrid.vue +256 -0
  44. package/src/components/CnDetailGrid/index.js +1 -0
  45. package/src/components/CnDetailPage/CnDetailPage.vue +432 -0
  46. package/src/components/CnDetailPage/index.js +1 -0
  47. package/src/components/CnFacetSidebar/CnFacetSidebar.vue +234 -223
  48. package/src/components/CnFacetSidebar/index.js +1 -1
  49. package/src/components/CnFilterBar/CnFilterBar.vue +153 -152
  50. package/src/components/CnFilterBar/index.js +1 -1
  51. package/src/components/CnFormDialog/CnFormDialog.vue +1047 -0
  52. package/src/components/CnFormDialog/index.js +1 -0
  53. package/src/components/CnIcon/CnIcon.vue +89 -0
  54. package/src/components/CnIcon/index.js +1 -0
  55. package/src/components/CnIndexPage/CnIndexPage.vue +980 -682
  56. package/src/components/CnIndexPage/index.js +1 -1
  57. package/src/components/CnIndexSidebar/CnIndexSidebar.vue +536 -0
  58. package/src/components/CnIndexSidebar/index.js +1 -0
  59. package/src/components/CnInfoWidget/CnInfoWidget.vue +219 -0
  60. package/src/components/CnInfoWidget/index.js +1 -0
  61. package/src/components/CnItemCard/CnItemCard.vue +134 -0
  62. package/src/components/CnItemCard/index.js +1 -0
  63. package/src/components/CnJsonViewer/CnJsonViewer.vue +312 -0
  64. package/src/components/CnJsonViewer/index.js +1 -0
  65. package/src/components/CnKpiGrid/CnKpiGrid.vue +93 -89
  66. package/src/components/CnKpiGrid/index.js +1 -1
  67. package/src/components/CnMassActionBar/CnMassActionBar.vue +161 -160
  68. package/src/components/CnMassActionBar/index.js +1 -1
  69. package/src/components/CnMassCopyDialog/CnMassCopyDialog.vue +327 -320
  70. package/src/components/CnMassCopyDialog/index.js +1 -1
  71. package/src/components/CnMassDeleteDialog/CnMassDeleteDialog.vue +245 -238
  72. package/src/components/CnMassDeleteDialog/index.js +1 -1
  73. package/src/components/CnMassExportDialog/CnMassExportDialog.vue +191 -190
  74. package/src/components/CnMassExportDialog/index.js +1 -1
  75. package/src/components/CnMassImportDialog/CnMassImportDialog.vue +494 -491
  76. package/src/components/CnMassImportDialog/index.js +1 -1
  77. package/src/components/CnNoteCard/CnNoteCard.vue +149 -0
  78. package/src/components/CnNoteCard/index.js +1 -0
  79. package/src/components/CnNotesCard/CnNotesCard.vue +416 -0
  80. package/src/components/CnNotesCard/index.js +1 -0
  81. package/src/components/CnObjectCard/CnObjectCard.vue +294 -292
  82. package/src/components/CnObjectCard/index.js +1 -1
  83. package/src/components/CnObjectDataWidget/CnObjectDataWidget.vue +854 -0
  84. package/src/components/CnObjectDataWidget/index.js +1 -0
  85. package/src/components/CnObjectMetadataWidget/CnObjectMetadataWidget.vue +289 -0
  86. package/src/components/CnObjectMetadataWidget/index.js +1 -0
  87. package/src/components/CnObjectSidebar/CnAuditTrailTab.vue +369 -0
  88. package/src/components/CnObjectSidebar/CnFilesTab.vue +287 -0
  89. package/src/components/CnObjectSidebar/CnNotesTab.vue +250 -0
  90. package/src/components/CnObjectSidebar/CnObjectSidebar.vue +255 -0
  91. package/src/components/CnObjectSidebar/CnTagsTab.vue +259 -0
  92. package/src/components/CnObjectSidebar/CnTasksTab.vue +483 -0
  93. package/src/components/CnObjectSidebar/index.js +6 -0
  94. package/src/components/CnPageHeader/CnPageHeader.vue +61 -0
  95. package/src/components/CnPageHeader/index.js +1 -0
  96. package/src/components/CnPagination/CnPagination.vue +253 -252
  97. package/src/components/CnPagination/index.js +1 -1
  98. package/src/components/CnProgressBar/CnProgressBar.vue +262 -0
  99. package/src/components/CnProgressBar/index.js +1 -0
  100. package/src/components/CnRegisterMapping/CnRegisterMapping.vue +793 -0
  101. package/src/components/CnRegisterMapping/index.js +1 -0
  102. package/src/components/CnRowActions/CnRowActions.vue +95 -73
  103. package/src/components/CnRowActions/index.js +1 -1
  104. package/src/components/CnSchemaFormDialog/CnSchemaConfigurationTab.vue +226 -0
  105. package/src/components/CnSchemaFormDialog/CnSchemaFormDialog.vue +788 -0
  106. package/src/components/CnSchemaFormDialog/CnSchemaPropertiesTab.vue +305 -0
  107. package/src/components/CnSchemaFormDialog/CnSchemaPropertyActions.vue +1398 -0
  108. package/src/components/CnSchemaFormDialog/CnSchemaSecurityTab.vue +236 -0
  109. package/src/components/CnSchemaFormDialog/index.js +1 -0
  110. package/src/components/CnSettingsCard/CnSettingsCard.vue +92 -92
  111. package/src/components/CnSettingsCard/index.js +1 -1
  112. package/src/components/CnSettingsSection/CnSettingsSection.vue +267 -266
  113. package/src/components/CnSettingsSection/index.js +1 -1
  114. package/src/components/CnStatsBlock/CnStatsBlock.vue +437 -366
  115. package/src/components/CnStatsBlock/index.js +1 -1
  116. package/src/components/CnStatsPanel/CnStatsPanel.vue +321 -0
  117. package/src/components/CnStatsPanel/index.js +1 -0
  118. package/src/components/CnStatusBadge/CnStatusBadge.vue +90 -77
  119. package/src/components/CnStatusBadge/index.js +1 -1
  120. package/src/components/CnTabbedFormDialog/CnTabbedFormDialog.vue +545 -0
  121. package/src/components/CnTabbedFormDialog/index.js +1 -0
  122. package/src/components/CnTableWidget/CnTableWidget.vue +333 -0
  123. package/src/components/CnTableWidget/index.js +1 -0
  124. package/src/components/CnTasksCard/CnTasksCard.vue +374 -0
  125. package/src/components/CnTasksCard/index.js +1 -0
  126. package/src/components/CnTileWidget/CnTileWidget.vue +159 -0
  127. package/src/components/CnTileWidget/index.js +1 -0
  128. package/src/components/CnTimelineStages/CnTimelineStages.vue +294 -0
  129. package/src/components/CnTimelineStages/index.js +1 -0
  130. package/src/components/CnUserActionMenu/CnUserActionMenu.vue +436 -0
  131. package/src/components/CnUserActionMenu/index.js +1 -0
  132. package/src/components/CnVersionInfoCard/CnVersionInfoCard.vue +313 -312
  133. package/src/components/CnVersionInfoCard/index.js +1 -1
  134. package/src/components/CnWidgetRenderer/CnWidgetRenderer.vue +180 -0
  135. package/src/components/CnWidgetRenderer/index.js +1 -0
  136. package/src/components/CnWidgetWrapper/CnWidgetWrapper.vue +248 -0
  137. package/src/components/CnWidgetWrapper/index.js +1 -0
  138. package/src/components/index.js +57 -25
  139. package/src/composables/index.js +5 -3
  140. package/src/composables/useContextMenu.js +126 -0
  141. package/src/composables/useDashboardView.js +286 -0
  142. package/src/composables/useDetailView.js +290 -132
  143. package/src/composables/useListView.js +364 -153
  144. package/src/composables/useSubResource.js +142 -142
  145. package/src/constants/metadata.js +30 -0
  146. package/src/css/CnSchemaFormDialog.css +546 -0
  147. package/src/css/__sample_nextcloud_tokens.css +110 -0
  148. package/src/css/actions-bar.css +54 -0
  149. package/src/css/badge.css +83 -51
  150. package/src/css/card.css +129 -128
  151. package/src/css/context-menu.css +20 -0
  152. package/src/css/dashboard.css +70 -0
  153. package/src/css/detail-page.css +235 -0
  154. package/src/css/detail.css +68 -68
  155. package/src/css/index-page.css +44 -0
  156. package/src/css/index-sidebar.css +193 -0
  157. package/src/css/index.css +17 -8
  158. package/src/css/layout.css +90 -90
  159. package/src/css/page-header.css +35 -0
  160. package/src/css/pagination.css +72 -72
  161. package/src/css/table.css +142 -143
  162. package/src/css/timeline-stages.css +220 -0
  163. package/src/css/utilities.css +46 -46
  164. package/src/index.js +95 -50
  165. package/src/l10n/index.js +12 -0
  166. package/src/mixins/gridLayout.js +118 -0
  167. package/src/store/createCrudStore.d.ts +350 -0
  168. package/src/store/createCrudStore.js +413 -0
  169. package/src/store/createSubResourcePlugin.js +125 -135
  170. package/src/store/index.js +4 -3
  171. package/src/store/pluginMerge.js +55 -0
  172. package/src/store/plugins/auditTrails.js +357 -17
  173. package/src/store/plugins/files.js +250 -186
  174. package/src/store/plugins/index.js +8 -4
  175. package/src/store/plugins/lifecycle.js +180 -180
  176. package/src/store/plugins/logs.d.ts +22 -0
  177. package/src/store/plugins/logs.js +172 -0
  178. package/src/store/plugins/registerMapping.js +195 -0
  179. package/src/store/plugins/relations.js +68 -68
  180. package/src/store/plugins/search.js +385 -0
  181. package/src/store/plugins/selection.js +104 -0
  182. package/src/store/useObjectStore.js +793 -625
  183. package/src/types/auditTrail.d.ts +32 -32
  184. package/src/types/file.d.ts +23 -23
  185. package/src/types/index.d.ts +67 -35
  186. package/src/types/notification.d.ts +36 -36
  187. package/src/types/object.d.ts +40 -40
  188. package/src/types/organisation.d.ts +41 -41
  189. package/src/types/register.d.ts +25 -25
  190. package/src/types/schema.d.ts +39 -39
  191. package/src/types/shared.d.ts +79 -79
  192. package/src/types/source.d.ts +14 -14
  193. package/src/types/task.d.ts +31 -31
  194. package/src/utils/errors.js +96 -96
  195. package/src/utils/getTheme.js +9 -0
  196. package/src/utils/headers.js +80 -44
  197. package/src/utils/id.js +13 -0
  198. package/src/utils/index.js +4 -3
  199. package/src/utils/schema.js +423 -287
  200. package/src/utils/widgetVisibility.js +162 -0
  201. package/src/components/CnDetailViewLayout/CnDetailViewLayout.vue +0 -88
  202. package/src/components/CnDetailViewLayout/index.js +0 -1
  203. package/src/components/CnEmptyState/CnEmptyState.vue +0 -78
  204. package/src/components/CnEmptyState/index.js +0 -1
  205. package/src/components/CnListViewLayout/CnListViewLayout.vue +0 -80
  206. package/src/components/CnListViewLayout/index.js +0 -1
  207. package/src/components/CnViewModeToggle/CnViewModeToggle.vue +0 -77
  208. package/src/components/CnViewModeToggle/index.js +0 -1
@@ -1 +1 @@
1
- export { default as CnMassImportDialog } from './CnMassImportDialog.vue'
1
+ export { default as CnMassImportDialog } from './CnMassImportDialog.vue'
@@ -0,0 +1,149 @@
1
+ <!--
2
+ This code was taken from nextcloud-vue due to certain changes being required but unable to be done as a patch.
3
+
4
+ https://github.com/nextcloud-libraries/nextcloud-vue/blob/main/src/components/NcNoteCard/NcNoteCard.vue
5
+ -->
6
+ <template>
7
+ <div
8
+ class="notecard"
9
+ :class="{
10
+ [`notecard--${type}`]: type,
11
+ }"
12
+ :role="shouldShowAlert ? 'alert' : 'note'">
13
+ <slot name="icon">
14
+ <NcIconSvgWrapper
15
+ :path="iconPath"
16
+ class="notecard__icon"
17
+ :class="{ 'notecard__icon--heading': heading }"
18
+ inline />
19
+ </slot>
20
+ <div>
21
+ <p v-if="heading" class="notecard__heading">
22
+ {{ heading }}
23
+ </p>
24
+ <slot>
25
+ <p class="notecard__text">
26
+ {{ text }}
27
+ </p>
28
+ </slot>
29
+ </div>
30
+ </div>
31
+ </template>
32
+
33
+ <script>
34
+ import { NcIconSvgWrapper } from '@nextcloud/vue'
35
+
36
+ // hardcoded @mdi/js icons to avoid unnececary package and bundlesize
37
+ // we are only doing this to patch NcNoteCard anyway
38
+ const mdiAlert = 'M13 14H11V9H13M13 18H11V16H13M1 21H23L12 2L1 21Z'
39
+ const mdiAlertDecagram = 'M23,12L20.56,9.22L20.9,5.54L17.29,4.72L15.4,1.54L12,3L8.6,1.54L6.71,4.72L3.1,5.53L3.44,9.21L1,12L3.44,14.78L3.1,18.47L6.71,19.29L8.6,22.47L12,21L15.4,22.46L17.29,19.28L20.9,18.46L20.56,14.78L23,12M13,17H11V15H13V17M13,13H11V7H13V13Z'
40
+ const mdiCheckboxMarkedCircle = 'M10,17L5,12L6.41,10.58L10,14.17L17.59,6.58L19,8M12,2A10,10 0 0,0 2,12A10,10 0 0,0 12,22A10,10 0 0,0 22,12A10,10 0 0,0 12,2Z'
41
+ const mdiInformation = 'M13,9H11V7H13M13,17H11V11H13M12,2A10,10 0 0,0 2,12A10,10 0 0,0 12,22A10,10 0 0,0 12,2Z'
42
+
43
+ export default {
44
+ name: 'CnNoteCard',
45
+ components: {
46
+ NcIconSvgWrapper,
47
+ },
48
+ props: {
49
+ /** Optional text to show as a heading of the note card */
50
+ heading: {
51
+ type: String,
52
+ default: undefined,
53
+ },
54
+ /**
55
+ * Enforce the `alert` role on the note card.
56
+ *
57
+ * The alert role should only be used for information that requires the user's immediate attention.
58
+ *
59
+ * @see https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Roles/alert_role
60
+ */
61
+ showAlert: {
62
+ type: Boolean,
63
+ default: undefined,
64
+ },
65
+ /** The message text of the note card */
66
+ text: {
67
+ type: String,
68
+ default: undefined,
69
+ },
70
+ /** Type or severity of the message */
71
+ type: {
72
+ type: String,
73
+ default: 'warning',
74
+ validator: (value) =>
75
+ ['success', 'info', 'warning', 'error'].includes(value),
76
+ },
77
+ },
78
+ computed: {
79
+ shouldShowAlert() {
80
+ return this.showAlert || this.type === 'error'
81
+ },
82
+ iconPath() {
83
+ switch (this.type) {
84
+ case 'error':
85
+ return mdiAlertDecagram
86
+ case 'success':
87
+ return mdiCheckboxMarkedCircle
88
+ case 'info':
89
+ return mdiInformation
90
+ case 'warning':
91
+ default:
92
+ return mdiAlert
93
+ }
94
+ },
95
+ },
96
+ }
97
+ </script>
98
+
99
+ <!-- we do not have support for scss so this has been translated to css -->
100
+ <!-- @TODO add scss support -->
101
+ <style scoped>
102
+ .notecard {
103
+ --note-card-icon-size: 20px;
104
+ --note-card-padding: calc(2 * var(--default-grid-baseline));
105
+ color: var(--color-main-text) !important;
106
+ background-color: var(--note-background) !important;
107
+ border-inline-start: var(--default-grid-baseline) solid var(--note-theme);
108
+ border-radius: var(--border-radius-small);
109
+ margin: 1rem 0;
110
+ padding: var(--note-card-padding);
111
+ display: flex;
112
+ flex-direction: row;
113
+ gap: var(--note-card-padding);
114
+ }
115
+
116
+ .notecard__heading {
117
+ font-size: var(--note-card-icon-size); /* Same as icon */
118
+ font-weight: 600;
119
+ }
120
+
121
+ .notecard__icon {
122
+ color: var(--note-theme);
123
+ }
124
+ .notecard__icon--heading {
125
+ font-size: var(--note-card-icon-size);
126
+ /* Ensure icon is on the same height as the heading */
127
+ margin-block: calc((1lh - 1em) / 2) auto;
128
+ }
129
+
130
+ .notecard--success {
131
+ --note-background: var(--color-success);
132
+ --note-theme: var(--color-success-text);
133
+ }
134
+
135
+ .notecard--info {
136
+ --note-background: var(--color-info);
137
+ --note-theme: var(--color-info-text);
138
+ }
139
+
140
+ .notecard--error {
141
+ --note-background: var(--color-error);
142
+ --note-theme: var(--color-error-text);
143
+ }
144
+
145
+ .notecard--warning {
146
+ --note-background: var(--color-warning);
147
+ --note-theme: var(--color-warning-text);
148
+ }
149
+ </style>
@@ -0,0 +1 @@
1
+ export { default as CnNoteCard } from './CnNoteCard.vue'
@@ -0,0 +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>
@@ -0,0 +1 @@
1
+ export { default as CnNotesCard } from './CnNotesCard.vue'