@conduction/nextcloud-vue 0.1.0-beta.2 → 0.1.0-beta.4
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.
- package/README.md +226 -226
- package/css/index.css +5 -0
- package/dist/nextcloud-vue.cjs.js +60455 -8755
- package/dist/nextcloud-vue.cjs.js.map +1 -1
- package/dist/nextcloud-vue.css +2062 -528
- package/dist/nextcloud-vue.esm.js +60411 -8731
- package/dist/nextcloud-vue.esm.js.map +1 -1
- package/package.json +75 -61
- package/src/components/CnActionsBar/CnActionsBar.vue +235 -225
- package/src/components/CnActionsBar/index.js +1 -1
- package/src/components/CnAdvancedFormDialog/CnAdvancedFormDialog.vue +579 -0
- package/src/components/CnAdvancedFormDialog/CnDataTab.vue +217 -0
- package/src/components/CnAdvancedFormDialog/CnMetadataTab.vue +121 -0
- package/src/components/CnAdvancedFormDialog/CnPropertiesTab.vue +418 -0
- package/src/components/CnAdvancedFormDialog/CnPropertyValueCell.vue +247 -0
- package/src/components/CnAdvancedFormDialog/index.js +1 -0
- package/src/components/CnCardGrid/CnCardGrid.vue +152 -152
- package/src/components/CnCardGrid/index.js +1 -1
- package/src/components/CnCellRenderer/CnCellRenderer.vue +132 -132
- package/src/components/CnCellRenderer/index.js +1 -1
- package/src/components/CnChartWidget/CnChartWidget.vue +320 -0
- package/src/components/CnChartWidget/index.js +1 -0
- package/src/components/CnConfigurationCard/CnConfigurationCard.vue +77 -77
- package/src/components/CnConfigurationCard/index.js +1 -1
- package/src/components/CnDashboardGrid/CnDashboardGrid.vue +225 -0
- package/src/components/CnDashboardGrid/index.js +1 -0
- package/src/components/CnDashboardPage/CnDashboardPage.vue +390 -0
- package/src/components/CnDashboardPage/index.js +1 -0
- package/src/components/CnDataTable/CnDataTable.vue +349 -349
- package/src/components/CnDataTable/index.js +1 -1
- package/src/components/CnDetailCard/CnDetailCard.vue +214 -0
- package/src/components/CnDetailCard/index.js +1 -0
- package/src/components/CnDetailPage/CnDetailPage.vue +281 -0
- package/src/components/CnDetailPage/index.js +1 -0
- package/src/components/CnFacetSidebar/CnFacetSidebar.vue +231 -223
- package/src/components/CnFacetSidebar/index.js +1 -1
- package/src/components/CnFilterBar/CnFilterBar.vue +152 -152
- package/src/components/CnFilterBar/index.js +1 -1
- package/src/components/CnIcon/CnIcon.vue +89 -89
- package/src/components/CnIcon/index.js +1 -1
- package/src/components/CnIndexPage/CnIndexPage.vue +874 -816
- package/src/components/CnIndexPage/index.js +1 -1
- package/src/components/CnIndexSidebar/CnIndexSidebar.vue +503 -484
- package/src/components/CnIndexSidebar/index.js +1 -1
- package/src/components/CnItemCard/CnItemCard.vue +132 -0
- package/src/components/CnItemCard/index.js +1 -0
- package/src/components/CnKpiGrid/CnKpiGrid.vue +89 -89
- package/src/components/CnKpiGrid/index.js +1 -1
- package/src/components/CnMassActionBar/CnMassActionBar.vue +160 -160
- package/src/components/CnMassActionBar/index.js +1 -1
- package/src/components/CnMassCopyDialog/CnMassCopyDialog.vue +320 -320
- package/src/components/CnMassCopyDialog/index.js +1 -1
- package/src/components/CnMassDeleteDialog/CnMassDeleteDialog.vue +238 -238
- package/src/components/CnMassDeleteDialog/index.js +1 -1
- package/src/components/CnMassExportDialog/CnMassExportDialog.vue +190 -190
- package/src/components/CnMassExportDialog/index.js +1 -1
- package/src/components/CnMassImportDialog/CnMassImportDialog.vue +491 -491
- package/src/components/CnMassImportDialog/index.js +1 -1
- package/src/components/CnNoteCard/CnNoteCard.vue +149 -0
- package/src/components/CnNoteCard/index.js +1 -0
- package/src/components/CnNotesCard/CnNotesCard.vue +413 -0
- package/src/components/CnNotesCard/index.js +1 -0
- package/src/components/CnObjectCard/CnObjectCard.vue +292 -292
- package/src/components/CnObjectCard/index.js +1 -1
- package/src/components/CnObjectSidebar/CnObjectSidebar.vue +876 -0
- package/src/components/CnObjectSidebar/index.js +1 -0
- package/src/components/CnPageHeader/CnPageHeader.vue +57 -57
- package/src/components/CnPageHeader/index.js +1 -1
- package/src/components/CnPagination/CnPagination.vue +252 -252
- package/src/components/CnPagination/index.js +1 -1
- package/src/components/CnRowActions/CnRowActions.vue +73 -73
- package/src/components/CnRowActions/index.js +1 -1
- package/src/components/CnSchemaFormDialog/CnSchemaConfigurationTab.vue +226 -0
- package/src/components/CnSchemaFormDialog/CnSchemaFormDialog.vue +787 -0
- package/src/components/CnSchemaFormDialog/CnSchemaPropertiesTab.vue +305 -0
- package/src/components/CnSchemaFormDialog/CnSchemaPropertyActions.vue +1398 -0
- package/src/components/CnSchemaFormDialog/CnSchemaSecurityTab.vue +236 -0
- package/src/components/CnSchemaFormDialog/index.js +1 -0
- package/src/components/CnSettingsCard/CnSettingsCard.vue +92 -92
- package/src/components/CnSettingsCard/index.js +1 -1
- package/src/components/CnSettingsSection/CnSettingsSection.vue +266 -266
- package/src/components/CnSettingsSection/index.js +1 -1
- package/src/components/CnStatsBlock/CnStatsBlock.vue +420 -366
- package/src/components/CnStatsBlock/index.js +1 -1
- package/src/components/CnStatusBadge/CnStatusBadge.vue +77 -77
- package/src/components/CnStatusBadge/index.js +1 -1
- package/src/components/CnTabbedFormDialog/CnTabbedFormDialog.vue +540 -0
- package/src/components/CnTabbedFormDialog/index.js +1 -0
- package/src/components/CnTasksCard/CnTasksCard.vue +373 -0
- package/src/components/CnTasksCard/index.js +1 -0
- package/src/components/CnTileWidget/CnTileWidget.vue +159 -0
- package/src/components/CnTileWidget/index.js +1 -0
- package/src/components/CnTimelineStages/CnTimelineStages.vue +292 -0
- package/src/components/CnTimelineStages/index.js +1 -0
- package/src/components/CnUserActionMenu/CnUserActionMenu.vue +435 -0
- package/src/components/CnUserActionMenu/index.js +1 -0
- package/src/components/CnVersionInfoCard/CnVersionInfoCard.vue +312 -312
- package/src/components/CnVersionInfoCard/index.js +1 -1
- package/src/components/CnWidgetRenderer/CnWidgetRenderer.vue +180 -0
- package/src/components/CnWidgetRenderer/index.js +1 -0
- package/src/components/CnWidgetWrapper/CnWidgetWrapper.vue +211 -0
- package/src/components/CnWidgetWrapper/index.js +1 -0
- package/src/components/index.js +43 -29
- package/src/composables/index.js +4 -3
- package/src/composables/useDashboardView.js +240 -0
- package/src/composables/useDetailView.js +289 -132
- package/src/composables/useListView.js +363 -153
- package/src/composables/useSubResource.js +142 -142
- package/src/constants/metadata.js +30 -30
- package/src/css/CnSchemaFormDialog.css +546 -0
- package/src/css/__sample_nextcloud_tokens.css +110 -0
- package/src/css/actions-bar.css +48 -48
- package/src/css/badge.css +51 -51
- package/src/css/card.css +128 -128
- package/src/css/dashboard.css +70 -0
- package/src/css/detail-page.css +168 -0
- package/src/css/detail.css +68 -68
- package/src/css/index-page.css +44 -32
- package/src/css/index-sidebar.css +193 -187
- package/src/css/index.css +16 -12
- package/src/css/layout.css +90 -90
- package/src/css/page-header.css +33 -33
- package/src/css/pagination.css +72 -72
- package/src/css/table.css +142 -142
- package/src/css/timeline-stages.css +218 -0
- package/src/css/utilities.css +46 -46
- package/src/index.js +72 -53
- package/src/store/createSubResourcePlugin.js +135 -135
- package/src/store/index.js +3 -3
- package/src/store/plugins/auditTrails.js +17 -17
- package/src/store/plugins/files.js +250 -186
- package/src/store/plugins/index.js +7 -5
- package/src/store/plugins/lifecycle.js +180 -180
- package/src/store/plugins/relations.js +68 -68
- package/src/store/plugins/search.js +372 -0
- package/src/store/plugins/selection.js +104 -0
- package/src/store/useObjectStore.js +829 -686
- package/src/types/auditTrail.d.ts +32 -32
- package/src/types/file.d.ts +23 -23
- package/src/types/index.d.ts +35 -35
- package/src/types/notification.d.ts +36 -36
- package/src/types/object.d.ts +40 -40
- package/src/types/organisation.d.ts +41 -41
- package/src/types/register.d.ts +25 -25
- package/src/types/schema.d.ts +39 -39
- package/src/types/shared.d.ts +79 -79
- package/src/types/source.d.ts +14 -14
- package/src/types/task.d.ts +31 -31
- package/src/utils/errors.js +96 -96
- package/src/utils/headers.js +68 -50
- package/src/utils/id.js +13 -0
- package/src/utils/index.js +3 -3
- package/src/utils/schema.js +422 -419
|
@@ -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,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>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default as CnNotesCard } from './CnNotesCard.vue'
|