From 31dab0372dd0d9b7a7b4b1e27faeaaf89c420ef3 Mon Sep 17 00:00:00 2001 From: Thomas Tanghus Date: Tue, 14 Feb 2012 13:57:11 +0100 Subject: [PATCH] Added some fixes for what to show when address books are (de)selected, all contacts deleted etc. Still need some cleaning up. --- apps/contacts/ajax/loadintro.php | 4 +-- apps/contacts/css/contacts.css | 3 ++- apps/contacts/js/contacts.js | 45 +++++++++++++++++++++++++++++++- 3 files changed, 48 insertions(+), 4 deletions(-) diff --git a/apps/contacts/ajax/loadintro.php b/apps/contacts/ajax/loadintro.php index d3249c19107..8e5673655a1 100644 --- a/apps/contacts/ajax/loadintro.php +++ b/apps/contacts/ajax/loadintro.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/newcontact.php: '.$msg, OC_Log::DEBUG); + OC_Log::write('contacts','ajax/loadintro.php: '.$msg, OC_Log::DEBUG); exit(); } function debug($msg) { - OC_Log::write('contacts','ajax/newcontact.php: '.$msg, OC_Log::DEBUG); + OC_Log::write('contacts','ajax/loadintro.php: '.$msg, OC_Log::DEBUG); } // foreach ($_POST as $key=>$element) { // debug('_POST: '.$key.'=>'.$element); diff --git a/apps/contacts/css/contacts.css b/apps/contacts/css/contacts.css index 86322a2cc2a..460859fae17 100644 --- a/apps/contacts/css/contacts.css +++ b/apps/contacts/css/contacts.css @@ -77,7 +77,8 @@ dl.form .delete { background:url('../../../core/img/actions/delete.svg') no-repeat center; } .edit { background:url('../../../core/img/actions/rename.svg') no-repeat center; } .mail { background:url('../../../core/img/actions/mail.svg') no-repeat center; } -.globe { background:url('../img/globe.svg') no-repeat center; } +/*.globe { background:url('../img/globe.svg') no-repeat center; }*/ +.globe { background:url('../../../core/img/actions/public.svg') no-repeat center; } #messagebox_msg { font-weight: bold; font-size: 1.2em; } diff --git a/apps/contacts/js/contacts.js b/apps/contacts/js/contacts.js index 6effbdd3ee4..9e3faec192a 100644 --- a/apps/contacts/js/contacts.js +++ b/apps/contacts/js/contacts.js @@ -251,6 +251,44 @@ Contacts={ honpre:'', honsuf:'', data:undefined, + update:function() { + // Make sure proper DOM is loaded. + console.log('Card.update(), #n: ' + $('#n').length); + console.log('Card.update(), #contacts: ' + $('#contacts li').length); + if($('#n').length == 0 && $('#contacts li').length > 0) { + $.getJSON(OC.filePath('contacts', 'ajax', 'loadcard.php'),{},function(jsondata){ + if(jsondata.status == 'success'){ + $('#rightcontent').html(jsondata.data.page); + Contacts.UI.loadHandlers(); + if($('#contacts li').length > 0) { + var firstid = $('#contacts li:first-child').data('id'); + console.log('trying to load: ' + firstid); + $.getJSON(OC.filePath('contacts', 'ajax', 'contactdetails.php'),{'id':firstid},function(jsondata){ + if(jsondata.status == 'success'){ + Contacts.UI.Card.loadContact(jsondata.data); + } else{ + Contacts.UI.messageBox(t('contacts', 'Error'), jsondata.data.message); + } + }); + } + } else{ + Contacts.UI.messageBox(t('contacts', 'Error'), jsondata.data.message); + } + }); + } + if($('#contacts li').length == 0) { + // load intro page + $.getJSON(OC.filePath('contacts', 'ajax', 'loadintro.php'),{},function(jsondata){ + if(jsondata.status == 'success'){ + id = ''; + $('#rightcontent').data('id',''); + $('#rightcontent').html(jsondata.data.page); + } else { + Contacts.UI.messageBox(t('contacts', 'Error'), jsondata.data.message); + } + }); + } + }, export:function() { document.location.href = OC.linkTo('contacts', 'export.php') + '?contactid=' + this.id; //$.get(OC.linkTo('contacts', 'export.php'),{'contactid':this.id},function(jsondata){ @@ -311,6 +349,8 @@ Contacts={ this.data = undefined; // Load first in list. if($('#contacts li').length > 0) { + Contacts.UI.Card.update(); + /* var firstid = $('#contacts li:first-child').data('id'); console.log('trying to load: ' + firstid); $.getJSON(OC.filePath('contacts', 'ajax', 'contactdetails.php'),{'id':firstid},function(jsondata){ @@ -320,7 +360,7 @@ Contacts={ else{ Contacts.UI.messageBox(t('contacts', 'Error'), jsondata.data.message); } - }); + });*/ } else { // load intro page $.getJSON('ajax/loadintro.php',{},function(jsondata){ @@ -447,6 +487,7 @@ Contacts={ $('#reverse_comma').text(this.famname + ', ' + this.givname);*/ $('#contact_identity').find('*[data-element="N"]').data('checksum', this.data.N[0]['checksum']); $('#contact_identity').find('*[data-element="FN"]').data('checksum', this.data.FN[0]['checksum']); + $('#contact_identity').show(); }, editNew:function(){ // add a new contact //Contacts.UI.notImplemented(); @@ -1079,9 +1120,11 @@ Contacts={ * Reload the contacts list. */ update:function(){ + console.log('Contacts.update, start'); $.getJSON('ajax/contacts.php',{},function(jsondata){ if(jsondata.status == 'success'){ $('#contacts').html(jsondata.data.page); + Contacts.UI.Card.update(); } else{ Contacts.UI.messageBox(t('contacts', 'Error'),jsondata.data.message); -- 2.39.5