JS Card model: initialize birthday as Date object

This commit is contained in:
Francis Lachapelle 2015-03-20 11:31:50 -04:00
parent a3aaf36477
commit 3864264787

View file

@ -61,7 +61,6 @@
.directive('sgAddress', function() { .directive('sgAddress', function() {
return { return {
restrict: 'A', restrict: 'A',
replace: true,
scope: { data: '=sgAddress' }, scope: { data: '=sgAddress' },
controller: ['$scope', function($scope) { controller: ['$scope', function($scope) {
$scope.addressLines = function(data) { $scope.addressLines = function(data) {
@ -99,7 +98,7 @@
/** /**
* @memberof Card * @memberof Card
* @desc Unwrap to a collection of Card instances. * @desc Unwrap to a collection of Card instances.
* @param {Object} futureCardData * @param {object} futureCardData
*/ */
Card.$unwrapCollection = function(futureCardData) { Card.$unwrapCollection = function(futureCardData) {
var collection = {}; var collection = {};
@ -411,7 +410,7 @@
* @function $unwrap * @function $unwrap
* @memberof Card.prototype * @memberof Card.prototype
* @desc Unwrap a promise and make a copy of the resolved data. * @desc Unwrap a promise and make a copy of the resolved data.
* @param {Object} futureCardData - a promise of the Card's data * @param {object} futureCardData - a promise of the Card's data
*/ */
Card.prototype.$unwrap = function(futureCardData) { Card.prototype.$unwrap = function(futureCardData) {
var _this = this; var _this = this;
@ -429,6 +428,9 @@
if (o.email) o.emails = [{value: o.email}]; if (o.email) o.emails = [{value: o.email}];
_this.refs[i] = new Card(o); _this.refs[i] = new Card(o);
}); });
if (_this.birthday) {
_this.birthday = new Date(_this.birthday * 1000);
}
// Make a copy of the data for an eventual reset // Make a copy of the data for an eventual reset
_this.$shadowData = _this.$omit(true); _this.$shadowData = _this.$omit(true);
}); });
@ -439,7 +441,7 @@
* @function $omit * @function $omit
* @memberof Card.prototype * @memberof Card.prototype
* @desc Return a sanitized object used to send to the server. * @desc Return a sanitized object used to send to the server.
* @param {Boolean} [deep] - make a deep copy if true * @param {boolean} [deep] - make a deep copy if true
* @return an object literal copy of the Card instance * @return an object literal copy of the Card instance
*/ */
Card.prototype.$omit = function(deep) { Card.prototype.$omit = function(deep) {