* mail: improve refresh of messageList on message deletion

This commit is contained in:
Klaus Leithoff 2012-04-17 15:11:26 +00:00
parent 2ed67861bd
commit 849259b340
4 changed files with 119 additions and 12 deletions

View File

@ -437,7 +437,7 @@ class ajaxfelamimail
*
* @return xajax response
*/
function deleteMessages($_messageList)
function deleteMessages($_messageList,$_refreshMessageList=true)
{
if($this->_debug) error_log(__METHOD__." called with Messages ".print_r($_messageList,true));
$messageCount = 0;
@ -457,7 +457,45 @@ class ajaxfelamimail
$response->addScript('onNodeSelect("'.$this->sessionData['mailbox'].'");');
return $response->getXML();
}
if ($_refreshMessageList === false)
{
$response = new xajaxResponse();
return $response->getXML();
}
return $this->generateMessageList($this->sessionData['mailbox'],($_messageList=='all'?0:(-1*$messageCount)));
}
/*
* undelete messages
*
* @param array _messageList list of UID's
*
* @return xajax response
*/
function undeleteMessages($_messageList, $_refreshMessageList = true)
{
if($this->_debug) error_log(__METHOD__." called with Messages ".print_r($_messageList,true));
$messageCount = 0;
if(is_array($_messageList) && count($_messageList['msg']) > 0) $messageCount = count($_messageList['msg']);
try
{
$this->bofelamimail->flagMessages('undelete',$message,$mailfolder);
}
catch (egw_exception $e)
{
$error = str_replace('"',"'",$e->getMessage());
$response = new xajaxResponse();
$response->addScript('resetMessageSelect();');
$response->addScript('tellUser("'.$error.'");');
$response->addScript('onNodeSelect("'.$this->sessionData['mailbox'].'");');
return $response->getXML();
}
if ($_refreshMessageList === false)
{
$response = new xajaxResponse();
return $response->getXML();
}
return $this->generateMessageList($this->sessionData['mailbox'],($_messageList=='all'?0:(-1*$messageCount)));
}

View File

@ -1713,15 +1713,6 @@ $j(document).ready(function() {
}
$forwardURL = $GLOBALS['egw']->link('/index.php',$linkData);
//delete url
$linkData = array (
'menuaction' => 'felamimail.uifelamimail.'.($_headerData['deleted']?'un':'').'deleteMessage',
'icServer' => $_icServer,
'folder' => base64_encode($_folderName),
'message' => $_headerData['uid'],
);
$deleteURL = $GLOBALS['egw']->link('/index.php',$linkData);
$navbarImages = array(
'new' => array(
'action' => 'do_onunload = false;'.($_forceNewWindow ? "egw_openWindowCentered('$asnewURL','composeasnew_".$_headerData['uid']."',".$fm_width.",".$fm_height.");": "window.location.href = '$asnewURL'"),
@ -1740,11 +1731,11 @@ $j(document).ready(function() {
'tooltip' => lang('forward'),
),
'revert' => array(
'action' => 'do_onunload = false;'.($_forceNewWindow ? "window.open('$deleteURL','_blank','dependent=yes,width=100,height=100,toolbar=no,scrollbars=no,status=no')": "window.location.href = '$deleteURL'"),
'action' => 'do_onunload = false;'.($_forceNewWindow ? "mail":"mailview")."_undeleteMessages({msg:[".$_headerData['uid']."]});",
'tooltip' => ($_headerData['deleted']?lang('undelete'):lang('delete')),
),
'delete' => array(// json_encode(array('msg'=>array($_headerData['uid']))) may be used for {msg:[".$_headerData['uid']."]}
'action' => 'do_onunload = false;'.($_forceNewWindow ? "mail_deleteMessages({msg:[".$_headerData['uid']."]});": "window.location.href = '$deleteURL'"),
'action' => 'do_onunload = false;'.($_forceNewWindow ? "mail":"mailview")."_deleteMessages({msg:[".$_headerData['uid']."]});",
'tooltip' => ($_headerData['deleted']?lang('undelete'):lang('delete')),
),
);

View File

@ -1,3 +1,18 @@
/**
* Refresh given application _targetapp display of entry _app _id, incl. outputting _msg
*
* Default implementation here only reloads window with it's current url with an added msg=_msg attached
*
* @param string _msg message (already translated) to show, eg. 'Entry deleted'
* @param string _app application name
* @param string|int _id=null id of entry to refresh
* @param string _type=null either 'edit', 'delete', 'add' or null
*/
function app_refresh(_msg, _app, _id, _type)
{
alert("app_refresh(\'"+_msg+"\',\'"+_app+"\',\'"+_id+"\',\'"+_type+"\')");
}
function egw_email_fetchDataProc(_elems, _columns, _callback, _context)
{
var request = new egw_json_request("felamimail.uiwidgets.ajax_fetch_data",
@ -377,6 +392,27 @@ function mail_deleteMessages(_messageList) {
}
}
function mail_undeleteMessages(_messageList) {
var Check = true;
var cbAllMessages = document.getElementById('selectAllMessagesCheckBox').checked;
mail_resetMessageSelect();
if (cbAllMessages == true) Check = confirm(egw_appWindow('felamimail').lang_confirm_all_messages);
if (cbAllMessages == true && Check == true)
{
_messageList = 'all';
}
if (Check == true) {
egw_appWindow('felamimail').setStatusMessage('<span style="font-weight: bold;">' + egw_appWindow('felamimail').lang_deleting_messages + '</span>');
mail_cleanup();
document.getElementById('divMessageList').innerHTML = '';
egw_appWindow('felamimail').xajax_doXMLHTTP("felamimail.ajaxfelamimail.undeleteMessages",_messageList);
} else {
mailGrid.dataRoot.actionObject.setAllSelected(false);
}
}
function displayMessage(_url,_windowName) {
egw_openWindowCentered(_url, _windowName, 850, egw_getWindowOuterHeight());
}

View File

@ -115,3 +115,45 @@ function fm_resizeBodyDIV() {
bodyDIV.style.height = egw_getWindowInnerHeight() - bodyDIV.offsetTop - 2 + 'px';
}
}
function mailview_deleteMessages(_messageList) {
var divMessageList = opener.document.getElementById('divMessageList');
xajax_doXMLHTTPsync("felamimail.ajaxfelamimail.deleteMessages",_messageList,false);
if (typeof divMessageList != 'undefined')
{
//divMessageList.innerHTML = '';
for(var i=0;i<_messageList['msg'].length;i++) {
_id = _messageList['msg'][i];
var dataElem = opener.mailGrid.dataRoot.getElementById(_id);
if (dataElem)
{
//dataElem.clearData();
dataElem.addClass('deleted');
//dataElem.parentActionObject.remove();
}
}
opener.refresh();
}
this.close();
//egw_appWindow('felamimail').
}
function mailview_undeleteMessages(_messageList) {
var divMessageList = opener.document.getElementById('divMessageList');
//if (typeof divMessageList != 'undefined') divMessageList.innerHTML = '';
if (typeof divMessageList != 'undefined')
{
//divMessageList.innerHTML = '';
for(var i=0;i<_messageList['msg'].length;i++) {
_id = _messageList['msg'][i];
var dataElem = opener.mailGrid.dataRoot.getElementById(_id);
if (dataElem)
{
//dataElem.clearData();
dataElem.removeClass('deleted');
}
}
}
xajax_doXMLHTTPsync("felamimail.ajaxfelamimail.undeleteMessages",_messageList,false);
//egw_appWindow('felamimail').
}