(feat) added date picker in contact editor + now handle correctly birthday

This commit is contained in:
Ludovic Marcotte
2015-08-20 10:29:47 -04:00
parent da81f7bc58
commit 65525dd33b
6 changed files with 48 additions and 14 deletions
@@ -176,6 +176,8 @@
if (index > -1 && this[attribute].length > index) {
this[attribute].splice(index, 1);
}
else
delete this[attribute];
}
else {
// No arguments -- delete card
@@ -274,8 +276,16 @@
return fullname;
};
/**
* @function $birthday
* @memberof Card.prototype
* @returns the formatted birthday object
*/
Card.prototype.$birthday = function() {
return new Date(this.birthday * 1000);
if (this.birthday) {
return [this.birthday.getFullYear(), this.birthday.getMonth() + 1, this.birthday.getDate()].join('/');
}
return '';
};
Card.prototype.$isCard = function() {
@@ -481,6 +491,13 @@
card[key] = value;
}
});
// We convert back our birthday object
if (card.birthday)
card.birthday = card.birthday.getTime()/1000;
else
card.birthday = 0;
return card;
};
@@ -21,6 +21,7 @@
vm.categories = {};
vm.userFilterResults = [];
vm.addOrgUnit = addOrgUnit;
vm.addBirthday = addBirthday;
vm.addEmail = addEmail;
vm.addPhone = addPhone;
vm.addUrl = addUrl;
@@ -37,6 +38,9 @@
var i = vm.card.$addOrgUnit('');
focus('orgUnit_' + i);
}
function addBirthday() {
vm.card.birthday = new Date();
}
function addEmail() {
var i = vm.card.$addEmail('');
focus('email_' + i);