From 2a939d0c6ffdfd7b40e0647e450b0441774586cd Mon Sep 17 00:00:00 2001 From: Nathan Gray Date: Tue, 24 Feb 2015 19:07:48 +0000 Subject: [PATCH] Add handler for dropping mail into infolog --- infolog/inc/class.infolog_ui.inc.php | 7 ++++- phpgwapi/js/jsapi/app_base.js | 47 ++++++++++++++++++++++++++++ 2 files changed, 53 insertions(+), 1 deletion(-) diff --git a/infolog/inc/class.infolog_ui.inc.php b/infolog/inc/class.infolog_ui.inc.php index 9970350346..07dda75b0c 100644 --- a/infolog/inc/class.infolog_ui.inc.php +++ b/infolog/inc/class.infolog_ui.inc.php @@ -1249,7 +1249,12 @@ class infolog_ui 'disableClass' => 'rowNoUndelete', ); } - + $actions['info_drop_mail'] = array( + 'type' => 'drop', + 'acceptedTypes' => 'mail', + 'onExecute' => 'javaScript:app.infolog.handle_dropped_mail', + 'hideOnDisabled' => true + ); //echo "

".__METHOD__."($do_email, $tid_filter, $org_view)

\n"; _debug_array($actions); return $actions; } diff --git a/phpgwapi/js/jsapi/app_base.js b/phpgwapi/js/jsapi/app_base.js index 083c716994..dc96bb9586 100644 --- a/phpgwapi/js/jsapi/app_base.js +++ b/phpgwapi/js/jsapi/app_base.js @@ -773,5 +773,52 @@ var AppJS = Class.extend( { 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); + } } });