Added some fixes for what to show when address books are (de)selected, all contacts deleted etc. Still need some cleaning up.

This commit is contained in:
Thomas Tanghus 2012-02-14 13:57:11 +01:00
parent ae426ad115
commit 31dab0372d
3 changed files with 48 additions and 4 deletions

View file

@ -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);

View file

@ -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; }

View file

@ -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);