incubator-callback-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From becka...@apache.org
Subject ios commit: Fixes CB-997, CB-976 remove Organization
Date Thu, 05 Jul 2012 16:01:42 GMT
Updated Branches:
  refs/heads/master 21a9cec0f -> 7b9b434de


Fixes CB-997, CB-976 remove Organization

Will now properly remove an organization if the Contact.organizations array
is set to an empty array.  Also tested removing individual ContactOrganization elements
by setting to empty string.


Project: http://git-wip-us.apache.org/repos/asf/incubator-cordova-ios/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-cordova-ios/commit/7b9b434d
Tree: http://git-wip-us.apache.org/repos/asf/incubator-cordova-ios/tree/7b9b434d
Diff: http://git-wip-us.apache.org/repos/asf/incubator-cordova-ios/diff/7b9b434d

Branch: refs/heads/master
Commit: 7b9b434de9278a251398c77993a40baa175f75f1
Parents: 21a9cec
Author: Becky Gibson <becka11y@apache.org>
Authored: Thu Jul 5 11:57:36 2012 -0400
Committer: Becky Gibson <becka11y@apache.org>
Committed: Thu Jul 5 11:57:36 2012 -0400

----------------------------------------------------------------------
 CordovaLib/Classes/CDVContact.m |   19 +++++++++++++------
 1 files changed, 13 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-cordova-ios/blob/7b9b434d/CordovaLib/Classes/CDVContact.m
----------------------------------------------------------------------
diff --git a/CordovaLib/Classes/CDVContact.m b/CordovaLib/Classes/CDVContact.m
index e7cdbfc..51297ca 100644
--- a/CordovaLib/Classes/CDVContact.m
+++ b/CordovaLib/Classes/CDVContact.m
@@ -319,12 +319,19 @@ static NSDictionary*	org_apache_cordova_contacts_defaultFields = nil;
     // TODO this may need work - should Organization information be removed when array is
empty??
 	array = [aContact valueForKey:kW3ContactOrganizations];  // iOS only supports one organization
- use first one
 	if ([array isKindOfClass:[NSArray class]]){
-		NSDictionary* dict = [array objectAtIndex:0];
-		if ([dict isKindOfClass:[NSDictionary class]]){
-			[self setValue: [dict valueForKey:@"name"] forProperty: kABPersonOrganizationProperty
inRecord: person asUpdate: bUpdate];
-			[self setValue: [dict valueForKey:kW3ContactTitle] forProperty:  kABPersonJobTitleProperty
inRecord: person asUpdate: bUpdate];
-			[self setValue: [dict valueForKey:kW3ContactDepartment] forProperty: kABPersonDepartmentProperty
inRecord: person asUpdate: bUpdate];
-		}
+        BOOL bRemove = NO;
+        NSDictionary* dict = nil;
+        if ([array count] > 0) {
+            dict = [array objectAtIndex:0];  
+        } else {
+            // remove the organization info entirely
+            bRemove = YES;     
+        }
+        if ([dict isKindOfClass:[NSDictionary class]] || bRemove == YES){
+            [self setValue: (bRemove ? @"" : [dict valueForKey:@"name"]) forProperty: kABPersonOrganizationProperty
inRecord: person asUpdate: bUpdate];
+            [self setValue: (bRemove ? @"" :[dict valueForKey:kW3ContactTitle]) forProperty:
 kABPersonJobTitleProperty inRecord: person asUpdate: bUpdate];
+            [self setValue: (bRemove ? @"" :[dict valueForKey:kW3ContactDepartment]) forProperty:
kABPersonDepartmentProperty inRecord: person asUpdate: bUpdate];
+        }
 	}
 	// add dates
 	// Dates come in as milliseconds in NSNumber Object


Mime
View raw message