|
85 | 85 | v-if="canEdit && !readOnly" |
86 | 86 | close-after-click |
87 | 87 | :disabled="isFormLocked" |
88 | | - @click="showDeleteDialog = true"> |
| 88 | + @click="onConfirmDelete"> |
89 | 89 | <template #icon> |
90 | 90 | <IconDelete :size="20" /> |
91 | 91 | </template> |
92 | 92 | {{ t('forms', 'Delete form') }} |
93 | 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 | 94 | </template> |
104 | 95 | </NcListItem> |
105 | 96 | </template> |
106 | 97 |
|
107 | 98 | <script> |
108 | | -import IconDeleteSvg from '@mdi/svg/svg/delete.svg?raw' |
109 | 99 | import { getCurrentUser } from '@nextcloud/auth' |
110 | 100 | import axios from '@nextcloud/axios' |
111 | | -import { showError } from '@nextcloud/dialogs' |
| 101 | +import { DialogSeverity, getDialogBuilder, showError } from '@nextcloud/dialogs' |
112 | 102 | import moment from '@nextcloud/moment' |
113 | 103 | import { generateOcsUrl } from '@nextcloud/router' |
114 | 104 | import NcActionButton from '@nextcloud/vue/components/NcActionButton' |
115 | 105 | import NcActionRouter from '@nextcloud/vue/components/NcActionRouter' |
116 | 106 | import NcActionSeparator from '@nextcloud/vue/components/NcActionSeparator' |
117 | | -import NcDialog from '@nextcloud/vue/components/NcDialog' |
118 | 107 | import NcListItem from '@nextcloud/vue/components/NcListItem' |
119 | 108 | import NcLoadingIcon from '@nextcloud/vue/components/NcLoadingIcon' |
120 | 109 | import IconArchiveOff from 'vue-material-design-icons/ArchiveOffOutline.vue' |
@@ -146,7 +135,6 @@ export default { |
146 | 135 | NcActionButton, |
147 | 136 | NcActionRouter, |
148 | 137 | NcActionSeparator, |
149 | | - NcDialog, |
150 | 138 | NcListItem, |
151 | 139 | NcLoadingIcon, |
152 | 140 | }, |
@@ -182,17 +170,6 @@ export default { |
182 | 170 | data() { |
183 | 171 | return { |
184 | 172 | 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 | 173 | } |
197 | 174 | }, |
198 | 175 |
|
@@ -312,6 +289,33 @@ export default { |
312 | 289 | this.$emit('clone', this.form.id) |
313 | 290 | }, |
314 | 291 |
|
| 292 | + async onConfirmDelete() { |
| 293 | + const dialog = getDialogBuilder(t('forms', 'Delete form')) |
| 294 | + .setText( |
| 295 | + t('forms', 'Are you sure you want to delete {title}?', { |
| 296 | + title: this.formTitle, |
| 297 | + }), |
| 298 | + ) |
| 299 | + .setSeverity(DialogSeverity.Error) |
| 300 | + .setButtons([ |
| 301 | + { |
| 302 | + label: t('forms', 'Cancel'), |
| 303 | + callback: () => {}, |
| 304 | + variant: 'secondary', |
| 305 | + }, |
| 306 | + { |
| 307 | + label: t('forms', 'Delete form'), |
| 308 | + callback: () => { |
| 309 | + this.onDeleteForm() |
| 310 | + }, |
| 311 | + variant: 'error', |
| 312 | + }, |
| 313 | + ]) |
| 314 | + .build() |
| 315 | +
|
| 316 | + await dialog.show() |
| 317 | + }, |
| 318 | +
|
315 | 319 | async onToggleArchive() { |
316 | 320 | try { |
317 | 321 | // TODO: add loading status feedback ? |
|
0 commit comments