From d689b20a608cda9139676dfc53f95ab6f8f94d01 Mon Sep 17 00:00:00 2001 From: Otto K Date: Thu, 6 Jun 2019 10:06:28 +0200 Subject: [PATCH] Implement check for account name existence in login dialog (#205) * Implement check for account name existence in login dialog * Improve semantics of method name * Refactor duplicate finding --- .../instance/checkIfAccountnameUnused..st | 8 ++++++++ .../instance/displayAccountnameExistsErrorMessage.st | 4 ++++ .../ICLoginDialog.class/instance/login.st | 2 ++ .../ICLoginDialog.class/methodProperties.json | 4 +++- 4 files changed, 17 insertions(+), 1 deletion(-) create mode 100644 packages/IMAPClient-UI.package/ICLoginDialog.class/instance/checkIfAccountnameUnused..st create mode 100644 packages/IMAPClient-UI.package/ICLoginDialog.class/instance/displayAccountnameExistsErrorMessage.st diff --git a/packages/IMAPClient-UI.package/ICLoginDialog.class/instance/checkIfAccountnameUnused..st b/packages/IMAPClient-UI.package/ICLoginDialog.class/instance/checkIfAccountnameUnused..st new file mode 100644 index 00000000..f7f088d1 --- /dev/null +++ b/packages/IMAPClient-UI.package/ICLoginDialog.class/instance/checkIfAccountnameUnused..st @@ -0,0 +1,8 @@ +helper +checkIfAccountnameUnused: aDictionary + + " return false if account with same name exists " + ICHelper loadCredentialsIntoDictionaries + detect: [:credDict | (aDictionary at: 'name') = (credDict at: 'name')] + ifFound: [:credDict | self displayAccountnameExistsErrorMessage. ^false] + ifNone: [^true] \ No newline at end of file diff --git a/packages/IMAPClient-UI.package/ICLoginDialog.class/instance/displayAccountnameExistsErrorMessage.st b/packages/IMAPClient-UI.package/ICLoginDialog.class/instance/displayAccountnameExistsErrorMessage.st new file mode 100644 index 00000000..e6ea7872 --- /dev/null +++ b/packages/IMAPClient-UI.package/ICLoginDialog.class/instance/displayAccountnameExistsErrorMessage.st @@ -0,0 +1,4 @@ +toasts +displayAccountnameExistsErrorMessage + + UserDialogBoxMorph inform: 'This account name already exists.' title: '' \ No newline at end of file diff --git a/packages/IMAPClient-UI.package/ICLoginDialog.class/instance/login.st b/packages/IMAPClient-UI.package/ICLoginDialog.class/instance/login.st index ed3b8c78..af11d55f 100644 --- a/packages/IMAPClient-UI.package/ICLoginDialog.class/instance/login.st +++ b/packages/IMAPClient-UI.package/ICLoginDialog.class/instance/login.st @@ -8,6 +8,8 @@ login dataDictionary := self makeDataDictionary. (self checkForEmptyParameter: dataDictionary) ifFalse: [^ self]. + (self checkIfAccountnameUnused: dataDictionary) + ifFalse: [^ self]. ((ICEndPoint new) testAccountWith: dataDictionary) ifTrue: [ diff --git a/packages/IMAPClient-UI.package/ICLoginDialog.class/methodProperties.json b/packages/IMAPClient-UI.package/ICLoginDialog.class/methodProperties.json index 21003713..4388167c 100644 --- a/packages/IMAPClient-UI.package/ICLoginDialog.class/methodProperties.json +++ b/packages/IMAPClient-UI.package/ICLoginDialog.class/methodProperties.json @@ -13,9 +13,11 @@ "changeInputField:" : "DH 7/25/2018 00:10", "checkBoxColor" : "ms 7/13/2016 17:34", "checkForEmptyParameter:" : "C.G. 7/25/2018 12:20", + "checkIfAccountnameUnused:" : "fr 6/6/2019 09:53", "checkIfLastCharacterIsTab:" : "C.G. 7/25/2018 14:22", "defaultBackgroundColor" : "C.G. 6/21/2018 00:28", "dialogTitle" : "ms 6/14/2016 09:53", + "displayAccountnameExistsErrorMessage" : "ok 6/5/2019 21:04", "displayEmptyFieldErrorMessage:" : "C.G. 7/25/2018 12:20", "emptyParameterFrom:" : "C.G. 7/25/2018 12:18", "endpoint" : "C.G. 7/25/2018 14:22", @@ -33,7 +35,7 @@ "inputCollection:" : "C.G. 7/25/2018 14:23", "keyEvent:" : "DH 7/25/2018 00:08", "loadData:" : "C.G. 6/21/2018 10:58", - "login" : "tg 4/30/2019 11:43", + "login" : "ok 6/6/2019 09:36", "loginMorph" : "C.G. 7/25/2018 14:24", "loginMorph:" : "C.G. 7/25/2018 14:24", "makeDataDictionary" : "C.G. 7/25/2018 12:16",