forked from extern/egroupware
Fix mail actions update for nm context menu, preview and display toolbar
This commit is contained in:
parent
9cf5fc20db
commit
eb41061212
@ -4337,7 +4337,11 @@ class mail_ui
|
||||
if ($_sendJsonResponse)
|
||||
{
|
||||
$response = egw_json_response::get();
|
||||
if ((isset($_messageList['all']) && $_messageList['all']) || ($query['filter'] && ($flag2check==$query['filter'] || stripos($query['filter'],$flag2check)!==false)))
|
||||
if (isset($_messageList['msg']) && $_messageList['popup'])
|
||||
{
|
||||
$response->call('egw.refresh',lang('flagged %1 message as %2 in %3',$_messageList['msg'],lang($_flag),$folder),'mail', $_messageList['msg'], 'update');
|
||||
}
|
||||
else if ((isset($_messageList['all']) && $_messageList['all']) || ($query['filter'] && ($flag2check==$query['filter'] || stripos($query['filter'],$flag2check)!==false)))
|
||||
{
|
||||
$response->call('egw.refresh',lang('flagged %1 messages as %2 in %3',(isset($_messageList['all']) && $_messageList['all']?lang('all'):count($_messageList['msg'])),lang($_flag),$folder),'mail');
|
||||
}
|
||||
|
154
mail/js/app.js
154
mail/js/app.js
@ -1963,70 +1963,89 @@ app.classes.mail = AppJS.extend(
|
||||
*/
|
||||
mail_callFlagMessages: function(_action, _elems, _allMessagesChecked)
|
||||
{
|
||||
var do_nmactions = true;
|
||||
var msg;
|
||||
var ftree;
|
||||
var _folder;
|
||||
if (typeof _allMessagesChecked=='undefined') _allMessagesChecked=false;
|
||||
if (_action.id=='read')
|
||||
{
|
||||
ftree = this.et2.getWidgetById(this.nm_index+'[foldertree]');
|
||||
var _foldernode = ftree.getSelectedNode();
|
||||
_folder = _foldernode.id;
|
||||
}
|
||||
if (typeof _elems == 'undefined'|| _elems.length==0)
|
||||
{
|
||||
do_nmactions = false;//indicates that this action is probably a popup?
|
||||
if (this.et2.getArrayMgr("content").getEntry('mail_id'))
|
||||
{
|
||||
msg = {};
|
||||
msg['msg'] = [this.et2.getArrayMgr('content').getEntry('mail_id') || ''];
|
||||
}
|
||||
if ((typeof _elems == 'undefined'|| _elems.length==0) && this.mail_isMainWindow)
|
||||
{
|
||||
if (this.mail_currentlyFocussed)
|
||||
{
|
||||
msg = {};
|
||||
msg['msg'] = [this.mail_currentlyFocussed];
|
||||
_elems = msg;
|
||||
do_nmactions = true;// is triggered from preview
|
||||
}
|
||||
}
|
||||
}
|
||||
/**
|
||||
* vars
|
||||
*/
|
||||
var folder = '',
|
||||
tree = {},
|
||||
formData = {},
|
||||
data = {
|
||||
msg: [this.et2.getArrayMgr("content").getEntry('mail_id')] || '',
|
||||
all: _allMessagesChecked || false,
|
||||
popup: egw(window).is_popup() || false,
|
||||
activeFilters: _action.id == 'readall'? false : this.mail_getActiveFilters(_action)
|
||||
},
|
||||
rowClass = _action.id;
|
||||
|
||||
var classToProcess = _action.id;
|
||||
if (_action.id=='read') classToProcess='seen';
|
||||
else if (_action.id=='readall') classToProcess='seen';
|
||||
else if (_action.id=='label1') classToProcess='labelone';
|
||||
else if (_action.id=='label2') classToProcess='labeltwo';
|
||||
else if (_action.id=='label3') classToProcess='labelthree';
|
||||
else if (_action.id=='label4') classToProcess='labelfour';
|
||||
else if (_action.id=='label5') classToProcess='labelfive';
|
||||
|
||||
if (do_nmactions)
|
||||
if (typeof _elems === 'undefined' || _elems.length == 0)
|
||||
{
|
||||
msg = this.mail_getFormData(_elems);
|
||||
msg['all'] = _allMessagesChecked;
|
||||
if (msg['all']=='cancel') return false;
|
||||
msg['activeFilters'] = (_action.id=='readall'?false:this.mail_getActiveFilters(_action));
|
||||
if (this.mail_isMainWindow && this.mail_currentlyFocussed)
|
||||
{
|
||||
data.msg = [this.mail_currentlyFocussed];
|
||||
_elems = data;
|
||||
data.msg = this.mail_getFormData(_elems).msg;
|
||||
}
|
||||
}
|
||||
else // action called by contextmenu
|
||||
{
|
||||
data.msg = this.mail_getFormData(_elems).msg;
|
||||
}
|
||||
switch (_action.id)
|
||||
{
|
||||
case 'read':
|
||||
rowClass = 'seen';
|
||||
if (data.popup)
|
||||
{
|
||||
tree = opener.etemplate2.getByApplication('mail')[0].widgetContainer.getWidgetById(this.nm_index+'[foldertree]');
|
||||
}
|
||||
else
|
||||
{
|
||||
tree = this.et2.getWidgetById(this.nm_index+'[foldertree]');
|
||||
}
|
||||
folder = tree.getSelectedNode().id;
|
||||
break;
|
||||
case 'readall':
|
||||
rowClass = 'seen';
|
||||
break;
|
||||
case 'label1':
|
||||
rowClass = 'labelone';
|
||||
break;
|
||||
case 'label2':
|
||||
rowClass = 'labeltwo';
|
||||
break;
|
||||
case 'label3':
|
||||
rowClass = 'labelthree';
|
||||
break;
|
||||
case 'label4':
|
||||
rowClass = 'labelfour';
|
||||
break;
|
||||
case 'label5':
|
||||
rowClass = 'labelfive';
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
jQuery(data).extend({},data, formData);
|
||||
if (data['all']=='cancel') return false;
|
||||
|
||||
if (_action.id.substring(0,2)=='un') {
|
||||
//old style, only available for undelete and unlabel (no toggle)
|
||||
if ( _action.id=='unlabel') // this means all labels should be removed
|
||||
{
|
||||
var labels = ['labelone','labeltwo','labelthree','labelfour','labelfive'];
|
||||
for (var i=0; i<labels.length; i++) this.mail_removeRowClass(_elems,labels[i]);
|
||||
this.mail_flagMessages(_action.id,msg,(do_nmactions?false:true));
|
||||
this.mail_flagMessages(_action.id,data);
|
||||
}
|
||||
else
|
||||
{
|
||||
this.mail_removeRowClass(_elems,_action.id.substring(2));
|
||||
this.mail_setRowClass(_elems,_action.id);
|
||||
this.mail_flagMessages(_action.id,msg,(do_nmactions?false:true));
|
||||
this.mail_flagMessages(_action.id,data);
|
||||
}
|
||||
}
|
||||
else if (_action.id=='readall')
|
||||
{
|
||||
this.mail_flagMessages('read',msg,(do_nmactions?false:true));
|
||||
this.mail_flagMessages('read',data);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -2035,9 +2054,9 @@ app.classes.mail = AppJS.extend(
|
||||
var dataElem;
|
||||
var flags;
|
||||
var classes = '';
|
||||
for (var i=0; i<msg.msg.length; i++)
|
||||
for (var i=0; i<data.msg.length; i++)
|
||||
{
|
||||
dataElem = egw.dataGetUIDdata(msg.msg[i]);
|
||||
dataElem = egw.dataGetUIDdata(data.msg[i]);
|
||||
if(typeof dataElem.data.flags == 'undefined')
|
||||
{
|
||||
dataElem.data.flags = {};
|
||||
@ -2048,59 +2067,50 @@ app.classes.mail = AppJS.extend(
|
||||
// since we toggle we need to unset the ones already set, and set the ones not set
|
||||
// flags is data, UI is done by class, so update both
|
||||
// Flags are there or not, class names are flag or 'un'+flag
|
||||
if(classes.indexOf(classToProcess) >= 0)
|
||||
if(classes.indexOf(rowClass) >= 0)
|
||||
{
|
||||
classes.splice(classes.indexOf(classToProcess),1);
|
||||
classes.splice(classes.indexOf(rowClass),1);
|
||||
}
|
||||
if(classes.indexOf('un' + classToProcess) >= 0)
|
||||
if(classes.indexOf('un' + rowClass) >= 0)
|
||||
{
|
||||
classes.splice(classes.indexOf('un' + classToProcess),1);
|
||||
classes.splice(classes.indexOf('un' + rowClass),1);
|
||||
}
|
||||
if (flags[_action.id])
|
||||
{
|
||||
msg_unset['msg'].push(msg.msg[i]);
|
||||
classes.push('un'+classToProcess);
|
||||
msg_unset['msg'].push(data.msg[i]);
|
||||
classes.push('un'+rowClass);
|
||||
delete flags[_action.id];
|
||||
}
|
||||
else
|
||||
{
|
||||
msg_set['msg'].push(msg.msg[i]);
|
||||
msg_set['msg'].push(data.msg[i]);
|
||||
flags[_action.id] = _action.id;
|
||||
classes.push(classToProcess);
|
||||
classes.push(rowClass);
|
||||
}
|
||||
|
||||
// Update cache & call callbacks - updates list
|
||||
dataElem.data['class'] = classes.join(' ');
|
||||
egw.dataStoreUID(msg.msg[i],dataElem.data);
|
||||
egw.dataStoreUID(data.msg[i],dataElem.data);
|
||||
|
||||
//Refresh the nm rows after we told dataComponent about all changes, since the dataComponent doesn't talk to nm, we need to do it manually
|
||||
this.updateFilter_data(msg.msg[i], _action.id, msg.activeFilters);
|
||||
this.updateFilter_data(data.msg[i], _action.id, data.activeFilters);
|
||||
}
|
||||
|
||||
// Notify server of changes
|
||||
if (msg_unset['msg'] && msg_unset['msg'].length)
|
||||
{
|
||||
if (!msg['all']) this.mail_flagMessages('un'+_action.id,msg_unset);
|
||||
if (!data['all']) this.mail_flagMessages('un'+_action.id,msg_unset);
|
||||
}
|
||||
if (msg_set['msg'] && msg_set['msg'].length)
|
||||
{
|
||||
if (!msg['all']) this.mail_flagMessages(_action.id,msg_set);
|
||||
if (!data['all']) this.mail_flagMessages(_action.id,msg_set);
|
||||
}
|
||||
//server must do the toggle, as we apply to ALL, not only the visible
|
||||
if (msg['all']) this.mail_flagMessages(_action.id,msg);
|
||||
if (data['all']) this.mail_flagMessages(_action.id,data);
|
||||
// No further update needed, only in case of read, the counters should be refreshed
|
||||
if (_action.id=='read') this.mail_refreshFolderStatus(_folder,'thisfolderonly',false,true);
|
||||
if (_action.id=='read') this.mail_refreshFolderStatus(folder,'thisfolderonly',false,true);
|
||||
return;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
this.mail_flagMessages(_action.id,msg,(do_nmactions?false:true));
|
||||
}
|
||||
// only refresh counter. not grid as the ajaxmethod is called asyncronously
|
||||
// on flagging, only seen/unseen has effect on counterdisplay
|
||||
if (_action.id=='read' || _action.id=='readall') this.mail_refreshFolderStatus(_folder,'thisfolderonly',false,true);
|
||||
//this.mail_refreshFolderStatus();
|
||||
},
|
||||
|
||||
/**
|
||||
|
Loading…
Reference in New Issue
Block a user