Implemented deleting account

This commit is contained in:
dankito 2020-08-09 15:52:20 +02:00
parent b44161a45f
commit 5d6384918e
4 changed files with 38 additions and 1 deletions

View File

@ -94,7 +94,7 @@
<string name="dialog_enter_atc_error_entered_atc_is_not_a_number">ATC muss eine Zahl sein.\n\nDer eingebene ATC Wert \'%s\' kann jedoch nicht in eine Zahl konvertiert werden.</string>
<string name="dialog_edit_account_ask_should_account_be_deleted">Möchten Sie das Konto \'%s\' wirklich löschen?
\n\nDies kann nicht rückgängig gemacht werden und die hierzu gespeicherten Daten gehen unwiederbringlich verloren.</string>
\n\nDies kann nicht rückgängig gemacht werden und alle zu diesem Konto gespeicherten Daten gehen unwiederbringlich verloren.</string>
<string name="error_no_name_entered">Bitte geben Sie den Namen des Empfängers ein</string>

View File

@ -6,6 +6,7 @@
"Add" = "Add";
"New" = "New";
"New ..." = "New ...";
"Delete" = "Delete";
"Show less ..." = "Show less ...";
"Show all ..." = "Show all ...";
@ -96,9 +97,14 @@
"Customer name" = "Customer name";
"FinTS server address" = "FinTS server address";
"Delete account" = "Delete account";
"Unsaved changes" = "Unsaved changes";
"Changed data hasn't been saved. Are you sure you want to discard them?" = "Changed data hasn't been saved. Are you sure you want to discard them?";
"Delete account?" = "Delete account?";
"Really delete account '%@'? This cannot be undone and data will be lost." = "Really delete account '%@'?\n\nThis cannot be undone and data will be lost.";
/* BankAccountSettingsDialog */

View File

@ -6,6 +6,7 @@
"Add" = "Hinzufügen";
"New" = "Neu";
"New ..." = "Neu ...";
"Delete" = "Löschen";
"Show less ..." = "Weniger anzeigen ...";
"Show all ..." = "Alles anzeigen ...";
@ -96,9 +97,14 @@
"Customer name" = "Kontoinhaber";
"FinTS server address" = "FinTS Server";
"Delete account" = "Konto löschen";
"Unsaved changes" = "Nicht gespeicherte Änderungen";
"Changed data hasn't been saved. Are you sure you want to discard them?" = "Es wurden nicht alle Änderungen gespeichert. Sind Sie sich sicher, dass Sie sie verwerfen möchten?";
"Delete account?" = "Konto löschen?";
"Really delete account '%@'? This cannot be undone and data will be lost." = "Möchten Sie das Konto '%@' wirklich löschen?\n\nDies kann nicht rückgängig gemacht werden und alle zu diesem Konto gespeicherten Daten gehen unwiederbringlich verloren.";
/* BankAccountSettingsDialog */

View File

@ -21,6 +21,8 @@ struct BankSettingsDialog: View {
@State private var unsavedChangesMessage: Message? = nil
@State private var askToDeleteAccountMessage: Message? = nil
private var hasUnsavedData: Bool {
return bank.displayName != displayName
@ -77,15 +79,38 @@ struct BankSettingsDialog: View {
}
}
}
HStack {
Spacer()
Button("Delete account", action: askUserToDeleteAccount)
.foregroundColor(Color.red)
Spacer()
}
}
.alert(item: $unsavedChangesMessage) { message in
Alert(title: message.title, message: message.message, primaryButton: message.primaryButton, secondaryButton: message.secondaryButton!)
}
.alert(item: $askToDeleteAccountMessage) { message in
Alert(title: message.title, message: message.message, primaryButton: message.primaryButton, secondaryButton: message.secondaryButton!)
}
.showNavigationBarTitle(LocalizedStringKey(bank.displayName))
.setCancelAndDoneNavigationBarButtons(onCancelPressed: cancelPressed, onDonePressed: donePressed)
}
func askUserToDeleteAccount() {
self.askToDeleteAccountMessage = Message(title: Text("Delete account?"), message: Text("Really delete account '\(bank.displayName)'? This cannot be undone and data will be lost."), primaryButton: .destructive(Text("Delete"), action: deleteAccount), secondaryButton: .cancel())
}
func deleteAccount() {
presenter.deleteAccount(customer: bank)
closeDialog()
}
private func cancelPressed() {
if hasUnsavedData {
self.unsavedChangesMessage = Message(title: Text("Unsaved changes"), message: Text("Changed data hasn't been saved. Are you sure you want to discard them?"), primaryButton: .ok(closeDialog), secondaryButton: .cancel())