From 4f9c9a8892aec464d420ae47a5cebdaae1dfee8c Mon Sep 17 00:00:00 2001 From: Nathan Gray Date: Wed, 22 Jan 2014 09:32:18 +0000 Subject: [PATCH] Clicking on profile in tree changes profile & selects inbox --- mail/inc/class.mail_ui.inc.php | 15 +++++++++++++-- mail/js/app.js | 23 +++++++++++++++++++---- 2 files changed, 32 insertions(+), 6 deletions(-) diff --git a/mail/inc/class.mail_ui.inc.php b/mail/inc/class.mail_ui.inc.php index 4db38b14fc..e76af41b3c 100644 --- a/mail/inc/class.mail_ui.inc.php +++ b/mail/inc/class.mail_ui.inc.php @@ -3707,9 +3707,11 @@ blockquote[type=cite] { /** * empty changeProfile - its called via json, so the function must start with ajax (or the class-name must contain ajax) * + * @param int $icServerId New profile / server ID + * @param bool $getFolders The client needs the folders for the profile * @return nothing */ - function ajax_changeProfile($icServerID) + function ajax_changeProfile($icServerID, $getFolders = true) { //lang('Connect to Profile %1',$icServerID); if ($icServerID && $icServerID != $this->mail_bo->profileID) @@ -3718,7 +3720,16 @@ blockquote[type=cite] { $this->changeProfile($icServerID); } $response = egw_json_response::get(); - $response->call('egw_refresh',lang('changed profile'),'mail'); + //$folderInfo = $this->mail_bo->getFolderStatus($icServerID,false); + + // Send full info back in the response + if($getFolders) + { + $refreshData = array( + $icServerID => $this->getFolderTree(true, $icServerID, true) + ); + $response->call('app.mail.mail_reloadNode',$refreshData); + } } /** diff --git a/mail/js/app.js b/mail/js/app.js index 7c561af130..86bfe2575f 100644 --- a/mail/js/app.js +++ b/mail/js/app.js @@ -1071,12 +1071,27 @@ app.classes.mail = AppJS.extend( * mail_changeProfile * @param folder, the ID of the selected Node -> should be an integer * @param _widget, handle to the tree widget + * @param {boolean} getFolders Flag to indicate that the profile needs the mail + * folders. False means they're already loaded in the tree, and we don't need + * them again */ - mail_changeProfile: function(folder,_widget) { + mail_changeProfile: function(folder,_widget, getFolders) { + if(typeof getFolders == 'undefined') + { + getFolders = true; + } // alert(folder); egw_message(this.egw.lang('Connect to Profile %1',_widget.getSelectedLabel())); - egw.json('mail.mail_ui.ajax_changeProfile',[folder]) - .sendRequest(); + + this.lock_tree(); + egw.json('mail.mail_ui.ajax_changeProfile',[folder, getFolders], jQuery.proxy(function() { + // Profile changed, select inbox + var inbox = folder + '::INBOX'; + _widget.reSelectItem(inbox) + this.mail_changeFolder(inbox,_widget,''); + this.unlock_tree(); + },this)) + .sendRequest(true); return true; }, @@ -1106,7 +1121,7 @@ app.classes.mail = AppJS.extend( if (server[0] != previousServer[0] && profile_selected) { // mail_changeProfile triggers a refresh, no need to do any more - return this.mail_changeProfile(_folder,_widget); + return this.mail_changeProfile(_folder,_widget, _widget.getSelectedNode().childsCount == 0); } // Apply new selected folder to list, which updates data