diff --git a/apps/contacts/ajax/addcontact.php b/apps/contacts/ajax/addcontact.php index 4bd3df54e3..c39d75eff8 100644 --- a/apps/contacts/ajax/addcontact.php +++ b/apps/contacts/ajax/addcontact.php @@ -24,11 +24,11 @@ require_once('../../../lib/base.php'); function bailOut($msg) { OC_JSON::error(array('data' => array('message' => $msg))); - OC_Log::write('contacts','ajax/saveproperty.php: '.$msg, OC_Log::DEBUG); + OC_Log::write('contacts','ajax/addcontact.php: '.$msg, OC_Log::DEBUG); exit(); } function debug($msg) { - OC_Log::write('contacts','ajax/saveproperty.php: '.$msg, OC_Log::DEBUG); + OC_Log::write('contacts','ajax/addcontact.php: '.$msg, OC_Log::DEBUG); } foreach ($_POST as $key=>$element) { debug('_POST: '.$key.'=>'.$element); @@ -44,11 +44,13 @@ $addressbook = OC_Contacts_App::getAddressbook( $aid ); $fn = trim($_POST['fn']); $n = trim($_POST['n']); +debug('N: '.$n); +debug('FN: '.$fn); $vcard = new OC_VObject('VCARD'); $vcard->setUID(); -$vcard->setString('N',$n); $vcard->setString('FN',$fn); +$vcard->setString('N',$n); $id = OC_Contacts_VCard::add($aid,$vcard->serialize()); if(!$id) { diff --git a/apps/contacts/ajax/editname.php b/apps/contacts/ajax/editname.php index 6205cc74b0..c7a7bcdeaf 100644 --- a/apps/contacts/ajax/editname.php +++ b/apps/contacts/ajax/editname.php @@ -9,14 +9,23 @@ require_once('../../../lib/base.php'); OC_JSON::checkLoggedIn(); OC_JSON::checkAppEnabled('contacts'); +function bailOut($msg) { + OC_JSON::error(array('data' => array('message' => $msg))); + OC_Log::write('contacts','ajax/editname.php: '.$msg, OC_Log::DEBUG); + exit(); +} +function debug($msg) { + OC_Log::write('contacts','ajax/editname.php: '.$msg, OC_Log::DEBUG); +} +foreach ($_GET as $key=>$element) { + debug('_GET: '.$key.'=>'.$element); +} $tmpl = new OC_TEMPLATE("contacts", "part.edit_name_dialog"); $id = $_GET['id']; if($id) { $vcard = OC_Contacts_App::getContactVCard($id); - - $name = array('', '', '', '', ''); if($vcard->__isset('N')) { $property = $vcard->__get('N'); diff --git a/apps/contacts/ajax/newcontact.php b/apps/contacts/ajax/newcontact.php index 3d1a8e7453..fcfd12ca80 100644 --- a/apps/contacts/ajax/newcontact.php +++ b/apps/contacts/ajax/newcontact.php @@ -24,11 +24,11 @@ require_once('../../../lib/base.php'); function bailOut($msg) { OC_JSON::error(array('data' => array('message' => $msg))); - OC_Log::write('contacts','ajax/saveproperty.php: '.$msg, OC_Log::DEBUG); + OC_Log::write('contacts','ajax/newcontact.php: '.$msg, OC_Log::DEBUG); exit(); } function debug($msg) { - OC_Log::write('contacts','ajax/saveproperty.php: '.$msg, OC_Log::DEBUG); + OC_Log::write('contacts','ajax/newcontact.php: '.$msg, OC_Log::DEBUG); } foreach ($_POST as $key=>$element) { debug('_POST: '.$key.'=>'.$element); @@ -47,10 +47,14 @@ $maxUploadFilesize = min($upload_max_filesize, $post_max_size); $freeSpace=OC_Filesystem::free_space('/'); $freeSpace=max($freeSpace,0); $maxUploadFilesize = min($maxUploadFilesize ,$freeSpace); +$adr_types = OC_Contacts_App::getTypesOfProperty('ADR'); +$phone_types = OC_Contacts_App::getTypesOfProperty('TEL'); $tmpl = new OC_Template('contacts','part.contact'); $tmpl->assign('uploadMaxFilesize', $maxUploadFilesize); $tmpl->assign('uploadMaxHumanFilesize', OC_Helper::humanFileSize($maxUploadFilesize)); +$tmpl->assign('adr_types',$adr_types); +$tmpl->assign('phone_types',$phone_types); $tmpl->assign('addressbooks',$addressbooks); $tmpl->assign('id',''); $page = $tmpl->fetchPage(); diff --git a/apps/contacts/css/contacts.css b/apps/contacts/css/contacts.css index a48533f85a..d90e93f64e 100644 --- a/apps/contacts/css/contacts.css +++ b/apps/contacts/css/contacts.css @@ -16,7 +16,7 @@ #contacts_propertymenu li:hover { background-color: #1d2d44; } #contacts_propertymenu li a:hover { color: #fff } #actionbar { height: 30px; width: 200px; position: fixed; right: 0px; top: 75px; margin: 0 0 0 0; padding: 0 0 0 0;} -#card { /*max-width: 70em;*/ border: thin solid lightgray; display: block; } +#card { /*max-width: 70em; border: thin solid lightgray; display: block;*/ } #firstrun { /*border: thin solid lightgray;*/ width: 80%; margin: 5em auto auto auto; text-align: center; font-weight:bold; font-size:1.5em; color:#777;} #firstrun #selections { /*border: thin solid lightgray;*/ font-size:0.8em; width: 100%; margin: 2em auto auto auto; clear: both; } diff --git a/apps/contacts/js/contacts.js b/apps/contacts/js/contacts.js index b66dd6949d..40f049de3b 100644 --- a/apps/contacts/js/contacts.js +++ b/apps/contacts/js/contacts.js @@ -67,25 +67,34 @@ Contacts={ propertyTypeFor:function(obj) { return $(obj).parents('.propertycontainer').first().data('element'); }, + showHideContactInfo:function() { + var show = ($('#emaillist li[class*="propertycontainer"]').length > 0 || $('#phonelist li[class*="propertycontainer"]').length > 0 || $('#addressdisplay dl[class*="propertycontainer"]').length > 0); + console.log('showHideContactInfo: ' + show); + if(show) { + $('#contact_communication').show(); + } else { + $('#contact_communication').hide(); + } + }, checkListFor:function(obj) { var type = $(obj).parents('.propertycontainer').first().data('element'); console.log('checkListFor: ' + type); switch (type) { case 'EMAIL': console.log('emails: '+$('#emaillist>li').length); - if($('#emaillist>li').length == 1) { + if($('#emaillist li[class*="propertycontainer"]').length == 0) { $('#emails').hide(); } break; case 'TEL': console.log('phones: '+$('#phonelist>li').length); - if($('#phonelist>li').length == 1) { + if($('#phonelist li[class*="propertycontainer"]').length == 0) { $('#phones').hide(); } break; case 'ADR': console.log('addresses: '+$('#addressdisplay>dl').length); - if($('#addressdisplay>dl').length == 1) { + if($('#addressdisplay dl[class*="propertycontainer"]').length == 0) { $('#addresses').hide(); } break; @@ -317,7 +326,7 @@ Contacts={ } }, populateNameFields:function() { - 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; //console.log('splitting: ' + this.data.N[0]['value']); @@ -366,6 +375,8 @@ Contacts={ editNew:function(){ // add a new contact //Contacts.UI.notImplemented(); //return false; + this.id = ''; this.fn = ''; this.fullname = ''; this.givname = ''; this.famname = ''; this.addname = ''; this.honpre = ''; this.honsuf = ''; + $.getJSON('ajax/newcontact.php',{},function(jsondata){ if(jsondata.status == 'success'){ @@ -394,7 +405,31 @@ Contacts={ */ if (jsondata.status == 'success'){ $('#rightcontent').data('id',jsondata.data.id); - id = jsondata.data.id; + var id = jsondata.data.id; + $.getJSON('ajax/contactdetails.php',{'id':id},function(jsondata){ + if(jsondata.status == 'success'){ + Contacts.UI.loadHandlers(); + Contacts.UI.Card.loadContact(jsondata.data); + $('#leftcontent .active').removeClass('active'); + var item = '