Updated Branches:
  refs/heads/master 5c4b670f9 -> 4d88bcc12

Refactor chooseContact() to retreive contact information instead of just a 
contactId.


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/4845fcf3
Tree: http://git-wip-us.apache.org/repos/asf/incubator-cordova-ios/tree/4845fcf3
Diff: http://git-wip-us.apache.org/repos/asf/incubator-cordova-ios/diff/4845fcf3

Branch: refs/heads/master
Commit: 4845fcf31c069f09be20f86150db6e976101f6ab
Parents: 5c4b670
Author: Olivier Louvignes <oliv...@mg-crea.com>
Authored: Thu Jul 12 14:00:18 2012 +0200
Committer: Becky Gibson <becka...@apache.org>
Committed: Thu Aug 16 11:19:50 2012 -0400

----------------------------------------------------------------------
 CordovaLib/Classes/CDVContacts.h |    2 ++
 CordovaLib/Classes/CDVContacts.m |   11 +++++++++--
 2 files changed, 11 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-cordova-ios/blob/4845fcf3/CordovaLib/Classes/CDVContacts.h
----------------------------------------------------------------------
diff --git a/CordovaLib/Classes/CDVContacts.h b/CordovaLib/Classes/CDVContacts.h
index c709ab9..e5f65a8 100755
--- a/CordovaLib/Classes/CDVContacts.h
+++ b/CordovaLib/Classes/CDVContacts.h
@@ -107,11 +107,13 @@
 {
        BOOL allowsEditing;
        NSString* callbackId;
+       NSMutableDictionary *options;
        ABRecordID selectedId;
 }
 
 @property BOOL allowsEditing;
 @property (copy) NSString* callbackId;
+@property (nonatomic, retain) NSMutableDictionary *options;
 @property ABRecordID selectedId;
 
 @end

http://git-wip-us.apache.org/repos/asf/incubator-cordova-ios/blob/4845fcf3/CordovaLib/Classes/CDVContacts.m
----------------------------------------------------------------------
diff --git a/CordovaLib/Classes/CDVContacts.m b/CordovaLib/Classes/CDVContacts.m
index 2c6ed39..790ec12 100755
--- a/CordovaLib/Classes/CDVContacts.m
+++ b/CordovaLib/Classes/CDVContacts.m
@@ -29,6 +29,7 @@
 
 @synthesize allowsEditing;
 @synthesize callbackId;
+@synthesize options;
 @synthesize selectedId;
 
 @end
@@ -177,6 +178,7 @@
        CDVContactsPicker* pickerController = [[CDVContactsPicker alloc] init];
        pickerController.peoplePickerDelegate = self;
        pickerController.callbackId = callbackId;
+       pickerController.options = options;
        pickerController.selectedId = kABRecordInvalidID;
        pickerController.allowsEditing = (BOOL)[options existsValue:@"true" 
forKey:@"allowsEditing"];
        
@@ -195,6 +197,11 @@
        ABRecordID contactId = ABRecordGetRecordID(person);
        picker.selectedId = contactId; // save so can return when dismiss
 
+       // Retreive pickedContact information
+       CDVContact* pickedContact = [[[CDVContact alloc] 
initFromABRecord:(ABRecordRef)person] autorelease];
+       NSArray *fields = [picker.options objectForKey:@"fields"] ?: [NSArray 
arrayWithObjects:@"id", nil];
+       NSDictionary *returnFields = [[CDVContact class] calcReturnFields: 
fields];
+       NSDictionary *pickedContactDictionary = [pickedContact 
toDictionary:returnFields];
        
        if (picker.allowsEditing) {
                
@@ -206,8 +213,8 @@
                
                [peoplePicker pushViewController:personController animated:YES];
        } else {
-               // return the contact Id
-               CDVPluginResult* result = [CDVPluginResult resultWithStatus: 
CDVCommandStatus_OK messageAsInt: contactId];
+               // return the pickedContact information
+               CDVPluginResult *result = [CDVPluginResult resultWithStatus: 
CDVCommandStatus_OK messageAsDictionary: pickedContactDictionary];
                [self writeJavascript:[result toSuccessCallbackString: 
picker.callbackId]];
                
         if ([picker respondsToSelector:@selector(presentingViewController)]) { 

Reply via email to