From ddc26c361c2344568f3add242f415ba11bd1da69 Mon Sep 17 00:00:00 2001 From: Hadi Nategh Date: Mon, 22 Sep 2014 12:55:40 +0000 Subject: [PATCH] Avoid to refresh mail list if the active folder is not the Draft folder while saving compose mail as draft --- mail/inc/class.mail_compose.inc.php | 3 ++- mail/js/app.js | 14 ++++++++++---- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/mail/inc/class.mail_compose.inc.php b/mail/inc/class.mail_compose.inc.php index 313a293520..91be7c7571 100644 --- a/mail/inc/class.mail_compose.inc.php +++ b/mail/inc/class.mail_compose.inc.php @@ -2430,7 +2430,8 @@ class mail_compose $response->data(array( 'draftedId' => $draft_id, 'message' => $msg, - 'success' => $success + 'success' => $success, + 'draftfolder' => $this->mail_bo->profileID.mail_ui::$delimiter.$this->mail_bo->getDraftFolder() )); } diff --git a/mail/js/app.js b/mail/js/app.js index fa5722e598..8ae578ce00 100644 --- a/mail/js/app.js +++ b/mail/js/app.js @@ -3187,6 +3187,7 @@ app.classes.mail = AppJS.extend( * -draftedId: new drafted id created by server * -message: resault message * -success: true if saving was successful otherwise false + * -draftfolder: Name of draft folder including its delimiter * * @param {string} _action action is the element which caused saving draft, it could be as such: * -button[saveAsDraft] @@ -3198,7 +3199,7 @@ app.classes.mail = AppJS.extend( //Make sure there's a response from server otherwise shoot an error message if (jQuery.isEmptyObject(_responseData)) { - this.egw.message('Could not saved the message. Besause, the response from server failed.', 'error'); + this.egw.message('Could not saved the message. Because, the response from server failed.', 'error'); return false; } @@ -3206,17 +3207,22 @@ app.classes.mail = AppJS.extend( { var content = this.et2.getArrayMgr('content'); var lastDrafted = this.et2.getWidgetById('lastDrafted'); + var folderTree = opener.etemplate2.getByApplication('mail')[0].widgetContainer.getWidgetById('nm[foldertree]'); + var activeFolder = folderTree?folderTree.getSelectedNode():null; if (content) { var prevDraftedId = content.data.lastDrafted; content.data.lastDrafted = _responseData.draftedId; this.et2.setArrayMgr('content', content); lastDrafted.set_value(_responseData.draftedId); - if (prevDraftedId) + if (typeof activeFolder.id !='undefined'&& activeFolder && _responseData.draftfolder == activeFolder.id) { - opener.egw_refresh(_responseData.message,'mail', prevDraftedId, 'delete'); + if (prevDraftedId) + { + opener.egw_refresh(_responseData.message,'mail', prevDraftedId, 'delete'); + } + this.egw.refresh(_responseData.message,'mail',_responseData.draftedId); } - this.egw.refresh(_responseData.message,'mail',_responseData.draftedId); switch (_action) { case 'button[saveAsDraftAndPrint]':