Bug 455797 - "birthday picker doesn't let me enter certain dates, resets day and year", also allow LDAP and LDIF import/export to work correctly. r=Standard8,sr=Neil. a=KaiRo for SM2a1.
This commit is contained in:
Родитель
76b777530f
Коммит
d0b8b3d322
|
@ -407,24 +407,24 @@ function GetCardValues(cardproperty, doc)
|
||||||
|
|
||||||
// get the month of the year (1 - 12)
|
// get the month of the year (1 - 12)
|
||||||
var month = cardproperty.getProperty("BirthMonth", null);
|
var month = cardproperty.getProperty("BirthMonth", null);
|
||||||
// set the datepicker's month and prepend a zero if necessary
|
if (month > 0 && month < 13)
|
||||||
if (month) {
|
birthday.month = month - 1;
|
||||||
birthday.month = parseInt(month) - 1;
|
else
|
||||||
if (month.length < 2)
|
birthday.monthField.value = null;
|
||||||
month = "0" + month;
|
|
||||||
}
|
|
||||||
birthday.monthField.value = month;
|
|
||||||
|
|
||||||
// get the date of the month (1 - 31)
|
// get the date of the month (1 - 31)
|
||||||
var date = cardproperty.getProperty("BirthDay", null);
|
var date = cardproperty.getProperty("BirthDay", null);
|
||||||
birthday.dateField.value = date;
|
if (date > 0 && date < 32)
|
||||||
|
birthday.date = date;
|
||||||
|
else
|
||||||
|
birthday.dateField.value = null;
|
||||||
|
|
||||||
// get the year
|
// get the year
|
||||||
var year = cardproperty.getProperty("BirthYear", null);
|
var year = cardproperty.getProperty("BirthYear", null);
|
||||||
var birthYear = doc.getElementById("BirthYear");
|
var birthYear = doc.getElementById("BirthYear");
|
||||||
// set the year in the datepicker to the stored year
|
// set the year in the datepicker to the stored year
|
||||||
// if the year isn't present, default to 2000 (a leap year)
|
// if the year isn't present, default to 2000 (a leap year)
|
||||||
birthday.year = year ? year : kDefaultYear;
|
birthday.year = year && year < 10000 && year > 0 ? year : kDefaultYear;
|
||||||
birthYear.value = year;
|
birthYear.value = year;
|
||||||
|
|
||||||
// get the current age
|
// get the current age
|
||||||
|
@ -484,19 +484,10 @@ function CheckAndSetCardValues(cardproperty, doc, check)
|
||||||
var birthDay = birthdayElem.dateField.value;
|
var birthDay = birthdayElem.dateField.value;
|
||||||
var birthYear = doc.getElementById("BirthYear").value;
|
var birthYear = doc.getElementById("BirthYear").value;
|
||||||
|
|
||||||
// set or delete the birth day, month, and year properties, if necessary
|
// set the birth day, month, and year properties
|
||||||
if (birthDay)
|
cardproperty.setProperty("BirthDay", birthDay);
|
||||||
cardproperty.setProperty("BirthDay", birthDay);
|
cardproperty.setProperty("BirthMonth", birthMonth);
|
||||||
else if(cardproperty.getProperty("BirthDay", null))
|
cardproperty.setProperty("BirthYear", birthYear);
|
||||||
cardproperty.deleteProperty("BirthDay");
|
|
||||||
if (birthMonth)
|
|
||||||
cardproperty.setProperty("BirthMonth", birthMonth);
|
|
||||||
else if(cardproperty.getProperty("BirthMonth", null))
|
|
||||||
cardproperty.deleteProperty("BirthMonth");
|
|
||||||
if (birthYear)
|
|
||||||
cardproperty.setProperty("BirthYear", birthYear);
|
|
||||||
else if(cardproperty.getProperty("BirthYear", null))
|
|
||||||
cardproperty.deleteProperty("BirthYear");
|
|
||||||
|
|
||||||
var popup = document.getElementById("PreferMailFormatPopup");
|
var popup = document.getElementById("PreferMailFormatPopup");
|
||||||
if (popup)
|
if (popup)
|
||||||
|
@ -783,18 +774,18 @@ function modifyDatepicker(aDatepicker) {
|
||||||
this._dateValue.setDate(0);
|
this._dateValue.setDate(0);
|
||||||
this._updateUI(this.dateField, this.date);
|
this._updateUI(this.dateField, this.date);
|
||||||
var date = this._dateValue.getDate();
|
var date = this._dateValue.getDate();
|
||||||
this.dateField.value = date < 10 ? "0" + date : date;
|
this.dateField.value = date < 10 && this.dateLeadingZero ? "0" + date : date;
|
||||||
var month = this._dateValue.getMonth() + 1;
|
var month = this._dateValue.getMonth() + 1;
|
||||||
this.monthField.value = month < 10 ? "0" + month : month;
|
this.monthField.value = month < 10 && this.monthLeadingZero ? "0" + month : month;
|
||||||
}
|
}
|
||||||
// update the date if the value isn't null
|
// update the date if the value isn't null
|
||||||
else if (aField == this.dateField && aValue != null) {
|
else if (aField == this.dateField && aValue != null) {
|
||||||
this._dateValue.setDate(aValue);
|
this._dateValue.setDate(aValue);
|
||||||
this._updateUI(this.dateField, this.date);
|
this._updateUI(this.dateField, this.date);
|
||||||
var date = this._dateValue.getDate();
|
var date = this._dateValue.getDate();
|
||||||
this.dateField.value = date < 10 ? "0" + date : date;
|
this.dateField.value = date < 10 && this.dateLeadingZero ? "0" + date : date;
|
||||||
var month = this._dateValue.getMonth() + 1;
|
var month = this._dateValue.getMonth() + 1;
|
||||||
this.monthField.value = month < 10 ? "0" + month : month;
|
this.monthField.value = month < 10 && this.monthLeadingZero ? "0" + month : month;
|
||||||
}
|
}
|
||||||
this.setAttribute("value", this.value);
|
this.setAttribute("value", this.value);
|
||||||
|
|
||||||
|
|
|
@ -318,8 +318,8 @@ function DisplayCardViewPane(realCard)
|
||||||
var month = card.getProperty("BirthMonth", null);
|
var month = card.getProperty("BirthMonth", null);
|
||||||
var year = card.getProperty("BirthYear", null);
|
var year = card.getProperty("BirthYear", null);
|
||||||
var dateStr;
|
var dateStr;
|
||||||
if (day || month) {
|
if (day > 0 && day < 32 && month > 0 && month < 13) {
|
||||||
var date = (new Date(year, parseInt(month) - 1, day));
|
var date = new Date(year, month - 1, day);
|
||||||
// if the year exists, just use Date.toLocaleString
|
// if the year exists, just use Date.toLocaleString
|
||||||
if (year)
|
if (year)
|
||||||
dateStr = date.toLocaleDateString();
|
dateStr = date.toLocaleDateString();
|
||||||
|
|
|
@ -405,24 +405,24 @@ function GetCardValues(cardproperty, doc)
|
||||||
|
|
||||||
// get the month of the year (1 - 12)
|
// get the month of the year (1 - 12)
|
||||||
var month = cardproperty.getProperty("BirthMonth", null);
|
var month = cardproperty.getProperty("BirthMonth", null);
|
||||||
// set the datepicker's month and prepend a zero if necessary
|
if (month > 0 && month < 13)
|
||||||
if (month) {
|
birthday.month = month - 1;
|
||||||
birthday.month = parseInt(month) - 1;
|
else
|
||||||
if (month.length < 2)
|
birthday.monthField.value = null;
|
||||||
month = "0" + month;
|
|
||||||
}
|
|
||||||
birthday.monthField.value = month;
|
|
||||||
|
|
||||||
// get the date of the month (1 - 31)
|
// get the date of the month (1 - 31)
|
||||||
var date = cardproperty.getProperty("BirthDay", null);
|
var date = cardproperty.getProperty("BirthDay", null);
|
||||||
birthday.dateField.value = date;
|
if (date > 0 && date < 32)
|
||||||
|
birthday.date = date;
|
||||||
|
else
|
||||||
|
birthday.dateField.value = null;
|
||||||
|
|
||||||
// get the year
|
// get the year
|
||||||
var year = cardproperty.getProperty("BirthYear", null);
|
var year = cardproperty.getProperty("BirthYear", null);
|
||||||
var birthYear = doc.getElementById("BirthYear");
|
var birthYear = doc.getElementById("BirthYear");
|
||||||
// set the year in the datepicker to the stored year
|
// set the year in the datepicker to the stored year
|
||||||
// if the year isn't present, default to 2000 (a leap year)
|
// if the year isn't present, default to 2000 (a leap year)
|
||||||
birthday.year = year ? year : kDefaultYear;
|
birthday.year = year && year < 10000 && year > 0 ? year : kDefaultYear;
|
||||||
birthYear.value = year;
|
birthYear.value = year;
|
||||||
|
|
||||||
// get the current age
|
// get the current age
|
||||||
|
@ -481,19 +481,10 @@ function CheckAndSetCardValues(cardproperty, doc, check)
|
||||||
var birthDay = birthdayElem.dateField.value;
|
var birthDay = birthdayElem.dateField.value;
|
||||||
var birthYear = doc.getElementById("BirthYear").value;
|
var birthYear = doc.getElementById("BirthYear").value;
|
||||||
|
|
||||||
// set or delete the birth day, month, and year properties, if necessary
|
// set the birth day, month, and year properties
|
||||||
if (birthDay)
|
cardproperty.setProperty("BirthDay", birthDay);
|
||||||
cardproperty.setProperty("BirthDay", birthDay);
|
cardproperty.setProperty("BirthMonth", birthMonth);
|
||||||
else if(cardproperty.getProperty("BirthDay", null))
|
cardproperty.setProperty("BirthYear", birthYear);
|
||||||
cardproperty.deleteProperty("BirthDay");
|
|
||||||
if (birthMonth)
|
|
||||||
cardproperty.setProperty("BirthMonth", birthMonth);
|
|
||||||
else if(cardproperty.getProperty("BirthMonth", null))
|
|
||||||
cardproperty.deleteProperty("BirthMonth");
|
|
||||||
if (birthYear)
|
|
||||||
cardproperty.setProperty("BirthYear", birthYear);
|
|
||||||
else if(cardproperty.getProperty("BirthYear", null))
|
|
||||||
cardproperty.deleteProperty("BirthYear");
|
|
||||||
|
|
||||||
var popup = document.getElementById("PreferMailFormatPopup");
|
var popup = document.getElementById("PreferMailFormatPopup");
|
||||||
if (popup)
|
if (popup)
|
||||||
|
@ -780,18 +771,18 @@ function modifyDatepicker(aDatepicker) {
|
||||||
this._dateValue.setDate(0);
|
this._dateValue.setDate(0);
|
||||||
this._updateUI(this.dateField, this.date);
|
this._updateUI(this.dateField, this.date);
|
||||||
var date = this._dateValue.getDate();
|
var date = this._dateValue.getDate();
|
||||||
this.dateField.value = date < 10 ? "0" + date : date;
|
this.dateField.value = date < 10 && this.dateLeadingZero ? "0" + date : date;
|
||||||
var month = this._dateValue.getMonth() + 1;
|
var month = this._dateValue.getMonth() + 1;
|
||||||
this.monthField.value = month < 10 ? "0" + month : month;
|
this.monthField.value = month < 10 && this.monthLeadingZero ? "0" + month : month;
|
||||||
}
|
}
|
||||||
// update the date if the value isn't null
|
// update the date if the value isn't null
|
||||||
else if (aField == this.dateField && aValue != null) {
|
else if (aField == this.dateField && aValue != null) {
|
||||||
this._dateValue.setDate(aValue);
|
this._dateValue.setDate(aValue);
|
||||||
this._updateUI(this.dateField, this.date);
|
this._updateUI(this.dateField, this.date);
|
||||||
var date = this._dateValue.getDate();
|
var date = this._dateValue.getDate();
|
||||||
this.dateField.value = date < 10 ? "0" + date : date;
|
this.dateField.value = date < 10 && this.dateLeadingZero ? "0" + date : date;
|
||||||
var month = this._dateValue.getMonth() + 1;
|
var month = this._dateValue.getMonth() + 1;
|
||||||
this.monthField.value = month < 10 ? "0" + month : month;
|
this.monthField.value = month < 10 && this.monthLeadingZero ? "0" + month : month;
|
||||||
}
|
}
|
||||||
this.setAttribute("value", this.value);
|
this.setAttribute("value", this.value);
|
||||||
|
|
||||||
|
|
|
@ -300,8 +300,8 @@ function DisplayCardViewPane(realCard)
|
||||||
var month = card.getProperty("BirthMonth", null);
|
var month = card.getProperty("BirthMonth", null);
|
||||||
var year = card.getProperty("BirthYear", null);
|
var year = card.getProperty("BirthYear", null);
|
||||||
var dateStr;
|
var dateStr;
|
||||||
if (day || month) {
|
if (day > 0 && day < 32 && month > 0 && month < 13) {
|
||||||
var date = (new Date(year, parseInt(month) - 1, day));
|
var date = new Date(year, month - 1, day);
|
||||||
// if the year exists, just use Date.toLocaleString
|
// if the year exists, just use Date.toLocaleString
|
||||||
if (year)
|
if (year)
|
||||||
dateStr = date.toLocaleDateString();
|
dateStr = date.toLocaleDateString();
|
||||||
|
|
|
@ -23,17 +23,17 @@ You will also need to give the AbImportHelper constructor two additional
|
||||||
parameters: the name the imported address book will have (the filename without
|
parameters: the name the imported address book will have (the filename without
|
||||||
the extension) and the name you chose for the JSON object.
|
the extension) and the name you chose for the JSON object.
|
||||||
|
|
||||||
Here is a sample unit test that doesn't check the results:
|
Here is a sample LDIF unit test that doesn't check the results:
|
||||||
function run_test()
|
function run_test()
|
||||||
{
|
{
|
||||||
var file = do_get_file("../mailnews/import/test/resources/basic_ldif_addressbook.ldif");
|
var file = do_get_file("../mailnews/import/test/resources/basic_ldif_addressbook.ldif");
|
||||||
new AbImportHelper(file, "ldif").beginImport();
|
new AbImportHelper(file, "LDIF").beginImport();
|
||||||
}
|
}
|
||||||
|
|
||||||
Here is a sample unit test that checks the results:
|
Here is a sample CSV unit test that checks the results:
|
||||||
function run_test()
|
function run_test()
|
||||||
{
|
{
|
||||||
var file = do_get_file("../mailnews/import/test/resources/basic_ldif_addressbook.ldif");
|
var file = do_get_file("../mailnews/import/test/resources/basic_csv_addressbook.csv");
|
||||||
new AbImportHelper(file, "ldif", "basic_ldif_addressbook",
|
new AbImportHelper(file, "CSV", "basic_csv_addressbook",
|
||||||
"basic_addressbook").beginImport();
|
"basic_addressbook").beginImport();
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,7 +8,7 @@
|
||||||
"LastName" : "Last",
|
"LastName" : "Last",
|
||||||
"NickName" : "Nickname",
|
"NickName" : "Nickname",
|
||||||
"SecondEmail" : "secondemail@host.invalid",
|
"SecondEmail" : "secondemail@host.invalid",
|
||||||
"_AimScreenName" : "screenname",
|
"_AimScreenName" : "screenname",
|
||||||
"PreferMailFormat" : 2,
|
"PreferMailFormat" : 2,
|
||||||
"LastModifiedDate" : 1213818826,
|
"LastModifiedDate" : 1213818826,
|
||||||
"WorkPhone" : "123-456-7890",
|
"WorkPhone" : "123-456-7890",
|
||||||
|
|
|
@ -36,6 +36,8 @@ o: Organization Name
|
||||||
mozillaWorkUrl: http://127.0.0.1
|
mozillaWorkUrl: http://127.0.0.1
|
||||||
mozillaHomeUrl: http://localhost
|
mozillaHomeUrl: http://localhost
|
||||||
birthyear: 1900
|
birthyear: 1900
|
||||||
|
birthmonth: 1
|
||||||
|
birthday: 2
|
||||||
mozillaCustom1: Custom Field 1
|
mozillaCustom1: Custom Field 1
|
||||||
mozillaCustom2: Custom Field 2
|
mozillaCustom2: Custom Field 2
|
||||||
mozillaCustom3: Custom Field 3
|
mozillaCustom3: Custom Field 3
|
||||||
|
|
|
@ -20,14 +20,13 @@ var gAbImportHelper;
|
||||||
*/
|
*/
|
||||||
function AbImportHelper(aFile, aType, aAbName, aJsonName)
|
function AbImportHelper(aFile, aType, aAbName, aJsonName)
|
||||||
{
|
{
|
||||||
helper = null;
|
gAbImportHelper = null;
|
||||||
this.mFile = aFile; // checked in the beginImport method
|
this.mFile = aFile; // checked in the beginImport method
|
||||||
this.mAbName = aAbName;
|
this.mAbName = aAbName;
|
||||||
|
|
||||||
/* Attribute notes: The attributes listed in the declaration below are
|
/* Attribute notes: The attributes listed in the declaration below are
|
||||||
* supported by all three text export/import types. AimScreenName &
|
* supported by all three text export/import types. AimScreenName and
|
||||||
* PreferMailFormat are only supported by LDIF, and BirthMonth and BirthDay
|
* PreferMailFormat are only supported by LDIF.
|
||||||
* are only supported by CSV and tab-delimited exports/imports.
|
|
||||||
* The following are not supported: anniversaryYear, anniversaryMonth,
|
* The following are not supported: anniversaryYear, anniversaryMonth,
|
||||||
* anniversaryDay, popularityIndex, isMailList, mailListURI, lastModifiedDate,
|
* anniversaryDay, popularityIndex, isMailList, mailListURI, lastModifiedDate,
|
||||||
* and allowRemoteContent
|
* and allowRemoteContent
|
||||||
|
@ -38,8 +37,8 @@ function AbImportHelper(aFile, aType, aAbName, aJsonName)
|
||||||
"CellularNumber", "HomeAddress", "HomeAddress2", "HomeCity", "HomeState",
|
"CellularNumber", "HomeAddress", "HomeAddress2", "HomeCity", "HomeState",
|
||||||
"HomeZipCode", "HomeCountry", "WorkAddress", "WorkAddress2", "WorkCity",
|
"HomeZipCode", "HomeCountry", "WorkAddress", "WorkAddress2", "WorkCity",
|
||||||
"WorkState", "WorkZipCode", "WorkCountry", "JobTitle", "Department",
|
"WorkState", "WorkZipCode", "WorkCountry", "JobTitle", "Department",
|
||||||
"Company", "BirthYear", "WebPage1", "WebPage2", "Custom1", "Custom2",
|
"Company", "BirthYear", "BirthMonth", "BirthDay", "WebPage1", "WebPage2",
|
||||||
"Custom3", "Custom4", "Notes"];
|
"Custom1", "Custom2", "Custom3", "Custom4", "Notes"];
|
||||||
// get the extra attributes supported for the given type of import
|
// get the extra attributes supported for the given type of import
|
||||||
if (aType == "LDIF")
|
if (aType == "LDIF")
|
||||||
{
|
{
|
||||||
|
@ -50,9 +49,7 @@ function AbImportHelper(aFile, aType, aAbName, aJsonName)
|
||||||
}
|
}
|
||||||
else if (aType == "CSV" || aType == "TAB")
|
else if (aType == "CSV" || aType == "TAB")
|
||||||
{
|
{
|
||||||
// CSV or TAB: add BirthMonth and BirthDay
|
this.mSupportedAttributes = supportedAttributes;
|
||||||
this.mSupportedAttributes = supportedAttributes.concat(["BirthMonth",
|
|
||||||
"BirthDay"]);
|
|
||||||
this.mLdif = false;
|
this.mLdif = false;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -232,7 +229,7 @@ AbImportHelper.prototype =
|
||||||
{
|
{
|
||||||
for (var i in aJsonCard)
|
for (var i in aJsonCard)
|
||||||
if (this.mSupportedAttributes.indexOf(i) >= 0)
|
if (this.mSupportedAttributes.indexOf(i) >= 0)
|
||||||
do_check_eq(aJsonCard[i], aCard.getProperty(i, "BAD"));
|
do_check_eq(aJsonCard[i], aCard.getProperty(i, "BAD"));
|
||||||
},
|
},
|
||||||
/**
|
/**
|
||||||
* AbImportHelper.getJsonCards
|
* AbImportHelper.getJsonCards
|
||||||
|
|
|
@ -365,6 +365,8 @@ pref("ldap_2.servers.default.attrmap._AimScreenName", "nsAIMid,nscpaimscreenname
|
||||||
pref("ldap_2.servers.default.attrmap.WebPage1", "mozillaWorkUrl,workurl");
|
pref("ldap_2.servers.default.attrmap.WebPage1", "mozillaWorkUrl,workurl");
|
||||||
pref("ldap_2.servers.default.attrmap.WebPage2", "mozillaHomeUrl,homeurl");
|
pref("ldap_2.servers.default.attrmap.WebPage2", "mozillaHomeUrl,homeurl");
|
||||||
pref("ldap_2.servers.default.attrmap.BirthYear", "birthyear");
|
pref("ldap_2.servers.default.attrmap.BirthYear", "birthyear");
|
||||||
|
pref("ldap_2.servers.default.attrmap.BirthMonth", "birthmonth");
|
||||||
|
pref("ldap_2.servers.default.attrmap.BirthDay", "birthday");
|
||||||
pref("ldap_2.servers.default.attrmap.Custom1", "mozillaCustom1,custom1");
|
pref("ldap_2.servers.default.attrmap.Custom1", "mozillaCustom1,custom1");
|
||||||
pref("ldap_2.servers.default.attrmap.Custom2", "mozillaCustom2,custom2");
|
pref("ldap_2.servers.default.attrmap.Custom2", "mozillaCustom2,custom2");
|
||||||
pref("ldap_2.servers.default.attrmap.Custom3", "mozillaCustom3,custom3");
|
pref("ldap_2.servers.default.attrmap.Custom3", "mozillaCustom3,custom3");
|
||||||
|
|
Загрузка…
Ссылка в новой задаче