@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.
- package/dist/nextcloud-vue.cjs +67614 -0
- package/dist/nextcloud-vue.cjs.js +13518 -13617
- package/dist/nextcloud-vue.cjs.js.map +1 -1
- package/dist/nextcloud-vue.cjs.map +1 -0
- package/dist/nextcloud-vue.css +1796 -1800
- package/dist/nextcloud-vue.esm.js +13518 -13617
- package/dist/nextcloud-vue.esm.js.map +1 -1
- package/package.json +3 -2
- package/src/components/CnActionsBar/CnActionsBar.vue +254 -254
- package/src/components/CnAdvancedFormDialog/CnAdvancedFormDialog.vue +570 -570
- package/src/components/CnAdvancedFormDialog/CnDataTab.vue +217 -217
- package/src/components/CnAdvancedFormDialog/CnMetadataTab.vue +121 -121
- package/src/components/CnAdvancedFormDialog/CnPropertiesTab.vue +422 -422
- package/src/components/CnAdvancedFormDialog/CnPropertyValueCell.vue +247 -247
- package/src/components/CnCard/CnCard.vue +415 -415
- package/src/components/CnCardGrid/CnCardGrid.vue +156 -156
- package/src/components/CnCellRenderer/CnCellRenderer.vue +132 -132
- package/src/components/CnChartWidget/CnChartWidget.vue +346 -346
- package/src/components/CnConfigurationCard/CnConfigurationCard.vue +77 -77
- package/src/components/CnContextMenu/CnContextMenu.vue +142 -142
- package/src/components/CnCopyDialog/CnCopyDialog.vue +266 -266
- package/src/components/CnDashboardGrid/CnDashboardGrid.vue +229 -229
- package/src/components/CnDashboardPage/CnDashboardPage.vue +397 -397
- package/src/components/CnDataTable/CnDataTable.vue +362 -362
- package/src/components/CnDeleteDialog/CnDeleteDialog.vue +177 -177
- package/src/components/CnDetailCard/CnDetailCard.vue +225 -225
- package/src/components/CnDetailGrid/CnDetailGrid.vue +256 -256
- package/src/components/CnDetailPage/CnDetailPage.vue +432 -432
- package/src/components/CnFacetSidebar/CnFacetSidebar.vue +234 -234
- package/src/components/CnFilterBar/CnFilterBar.vue +153 -153
- package/src/components/CnFormDialog/CnFormDialog.vue +1047 -1047
- package/src/components/CnIcon/CnIcon.vue +89 -89
- package/src/components/CnIndexPage/CnIndexPage.vue +981 -980
- package/src/components/CnIndexSidebar/CnIndexSidebar.vue +536 -536
- package/src/components/CnInfoWidget/CnInfoWidget.vue +219 -219
- package/src/components/CnItemCard/CnItemCard.vue +134 -134
- package/src/components/CnJsonViewer/CnJsonViewer.vue +312 -312
- package/src/components/CnKpiGrid/CnKpiGrid.vue +93 -93
- package/src/components/CnMassActionBar/CnMassActionBar.vue +161 -161
- package/src/components/CnMassCopyDialog/CnMassCopyDialog.vue +327 -327
- package/src/components/CnMassDeleteDialog/CnMassDeleteDialog.vue +245 -245
- package/src/components/CnMassExportDialog/CnMassExportDialog.vue +191 -191
- package/src/components/CnMassImportDialog/CnMassImportDialog.vue +494 -494
- package/src/components/CnNoteCard/CnNoteCard.vue +149 -149
- package/src/components/CnNotesCard/CnNotesCard.vue +416 -416
- package/src/components/CnObjectCard/CnObjectCard.vue +294 -294
- package/src/components/CnObjectDataWidget/CnObjectDataWidget.vue +854 -854
- package/src/components/CnObjectMetadataWidget/CnObjectMetadataWidget.vue +289 -289
- package/src/components/CnObjectSidebar/CnAuditTrailTab.vue +369 -369
- package/src/components/CnObjectSidebar/CnFilesTab.vue +287 -287
- package/src/components/CnObjectSidebar/CnNotesTab.vue +250 -250
- package/src/components/CnObjectSidebar/CnObjectSidebar.vue +255 -255
- package/src/components/CnObjectSidebar/CnTagsTab.vue +259 -259
- package/src/components/CnObjectSidebar/CnTasksTab.vue +483 -483
- package/src/components/CnPageHeader/CnPageHeader.vue +61 -61
- package/src/components/CnPagination/CnPagination.vue +253 -253
- package/src/components/CnProgressBar/CnProgressBar.vue +262 -262
- package/src/components/CnRegisterMapping/CnRegisterMapping.vue +793 -793
- package/src/components/CnRowActions/CnRowActions.vue +95 -95
- package/src/components/CnSchemaFormDialog/CnSchemaConfigurationTab.vue +226 -226
- package/src/components/CnSchemaFormDialog/CnSchemaFormDialog.vue +788 -788
- package/src/components/CnSchemaFormDialog/CnSchemaPropertiesTab.vue +305 -305
- package/src/components/CnSchemaFormDialog/CnSchemaPropertyActions.vue +1398 -1398
- package/src/components/CnSchemaFormDialog/CnSchemaSecurityTab.vue +236 -236
- package/src/components/CnSettingsCard/CnSettingsCard.vue +92 -92
- package/src/components/CnSettingsSection/CnSettingsSection.vue +267 -267
- package/src/components/CnStatsBlock/CnStatsBlock.vue +437 -437
- package/src/components/CnStatsPanel/CnStatsPanel.vue +321 -321
- package/src/components/CnStatusBadge/CnStatusBadge.vue +90 -90
- package/src/components/CnTabbedFormDialog/CnTabbedFormDialog.vue +545 -545
- package/src/components/CnTableWidget/CnTableWidget.vue +333 -333
- package/src/components/CnTasksCard/CnTasksCard.vue +374 -374
- package/src/components/CnTileWidget/CnTileWidget.vue +159 -159
- package/src/components/CnTimelineStages/CnTimelineStages.vue +294 -294
- package/src/components/CnUserActionMenu/CnUserActionMenu.vue +436 -436
- package/src/components/CnVersionInfoCard/CnVersionInfoCard.vue +313 -313
- package/src/components/CnWidgetRenderer/CnWidgetRenderer.vue +180 -180
- package/src/components/CnWidgetWrapper/CnWidgetWrapper.vue +248 -248
|
@@ -1,250 +1,250 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<div class="cn-sidebar-tab">
|
|
3
|
-
<!-- Add / Edit note -->
|
|
4
|
-
<div class="cn-sidebar-tab__action">
|
|
5
|
-
<textarea
|
|
6
|
-
v-model="newNoteText"
|
|
7
|
-
class="cn-sidebar-tab__textarea"
|
|
8
|
-
:placeholder="addNotePlaceholder"
|
|
9
|
-
rows="3" />
|
|
10
|
-
<div class="cn-sidebar-tab__action--row">
|
|
11
|
-
<NcButton
|
|
12
|
-
v-if="editingNoteId"
|
|
13
|
-
type="tertiary"
|
|
14
|
-
@click="cancelEdit">
|
|
15
|
-
{{ cancelLabel }}
|
|
16
|
-
</NcButton>
|
|
17
|
-
<NcButton
|
|
18
|
-
type="primary"
|
|
19
|
-
:disabled="!newNoteText.trim() || saving"
|
|
20
|
-
@click="editingNoteId ? saveEdit() : addNote()">
|
|
21
|
-
<template #icon>
|
|
22
|
-
<Send :size="20" />
|
|
23
|
-
</template>
|
|
24
|
-
{{ editingNoteId ? saveLabel : addNoteLabel }}
|
|
25
|
-
</NcButton>
|
|
26
|
-
</div>
|
|
27
|
-
</div>
|
|
28
|
-
|
|
29
|
-
<!-- Notes list -->
|
|
30
|
-
<NcLoadingIcon v-if="loading" />
|
|
31
|
-
<div v-else-if="notes.length === 0" class="cn-sidebar-tab__empty">
|
|
32
|
-
{{ noNotesLabel }}
|
|
33
|
-
</div>
|
|
34
|
-
<div v-else class="cn-sidebar-tab__list">
|
|
35
|
-
<NcListItem
|
|
36
|
-
v-for="note in notes"
|
|
37
|
-
:key="note.id"
|
|
38
|
-
:name="note.actorDisplayName || note.author || 'Unknown'"
|
|
39
|
-
:bold="false"
|
|
40
|
-
:force-display-actions="true">
|
|
41
|
-
<template #icon>
|
|
42
|
-
<CommentTextOutline :size="32" />
|
|
43
|
-
</template>
|
|
44
|
-
<template #subname>
|
|
45
|
-
{{ note.message || note.content }}
|
|
46
|
-
</template>
|
|
47
|
-
<template #details>
|
|
48
|
-
{{ formatDate(note.creationDateTime || note.created) }}
|
|
49
|
-
</template>
|
|
50
|
-
<template v-if="canDelete(note)" #actions>
|
|
51
|
-
<NcActionButton @click="startEdit(note)">
|
|
52
|
-
<template #icon>
|
|
53
|
-
<Pencil :size="20" />
|
|
54
|
-
</template>
|
|
55
|
-
{{ editLabel }}
|
|
56
|
-
</NcActionButton>
|
|
57
|
-
<NcActionButton @click="deleteNote(note)">
|
|
58
|
-
<template #icon>
|
|
59
|
-
<Delete :size="20" />
|
|
60
|
-
</template>
|
|
61
|
-
{{ deleteLabel }}
|
|
62
|
-
</NcActionButton>
|
|
63
|
-
</template>
|
|
64
|
-
</NcListItem>
|
|
65
|
-
</div>
|
|
66
|
-
</div>
|
|
67
|
-
</template>
|
|
68
|
-
|
|
69
|
-
<script>
|
|
70
|
-
import { translate as t } from '@nextcloud/l10n'
|
|
71
|
-
import { NcButton, NcListItem, NcActionButton, NcLoadingIcon } from '@nextcloud/vue'
|
|
72
|
-
import CommentTextOutline from 'vue-material-design-icons/CommentTextOutline.vue'
|
|
73
|
-
import Send from 'vue-material-design-icons/Send.vue'
|
|
74
|
-
import Pencil from 'vue-material-design-icons/Pencil.vue'
|
|
75
|
-
import Delete from 'vue-material-design-icons/Delete.vue'
|
|
76
|
-
import { buildHeaders } from '../../utils/index.js'
|
|
77
|
-
|
|
78
|
-
export default {
|
|
79
|
-
name: 'CnNotesTab',
|
|
80
|
-
|
|
81
|
-
components: { NcButton, NcListItem, NcActionButton, NcLoadingIcon, CommentTextOutline, Send, Pencil, Delete },
|
|
82
|
-
|
|
83
|
-
props: {
|
|
84
|
-
objectId: { type: String, required: true },
|
|
85
|
-
register: { type: String, default: '' },
|
|
86
|
-
schema: { type: String, default: '' },
|
|
87
|
-
apiBase: { type: String, default: '/apps/openregister/api' },
|
|
88
|
-
addNoteLabel: { type: String, default: () => t('nextcloud-vue', 'Add note') },
|
|
89
|
-
addNotePlaceholder: { type: String, default: () => t('nextcloud-vue', 'Write a note...') },
|
|
90
|
-
editLabel: { type: String, default: () => t('nextcloud-vue', 'Edit') },
|
|
91
|
-
saveLabel: { type: String, default: () => t('nextcloud-vue', 'Save') },
|
|
92
|
-
cancelLabel: { type: String, default: () => t('nextcloud-vue', 'Cancel') },
|
|
93
|
-
deleteLabel: { type: String, default: () => t('nextcloud-vue', 'Delete') },
|
|
94
|
-
noNotesLabel: { type: String, default: () => t('nextcloud-vue', 'No notes yet') },
|
|
95
|
-
},
|
|
96
|
-
|
|
97
|
-
data() {
|
|
98
|
-
return {
|
|
99
|
-
notes: [],
|
|
100
|
-
loading: false,
|
|
101
|
-
newNoteText: '',
|
|
102
|
-
saving: false,
|
|
103
|
-
editingNoteId: null,
|
|
104
|
-
}
|
|
105
|
-
},
|
|
106
|
-
|
|
107
|
-
watch: {
|
|
108
|
-
objectId: {
|
|
109
|
-
immediate: true,
|
|
110
|
-
handler(id) { if (id) this.fetchNotes() },
|
|
111
|
-
},
|
|
112
|
-
},
|
|
113
|
-
|
|
114
|
-
methods: {
|
|
115
|
-
async fetchNotes() {
|
|
116
|
-
if (!this.register || !this.schema) return
|
|
117
|
-
this.loading = true
|
|
118
|
-
try {
|
|
119
|
-
const response = await fetch(
|
|
120
|
-
`${this.apiBase}/objects/${this.register}/${this.schema}/${this.objectId}/notes`,
|
|
121
|
-
{ headers: buildHeaders() },
|
|
122
|
-
)
|
|
123
|
-
if (response.ok) {
|
|
124
|
-
const data = await response.json()
|
|
125
|
-
this.notes = data.results || data || []
|
|
126
|
-
}
|
|
127
|
-
} catch (err) {
|
|
128
|
-
console.error('CnNotesTab: Failed to fetch notes', err)
|
|
129
|
-
} finally {
|
|
130
|
-
this.loading = false
|
|
131
|
-
}
|
|
132
|
-
},
|
|
133
|
-
|
|
134
|
-
async addNote() {
|
|
135
|
-
if (!this.newNoteText.trim()) return
|
|
136
|
-
this.saving = true
|
|
137
|
-
try {
|
|
138
|
-
await fetch(
|
|
139
|
-
`${this.apiBase}/objects/${this.register}/${this.schema}/${this.objectId}/notes`,
|
|
140
|
-
{
|
|
141
|
-
method: 'POST',
|
|
142
|
-
headers: buildHeaders(),
|
|
143
|
-
body: JSON.stringify({ message: this.newNoteText.trim() }),
|
|
144
|
-
},
|
|
145
|
-
)
|
|
146
|
-
this.newNoteText = ''
|
|
147
|
-
await this.fetchNotes()
|
|
148
|
-
} catch (err) {
|
|
149
|
-
console.error('CnNotesTab: Failed to add note', err)
|
|
150
|
-
} finally {
|
|
151
|
-
this.saving = false
|
|
152
|
-
}
|
|
153
|
-
},
|
|
154
|
-
|
|
155
|
-
startEdit(note) {
|
|
156
|
-
this.editingNoteId = note.id
|
|
157
|
-
this.newNoteText = note.message || note.content || ''
|
|
158
|
-
},
|
|
159
|
-
|
|
160
|
-
cancelEdit() {
|
|
161
|
-
this.editingNoteId = null
|
|
162
|
-
this.newNoteText = ''
|
|
163
|
-
},
|
|
164
|
-
|
|
165
|
-
async saveEdit() {
|
|
166
|
-
if (!this.newNoteText.trim() || !this.editingNoteId) return
|
|
167
|
-
this.saving = true
|
|
168
|
-
try {
|
|
169
|
-
await fetch(
|
|
170
|
-
`${this.apiBase}/objects/${this.register}/${this.schema}/${this.objectId}/notes/${this.editingNoteId}`,
|
|
171
|
-
{
|
|
172
|
-
method: 'PUT',
|
|
173
|
-
headers: buildHeaders(),
|
|
174
|
-
body: JSON.stringify({ message: this.newNoteText.trim() }),
|
|
175
|
-
},
|
|
176
|
-
)
|
|
177
|
-
this.editingNoteId = null
|
|
178
|
-
this.newNoteText = ''
|
|
179
|
-
await this.fetchNotes()
|
|
180
|
-
} catch (err) {
|
|
181
|
-
console.error('CnNotesTab: Failed to update note', err)
|
|
182
|
-
} finally {
|
|
183
|
-
this.saving = false
|
|
184
|
-
}
|
|
185
|
-
},
|
|
186
|
-
|
|
187
|
-
canDelete(note) {
|
|
188
|
-
return note.actorId === OC?.currentUser || note.author === OC?.currentUser
|
|
189
|
-
},
|
|
190
|
-
|
|
191
|
-
async deleteNote(note) {
|
|
192
|
-
try {
|
|
193
|
-
await fetch(
|
|
194
|
-
`${this.apiBase}/objects/${this.register}/${this.schema}/${this.objectId}/notes/${note.id}`,
|
|
195
|
-
{ method: 'DELETE', headers: buildHeaders() },
|
|
196
|
-
)
|
|
197
|
-
this.notes = this.notes.filter(n => n.id !== note.id)
|
|
198
|
-
} catch (err) {
|
|
199
|
-
console.error('CnNotesTab: Failed to delete note', err)
|
|
200
|
-
}
|
|
201
|
-
},
|
|
202
|
-
|
|
203
|
-
formatDate(dateStr) {
|
|
204
|
-
if (!dateStr) return ''
|
|
205
|
-
try {
|
|
206
|
-
return new Date(dateStr).toLocaleString(undefined, {
|
|
207
|
-
year: 'numeric',
|
|
208
|
-
month: 'short',
|
|
209
|
-
day: 'numeric',
|
|
210
|
-
hour: '2-digit',
|
|
211
|
-
minute: '2-digit',
|
|
212
|
-
})
|
|
213
|
-
} catch { return dateStr }
|
|
214
|
-
},
|
|
215
|
-
},
|
|
216
|
-
}
|
|
217
|
-
</script>
|
|
218
|
-
|
|
219
|
-
<style scoped>
|
|
220
|
-
.cn-sidebar-tab { padding: 12px; }
|
|
221
|
-
.cn-sidebar-tab__action { margin-bottom: 16px; }
|
|
222
|
-
.cn-sidebar-tab__action--row { display: flex; gap: 8px; align-items: flex-end; }
|
|
223
|
-
|
|
224
|
-
.cn-sidebar-tab__textarea {
|
|
225
|
-
width: 100%;
|
|
226
|
-
padding: 8px;
|
|
227
|
-
border: 1px solid var(--color-border);
|
|
228
|
-
border-radius: var(--border-radius);
|
|
229
|
-
resize: vertical;
|
|
230
|
-
font-family: inherit;
|
|
231
|
-
font-size: 13px;
|
|
232
|
-
margin-bottom: 8px;
|
|
233
|
-
background: var(--color-main-background);
|
|
234
|
-
color: var(--color-main-text);
|
|
235
|
-
}
|
|
236
|
-
|
|
237
|
-
.cn-sidebar-tab__textarea:focus {
|
|
238
|
-
border-color: var(--color-primary-element);
|
|
239
|
-
outline: none;
|
|
240
|
-
}
|
|
241
|
-
|
|
242
|
-
.cn-sidebar-tab__empty {
|
|
243
|
-
text-align: center;
|
|
244
|
-
padding: 24px 12px;
|
|
245
|
-
color: var(--color-text-maxcontrast);
|
|
246
|
-
font-size: 13px;
|
|
247
|
-
}
|
|
248
|
-
|
|
249
|
-
.cn-sidebar-tab__list { display: flex; flex-direction: column; gap: 2px; }
|
|
250
|
-
</style>
|
|
1
|
+
<template>
|
|
2
|
+
<div class="cn-sidebar-tab">
|
|
3
|
+
<!-- Add / Edit note -->
|
|
4
|
+
<div class="cn-sidebar-tab__action">
|
|
5
|
+
<textarea
|
|
6
|
+
v-model="newNoteText"
|
|
7
|
+
class="cn-sidebar-tab__textarea"
|
|
8
|
+
:placeholder="addNotePlaceholder"
|
|
9
|
+
rows="3" />
|
|
10
|
+
<div class="cn-sidebar-tab__action--row">
|
|
11
|
+
<NcButton
|
|
12
|
+
v-if="editingNoteId"
|
|
13
|
+
type="tertiary"
|
|
14
|
+
@click="cancelEdit">
|
|
15
|
+
{{ cancelLabel }}
|
|
16
|
+
</NcButton>
|
|
17
|
+
<NcButton
|
|
18
|
+
type="primary"
|
|
19
|
+
:disabled="!newNoteText.trim() || saving"
|
|
20
|
+
@click="editingNoteId ? saveEdit() : addNote()">
|
|
21
|
+
<template #icon>
|
|
22
|
+
<Send :size="20" />
|
|
23
|
+
</template>
|
|
24
|
+
{{ editingNoteId ? saveLabel : addNoteLabel }}
|
|
25
|
+
</NcButton>
|
|
26
|
+
</div>
|
|
27
|
+
</div>
|
|
28
|
+
|
|
29
|
+
<!-- Notes list -->
|
|
30
|
+
<NcLoadingIcon v-if="loading" />
|
|
31
|
+
<div v-else-if="notes.length === 0" class="cn-sidebar-tab__empty">
|
|
32
|
+
{{ noNotesLabel }}
|
|
33
|
+
</div>
|
|
34
|
+
<div v-else class="cn-sidebar-tab__list">
|
|
35
|
+
<NcListItem
|
|
36
|
+
v-for="note in notes"
|
|
37
|
+
:key="note.id"
|
|
38
|
+
:name="note.actorDisplayName || note.author || 'Unknown'"
|
|
39
|
+
:bold="false"
|
|
40
|
+
:force-display-actions="true">
|
|
41
|
+
<template #icon>
|
|
42
|
+
<CommentTextOutline :size="32" />
|
|
43
|
+
</template>
|
|
44
|
+
<template #subname>
|
|
45
|
+
{{ note.message || note.content }}
|
|
46
|
+
</template>
|
|
47
|
+
<template #details>
|
|
48
|
+
{{ formatDate(note.creationDateTime || note.created) }}
|
|
49
|
+
</template>
|
|
50
|
+
<template v-if="canDelete(note)" #actions>
|
|
51
|
+
<NcActionButton @click="startEdit(note)">
|
|
52
|
+
<template #icon>
|
|
53
|
+
<Pencil :size="20" />
|
|
54
|
+
</template>
|
|
55
|
+
{{ editLabel }}
|
|
56
|
+
</NcActionButton>
|
|
57
|
+
<NcActionButton @click="deleteNote(note)">
|
|
58
|
+
<template #icon>
|
|
59
|
+
<Delete :size="20" />
|
|
60
|
+
</template>
|
|
61
|
+
{{ deleteLabel }}
|
|
62
|
+
</NcActionButton>
|
|
63
|
+
</template>
|
|
64
|
+
</NcListItem>
|
|
65
|
+
</div>
|
|
66
|
+
</div>
|
|
67
|
+
</template>
|
|
68
|
+
|
|
69
|
+
<script>
|
|
70
|
+
import { translate as t } from '@nextcloud/l10n'
|
|
71
|
+
import { NcButton, NcListItem, NcActionButton, NcLoadingIcon } from '@nextcloud/vue'
|
|
72
|
+
import CommentTextOutline from 'vue-material-design-icons/CommentTextOutline.vue'
|
|
73
|
+
import Send from 'vue-material-design-icons/Send.vue'
|
|
74
|
+
import Pencil from 'vue-material-design-icons/Pencil.vue'
|
|
75
|
+
import Delete from 'vue-material-design-icons/Delete.vue'
|
|
76
|
+
import { buildHeaders } from '../../utils/index.js'
|
|
77
|
+
|
|
78
|
+
export default {
|
|
79
|
+
name: 'CnNotesTab',
|
|
80
|
+
|
|
81
|
+
components: { NcButton, NcListItem, NcActionButton, NcLoadingIcon, CommentTextOutline, Send, Pencil, Delete },
|
|
82
|
+
|
|
83
|
+
props: {
|
|
84
|
+
objectId: { type: String, required: true },
|
|
85
|
+
register: { type: String, default: '' },
|
|
86
|
+
schema: { type: String, default: '' },
|
|
87
|
+
apiBase: { type: String, default: '/apps/openregister/api' },
|
|
88
|
+
addNoteLabel: { type: String, default: () => t('nextcloud-vue', 'Add note') },
|
|
89
|
+
addNotePlaceholder: { type: String, default: () => t('nextcloud-vue', 'Write a note...') },
|
|
90
|
+
editLabel: { type: String, default: () => t('nextcloud-vue', 'Edit') },
|
|
91
|
+
saveLabel: { type: String, default: () => t('nextcloud-vue', 'Save') },
|
|
92
|
+
cancelLabel: { type: String, default: () => t('nextcloud-vue', 'Cancel') },
|
|
93
|
+
deleteLabel: { type: String, default: () => t('nextcloud-vue', 'Delete') },
|
|
94
|
+
noNotesLabel: { type: String, default: () => t('nextcloud-vue', 'No notes yet') },
|
|
95
|
+
},
|
|
96
|
+
|
|
97
|
+
data() {
|
|
98
|
+
return {
|
|
99
|
+
notes: [],
|
|
100
|
+
loading: false,
|
|
101
|
+
newNoteText: '',
|
|
102
|
+
saving: false,
|
|
103
|
+
editingNoteId: null,
|
|
104
|
+
}
|
|
105
|
+
},
|
|
106
|
+
|
|
107
|
+
watch: {
|
|
108
|
+
objectId: {
|
|
109
|
+
immediate: true,
|
|
110
|
+
handler(id) { if (id) this.fetchNotes() },
|
|
111
|
+
},
|
|
112
|
+
},
|
|
113
|
+
|
|
114
|
+
methods: {
|
|
115
|
+
async fetchNotes() {
|
|
116
|
+
if (!this.register || !this.schema) return
|
|
117
|
+
this.loading = true
|
|
118
|
+
try {
|
|
119
|
+
const response = await fetch(
|
|
120
|
+
`${this.apiBase}/objects/${this.register}/${this.schema}/${this.objectId}/notes`,
|
|
121
|
+
{ headers: buildHeaders() },
|
|
122
|
+
)
|
|
123
|
+
if (response.ok) {
|
|
124
|
+
const data = await response.json()
|
|
125
|
+
this.notes = data.results || data || []
|
|
126
|
+
}
|
|
127
|
+
} catch (err) {
|
|
128
|
+
console.error('CnNotesTab: Failed to fetch notes', err)
|
|
129
|
+
} finally {
|
|
130
|
+
this.loading = false
|
|
131
|
+
}
|
|
132
|
+
},
|
|
133
|
+
|
|
134
|
+
async addNote() {
|
|
135
|
+
if (!this.newNoteText.trim()) return
|
|
136
|
+
this.saving = true
|
|
137
|
+
try {
|
|
138
|
+
await fetch(
|
|
139
|
+
`${this.apiBase}/objects/${this.register}/${this.schema}/${this.objectId}/notes`,
|
|
140
|
+
{
|
|
141
|
+
method: 'POST',
|
|
142
|
+
headers: buildHeaders(),
|
|
143
|
+
body: JSON.stringify({ message: this.newNoteText.trim() }),
|
|
144
|
+
},
|
|
145
|
+
)
|
|
146
|
+
this.newNoteText = ''
|
|
147
|
+
await this.fetchNotes()
|
|
148
|
+
} catch (err) {
|
|
149
|
+
console.error('CnNotesTab: Failed to add note', err)
|
|
150
|
+
} finally {
|
|
151
|
+
this.saving = false
|
|
152
|
+
}
|
|
153
|
+
},
|
|
154
|
+
|
|
155
|
+
startEdit(note) {
|
|
156
|
+
this.editingNoteId = note.id
|
|
157
|
+
this.newNoteText = note.message || note.content || ''
|
|
158
|
+
},
|
|
159
|
+
|
|
160
|
+
cancelEdit() {
|
|
161
|
+
this.editingNoteId = null
|
|
162
|
+
this.newNoteText = ''
|
|
163
|
+
},
|
|
164
|
+
|
|
165
|
+
async saveEdit() {
|
|
166
|
+
if (!this.newNoteText.trim() || !this.editingNoteId) return
|
|
167
|
+
this.saving = true
|
|
168
|
+
try {
|
|
169
|
+
await fetch(
|
|
170
|
+
`${this.apiBase}/objects/${this.register}/${this.schema}/${this.objectId}/notes/${this.editingNoteId}`,
|
|
171
|
+
{
|
|
172
|
+
method: 'PUT',
|
|
173
|
+
headers: buildHeaders(),
|
|
174
|
+
body: JSON.stringify({ message: this.newNoteText.trim() }),
|
|
175
|
+
},
|
|
176
|
+
)
|
|
177
|
+
this.editingNoteId = null
|
|
178
|
+
this.newNoteText = ''
|
|
179
|
+
await this.fetchNotes()
|
|
180
|
+
} catch (err) {
|
|
181
|
+
console.error('CnNotesTab: Failed to update note', err)
|
|
182
|
+
} finally {
|
|
183
|
+
this.saving = false
|
|
184
|
+
}
|
|
185
|
+
},
|
|
186
|
+
|
|
187
|
+
canDelete(note) {
|
|
188
|
+
return note.actorId === OC?.currentUser || note.author === OC?.currentUser
|
|
189
|
+
},
|
|
190
|
+
|
|
191
|
+
async deleteNote(note) {
|
|
192
|
+
try {
|
|
193
|
+
await fetch(
|
|
194
|
+
`${this.apiBase}/objects/${this.register}/${this.schema}/${this.objectId}/notes/${note.id}`,
|
|
195
|
+
{ method: 'DELETE', headers: buildHeaders() },
|
|
196
|
+
)
|
|
197
|
+
this.notes = this.notes.filter(n => n.id !== note.id)
|
|
198
|
+
} catch (err) {
|
|
199
|
+
console.error('CnNotesTab: Failed to delete note', err)
|
|
200
|
+
}
|
|
201
|
+
},
|
|
202
|
+
|
|
203
|
+
formatDate(dateStr) {
|
|
204
|
+
if (!dateStr) return ''
|
|
205
|
+
try {
|
|
206
|
+
return new Date(dateStr).toLocaleString(undefined, {
|
|
207
|
+
year: 'numeric',
|
|
208
|
+
month: 'short',
|
|
209
|
+
day: 'numeric',
|
|
210
|
+
hour: '2-digit',
|
|
211
|
+
minute: '2-digit',
|
|
212
|
+
})
|
|
213
|
+
} catch { return dateStr }
|
|
214
|
+
},
|
|
215
|
+
},
|
|
216
|
+
}
|
|
217
|
+
</script>
|
|
218
|
+
|
|
219
|
+
<style scoped>
|
|
220
|
+
.cn-sidebar-tab { padding: 12px; }
|
|
221
|
+
.cn-sidebar-tab__action { margin-bottom: 16px; }
|
|
222
|
+
.cn-sidebar-tab__action--row { display: flex; gap: 8px; align-items: flex-end; }
|
|
223
|
+
|
|
224
|
+
.cn-sidebar-tab__textarea {
|
|
225
|
+
width: 100%;
|
|
226
|
+
padding: 8px;
|
|
227
|
+
border: 1px solid var(--color-border);
|
|
228
|
+
border-radius: var(--border-radius);
|
|
229
|
+
resize: vertical;
|
|
230
|
+
font-family: inherit;
|
|
231
|
+
font-size: 13px;
|
|
232
|
+
margin-bottom: 8px;
|
|
233
|
+
background: var(--color-main-background);
|
|
234
|
+
color: var(--color-main-text);
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
.cn-sidebar-tab__textarea:focus {
|
|
238
|
+
border-color: var(--color-primary-element);
|
|
239
|
+
outline: none;
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
.cn-sidebar-tab__empty {
|
|
243
|
+
text-align: center;
|
|
244
|
+
padding: 24px 12px;
|
|
245
|
+
color: var(--color-text-maxcontrast);
|
|
246
|
+
font-size: 13px;
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
.cn-sidebar-tab__list { display: flex; flex-direction: column; gap: 2px; }
|
|
250
|
+
</style>
|