From 208110e9cdaeb83737b3ba6badc6b3a8975647c9 Mon Sep 17 00:00:00 2001 From: Bibiko Date: Fri, 5 Mar 2010 21:16:27 +0000 Subject: =?UTF-8?q?=E2=80=A2=20CSV=20Import=20Field=20Mapper=20-=20improve?= =?UTF-8?q?d=20some=20validation=20logic=20-=20added=20"Match=20Field"=20t?= =?UTF-8?q?o=20source=20file=20field=20popup=20to=20be=20consistent=20if?= =?UTF-8?q?=20UPDATE=20is=20chosen=20-=20the=20label=20"Advanced"=20is=20n?= =?UTF-8?q?ow=20clickable=20as=20well?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Source/SPFieldMapperController.m | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) (limited to 'Source') diff --git a/Source/SPFieldMapperController.m b/Source/SPFieldMapperController.m index 1760d239..5e43398c 100644 --- a/Source/SPFieldMapperController.m +++ b/Source/SPFieldMapperController.m @@ -350,8 +350,10 @@ [[importMethodPopup itemWithTitle:@"UPDATE"] setEnabled:YES]; } else { [[importMethodPopup itemWithTitle:@"UPDATE"] setEnabled:NO]; - if([[importMethodPopup titleOfSelectedItem] isEqualToString:@"UPDATE"]) + if([[importMethodPopup titleOfSelectedItem] isEqualToString:@"UPDATE"]) { [importMethodPopup selectItemWithTitle:@"INSERT"]; + [self changeImportMethod:nil]; + } } [self updateFieldNameAlignment]; @@ -407,7 +409,6 @@ // If operator is set to = for UPDATE method replace it by doNotImport if(![[importMethodPopup titleOfSelectedItem] isEqualToString:@"UPDATE"]) { [advancedButton setEnabled:YES]; - [addRemainingDataSwitch setHidden:YES]; for(i=0; i<[fieldMappingTableColumnNames count]; i++) { if([fieldMappingOperatorArray objectAtIndex:i] == isEqual) { [fieldMappingOperatorArray replaceObjectAtIndex:i withObject:doNotImport]; @@ -553,8 +554,9 @@ [fieldMappingArray replaceObjectAtIndex:[fieldMapperTableView selectedRow] withObject:[NSNumber numberWithInteger:[globalValuesTableView selectedRow]+numberOfImportColumns]]; - // Set corresponding operator to doImport - [fieldMappingOperatorArray replaceObjectAtIndex:[fieldMapperTableView selectedRow] withObject:doImport]; + // Set corresponding operator to doImport if not set to isEqual + if([fieldMappingOperatorArray objectAtIndex:[fieldMapperTableView selectedRow]] != isEqual) + [fieldMappingOperatorArray replaceObjectAtIndex:[fieldMapperTableView selectedRow] withObject:doImport]; [fieldMapperTableView reloadData]; @@ -573,8 +575,10 @@ { showAdvancedView = !showAdvancedView; if(showAdvancedView) { + [advancedButton setState:NSOnState]; [self changeImportMethod:nil]; } else { + [advancedButton setState:NSOffState]; [advancedBox setHidden:YES]; [advancedReplaceView setHidden:YES]; [advancedUpdateView setHidden:YES]; @@ -952,6 +956,8 @@ [c addItemWithTitle:NSLocalizedString(@"Ignore field", @"ignore field label")]; [c addItemWithTitle:NSLocalizedString(@"Ignore all fields", @"ignore all fields menu item")]; [c addItemWithTitle:NSLocalizedString(@"Import all fields", @"import all fields menu item")]; + if([[self selectedImportMethod] isEqualToString:@"UPDATE"]) + [c addItemWithTitle:NSLocalizedString(@"Match field", @"match field menu item")]; [m addItem:[NSMenuItem separatorItem]]; [c addItemWithTitle:NSLocalizedString(@"Add global value…", @"add global value menu item")]; [c addItemWithTitle:[NSString stringWithFormat:@"DEFAULT: %@", [fieldMappingTableDefaultValues objectAtIndex:rowIndex]]]; @@ -1021,12 +1027,15 @@ [fieldMappingOperatorArray addObject:globalValue]; [aTableView performSelector:@selector(reloadData) withObject:nil afterDelay:0.0]; } + else if([[self selectedImportMethod] isEqualToString:@"UPDATE"] && [anObject integerValue] == [fieldMappingButtonOptions count]+4) { + [fieldMappingOperatorArray replaceObjectAtIndex:rowIndex withObject:isEqual]; + [aTableView performSelector:@selector(reloadData) withObject:nil afterDelay:0.0]; + } // Add global value - else if([anObject integerValue] == [fieldMappingButtonOptions count]+5) { + else if([anObject integerValue] == ([[self selectedImportMethod] isEqualToString:@"UPDATE"]) ? [fieldMappingButtonOptions count]+6 : [fieldMappingButtonOptions count]+5) { [aTableView performSelector:@selector(reloadData) withObject:nil afterDelay:0.0]; [self addGlobalSourceVariable:nil]; } - [self validateImportButton]; return; -- cgit v1.2.3