Refresh the nm and lock the tree if current active folder is the Trash Folder, when calling "Empty Trash" action, otherwise no need to refresh or lock the tree

This commit is contained in:
Hadi Nategh 2014-08-11 14:02:26 +00:00
parent ac55076b7b
commit 5941ff6a26
2 changed files with 13 additions and 8 deletions

View File

@ -4010,16 +4010,17 @@ class mail_ui
} }
/** /**
* empty trash folder - its called via json, so the function must start with ajax (or the class-name must contain ajax) * Empty trash folder
* *
* @param string $icServerID id of the server to empty its trashFolder * @param string $icServerID id of the server to empty its trashFolder
* @param string $selectedFolder seleted(active) folder by nm filter
* @return nothing * @return nothing
*/ */
function ajax_emptyTrash($icServerID) function ajax_emptyTrash($icServerID, $selectedFolder)
{ {
//error_log(__METHOD__.__LINE__.' '.$icServerID); //error_log(__METHOD__.__LINE__.' '.$icServerID);
translation::add_app('mail'); translation::add_app('mail');
$response = egw_json_response::get();
$rememberServerID = $this->mail_bo->profileID; $rememberServerID = $this->mail_bo->profileID;
if ($icServerID && $icServerID != $this->mail_bo->profileID) if ($icServerID && $icServerID != $this->mail_bo->profileID)
{ {
@ -4028,20 +4029,23 @@ class mail_ui
} }
$trashFolder = $this->mail_bo->getTrashFolder(); $trashFolder = $this->mail_bo->getTrashFolder();
if(!empty($trashFolder)) { if(!empty($trashFolder)) {
if ($selectedFolder == $icServerID.self::$delimiter.$trashFolder)
{
// Lock the tree if the active folder is Trash folder
$response->call('app.mail.lock_tree');
}
$this->mail_bo->compressFolder($trashFolder); $this->mail_bo->compressFolder($trashFolder);
} }
if ($rememberServerID != $this->mail_bo->profileID) if ($rememberServerID != $this->mail_bo->profileID)
{ {
$oldFolderInfo = $this->mail_bo->getFolderStatus($trashFolder,false,false,false); $oldFolderInfo = $this->mail_bo->getFolderStatus($trashFolder,false,false,false);
$response = egw_json_response::get();
$response->call('egw.message',lang('empty trash')); $response->call('egw.message',lang('empty trash'));
$response->call('app.mail.mail_reloadNode',array($icServerID.self::$delimiter.$trashFolder=>$oldFolderInfo['shortDisplayName'])); $response->call('app.mail.mail_reloadNode',array($icServerID.self::$delimiter.$trashFolder=>$oldFolderInfo['shortDisplayName']));
//error_log(__METHOD__.__LINE__.' change Profile to ->'.$rememberServerID); //error_log(__METHOD__.__LINE__.' change Profile to ->'.$rememberServerID);
$this->changeProfile($rememberServerID); $this->changeProfile($rememberServerID);
} }
else else if ($selectedFolder == $icServerID.self::$delimiter.$trashFolder)
{ {
$response = egw_json_response::get();
$response->call('egw.refresh',lang('empty trash'),'mail'); $response->call('egw.refresh',lang('empty trash'),'mail');
} }
} }

View File

@ -1472,10 +1472,11 @@ app.classes.mail = AppJS.extend(
*/ */
mail_emptyTrash: function(action,_senders) { mail_emptyTrash: function(action,_senders) {
var server = _senders[0].iface.id.split('::'); var server = _senders[0].iface.id.split('::');
var activeFilters = this.mail_getActiveFilters();
var self = this; var self = this;
this.egw.message(this.egw.lang('empty trash')); this.egw.message(this.egw.lang('empty trash'));
this.lock_tree(); egw.json('mail.mail_ui.ajax_emptyTrash',[server[0], activeFilters['selectedFolder']? activeFilters['selectedFolder']:null],function(){self.unlock_tree()})
egw.json('mail.mail_ui.ajax_emptyTrash',[server[0]],function(){self.unlock_tree();})
.sendRequest(true); .sendRequest(true);
}, },