@conduction/nextcloud-vue 0.1.0-beta.1

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 (93) hide show
  1. package/dist/nextcloud-vue.cjs.js +10710 -0
  2. package/dist/nextcloud-vue.cjs.js.map +1 -0
  3. package/dist/nextcloud-vue.css +803 -0
  4. package/dist/nextcloud-vue.esm.js +10665 -0
  5. package/dist/nextcloud-vue.esm.js.map +1 -0
  6. package/package.json +63 -0
  7. package/src/components/CnCardGrid/CnCardGrid.vue +152 -0
  8. package/src/components/CnCardGrid/index.js +1 -0
  9. package/src/components/CnCellRenderer/CnCellRenderer.vue +132 -0
  10. package/src/components/CnCellRenderer/index.js +1 -0
  11. package/src/components/CnConfigurationCard/CnConfigurationCard.vue +77 -0
  12. package/src/components/CnConfigurationCard/index.js +1 -0
  13. package/src/components/CnDataTable/CnDataTable.vue +354 -0
  14. package/src/components/CnDataTable/index.js +1 -0
  15. package/src/components/CnDetailViewLayout/CnDetailViewLayout.vue +88 -0
  16. package/src/components/CnDetailViewLayout/index.js +1 -0
  17. package/src/components/CnEmptyState/CnEmptyState.vue +78 -0
  18. package/src/components/CnEmptyState/index.js +1 -0
  19. package/src/components/CnFacetSidebar/CnFacetSidebar.vue +223 -0
  20. package/src/components/CnFacetSidebar/index.js +1 -0
  21. package/src/components/CnFilterBar/CnFilterBar.vue +152 -0
  22. package/src/components/CnFilterBar/index.js +1 -0
  23. package/src/components/CnIndexPage/CnIndexPage.vue +682 -0
  24. package/src/components/CnIndexPage/index.js +1 -0
  25. package/src/components/CnKpiGrid/CnKpiGrid.vue +89 -0
  26. package/src/components/CnKpiGrid/index.js +1 -0
  27. package/src/components/CnListViewLayout/CnListViewLayout.vue +80 -0
  28. package/src/components/CnListViewLayout/index.js +1 -0
  29. package/src/components/CnMassActionBar/CnMassActionBar.vue +160 -0
  30. package/src/components/CnMassActionBar/index.js +1 -0
  31. package/src/components/CnMassCopyDialog/CnMassCopyDialog.vue +320 -0
  32. package/src/components/CnMassCopyDialog/index.js +1 -0
  33. package/src/components/CnMassDeleteDialog/CnMassDeleteDialog.vue +238 -0
  34. package/src/components/CnMassDeleteDialog/index.js +1 -0
  35. package/src/components/CnMassExportDialog/CnMassExportDialog.vue +190 -0
  36. package/src/components/CnMassExportDialog/index.js +1 -0
  37. package/src/components/CnMassImportDialog/CnMassImportDialog.vue +491 -0
  38. package/src/components/CnMassImportDialog/index.js +1 -0
  39. package/src/components/CnObjectCard/CnObjectCard.vue +292 -0
  40. package/src/components/CnObjectCard/index.js +1 -0
  41. package/src/components/CnPagination/CnPagination.vue +252 -0
  42. package/src/components/CnPagination/index.js +1 -0
  43. package/src/components/CnRowActions/CnRowActions.vue +73 -0
  44. package/src/components/CnRowActions/index.js +1 -0
  45. package/src/components/CnSettingsCard/CnSettingsCard.vue +92 -0
  46. package/src/components/CnSettingsCard/index.js +1 -0
  47. package/src/components/CnSettingsSection/CnSettingsSection.vue +266 -0
  48. package/src/components/CnSettingsSection/index.js +1 -0
  49. package/src/components/CnStatsBlock/CnStatsBlock.vue +366 -0
  50. package/src/components/CnStatsBlock/index.js +1 -0
  51. package/src/components/CnStatusBadge/CnStatusBadge.vue +77 -0
  52. package/src/components/CnStatusBadge/index.js +1 -0
  53. package/src/components/CnVersionInfoCard/CnVersionInfoCard.vue +312 -0
  54. package/src/components/CnVersionInfoCard/index.js +1 -0
  55. package/src/components/CnViewModeToggle/CnViewModeToggle.vue +77 -0
  56. package/src/components/CnViewModeToggle/index.js +1 -0
  57. package/src/components/index.js +25 -0
  58. package/src/composables/index.js +3 -0
  59. package/src/composables/useDetailView.js +132 -0
  60. package/src/composables/useListView.js +153 -0
  61. package/src/composables/useSubResource.js +142 -0
  62. package/src/css/badge.css +51 -0
  63. package/src/css/card.css +128 -0
  64. package/src/css/detail.css +68 -0
  65. package/src/css/index.css +8 -0
  66. package/src/css/layout.css +90 -0
  67. package/src/css/pagination.css +72 -0
  68. package/src/css/table.css +143 -0
  69. package/src/css/utilities.css +46 -0
  70. package/src/index.js +50 -0
  71. package/src/store/createSubResourcePlugin.js +135 -0
  72. package/src/store/index.js +3 -0
  73. package/src/store/plugins/auditTrails.js +17 -0
  74. package/src/store/plugins/files.js +186 -0
  75. package/src/store/plugins/index.js +4 -0
  76. package/src/store/plugins/lifecycle.js +180 -0
  77. package/src/store/plugins/relations.js +68 -0
  78. package/src/store/useObjectStore.js +625 -0
  79. package/src/types/auditTrail.d.ts +32 -0
  80. package/src/types/file.d.ts +23 -0
  81. package/src/types/index.d.ts +35 -0
  82. package/src/types/notification.d.ts +36 -0
  83. package/src/types/object.d.ts +40 -0
  84. package/src/types/organisation.d.ts +41 -0
  85. package/src/types/register.d.ts +25 -0
  86. package/src/types/schema.d.ts +39 -0
  87. package/src/types/shared.d.ts +79 -0
  88. package/src/types/source.d.ts +14 -0
  89. package/src/types/task.d.ts +31 -0
  90. package/src/utils/errors.js +96 -0
  91. package/src/utils/headers.js +44 -0
  92. package/src/utils/index.js +3 -0
  93. package/src/utils/schema.js +287 -0
@@ -0,0 +1,312 @@
1
+ <template>
2
+ <CnSettingsSection
3
+ :name="title"
4
+ :description="description"
5
+ :doc-url="docUrl"
6
+ :loading="loading"
7
+ loading-message="Loading version information...">
8
+ <!-- Actions slot -->
9
+ <template #actions>
10
+ <!-- Update Button -->
11
+ <NcButton
12
+ v-if="showUpdateButton"
13
+ :type="updateButtonType"
14
+ :disabled="updateButtonDisabled"
15
+ @click="handleUpdateClick">
16
+ <template #icon>
17
+ <NcLoadingIcon v-if="updating" :size="20" />
18
+ <Check v-else-if="isUpToDate" :size="20" />
19
+ <Update v-else :size="20" />
20
+ </template>
21
+ {{ updateButtonText }}
22
+ </NcButton>
23
+
24
+ <!-- Additional Actions (slot) -->
25
+ <slot name="actions" />
26
+ </template>
27
+
28
+ <!-- Main content (only shown when not loading) -->
29
+ <div v-if="!loading" class="cn-version-info">
30
+ <!-- Version card with gray background -->
31
+ <div class="cn-version-info__card">
32
+ <h4>{{ cardTitle }}</h4>
33
+ <div class="cn-version-info__details">
34
+ <!-- Application Name -->
35
+ <div class="cn-version-info__item">
36
+ <span class="cn-version-info__label">{{ labels.appName }}:</span>
37
+ <span class="cn-version-info__value">{{ appName }}</span>
38
+ </div>
39
+
40
+ <!-- Version -->
41
+ <div class="cn-version-info__item">
42
+ <span class="cn-version-info__label">{{ labels.version }}:</span>
43
+ <span class="cn-version-info__value">{{ appVersion }}</span>
44
+ </div>
45
+
46
+ <!-- Configured Version (if provided) -->
47
+ <div v-if="configuredVersion" class="cn-version-info__item">
48
+ <span class="cn-version-info__label">{{ labels.configuredVersion }}:</span>
49
+ <span class="cn-version-info__value">{{ configuredVersion }}</span>
50
+ </div>
51
+
52
+ <!-- Additional items -->
53
+ <div v-for="item in additionalItems" :key="item.label" class="cn-version-info__item">
54
+ <span class="cn-version-info__label">{{ item.label }}:</span>
55
+ <span class="cn-version-info__value" :class="item.statusClass">{{ item.value }}</span>
56
+ </div>
57
+
58
+ <!-- Optional additional items slot -->
59
+ <slot name="additional-items" />
60
+ </div>
61
+
62
+ <!-- Optional footer slot -->
63
+ <slot name="footer" />
64
+ </div>
65
+
66
+ <!-- Optional extra cards slot -->
67
+ <slot name="extra-cards" />
68
+ </div>
69
+ </CnSettingsSection>
70
+ </template>
71
+
72
+ <script>
73
+ import { CnSettingsSection } from '../CnSettingsSection/index.js'
74
+ import { NcLoadingIcon, NcButton } from '@nextcloud/vue'
75
+ import Check from 'vue-material-design-icons/Check.vue'
76
+ import Update from 'vue-material-design-icons/Update.vue'
77
+
78
+ /**
79
+ * CnVersionInfoCard - App version information card for admin settings pages.
80
+ *
81
+ * Displays application name, version, and optional configured version with an
82
+ * update button. Wraps CnSettingsSection for consistent admin settings layout.
83
+ *
84
+ * Every Conduction Nextcloud app should show this as the first section on its
85
+ * admin settings page.
86
+ *
87
+ * @example Basic usage
88
+ * <CnVersionInfoCard app-name="Open Register" app-version="0.2.3" />
89
+ *
90
+ * @example With update button
91
+ * <CnVersionInfoCard
92
+ * app-name="Open Register"
93
+ * app-version="0.2.3"
94
+ * configured-version="0.2.2"
95
+ * :is-up-to-date="false"
96
+ * :show-update-button="true"
97
+ * :updating="isUpdating"
98
+ * @update="runUpdate" />
99
+ *
100
+ * @example With additional items and actions
101
+ * <CnVersionInfoCard
102
+ * app-name="Pipelinq"
103
+ * app-version="0.1.7"
104
+ * :additional-items="[{ label: 'Database', value: 'Connected', statusClass: 'cn-version-info__status--ok' }]">
105
+ * <template #actions>
106
+ * <NcButton @click="clearCache">Clear App Store Cache</NcButton>
107
+ * </template>
108
+ * </CnVersionInfoCard>
109
+ */
110
+ export default {
111
+ name: 'CnVersionInfoCard',
112
+
113
+ components: {
114
+ CnSettingsSection,
115
+ NcLoadingIcon,
116
+ NcButton,
117
+ Check,
118
+ Update,
119
+ },
120
+
121
+ props: {
122
+ /** Section title */
123
+ title: {
124
+ type: String,
125
+ default: 'Version Information',
126
+ },
127
+ /** Section description */
128
+ description: {
129
+ type: String,
130
+ default: 'Information about the current application installation',
131
+ },
132
+ /** Documentation URL (shows info icon next to title) */
133
+ docUrl: {
134
+ type: String,
135
+ default: '',
136
+ },
137
+ /** Card heading text */
138
+ cardTitle: {
139
+ type: String,
140
+ default: 'Application Information',
141
+ },
142
+ /** Application name to display */
143
+ appName: {
144
+ type: String,
145
+ required: true,
146
+ },
147
+ /** Application version string */
148
+ appVersion: {
149
+ type: String,
150
+ required: true,
151
+ },
152
+ /** Configured version (optional, for apps that track configuration versions separately) */
153
+ configuredVersion: {
154
+ type: String,
155
+ default: '',
156
+ },
157
+ /** Whether the app configuration is up to date */
158
+ isUpToDate: {
159
+ type: Boolean,
160
+ default: true,
161
+ },
162
+ /** Whether to show the update button */
163
+ showUpdateButton: {
164
+ type: Boolean,
165
+ default: false,
166
+ },
167
+ /** Whether an update is currently in progress */
168
+ updating: {
169
+ type: Boolean,
170
+ default: false,
171
+ },
172
+ /**
173
+ * Additional key-value items to display.
174
+ * Format: [{ label: 'Label', value: 'Value', statusClass: 'cn-version-info__status--ok' }]
175
+ */
176
+ additionalItems: {
177
+ type: Array,
178
+ default: () => [],
179
+ },
180
+ /** Whether version info is loading */
181
+ loading: {
182
+ type: Boolean,
183
+ default: false,
184
+ },
185
+ /** Custom labels for the standard fields */
186
+ labels: {
187
+ type: Object,
188
+ default: () => ({
189
+ appName: 'Application Name',
190
+ version: 'Version',
191
+ configuredVersion: 'Configured Version',
192
+ }),
193
+ },
194
+ },
195
+
196
+ emits: ['update'],
197
+
198
+ computed: {
199
+ /** @return {string} Button type based on update status */
200
+ updateButtonType() {
201
+ if (this.isUpToDate) {
202
+ return 'success'
203
+ }
204
+ return 'error'
205
+ },
206
+
207
+ /** @return {boolean} Whether the update button should be disabled */
208
+ updateButtonDisabled() {
209
+ return this.isUpToDate || this.updating
210
+ },
211
+
212
+ /** @return {string} Update button label text */
213
+ updateButtonText() {
214
+ if (this.updating) {
215
+ return 'Updating...'
216
+ }
217
+ if (this.isUpToDate) {
218
+ return 'Up to date'
219
+ }
220
+ return 'Update'
221
+ },
222
+ },
223
+
224
+ methods: {
225
+ handleUpdateClick() {
226
+ if (!this.updateButtonDisabled) {
227
+ this.$emit('update')
228
+ }
229
+ },
230
+ },
231
+ }
232
+ </script>
233
+
234
+ <style scoped>
235
+ .cn-version-info__card {
236
+ background: var(--color-background-hover);
237
+ border: 1px solid var(--color-border);
238
+ border-radius: var(--border-radius-large);
239
+ padding: 20px;
240
+ margin-bottom: 20px;
241
+ }
242
+
243
+ .cn-version-info__card h4 {
244
+ margin: 0 0 16px 0;
245
+ font-size: 16px;
246
+ font-weight: 600;
247
+ color: var(--color-main-text);
248
+ }
249
+
250
+ .cn-version-info__details {
251
+ display: flex;
252
+ flex-direction: column;
253
+ gap: 12px;
254
+ }
255
+
256
+ .cn-version-info__item {
257
+ display: flex;
258
+ justify-content: space-between;
259
+ align-items: center;
260
+ padding: 8px 0;
261
+ border-bottom: 1px solid var(--color-border);
262
+ }
263
+
264
+ .cn-version-info__item:last-child {
265
+ border-bottom: none;
266
+ }
267
+
268
+ .cn-version-info__label {
269
+ font-weight: 500;
270
+ color: var(--color-text-maxcontrast);
271
+ font-size: 14px;
272
+ }
273
+
274
+ .cn-version-info__value {
275
+ font-family: 'Courier New', Courier, monospace;
276
+ font-weight: 600;
277
+ color: var(--color-main-text);
278
+ font-size: 14px;
279
+ }
280
+
281
+ /* Status classes for values */
282
+ .cn-version-info__status--ok {
283
+ color: var(--color-success);
284
+ font-weight: 600;
285
+ }
286
+
287
+ .cn-version-info__status--warning {
288
+ color: var(--color-warning);
289
+ font-weight: 600;
290
+ }
291
+
292
+ .cn-version-info__status--error {
293
+ color: var(--color-error);
294
+ font-weight: 600;
295
+ }
296
+
297
+ @media (max-width: 768px) {
298
+ .cn-version-info__item {
299
+ flex-direction: column;
300
+ align-items: flex-start;
301
+ gap: 4px;
302
+ }
303
+
304
+ .cn-version-info__label {
305
+ font-weight: 600;
306
+ }
307
+
308
+ .cn-version-info__value {
309
+ word-break: break-all;
310
+ }
311
+ }
312
+ </style>
@@ -0,0 +1 @@
1
+ export { default as CnVersionInfoCard } from './CnVersionInfoCard.vue'
@@ -0,0 +1,77 @@
1
+ <template>
2
+ <div class="cn-view-mode-toggle" role="group" :aria-label="ariaLabel">
3
+ <NcButton
4
+ :type="value === 'cards' ? 'primary' : 'secondary'"
5
+ :aria-pressed="String(value === 'cards')"
6
+ @click="$emit('input', 'cards')">
7
+ <template #icon>
8
+ <ViewGrid :size="20" />
9
+ </template>
10
+ {{ cardsLabel }}
11
+ </NcButton>
12
+ <NcButton
13
+ :type="value === 'table' ? 'primary' : 'secondary'"
14
+ :aria-pressed="String(value === 'table')"
15
+ @click="$emit('input', 'table')">
16
+ <template #icon>
17
+ <ViewList :size="20" />
18
+ </template>
19
+ {{ tableLabel }}
20
+ </NcButton>
21
+ </div>
22
+ </template>
23
+
24
+ <script>
25
+ import { NcButton } from '@nextcloud/vue'
26
+ import ViewGrid from 'vue-material-design-icons/ViewGrid.vue'
27
+ import ViewList from 'vue-material-design-icons/ViewList.vue'
28
+
29
+ /**
30
+ * CnViewModeToggle — Cards/Table view mode toggle.
31
+ *
32
+ * @example
33
+ * <CnViewModeToggle v-model="viewMode" />
34
+ */
35
+ export default {
36
+ name: 'CnViewModeToggle',
37
+
38
+ components: {
39
+ NcButton,
40
+ ViewGrid,
41
+ ViewList,
42
+ },
43
+
44
+ props: {
45
+ /** Current view mode: 'cards' or 'table' */
46
+ value: {
47
+ type: String,
48
+ default: 'table',
49
+ validator: (v) => ['cards', 'table'].includes(v),
50
+ },
51
+ /** Label for cards button */
52
+ cardsLabel: {
53
+ type: String,
54
+ default: 'Cards',
55
+ },
56
+ /** Label for table button */
57
+ tableLabel: {
58
+ type: String,
59
+ default: 'Table',
60
+ },
61
+ /** Aria label for the toggle group */
62
+ ariaLabel: {
63
+ type: String,
64
+ default: 'View mode',
65
+ },
66
+ },
67
+ }
68
+ </script>
69
+
70
+ <style scoped>
71
+ .cn-view-mode-toggle {
72
+ display: inline-flex;
73
+ gap: 0;
74
+ border-radius: var(--border-radius-pill, 20px);
75
+ overflow: hidden;
76
+ }
77
+ </style>
@@ -0,0 +1 @@
1
+ export { default as CnViewModeToggle } from './CnViewModeToggle.vue'
@@ -0,0 +1,25 @@
1
+ export { CnDataTable } from './CnDataTable/index.js'
2
+ export { CnFilterBar } from './CnFilterBar/index.js'
3
+ export { CnListViewLayout } from './CnListViewLayout/index.js'
4
+ export { CnDetailViewLayout } from './CnDetailViewLayout/index.js'
5
+ export { CnStatusBadge } from './CnStatusBadge/index.js'
6
+ export { CnEmptyState } from './CnEmptyState/index.js'
7
+ export { CnPagination } from './CnPagination/index.js'
8
+ export { CnSettingsCard } from './CnSettingsCard/index.js'
9
+ export { CnSettingsSection } from './CnSettingsSection/index.js'
10
+ export { CnStatsBlock } from './CnStatsBlock/index.js'
11
+ export { CnConfigurationCard } from './CnConfigurationCard/index.js'
12
+ export { CnVersionInfoCard } from './CnVersionInfoCard/index.js'
13
+ export { CnCellRenderer } from './CnCellRenderer/index.js'
14
+ export { CnObjectCard } from './CnObjectCard/index.js'
15
+ export { CnCardGrid } from './CnCardGrid/index.js'
16
+ export { CnFacetSidebar } from './CnFacetSidebar/index.js'
17
+ export { CnViewModeToggle } from './CnViewModeToggle/index.js'
18
+ export { CnRowActions } from './CnRowActions/index.js'
19
+ export { CnIndexPage } from './CnIndexPage/index.js'
20
+ export { CnMassActionBar } from './CnMassActionBar/index.js'
21
+ export { CnMassDeleteDialog } from './CnMassDeleteDialog/index.js'
22
+ export { CnMassCopyDialog } from './CnMassCopyDialog/index.js'
23
+ export { CnKpiGrid } from './CnKpiGrid/index.js'
24
+ export { CnMassExportDialog } from './CnMassExportDialog/index.js'
25
+ export { CnMassImportDialog } from './CnMassImportDialog/index.js'
@@ -0,0 +1,3 @@
1
+ export { useListView } from './useListView.js'
2
+ export { useDetailView } from './useDetailView.js'
3
+ export { useSubResource } from './useSubResource.js'
@@ -0,0 +1,132 @@
1
+ import { ref } from 'vue'
2
+
3
+ /**
4
+ * Composable for managing detail view state: loading, editing, deleting.
5
+ *
6
+ * Extracts the load/edit/delete pattern found in every detail view
7
+ * across Pipelinq and Procest.
8
+ *
9
+ * @param {object} options Configuration options
10
+ * @param {string} options.objectType The registered object type slug
11
+ * @param {Function} options.fetchFn (type, id) => Promise<object>
12
+ * @param {Function} options.saveFn (type, data) => Promise<object>
13
+ * @param {Function} options.deleteFn (type, id) => Promise<boolean>
14
+ * @param {Function} [options.onSaved] Callback after successful save
15
+ * @param {Function} [options.onDeleted] Callback after successful delete
16
+ * @return {object} Reactive state and methods
17
+ *
18
+ * @example
19
+ * import { useDetailView } from '@conduction/nextcloud-vue'
20
+ *
21
+ * const { objectData, editing, loading, showDeleteDialog, load, save, confirmDelete, executeDelete } = useDetailView({
22
+ * objectType: 'client',
23
+ * fetchFn: (type, id) => objectStore.fetchObject(type, id),
24
+ * saveFn: (type, data) => objectStore.saveObject(type, data),
25
+ * deleteFn: (type, id) => objectStore.deleteObject(type, id),
26
+ * onSaved: (result) => router.push(`/clients/${result.id}`),
27
+ * onDeleted: () => router.push('/clients'),
28
+ * })
29
+ */
30
+ export function useDetailView(options) {
31
+ const objectData = ref({})
32
+ const editing = ref(false)
33
+ const loading = ref(false)
34
+ const saving = ref(false)
35
+ const showDeleteDialog = ref(false)
36
+ const error = ref(null)
37
+
38
+ /**
39
+ * Load an object by ID.
40
+ * @param {string} id Object ID
41
+ * @return {Promise<object|null>}
42
+ */
43
+ async function load(id) {
44
+ loading.value = true
45
+ error.value = null
46
+ try {
47
+ const result = await options.fetchFn(options.objectType, id)
48
+ if (result) {
49
+ objectData.value = { ...result }
50
+ }
51
+ return result
52
+ } catch (err) {
53
+ error.value = err.message || 'Failed to load'
54
+ return null
55
+ } finally {
56
+ loading.value = false
57
+ }
58
+ }
59
+
60
+ /**
61
+ * Save the current object data (create or update).
62
+ * @param {object} [formData] Optional form data override (defaults to objectData)
63
+ * @return {Promise<object|null>}
64
+ */
65
+ async function save(formData) {
66
+ saving.value = true
67
+ error.value = null
68
+ try {
69
+ const data = formData || objectData.value
70
+ const result = await options.saveFn(options.objectType, data)
71
+ if (result) {
72
+ objectData.value = { ...result }
73
+ editing.value = false
74
+ if (options.onSaved) {
75
+ options.onSaved(result)
76
+ }
77
+ }
78
+ return result
79
+ } catch (err) {
80
+ error.value = err.message || 'Failed to save'
81
+ return null
82
+ } finally {
83
+ saving.value = false
84
+ }
85
+ }
86
+
87
+ /**
88
+ * Show the delete confirmation dialog.
89
+ */
90
+ function confirmDelete() {
91
+ showDeleteDialog.value = true
92
+ }
93
+
94
+ /**
95
+ * Execute the delete operation.
96
+ * @param {string} [id] Object ID (defaults to objectData.id)
97
+ * @return {Promise<boolean>}
98
+ */
99
+ async function executeDelete(id) {
100
+ const deleteId = id || objectData.value.id
101
+ loading.value = true
102
+ error.value = null
103
+ try {
104
+ const success = await options.deleteFn(options.objectType, deleteId)
105
+ if (success) {
106
+ showDeleteDialog.value = false
107
+ if (options.onDeleted) {
108
+ options.onDeleted()
109
+ }
110
+ }
111
+ return success
112
+ } catch (err) {
113
+ error.value = err.message || 'Failed to delete'
114
+ return false
115
+ } finally {
116
+ loading.value = false
117
+ }
118
+ }
119
+
120
+ return {
121
+ objectData,
122
+ editing,
123
+ loading,
124
+ saving,
125
+ showDeleteDialog,
126
+ error,
127
+ load,
128
+ save,
129
+ confirmDelete,
130
+ executeDelete,
131
+ }
132
+ }
@@ -0,0 +1,153 @@
1
+ import { ref, onBeforeUnmount } from 'vue'
2
+
3
+ /**
4
+ * Composable for managing list view state: search, filters, sorting, pagination.
5
+ *
6
+ * Extracts the search-debounce + filter + sort + pagination pattern
7
+ * found in every list view across Pipelinq and Procest.
8
+ *
9
+ * @param {object} options Configuration options
10
+ * @param {string} options.objectType The registered object type slug
11
+ * @param {Function} options.fetchFn Function to call: (type, params) => Promise<Array>
12
+ * @param {number} [options.debounceMs=300] Search debounce in milliseconds
13
+ * @param {number} [options.pageSize=20] Default page size
14
+ * @param {object} [options.defaultSort] Default sort: { key: string, order: 'asc'|'desc' }
15
+ * @return {object} Reactive state and methods
16
+ *
17
+ * @example
18
+ * import { useListView } from '@conduction/nextcloud-vue'
19
+ *
20
+ * const { searchTerm, sortKey, sortOrder, currentPage, onSearchInput, toggleSort, fetch } = useListView({
21
+ * objectType: 'client',
22
+ * fetchFn: (type, params) => objectStore.fetchCollection(type, params),
23
+ * defaultSort: { key: 'name', order: 'asc' },
24
+ * })
25
+ */
26
+ export function useListView(options) {
27
+ const searchTerm = ref('')
28
+ const filters = ref({})
29
+ const sortKey = ref(options.defaultSort?.key || null)
30
+ const sortOrder = ref(options.defaultSort?.order || 'asc')
31
+ const currentPage = ref(1)
32
+ const pageSize = ref(options.pageSize || 20)
33
+
34
+ let searchTimeout = null
35
+
36
+ /**
37
+ * Build fetch parameters from current state.
38
+ * @return {object} Parameters for the fetch function
39
+ */
40
+ function buildFetchParams() {
41
+ const params = {
42
+ _limit: pageSize.value,
43
+ _page: currentPage.value,
44
+ }
45
+
46
+ if (searchTerm.value) {
47
+ params._search = searchTerm.value
48
+ }
49
+
50
+ if (sortKey.value) {
51
+ params._order = { [sortKey.value]: sortOrder.value }
52
+ }
53
+
54
+ // Merge active filters
55
+ for (const [key, value] of Object.entries(filters.value)) {
56
+ if (value !== null && value !== '' && value !== false) {
57
+ params[key] = value
58
+ }
59
+ }
60
+
61
+ return params
62
+ }
63
+
64
+ /**
65
+ * Execute a fetch with current state.
66
+ * @param {number} [page] Optional page override
67
+ * @return {Promise<Array>} Fetched results
68
+ */
69
+ async function fetchData(page) {
70
+ if (page !== undefined) {
71
+ currentPage.value = page
72
+ }
73
+ const params = buildFetchParams()
74
+ return options.fetchFn(options.objectType, params)
75
+ }
76
+
77
+ /**
78
+ * Handle search input with debouncing.
79
+ * @param {string} value New search value
80
+ */
81
+ function onSearchInput(value) {
82
+ searchTerm.value = value
83
+ clearTimeout(searchTimeout)
84
+ searchTimeout = setTimeout(() => fetchData(1), options.debounceMs || 300)
85
+ }
86
+
87
+ /**
88
+ * Toggle sort on a column. Cycles: asc -> desc -> null.
89
+ * @param {string} key Column key
90
+ */
91
+ function toggleSort(key) {
92
+ if (sortKey.value === key) {
93
+ if (sortOrder.value === 'asc') {
94
+ sortOrder.value = 'desc'
95
+ } else {
96
+ sortKey.value = null
97
+ sortOrder.value = 'asc'
98
+ }
99
+ } else {
100
+ sortKey.value = key
101
+ sortOrder.value = 'asc'
102
+ }
103
+ fetchData(1)
104
+ }
105
+
106
+ /**
107
+ * Set a filter value and re-fetch.
108
+ * @param {string} key Filter key
109
+ * @param {*} value Filter value
110
+ */
111
+ function setFilter(key, value) {
112
+ filters.value = { ...filters.value, [key]: value }
113
+ fetchData(1)
114
+ }
115
+
116
+ /**
117
+ * Clear all filters and search, then re-fetch.
118
+ */
119
+ function clearAllFilters() {
120
+ searchTerm.value = ''
121
+ filters.value = {}
122
+ sortKey.value = options.defaultSort?.key || null
123
+ sortOrder.value = options.defaultSort?.order || 'asc'
124
+ fetchData(1)
125
+ }
126
+
127
+ /**
128
+ * Navigate to a specific page.
129
+ * @param {number} page Page number
130
+ */
131
+ function goToPage(page) {
132
+ currentPage.value = page
133
+ fetchData()
134
+ }
135
+
136
+ onBeforeUnmount(() => clearTimeout(searchTimeout))
137
+
138
+ return {
139
+ searchTerm,
140
+ filters,
141
+ sortKey,
142
+ sortOrder,
143
+ currentPage,
144
+ pageSize,
145
+ onSearchInput,
146
+ toggleSort,
147
+ setFilter,
148
+ clearAllFilters,
149
+ goToPage,
150
+ fetch: fetchData,
151
+ buildFetchParams,
152
+ }
153
+ }