aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormltownsend <mltownsend@gmail.com>2010-02-08 16:34:18 +0000
committermltownsend <mltownsend@gmail.com>2010-02-08 16:34:18 +0000
commita947c6e6c97a31fe18ee168e5c02294706fba164 (patch)
tree4b2e89c6bf398e340dbe5bb370fb96d636ac9928
parent8f13ed5a02b4ed8ed015e3ebe04f4cb19178ab5b (diff)
downloadsequelpro-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.
-rw-r--r--Interfaces/English.lproj/UserManagerView.xib12
-rw-r--r--Source/SPUserManager.h1
-rw-r--r--Source/SPUserManager.m46
3 files changed, 43 insertions, 16 deletions
diff --git a/Interfaces/English.lproj/UserManagerView.xib b/Interfaces/English.lproj/UserManagerView.xib
index 3b53174d..890d5dc7 100644
--- a/Interfaces/English.lproj/UserManagerView.xib
+++ b/Interfaces/English.lproj/UserManagerView.xib
@@ -3966,6 +3966,14 @@
</object>
<int key="connectionID">892</int>
</object>
+ <object class="IBConnectionRecord">
+ <object class="IBOutletConnection" key="connection">
+ <string key="label">userNameTextField</string>
+ <reference key="source" ref="1001"/>
+ <reference key="destination" ref="1021720165"/>
+ </object>
+ <int key="connectionID">893</int>
+ </object>
</object>
<object class="IBMutableOrderedSet" key="objectRecords">
<object class="NSArray" key="orderedObjects">
@@ -5521,7 +5529,7 @@
</object>
</object>
<nil key="sourceID"/>
- <int key="maxID">892</int>
+ <int key="maxID">893</int>
</object>
<object class="IBClassDescriber" key="IBDocument.Classes">
<object class="NSMutableArray" key="referencedPartialClassDescriptions">
@@ -5658,6 +5666,7 @@
<string>schemasTableView</string>
<string>tabView</string>
<string>treeController</string>
+ <string>userNameTextField</string>
</object>
<object class="NSMutableArray" key="dict.values">
<bool key="EncodedWithXMLCoder">YES</bool>
@@ -5673,6 +5682,7 @@
<string>NSTableView</string>
<string>NSTabView</string>
<string>NSTreeController</string>
+ <string>NSTextField</string>
</object>
</object>
<object class="IBClassDescriptionSource" key="sourceIdentifier">
diff --git a/Source/SPUserManager.h b/Source/SPUserManager.h
index 76a790e5..172fbdde 100644
--- a/Source/SPUserManager.h
+++ b/Source/SPUserManager.h
@@ -52,6 +52,7 @@
IBOutlet NSButton *addSchemaPrivButton;
IBOutlet NSButton *removeSchemaPrivButton;
+ IBOutlet NSTextField *userNameTextField;
NSMutableArray *schemas;
NSMutableArray *grantedSchemaPrivs;
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;