1
0
mirror of https://github.com/owncloudarchive/contacts.git synced 2024-11-29 11:24:11 +01:00

Contacts: Hack to add structured name from formatted name.

This commit is contained in:
Thomas Tanghus 2012-05-11 01:13:19 +02:00
parent dd48fc009e
commit afe3f30dff
2 changed files with 27 additions and 12 deletions

View File

@ -443,7 +443,6 @@ Contacts={
} }
}); });
this.fn = ''; this.fullname = ''; this.givname = ''; this.famname = ''; this.addname = ''; this.honpre = ''; this.honsuf = ''; this.fn = ''; this.fullname = ''; this.givname = ''; this.famname = ''; this.addname = ''; this.honpre = ''; this.honsuf = '';
var full = '';
var narray = undefined; var narray = undefined;
if(this.data.FN) { if(this.data.FN) {
this.fn = this.data.FN[0]['value']; this.fn = this.data.FN[0]['value'];
@ -453,7 +452,6 @@ Contacts={
} }
if(this.data.N == undefined) { if(this.data.N == undefined) {
narray = [this.fn,'','','','']; // Checking for non-existing 'N' property :-P narray = [this.fn,'','','','']; // Checking for non-existing 'N' property :-P
full = this.fn;
} else { } else {
narray = this.data.N[0]['value']; narray = this.data.N[0]['value'];
} }
@ -479,7 +477,6 @@ Contacts={
} }
$('#n').html(this.fullname); $('#n').html(this.fullname);
$('#fn_select option').remove(); $('#fn_select option').remove();
$('#fn_select').combobox('value', this.fn);
var names = [this.fullname, this.givname + ' ' + this.famname, this.famname + ' ' + this.givname, this.famname + ', ' + this.givname]; var names = [this.fullname, this.givname + ' ' + this.famname, this.famname + ' ' + this.givname, this.famname + ', ' + this.givname];
if(this.data.ORG) { if(this.data.ORG) {
names[names.length]=this.data.ORG[0].value; names[names.length]=this.data.ORG[0].value;
@ -489,6 +486,7 @@ Contacts={
.append($('<option></option>') .append($('<option></option>')
.text(value)); .text(value));
}); });
$('#fn_select').combobox('value', this.fn);
$('#contact_identity').find('*[data-element="N"]').data('checksum', this.data.N[0]['checksum']); $('#contact_identity').find('*[data-element="N"]').data('checksum', this.data.N[0]['checksum']);
if(this.data.FN) { if(this.data.FN) {
$('#contact_identity').find('*[data-element="FN"]').data('checksum', this.data.FN[0]['checksum']); $('#contact_identity').find('*[data-element="FN"]').data('checksum', this.data.FN[0]['checksum']);
@ -564,6 +562,22 @@ Contacts={
var checksum = container.data('checksum'); var checksum = container.data('checksum');
var name = container.data('element'); var name = container.data('element');
var fields = container.find('input.contacts_property,select.contacts_property').serializeArray(); var fields = container.find('input.contacts_property,select.contacts_property').serializeArray();
switch(name) {
case 'FN':
var nempty = true;
for(var i in Contacts.UI.Card.data.N[0]['value']) {
if(Contacts.UI.Card.data.N[0]['value'][i] != '') {
nempty = false;
break;
}
}
if(nempty) {
$('#n').val(fields[0].value + ';;;;');
Contacts.UI.Card.data.N[0]['value'] = Array(fields[0].value, '', '', '', '');
setTimeout(function() {Contacts.UI.Card.saveProperty($('#n'))}, 500);
}
break;
}
var q = container.find('input.contacts_property,select.contacts_property,textarea.contacts_property').serialize(); var q = container.find('input.contacts_property,select.contacts_property,textarea.contacts_property').serialize();
if(q == '' || q == undefined) { if(q == '' || q == undefined) {
OC.dialogs.alert(t('contacts', 'Couldn\'t serialize elements.'), t('contacts', 'Error')); OC.dialogs.alert(t('contacts', 'Couldn\'t serialize elements.'), t('contacts', 'Error'));

View File

@ -241,15 +241,6 @@ class OC_Contacts_VCard{
if(self::trueUID($aid, $uid)) { if(self::trueUID($aid, $uid)) {
$vcard->setString('UID', $uid); $vcard->setString('UID', $uid);
} }
$vcard->setString('VERSION','3.0');
// Add product ID is missing.
$prodid = trim($vcard->getAsString('PRODID'));
if(!$prodid) {
$appinfo = OCP\App::getAppInfo('contacts');
$appversion = OCP\App::getAppVersion('contacts');
$prodid = '-//ownCloud//NONSGML '.$appinfo['name'].' '.$appversion.'//EN';
$vcard->setString('PRODID', $prodid);
}
$now = new DateTime; $now = new DateTime;
$vcard->setString('REV', $now->format(DateTime::W3C)); $vcard->setString('REV', $now->format(DateTime::W3C));
} }
@ -272,6 +263,16 @@ class OC_Contacts_VCard{
self::updateValuesFromAdd($aid, $card); self::updateValuesFromAdd($aid, $card);
} }
$card->setString('VERSION','3.0');
// Add product ID is missing.
$prodid = trim($card->getAsString('PRODID'));
if(!$prodid) {
$appinfo = OCP\App::getAppInfo('contacts');
$appversion = OCP\App::getAppVersion('contacts');
$prodid = '-//ownCloud//NONSGML '.$appinfo['name'].' '.$appversion.'//EN';
$card->setString('PRODID', $prodid);
}
$fn = $card->getAsString('FN'); $fn = $card->getAsString('FN');
if (empty($fn)) { if (empty($fn)) {
$fn = ''; $fn = '';