From 8244ec77c02803faa3069cf9515ea21bb4cdd31a Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?John=20Molakvo=C3=A6=20=28skjnldsv=29?=
 <skjnldsv@protonmail.com>
Date: Sat, 5 Jan 2019 10:53:59 +0100
Subject: Addressbook deletion confirm
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Signed-off-by: John Molakvoæ (skjnldsv) <skjnldsv@protonmail.com>
---
 src/components/Settings/SettingsAddressbook.vue | 44 ++++++++++++++++---------
 1 file changed, 28 insertions(+), 16 deletions(-)

(limited to 'src/components/Settings/SettingsAddressbook.vue')

diff --git a/src/components/Settings/SettingsAddressbook.vue b/src/components/Settings/SettingsAddressbook.vue
index dd6ac69c..991ffcda 100644
--- a/src/components/Settings/SettingsAddressbook.vue
+++ b/src/components/Settings/SettingsAddressbook.vue
@@ -140,7 +140,7 @@ export default {
 					menu.push({
 						icon: this.deleteAddressbookLoading ? 'icon-loading-small' : 'icon-delete',
 						text: t('contacts', 'Delete'),
-						action: this.deleteAddressbook
+						action: this.confirmDeletion
 					})
 				}
 			}
@@ -184,21 +184,33 @@ export default {
 				}
 			}, 500)
 		},
-		deleteAddressbook() {
-			// change to loading status
-			this.deleteAddressbookLoading = true
-			setTimeout(() => {
-				try {
-					this.$store.dispatch('deleteAddressbook', this.addressbook)
-				} catch (err) {
-					// error handling
-					console.error(err)
-					OC.Notification.showTemporary(t('contacts', 'Deletion of addressbook was not successful.'))
-				} finally {
-					// stop loading status regardless of outcome
-					this.deleteAddressbookLoading = false
-				}
-			}, 500)
+
+		confirmDeletion() {
+			OC.dialogs.confirm(
+				t('contacts', 'This will delete the addressbook and every contacts within it'),
+				t('contacts', 'Delete {addressbook} ?', { addressbook: this.addressbook.displayName }),
+				this.deleteAddressbook,
+				true
+			)
+		},
+
+		deleteAddressbook(confirm) {
+			if (confirm) {
+				// change to loading status
+				this.deleteAddressbookLoading = true
+				setTimeout(() => {
+					try {
+						this.$store.dispatch('deleteAddressbook', this.addressbook)
+					} catch (err) {
+						// error handling
+						console.error(err)
+						OC.Notification.showTemporary(t('contacts', 'Deletion of addressbook was not successful.'))
+					} finally {
+						// stop loading status regardless of outcome
+						this.deleteAddressbookLoading = false
+					}
+				}, 500)
+			}
 		},
 		renameAddressbook() {
 			this.editingName = true
-- 
cgit v1.2.3

