1
0
mirror of https://github.com/owncloudarchive/contacts.git synced 2025-01-31 20:52:17 +01:00

Check for invalid BDAY in js. Port #194 to master

This commit is contained in:
Thomas Tanghus 2013-09-10 21:30:10 +02:00
parent 4b85277e3e
commit 6435ec0393

View File

@ -1113,25 +1113,38 @@ OC.Contacts = OC.Contacts || {};
} }
}; };
var n = this.getPreferredValue('N', ['', '', '', '', '']); var values;
//console.log('Contact.renderContact', this.data); if(this.data) {
var values = this.data var n = this.getPreferredValue('N', ['', '', '', '', '']),
? { bday = this.getPreferredValue('BDAY', '');
if(bday.length >= 10) {
try {
bday = $.datepicker.parseDate('yy-mm-dd', bday.substring(0, 10));
bday = $.datepicker.formatDate(datepickerFormatDate, bday);
} catch (e) {
var message = t('contacts', 'Error parsing birthday {bday}: {error}', {bday:bday, error: e});
console.warn(message);
bday = '';
$(document).trigger('status.contacts.error', {
status: 'error',
message: message
});
}
}
values = {
id: this.id, id: this.id,
favorite:groupprops.favorite ? 'active' : '', favorite:groupprops.favorite ? 'active' : '',
name: this.getDisplayName(), name: this.getPreferredValue('FN', ''),
n0: n[0]||'', n1: n[1]||'', n2: n[2]||'', n3: n[3]||'', n4: n[4]||'', n0: n[0]||'', n1: n[1]||'', n2: n[2]||'', n3: n[3]||'', n4: n[4]||'',
nickname: this.getPreferredValue('NICKNAME', ''), nickname: this.getPreferredValue('NICKNAME', ''),
title: this.getPreferredValue('TITLE', ''), title: this.getPreferredValue('TITLE', ''),
org: this.getPreferredValue('ORG', []).clean('').join(', '), // TODO Add parts if more than one. org: this.getPreferredValue('ORG', []).clean('').join(', '), // TODO Add parts if more than one.
bday: this.getPreferredValue('BDAY', '').length >= 10 bday: bday,
? $.datepicker.formatDate(datepickerFormatDate,
$.datepicker.parseDate('yy-mm-dd',
this.getPreferredValue('BDAY', '').substring(0, 10)))
: '',
note: this.getPreferredValue('NOTE', '') note: this.getPreferredValue('NOTE', '')
} }
: {id:'', favorite:'', name:'', nickname:'', title:'', org:'', bday:'', note:'', n0:'', n1:'', n2:'', n3:'', n4:''}; } else {
values = {id:'', favorite:'', name:'', nickname:'', title:'', org:'', bday:'', note:'', n0:'', n1:'', n2:'', n3:'', n4:''};
}
this.$fullelem = this.$fullTemplate.octemplate(values).data('contactobject', this); this.$fullelem = this.$fullTemplate.octemplate(values).data('contactobject', this);
this.$footer = this.$fullelem.find('footer'); this.$footer = this.$fullelem.find('footer');