@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.
- package/dist/nextcloud-vue.cjs.js +10710 -0
- package/dist/nextcloud-vue.cjs.js.map +1 -0
- package/dist/nextcloud-vue.css +803 -0
- package/dist/nextcloud-vue.esm.js +10665 -0
- package/dist/nextcloud-vue.esm.js.map +1 -0
- package/package.json +63 -0
- package/src/components/CnCardGrid/CnCardGrid.vue +152 -0
- package/src/components/CnCardGrid/index.js +1 -0
- package/src/components/CnCellRenderer/CnCellRenderer.vue +132 -0
- package/src/components/CnCellRenderer/index.js +1 -0
- package/src/components/CnConfigurationCard/CnConfigurationCard.vue +77 -0
- package/src/components/CnConfigurationCard/index.js +1 -0
- package/src/components/CnDataTable/CnDataTable.vue +354 -0
- package/src/components/CnDataTable/index.js +1 -0
- package/src/components/CnDetailViewLayout/CnDetailViewLayout.vue +88 -0
- package/src/components/CnDetailViewLayout/index.js +1 -0
- package/src/components/CnEmptyState/CnEmptyState.vue +78 -0
- package/src/components/CnEmptyState/index.js +1 -0
- package/src/components/CnFacetSidebar/CnFacetSidebar.vue +223 -0
- package/src/components/CnFacetSidebar/index.js +1 -0
- package/src/components/CnFilterBar/CnFilterBar.vue +152 -0
- package/src/components/CnFilterBar/index.js +1 -0
- package/src/components/CnIndexPage/CnIndexPage.vue +682 -0
- package/src/components/CnIndexPage/index.js +1 -0
- package/src/components/CnKpiGrid/CnKpiGrid.vue +89 -0
- package/src/components/CnKpiGrid/index.js +1 -0
- package/src/components/CnListViewLayout/CnListViewLayout.vue +80 -0
- package/src/components/CnListViewLayout/index.js +1 -0
- package/src/components/CnMassActionBar/CnMassActionBar.vue +160 -0
- package/src/components/CnMassActionBar/index.js +1 -0
- package/src/components/CnMassCopyDialog/CnMassCopyDialog.vue +320 -0
- package/src/components/CnMassCopyDialog/index.js +1 -0
- package/src/components/CnMassDeleteDialog/CnMassDeleteDialog.vue +238 -0
- package/src/components/CnMassDeleteDialog/index.js +1 -0
- package/src/components/CnMassExportDialog/CnMassExportDialog.vue +190 -0
- package/src/components/CnMassExportDialog/index.js +1 -0
- package/src/components/CnMassImportDialog/CnMassImportDialog.vue +491 -0
- package/src/components/CnMassImportDialog/index.js +1 -0
- package/src/components/CnObjectCard/CnObjectCard.vue +292 -0
- package/src/components/CnObjectCard/index.js +1 -0
- package/src/components/CnPagination/CnPagination.vue +252 -0
- package/src/components/CnPagination/index.js +1 -0
- package/src/components/CnRowActions/CnRowActions.vue +73 -0
- package/src/components/CnRowActions/index.js +1 -0
- package/src/components/CnSettingsCard/CnSettingsCard.vue +92 -0
- package/src/components/CnSettingsCard/index.js +1 -0
- package/src/components/CnSettingsSection/CnSettingsSection.vue +266 -0
- package/src/components/CnSettingsSection/index.js +1 -0
- package/src/components/CnStatsBlock/CnStatsBlock.vue +366 -0
- package/src/components/CnStatsBlock/index.js +1 -0
- package/src/components/CnStatusBadge/CnStatusBadge.vue +77 -0
- package/src/components/CnStatusBadge/index.js +1 -0
- package/src/components/CnVersionInfoCard/CnVersionInfoCard.vue +312 -0
- package/src/components/CnVersionInfoCard/index.js +1 -0
- package/src/components/CnViewModeToggle/CnViewModeToggle.vue +77 -0
- package/src/components/CnViewModeToggle/index.js +1 -0
- package/src/components/index.js +25 -0
- package/src/composables/index.js +3 -0
- package/src/composables/useDetailView.js +132 -0
- package/src/composables/useListView.js +153 -0
- package/src/composables/useSubResource.js +142 -0
- package/src/css/badge.css +51 -0
- package/src/css/card.css +128 -0
- package/src/css/detail.css +68 -0
- package/src/css/index.css +8 -0
- package/src/css/layout.css +90 -0
- package/src/css/pagination.css +72 -0
- package/src/css/table.css +143 -0
- package/src/css/utilities.css +46 -0
- package/src/index.js +50 -0
- package/src/store/createSubResourcePlugin.js +135 -0
- package/src/store/index.js +3 -0
- package/src/store/plugins/auditTrails.js +17 -0
- package/src/store/plugins/files.js +186 -0
- package/src/store/plugins/index.js +4 -0
- package/src/store/plugins/lifecycle.js +180 -0
- package/src/store/plugins/relations.js +68 -0
- package/src/store/useObjectStore.js +625 -0
- package/src/types/auditTrail.d.ts +32 -0
- package/src/types/file.d.ts +23 -0
- package/src/types/index.d.ts +35 -0
- package/src/types/notification.d.ts +36 -0
- package/src/types/object.d.ts +40 -0
- package/src/types/organisation.d.ts +41 -0
- package/src/types/register.d.ts +25 -0
- package/src/types/schema.d.ts +39 -0
- package/src/types/shared.d.ts +79 -0
- package/src/types/source.d.ts +14 -0
- package/src/types/task.d.ts +31 -0
- package/src/utils/errors.js +96 -0
- package/src/utils/headers.js +44 -0
- package/src/utils/index.js +3 -0
- package/src/utils/schema.js +287 -0
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div class="cn-kpi-grid" :class="gridClasses">
|
|
3
|
+
<slot />
|
|
4
|
+
</div>
|
|
5
|
+
</template>
|
|
6
|
+
|
|
7
|
+
<script>
|
|
8
|
+
/**
|
|
9
|
+
* CnKpiGrid — Responsive grid layout for KPI/stats cards.
|
|
10
|
+
*
|
|
11
|
+
* Wraps CnStatsBlock components in a responsive CSS grid. Supports
|
|
12
|
+
* 2, 3, or 4 column layouts that adapt to screen size.
|
|
13
|
+
*
|
|
14
|
+
* @example 4-column dashboard (default)
|
|
15
|
+
* <CnKpiGrid>
|
|
16
|
+
* <CnStatsBlock title="Cases" :count="42" :icon="BriefcaseOutline" variant="primary" />
|
|
17
|
+
* <CnStatsBlock title="Contacts" :count="128" :icon="AccountGroup" variant="success" />
|
|
18
|
+
* <CnStatsBlock title="Tasks" :count="7" :icon="ClipboardCheck" variant="warning" />
|
|
19
|
+
* <CnStatsBlock title="Overdue" :count="3" :icon="AlertCircle" variant="error" />
|
|
20
|
+
* </CnKpiGrid>
|
|
21
|
+
*
|
|
22
|
+
* @example 2-column layout
|
|
23
|
+
* <CnKpiGrid :columns="2">
|
|
24
|
+
* <CnStatsBlock title="Open" :count="15" />
|
|
25
|
+
* <CnStatsBlock title="Closed" :count="42" />
|
|
26
|
+
* </CnKpiGrid>
|
|
27
|
+
*/
|
|
28
|
+
export default {
|
|
29
|
+
name: 'CnKpiGrid',
|
|
30
|
+
|
|
31
|
+
props: {
|
|
32
|
+
/** Number of columns at max width: 2, 3, or 4 */
|
|
33
|
+
columns: {
|
|
34
|
+
type: Number,
|
|
35
|
+
default: 4,
|
|
36
|
+
validator: (v) => [2, 3, 4].includes(v),
|
|
37
|
+
},
|
|
38
|
+
},
|
|
39
|
+
|
|
40
|
+
computed: {
|
|
41
|
+
gridClasses() {
|
|
42
|
+
return {
|
|
43
|
+
[`cn-kpi-grid--cols-${this.columns}`]: true,
|
|
44
|
+
}
|
|
45
|
+
},
|
|
46
|
+
},
|
|
47
|
+
}
|
|
48
|
+
</script>
|
|
49
|
+
|
|
50
|
+
<style scoped>
|
|
51
|
+
.cn-kpi-grid {
|
|
52
|
+
display: grid;
|
|
53
|
+
gap: 16px;
|
|
54
|
+
margin-bottom: 24px;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
.cn-kpi-grid--cols-2 {
|
|
58
|
+
grid-template-columns: repeat(2, 1fr);
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
.cn-kpi-grid--cols-3 {
|
|
62
|
+
grid-template-columns: repeat(3, 1fr);
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
.cn-kpi-grid--cols-4 {
|
|
66
|
+
grid-template-columns: repeat(4, 1fr);
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
/* Responsive breakpoints */
|
|
70
|
+
@media (max-width: 1200px) {
|
|
71
|
+
.cn-kpi-grid--cols-4 {
|
|
72
|
+
grid-template-columns: repeat(2, 1fr);
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
@media (max-width: 900px) {
|
|
77
|
+
.cn-kpi-grid--cols-3 {
|
|
78
|
+
grid-template-columns: repeat(2, 1fr);
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
@media (max-width: 600px) {
|
|
83
|
+
.cn-kpi-grid--cols-2,
|
|
84
|
+
.cn-kpi-grid--cols-3,
|
|
85
|
+
.cn-kpi-grid--cols-4 {
|
|
86
|
+
grid-template-columns: 1fr;
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
</style>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default as CnKpiGrid } from './CnKpiGrid.vue'
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div class="cn-list-layout">
|
|
3
|
+
<!-- Header -->
|
|
4
|
+
<div class="cn-list-layout__header">
|
|
5
|
+
<div class="cn-list-layout__title">
|
|
6
|
+
<h2>{{ title }}</h2>
|
|
7
|
+
<span v-if="totalItems > 0" class="cn-list-layout__count">({{ totalItems }})</span>
|
|
8
|
+
</div>
|
|
9
|
+
<div class="cn-list-layout__actions">
|
|
10
|
+
<slot name="actions" />
|
|
11
|
+
</div>
|
|
12
|
+
</div>
|
|
13
|
+
|
|
14
|
+
<!-- Filters slot -->
|
|
15
|
+
<slot name="filters" />
|
|
16
|
+
|
|
17
|
+
<!-- Loading state -->
|
|
18
|
+
<div v-if="loading" class="cn-loading-container">
|
|
19
|
+
<NcLoadingIcon :size="32" />
|
|
20
|
+
</div>
|
|
21
|
+
|
|
22
|
+
<!-- Main content (table area) -->
|
|
23
|
+
<template v-else>
|
|
24
|
+
<slot />
|
|
25
|
+
</template>
|
|
26
|
+
|
|
27
|
+
<!-- Pagination slot -->
|
|
28
|
+
<slot name="pagination" />
|
|
29
|
+
</div>
|
|
30
|
+
</template>
|
|
31
|
+
|
|
32
|
+
<script>
|
|
33
|
+
import { NcLoadingIcon } from '@nextcloud/vue'
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* CnListViewLayout — Full list page layout wrapping header, filters, table, and pagination.
|
|
37
|
+
*
|
|
38
|
+
* Provides the standard page structure used by every list view: a header with
|
|
39
|
+
* title + action buttons, a filter/search area, the main content (table), and pagination.
|
|
40
|
+
*
|
|
41
|
+
* @example
|
|
42
|
+
* <CnListViewLayout title="Clients" :total-items="clients.length" :loading="isLoading">
|
|
43
|
+
* <template #actions>
|
|
44
|
+
* <NcButton type="primary" @click="createClient">New client</NcButton>
|
|
45
|
+
* </template>
|
|
46
|
+
* <template #filters>
|
|
47
|
+
* <CnFilterBar ... />
|
|
48
|
+
* </template>
|
|
49
|
+
* <CnDataTable :columns="columns" :rows="clients" />
|
|
50
|
+
* <template #pagination>
|
|
51
|
+
* <CnPagination ... />
|
|
52
|
+
* </template>
|
|
53
|
+
* </CnListViewLayout>
|
|
54
|
+
*/
|
|
55
|
+
export default {
|
|
56
|
+
name: 'CnListViewLayout',
|
|
57
|
+
|
|
58
|
+
components: {
|
|
59
|
+
NcLoadingIcon,
|
|
60
|
+
},
|
|
61
|
+
|
|
62
|
+
props: {
|
|
63
|
+
/** Page title */
|
|
64
|
+
title: {
|
|
65
|
+
type: String,
|
|
66
|
+
required: true,
|
|
67
|
+
},
|
|
68
|
+
/** Total items count (shown next to title) */
|
|
69
|
+
totalItems: {
|
|
70
|
+
type: Number,
|
|
71
|
+
default: 0,
|
|
72
|
+
},
|
|
73
|
+
/** Whether data is loading */
|
|
74
|
+
loading: {
|
|
75
|
+
type: Boolean,
|
|
76
|
+
default: false,
|
|
77
|
+
},
|
|
78
|
+
},
|
|
79
|
+
}
|
|
80
|
+
</script>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default as CnListViewLayout } from './CnListViewLayout.vue'
|
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<NcActions
|
|
3
|
+
v-if="count > 0"
|
|
4
|
+
:menu-name="menuLabel"
|
|
5
|
+
:inline="0">
|
|
6
|
+
<template #icon>
|
|
7
|
+
<TuneVariant :size="20" />
|
|
8
|
+
</template>
|
|
9
|
+
|
|
10
|
+
<!-- Built-in: Import -->
|
|
11
|
+
<NcActionButton
|
|
12
|
+
v-if="showImport"
|
|
13
|
+
@click="$emit('mass-import')">
|
|
14
|
+
<template #icon>
|
|
15
|
+
<Import :size="20" />
|
|
16
|
+
</template>
|
|
17
|
+
{{ importLabel }}
|
|
18
|
+
</NcActionButton>
|
|
19
|
+
|
|
20
|
+
<!-- Built-in: Export -->
|
|
21
|
+
<NcActionButton
|
|
22
|
+
v-if="showExport"
|
|
23
|
+
@click="$emit('mass-export')">
|
|
24
|
+
<template #icon>
|
|
25
|
+
<Export :size="20" />
|
|
26
|
+
</template>
|
|
27
|
+
{{ exportLabel }}
|
|
28
|
+
</NcActionButton>
|
|
29
|
+
|
|
30
|
+
<!-- Built-in: Copy -->
|
|
31
|
+
<NcActionButton
|
|
32
|
+
v-if="showCopy"
|
|
33
|
+
@click="$emit('mass-copy')">
|
|
34
|
+
<template #icon>
|
|
35
|
+
<ContentCopy :size="20" />
|
|
36
|
+
</template>
|
|
37
|
+
{{ copyLabel }}
|
|
38
|
+
</NcActionButton>
|
|
39
|
+
|
|
40
|
+
<!-- Built-in: Delete -->
|
|
41
|
+
<NcActionButton
|
|
42
|
+
v-if="showDelete"
|
|
43
|
+
@click="$emit('mass-delete')">
|
|
44
|
+
<template #icon>
|
|
45
|
+
<TrashCanOutline :size="20" />
|
|
46
|
+
</template>
|
|
47
|
+
{{ deleteLabel }}
|
|
48
|
+
</NcActionButton>
|
|
49
|
+
|
|
50
|
+
<!-- Custom actions slot -->
|
|
51
|
+
<slot name="actions" :count="count" :selected-ids="selectedIds" />
|
|
52
|
+
</NcActions>
|
|
53
|
+
</template>
|
|
54
|
+
|
|
55
|
+
<script>
|
|
56
|
+
import { NcActions, NcActionButton } from '@nextcloud/vue'
|
|
57
|
+
import TuneVariant from 'vue-material-design-icons/TuneVariant.vue'
|
|
58
|
+
import ContentCopy from 'vue-material-design-icons/ContentCopy.vue'
|
|
59
|
+
import TrashCanOutline from 'vue-material-design-icons/TrashCanOutline.vue'
|
|
60
|
+
import Import from 'vue-material-design-icons/Import.vue'
|
|
61
|
+
import Export from 'vue-material-design-icons/Export.vue'
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* CnMassActionBar — Mass action dropdown button for selected items.
|
|
65
|
+
*
|
|
66
|
+
* Renders as a single "Mass Actions (N)" dropdown button with built-in
|
|
67
|
+
* Import, Export, Copy, and Delete actions plus a slot for custom actions.
|
|
68
|
+
* Place this in the header/action bar of your index page.
|
|
69
|
+
*
|
|
70
|
+
* ## Adding Custom Mass Actions
|
|
71
|
+
*
|
|
72
|
+
* Use the `#actions` scoped slot to add app-specific mass actions.
|
|
73
|
+
* Slot content should use `NcActionButton` components:
|
|
74
|
+
*
|
|
75
|
+
* ```vue
|
|
76
|
+
* <CnMassActionBar :selected-ids="selectedIds" :count="selectedIds.length">
|
|
77
|
+
* <template #actions="{ count, selectedIds }">
|
|
78
|
+
* <NcActionButton @click="migrateSelected(selectedIds)">
|
|
79
|
+
* <template #icon><SwapHorizontal :size="20" /></template>
|
|
80
|
+
* Migrate
|
|
81
|
+
* </NcActionButton>
|
|
82
|
+
* <NcActionButton @click="publishSelected(selectedIds)">
|
|
83
|
+
* <template #icon><Publish :size="20" /></template>
|
|
84
|
+
* Publish
|
|
85
|
+
* </NcActionButton>
|
|
86
|
+
* </template>
|
|
87
|
+
* </CnMassActionBar>
|
|
88
|
+
* ```
|
|
89
|
+
*
|
|
90
|
+
* @example Basic usage
|
|
91
|
+
* <CnMassActionBar
|
|
92
|
+
* :selected-ids="selectedIds"
|
|
93
|
+
* :count="selectedIds.length"
|
|
94
|
+
* @mass-copy="openCopyDialog"
|
|
95
|
+
* @mass-delete="openDeleteDialog"
|
|
96
|
+
* @mass-import="openImportDialog"
|
|
97
|
+
* @mass-export="openExportDialog" />
|
|
98
|
+
*/
|
|
99
|
+
export default {
|
|
100
|
+
name: 'CnMassActionBar',
|
|
101
|
+
|
|
102
|
+
components: {
|
|
103
|
+
NcActions,
|
|
104
|
+
NcActionButton,
|
|
105
|
+
TuneVariant,
|
|
106
|
+
ContentCopy,
|
|
107
|
+
TrashCanOutline,
|
|
108
|
+
Import,
|
|
109
|
+
Export,
|
|
110
|
+
},
|
|
111
|
+
|
|
112
|
+
props: {
|
|
113
|
+
/** Array of selected item IDs */
|
|
114
|
+
selectedIds: {
|
|
115
|
+
type: Array,
|
|
116
|
+
default: () => [],
|
|
117
|
+
},
|
|
118
|
+
/** Number of selected items */
|
|
119
|
+
count: {
|
|
120
|
+
type: Number,
|
|
121
|
+
default: 0,
|
|
122
|
+
},
|
|
123
|
+
/** Whether to show the built-in Import action */
|
|
124
|
+
showImport: {
|
|
125
|
+
type: Boolean,
|
|
126
|
+
default: true,
|
|
127
|
+
},
|
|
128
|
+
/** Whether to show the built-in Export action */
|
|
129
|
+
showExport: {
|
|
130
|
+
type: Boolean,
|
|
131
|
+
default: true,
|
|
132
|
+
},
|
|
133
|
+
/** Whether to show the built-in Copy action */
|
|
134
|
+
showCopy: {
|
|
135
|
+
type: Boolean,
|
|
136
|
+
default: true,
|
|
137
|
+
},
|
|
138
|
+
/** Whether to show the built-in Delete action */
|
|
139
|
+
showDelete: {
|
|
140
|
+
type: Boolean,
|
|
141
|
+
default: true,
|
|
142
|
+
},
|
|
143
|
+
/** Label template for the menu button. Use {count} for the count. */
|
|
144
|
+
menuLabelTemplate: {
|
|
145
|
+
type: String,
|
|
146
|
+
default: 'Mass Actions ({count})',
|
|
147
|
+
},
|
|
148
|
+
importLabel: { type: String, default: 'Import' },
|
|
149
|
+
exportLabel: { type: String, default: 'Export' },
|
|
150
|
+
copyLabel: { type: String, default: 'Copy' },
|
|
151
|
+
deleteLabel: { type: String, default: 'Delete' },
|
|
152
|
+
},
|
|
153
|
+
|
|
154
|
+
computed: {
|
|
155
|
+
menuLabel() {
|
|
156
|
+
return this.menuLabelTemplate.replace('{count}', String(this.count))
|
|
157
|
+
},
|
|
158
|
+
},
|
|
159
|
+
}
|
|
160
|
+
</script>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default as CnMassActionBar } from './CnMassActionBar.vue'
|
|
@@ -0,0 +1,320 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<NcDialog
|
|
3
|
+
:name="dialogTitle"
|
|
4
|
+
size="normal"
|
|
5
|
+
:can-close="!loading"
|
|
6
|
+
@closing="$emit('close')">
|
|
7
|
+
<!-- Review phase -->
|
|
8
|
+
<div v-if="result === null" class="cn-mass-copy__review">
|
|
9
|
+
<div class="cn-mass-copy__pattern">
|
|
10
|
+
<label for="cn-mass-copy-pattern">{{ patternLabel }}</label>
|
|
11
|
+
<NcSelect
|
|
12
|
+
input-id="cn-mass-copy-pattern"
|
|
13
|
+
:options="patternOptions"
|
|
14
|
+
:value="selectedPattern"
|
|
15
|
+
:clearable="false"
|
|
16
|
+
@input="onPatternChange" />
|
|
17
|
+
</div>
|
|
18
|
+
|
|
19
|
+
<div class="cn-mass-copy__list">
|
|
20
|
+
<div
|
|
21
|
+
v-for="item in localItems"
|
|
22
|
+
:key="item.id"
|
|
23
|
+
class="cn-mass-copy__item">
|
|
24
|
+
<div class="cn-mass-copy__item-names">
|
|
25
|
+
<span class="cn-mass-copy__item-original">{{ getItemName(item) }}</span>
|
|
26
|
+
<span class="cn-mass-copy__item-arrow">→</span>
|
|
27
|
+
<span class="cn-mass-copy__item-new">{{ getNewName(item) }}</span>
|
|
28
|
+
</div>
|
|
29
|
+
<NcButton
|
|
30
|
+
type="tertiary"
|
|
31
|
+
:aria-label="removeLabel"
|
|
32
|
+
@click="removeItem(item.id)">
|
|
33
|
+
<template #icon>
|
|
34
|
+
<Close :size="16" />
|
|
35
|
+
</template>
|
|
36
|
+
</NcButton>
|
|
37
|
+
</div>
|
|
38
|
+
</div>
|
|
39
|
+
|
|
40
|
+
<p v-if="localItems.length === 0" class="cn-mass-copy__empty">
|
|
41
|
+
{{ emptyText }}
|
|
42
|
+
</p>
|
|
43
|
+
</div>
|
|
44
|
+
|
|
45
|
+
<!-- Result phase -->
|
|
46
|
+
<div v-else class="cn-mass-copy__result">
|
|
47
|
+
<NcNoteCard v-if="result.success" type="success">
|
|
48
|
+
{{ successText }}
|
|
49
|
+
</NcNoteCard>
|
|
50
|
+
<NcNoteCard v-if="result.error" type="error">
|
|
51
|
+
{{ result.error }}
|
|
52
|
+
</NcNoteCard>
|
|
53
|
+
</div>
|
|
54
|
+
|
|
55
|
+
<template #actions>
|
|
56
|
+
<NcButton @click="$emit('close')">
|
|
57
|
+
{{ result === null ? cancelLabel : closeLabel }}
|
|
58
|
+
</NcButton>
|
|
59
|
+
<NcButton
|
|
60
|
+
v-if="result === null"
|
|
61
|
+
type="primary"
|
|
62
|
+
:disabled="loading || localItems.length === 0"
|
|
63
|
+
@click="executeCopy">
|
|
64
|
+
<template #icon>
|
|
65
|
+
<NcLoadingIcon v-if="loading" :size="20" />
|
|
66
|
+
<ContentCopy v-else :size="20" />
|
|
67
|
+
</template>
|
|
68
|
+
{{ confirmLabel }}
|
|
69
|
+
</NcButton>
|
|
70
|
+
</template>
|
|
71
|
+
</NcDialog>
|
|
72
|
+
</template>
|
|
73
|
+
|
|
74
|
+
<script>
|
|
75
|
+
import { NcDialog, NcButton, NcNoteCard, NcLoadingIcon, NcSelect } from '@nextcloud/vue'
|
|
76
|
+
import ContentCopy from 'vue-material-design-icons/ContentCopy.vue'
|
|
77
|
+
import Close from 'vue-material-design-icons/Close.vue'
|
|
78
|
+
|
|
79
|
+
/**
|
|
80
|
+
* CnMassCopyDialog — Two-phase mass copy confirmation dialog.
|
|
81
|
+
*
|
|
82
|
+
* Phase 1 (review): Shows the items to be copied with a naming pattern
|
|
83
|
+
* selector and real-time preview of new names. Phase 2 (result): Shows
|
|
84
|
+
* success or error.
|
|
85
|
+
*
|
|
86
|
+
* The dialog does NOT perform the copy itself — it emits a `confirm` event
|
|
87
|
+
* with the items and naming function. The parent performs the actual API
|
|
88
|
+
* call and calls `setResult()` via a ref.
|
|
89
|
+
*
|
|
90
|
+
* @example
|
|
91
|
+
* <CnMassCopyDialog
|
|
92
|
+
* v-if="showCopyDialog"
|
|
93
|
+
* ref="copyDialog"
|
|
94
|
+
* :items="selectedObjects"
|
|
95
|
+
* :name-field="'title'"
|
|
96
|
+
* @confirm="onCopyConfirm"
|
|
97
|
+
* @close="showCopyDialog = false" />
|
|
98
|
+
*
|
|
99
|
+
* // In methods:
|
|
100
|
+
* async onCopyConfirm({ ids, getName }) {
|
|
101
|
+
* try {
|
|
102
|
+
* for (const item of this.selectedObjects) {
|
|
103
|
+
* await store.copyObject(item.id, { title: getName(item) })
|
|
104
|
+
* }
|
|
105
|
+
* this.$refs.copyDialog.setResult({ success: true })
|
|
106
|
+
* } catch (e) {
|
|
107
|
+
* this.$refs.copyDialog.setResult({ error: e.message })
|
|
108
|
+
* }
|
|
109
|
+
* }
|
|
110
|
+
*/
|
|
111
|
+
export default {
|
|
112
|
+
name: 'CnMassCopyDialog',
|
|
113
|
+
|
|
114
|
+
components: {
|
|
115
|
+
NcDialog,
|
|
116
|
+
NcButton,
|
|
117
|
+
NcNoteCard,
|
|
118
|
+
NcLoadingIcon,
|
|
119
|
+
NcSelect,
|
|
120
|
+
ContentCopy,
|
|
121
|
+
Close,
|
|
122
|
+
},
|
|
123
|
+
|
|
124
|
+
props: {
|
|
125
|
+
/** Items to copy. Each must have an `id` property. */
|
|
126
|
+
items: {
|
|
127
|
+
type: Array,
|
|
128
|
+
required: true,
|
|
129
|
+
},
|
|
130
|
+
/** Property name used for display (e.g., 'title', 'name') */
|
|
131
|
+
nameField: {
|
|
132
|
+
type: String,
|
|
133
|
+
default: 'title',
|
|
134
|
+
},
|
|
135
|
+
/** Dialog title */
|
|
136
|
+
dialogTitle: {
|
|
137
|
+
type: String,
|
|
138
|
+
default: 'Copy Items',
|
|
139
|
+
},
|
|
140
|
+
/** Label for the naming pattern selector */
|
|
141
|
+
patternLabel: {
|
|
142
|
+
type: String,
|
|
143
|
+
default: 'Naming pattern',
|
|
144
|
+
},
|
|
145
|
+
/** Text when all items removed from list */
|
|
146
|
+
emptyText: {
|
|
147
|
+
type: String,
|
|
148
|
+
default: 'No items selected for copying.',
|
|
149
|
+
},
|
|
150
|
+
/** Success message */
|
|
151
|
+
successText: {
|
|
152
|
+
type: String,
|
|
153
|
+
default: 'Items successfully copied.',
|
|
154
|
+
},
|
|
155
|
+
cancelLabel: { type: String, default: 'Cancel' },
|
|
156
|
+
closeLabel: { type: String, default: 'Close' },
|
|
157
|
+
confirmLabel: { type: String, default: 'Copy' },
|
|
158
|
+
removeLabel: { type: String, default: 'Remove from list' },
|
|
159
|
+
},
|
|
160
|
+
|
|
161
|
+
data() {
|
|
162
|
+
return {
|
|
163
|
+
localItems: [...this.items],
|
|
164
|
+
loading: false,
|
|
165
|
+
result: null,
|
|
166
|
+
closeTimeout: null,
|
|
167
|
+
selectedPattern: { id: 'copy-of', label: 'Copy of {name}' },
|
|
168
|
+
}
|
|
169
|
+
},
|
|
170
|
+
|
|
171
|
+
computed: {
|
|
172
|
+
patternOptions() {
|
|
173
|
+
return [
|
|
174
|
+
{ id: 'copy-of', label: 'Copy of {name}' },
|
|
175
|
+
{ id: 'name-copy', label: '{name} - Copy' },
|
|
176
|
+
{ id: 'name-parens', label: '{name} (Copy)' },
|
|
177
|
+
]
|
|
178
|
+
},
|
|
179
|
+
},
|
|
180
|
+
|
|
181
|
+
watch: {
|
|
182
|
+
items(val) {
|
|
183
|
+
this.localItems = [...val]
|
|
184
|
+
},
|
|
185
|
+
},
|
|
186
|
+
|
|
187
|
+
beforeDestroy() {
|
|
188
|
+
if (this.closeTimeout) clearTimeout(this.closeTimeout)
|
|
189
|
+
},
|
|
190
|
+
|
|
191
|
+
methods: {
|
|
192
|
+
getItemName(item) {
|
|
193
|
+
return item[this.nameField] || item.name || item.title || item.id
|
|
194
|
+
},
|
|
195
|
+
|
|
196
|
+
getNewName(item) {
|
|
197
|
+
const name = this.getItemName(item)
|
|
198
|
+
return this.applyPattern(name, this.selectedPattern.id)
|
|
199
|
+
},
|
|
200
|
+
|
|
201
|
+
applyPattern(name, patternId) {
|
|
202
|
+
switch (patternId) {
|
|
203
|
+
case 'copy-of':
|
|
204
|
+
return `Copy of ${name}`
|
|
205
|
+
case 'name-copy':
|
|
206
|
+
return `${name} - Copy`
|
|
207
|
+
case 'name-parens':
|
|
208
|
+
return `${name} (Copy)`
|
|
209
|
+
default:
|
|
210
|
+
return `Copy of ${name}`
|
|
211
|
+
}
|
|
212
|
+
},
|
|
213
|
+
|
|
214
|
+
onPatternChange(option) {
|
|
215
|
+
this.selectedPattern = option
|
|
216
|
+
},
|
|
217
|
+
|
|
218
|
+
removeItem(id) {
|
|
219
|
+
this.localItems = this.localItems.filter((i) => i.id !== id)
|
|
220
|
+
},
|
|
221
|
+
|
|
222
|
+
executeCopy() {
|
|
223
|
+
this.loading = true
|
|
224
|
+
const ids = this.localItems.map((i) => i.id)
|
|
225
|
+
const patternId = this.selectedPattern.id
|
|
226
|
+
/**
|
|
227
|
+
* @event confirm Emitted when the user confirms copying.
|
|
228
|
+
* Payload: { ids, getName } where getName(item) returns the new name.
|
|
229
|
+
*/
|
|
230
|
+
this.$emit('confirm', {
|
|
231
|
+
ids,
|
|
232
|
+
getName: (item) => {
|
|
233
|
+
const name = this.getItemName(item)
|
|
234
|
+
return this.applyPattern(name, patternId)
|
|
235
|
+
},
|
|
236
|
+
})
|
|
237
|
+
},
|
|
238
|
+
|
|
239
|
+
/**
|
|
240
|
+
* Set the result of the copy operation. Call this from the parent
|
|
241
|
+
* after the API call completes.
|
|
242
|
+
*
|
|
243
|
+
* @param {{ success?: boolean, error?: string }} resultData
|
|
244
|
+
* @public
|
|
245
|
+
*/
|
|
246
|
+
setResult(resultData) {
|
|
247
|
+
this.loading = false
|
|
248
|
+
this.result = resultData
|
|
249
|
+
if (resultData.success) {
|
|
250
|
+
this.closeTimeout = setTimeout(() => {
|
|
251
|
+
this.$emit('close')
|
|
252
|
+
}, 2000)
|
|
253
|
+
}
|
|
254
|
+
},
|
|
255
|
+
},
|
|
256
|
+
}
|
|
257
|
+
</script>
|
|
258
|
+
|
|
259
|
+
<style scoped>
|
|
260
|
+
.cn-mass-copy__pattern {
|
|
261
|
+
margin-bottom: 16px;
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
.cn-mass-copy__pattern label {
|
|
265
|
+
display: block;
|
|
266
|
+
font-weight: 600;
|
|
267
|
+
margin-bottom: 4px;
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
.cn-mass-copy__list {
|
|
271
|
+
max-height: 300px;
|
|
272
|
+
overflow-y: auto;
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
.cn-mass-copy__item {
|
|
276
|
+
display: flex;
|
|
277
|
+
align-items: center;
|
|
278
|
+
justify-content: space-between;
|
|
279
|
+
padding: 8px 12px;
|
|
280
|
+
border-bottom: 1px solid var(--color-border);
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
.cn-mass-copy__item:last-child {
|
|
284
|
+
border-bottom: none;
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
.cn-mass-copy__item-names {
|
|
288
|
+
display: flex;
|
|
289
|
+
align-items: center;
|
|
290
|
+
gap: 8px;
|
|
291
|
+
overflow: hidden;
|
|
292
|
+
flex: 1;
|
|
293
|
+
}
|
|
294
|
+
|
|
295
|
+
.cn-mass-copy__item-original {
|
|
296
|
+
color: var(--color-text-maxcontrast);
|
|
297
|
+
overflow: hidden;
|
|
298
|
+
text-overflow: ellipsis;
|
|
299
|
+
white-space: nowrap;
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
.cn-mass-copy__item-arrow {
|
|
303
|
+
flex-shrink: 0;
|
|
304
|
+
color: var(--color-text-maxcontrast);
|
|
305
|
+
}
|
|
306
|
+
|
|
307
|
+
.cn-mass-copy__item-new {
|
|
308
|
+
font-weight: 500;
|
|
309
|
+
overflow: hidden;
|
|
310
|
+
text-overflow: ellipsis;
|
|
311
|
+
white-space: nowrap;
|
|
312
|
+
}
|
|
313
|
+
|
|
314
|
+
.cn-mass-copy__empty {
|
|
315
|
+
text-align: center;
|
|
316
|
+
color: var(--color-text-maxcontrast);
|
|
317
|
+
font-style: italic;
|
|
318
|
+
padding: 20px;
|
|
319
|
+
}
|
|
320
|
+
</style>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default as CnMassCopyDialog } from './CnMassCopyDialog.vue'
|