@conduction/nextcloud-vue 0.1.0-beta.3 → 0.1.0-beta.5
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/README.md +226 -226
- package/dist/nextcloud-vue.cjs +67614 -0
- package/dist/nextcloud-vue.cjs.js +58386 -6112
- package/dist/nextcloud-vue.cjs.js.map +1 -1
- package/dist/nextcloud-vue.cjs.map +1 -0
- package/dist/nextcloud-vue.css +1819 -285
- package/dist/nextcloud-vue.esm.js +58342 -6088
- package/dist/nextcloud-vue.esm.js.map +1 -1
- package/package.json +82 -62
- package/src/components/CnActionsBar/CnActionsBar.vue +17 -7
- package/src/components/CnActionsBar/index.js +1 -1
- package/src/components/CnAdvancedFormDialog/CnAdvancedFormDialog.vue +579 -0
- package/src/components/CnAdvancedFormDialog/CnDataTab.vue +217 -0
- package/src/components/CnAdvancedFormDialog/CnMetadataTab.vue +121 -0
- package/src/components/CnAdvancedFormDialog/CnPropertiesTab.vue +418 -0
- package/src/components/CnAdvancedFormDialog/CnPropertyValueCell.vue +247 -0
- package/src/components/CnAdvancedFormDialog/index.js +1 -0
- package/src/components/CnCardGrid/CnCardGrid.vue +1 -1
- package/src/components/CnCardGrid/index.js +1 -1
- package/src/components/CnCellRenderer/index.js +1 -1
- package/src/components/CnChartWidget/CnChartWidget.vue +320 -0
- package/src/components/CnChartWidget/index.js +1 -0
- package/src/components/CnConfigurationCard/index.js +1 -1
- package/src/components/CnCopyDialog/CnCopyDialog.vue +250 -250
- package/src/components/CnDashboardGrid/CnDashboardGrid.vue +225 -0
- package/src/components/CnDashboardGrid/index.js +1 -0
- package/src/components/CnDashboardPage/CnDashboardPage.vue +390 -0
- package/src/components/CnDashboardPage/index.js +1 -0
- package/src/components/CnDataTable/CnDataTable.vue +1 -1
- package/src/components/CnDataTable/index.js +1 -1
- package/src/components/CnDeleteDialog/CnDeleteDialog.vue +170 -170
- package/src/components/CnDetailCard/CnDetailCard.vue +214 -0
- package/src/components/CnDetailCard/index.js +1 -0
- package/src/components/CnDetailPage/CnDetailPage.vue +285 -0
- package/src/components/CnDetailPage/index.js +1 -0
- package/src/components/CnFacetSidebar/CnFacetSidebar.vue +9 -1
- package/src/components/CnFacetSidebar/index.js +1 -1
- package/src/components/CnFilterBar/index.js +1 -1
- package/src/components/CnFormDialog/CnFormDialog.vue +302 -11
- package/src/components/CnIcon/index.js +1 -1
- package/src/components/CnIndexPage/CnIndexPage.vue +71 -3
- package/src/components/CnIndexPage/index.js +1 -1
- package/src/components/CnIndexSidebar/CnIndexSidebar.vue +121 -102
- package/src/components/CnIndexSidebar/index.js +1 -1
- package/src/components/CnItemCard/CnItemCard.vue +132 -0
- package/src/components/CnItemCard/index.js +1 -0
- package/src/components/CnKpiGrid/index.js +1 -1
- package/src/components/CnMassActionBar/index.js +1 -1
- package/src/components/CnMassCopyDialog/index.js +1 -1
- package/src/components/CnMassDeleteDialog/index.js +1 -1
- package/src/components/CnMassExportDialog/index.js +1 -1
- package/src/components/CnMassImportDialog/index.js +1 -1
- package/src/components/CnNoteCard/CnNoteCard.vue +149 -0
- package/src/components/CnNoteCard/index.js +1 -0
- package/src/components/CnNotesCard/CnNotesCard.vue +413 -0
- package/src/components/CnNotesCard/index.js +1 -0
- package/src/components/CnObjectCard/CnObjectCard.vue +1 -1
- package/src/components/CnObjectCard/index.js +1 -1
- package/src/components/CnObjectSidebar/CnObjectSidebar.vue +876 -0
- package/src/components/CnObjectSidebar/index.js +1 -0
- package/src/components/CnPageHeader/index.js +1 -1
- package/src/components/CnPagination/index.js +1 -1
- package/src/components/CnRegisterMapping/CnRegisterMapping.vue +792 -792
- package/src/components/CnRowActions/CnRowActions.vue +25 -3
- package/src/components/CnRowActions/index.js +1 -1
- package/src/components/CnSchemaFormDialog/CnSchemaConfigurationTab.vue +226 -0
- package/src/components/CnSchemaFormDialog/CnSchemaFormDialog.vue +787 -0
- package/src/components/CnSchemaFormDialog/CnSchemaPropertiesTab.vue +305 -0
- package/src/components/CnSchemaFormDialog/CnSchemaPropertyActions.vue +1398 -0
- package/src/components/CnSchemaFormDialog/CnSchemaSecurityTab.vue +236 -0
- package/src/components/CnSchemaFormDialog/index.js +1 -0
- package/src/components/CnSettingsCard/index.js +1 -1
- package/src/components/CnSettingsSection/index.js +1 -1
- package/src/components/CnStatsBlock/CnStatsBlock.vue +62 -8
- package/src/components/CnStatsBlock/index.js +1 -1
- package/src/components/CnStatusBadge/index.js +1 -1
- package/src/components/CnTabbedFormDialog/CnTabbedFormDialog.vue +540 -0
- package/src/components/CnTabbedFormDialog/index.js +1 -0
- package/src/components/CnTasksCard/CnTasksCard.vue +373 -0
- package/src/components/CnTasksCard/index.js +1 -0
- package/src/components/CnTileWidget/CnTileWidget.vue +159 -0
- package/src/components/CnTileWidget/index.js +1 -0
- package/src/components/CnTimelineStages/CnTimelineStages.vue +292 -0
- package/src/components/CnTimelineStages/index.js +1 -0
- package/src/components/CnUserActionMenu/CnUserActionMenu.vue +435 -0
- package/src/components/CnUserActionMenu/index.js +1 -0
- package/src/components/CnVersionInfoCard/index.js +1 -1
- package/src/components/CnWidgetRenderer/CnWidgetRenderer.vue +180 -0
- package/src/components/CnWidgetRenderer/index.js +1 -0
- package/src/components/CnWidgetWrapper/CnWidgetWrapper.vue +211 -0
- package/src/components/CnWidgetWrapper/index.js +1 -0
- package/src/components/index.js +43 -29
- package/src/composables/index.js +4 -3
- package/src/composables/useDashboardView.js +240 -0
- package/src/composables/useDetailView.js +289 -132
- package/src/composables/useListView.js +363 -362
- package/src/composables/useSubResource.js +142 -142
- package/src/constants/metadata.js +30 -30
- package/src/css/CnSchemaFormDialog.css +546 -0
- package/src/css/__sample_nextcloud_tokens.css +110 -0
- package/src/css/actions-bar.css +48 -48
- package/src/css/badge.css +51 -51
- package/src/css/card.css +128 -128
- package/src/css/dashboard.css +70 -0
- package/src/css/detail-page.css +168 -0
- package/src/css/detail.css +68 -68
- package/src/css/index-page.css +44 -32
- package/src/css/index-sidebar.css +193 -187
- package/src/css/index.css +16 -12
- package/src/css/layout.css +90 -90
- package/src/css/page-header.css +33 -33
- package/src/css/pagination.css +72 -72
- package/src/css/table.css +142 -142
- package/src/css/timeline-stages.css +218 -0
- package/src/css/utilities.css +46 -46
- package/src/index.js +72 -53
- package/src/store/createSubResourcePlugin.js +135 -135
- package/src/store/index.js +3 -3
- package/src/store/plugins/auditTrails.js +17 -17
- package/src/store/plugins/files.js +250 -186
- package/src/store/plugins/index.js +7 -5
- package/src/store/plugins/lifecycle.js +180 -180
- package/src/store/plugins/relations.js +68 -68
- package/src/store/plugins/search.js +372 -0
- package/src/store/plugins/selection.js +104 -0
- package/src/store/useObjectStore.js +829 -686
- package/src/types/auditTrail.d.ts +32 -32
- package/src/types/file.d.ts +23 -23
- package/src/types/index.d.ts +35 -35
- package/src/types/notification.d.ts +36 -36
- package/src/types/object.d.ts +40 -40
- package/src/types/organisation.d.ts +41 -41
- package/src/types/register.d.ts +25 -25
- package/src/types/schema.d.ts +39 -39
- package/src/types/shared.d.ts +79 -79
- package/src/types/source.d.ts +14 -14
- package/src/types/task.d.ts +31 -31
- package/src/utils/errors.js +96 -96
- package/src/utils/headers.js +68 -50
- package/src/utils/id.js +13 -0
- package/src/utils/index.js +3 -3
- package/src/utils/schema.js +422 -419
|
@@ -1,250 +1,250 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<NcDialog
|
|
3
|
-
:name="dialogTitle"
|
|
4
|
-
size="small"
|
|
5
|
-
:can-close="!loading"
|
|
6
|
-
@closing="$emit('close')">
|
|
7
|
-
<!-- Result phase -->
|
|
8
|
-
<div v-if="result !== null" class="cn-copy__result">
|
|
9
|
-
<NcNoteCard v-if="result.success" type="success">
|
|
10
|
-
{{ successText }}
|
|
11
|
-
</NcNoteCard>
|
|
12
|
-
<NcNoteCard v-if="result.error" type="error">
|
|
13
|
-
{{ result.error }}
|
|
14
|
-
</NcNoteCard>
|
|
15
|
-
</div>
|
|
16
|
-
|
|
17
|
-
<!-- Form phase -->
|
|
18
|
-
<div v-else class="cn-copy__form">
|
|
19
|
-
<div class="cn-copy__pattern">
|
|
20
|
-
<label for="cn-copy-pattern">{{ patternLabel }}</label>
|
|
21
|
-
<NcSelect
|
|
22
|
-
input-id="cn-copy-pattern"
|
|
23
|
-
:options="patternOptions"
|
|
24
|
-
:value="selectedPattern"
|
|
25
|
-
:clearable="false"
|
|
26
|
-
@input="selectedPattern = $event" />
|
|
27
|
-
</div>
|
|
28
|
-
|
|
29
|
-
<div class="cn-copy__preview">
|
|
30
|
-
<div class="cn-copy__preview-row">
|
|
31
|
-
<span class="cn-copy__preview-original">{{ itemName }}</span>
|
|
32
|
-
<span class="cn-copy__preview-arrow">→</span>
|
|
33
|
-
<span class="cn-copy__preview-new">{{ newName }}</span>
|
|
34
|
-
</div>
|
|
35
|
-
</div>
|
|
36
|
-
</div>
|
|
37
|
-
|
|
38
|
-
<template #actions>
|
|
39
|
-
<NcButton @click="$emit('close')">
|
|
40
|
-
{{ result !== null ? closeLabel : cancelLabel }}
|
|
41
|
-
</NcButton>
|
|
42
|
-
<NcButton
|
|
43
|
-
v-if="result === null"
|
|
44
|
-
type="primary"
|
|
45
|
-
:disabled="loading"
|
|
46
|
-
@click="executeCopy">
|
|
47
|
-
<template #icon>
|
|
48
|
-
<NcLoadingIcon v-if="loading" :size="20" />
|
|
49
|
-
<ContentCopy v-else :size="20" />
|
|
50
|
-
</template>
|
|
51
|
-
{{ confirmLabel }}
|
|
52
|
-
</NcButton>
|
|
53
|
-
</template>
|
|
54
|
-
</NcDialog>
|
|
55
|
-
</template>
|
|
56
|
-
|
|
57
|
-
<script>
|
|
58
|
-
import { NcDialog, NcButton, NcNoteCard, NcLoadingIcon, NcSelect } from '@nextcloud/vue'
|
|
59
|
-
import ContentCopy from 'vue-material-design-icons/ContentCopy.vue'
|
|
60
|
-
|
|
61
|
-
/**
|
|
62
|
-
* CnCopyDialog — Single-item copy confirmation dialog with naming pattern.
|
|
63
|
-
*
|
|
64
|
-
* Two-phase UI: form (with name preview) then result. The dialog does NOT
|
|
65
|
-
* perform the copy itself — it emits a `confirm` event with the item ID
|
|
66
|
-
* and the new name. The parent performs the actual API call and calls
|
|
67
|
-
* `setResult()` via a ref.
|
|
68
|
-
*
|
|
69
|
-
* @example
|
|
70
|
-
* <CnCopyDialog
|
|
71
|
-
* v-if="showCopyDialog"
|
|
72
|
-
* ref="copyDialog"
|
|
73
|
-
* :item="itemToCopy"
|
|
74
|
-
* @confirm="onCopyConfirm"
|
|
75
|
-
* @close="showCopyDialog = false" />
|
|
76
|
-
*
|
|
77
|
-
* // In methods:
|
|
78
|
-
* async onCopyConfirm({ id, newName }) {
|
|
79
|
-
* try {
|
|
80
|
-
* await store.copyItem(id, { title: newName })
|
|
81
|
-
* this.$refs.copyDialog.setResult({ success: true })
|
|
82
|
-
* } catch (e) {
|
|
83
|
-
* this.$refs.copyDialog.setResult({ error: e.message })
|
|
84
|
-
* }
|
|
85
|
-
* }
|
|
86
|
-
*/
|
|
87
|
-
export default {
|
|
88
|
-
name: 'CnCopyDialog',
|
|
89
|
-
|
|
90
|
-
components: {
|
|
91
|
-
NcDialog,
|
|
92
|
-
NcButton,
|
|
93
|
-
NcNoteCard,
|
|
94
|
-
NcLoadingIcon,
|
|
95
|
-
NcSelect,
|
|
96
|
-
ContentCopy,
|
|
97
|
-
},
|
|
98
|
-
|
|
99
|
-
props: {
|
|
100
|
-
/** The item to copy. Must have an `id` property. */
|
|
101
|
-
item: {
|
|
102
|
-
type: Object,
|
|
103
|
-
required: true,
|
|
104
|
-
},
|
|
105
|
-
/** Property name used for display (e.g., 'title', 'name') */
|
|
106
|
-
nameField: {
|
|
107
|
-
type: String,
|
|
108
|
-
default: 'title',
|
|
109
|
-
},
|
|
110
|
-
/** Dialog title */
|
|
111
|
-
dialogTitle: {
|
|
112
|
-
type: String,
|
|
113
|
-
default: 'Copy Item',
|
|
114
|
-
},
|
|
115
|
-
/** Label for the naming pattern selector */
|
|
116
|
-
patternLabel: {
|
|
117
|
-
type: String,
|
|
118
|
-
default: 'Naming pattern',
|
|
119
|
-
},
|
|
120
|
-
/** Success message */
|
|
121
|
-
successText: {
|
|
122
|
-
type: String,
|
|
123
|
-
default: 'Item successfully copied.',
|
|
124
|
-
},
|
|
125
|
-
cancelLabel: { type: String, default: 'Cancel' },
|
|
126
|
-
closeLabel: { type: String, default: 'Close' },
|
|
127
|
-
confirmLabel: { type: String, default: 'Copy' },
|
|
128
|
-
},
|
|
129
|
-
|
|
130
|
-
data() {
|
|
131
|
-
return {
|
|
132
|
-
loading: false,
|
|
133
|
-
result: null,
|
|
134
|
-
closeTimeout: null,
|
|
135
|
-
selectedPattern: { id: 'copy-of', label: 'Copy of {name}' },
|
|
136
|
-
}
|
|
137
|
-
},
|
|
138
|
-
|
|
139
|
-
computed: {
|
|
140
|
-
itemName() {
|
|
141
|
-
return this.item[this.nameField] || this.item.name || this.item.title || this.item.id
|
|
142
|
-
},
|
|
143
|
-
|
|
144
|
-
patternOptions() {
|
|
145
|
-
return [
|
|
146
|
-
{ id: 'copy-of', label: 'Copy of {name}' },
|
|
147
|
-
{ id: 'name-copy', label: '{name} - Copy' },
|
|
148
|
-
{ id: 'name-parens', label: '{name} (Copy)' },
|
|
149
|
-
]
|
|
150
|
-
},
|
|
151
|
-
|
|
152
|
-
newName() {
|
|
153
|
-
return this.applyPattern(this.itemName, this.selectedPattern.id)
|
|
154
|
-
},
|
|
155
|
-
},
|
|
156
|
-
|
|
157
|
-
beforeDestroy() {
|
|
158
|
-
if (this.closeTimeout) clearTimeout(this.closeTimeout)
|
|
159
|
-
},
|
|
160
|
-
|
|
161
|
-
/**
|
|
162
|
-
* @event confirm Emitted when the user confirms copying. Payload: `{ id, newName }`.
|
|
163
|
-
* @event close Emitted when the dialog should be closed (cancel, close button, or auto-close after success).
|
|
164
|
-
*/
|
|
165
|
-
|
|
166
|
-
methods: {
|
|
167
|
-
applyPattern(name, patternId) {
|
|
168
|
-
switch (patternId) {
|
|
169
|
-
case 'copy-of':
|
|
170
|
-
return `Copy of ${name}`
|
|
171
|
-
case 'name-copy':
|
|
172
|
-
return `${name} - Copy`
|
|
173
|
-
case 'name-parens':
|
|
174
|
-
return `${name} (Copy)`
|
|
175
|
-
default:
|
|
176
|
-
return `Copy of ${name}`
|
|
177
|
-
}
|
|
178
|
-
},
|
|
179
|
-
|
|
180
|
-
executeCopy() {
|
|
181
|
-
this.loading = true
|
|
182
|
-
this.$emit('confirm', {
|
|
183
|
-
id: this.item.id,
|
|
184
|
-
newName: this.newName,
|
|
185
|
-
})
|
|
186
|
-
},
|
|
187
|
-
|
|
188
|
-
/**
|
|
189
|
-
* Set the result of the copy operation. Call this from the parent
|
|
190
|
-
* after the API call completes.
|
|
191
|
-
*
|
|
192
|
-
* @param {{ success?: boolean, error?: string }} resultData
|
|
193
|
-
* @public
|
|
194
|
-
*/
|
|
195
|
-
setResult(resultData) {
|
|
196
|
-
this.loading = false
|
|
197
|
-
this.result = resultData
|
|
198
|
-
if (resultData.success) {
|
|
199
|
-
this.closeTimeout = setTimeout(() => {
|
|
200
|
-
this.$emit('close')
|
|
201
|
-
}, 2000)
|
|
202
|
-
}
|
|
203
|
-
},
|
|
204
|
-
},
|
|
205
|
-
}
|
|
206
|
-
</script>
|
|
207
|
-
|
|
208
|
-
<style scoped>
|
|
209
|
-
.cn-copy__pattern {
|
|
210
|
-
margin-bottom: 16px;
|
|
211
|
-
}
|
|
212
|
-
|
|
213
|
-
.cn-copy__pattern label {
|
|
214
|
-
display: block;
|
|
215
|
-
font-weight: 600;
|
|
216
|
-
margin-bottom: 4px;
|
|
217
|
-
}
|
|
218
|
-
|
|
219
|
-
.cn-copy__preview {
|
|
220
|
-
margin-top: 12px;
|
|
221
|
-
}
|
|
222
|
-
|
|
223
|
-
.cn-copy__preview-row {
|
|
224
|
-
display: flex;
|
|
225
|
-
align-items: center;
|
|
226
|
-
gap: 8px;
|
|
227
|
-
padding: 8px 12px;
|
|
228
|
-
background-color: var(--color-background-hover);
|
|
229
|
-
border-radius: var(--border-radius);
|
|
230
|
-
}
|
|
231
|
-
|
|
232
|
-
.cn-copy__preview-original {
|
|
233
|
-
color: var(--color-text-maxcontrast);
|
|
234
|
-
overflow: hidden;
|
|
235
|
-
text-overflow: ellipsis;
|
|
236
|
-
white-space: nowrap;
|
|
237
|
-
}
|
|
238
|
-
|
|
239
|
-
.cn-copy__preview-arrow {
|
|
240
|
-
flex-shrink: 0;
|
|
241
|
-
color: var(--color-text-maxcontrast);
|
|
242
|
-
}
|
|
243
|
-
|
|
244
|
-
.cn-copy__preview-new {
|
|
245
|
-
font-weight: 500;
|
|
246
|
-
overflow: hidden;
|
|
247
|
-
text-overflow: ellipsis;
|
|
248
|
-
white-space: nowrap;
|
|
249
|
-
}
|
|
250
|
-
</style>
|
|
1
|
+
<template>
|
|
2
|
+
<NcDialog
|
|
3
|
+
:name="dialogTitle"
|
|
4
|
+
size="small"
|
|
5
|
+
:can-close="!loading"
|
|
6
|
+
@closing="$emit('close')">
|
|
7
|
+
<!-- Result phase -->
|
|
8
|
+
<div v-if="result !== null" class="cn-copy__result">
|
|
9
|
+
<NcNoteCard v-if="result.success" type="success">
|
|
10
|
+
{{ successText }}
|
|
11
|
+
</NcNoteCard>
|
|
12
|
+
<NcNoteCard v-if="result.error" type="error">
|
|
13
|
+
{{ result.error }}
|
|
14
|
+
</NcNoteCard>
|
|
15
|
+
</div>
|
|
16
|
+
|
|
17
|
+
<!-- Form phase -->
|
|
18
|
+
<div v-else class="cn-copy__form">
|
|
19
|
+
<div class="cn-copy__pattern">
|
|
20
|
+
<label for="cn-copy-pattern">{{ patternLabel }}</label>
|
|
21
|
+
<NcSelect
|
|
22
|
+
input-id="cn-copy-pattern"
|
|
23
|
+
:options="patternOptions"
|
|
24
|
+
:value="selectedPattern"
|
|
25
|
+
:clearable="false"
|
|
26
|
+
@input="selectedPattern = $event" />
|
|
27
|
+
</div>
|
|
28
|
+
|
|
29
|
+
<div class="cn-copy__preview">
|
|
30
|
+
<div class="cn-copy__preview-row">
|
|
31
|
+
<span class="cn-copy__preview-original">{{ itemName }}</span>
|
|
32
|
+
<span class="cn-copy__preview-arrow">→</span>
|
|
33
|
+
<span class="cn-copy__preview-new">{{ newName }}</span>
|
|
34
|
+
</div>
|
|
35
|
+
</div>
|
|
36
|
+
</div>
|
|
37
|
+
|
|
38
|
+
<template #actions>
|
|
39
|
+
<NcButton @click="$emit('close')">
|
|
40
|
+
{{ result !== null ? closeLabel : cancelLabel }}
|
|
41
|
+
</NcButton>
|
|
42
|
+
<NcButton
|
|
43
|
+
v-if="result === null"
|
|
44
|
+
type="primary"
|
|
45
|
+
:disabled="loading"
|
|
46
|
+
@click="executeCopy">
|
|
47
|
+
<template #icon>
|
|
48
|
+
<NcLoadingIcon v-if="loading" :size="20" />
|
|
49
|
+
<ContentCopy v-else :size="20" />
|
|
50
|
+
</template>
|
|
51
|
+
{{ confirmLabel }}
|
|
52
|
+
</NcButton>
|
|
53
|
+
</template>
|
|
54
|
+
</NcDialog>
|
|
55
|
+
</template>
|
|
56
|
+
|
|
57
|
+
<script>
|
|
58
|
+
import { NcDialog, NcButton, NcNoteCard, NcLoadingIcon, NcSelect } from '@nextcloud/vue'
|
|
59
|
+
import ContentCopy from 'vue-material-design-icons/ContentCopy.vue'
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* CnCopyDialog — Single-item copy confirmation dialog with naming pattern.
|
|
63
|
+
*
|
|
64
|
+
* Two-phase UI: form (with name preview) then result. The dialog does NOT
|
|
65
|
+
* perform the copy itself — it emits a `confirm` event with the item ID
|
|
66
|
+
* and the new name. The parent performs the actual API call and calls
|
|
67
|
+
* `setResult()` via a ref.
|
|
68
|
+
*
|
|
69
|
+
* @example
|
|
70
|
+
* <CnCopyDialog
|
|
71
|
+
* v-if="showCopyDialog"
|
|
72
|
+
* ref="copyDialog"
|
|
73
|
+
* :item="itemToCopy"
|
|
74
|
+
* @confirm="onCopyConfirm"
|
|
75
|
+
* @close="showCopyDialog = false" />
|
|
76
|
+
*
|
|
77
|
+
* // In methods:
|
|
78
|
+
* async onCopyConfirm({ id, newName }) {
|
|
79
|
+
* try {
|
|
80
|
+
* await store.copyItem(id, { title: newName })
|
|
81
|
+
* this.$refs.copyDialog.setResult({ success: true })
|
|
82
|
+
* } catch (e) {
|
|
83
|
+
* this.$refs.copyDialog.setResult({ error: e.message })
|
|
84
|
+
* }
|
|
85
|
+
* }
|
|
86
|
+
*/
|
|
87
|
+
export default {
|
|
88
|
+
name: 'CnCopyDialog',
|
|
89
|
+
|
|
90
|
+
components: {
|
|
91
|
+
NcDialog,
|
|
92
|
+
NcButton,
|
|
93
|
+
NcNoteCard,
|
|
94
|
+
NcLoadingIcon,
|
|
95
|
+
NcSelect,
|
|
96
|
+
ContentCopy,
|
|
97
|
+
},
|
|
98
|
+
|
|
99
|
+
props: {
|
|
100
|
+
/** The item to copy. Must have an `id` property. */
|
|
101
|
+
item: {
|
|
102
|
+
type: Object,
|
|
103
|
+
required: true,
|
|
104
|
+
},
|
|
105
|
+
/** Property name used for display (e.g., 'title', 'name') */
|
|
106
|
+
nameField: {
|
|
107
|
+
type: String,
|
|
108
|
+
default: 'title',
|
|
109
|
+
},
|
|
110
|
+
/** Dialog title */
|
|
111
|
+
dialogTitle: {
|
|
112
|
+
type: String,
|
|
113
|
+
default: 'Copy Item',
|
|
114
|
+
},
|
|
115
|
+
/** Label for the naming pattern selector */
|
|
116
|
+
patternLabel: {
|
|
117
|
+
type: String,
|
|
118
|
+
default: 'Naming pattern',
|
|
119
|
+
},
|
|
120
|
+
/** Success message */
|
|
121
|
+
successText: {
|
|
122
|
+
type: String,
|
|
123
|
+
default: 'Item successfully copied.',
|
|
124
|
+
},
|
|
125
|
+
cancelLabel: { type: String, default: 'Cancel' },
|
|
126
|
+
closeLabel: { type: String, default: 'Close' },
|
|
127
|
+
confirmLabel: { type: String, default: 'Copy' },
|
|
128
|
+
},
|
|
129
|
+
|
|
130
|
+
data() {
|
|
131
|
+
return {
|
|
132
|
+
loading: false,
|
|
133
|
+
result: null,
|
|
134
|
+
closeTimeout: null,
|
|
135
|
+
selectedPattern: { id: 'copy-of', label: 'Copy of {name}' },
|
|
136
|
+
}
|
|
137
|
+
},
|
|
138
|
+
|
|
139
|
+
computed: {
|
|
140
|
+
itemName() {
|
|
141
|
+
return this.item[this.nameField] || this.item.name || this.item.title || this.item.id
|
|
142
|
+
},
|
|
143
|
+
|
|
144
|
+
patternOptions() {
|
|
145
|
+
return [
|
|
146
|
+
{ id: 'copy-of', label: 'Copy of {name}' },
|
|
147
|
+
{ id: 'name-copy', label: '{name} - Copy' },
|
|
148
|
+
{ id: 'name-parens', label: '{name} (Copy)' },
|
|
149
|
+
]
|
|
150
|
+
},
|
|
151
|
+
|
|
152
|
+
newName() {
|
|
153
|
+
return this.applyPattern(this.itemName, this.selectedPattern.id)
|
|
154
|
+
},
|
|
155
|
+
},
|
|
156
|
+
|
|
157
|
+
beforeDestroy() {
|
|
158
|
+
if (this.closeTimeout) clearTimeout(this.closeTimeout)
|
|
159
|
+
},
|
|
160
|
+
|
|
161
|
+
/**
|
|
162
|
+
* @event confirm Emitted when the user confirms copying. Payload: `{ id, newName }`.
|
|
163
|
+
* @event close Emitted when the dialog should be closed (cancel, close button, or auto-close after success).
|
|
164
|
+
*/
|
|
165
|
+
|
|
166
|
+
methods: {
|
|
167
|
+
applyPattern(name, patternId) {
|
|
168
|
+
switch (patternId) {
|
|
169
|
+
case 'copy-of':
|
|
170
|
+
return `Copy of ${name}`
|
|
171
|
+
case 'name-copy':
|
|
172
|
+
return `${name} - Copy`
|
|
173
|
+
case 'name-parens':
|
|
174
|
+
return `${name} (Copy)`
|
|
175
|
+
default:
|
|
176
|
+
return `Copy of ${name}`
|
|
177
|
+
}
|
|
178
|
+
},
|
|
179
|
+
|
|
180
|
+
executeCopy() {
|
|
181
|
+
this.loading = true
|
|
182
|
+
this.$emit('confirm', {
|
|
183
|
+
id: this.item.id,
|
|
184
|
+
newName: this.newName,
|
|
185
|
+
})
|
|
186
|
+
},
|
|
187
|
+
|
|
188
|
+
/**
|
|
189
|
+
* Set the result of the copy operation. Call this from the parent
|
|
190
|
+
* after the API call completes.
|
|
191
|
+
*
|
|
192
|
+
* @param {{ success?: boolean, error?: string }} resultData
|
|
193
|
+
* @public
|
|
194
|
+
*/
|
|
195
|
+
setResult(resultData) {
|
|
196
|
+
this.loading = false
|
|
197
|
+
this.result = resultData
|
|
198
|
+
if (resultData.success) {
|
|
199
|
+
this.closeTimeout = setTimeout(() => {
|
|
200
|
+
this.$emit('close')
|
|
201
|
+
}, 2000)
|
|
202
|
+
}
|
|
203
|
+
},
|
|
204
|
+
},
|
|
205
|
+
}
|
|
206
|
+
</script>
|
|
207
|
+
|
|
208
|
+
<style scoped>
|
|
209
|
+
.cn-copy__pattern {
|
|
210
|
+
margin-bottom: 16px;
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
.cn-copy__pattern label {
|
|
214
|
+
display: block;
|
|
215
|
+
font-weight: 600;
|
|
216
|
+
margin-bottom: 4px;
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
.cn-copy__preview {
|
|
220
|
+
margin-top: 12px;
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
.cn-copy__preview-row {
|
|
224
|
+
display: flex;
|
|
225
|
+
align-items: center;
|
|
226
|
+
gap: 8px;
|
|
227
|
+
padding: 8px 12px;
|
|
228
|
+
background-color: var(--color-background-hover);
|
|
229
|
+
border-radius: var(--border-radius);
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
.cn-copy__preview-original {
|
|
233
|
+
color: var(--color-text-maxcontrast);
|
|
234
|
+
overflow: hidden;
|
|
235
|
+
text-overflow: ellipsis;
|
|
236
|
+
white-space: nowrap;
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
.cn-copy__preview-arrow {
|
|
240
|
+
flex-shrink: 0;
|
|
241
|
+
color: var(--color-text-maxcontrast);
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
.cn-copy__preview-new {
|
|
245
|
+
font-weight: 500;
|
|
246
|
+
overflow: hidden;
|
|
247
|
+
text-overflow: ellipsis;
|
|
248
|
+
white-space: nowrap;
|
|
249
|
+
}
|
|
250
|
+
</style>
|