@conduction/nextcloud-vue 0.1.0-beta.4 → 0.1.0-beta.6

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 (71) hide show
  1. package/dist/nextcloud-vue.cjs +67614 -0
  2. package/dist/nextcloud-vue.cjs.js +9559 -8983
  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 +1231 -1231
  6. package/dist/nextcloud-vue.esm.js +9559 -8983
  7. package/dist/nextcloud-vue.esm.js.map +1 -1
  8. package/package.json +14 -5
  9. package/src/components/CnActionsBar/CnActionsBar.vue +235 -235
  10. package/src/components/CnAdvancedFormDialog/CnAdvancedFormDialog.vue +579 -579
  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 +418 -418
  14. package/src/components/CnAdvancedFormDialog/CnPropertyValueCell.vue +247 -247
  15. package/src/components/CnCardGrid/CnCardGrid.vue +152 -152
  16. package/src/components/CnCellRenderer/CnCellRenderer.vue +132 -132
  17. package/src/components/CnChartWidget/CnChartWidget.vue +320 -320
  18. package/src/components/CnConfigurationCard/CnConfigurationCard.vue +77 -77
  19. package/src/components/CnCopyDialog/CnCopyDialog.vue +250 -250
  20. package/src/components/CnDashboardGrid/CnDashboardGrid.vue +225 -225
  21. package/src/components/CnDashboardPage/CnDashboardPage.vue +390 -390
  22. package/src/components/CnDataTable/CnDataTable.vue +349 -349
  23. package/src/components/CnDeleteDialog/CnDeleteDialog.vue +170 -170
  24. package/src/components/CnDetailCard/CnDetailCard.vue +214 -214
  25. package/src/components/CnDetailPage/CnDetailPage.vue +285 -281
  26. package/src/components/CnFacetSidebar/CnFacetSidebar.vue +231 -231
  27. package/src/components/CnFilterBar/CnFilterBar.vue +152 -152
  28. package/src/components/CnFormDialog/CnFormDialog.vue +302 -11
  29. package/src/components/CnIcon/CnIcon.vue +89 -89
  30. package/src/components/CnIndexPage/CnIndexPage.vue +884 -874
  31. package/src/components/CnIndexSidebar/CnIndexSidebar.vue +503 -503
  32. package/src/components/CnItemCard/CnItemCard.vue +132 -132
  33. package/src/components/CnKpiGrid/CnKpiGrid.vue +89 -89
  34. package/src/components/CnMassActionBar/CnMassActionBar.vue +160 -160
  35. package/src/components/CnMassCopyDialog/CnMassCopyDialog.vue +320 -320
  36. package/src/components/CnMassDeleteDialog/CnMassDeleteDialog.vue +238 -238
  37. package/src/components/CnMassExportDialog/CnMassExportDialog.vue +190 -190
  38. package/src/components/CnMassImportDialog/CnMassImportDialog.vue +491 -491
  39. package/src/components/CnNoteCard/CnNoteCard.vue +149 -149
  40. package/src/components/CnNotesCard/CnNotesCard.vue +413 -413
  41. package/src/components/CnObjectCard/CnObjectCard.vue +292 -292
  42. package/src/components/CnObjectCard/eslint-setup.md +235 -0
  43. package/src/components/CnObjectCard/package.json-or.json +132 -0
  44. package/src/components/CnObjectSidebar/CnObjectSidebar.vue +876 -876
  45. package/src/components/CnPageHeader/CnPageHeader.vue +57 -57
  46. package/src/components/CnPagination/CnPagination.vue +252 -252
  47. package/src/components/CnRegisterMapping/CnRegisterMapping.vue +792 -792
  48. package/src/components/CnRowActions/CnRowActions.vue +95 -73
  49. package/src/components/CnSchemaFormDialog/CnSchemaConfigurationTab.vue +226 -226
  50. package/src/components/CnSchemaFormDialog/CnSchemaFormDialog.vue +787 -787
  51. package/src/components/CnSchemaFormDialog/CnSchemaPropertiesTab.vue +305 -305
  52. package/src/components/CnSchemaFormDialog/CnSchemaPropertyActions.vue +1398 -1398
  53. package/src/components/CnSchemaFormDialog/CnSchemaSecurityTab.vue +236 -236
  54. package/src/components/CnSettingsCard/CnSettingsCard.vue +92 -92
  55. package/src/components/CnSettingsSection/CnSettingsSection.vue +266 -266
  56. package/src/components/CnStatsBlock/CnStatsBlock.vue +420 -420
  57. package/src/components/CnStatusBadge/CnStatusBadge.vue +77 -77
  58. package/src/components/CnTabbedFormDialog/CnTabbedFormDialog.vue +540 -540
  59. package/src/components/CnTasksCard/CnTasksCard.vue +373 -373
  60. package/src/components/CnTileWidget/CnTileWidget.vue +159 -159
  61. package/src/components/CnTimelineStages/CnTimelineStages.vue +292 -292
  62. package/src/components/CnUserActionMenu/CnUserActionMenu.vue +435 -435
  63. package/src/components/CnVersionInfoCard/CnVersionInfoCard.vue +312 -312
  64. package/src/components/CnWidgetRenderer/CnWidgetRenderer.vue +180 -180
  65. package/src/components/CnWidgetWrapper/CnWidgetWrapper.vue +211 -211
  66. package/src/index.js +1 -1
  67. package/src/types/notification.d.ts +13 -13
  68. package/src/types/organisation.d.ts +15 -15
  69. package/src/types/schema.d.ts +13 -13
  70. package/src/types/task.d.ts +6 -6
  71. package/src/utils/headers.js +5 -3
@@ -1,503 +1,503 @@
1
- <template>
2
- <NcAppSidebar
3
- :name="resolvedName"
4
- :title="resolvedName"
5
- :subname="resolvedSubname"
6
- :open.sync="internalOpen"
7
- :active="internalActiveTab"
8
- :compact="!!resolvedIcon"
9
- @close="$emit('update:open', false)"
10
- @update:active="onTabChange">
11
- <!-- Schema icon in sidebar header -->
12
- <template v-if="resolvedIcon" #header>
13
- <div class="cn-index-sidebar__header-icon">
14
- <CnIcon :name="resolvedIcon" :size="32" />
15
- </div>
16
- </template>
17
-
18
- <!-- Search Tab -->
19
- <NcAppSidebarTab
20
- id="search-tab"
21
- :name="searchTabLabel"
22
- :order="1">
23
- <template #icon>
24
- <Magnify :size="20" />
25
- </template>
26
-
27
- <div class="cn-index-sidebar__tab-content">
28
- <div v-if="$slots['search-above']" class="cn-index-sidebar__section">
29
- <slot name="search-above" />
30
- </div>
31
-
32
- <div class="cn-index-sidebar__section">
33
- <h3>{{ searchLabel }}</h3>
34
- <NcTextField
35
- :value="searchValue"
36
- :placeholder="searchPlaceholder"
37
- :label="searchLabel"
38
- @update:value="$emit('search', $event)" />
39
- </div>
40
-
41
- <div v-if="schemaFilters.length > 0" class="cn-index-sidebar__section">
42
- <h3>{{ filtersLabel }}</h3>
43
- <div
44
- v-for="filter in schemaFilters"
45
- :key="filter.key"
46
- class="cn-index-sidebar__filter-group">
47
- <div class="cn-index-sidebar__filter-header">
48
- <span class="cn-index-sidebar__filter-label">{{ filter.label }}</span>
49
- <NcPopover v-if="filter.description" popup-role="dialog">
50
- <template #trigger>
51
- <NcButton
52
- type="tertiary-no-background"
53
- :aria-label="filter.label + ' info'"
54
- class="cn-index-sidebar__info-btn">
55
- <template #icon>
56
- <InformationOutline :size="16" />
57
- </template>
58
- </NcButton>
59
- </template>
60
- <p class="cn-index-sidebar__filter-description">{{ filter.description }}</p>
61
- </NcPopover>
62
- </div>
63
- <NcSelect
64
- class="cn-index-sidebar__select"
65
- :value="getSelectedFilterOptions(filter)"
66
- :options="getFilterOptions(filter)"
67
- placeholder="Select..."
68
- :input-label="filter.label"
69
- :multiple="true"
70
- :clearable="true"
71
- @input="onFilterChange(filter.key, $event)" />
72
- </div>
73
- </div>
74
-
75
- <slot name="search-extra" />
76
- </div>
77
- </NcAppSidebarTab>
78
-
79
- <!-- Columns Tab -->
80
- <NcAppSidebarTab
81
- id="columns-tab"
82
- :name="columnsTabLabel"
83
- :order="2">
84
- <template #icon>
85
- <FormatColumns :size="20" />
86
- </template>
87
-
88
- <div class="cn-index-sidebar__tab-content">
89
- <div class="cn-sidebar-columns">
90
- <h3>{{ columnsHeading }}</h3>
91
- <p class="cn-sidebar-columns__description">{{ columnsDescription }}</p>
92
-
93
- <template v-if="allColumns.length > 0 || allGroups.length > 0">
94
- <!-- Schema properties group (collapsible) -->
95
- <div v-if="allColumns.length > 0" class="cn-sidebar-columns__group cn-sidebar-columns__group--collapsible">
96
- <div class="cn-sidebar-columns__group-header" @click="propertiesExpanded = !propertiesExpanded">
97
- <ChevronDown v-if="propertiesExpanded" :size="20" />
98
- <ChevronRight v-else :size="20" />
99
- <h4>{{ resolvedPropertiesLabel }}</h4>
100
- <NcCheckboxRadioSwitch
101
- :checked="isGroupAllVisible(allColumns)"
102
- class="cn-sidebar-columns__select-all"
103
- @click.native.stop
104
- @update:checked="toggleGroupAll(allColumns)">
105
- All
106
- </NcCheckboxRadioSwitch>
107
- </div>
108
- <div v-if="propertiesExpanded" class="cn-sidebar-columns__group-content">
109
- <NcCheckboxRadioSwitch
110
- v-for="col in allColumns"
111
- :key="col.key"
112
- :checked="isColumnVisible(col.key)"
113
- @update:checked="toggleColumn(col.key)">
114
- {{ col.label }}
115
- </NcCheckboxRadioSwitch>
116
- </div>
117
- </div>
118
-
119
- <!-- Extra column groups (built-in Metadata + external) -->
120
- <div
121
- v-for="group in allGroups"
122
- :key="group.id"
123
- class="cn-sidebar-columns__group cn-sidebar-columns__group--collapsible">
124
- <div class="cn-sidebar-columns__group-header" @click="toggleGroup(group.id)">
125
- <ChevronDown v-if="expandedGroups[group.id]" :size="20" />
126
- <ChevronRight v-else :size="20" />
127
- <h4>{{ group.label }}</h4>
128
- <NcCheckboxRadioSwitch
129
- :checked="isGroupAllVisible(group.columns)"
130
- class="cn-sidebar-columns__select-all"
131
- @click.native.stop
132
- @update:checked="toggleGroupAll(group.columns)">
133
- All
134
- </NcCheckboxRadioSwitch>
135
- </div>
136
- <div v-if="expandedGroups[group.id]" class="cn-sidebar-columns__group-content">
137
- <NcCheckboxRadioSwitch
138
- v-for="col in group.columns"
139
- :key="col.key"
140
- :checked="isColumnVisible(col.key)"
141
- @update:checked="toggleColumn(col.key)">
142
- {{ col.label }}
143
- </NcCheckboxRadioSwitch>
144
- </div>
145
- </div>
146
- </template>
147
-
148
- <p v-else class="cn-sidebar-columns__empty">
149
- No columns available. Provide a schema to auto-generate columns.
150
- </p>
151
- </div>
152
-
153
- <slot name="columns-extra" />
154
- </div>
155
- </NcAppSidebarTab>
156
-
157
- <!-- Extra tabs injected by the consumer -->
158
- <slot name="tabs" />
159
- </NcAppSidebar>
160
- </template>
161
-
162
- <script>
163
- import { NcAppSidebar, NcAppSidebarTab, NcTextField, NcSelect, NcCheckboxRadioSwitch, NcPopover, NcButton } from '@nextcloud/vue'
164
- import Magnify from 'vue-material-design-icons/Magnify.vue'
165
- import FormatColumns from 'vue-material-design-icons/FormatColumns.vue'
166
- import ChevronDown from 'vue-material-design-icons/ChevronDown.vue'
167
- import ChevronRight from 'vue-material-design-icons/ChevronRight.vue'
168
- import InformationOutline from 'vue-material-design-icons/InformationOutline.vue'
169
- import { CnIcon } from '../CnIcon/index.js'
170
- import { columnsFromSchema, filtersFromSchema } from '../../utils/schema.js'
171
- import { METADATA_COLUMNS } from '../../constants/metadata.js'
172
-
173
- /**
174
- * CnIndexSidebar — Reusable NcAppSidebar wrapper with Search + Columns tabs.
175
- *
176
- * Designed to be schema-driven: pass a schema and the sidebar auto-generates
177
- * search filters, column visibility controls, and the standard Metadata group.
178
- * Title and properties group label are derived from schema.title by default.
179
- *
180
- * Must be rendered at the App.vue level as a sibling of NcAppContent.
181
- * Use provide/inject to connect it to page components.
182
- *
183
- * @example
184
- * <!-- Minimal usage — schema drives everything -->
185
- * <CnIndexSidebar
186
- * :schema="schema"
187
- * :visible-columns="visibleCols"
188
- * :search-value="search"
189
- * @search="onSearch"
190
- * @columns-change="onColumnsChange" />
191
- *
192
- * @slot search-above - Content rendered above the search field in the Search tab (e.g. hints, quick actions).
193
- * @slot search-extra - Content rendered below the search field and filters in the Search tab (e.g. saved searches).
194
- */
195
- export default {
196
- name: 'CnIndexSidebar',
197
-
198
- components: {
199
- NcAppSidebar,
200
- NcAppSidebarTab,
201
- NcTextField,
202
- NcSelect,
203
- NcCheckboxRadioSwitch,
204
- NcPopover,
205
- NcButton,
206
- CnIcon,
207
- Magnify,
208
- FormatColumns,
209
- ChevronDown,
210
- ChevronRight,
211
- InformationOutline,
212
- },
213
-
214
- props: {
215
- /** Sidebar title. Defaults to schema.title when not set. */
216
- title: {
217
- type: String,
218
- default: '',
219
- },
220
- /** MDI icon name or emoji. Defaults to schema.icon when not set. */
221
- icon: {
222
- type: String,
223
- default: '',
224
- },
225
- /** Schema object for auto-generating filters, columns, and labels */
226
- schema: {
227
- type: Object,
228
- default: null,
229
- },
230
- /** Array of currently visible column keys */
231
- visibleColumns: {
232
- type: Array,
233
- default: null,
234
- },
235
- /** Current search term */
236
- searchValue: {
237
- type: String,
238
- default: '',
239
- },
240
- /** Whether sidebar is open */
241
- open: {
242
- type: Boolean,
243
- default: true,
244
- },
245
- /** Current active facet filters: { fieldName: [values] } */
246
- activeFilters: {
247
- type: Object,
248
- default: () => ({}),
249
- },
250
- /** Live facet data from API: { fieldName: { values: [{value, count}] } } */
251
- facetData: {
252
- type: Object,
253
- default: () => ({}),
254
- },
255
- /**
256
- * Additional column groups beyond schema properties and the built-in Metadata.
257
- * Each group: { id: string, label: string, columns: Array<{key, label}>, expanded?: boolean }
258
- */
259
- columnGroups: {
260
- type: Array,
261
- default: () => [],
262
- },
263
- /** Whether to include the built-in Metadata column group */
264
- showMetadata: {
265
- type: Boolean,
266
- default: true,
267
- },
268
- /** Search input placeholder */
269
- searchPlaceholder: {
270
- type: String,
271
- default: 'Type to search...',
272
- },
273
- /** Search tab label */
274
- searchTabLabel: {
275
- type: String,
276
- default: 'Search',
277
- },
278
- /** Columns tab label */
279
- columnsTabLabel: {
280
- type: String,
281
- default: 'Columns',
282
- },
283
- /** Search section heading */
284
- searchLabel: {
285
- type: String,
286
- default: 'Search',
287
- },
288
- /** Filters section heading */
289
- filtersLabel: {
290
- type: String,
291
- default: 'Filters',
292
- },
293
- /** Columns section heading */
294
- columnsHeading: {
295
- type: String,
296
- default: 'Column Visibility',
297
- },
298
- /** Columns section description */
299
- columnsDescription: {
300
- type: String,
301
- default: 'Select which columns to display in the table',
302
- },
303
- /** Override label for the schema properties group. Defaults to schema.title. */
304
- propertiesGroupLabel: {
305
- type: String,
306
- default: '',
307
- },
308
- /**
309
- * ID of the tab that should be active when the sidebar opens.
310
- * Built-in IDs are 'search-tab' and 'columns-tab'.
311
- * Use the id you set on your custom NcAppSidebarTab for custom tabs.
312
- */
313
- defaultTab: {
314
- type: String,
315
- default: 'search-tab',
316
- },
317
- /**
318
- * Whether the current user is an admin.
319
- * When false, schema properties with `adminOnly: true` are hidden from filters.
320
- */
321
- userIsAdmin: {
322
- type: Boolean,
323
- default: true,
324
- },
325
- },
326
-
327
- data() {
328
- return {
329
- internalOpen: this.open,
330
- internalActiveTab: this.defaultTab,
331
- propertiesExpanded: true,
332
- expandedGroups: {},
333
- }
334
- },
335
-
336
- computed: {
337
- /** Resolved icon — explicit prop overrides schema.icon */
338
- resolvedIcon() {
339
- return this.icon || this.schema?.icon || ''
340
- },
341
-
342
- /** Sidebar name — schema title, shown as the h2 header */
343
- resolvedName() {
344
- if (this.title) return this.title
345
- return this.schema?.title || 'Search'
346
- },
347
-
348
- /** Sidebar subname — schema description, shown below the name */
349
- resolvedSubname() {
350
- return this.schema?.description || ''
351
- },
352
-
353
- /** Properties group label — derived from schema.title if not explicitly set */
354
- resolvedPropertiesLabel() {
355
- if (this.propertiesGroupLabel) return this.propertiesGroupLabel
356
- return this.schema?.title || 'Properties'
357
- },
358
-
359
- /** All available columns from schema */
360
- allColumns() {
361
- if (!this.schema) return []
362
- return columnsFromSchema(this.schema, {})
363
- },
364
-
365
- /** Filter definitions from schema (facetable properties, respecting RBAC) */
366
- schemaFilters() {
367
- if (!this.schema) return []
368
- return filtersFromSchema(this.schema, { isAdmin: this.userIsAdmin })
369
- },
370
-
371
- /** Combined column groups: built-in Metadata + external groups */
372
- allGroups() {
373
- const groups = []
374
- if (this.showMetadata && this.schema) {
375
- groups.push({
376
- id: 'metadata',
377
- label: 'Metadata',
378
- columns: METADATA_COLUMNS,
379
- expanded: true,
380
- })
381
- }
382
- return [...groups, ...this.columnGroups]
383
- },
384
-
385
- /** All column keys across schema properties and all groups */
386
- allColumnKeys() {
387
- return [
388
- ...this.allColumns.map((c) => c.key),
389
- ...this.allGroups.flatMap((g) => g.columns.map((c) => c.key)),
390
- ]
391
- },
392
- },
393
-
394
- watch: {
395
- open(val) {
396
- this.internalOpen = val
397
- },
398
- internalOpen(val) {
399
- this.$emit('update:open', val)
400
- },
401
- defaultTab(val) {
402
- this.internalActiveTab = val
403
- },
404
- allGroups: {
405
- immediate: true,
406
- handler(groups) {
407
- for (const group of groups) {
408
- if (!(group.id in this.expandedGroups)) {
409
- this.$set(this.expandedGroups, group.id, group.expanded !== false)
410
- }
411
- }
412
- },
413
- },
414
- },
415
-
416
- methods: {
417
- /** Handle tab change from NcAppSidebar */
418
- onTabChange(tabId) {
419
- this.internalActiveTab = tabId
420
- this.$emit('tab-change', tabId)
421
- },
422
-
423
- /** Check if a column is currently visible */
424
- isColumnVisible(key) {
425
- if (this.visibleColumns === null) return true
426
- return this.visibleColumns.includes(key)
427
- },
428
-
429
- /** Check if all columns in a group are visible */
430
- isGroupAllVisible(columns) {
431
- return columns.every((col) => this.isColumnVisible(col.key))
432
- },
433
-
434
- /** Toggle a single column's visibility */
435
- toggleColumn(key) {
436
- let newVisible
437
- if (this.visibleColumns === null) {
438
- newVisible = this.allColumnKeys.filter((k) => k !== key)
439
- } else if (this.isColumnVisible(key)) {
440
- newVisible = this.visibleColumns.filter((k) => k !== key)
441
- } else {
442
- newVisible = [...this.visibleColumns, key]
443
- }
444
- this.$emit('columns-change', newVisible)
445
- },
446
-
447
- /** Select or deselect all columns in a group */
448
- toggleGroupAll(columns) {
449
- const groupKeys = columns.map((c) => c.key)
450
- const allVisible = this.isGroupAllVisible(columns)
451
-
452
- let newVisible
453
- if (this.visibleColumns === null) {
454
- // Currently all visible — deselect this group
455
- newVisible = this.allColumnKeys.filter((k) => !groupKeys.includes(k))
456
- } else if (allVisible) {
457
- // All in group visible — deselect them
458
- newVisible = this.visibleColumns.filter((k) => !groupKeys.includes(k))
459
- } else {
460
- // Not all visible — select them all
461
- const current = new Set(this.visibleColumns)
462
- groupKeys.forEach((k) => current.add(k))
463
- newVisible = [...current]
464
- }
465
- this.$emit('columns-change', newVisible)
466
- },
467
-
468
- /** Toggle a group's expanded state */
469
- toggleGroup(groupId) {
470
- this.$set(this.expandedGroups, groupId, !this.expandedGroups[groupId])
471
- },
472
-
473
- /** Get filter options for a filter definition */
474
- getFilterOptions(filter) {
475
- const facet = this.facetData[filter.key]
476
- if (facet?.values?.length > 0) {
477
- return facet.values.map((v) => ({
478
- id: v.value,
479
- label: v.count !== undefined ? `${v.value} (${v.count})` : String(v.value),
480
- }))
481
- }
482
- return filter.options || []
483
- },
484
-
485
- /** Get currently selected options for a filter */
486
- getSelectedFilterOptions(filter) {
487
- const value = this.activeFilters[filter.key]
488
- if (!value) return []
489
- const values = Array.isArray(value) ? value : [value]
490
- const options = this.getFilterOptions(filter)
491
- return values.map((v) => options.find((o) => o.id === v) || { id: v, label: String(v) })
492
- },
493
-
494
- /** Handle filter select change */
495
- onFilterChange(key, selected) {
496
- const values = selected ? selected.map((o) => o.id) : []
497
- this.$emit('filter-change', { key, values })
498
- },
499
- },
500
- }
501
- </script>
502
-
503
- <!-- Styles in css/index-sidebar.css -->
1
+ <template>
2
+ <NcAppSidebar
3
+ :name="resolvedName"
4
+ :title="resolvedName"
5
+ :subname="resolvedSubname"
6
+ :open.sync="internalOpen"
7
+ :active="internalActiveTab"
8
+ :compact="!!resolvedIcon"
9
+ @close="$emit('update:open', false)"
10
+ @update:active="onTabChange">
11
+ <!-- Schema icon in sidebar header -->
12
+ <template v-if="resolvedIcon" #header>
13
+ <div class="cn-index-sidebar__header-icon">
14
+ <CnIcon :name="resolvedIcon" :size="32" />
15
+ </div>
16
+ </template>
17
+
18
+ <!-- Search Tab -->
19
+ <NcAppSidebarTab
20
+ id="search-tab"
21
+ :name="searchTabLabel"
22
+ :order="1">
23
+ <template #icon>
24
+ <Magnify :size="20" />
25
+ </template>
26
+
27
+ <div class="cn-index-sidebar__tab-content">
28
+ <div v-if="$slots['search-above']" class="cn-index-sidebar__section">
29
+ <slot name="search-above" />
30
+ </div>
31
+
32
+ <div class="cn-index-sidebar__section">
33
+ <h3>{{ searchLabel }}</h3>
34
+ <NcTextField
35
+ :value="searchValue"
36
+ :placeholder="searchPlaceholder"
37
+ :label="searchLabel"
38
+ @update:value="$emit('search', $event)" />
39
+ </div>
40
+
41
+ <div v-if="schemaFilters.length > 0" class="cn-index-sidebar__section">
42
+ <h3>{{ filtersLabel }}</h3>
43
+ <div
44
+ v-for="filter in schemaFilters"
45
+ :key="filter.key"
46
+ class="cn-index-sidebar__filter-group">
47
+ <div class="cn-index-sidebar__filter-header">
48
+ <span class="cn-index-sidebar__filter-label">{{ filter.label }}</span>
49
+ <NcPopover v-if="filter.description" popup-role="dialog">
50
+ <template #trigger>
51
+ <NcButton
52
+ type="tertiary-no-background"
53
+ :aria-label="filter.label + ' info'"
54
+ class="cn-index-sidebar__info-btn">
55
+ <template #icon>
56
+ <InformationOutline :size="16" />
57
+ </template>
58
+ </NcButton>
59
+ </template>
60
+ <p class="cn-index-sidebar__filter-description">{{ filter.description }}</p>
61
+ </NcPopover>
62
+ </div>
63
+ <NcSelect
64
+ class="cn-index-sidebar__select"
65
+ :value="getSelectedFilterOptions(filter)"
66
+ :options="getFilterOptions(filter)"
67
+ placeholder="Select..."
68
+ :input-label="filter.label"
69
+ :multiple="true"
70
+ :clearable="true"
71
+ @input="onFilterChange(filter.key, $event)" />
72
+ </div>
73
+ </div>
74
+
75
+ <slot name="search-extra" />
76
+ </div>
77
+ </NcAppSidebarTab>
78
+
79
+ <!-- Columns Tab -->
80
+ <NcAppSidebarTab
81
+ id="columns-tab"
82
+ :name="columnsTabLabel"
83
+ :order="2">
84
+ <template #icon>
85
+ <FormatColumns :size="20" />
86
+ </template>
87
+
88
+ <div class="cn-index-sidebar__tab-content">
89
+ <div class="cn-sidebar-columns">
90
+ <h3>{{ columnsHeading }}</h3>
91
+ <p class="cn-sidebar-columns__description">{{ columnsDescription }}</p>
92
+
93
+ <template v-if="allColumns.length > 0 || allGroups.length > 0">
94
+ <!-- Schema properties group (collapsible) -->
95
+ <div v-if="allColumns.length > 0" class="cn-sidebar-columns__group cn-sidebar-columns__group--collapsible">
96
+ <div class="cn-sidebar-columns__group-header" @click="propertiesExpanded = !propertiesExpanded">
97
+ <ChevronDown v-if="propertiesExpanded" :size="20" />
98
+ <ChevronRight v-else :size="20" />
99
+ <h4>{{ resolvedPropertiesLabel }}</h4>
100
+ <NcCheckboxRadioSwitch
101
+ :checked="isGroupAllVisible(allColumns)"
102
+ class="cn-sidebar-columns__select-all"
103
+ @click.native.stop
104
+ @update:checked="toggleGroupAll(allColumns)">
105
+ All
106
+ </NcCheckboxRadioSwitch>
107
+ </div>
108
+ <div v-if="propertiesExpanded" class="cn-sidebar-columns__group-content">
109
+ <NcCheckboxRadioSwitch
110
+ v-for="col in allColumns"
111
+ :key="col.key"
112
+ :checked="isColumnVisible(col.key)"
113
+ @update:checked="toggleColumn(col.key)">
114
+ {{ col.label }}
115
+ </NcCheckboxRadioSwitch>
116
+ </div>
117
+ </div>
118
+
119
+ <!-- Extra column groups (built-in Metadata + external) -->
120
+ <div
121
+ v-for="group in allGroups"
122
+ :key="group.id"
123
+ class="cn-sidebar-columns__group cn-sidebar-columns__group--collapsible">
124
+ <div class="cn-sidebar-columns__group-header" @click="toggleGroup(group.id)">
125
+ <ChevronDown v-if="expandedGroups[group.id]" :size="20" />
126
+ <ChevronRight v-else :size="20" />
127
+ <h4>{{ group.label }}</h4>
128
+ <NcCheckboxRadioSwitch
129
+ :checked="isGroupAllVisible(group.columns)"
130
+ class="cn-sidebar-columns__select-all"
131
+ @click.native.stop
132
+ @update:checked="toggleGroupAll(group.columns)">
133
+ All
134
+ </NcCheckboxRadioSwitch>
135
+ </div>
136
+ <div v-if="expandedGroups[group.id]" class="cn-sidebar-columns__group-content">
137
+ <NcCheckboxRadioSwitch
138
+ v-for="col in group.columns"
139
+ :key="col.key"
140
+ :checked="isColumnVisible(col.key)"
141
+ @update:checked="toggleColumn(col.key)">
142
+ {{ col.label }}
143
+ </NcCheckboxRadioSwitch>
144
+ </div>
145
+ </div>
146
+ </template>
147
+
148
+ <p v-else class="cn-sidebar-columns__empty">
149
+ No columns available. Provide a schema to auto-generate columns.
150
+ </p>
151
+ </div>
152
+
153
+ <slot name="columns-extra" />
154
+ </div>
155
+ </NcAppSidebarTab>
156
+
157
+ <!-- Extra tabs injected by the consumer -->
158
+ <slot name="tabs" />
159
+ </NcAppSidebar>
160
+ </template>
161
+
162
+ <script>
163
+ import { NcAppSidebar, NcAppSidebarTab, NcTextField, NcSelect, NcCheckboxRadioSwitch, NcPopover, NcButton } from '@nextcloud/vue'
164
+ import Magnify from 'vue-material-design-icons/Magnify.vue'
165
+ import FormatColumns from 'vue-material-design-icons/FormatColumns.vue'
166
+ import ChevronDown from 'vue-material-design-icons/ChevronDown.vue'
167
+ import ChevronRight from 'vue-material-design-icons/ChevronRight.vue'
168
+ import InformationOutline from 'vue-material-design-icons/InformationOutline.vue'
169
+ import { CnIcon } from '../CnIcon/index.js'
170
+ import { columnsFromSchema, filtersFromSchema } from '../../utils/schema.js'
171
+ import { METADATA_COLUMNS } from '../../constants/metadata.js'
172
+
173
+ /**
174
+ * CnIndexSidebar — Reusable NcAppSidebar wrapper with Search + Columns tabs.
175
+ *
176
+ * Designed to be schema-driven: pass a schema and the sidebar auto-generates
177
+ * search filters, column visibility controls, and the standard Metadata group.
178
+ * Title and properties group label are derived from schema.title by default.
179
+ *
180
+ * Must be rendered at the App.vue level as a sibling of NcAppContent.
181
+ * Use provide/inject to connect it to page components.
182
+ *
183
+ * @example
184
+ * <!-- Minimal usage — schema drives everything -->
185
+ * <CnIndexSidebar
186
+ * :schema="schema"
187
+ * :visible-columns="visibleCols"
188
+ * :search-value="search"
189
+ * @search="onSearch"
190
+ * @columns-change="onColumnsChange" />
191
+ *
192
+ * @slot search-above - Content rendered above the search field in the Search tab (e.g. hints, quick actions).
193
+ * @slot search-extra - Content rendered below the search field and filters in the Search tab (e.g. saved searches).
194
+ */
195
+ export default {
196
+ name: 'CnIndexSidebar',
197
+
198
+ components: {
199
+ NcAppSidebar,
200
+ NcAppSidebarTab,
201
+ NcTextField,
202
+ NcSelect,
203
+ NcCheckboxRadioSwitch,
204
+ NcPopover,
205
+ NcButton,
206
+ CnIcon,
207
+ Magnify,
208
+ FormatColumns,
209
+ ChevronDown,
210
+ ChevronRight,
211
+ InformationOutline,
212
+ },
213
+
214
+ props: {
215
+ /** Sidebar title. Defaults to schema.title when not set. */
216
+ title: {
217
+ type: String,
218
+ default: '',
219
+ },
220
+ /** MDI icon name or emoji. Defaults to schema.icon when not set. */
221
+ icon: {
222
+ type: String,
223
+ default: '',
224
+ },
225
+ /** Schema object for auto-generating filters, columns, and labels */
226
+ schema: {
227
+ type: Object,
228
+ default: null,
229
+ },
230
+ /** Array of currently visible column keys */
231
+ visibleColumns: {
232
+ type: Array,
233
+ default: null,
234
+ },
235
+ /** Current search term */
236
+ searchValue: {
237
+ type: String,
238
+ default: '',
239
+ },
240
+ /** Whether sidebar is open */
241
+ open: {
242
+ type: Boolean,
243
+ default: true,
244
+ },
245
+ /** Current active facet filters: { fieldName: [values] } */
246
+ activeFilters: {
247
+ type: Object,
248
+ default: () => ({}),
249
+ },
250
+ /** Live facet data from API: { fieldName: { values: [{value, count}] } } */
251
+ facetData: {
252
+ type: Object,
253
+ default: () => ({}),
254
+ },
255
+ /**
256
+ * Additional column groups beyond schema properties and the built-in Metadata.
257
+ * Each group: { id: string, label: string, columns: Array<{key, label}>, expanded?: boolean }
258
+ */
259
+ columnGroups: {
260
+ type: Array,
261
+ default: () => [],
262
+ },
263
+ /** Whether to include the built-in Metadata column group */
264
+ showMetadata: {
265
+ type: Boolean,
266
+ default: true,
267
+ },
268
+ /** Search input placeholder */
269
+ searchPlaceholder: {
270
+ type: String,
271
+ default: 'Type to search...',
272
+ },
273
+ /** Search tab label */
274
+ searchTabLabel: {
275
+ type: String,
276
+ default: 'Search',
277
+ },
278
+ /** Columns tab label */
279
+ columnsTabLabel: {
280
+ type: String,
281
+ default: 'Columns',
282
+ },
283
+ /** Search section heading */
284
+ searchLabel: {
285
+ type: String,
286
+ default: 'Search',
287
+ },
288
+ /** Filters section heading */
289
+ filtersLabel: {
290
+ type: String,
291
+ default: 'Filters',
292
+ },
293
+ /** Columns section heading */
294
+ columnsHeading: {
295
+ type: String,
296
+ default: 'Column Visibility',
297
+ },
298
+ /** Columns section description */
299
+ columnsDescription: {
300
+ type: String,
301
+ default: 'Select which columns to display in the table',
302
+ },
303
+ /** Override label for the schema properties group. Defaults to schema.title. */
304
+ propertiesGroupLabel: {
305
+ type: String,
306
+ default: '',
307
+ },
308
+ /**
309
+ * ID of the tab that should be active when the sidebar opens.
310
+ * Built-in IDs are 'search-tab' and 'columns-tab'.
311
+ * Use the id you set on your custom NcAppSidebarTab for custom tabs.
312
+ */
313
+ defaultTab: {
314
+ type: String,
315
+ default: 'search-tab',
316
+ },
317
+ /**
318
+ * Whether the current user is an admin.
319
+ * When false, schema properties with `adminOnly: true` are hidden from filters.
320
+ */
321
+ userIsAdmin: {
322
+ type: Boolean,
323
+ default: true,
324
+ },
325
+ },
326
+
327
+ data() {
328
+ return {
329
+ internalOpen: this.open,
330
+ internalActiveTab: this.defaultTab,
331
+ propertiesExpanded: true,
332
+ expandedGroups: {},
333
+ }
334
+ },
335
+
336
+ computed: {
337
+ /** Resolved icon — explicit prop overrides schema.icon */
338
+ resolvedIcon() {
339
+ return this.icon || this.schema?.icon || ''
340
+ },
341
+
342
+ /** Sidebar name — schema title, shown as the h2 header */
343
+ resolvedName() {
344
+ if (this.title) return this.title
345
+ return this.schema?.title || 'Search'
346
+ },
347
+
348
+ /** Sidebar subname — schema description, shown below the name */
349
+ resolvedSubname() {
350
+ return this.schema?.description || ''
351
+ },
352
+
353
+ /** Properties group label — derived from schema.title if not explicitly set */
354
+ resolvedPropertiesLabel() {
355
+ if (this.propertiesGroupLabel) return this.propertiesGroupLabel
356
+ return this.schema?.title || 'Properties'
357
+ },
358
+
359
+ /** All available columns from schema */
360
+ allColumns() {
361
+ if (!this.schema) return []
362
+ return columnsFromSchema(this.schema, {})
363
+ },
364
+
365
+ /** Filter definitions from schema (facetable properties, respecting RBAC) */
366
+ schemaFilters() {
367
+ if (!this.schema) return []
368
+ return filtersFromSchema(this.schema, { isAdmin: this.userIsAdmin })
369
+ },
370
+
371
+ /** Combined column groups: built-in Metadata + external groups */
372
+ allGroups() {
373
+ const groups = []
374
+ if (this.showMetadata && this.schema) {
375
+ groups.push({
376
+ id: 'metadata',
377
+ label: 'Metadata',
378
+ columns: METADATA_COLUMNS,
379
+ expanded: true,
380
+ })
381
+ }
382
+ return [...groups, ...this.columnGroups]
383
+ },
384
+
385
+ /** All column keys across schema properties and all groups */
386
+ allColumnKeys() {
387
+ return [
388
+ ...this.allColumns.map((c) => c.key),
389
+ ...this.allGroups.flatMap((g) => g.columns.map((c) => c.key)),
390
+ ]
391
+ },
392
+ },
393
+
394
+ watch: {
395
+ open(val) {
396
+ this.internalOpen = val
397
+ },
398
+ internalOpen(val) {
399
+ this.$emit('update:open', val)
400
+ },
401
+ defaultTab(val) {
402
+ this.internalActiveTab = val
403
+ },
404
+ allGroups: {
405
+ immediate: true,
406
+ handler(groups) {
407
+ for (const group of groups) {
408
+ if (!(group.id in this.expandedGroups)) {
409
+ this.$set(this.expandedGroups, group.id, group.expanded !== false)
410
+ }
411
+ }
412
+ },
413
+ },
414
+ },
415
+
416
+ methods: {
417
+ /** Handle tab change from NcAppSidebar */
418
+ onTabChange(tabId) {
419
+ this.internalActiveTab = tabId
420
+ this.$emit('tab-change', tabId)
421
+ },
422
+
423
+ /** Check if a column is currently visible */
424
+ isColumnVisible(key) {
425
+ if (this.visibleColumns === null) return true
426
+ return this.visibleColumns.includes(key)
427
+ },
428
+
429
+ /** Check if all columns in a group are visible */
430
+ isGroupAllVisible(columns) {
431
+ return columns.every((col) => this.isColumnVisible(col.key))
432
+ },
433
+
434
+ /** Toggle a single column's visibility */
435
+ toggleColumn(key) {
436
+ let newVisible
437
+ if (this.visibleColumns === null) {
438
+ newVisible = this.allColumnKeys.filter((k) => k !== key)
439
+ } else if (this.isColumnVisible(key)) {
440
+ newVisible = this.visibleColumns.filter((k) => k !== key)
441
+ } else {
442
+ newVisible = [...this.visibleColumns, key]
443
+ }
444
+ this.$emit('columns-change', newVisible)
445
+ },
446
+
447
+ /** Select or deselect all columns in a group */
448
+ toggleGroupAll(columns) {
449
+ const groupKeys = columns.map((c) => c.key)
450
+ const allVisible = this.isGroupAllVisible(columns)
451
+
452
+ let newVisible
453
+ if (this.visibleColumns === null) {
454
+ // Currently all visible — deselect this group
455
+ newVisible = this.allColumnKeys.filter((k) => !groupKeys.includes(k))
456
+ } else if (allVisible) {
457
+ // All in group visible — deselect them
458
+ newVisible = this.visibleColumns.filter((k) => !groupKeys.includes(k))
459
+ } else {
460
+ // Not all visible — select them all
461
+ const current = new Set(this.visibleColumns)
462
+ groupKeys.forEach((k) => current.add(k))
463
+ newVisible = [...current]
464
+ }
465
+ this.$emit('columns-change', newVisible)
466
+ },
467
+
468
+ /** Toggle a group's expanded state */
469
+ toggleGroup(groupId) {
470
+ this.$set(this.expandedGroups, groupId, !this.expandedGroups[groupId])
471
+ },
472
+
473
+ /** Get filter options for a filter definition */
474
+ getFilterOptions(filter) {
475
+ const facet = this.facetData[filter.key]
476
+ if (facet?.values?.length > 0) {
477
+ return facet.values.map((v) => ({
478
+ id: v.value,
479
+ label: v.count !== undefined ? `${v.value} (${v.count})` : String(v.value),
480
+ }))
481
+ }
482
+ return filter.options || []
483
+ },
484
+
485
+ /** Get currently selected options for a filter */
486
+ getSelectedFilterOptions(filter) {
487
+ const value = this.activeFilters[filter.key]
488
+ if (!value) return []
489
+ const values = Array.isArray(value) ? value : [value]
490
+ const options = this.getFilterOptions(filter)
491
+ return values.map((v) => options.find((o) => o.id === v) || { id: v, label: String(v) })
492
+ },
493
+
494
+ /** Handle filter select change */
495
+ onFilterChange(key, selected) {
496
+ const values = selected ? selected.map((o) => o.id) : []
497
+ this.$emit('filter-change', { key, values })
498
+ },
499
+ },
500
+ }
501
+ </script>
502
+
503
+ <!-- Styles in css/index-sidebar.css -->