diff options
author | mltownsend <mltownsend@gmail.com> | 2010-02-08 16:34:18 +0000 |
---|---|---|
committer | mltownsend <mltownsend@gmail.com> | 2010-02-08 16:34:18 +0000 |
commit | a947c6e6c97a31fe18ee168e5c02294706fba164 (patch) | |
tree | 4b2e89c6bf398e340dbe5bb370fb96d636ac9928 /Source/SPUserManager.m | |
parent | 8f13ed5a02b4ed8ed015e3ebe04f4cb19178ab5b (diff) | |
download | sequelpro-a947c6e6c97a31fe18ee168e5c02294706fba164.tar.gz sequelpro-a947c6e6c97a31fe18ee168e5c02294706fba164.tar.bz2 sequelpro-a947c6e6c97a31fe18ee168e5c02294706fba164.zip |
Fix bug where adding a user, setting name and password, then immediately hitting Apply didn't end editing in the password field.
Diffstat (limited to 'Source/SPUserManager.m')
-rw-r--r-- | Source/SPUserManager.m | 46 |
1 files changed, 31 insertions, 15 deletions
diff --git a/Source/SPUserManager.m b/Source/SPUserManager.m index c5b621ef..a65de9ee 100644 --- a/Source/SPUserManager.m +++ b/Source/SPUserManager.m @@ -555,6 +555,10 @@ - (IBAction)doApply:(id)sender { NSError *error = nil; + + //Change the first responder to end editing in any field + [[self window] makeFirstResponder:self]; + [[self managedObjectContext] save:&error]; if (error != nil) { @@ -625,6 +629,7 @@ [treeController addObject:newItem]; [outlineView expandItem:[outlineView itemAtRow:[outlineView selectedRow]]]; + [[self window] makeFirstResponder:userNameTextField]; } - (IBAction)removeUser:(id)sender @@ -907,22 +912,33 @@ { if ([[[user entity] name] isEqualToString:@"Privileges"]) continue; - NSString *createStatement; - - if ([user parent] && [[user parent] valueForKey:@"user"] && [[user parent] valueForKey:@"password"]) { - - createStatement = [NSString stringWithFormat:@"CREATE USER %@@%@ IDENTIFIED BY %@;", - [[[user parent] valueForKey:@"user"] tickQuotedString], - [[user valueForKey:@"host"] tickQuotedString], - [[[user parent] valueForKey:@"password"] tickQuotedString]]; - - // Create user in database - [self.mySqlConnection queryString:createStatement]; - - if ([self checkAndDisplayMySqlError]) { - [self grantPrivilegesToUser:user]; - } + NSString *createStatement = nil; + + if ([user parent] && [[user parent] valueForKey:@"user"] && [[user parent] valueForKey:@"password"]) + { + createStatement = [NSString stringWithFormat:@"CREATE USER %@@%@ IDENTIFIED BY %@", + [[[user parent] valueForKey:@"user"] tickQuotedString], + [[user valueForKey:@"host"] tickQuotedString], + [[[user parent] valueForKey:@"password"] tickQuotedString]]; } + else + { + if ([user parent] && [[user parent] valueForKey:@"user"]) + { + createStatement = [NSString stringWithFormat:@"CREATE USER %@@%@", + [[[user parent] valueForKey:@"user"] tickQuotedString], + [[user valueForKey:@"host"] tickQuotedString]]; + } + } + + if (createStatement) + { + // Create user in database + [self.mySqlConnection queryString:createStatement]; + + if ([self checkAndDisplayMySqlError]) + [self grantPrivilegesToUser:user]; + } } return YES; |