[Pkg-mozext-commits] [gcontactsync] 49/88: Issue #28 - Provide more people fields. Added a hidden pref to control how many fields are present.

David Prévot taffit at moszumanska.debian.org
Thu Sep 18 20:52:29 UTC 2014


This is an automated email from the git hooks/post-receive script.

taffit pushed a commit to branch master
in repository gcontactsync.

commit 33e008b0c0b22e4276b16c981f36c3372ed19488
Author: Josh Geenen <joshgeenen at gmail.com>
Date:   Mon May 26 17:18:44 2014 -0500

    Issue #28 - Provide more people fields. Added a hidden pref to control how many fields are present.
---
 src/content/ABOverlay.js                 | 13 +++++++------
 src/content/CardDialogOverlay.js         | 26 ++++++++++++++++----------
 src/content/CardDialogOverlay.xul        | 27 ++-------------------------
 src/content/ContactConverter.js          | 18 ++++++++++--------
 src/content/Preferences.js               |  3 ++-
 src/defaults/preferences/gContactSync.js |  2 ++
 6 files changed, 39 insertions(+), 50 deletions(-)

diff --git a/src/content/ABOverlay.js b/src/content/ABOverlay.js
index 21deb78..5c497da 100644
--- a/src/content/ABOverlay.js
+++ b/src/content/ABOverlay.js
@@ -303,12 +303,12 @@ com.gContactSync.ABOverlay = {
  
       // Other section (relations)
       var visible = !cvData.cvhOther.getAttribute("collapsed");
+      var relationsArray = [];
+      for (var j = 0; j < com.gContactSync.Preferences.mSyncPrefs.numRelations.value; ++j) {
+        relationsArray.push("Relation" + j);
+      }
       // Relation fields
-      visible = com.gContactSync.ABOverlay.getVisible(aCard, ["Relation0",
-                                                              "Relation1",
-                                                              "Relation2",
-                                                              "Relation3"],
-                                                      visible, true);
+      visible = com.gContactSync.ABOverlay.getVisible(aCard, relationsArray, visible, true);
 
       var day = aCard.getProperty("AnniversaryDay", null);
       var month = aCard.getProperty("AnniversaryMonth", null);
@@ -495,10 +495,11 @@ com.gContactSync.ABOverlay = {
     var otherVbox = document.createElement("vbox");
     otherVbox.setAttribute("flex", "1");
     // Relation fields)
-    for (var i = 0; i < 4; i++) {
+    for (var i = 0; i < com.gContactSync.Preferences.mSyncPrefs.numRelations.value; ++i) {
       cvData["cvRelation" + i] = com.gContactSync.ABOverlay.makeDescElement("Relation" + i, "CardViewText");
       otherVbox.appendChild(cvData["cvRelation" + i]);
     }
+    vbox.appendChild(otherVbox);
 
     // Anniversary
     cvData.cvAnniversary = com.gContactSync.ABOverlay.makeDescElement("Anniversary", "CardViewText");
diff --git a/src/content/CardDialogOverlay.js b/src/content/CardDialogOverlay.js
index ec06491..75bfca4 100644
--- a/src/content/CardDialogOverlay.js
+++ b/src/content/CardDialogOverlay.js
@@ -63,14 +63,6 @@ com.gContactSync.gAttributes = {
   "PagerNumberType":      {},
   "HomeFaxNumberType":    {},
   "OtherNumberType":      {},
-  "Relation0":            {},
-  "Relation0Type":        {},
-  "Relation1":            {},
-  "Relation1Type":        {},
-  "Relation2":            {},
-  "Relation2Type":        {},
-  "Relation3":            {},
-  "Relation3Type":        {},
   "WebPage1Type":         {},
   "WebPage2Type":         {}
 };
@@ -99,6 +91,10 @@ com.gContactSync.CardDialogOverlay = {
       com.gContactSync.CardDialogOverlay.mLoadNumber++;
       return;
     }
+    for (var i = 0; i < com.gContactSync.Preferences.mSyncPrefs.numRelations.value; ++i) {
+      com.gContactSync.gAttributes["Relation" + i] = "";
+      com.gContactSync.gAttributes["Relation" + i + "Type"] = "";
+    }
 
     try {
       // QI the card if it doesn't have the getProperty method
@@ -279,8 +275,18 @@ com.gContactSync.CardDialogOverlay = {
           for (i in com.gContactSync.gdata.contacts.RELATION_TYPES) {
             relationTypes.push(i);
           }
-          for (i = 0; i < 4; i++) {
-            var relationBox = document.getElementById("Relation" + i + "Box");
+          var groupbox = document.getElementById("relationsGroupBox");
+          for (var i = 0; i < com.gContactSync.Preferences.mSyncPrefs.numRelations.value; i++) {
+            var relationBox = document.createElement("hbox");
+            var spacer = document.createElement("spacer");
+            spacer.setAttribute("flex", 1);
+            relationBox.appendChild(spacer);
+            var relationText = document.createElement("textbox");
+            relationText.id = "Relation" + i;
+            relationText.setAttribute("class", "uri-element");
+            relationText.setAttribute("width", "180px");
+            relationBox.appendChild(relationText);
+            groupbox.appendChild(relationBox);
             this.addMenuItems(relationBox, relationTypes, "Relation" + i + "Type", "", com.gContactSync.StringBundle.getStr("relationWidth"));
           }
         }
diff --git a/src/content/CardDialogOverlay.xul b/src/content/CardDialogOverlay.xul
index 9caa1a1..09c9ca4 100644
--- a/src/content/CardDialogOverlay.xul
+++ b/src/content/CardDialogOverlay.xul
@@ -129,32 +129,9 @@
       </vbox>
       <vbox id="relationFields" hidden="true">
           <vbox id="gcontactSyncFields2" class="alignBoxWithFieldset" align="left">
-            <groupbox flex="1">
+            <groupbox flex="1" id="relationsGroupBox">
               <caption label="&relations.box;"/>
-              <hbox id="Relation0Box">
-                <spacer flex="1"/>
-                <hbox>
-                  <textbox id="Relation0" class="uri-element" width="180px"/>
-                </hbox>
-              </hbox>
-              <hbox id="Relation1Box">
-                <spacer flex="1"/>
-                <hbox>
-                  <textbox id="Relation1" class="uri-element" width="180px"/>
-                </hbox>
-              </hbox>
-              <hbox id="Relation2Box">
-                <spacer flex="1"/>
-                <hbox>
-                  <textbox id="Relation2"  class="uri-element" width="180px"/>
-                </hbox>
-              </hbox>
-              <hbox id="Relation3Box">
-                <spacer flex="1"/>
-                <hbox>
-                  <textbox id="Relation3" class="uri-element" width="180px"/>
-                </hbox>
-              </hbox>
+              <!-- Contents are added by CardDialogOverlay.js -->
             </groupbox>
           </vbox>
       </vbox>
diff --git a/src/content/ContactConverter.js b/src/content/ContactConverter.js
index 4278cfd..165748d 100644
--- a/src/content/ContactConverter.js
+++ b/src/content/ContactConverter.js
@@ -69,9 +69,7 @@ com.gContactSync.ContactConverter = {
     "HomeFaxNumber", "OtherNumber", "ThirdEmail", "FourthEmail",
     "PrimaryEmailType", "SecondEmailType", "ThirdEmailType", "FourthEmailType",
     "HomePhoneType", "WorkPhoneType", "FaxNumberType", "CellularNumberType",
-    "PagerNumberType", "HomeFaxNumberType", "OtherNumberType", "Relation0",
-    "Relation0Type", "Relation1", "Relation1Type", "Relation2",
-    "Relation2Type", "Relation3", "Relation3Type", "CompanySymbol",
+    "PagerNumberType", "HomeFaxNumberType", "OtherNumberType", "CompanySymbol",
     "JobDescription", "WebPage1Type", "WebPage2Type"
   ],
   /** Stores whether this object has been initialized yet */
@@ -131,11 +129,6 @@ com.gContactSync.ContactConverter = {
       new com.gContactSync.ConverterElement("PhotoURL", "PhotoURL", 0),
       new com.gContactSync.ConverterElement("SelfURL",  "SelfURL",  0),
       new com.gContactSync.ConverterElement("EditURL",  "EditURL",  0),
-      // Relation fields
-      new com.gContactSync.ConverterElement("relation", "Relation0", 0, ""),
-      new com.gContactSync.ConverterElement("relation", "Relation1", 1, ""),
-      new com.gContactSync.ConverterElement("relation", "Relation2", 2, ""),
-      new com.gContactSync.ConverterElement("relation", "Relation3", 3, ""),
       // Websites
       new com.gContactSync.ConverterElement("website",   "WebPage2", 0, "home"),
       new com.gContactSync.ConverterElement("website",   "WebPage1", 1, "work"),
@@ -157,6 +150,10 @@ com.gContactSync.ContactConverter = {
       this.mConverterArr.push(new com.gContactSync.ConverterElement("postcode", "WorkZipCode",     0, "work"));
       this.mConverterArr.push(new com.gContactSync.ConverterElement("country",  "WorkCountry",     0, "work"));
     }
+    for (var i = 0; i < com.gContactSync.Preferences.mSyncPrefs.numRelations.value; i++) {
+      // Relation fields
+      this.mConverterArr.push(new com.gContactSync.ConverterElement("relation", "Relation" + i, i, ""));
+    }
     this.mInitialized = true;
   },
   /**
@@ -168,8 +165,13 @@ com.gContactSync.ContactConverter = {
     if (!this.mInitialized)
       this.init();
     var arr = this.mAddedAttributes.slice();
+    for (var i = 0; i < com.gContactSync.Preferences.mSyncPrefs.numRelations.value; ++i) {
+      arr.push("Relation" + i);
+      arr.push("Relation" + i + "Type");
+    }
     if (aIncludeURLs)
       arr = arr.concat("PhotoURL", "SelfURL", "EditURL", "GoogleID");
+    com.gContactSync.LOGGER.VERBOSE_LOG(arr);
     return arr;
   },
   /**
diff --git a/src/content/Preferences.js b/src/content/Preferences.js
index 51f2288..93ff230 100644
--- a/src/content/Preferences.js
+++ b/src/content/Preferences.js
@@ -209,7 +209,8 @@ com.gContactSync.Preferences = {
     v04UpgradeNeeded:         new com.gContactSync.Pref("v04UpgradeNeeded",         "bool", false),
     v04RCUpgradeNeeded:       new com.gContactSync.Pref("v04RCUpgradeNeeded",       "bool", false),
     httpRequestTimeout:       new com.gContactSync.Pref("httpRequestTimeout",        "int", 0),
-    httpRequestDelay:         new com.gContactSync.Pref("httpRequestDelay",          "int", 120)
+    httpRequestDelay:         new com.gContactSync.Pref("httpRequestDelay",          "int", 120),
+    numRelations:             new com.gContactSync.Pref("numRelations",              "int", 6)
   },
   /**
    * Gets a preference given its branch, name, and type
diff --git a/src/defaults/preferences/gContactSync.js b/src/defaults/preferences/gContactSync.js
index 3496fe5..dd6958e 100644
--- a/src/defaults/preferences/gContactSync.js
+++ b/src/defaults/preferences/gContactSync.js
@@ -92,6 +92,8 @@ pref("extensions.gContactSync.v04RCUpgradeNeeded", false);
 pref("extensions.gContactSync.httpRequestTimeout", 0);
 // Delay between HTTP requests to mitigate 503 errors.
 pref("extensions.gContactSync.httpRequestDelay", 120);
+// Number of relation/people fields to show
+pref("extensions.gContactSync.numRelations", 6);
 // extended properties to sync
 pref("extensions.gContactSync.extended1", "Custom1");
 pref("extensions.gContactSync.extended2", "Custom2");

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-mozext/gcontactsync.git



More information about the Pkg-mozext-commits mailing list