mirror of
https://github.com/EGroupware/egroupware.git
synced 2025-01-14 18:08:21 +01:00
Move mail folders via drag and drop
This commit is contained in:
parent
04a845fa35
commit
473d7e2001
@ -332,6 +332,11 @@ class mail_ui
|
|||||||
'acceptedTypes' => 'mail',
|
'acceptedTypes' => 'mail',
|
||||||
'type' => 'drop',
|
'type' => 'drop',
|
||||||
),
|
),
|
||||||
|
'drop_move_folder' => array(
|
||||||
|
'type' => 'drop',
|
||||||
|
'acceptedTypes' => 'mailFolder',
|
||||||
|
'onExecute' => 'javaScript:app.mail.mail_MoveFolder'
|
||||||
|
),
|
||||||
// Tree does support this one
|
// Tree does support this one
|
||||||
'add' => array(
|
'add' => array(
|
||||||
'caption' => 'Add Folder',
|
'caption' => 'Add Folder',
|
||||||
@ -343,7 +348,8 @@ class mail_ui
|
|||||||
),
|
),
|
||||||
'move' => array(
|
'move' => array(
|
||||||
'caption' => 'Move Folder',
|
'caption' => 'Move Folder',
|
||||||
'onExecute' => 'javaScript:app.mail.mail_MoveFolder'
|
'type' => 'drag',
|
||||||
|
'dragType' => array('mailFolder')
|
||||||
),
|
),
|
||||||
'delete' => array(
|
'delete' => array(
|
||||||
'caption' => 'Delete Folder',
|
'caption' => 'Delete Folder',
|
||||||
@ -3514,10 +3520,10 @@ $success=true;
|
|||||||
/**
|
/**
|
||||||
* move folder
|
* move folder
|
||||||
*
|
*
|
||||||
* @param array _folderName folder to vove
|
* @param string _folderName folder to vove
|
||||||
* @param array _target target folder
|
* @param string _target target folder
|
||||||
*
|
*
|
||||||
* @return xajax response
|
* @return void
|
||||||
*/
|
*/
|
||||||
function ajax_MoveFolder($_folderName, $_target)
|
function ajax_MoveFolder($_folderName, $_target)
|
||||||
{
|
{
|
||||||
@ -3529,10 +3535,11 @@ $success=true;
|
|||||||
$del = $this->mail_bo->getHierarchyDelimiter(false);
|
$del = $this->mail_bo->getHierarchyDelimiter(false);
|
||||||
$oA = array();
|
$oA = array();
|
||||||
list($profileID,$folderName) = explode(self::$delimiter,$decodedFolderName,2);
|
list($profileID,$folderName) = explode(self::$delimiter,$decodedFolderName,2);
|
||||||
|
list($newProfileID,$_newLocation) = explode(self::$delimiter,$_newLocation,2);
|
||||||
$hasChildren = false;
|
$hasChildren = false;
|
||||||
if (is_numeric($profileID))
|
if (is_numeric($profileID))
|
||||||
{
|
{
|
||||||
if ($profileID != $this->mail_bo->profileID) return; // only current connection
|
if ($profileID != $this->mail_bo->profileID || $profileID != $newProfileID) return; // only current connection
|
||||||
$pA = explode($del,$folderName);
|
$pA = explode($del,$folderName);
|
||||||
$namePart = array_pop($pA);
|
$namePart = array_pop($pA);
|
||||||
$_newName = $namePart;
|
$_newName = $namePart;
|
||||||
@ -3631,7 +3638,13 @@ $success=true;
|
|||||||
// if we move the folder within the same parent-branch of the tree, there is no need no refresh the upper part
|
// if we move the folder within the same parent-branch of the tree, there is no need no refresh the upper part
|
||||||
if (strlen($parentFolder)>strlen($oldParentFolder) && strpos($parentFolder,$oldParentFolder)!==false) unset($refreshData[$profileID.self::$delimiter.$parentFolder]);
|
if (strlen($parentFolder)>strlen($oldParentFolder) && strpos($parentFolder,$oldParentFolder)!==false) unset($refreshData[$profileID.self::$delimiter.$parentFolder]);
|
||||||
if (count($refreshData)>1 && strlen($oldParentFolder)>strlen($parentFolder) && strpos($oldParentFolder,$parentFolder)!==false) unset($refreshData[$profileID.self::$delimiter.$oldParentFolder]);
|
if (count($refreshData)>1 && strlen($oldParentFolder)>strlen($parentFolder) && strpos($oldParentFolder,$parentFolder)!==false) unset($refreshData[$profileID.self::$delimiter.$oldParentFolder]);
|
||||||
$response->call('app.mail.mail_reloadNode',$refreshData,'mail');
|
|
||||||
|
// Send full info back in the response
|
||||||
|
foreach($refreshData as $folder => &$name)
|
||||||
|
{
|
||||||
|
$name = $this->getFolderTree(true, $folder, true);
|
||||||
|
}
|
||||||
|
$response->call('app.mail.mail_reloadNode',$refreshData);
|
||||||
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -840,9 +840,8 @@ app.classes.mail = AppJS.extend(
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* mail_reloadNode, function to reload the leaf represented by the given ID
|
* mail_reloadNode, function to reload the leaf represented by the given ID
|
||||||
* @param array _status status array with the required data (KEY id, VALUE desc)
|
* @param {Object.<string,string>|Object.<string,Object}} _status
|
||||||
* key is the id of the leaf to delete
|
* Object with the required data (KEY id, VALUE desc), or ID => {new data}
|
||||||
* multiple sets can be passed to mail_deleteLeaf
|
|
||||||
*/
|
*/
|
||||||
mail_reloadNode: function(_status) {
|
mail_reloadNode: function(_status) {
|
||||||
//console.log('mail_reloadNode',_status);
|
//console.log('mail_reloadNode',_status);
|
||||||
@ -851,17 +850,22 @@ app.classes.mail = AppJS.extend(
|
|||||||
for (var i in _status)
|
for (var i in _status)
|
||||||
{
|
{
|
||||||
// if olddesc is undefined or #skip# then skip the message, as we process subfolders
|
// if olddesc is undefined or #skip# then skip the message, as we process subfolders
|
||||||
if (typeof _status[i] !== 'undefined' && _status[i] !== '#skip-user-interaction-message#') this.app_refresh(this.egw.lang("Reloaded Folder %1 ",_status[i], 'mail'));
|
if (typeof _status[i] !== 'undefined' && _status[i] !== '#skip-user-interaction-message#')
|
||||||
ftree.refreshItem(i);
|
{
|
||||||
|
this.app_refresh(this.egw.lang("Reloaded Folder %1 ",typeof _status[i] == "string" ? _status[i] : _status[i].text), 'mail');
|
||||||
|
}
|
||||||
|
ftree.refreshItem(i,typeof _status[i] == "object" ? _status[i] : null);
|
||||||
|
}
|
||||||
|
|
||||||
var selectedNodeAfter = ftree.getSelectedNode();
|
var selectedNodeAfter = ftree.getSelectedNode();
|
||||||
//alert(i +'->'+_status[i]['id']+'+'+_status[i]['desc']);
|
|
||||||
if (selectedNodeAfter.id!=selectedNode.id && selectedNode.id==i)
|
// If selected folder changed, refresh nextmatch
|
||||||
|
if (selectedNodeAfter != null && selectedNodeAfter.id!=selectedNode.id)
|
||||||
{
|
{
|
||||||
var nm = this.et2.getWidgetById(this.nm_index);
|
var nm = this.et2.getWidgetById(this.nm_index);
|
||||||
nm.activeFilters["selectedFolder"] = selectedNodeAfter.id;
|
nm.activeFilters["selectedFolder"] = selectedNodeAfter.id;
|
||||||
nm.applyFilters();
|
nm.applyFilters();
|
||||||
}
|
}
|
||||||
}
|
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -1946,54 +1950,28 @@ app.classes.mail = AppJS.extend(
|
|||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* mail_MoveFolder - implementation of the MoveFolder action of right click options on the tree
|
* mail_MoveFolder - implementation of the MoveFolder action on the tree
|
||||||
*
|
*
|
||||||
* @param _action
|
* @param {egwAction} _action
|
||||||
* @param _senders - the representation of the tree leaf to be manipulated
|
* @param {egwActionObject[]} _senders - the representation of the tree leaf to be manipulated
|
||||||
|
* @param {egwActionObject} destination Drop target egwActionObject representing the destination
|
||||||
*/
|
*/
|
||||||
mail_MoveFolder: function(action,_senders) {
|
mail_MoveFolder: function(_action,_senders,destination) {
|
||||||
//console.log(action,_senders);
|
if(!destination || !destination.id)
|
||||||
//action.id == 'rename'
|
|
||||||
//_senders.iface.id == target leaf / leaf to edit
|
|
||||||
var ftree = this.et2.getWidgetById(this.nm_index+'[foldertree]');
|
|
||||||
OldFolderName = ftree.getLabel(_senders[0].iface.id);
|
|
||||||
if (jQuery(OldFolderName).text().length>0) OldFolderName = jQuery(OldFolderName).text();
|
|
||||||
OldFolderName = OldFolderName.trim();
|
|
||||||
OldFolderName = OldFolderName.replace(/\([0-9]*\)/g,'').trim();
|
|
||||||
//console.log(OldFolderName);
|
|
||||||
var buttons = [
|
|
||||||
{text: this.egw.lang("Move"), id: "move", class: "ui-priority-primary", "default": true},
|
|
||||||
{text: this.egw.lang("Cancel"), id:"cancel"},
|
|
||||||
];
|
|
||||||
var dialog = et2_createWidget("dialog",{
|
|
||||||
// If you use a template, the second parameter will be the value of the template, as if it were submitted.
|
|
||||||
callback: function(_button_id, _value) {
|
|
||||||
var senders = this.my_data.data;
|
|
||||||
var NewFolderName = null;
|
|
||||||
if (typeof _value.folder[0] != 'undefined' && _value.folder[0].length>0) NewFolderName = _value.folder[0];
|
|
||||||
//alert(NewFolderName);
|
|
||||||
if (NewFolderName && NewFolderName.length>0)
|
|
||||||
{
|
{
|
||||||
switch (_button_id)
|
egw.debug('warn', "Move folder, but no target");
|
||||||
{
|
|
||||||
case "move":
|
|
||||||
egw.json('mail.mail_ui.ajax_MoveFolder',[senders[0].iface.id, NewFolderName])
|
|
||||||
.sendRequest(true);
|
|
||||||
return;
|
return;
|
||||||
case "cancel":
|
|
||||||
}
|
}
|
||||||
}
|
// Some UI feedback while the folder is moved
|
||||||
},
|
$j(destination.iface.getDOMNode()).addClass('loading');
|
||||||
buttons: buttons,
|
|
||||||
title: this.egw.lang("Move Folder %1 ?",OldFolderName),
|
|
||||||
template:egw.webserverUrl+"/mail/templates/default/moveFolder.xet",
|
|
||||||
value: { content: {selectedLeaf:OldFolderName}, sel_options: {}}
|
|
||||||
});
|
|
||||||
|
|
||||||
// setting required data for callback in as my_data
|
for(var i = 0; i < _senders.length; i++)
|
||||||
dialog.my_data = {
|
{
|
||||||
data: _senders,
|
egw.jsonq('mail.mail_ui.ajax_MoveFolder',[_senders[i].iface.id, destination.id],
|
||||||
};
|
// Move is done (successfully or not), remove loading
|
||||||
|
function() {$j(destination.iface.getDOMNode()).removeClass('loading');}
|
||||||
|
);
|
||||||
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
Reference in New Issue
Block a user