|
16 | 16 | params: { hash: form.hash }, |
17 | 17 | }" |
18 | 18 | @click="mobileCloseNavigation"> |
19 | | - <template #icon> |
20 | | - <NcLoadingIcon v-if="loading" :size="16" /> |
21 | | - <IconCheck v-else-if="isExpired" :size="16" /> |
22 | | - <FormsIcon v-else :size="16" /> |
23 | | - </template> |
24 | | - <template v-if="hasSubtitle" #subname> |
25 | | - {{ formSubtitle }} |
26 | | - </template> |
27 | | - <template |
28 | | - v-if="!loading && (!readOnly || canEdit || canSeeResults)" |
29 | | - #actions> |
30 | | - <NcActionRouter |
31 | | - v-if="!isArchived && canEdit" |
32 | | - close-after-click |
33 | | - :disabled="isFormLocked" |
34 | | - exact |
35 | | - :to="{ name: 'edit', params: { hash: form.hash } }" |
36 | | - @click="mobileCloseNavigation"> |
37 | | - <template #icon> |
38 | | - <IconPencil :size="20" /> |
39 | | - </template> |
40 | | - {{ t('forms', 'Edit form') }} |
41 | | - </NcActionRouter> |
42 | | - <NcActionButton |
43 | | - v-if="!isArchived && !readOnly" |
44 | | - close-after-click |
45 | | - @click="onShareForm"> |
46 | | - <template #icon> |
47 | | - <IconShareVariant :size="20" /> |
48 | | - </template> |
49 | | - {{ t('forms', 'Share form') }} |
50 | | - </NcActionButton> |
51 | | - <NcActionRouter |
52 | | - v-if="canSeeResults" |
53 | | - close-after-click |
54 | | - exact |
55 | | - :to="{ name: 'results', params: { hash: form.hash } }" |
56 | | - @click="mobileCloseNavigation"> |
57 | | - <template #icon> |
58 | | - <IconPoll :size="20" /> |
59 | | - </template> |
60 | | - {{ t('forms', 'Results') }} |
61 | | - </NcActionRouter> |
62 | | - <NcActionButton v-if="canEdit" close-after-click @click="onCloneForm"> |
63 | | - <template #icon> |
64 | | - <IconContentCopy :size="20" /> |
65 | | - </template> |
66 | | - {{ t('forms', 'Copy form') }} |
67 | | - </NcActionButton> |
68 | | - <NcActionSeparator v-if="canEdit && !readOnly" /> |
69 | | - <NcActionButton |
70 | | - v-if="canEdit && !readOnly" |
71 | | - close-after-click |
72 | | - :disabled="isFormLocked" |
73 | | - @click="onToggleArchive"> |
74 | | - <template #icon> |
75 | | - <IconArchiveOff v-if="isArchived" :size="20" /> |
76 | | - <IconArchive v-else :size="20" /> |
77 | | - </template> |
78 | | - {{ |
79 | | - isArchived |
80 | | - ? t('forms', 'Unarchive form') |
81 | | - : t('forms', 'Archive form') |
82 | | - }} |
83 | | - </NcActionButton> |
84 | | - <NcActionButton |
85 | | - v-if="canEdit && !readOnly" |
86 | | - close-after-click |
87 | | - :disabled="isFormLocked" |
88 | | - @click="showDeleteDialog = true"> |
89 | | - <template #icon> |
90 | | - <IconDelete :size="20" /> |
91 | | - </template> |
92 | | - {{ t('forms', 'Delete form') }} |
93 | | - </NcActionButton> |
94 | | - <NcDialog |
95 | | - :open.sync="showDeleteDialog" |
96 | | - :name="t('forms', 'Delete form')" |
97 | | - :message=" |
98 | | - t('forms', 'Are you sure you want to delete {title}?', { |
99 | | - title: formTitle, |
100 | | - }) |
101 | | - " |
102 | | - :buttons="buttons" /> |
103 | | - </template> |
| 19 | + <template #icon> |
| 20 | + <NcLoadingIcon v-if="loading" :size="16" /> |
| 21 | + <IconCheck v-else-if="isExpired" :size="16" /> |
| 22 | + <FormsIcon v-else :size="16" /> |
| 23 | + </template> |
| 24 | + <template v-if="hasSubtitle" #subname> |
| 25 | + {{ formSubtitle }} |
| 26 | + </template> |
| 27 | + <template |
| 28 | + v-if="!loading && (!readOnly || canEdit || canSeeResults)" |
| 29 | + #actions> |
| 30 | + <NcActionRouter |
| 31 | + v-if="!isArchived && canEdit" |
| 32 | + close-after-click |
| 33 | + :disabled="isFormLocked" |
| 34 | + exact |
| 35 | + :to="{ name: 'edit', params: { hash: form.hash } }" |
| 36 | + @click="mobileCloseNavigation"> |
| 37 | + <template #icon> |
| 38 | + <IconPencil :size="20" /> |
| 39 | + </template> |
| 40 | + {{ t('forms', 'Edit form') }} |
| 41 | + </NcActionRouter> |
| 42 | + <NcActionButton |
| 43 | + v-if="!isArchived && !readOnly" |
| 44 | + close-after-click |
| 45 | + @click="onShareForm"> |
| 46 | + <template #icon> |
| 47 | + <IconShareVariant :size="20" /> |
| 48 | + </template> |
| 49 | + {{ t('forms', 'Share form') }} |
| 50 | + </NcActionButton> |
| 51 | + <NcActionRouter |
| 52 | + v-if="canSeeResults" |
| 53 | + close-after-click |
| 54 | + exact |
| 55 | + :to="{ name: 'results', params: { hash: form.hash } }" |
| 56 | + @click="mobileCloseNavigation"> |
| 57 | + <template #icon> |
| 58 | + <IconPoll :size="20" /> |
| 59 | + </template> |
| 60 | + {{ t('forms', 'Results') }} |
| 61 | + </NcActionRouter> |
| 62 | + <NcActionButton |
| 63 | + v-if="canEdit" |
| 64 | + close-after-click |
| 65 | + @click="onCloneForm"> |
| 66 | + <template #icon> |
| 67 | + <IconContentCopy :size="20" /> |
| 68 | + </template> |
| 69 | + {{ t('forms', 'Copy form') }} |
| 70 | + </NcActionButton> |
| 71 | + <NcActionSeparator v-if="canEdit && !readOnly" /> |
| 72 | + <NcActionButton |
| 73 | + v-if="canEdit && !readOnly" |
| 74 | + close-after-click |
| 75 | + :disabled="isFormLocked" |
| 76 | + @click="onToggleArchive"> |
| 77 | + <template #icon> |
| 78 | + <IconArchiveOff v-if="isArchived" :size="20" /> |
| 79 | + <IconArchive v-else :size="20" /> |
| 80 | + </template> |
| 81 | + {{ |
| 82 | + isArchived |
| 83 | + ? t('forms', 'Unarchive form') |
| 84 | + : t('forms', 'Archive form') |
| 85 | + }} |
| 86 | + </NcActionButton> |
| 87 | + <NcActionButton |
| 88 | + v-if="canEdit && !readOnly" |
| 89 | + close-after-click |
| 90 | + :disabled="isFormLocked" |
| 91 | + @click="onConfirmDelete"> |
| 92 | + <template #icon> |
| 93 | + <IconDelete :size="20" /> |
| 94 | + </template> |
| 95 | + {{ t('forms', 'Delete form') }} |
| 96 | + </NcActionButton> |
| 97 | + </template> |
104 | 98 | </NcListItem> |
105 | 99 | </template> |
106 | 100 |
|
107 | 101 | <script> |
108 | | -import IconDeleteSvg from '@mdi/svg/svg/delete.svg?raw' |
109 | 102 | import { getCurrentUser } from '@nextcloud/auth' |
110 | 103 | import axios from '@nextcloud/axios' |
111 | | -import { showError } from '@nextcloud/dialogs' |
| 104 | +import { DialogSeverity, getDialogBuilder, showError } from '@nextcloud/dialogs' |
112 | 105 | import moment from '@nextcloud/moment' |
113 | 106 | import { generateOcsUrl } from '@nextcloud/router' |
114 | 107 | import NcActionButton from '@nextcloud/vue/components/NcActionButton' |
115 | 108 | import NcActionRouter from '@nextcloud/vue/components/NcActionRouter' |
116 | 109 | import NcActionSeparator from '@nextcloud/vue/components/NcActionSeparator' |
117 | | -import NcDialog from '@nextcloud/vue/components/NcDialog' |
118 | 110 | import NcListItem from '@nextcloud/vue/components/NcListItem' |
119 | 111 | import NcLoadingIcon from '@nextcloud/vue/components/NcLoadingIcon' |
120 | 112 | import IconArchiveOff from 'vue-material-design-icons/ArchiveOffOutline.vue' |
@@ -146,7 +138,6 @@ export default { |
146 | 138 | NcActionButton, |
147 | 139 | NcActionRouter, |
148 | 140 | NcActionSeparator, |
149 | | - NcDialog, |
150 | 141 | NcListItem, |
151 | 142 | NcLoadingIcon, |
152 | 143 | }, |
@@ -182,17 +173,6 @@ export default { |
182 | 173 | data() { |
183 | 174 | return { |
184 | 175 | loading: false, |
185 | | - showDeleteDialog: false, |
186 | | - buttons: [ |
187 | | - { |
188 | | - label: t('forms', 'Delete form'), |
189 | | - icon: IconDeleteSvg, |
190 | | - type: 'error', |
191 | | - callback: () => { |
192 | | - this.onDeleteForm() |
193 | | - }, |
194 | | - }, |
195 | | - ], |
196 | 176 | } |
197 | 177 | }, |
198 | 178 |
|
@@ -312,6 +292,33 @@ export default { |
312 | 292 | this.$emit('clone', this.form.id) |
313 | 293 | }, |
314 | 294 |
|
| 295 | + async onConfirmDelete() { |
| 296 | + const dialog = getDialogBuilder(t('forms', 'Delete form')) |
| 297 | + .setText( |
| 298 | + t('forms', 'Are you sure you want to delete {title}?', { |
| 299 | + title: this.formTitle, |
| 300 | + }), |
| 301 | + ) |
| 302 | + .setSeverity(DialogSeverity.Error) |
| 303 | + .setButtons([ |
| 304 | + { |
| 305 | + label: t('forms', 'Cancel'), |
| 306 | + callback: () => {}, |
| 307 | + variant: 'secondary', |
| 308 | + }, |
| 309 | + { |
| 310 | + label: t('forms', 'Delete form'), |
| 311 | + callback: () => { |
| 312 | + this.onDeleteForm() |
| 313 | + }, |
| 314 | + variant: 'error', |
| 315 | + }, |
| 316 | + ]) |
| 317 | + .build() |
| 318 | +
|
| 319 | + await dialog.show() |
| 320 | + }, |
| 321 | +
|
315 | 322 | async onToggleArchive() { |
316 | 323 | try { |
317 | 324 | // TODO: add loading status feedback ? |
|
0 commit comments