Return-Path: X-Original-To: apmail-incubator-callback-commits-archive@minotaur.apache.org Delivered-To: apmail-incubator-callback-commits-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id D7AF4C122 for ; Thu, 5 Jul 2012 16:01:43 +0000 (UTC) Received: (qmail 47630 invoked by uid 500); 5 Jul 2012 16:01:43 -0000 Delivered-To: apmail-incubator-callback-commits-archive@incubator.apache.org Received: (qmail 47581 invoked by uid 500); 5 Jul 2012 16:01:43 -0000 Mailing-List: contact callback-commits-help@incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: callback-dev@incubator.apache.org Delivered-To: mailing list callback-commits@incubator.apache.org Received: (qmail 47569 invoked by uid 99); 5 Jul 2012 16:01:43 -0000 Received: from tyr.zones.apache.org (HELO tyr.zones.apache.org) (140.211.11.114) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 05 Jul 2012 16:01:43 +0000 Received: by tyr.zones.apache.org (Postfix, from userid 65534) id C17F8AE39; Thu, 5 Jul 2012 16:01:42 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: becka11y@apache.org To: callback-commits@incubator.apache.org X-Mailer: ASF-Git Admin Mailer Subject: ios commit: Fixes CB-997, CB-976 remove Organization Message-Id: <20120705160142.C17F8AE39@tyr.zones.apache.org> Date: Thu, 5 Jul 2012 16:01:42 +0000 (UTC) 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 Authored: Thu Jul 5 11:57:36 2012 -0400 Committer: Becky Gibson 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