diff --git a/MacPass/Base.lproj/InspectorView.xib b/MacPass/Base.lproj/InspectorView.xib
index d4fc2b15..f68e8ad3 100644
--- a/MacPass/Base.lproj/InspectorView.xib
+++ b/MacPass/Base.lproj/InspectorView.xib
@@ -125,10 +125,35 @@
268
+
-2147483380
- {{197, 2}, {60, 25}}
+ {{198, 2}, {60, 25}}
_NS:22
@@ -157,7 +182,7 @@
{278, 30}
-
+
_NS:9
HNHGradientView
@@ -167,6 +192,7 @@
{{0, 30}, {278, 369}}
+
_NS:9
@@ -177,7 +203,6 @@
{278, 369}
-
_NS:28
Entry
@@ -329,12 +354,28 @@
3122
-
- handleEditButtonClickEvent:
+
+ cancelEditButton
-
+
- 3125
+ 3141
+
+
+
+ toggleEdit:
+
+
+
+ 3143
+
+
+
+ toggleEdit:
+
+
+
+ 3144
@@ -629,20 +670,20 @@
2930
-
-
- 6
+
+
+ 5
0
-
+
6
1
-
- 21
+
+ 8
1000
- 3
- 9
+ 6
+ 24
3
NO
@@ -663,6 +704,40 @@
2
NO
+
+
+ 6
+ 0
+
+ 6
+ 1
+
+ 20
+
+ 1000
+
+ 8
+ 23
+ 3
+ NO
+
+
+
+ 11
+ 0
+
+ 11
+ 1
+
+ 0.0
+
+ 1000
+
+ 6
+ 24
+ 2
+ NO
+
8
@@ -681,6 +756,7 @@
NO
+
@@ -896,13 +972,36 @@
- 3112
+ 3126
+
+
+
+
+
+
+
+ 3127
+
+
+
+
+ 3129
+
+
+
+
+ 3138
+
+
+
+
+ 3139
- 3123
-
+ 3140
+
@@ -946,8 +1045,10 @@
com.apple.InterfaceBuilder.CocoaPlugin
+
+
-
+
com.apple.InterfaceBuilder.CocoaPlugin
@@ -989,14 +1090,19 @@
com.apple.InterfaceBuilder.CocoaPlugin
com.apple.InterfaceBuilder.CocoaPlugin
- com.apple.InterfaceBuilder.CocoaPlugin
- com.apple.InterfaceBuilder.CocoaPlugin
+
+ com.apple.InterfaceBuilder.CocoaPlugin
+ com.apple.InterfaceBuilder.CocoaPlugin
+ com.apple.InterfaceBuilder.CocoaPlugin
+ com.apple.InterfaceBuilder.CocoaPlugin
+ com.apple.InterfaceBuilder.CocoaPlugin
+ com.apple.InterfaceBuilder.CocoaPlugin
- 3125
+ 3144
@@ -1012,21 +1118,22 @@
MPInspectorViewController
MPViewController
- id
id
+ id
-
- handleEditButtonClickEvent:
- id
-
showImagePopup:
id
+
+ toggleEdit:
+ id
+
HNHGradientView
+ NSButton
NSTextField
NSButton
MPPopupImageView
@@ -1040,6 +1147,10 @@
bottomBar
HNHGradientView
+
+ cancelEditButton
+ NSButton
+
createdTextField
NSTextField
diff --git a/MacPass/EntryInspectorView.xib b/MacPass/EntryInspectorView.xib
index ac3e68b6..db1549bd 100644
--- a/MacPass/EntryInspectorView.xib
+++ b/MacPass/EntryInspectorView.xib
@@ -1,5 +1,5 @@
-
+
@@ -595,7 +595,7 @@
-
+
@@ -622,7 +622,7 @@
-
+
-
+
-
+
-
+
-
+
@@ -660,7 +660,7 @@
-
+
@@ -668,7 +668,7 @@
-
+
diff --git a/MacPass/MPDocumentWindowController.m b/MacPass/MPDocumentWindowController.m
index 85ed99a5..e0068034 100644
--- a/MacPass/MPDocumentWindowController.m
+++ b/MacPass/MPDocumentWindowController.m
@@ -357,8 +357,6 @@ typedef NS_ENUM(NSUInteger, MPAlertContext) {
[_entryViewController updateResponderChain];
[_inspectorViewController updateResponderChain];
[_outlineViewController updateResponderChain];
- /* Custom setup after being added to window */
- [_inspectorViewController prepareView];
[_outlineViewController showOutline];
/* Restore the State the inspector view was in before the view change */
diff --git a/MacPass/MPEntryInspectorViewController.m b/MacPass/MPEntryInspectorViewController.m
index 94941439..c89b2542 100644
--- a/MacPass/MPEntryInspectorViewController.m
+++ b/MacPass/MPEntryInspectorViewController.m
@@ -184,39 +184,15 @@ typedef NS_ENUM(NSUInteger, MPEntryTab) {
[self.entry removeBinary:binary];
}
-// CS: could there be a better way?
-- (void)beginEditing
-{
- NSLog(@"beganEditing:");
-
- _titleTextField.editable = YES;
- _usernameTextField.editable = YES;
- _URLTextField.editable = YES;
- _passwordTextField.editable = YES;
-
- _createdTextField.editable = YES;
- _modifiedTextField.editable = YES;
-
- _notesTextView.editable = YES;
+#pragma mark Editing
+- (void)beginEditing {
+ [self _toggleEditing:YES];
}
-
-// CS: could there be a better way?
-- (void)endEditing
-{
- NSLog(@"endEditing");
- _titleTextField.editable = NO;
- _usernameTextField.editable = NO;
- _URLTextField.editable = NO;
- _passwordTextField.editable = NO;
-
- _createdTextField.editable = NO;
- _modifiedTextField.editable = NO;
-
- _notesTextView.editable = NO;
+- (void)endEditing {
+ [self _toggleEditing:NO];
}
-
#pragma mark -
#pragma mark Popovers
@@ -309,4 +285,25 @@ typedef NS_ENUM(NSUInteger, MPEntryTab) {
}
}
+- (void)_toggleEditing:(BOOL)edit {
+ /* TODO: not fully working right now */
+
+ [_titleTextField setEditable:edit];
+ [_titleTextField setSelectable:edit];
+ [_usernameTextField setEditable:edit];
+ [_usernameTextField setSelectable:edit];
+ [_URLTextField setEditable:edit];
+ [_URLTextField setSelectable:edit];
+ [_passwordTextField setEditable:edit];
+ [_passwordTextField setSelectable:edit];
+
+ [_createdTextField setEditable:edit];
+ [_createdTextField setSelectable:edit];
+ [_notesTextView setEditable:edit];
+ [_notesTextView setSelectable:edit];
+ [_modifiedTextField setEditable:edit];
+ [_modifiedTextField setSelectable:edit];
+
+}
+
@end
diff --git a/MacPass/MPInspectorViewController.h b/MacPass/MPInspectorViewController.h
index 668ed392..996dab56 100644
--- a/MacPass/MPInspectorViewController.h
+++ b/MacPass/MPInspectorViewController.h
@@ -20,12 +20,12 @@
@property (weak) IBOutlet MPPopupImageView *itemImageView;
@property (weak) IBOutlet NSTextField *itemNameTextField;
@property (weak) IBOutlet NSButton *editButton;
+@property (weak) IBOutlet NSButton *cancelEditButton;
- (IBAction)showImagePopup:(id)sender;
-- (IBAction)handleEditButtonClickEvent:(id)sender;
+- (IBAction)toggleEdit:(id)sender;
/* Seperate call to ensure alle registered objects are in place */
- (void)setupNotifications:(NSWindowController *)windowController;
-- (void)prepareView;
@end
diff --git a/MacPass/MPInspectorViewController.m b/MacPass/MPInspectorViewController.m
index c1e89498..3d28aab5 100644
--- a/MacPass/MPInspectorViewController.m
+++ b/MacPass/MPInspectorViewController.m
@@ -34,6 +34,7 @@ typedef NS_ENUM(NSUInteger, MPContentTab) {
MPEntryInspectorViewController *_entryViewController;
MPGroupInspectorViewController *_groupViewController;
NSPopover *_popover;
+ BOOL _isEditing;
}
@property (strong) MPIconSelectViewController *iconSelectionViewController;
@@ -41,8 +42,6 @@ typedef NS_ENUM(NSUInteger, MPContentTab) {
@property (nonatomic, strong) NSDate *modificationDate;
@property (nonatomic, strong) NSDate *creationDate;
-@property (nonatomic, assign) BOOL showEditButton;
-
@property (nonatomic, assign) NSUInteger activeTab;
@property (weak) IBOutlet NSTabView *tabView;
@@ -60,7 +59,7 @@ typedef NS_ENUM(NSUInteger, MPContentTab) {
_activeTab = MPEmptyTab;
_entryViewController = [[MPEntryInspectorViewController alloc] init];
_groupViewController = [[MPGroupInspectorViewController alloc] init];
- _showEditButton = NO;
+ _isEditing = NO;
}
return self;
}
@@ -77,14 +76,6 @@ typedef NS_ENUM(NSUInteger, MPContentTab) {
- (void)setActiveTab:(NSUInteger)activeTab {
if(_activeTab != activeTab) {
_activeTab = activeTab;
- self.showEditButton = [[[self windowController] document] tree].metaData.isHistoryEnabled;
- }
-}
-
-- (void)setShowEditButton:(BOOL)showEditButton {
- showEditButton &= (self.activeTab == MPEntryTab);
- if(_showEditButton != showEditButton) {
- _showEditButton = showEditButton;
}
}
@@ -158,24 +149,34 @@ typedef NS_ENUM(NSUInteger, MPContentTab) {
#pragma mark -
#pragma mark Click Edit Button
-
-// button title can be used as a status indicator
-- (IBAction)handleEditButtonClickEvent:(id)sender
-{
- NSString *buttonTitle;
+- (void)toggleEdit:(id)sender {
+ BOOL didCancel = sender == self.cancelEditButton;
+ MPDocument *document = [[self windowController] document];
+ NSUndoManager *undoManager = [document undoManager];
- buttonTitle = self.editButton.title;
-
- if ([buttonTitle isEqualToString:@"Edit"]) {
- NSLog(@"begin editing");
- [_entryViewController beginEditing];
- self.editButton.title = @"Done";
- }
- else if ([buttonTitle isEqualToString:@"Done"]) {
- NSLog(@"finished editing");
+ if(_isEditing) {
+ BOOL didChangeItem = [undoManager canUndo];
+ [undoManager endUndoGrouping];
+ [undoManager setActionName:NSLocalizedString(@"EDIT_GROUP_OR_ENTRY", "")];
+ [self.editButton setTitle:NSLocalizedString(@"EDIT_ITEM", "")];
+ [self.cancelEditButton setHidden:YES];
[_entryViewController endEditing];
- self.editButton.title = @"Edit";
+
+ /*
+ We need to be carefull to only undo the things we actually changed
+ otherwise we undo older actions
+ */
+ if(didCancel && didChangeItem) {
+ [undoManager undo];
+ }
}
+ else {
+ [undoManager beginUndoGrouping];
+ [self.editButton setTitle:NSLocalizedString(@"SAVE_CHANGES", "")];
+ [self.cancelEditButton setHidden:NO];
+ [_entryViewController beginEditing];
+ }
+ _isEditing = !_isEditing;
}
#pragma mark -
@@ -219,13 +220,6 @@ typedef NS_ENUM(NSUInteger, MPContentTab) {
#pragma mark -
#pragma mark Bindings
-- (void)prepareView {
- MPDocument *document = [[self windowController] document];
- [self bind:@"showEditButton" toObject:document.tree.metaData withKeyPath:@"isHistoryEnabled" options:nil];
- NSDictionary *bindingOptions = @{ NSValueTransformerNameBindingOption : NSNegateBooleanTransformerName };
- [self.editButton bind:NSHiddenBinding toObject:self withKeyPath:@"showEditButton" options:bindingOptions];
-}
-
- (void)_updateItemBindings:(id)item {
if(!item) {
[self.itemNameTextField unbind:NSValueBinding];
@@ -269,8 +263,7 @@ typedef NS_ENUM(NSUInteger, MPContentTab) {
}
[self _updateItemBindings:document.selectedItem];
- // disable the entry text fields whenever the entry selection changes
- [_entryViewController endEditing];
- self.editButton.title = @"Edit";
+ /* disable the entry text fields whenever the entry selection changes */
+ //[_entryViewController endEditing];
}
@end
\ No newline at end of file