cordova-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From an-s...@apache.org
Subject cordova-plugin-contacts git commit: CB-11975 iOS: Allow to use numeric values in search filter
Date Wed, 02 Nov 2016 07:26:37 GMT
Repository: cordova-plugin-contacts
Updated Branches:
  refs/heads/master 7f662d6c6 -> a19baba6f


CB-11975 iOS: Allow to use numeric values in search filter

This closes #139


Project: http://git-wip-us.apache.org/repos/asf/cordova-plugin-contacts/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-plugin-contacts/commit/a19baba6
Tree: http://git-wip-us.apache.org/repos/asf/cordova-plugin-contacts/tree/a19baba6
Diff: http://git-wip-us.apache.org/repos/asf/cordova-plugin-contacts/diff/a19baba6

Branch: refs/heads/master
Commit: a19baba6fbba5ab6d18c27eee0db4c3a2ea94f17
Parents: 7f662d6
Author: Nikita Matrosov <matrosov.nikita94@gmail.com>
Authored: Mon Oct 10 12:02:17 2016 +0300
Committer: Vladimir Kotikov <v-vlkoti@microsoft.com>
Committed: Wed Nov 2 10:25:09 2016 +0300

----------------------------------------------------------------------
 src/ios/CDVContacts.m |  4 +++-
 tests/tests.js        | 21 +++++++++++++++++++++
 2 files changed, 24 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-plugin-contacts/blob/a19baba6/src/ios/CDVContacts.m
----------------------------------------------------------------------
diff --git a/src/ios/CDVContacts.m b/src/ios/CDVContacts.m
index d5dd958..14fce2c 100644
--- a/src/ios/CDVContacts.m
+++ b/src/ios/CDVContacts.m
@@ -330,7 +330,9 @@
             NSArray* desiredFields = nil;
             if (![findOptions isKindOfClass:[NSNull class]]) {
                 id value = nil;
-                filter = (NSString*)[findOptions objectForKey:@"filter"];
+                id filterValue = [findOptions objectForKey:@"filter"];
+                BOOL filterValueIsNumber = [filterValue isKindOfClass:[NSNumber class]];
+                filter = filterValueIsNumber ? [filterValue stringValue] : (NSString *) filterValue;
                 value = [findOptions objectForKey:@"multiple"];
                 if ([value isKindOfClass:[NSNumber class]]) {
                     // multiple is a boolean that will come through as an NSNumber

http://git-wip-us.apache.org/repos/asf/cordova-plugin-contacts/blob/a19baba6/tests/tests.js
----------------------------------------------------------------------
diff --git a/tests/tests.js b/tests/tests.js
index 1f06cc4..6d0ef54 100644
--- a/tests/tests.js
+++ b/tests/tests.js
@@ -281,6 +281,27 @@ exports.defineAutoTests = function() {
                     };
                     specContext.contactObj.save(onSuccessSave, fail.bind(null, done));
                 });
+                it("contacts.spec.7.2 should find contact despite id isn't string ", function(done)
{
+                    if (isWindows || isWindowsPhone8 || isIOSPermissionBlocked) {
+                        pending();
+                    }
+                    var testDisplayName = "testContact";
+                    var specContext = this;
+                    specContext.contactObj = new Contact();
+                    specContext.contactObj.displayName = testDisplayName;
+                    var win = function(contactResult) {
+                        expect(contactResult.length > 0).toBe(true);
+                        done();
+                    };
+                    var onSuccessSave = function(savedContact) {
+                        specContext.contactObj = savedContact;
+                        var options = new ContactFindOptions();
+                        options.filter = savedContact.id;
+                        options.multiple = true;
+                        navigator.contacts.find(["id"], win, fail.bind(null, done), options);
+                    };
+                    specContext.contactObj.save(onSuccessSave, fail.bind(null, done));
+                });
             });
         });
 


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cordova.apache.org
For additional commands, e-mail: commits-help@cordova.apache.org


Mime
View raw message