Add handler for dropping mail into infolog

This commit is contained in:
Nathan Gray 2015-02-24 19:07:48 +00:00
parent 73dfdc4cf4
commit 2a939d0c6f
2 changed files with 53 additions and 1 deletions

View File

@ -1249,7 +1249,12 @@ class infolog_ui
'disableClass' => 'rowNoUndelete', 'disableClass' => 'rowNoUndelete',
); );
} }
$actions['info_drop_mail'] = array(
'type' => 'drop',
'acceptedTypes' => 'mail',
'onExecute' => 'javaScript:app.infolog.handle_dropped_mail',
'hideOnDisabled' => true
);
//echo "<p>".__METHOD__."($do_email, $tid_filter, $org_view)</p>\n"; _debug_array($actions); //echo "<p>".__METHOD__."($do_email, $tid_filter, $org_view)</p>\n"; _debug_array($actions);
return $actions; return $actions;
} }

View File

@ -773,5 +773,52 @@ var AppJS = Class.extend(
{ {
return this.et2._inst.uniqueId; return this.et2._inst.uniqueId;
} }
},
/**
* Handler for drag and drop when dragging nextmatch rows from mail app
* and dropped on a row in the current application. We copy the mail into
* the filemanager to link it since we can't link directly.
*
* This doesn't happen automatically. Each application must indicate that
* it will accept dropped mail by it's nextmatch actions:
*
* $actions['info_drop_mail'] = array(
* 'type' => 'drop',
* 'acceptedTypes' => 'mail',
* 'onExecute' => 'javaScript:app.infolog.handle_dropped_mail',
* 'hideOnDisabled' => true
* );
*
* This action, when defined, will not affect the automatic linking between
* normal applications.
*
* @param {egwAction} _action
* @param {egwActionObject[]} _selected Dragged mail rows
* @param {egwActionObject} _target Current application's nextmatch row the mail was dropped on
*/
handle_dropped_mail: function(_action, _selected, _target)
{
/**
* Mail doesn't support link system, so we copy it to VFS
*/
var ids = _target.id.split("::");
if(ids.length != 2 || ids[0] == 'mail') return;
var vfs_path = "/apps/"+ids[0]+"/"+ids[1];
var mail_ids = [];
for(var i = 0; i < _selected.length; i++)
{
mail_ids.push(_selected[i].id);
}
if(mail_ids.length)
{
egw.message(egw.lang("Please wait..."));
this.egw.json('filemanager.filemanager_ui.ajax_action',['mail',mail_ids, vfs_path],function(data){
// Trigger an update (minimal, no sorting changes) to display the new link
egw.refresh(data.msg||'',ids[0],ids[1],'update');
}).sendRequest(true);
}
} }
}); });