@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,483 +1,483 @@
1
- <template>
2
- <div class="cn-sidebar-tab">
3
- <!-- Add / Edit task -->
4
- <div class="cn-sidebar-tab__section">
5
- <div class="cn-sidebar-tab__action--row">
6
- <NcTextField
7
- v-model="newTaskSummary"
8
- :label="editingTaskId ? editLabel : addTaskPlaceholder"
9
- @keyup.enter="editingTaskId ? saveEdit() : addTask()" />
10
- <NcButton
11
- v-if="editingTaskId"
12
- type="tertiary"
13
- @click="cancelEdit">
14
- <template #icon>
15
- <Close :size="20" />
16
- </template>
17
- </NcButton>
18
- <NcButton
19
- type="primary"
20
- :disabled="!newTaskSummary.trim() || saving"
21
- @click="editingTaskId ? saveEdit() : addTask()">
22
- <template #icon>
23
- <Plus v-if="!editingTaskId" :size="20" />
24
- <ContentSave v-else :size="20" />
25
- </template>
26
- </NcButton>
27
- </div>
28
- <div class="cn-sidebar-tab__grid">
29
- <NcDateTimePickerNative
30
- id="task-deadline"
31
- v-model="newTaskDue"
32
- :label="deadlineLabel"
33
- type="date" />
34
- <NcSelect
35
- v-model="newTaskAssignee"
36
- :options="userList"
37
- :placeholder="assigneeLabel"
38
- :input-label="assigneeLabel"
39
- label="displayName"
40
- track-by="userId"
41
- :clearable="true" />
42
- </div>
43
- </div>
44
-
45
- <!-- Filters -->
46
- <div v-if="tasks.length > 0 || filterStatus || filterAssignee" class="cn-sidebar-tab__section cn-sidebar-tab__section--filters">
47
- <div class="cn-sidebar-tab__grid">
48
- <NcSelect
49
- v-model="filterStatus"
50
- :options="statusOptions"
51
- :placeholder="statusFilterLabel"
52
- :input-label="statusFilterLabel"
53
- :clearable="true" />
54
- <NcSelect
55
- v-model="filterAssignee"
56
- :options="assigneeOptions"
57
- :placeholder="assigneeFilterLabel"
58
- :input-label="assigneeFilterLabel"
59
- :clearable="true" />
60
- </div>
61
- </div>
62
-
63
- <!-- Tasks list -->
64
- <NcLoadingIcon v-if="loading" />
65
- <div v-else-if="filteredTasks.length === 0" class="cn-sidebar-tab__empty">
66
- {{ noTasksLabel }}
67
- </div>
68
- <div v-else class="cn-sidebar-tab__list">
69
- <NcListItem
70
- v-for="task in filteredTasks"
71
- :key="task.id"
72
- :name="task.summary || task.title || task.name"
73
- :bold="false"
74
- :force-display-actions="true"
75
- :class="{ 'cn-sidebar-tab__task--overdue': isOverdue(task) }">
76
- <template #icon>
77
- <button class="cn-sidebar-tab__task-checkbox" @click.stop="toggleTask(task)">
78
- <CheckboxMarkedOutline v-if="task.status === 'completed'" :size="32" class="cn-sidebar-tab__task-done" />
79
- <CheckboxBlankOutline v-else :size="32" :class="{ 'cn-sidebar-tab__task-overdue-icon': isOverdue(task) }" />
80
- </button>
81
- </template>
82
- <template #subname>
83
- {{ extractAssignee(task) }}
84
- </template>
85
- <template v-if="task.due" #details>
86
- <span :class="{ 'cn-sidebar-tab__task-overdue-date': isOverdue(task) }">
87
- {{ formatShortDate(task.due) }}
88
- </span>
89
- </template>
90
- <template #actions>
91
- <NcActionButton @click="startEdit(task)">
92
- <template #icon>
93
- <Pencil :size="20" />
94
- </template>
95
- {{ editLabel }}
96
- </NcActionButton>
97
- <NcActionButton v-if="task.status !== 'completed'" @click="completeTask(task)">
98
- <template #icon>
99
- <CheckboxMarkedOutline :size="20" />
100
- </template>
101
- {{ completeLabel }}
102
- </NcActionButton>
103
- <NcActionButton @click="deleteTask(task)">
104
- <template #icon>
105
- <Delete :size="20" />
106
- </template>
107
- {{ deleteLabel }}
108
- </NcActionButton>
109
- </template>
110
- </NcListItem>
111
- </div>
112
- <NcButton
113
- v-if="tasks.length < total"
114
- type="tertiary"
115
- :wide="true"
116
- :disabled="loadingMore"
117
- class="cn-sidebar-tab__load-more"
118
- @click="loadMore">
119
- <template v-if="loadingMore" #icon>
120
- <NcLoadingIcon :size="20" />
121
- </template>
122
- {{ loadingMore ? '' : loadMoreLabel }}
123
- </NcButton>
124
- </div>
125
- </template>
126
-
127
- <script>
128
- import { translate as t } from '@nextcloud/l10n'
129
- import { NcButton, NcTextField, NcListItem, NcActionButton, NcLoadingIcon, NcDateTimePickerNative, NcSelect } from '@nextcloud/vue'
130
- import Plus from 'vue-material-design-icons/Plus.vue'
131
- import Delete from 'vue-material-design-icons/Delete.vue'
132
- import Pencil from 'vue-material-design-icons/Pencil.vue'
133
- import Close from 'vue-material-design-icons/Close.vue'
134
- import ContentSave from 'vue-material-design-icons/ContentSave.vue'
135
- import CheckboxMarkedOutline from 'vue-material-design-icons/CheckboxMarkedOutline.vue'
136
- import CheckboxBlankOutline from 'vue-material-design-icons/CheckboxBlankOutline.vue'
137
- import { buildHeaders } from '../../utils/index.js'
138
-
139
- export default {
140
- name: 'CnTasksTab',
141
-
142
- components: {
143
- NcButton,
144
- NcTextField,
145
- NcListItem,
146
- NcActionButton,
147
- NcLoadingIcon,
148
- NcDateTimePickerNative,
149
- NcSelect,
150
- Plus,
151
- Delete,
152
- Pencil,
153
- Close,
154
- ContentSave,
155
- CheckboxMarkedOutline,
156
- CheckboxBlankOutline,
157
- },
158
-
159
- props: {
160
- objectId: { type: String, required: true },
161
- register: { type: String, default: '' },
162
- schema: { type: String, default: '' },
163
- apiBase: { type: String, default: '/apps/openregister/api' },
164
- addTaskPlaceholder: { type: String, default: () => t('nextcloud-vue', 'Add task...') },
165
- deadlineLabel: { type: String, default: () => t('nextcloud-vue', 'Deadline') },
166
- assigneeLabel: { type: String, default: () => t('nextcloud-vue', 'Assignee') },
167
- completeLabel: { type: String, default: () => t('nextcloud-vue', 'Complete') },
168
- editLabel: { type: String, default: () => t('nextcloud-vue', 'Edit') },
169
- deleteLabel: { type: String, default: () => t('nextcloud-vue', 'Delete') },
170
- noTasksLabel: { type: String, default: () => t('nextcloud-vue', 'No linked tasks') },
171
- loadMoreLabel: { type: String, default: () => t('nextcloud-vue', 'Load more') },
172
- statusFilterLabel: { type: String, default: () => t('nextcloud-vue', 'Status') },
173
- assigneeFilterLabel: { type: String, default: () => t('nextcloud-vue', 'Assignee') },
174
- },
175
-
176
- data() {
177
- return {
178
- tasks: [],
179
- loading: false,
180
- loadingMore: false,
181
- newTaskSummary: '',
182
- newTaskDue: null,
183
- newTaskAssignee: null,
184
- saving: false,
185
- editingTaskId: null,
186
- userList: [],
187
- page: 1,
188
- total: 0,
189
- limit: 20,
190
- filterStatus: null,
191
- filterAssignee: null,
192
- }
193
- },
194
-
195
- computed: {
196
- statusOptions() {
197
- return [...new Set(this.tasks.map(t => t.status).filter(Boolean))]
198
- },
199
- assigneeOptions() {
200
- return [...new Set(this.tasks.map(t => this.extractAssignee(t)).filter(Boolean))]
201
- },
202
- filteredTasks() {
203
- let result = this.tasks
204
- if (this.filterStatus) {
205
- result = result.filter(t => t.status === this.filterStatus)
206
- }
207
- if (this.filterAssignee) {
208
- result = result.filter(t => this.extractAssignee(t) === this.filterAssignee)
209
- }
210
- return result
211
- },
212
- },
213
-
214
- watch: {
215
- objectId: {
216
- immediate: true,
217
- handler(id) {
218
- if (id) {
219
- this.fetchTasks()
220
- this.fetchUsers()
221
- }
222
- },
223
- },
224
- },
225
-
226
- methods: {
227
- async fetchTasks(append = false) {
228
- if (!this.register || !this.schema) return
229
- if (append) { this.loadingMore = true } else { this.loading = true }
230
- try {
231
- const params = new URLSearchParams({ limit: this.limit, _page: this.page })
232
- const response = await fetch(
233
- `${this.apiBase}/objects/${this.register}/${this.schema}/${this.objectId}/tasks?${params}`,
234
- { headers: buildHeaders() },
235
- )
236
- if (response.ok) {
237
- const data = await response.json()
238
- const results = data.results || data || []
239
- this.tasks = append ? [...this.tasks, ...results] : results
240
- this.total = data.total || this.tasks.length
241
- }
242
- } catch (err) {
243
- console.error('CnTasksTab: Failed to fetch tasks', err)
244
- } finally {
245
- this.loading = false
246
- this.loadingMore = false
247
- }
248
- },
249
-
250
- loadMore() {
251
- this.page++
252
- this.fetchTasks(true)
253
- },
254
-
255
- isOverdue(task) {
256
- if (!task.due || task.status === 'completed') return false
257
- return new Date(task.due) < new Date()
258
- },
259
-
260
- async fetchUsers() {
261
- try {
262
- const response = await fetch('/ocs/v2.php/cloud/users/details?format=json&limit=50', {
263
- headers: buildHeaders(),
264
- })
265
- if (response.ok) {
266
- const data = await response.json()
267
- const users = data.ocs?.data?.users || {}
268
- this.userList = Object.entries(users).map(([id, user]) => ({
269
- userId: id,
270
- displayName: user.displayname || id,
271
- }))
272
- }
273
- } catch (err) {
274
- console.error('CnTasksTab: Failed to fetch users', err)
275
- }
276
- },
277
-
278
- async addTask() {
279
- if (!this.newTaskSummary.trim() || !this.register || !this.schema) return
280
- this.saving = true
281
- try {
282
- const taskData = { summary: this.newTaskSummary.trim() }
283
- if (this.newTaskDue) {
284
- taskData.due = new Date(this.newTaskDue).toISOString()
285
- }
286
- if (this.newTaskAssignee) {
287
- taskData.description = 'Assigned to: ' + this.newTaskAssignee.displayName
288
- }
289
- await fetch(
290
- `${this.apiBase}/objects/${this.register}/${this.schema}/${this.objectId}/tasks`,
291
- {
292
- method: 'POST',
293
- headers: buildHeaders(),
294
- body: JSON.stringify(taskData),
295
- },
296
- )
297
- this.clearForm()
298
- await this.fetchTasks()
299
- } catch (err) {
300
- console.error('CnTasksTab: Failed to add task', err)
301
- } finally {
302
- this.saving = false
303
- }
304
- },
305
-
306
- startEdit(task) {
307
- this.editingTaskId = task.id
308
- this.newTaskSummary = task.summary || task.title || task.name || ''
309
- this.newTaskDue = task.due ? new Date(task.due).toISOString().split('T')[0] : null
310
- const assigneeName = this.extractAssignee(task)
311
- this.newTaskAssignee = this.userList.find(u => u.displayName === assigneeName) || null
312
- },
313
-
314
- cancelEdit() {
315
- this.editingTaskId = null
316
- this.clearForm()
317
- },
318
-
319
- async saveEdit() {
320
- if (!this.newTaskSummary.trim() || !this.editingTaskId) return
321
- this.saving = true
322
- try {
323
- const taskData = { summary: this.newTaskSummary.trim() }
324
- if (this.newTaskDue) {
325
- taskData.due = new Date(this.newTaskDue).toISOString()
326
- } else {
327
- taskData.due = ''
328
- }
329
- if (this.newTaskAssignee) {
330
- taskData.description = 'Assigned to: ' + this.newTaskAssignee.displayName
331
- } else {
332
- taskData.description = ''
333
- }
334
- await fetch(
335
- `${this.apiBase}/objects/${this.register}/${this.schema}/${this.objectId}/tasks/${encodeURIComponent(this.editingTaskId)}`,
336
- {
337
- method: 'PUT',
338
- headers: buildHeaders(),
339
- body: JSON.stringify(taskData),
340
- },
341
- )
342
- this.editingTaskId = null
343
- this.clearForm()
344
- await this.fetchTasks()
345
- } catch (err) {
346
- console.error('CnTasksTab: Failed to update task', err)
347
- } finally {
348
- this.saving = false
349
- }
350
- },
351
-
352
- clearForm() {
353
- this.newTaskSummary = ''
354
- this.newTaskDue = null
355
- this.newTaskAssignee = null
356
- },
357
-
358
- async toggleTask(task) {
359
- const newStatus = task.status === 'completed' ? 'NEEDS-ACTION' : 'COMPLETED'
360
- try {
361
- await fetch(
362
- `${this.apiBase}/objects/${this.register}/${this.schema}/${this.objectId}/tasks/${encodeURIComponent(task.id)}`,
363
- {
364
- method: 'PUT',
365
- headers: buildHeaders(),
366
- body: JSON.stringify({ status: newStatus }),
367
- },
368
- )
369
- await this.fetchTasks()
370
- } catch (err) {
371
- console.error('CnTasksTab: Failed to toggle task', err)
372
- }
373
- },
374
-
375
- async completeTask(task) {
376
- try {
377
- await fetch(
378
- `${this.apiBase}/objects/${this.register}/${this.schema}/${this.objectId}/tasks/${encodeURIComponent(task.id)}`,
379
- {
380
- method: 'PUT',
381
- headers: buildHeaders(),
382
- body: JSON.stringify({ status: 'COMPLETED' }),
383
- },
384
- )
385
- await this.fetchTasks()
386
- } catch (err) {
387
- console.error('CnTasksTab: Failed to complete task', err)
388
- }
389
- },
390
-
391
- async deleteTask(task) {
392
- try {
393
- await fetch(
394
- `${this.apiBase}/objects/${this.register}/${this.schema}/${this.objectId}/tasks/${encodeURIComponent(task.id)}`,
395
- { method: 'DELETE', headers: buildHeaders() },
396
- )
397
- this.tasks = this.tasks.filter(t => t.id !== task.id)
398
- } catch (err) {
399
- console.error('CnTasksTab: Failed to delete task', err)
400
- }
401
- },
402
-
403
- extractAssignee(task) {
404
- if (task.description?.startsWith('Assigned to: ')) {
405
- return task.description.replace('Assigned to: ', '')
406
- }
407
- return task.description || ''
408
- },
409
-
410
- formatShortDate(dateStr) {
411
- if (!dateStr) return ''
412
- try {
413
- return new Date(dateStr).toLocaleDateString(undefined, {
414
- day: 'numeric', month: 'short',
415
- })
416
- } catch { return dateStr }
417
- },
418
- },
419
- }
420
- </script>
421
-
422
- <style scoped>
423
- .cn-sidebar-tab {
424
- padding: 12px;
425
- overflow-x: hidden;
426
- }
427
-
428
- .cn-sidebar-tab__section {
429
- margin-bottom: 12px;
430
- }
431
-
432
- .cn-sidebar-tab__section--filters {
433
- padding-top: 12px;
434
- border-top: 1px solid var(--color-border);
435
- }
436
-
437
- .cn-sidebar-tab__action--row {
438
- display: flex;
439
- gap: 8px;
440
- align-items: flex-end;
441
- margin-bottom: 8px;
442
- }
443
-
444
- .cn-sidebar-tab__grid {
445
- display: grid;
446
- grid-template-columns: 1fr 1fr;
447
- gap: 8px;
448
- }
449
-
450
- .cn-sidebar-tab__grid > * {
451
- min-width: 0;
452
- }
453
-
454
- .cn-sidebar-tab__empty {
455
- text-align: center;
456
- padding: 24px 12px;
457
- color: var(--color-text-maxcontrast);
458
- font-size: 13px;
459
- }
460
-
461
- .cn-sidebar-tab__list {
462
- display: flex;
463
- flex-direction: column;
464
- gap: 2px;
465
- }
466
-
467
- .cn-sidebar-tab__load-more { margin-top: 8px; }
468
-
469
- .cn-sidebar-tab__task-checkbox {
470
- display: flex;
471
- align-items: center;
472
- justify-content: center;
473
- background: none;
474
- border: none;
475
- padding: 0;
476
- cursor: pointer;
477
- color: inherit;
478
- }
479
-
480
- .cn-sidebar-tab__task-done { color: var(--color-success); }
481
- .cn-sidebar-tab__task-overdue-icon { color: var(--color-error, #e53935); }
482
- .cn-sidebar-tab__task-overdue-date { color: var(--color-error, #e53935); font-weight: 500; }
483
- </style>
1
+ <template>
2
+ <div class="cn-sidebar-tab">
3
+ <!-- Add / Edit task -->
4
+ <div class="cn-sidebar-tab__section">
5
+ <div class="cn-sidebar-tab__action--row">
6
+ <NcTextField
7
+ v-model="newTaskSummary"
8
+ :label="editingTaskId ? editLabel : addTaskPlaceholder"
9
+ @keyup.enter="editingTaskId ? saveEdit() : addTask()" />
10
+ <NcButton
11
+ v-if="editingTaskId"
12
+ type="tertiary"
13
+ @click="cancelEdit">
14
+ <template #icon>
15
+ <Close :size="20" />
16
+ </template>
17
+ </NcButton>
18
+ <NcButton
19
+ type="primary"
20
+ :disabled="!newTaskSummary.trim() || saving"
21
+ @click="editingTaskId ? saveEdit() : addTask()">
22
+ <template #icon>
23
+ <Plus v-if="!editingTaskId" :size="20" />
24
+ <ContentSave v-else :size="20" />
25
+ </template>
26
+ </NcButton>
27
+ </div>
28
+ <div class="cn-sidebar-tab__grid">
29
+ <NcDateTimePickerNative
30
+ id="task-deadline"
31
+ v-model="newTaskDue"
32
+ :label="deadlineLabel"
33
+ type="date" />
34
+ <NcSelect
35
+ v-model="newTaskAssignee"
36
+ :options="userList"
37
+ :placeholder="assigneeLabel"
38
+ :input-label="assigneeLabel"
39
+ label="displayName"
40
+ track-by="userId"
41
+ :clearable="true" />
42
+ </div>
43
+ </div>
44
+
45
+ <!-- Filters -->
46
+ <div v-if="tasks.length > 0 || filterStatus || filterAssignee" class="cn-sidebar-tab__section cn-sidebar-tab__section--filters">
47
+ <div class="cn-sidebar-tab__grid">
48
+ <NcSelect
49
+ v-model="filterStatus"
50
+ :options="statusOptions"
51
+ :placeholder="statusFilterLabel"
52
+ :input-label="statusFilterLabel"
53
+ :clearable="true" />
54
+ <NcSelect
55
+ v-model="filterAssignee"
56
+ :options="assigneeOptions"
57
+ :placeholder="assigneeFilterLabel"
58
+ :input-label="assigneeFilterLabel"
59
+ :clearable="true" />
60
+ </div>
61
+ </div>
62
+
63
+ <!-- Tasks list -->
64
+ <NcLoadingIcon v-if="loading" />
65
+ <div v-else-if="filteredTasks.length === 0" class="cn-sidebar-tab__empty">
66
+ {{ noTasksLabel }}
67
+ </div>
68
+ <div v-else class="cn-sidebar-tab__list">
69
+ <NcListItem
70
+ v-for="task in filteredTasks"
71
+ :key="task.id"
72
+ :name="task.summary || task.title || task.name"
73
+ :bold="false"
74
+ :force-display-actions="true"
75
+ :class="{ 'cn-sidebar-tab__task--overdue': isOverdue(task) }">
76
+ <template #icon>
77
+ <button class="cn-sidebar-tab__task-checkbox" @click.stop="toggleTask(task)">
78
+ <CheckboxMarkedOutline v-if="task.status === 'completed'" :size="32" class="cn-sidebar-tab__task-done" />
79
+ <CheckboxBlankOutline v-else :size="32" :class="{ 'cn-sidebar-tab__task-overdue-icon': isOverdue(task) }" />
80
+ </button>
81
+ </template>
82
+ <template #subname>
83
+ {{ extractAssignee(task) }}
84
+ </template>
85
+ <template v-if="task.due" #details>
86
+ <span :class="{ 'cn-sidebar-tab__task-overdue-date': isOverdue(task) }">
87
+ {{ formatShortDate(task.due) }}
88
+ </span>
89
+ </template>
90
+ <template #actions>
91
+ <NcActionButton @click="startEdit(task)">
92
+ <template #icon>
93
+ <Pencil :size="20" />
94
+ </template>
95
+ {{ editLabel }}
96
+ </NcActionButton>
97
+ <NcActionButton v-if="task.status !== 'completed'" @click="completeTask(task)">
98
+ <template #icon>
99
+ <CheckboxMarkedOutline :size="20" />
100
+ </template>
101
+ {{ completeLabel }}
102
+ </NcActionButton>
103
+ <NcActionButton @click="deleteTask(task)">
104
+ <template #icon>
105
+ <Delete :size="20" />
106
+ </template>
107
+ {{ deleteLabel }}
108
+ </NcActionButton>
109
+ </template>
110
+ </NcListItem>
111
+ </div>
112
+ <NcButton
113
+ v-if="tasks.length < total"
114
+ type="tertiary"
115
+ :wide="true"
116
+ :disabled="loadingMore"
117
+ class="cn-sidebar-tab__load-more"
118
+ @click="loadMore">
119
+ <template v-if="loadingMore" #icon>
120
+ <NcLoadingIcon :size="20" />
121
+ </template>
122
+ {{ loadingMore ? '' : loadMoreLabel }}
123
+ </NcButton>
124
+ </div>
125
+ </template>
126
+
127
+ <script>
128
+ import { translate as t } from '@nextcloud/l10n'
129
+ import { NcButton, NcTextField, NcListItem, NcActionButton, NcLoadingIcon, NcDateTimePickerNative, NcSelect } from '@nextcloud/vue'
130
+ import Plus from 'vue-material-design-icons/Plus.vue'
131
+ import Delete from 'vue-material-design-icons/Delete.vue'
132
+ import Pencil from 'vue-material-design-icons/Pencil.vue'
133
+ import Close from 'vue-material-design-icons/Close.vue'
134
+ import ContentSave from 'vue-material-design-icons/ContentSave.vue'
135
+ import CheckboxMarkedOutline from 'vue-material-design-icons/CheckboxMarkedOutline.vue'
136
+ import CheckboxBlankOutline from 'vue-material-design-icons/CheckboxBlankOutline.vue'
137
+ import { buildHeaders } from '../../utils/index.js'
138
+
139
+ export default {
140
+ name: 'CnTasksTab',
141
+
142
+ components: {
143
+ NcButton,
144
+ NcTextField,
145
+ NcListItem,
146
+ NcActionButton,
147
+ NcLoadingIcon,
148
+ NcDateTimePickerNative,
149
+ NcSelect,
150
+ Plus,
151
+ Delete,
152
+ Pencil,
153
+ Close,
154
+ ContentSave,
155
+ CheckboxMarkedOutline,
156
+ CheckboxBlankOutline,
157
+ },
158
+
159
+ props: {
160
+ objectId: { type: String, required: true },
161
+ register: { type: String, default: '' },
162
+ schema: { type: String, default: '' },
163
+ apiBase: { type: String, default: '/apps/openregister/api' },
164
+ addTaskPlaceholder: { type: String, default: () => t('nextcloud-vue', 'Add task...') },
165
+ deadlineLabel: { type: String, default: () => t('nextcloud-vue', 'Deadline') },
166
+ assigneeLabel: { type: String, default: () => t('nextcloud-vue', 'Assignee') },
167
+ completeLabel: { type: String, default: () => t('nextcloud-vue', 'Complete') },
168
+ editLabel: { type: String, default: () => t('nextcloud-vue', 'Edit') },
169
+ deleteLabel: { type: String, default: () => t('nextcloud-vue', 'Delete') },
170
+ noTasksLabel: { type: String, default: () => t('nextcloud-vue', 'No linked tasks') },
171
+ loadMoreLabel: { type: String, default: () => t('nextcloud-vue', 'Load more') },
172
+ statusFilterLabel: { type: String, default: () => t('nextcloud-vue', 'Status') },
173
+ assigneeFilterLabel: { type: String, default: () => t('nextcloud-vue', 'Assignee') },
174
+ },
175
+
176
+ data() {
177
+ return {
178
+ tasks: [],
179
+ loading: false,
180
+ loadingMore: false,
181
+ newTaskSummary: '',
182
+ newTaskDue: null,
183
+ newTaskAssignee: null,
184
+ saving: false,
185
+ editingTaskId: null,
186
+ userList: [],
187
+ page: 1,
188
+ total: 0,
189
+ limit: 20,
190
+ filterStatus: null,
191
+ filterAssignee: null,
192
+ }
193
+ },
194
+
195
+ computed: {
196
+ statusOptions() {
197
+ return [...new Set(this.tasks.map(t => t.status).filter(Boolean))]
198
+ },
199
+ assigneeOptions() {
200
+ return [...new Set(this.tasks.map(t => this.extractAssignee(t)).filter(Boolean))]
201
+ },
202
+ filteredTasks() {
203
+ let result = this.tasks
204
+ if (this.filterStatus) {
205
+ result = result.filter(t => t.status === this.filterStatus)
206
+ }
207
+ if (this.filterAssignee) {
208
+ result = result.filter(t => this.extractAssignee(t) === this.filterAssignee)
209
+ }
210
+ return result
211
+ },
212
+ },
213
+
214
+ watch: {
215
+ objectId: {
216
+ immediate: true,
217
+ handler(id) {
218
+ if (id) {
219
+ this.fetchTasks()
220
+ this.fetchUsers()
221
+ }
222
+ },
223
+ },
224
+ },
225
+
226
+ methods: {
227
+ async fetchTasks(append = false) {
228
+ if (!this.register || !this.schema) return
229
+ if (append) { this.loadingMore = true } else { this.loading = true }
230
+ try {
231
+ const params = new URLSearchParams({ limit: this.limit, _page: this.page })
232
+ const response = await fetch(
233
+ `${this.apiBase}/objects/${this.register}/${this.schema}/${this.objectId}/tasks?${params}`,
234
+ { headers: buildHeaders() },
235
+ )
236
+ if (response.ok) {
237
+ const data = await response.json()
238
+ const results = data.results || data || []
239
+ this.tasks = append ? [...this.tasks, ...results] : results
240
+ this.total = data.total || this.tasks.length
241
+ }
242
+ } catch (err) {
243
+ console.error('CnTasksTab: Failed to fetch tasks', err)
244
+ } finally {
245
+ this.loading = false
246
+ this.loadingMore = false
247
+ }
248
+ },
249
+
250
+ loadMore() {
251
+ this.page++
252
+ this.fetchTasks(true)
253
+ },
254
+
255
+ isOverdue(task) {
256
+ if (!task.due || task.status === 'completed') return false
257
+ return new Date(task.due) < new Date()
258
+ },
259
+
260
+ async fetchUsers() {
261
+ try {
262
+ const response = await fetch('/ocs/v2.php/cloud/users/details?format=json&limit=50', {
263
+ headers: buildHeaders(),
264
+ })
265
+ if (response.ok) {
266
+ const data = await response.json()
267
+ const users = data.ocs?.data?.users || {}
268
+ this.userList = Object.entries(users).map(([id, user]) => ({
269
+ userId: id,
270
+ displayName: user.displayname || id,
271
+ }))
272
+ }
273
+ } catch (err) {
274
+ console.error('CnTasksTab: Failed to fetch users', err)
275
+ }
276
+ },
277
+
278
+ async addTask() {
279
+ if (!this.newTaskSummary.trim() || !this.register || !this.schema) return
280
+ this.saving = true
281
+ try {
282
+ const taskData = { summary: this.newTaskSummary.trim() }
283
+ if (this.newTaskDue) {
284
+ taskData.due = new Date(this.newTaskDue).toISOString()
285
+ }
286
+ if (this.newTaskAssignee) {
287
+ taskData.description = 'Assigned to: ' + this.newTaskAssignee.displayName
288
+ }
289
+ await fetch(
290
+ `${this.apiBase}/objects/${this.register}/${this.schema}/${this.objectId}/tasks`,
291
+ {
292
+ method: 'POST',
293
+ headers: buildHeaders(),
294
+ body: JSON.stringify(taskData),
295
+ },
296
+ )
297
+ this.clearForm()
298
+ await this.fetchTasks()
299
+ } catch (err) {
300
+ console.error('CnTasksTab: Failed to add task', err)
301
+ } finally {
302
+ this.saving = false
303
+ }
304
+ },
305
+
306
+ startEdit(task) {
307
+ this.editingTaskId = task.id
308
+ this.newTaskSummary = task.summary || task.title || task.name || ''
309
+ this.newTaskDue = task.due ? new Date(task.due).toISOString().split('T')[0] : null
310
+ const assigneeName = this.extractAssignee(task)
311
+ this.newTaskAssignee = this.userList.find(u => u.displayName === assigneeName) || null
312
+ },
313
+
314
+ cancelEdit() {
315
+ this.editingTaskId = null
316
+ this.clearForm()
317
+ },
318
+
319
+ async saveEdit() {
320
+ if (!this.newTaskSummary.trim() || !this.editingTaskId) return
321
+ this.saving = true
322
+ try {
323
+ const taskData = { summary: this.newTaskSummary.trim() }
324
+ if (this.newTaskDue) {
325
+ taskData.due = new Date(this.newTaskDue).toISOString()
326
+ } else {
327
+ taskData.due = ''
328
+ }
329
+ if (this.newTaskAssignee) {
330
+ taskData.description = 'Assigned to: ' + this.newTaskAssignee.displayName
331
+ } else {
332
+ taskData.description = ''
333
+ }
334
+ await fetch(
335
+ `${this.apiBase}/objects/${this.register}/${this.schema}/${this.objectId}/tasks/${encodeURIComponent(this.editingTaskId)}`,
336
+ {
337
+ method: 'PUT',
338
+ headers: buildHeaders(),
339
+ body: JSON.stringify(taskData),
340
+ },
341
+ )
342
+ this.editingTaskId = null
343
+ this.clearForm()
344
+ await this.fetchTasks()
345
+ } catch (err) {
346
+ console.error('CnTasksTab: Failed to update task', err)
347
+ } finally {
348
+ this.saving = false
349
+ }
350
+ },
351
+
352
+ clearForm() {
353
+ this.newTaskSummary = ''
354
+ this.newTaskDue = null
355
+ this.newTaskAssignee = null
356
+ },
357
+
358
+ async toggleTask(task) {
359
+ const newStatus = task.status === 'completed' ? 'NEEDS-ACTION' : 'COMPLETED'
360
+ try {
361
+ await fetch(
362
+ `${this.apiBase}/objects/${this.register}/${this.schema}/${this.objectId}/tasks/${encodeURIComponent(task.id)}`,
363
+ {
364
+ method: 'PUT',
365
+ headers: buildHeaders(),
366
+ body: JSON.stringify({ status: newStatus }),
367
+ },
368
+ )
369
+ await this.fetchTasks()
370
+ } catch (err) {
371
+ console.error('CnTasksTab: Failed to toggle task', err)
372
+ }
373
+ },
374
+
375
+ async completeTask(task) {
376
+ try {
377
+ await fetch(
378
+ `${this.apiBase}/objects/${this.register}/${this.schema}/${this.objectId}/tasks/${encodeURIComponent(task.id)}`,
379
+ {
380
+ method: 'PUT',
381
+ headers: buildHeaders(),
382
+ body: JSON.stringify({ status: 'COMPLETED' }),
383
+ },
384
+ )
385
+ await this.fetchTasks()
386
+ } catch (err) {
387
+ console.error('CnTasksTab: Failed to complete task', err)
388
+ }
389
+ },
390
+
391
+ async deleteTask(task) {
392
+ try {
393
+ await fetch(
394
+ `${this.apiBase}/objects/${this.register}/${this.schema}/${this.objectId}/tasks/${encodeURIComponent(task.id)}`,
395
+ { method: 'DELETE', headers: buildHeaders() },
396
+ )
397
+ this.tasks = this.tasks.filter(t => t.id !== task.id)
398
+ } catch (err) {
399
+ console.error('CnTasksTab: Failed to delete task', err)
400
+ }
401
+ },
402
+
403
+ extractAssignee(task) {
404
+ if (task.description?.startsWith('Assigned to: ')) {
405
+ return task.description.replace('Assigned to: ', '')
406
+ }
407
+ return task.description || ''
408
+ },
409
+
410
+ formatShortDate(dateStr) {
411
+ if (!dateStr) return ''
412
+ try {
413
+ return new Date(dateStr).toLocaleDateString(undefined, {
414
+ day: 'numeric', month: 'short',
415
+ })
416
+ } catch { return dateStr }
417
+ },
418
+ },
419
+ }
420
+ </script>
421
+
422
+ <style scoped>
423
+ .cn-sidebar-tab {
424
+ padding: 12px;
425
+ overflow-x: hidden;
426
+ }
427
+
428
+ .cn-sidebar-tab__section {
429
+ margin-bottom: 12px;
430
+ }
431
+
432
+ .cn-sidebar-tab__section--filters {
433
+ padding-top: 12px;
434
+ border-top: 1px solid var(--color-border);
435
+ }
436
+
437
+ .cn-sidebar-tab__action--row {
438
+ display: flex;
439
+ gap: 8px;
440
+ align-items: flex-end;
441
+ margin-bottom: 8px;
442
+ }
443
+
444
+ .cn-sidebar-tab__grid {
445
+ display: grid;
446
+ grid-template-columns: 1fr 1fr;
447
+ gap: 8px;
448
+ }
449
+
450
+ .cn-sidebar-tab__grid > * {
451
+ min-width: 0;
452
+ }
453
+
454
+ .cn-sidebar-tab__empty {
455
+ text-align: center;
456
+ padding: 24px 12px;
457
+ color: var(--color-text-maxcontrast);
458
+ font-size: 13px;
459
+ }
460
+
461
+ .cn-sidebar-tab__list {
462
+ display: flex;
463
+ flex-direction: column;
464
+ gap: 2px;
465
+ }
466
+
467
+ .cn-sidebar-tab__load-more { margin-top: 8px; }
468
+
469
+ .cn-sidebar-tab__task-checkbox {
470
+ display: flex;
471
+ align-items: center;
472
+ justify-content: center;
473
+ background: none;
474
+ border: none;
475
+ padding: 0;
476
+ cursor: pointer;
477
+ color: inherit;
478
+ }
479
+
480
+ .cn-sidebar-tab__task-done { color: var(--color-success); }
481
+ .cn-sidebar-tab__task-overdue-icon { color: var(--color-error, #e53935); }
482
+ .cn-sidebar-tab__task-overdue-date { color: var(--color-error, #e53935); font-weight: 500; }
483
+ </style>