You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by he...@apache.org on 2014/01/09 21:10:54 UTC
[19/21] git commit: added readOnly formatted field
added readOnly formatted field
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/4ca5d1b1
Tree: http://git-wip-us.apache.org/repos/asf/cordova-plugin-contacts/tree/4ca5d1b1
Diff: http://git-wip-us.apache.org/repos/asf/cordova-plugin-contacts/diff/4ca5d1b1
Branch: refs/heads/master
Commit: 4ca5d1b12d7b5a48e25ff89d76896558182439d8
Parents: f7bc688
Author: Piotr Zalewa <pi...@zalewa.info>
Authored: Tue Jan 7 09:45:28 2014 +0100
Committer: Piotr Zalewa <pi...@zalewa.info>
Committed: Tue Jan 7 09:45:28 2014 +0100
----------------------------------------------------------------------
src/firefoxos/ContactsProxy.js | 35 ++++++++++++++++++++++++++---------
1 file changed, 26 insertions(+), 9 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cordova-plugin-contacts/blob/4ca5d1b1/src/firefoxos/ContactsProxy.js
----------------------------------------------------------------------
diff --git a/src/firefoxos/ContactsProxy.js b/src/firefoxos/ContactsProxy.js
index c24ad78..354a746 100644
--- a/src/firefoxos/ContactsProxy.js
+++ b/src/firefoxos/ContactsProxy.js
@@ -142,15 +142,6 @@ mozContact.prototype.updateFromCordova = function(contact) {
if (contact.note) {
this.note = [contact.note];
}
- /* Find out how to translate these parameters
- // photo: Blob
- // url: Array with metadata (?)
- // impp: exportIM(contact.ims), TODO: find the moz impp definition
- // anniversary
- // sex
- // genderIdentity
- // key
- */
}
@@ -207,6 +198,20 @@ Contact.prototype.updateFromMozilla = function(moz) {
return organizations;
}
+ function createFormatted(cordova) {
+ var f = '';
+ if (cordova.name.givenName) {
+ f = cordova.name.givenName;
+ }
+ if (cordova.name.familyName) {
+ if (f) {
+ f += ' ';
+ }
+ f += cordova.name.familyName;
+ }
+ return f;
+ }
+
if (moz.id) {
this.id = moz.id;
@@ -260,6 +265,18 @@ Contact.prototype.updateFromMozilla = function(moz) {
// XXX: organizations array is created from org and jobTitle
this.organizations = createOrganizations(moz.org, moz.jobTitle);
}
+ // construct a read-only formatted value
+ this.name.formatted = createFormatted(this);
+
+ /* Find out how to translate these parameters
+ // photo: Blob
+ // url: Array with metadata (?)
+ // impp: exportIM(contact.ims), TODO: find the moz impp definition
+ // anniversary
+ // sex
+ // genderIdentity
+ // key
+ */
}