mirror of
https://github.com/EGroupware/egroupware.git
synced 2024-11-27 18:33:39 +01:00
Filemanager paste actions
- add paste to nm placeholder actions - add basic folder permissions check - disable paste if no files in clipboard
This commit is contained in:
parent
3204e332aa
commit
904d616145
@ -176,6 +176,7 @@ class filemanager_ui
|
||||
'acceptedTypes' => 'file',
|
||||
'group' => $group + 0.5,
|
||||
'order' => 10,
|
||||
'enabled' => 'javaScript:app.filemanager.paste_enabled',
|
||||
'children' => array()
|
||||
),
|
||||
'documents' => filemanager_merge::document_action(
|
||||
@ -247,7 +248,7 @@ class filemanager_ui
|
||||
$action['type'] = 'popup';
|
||||
if($action['acceptedTypes'] == 'file')
|
||||
{
|
||||
$action['enabled'] = 'javaScript:app.filemanager.drop_enabled';
|
||||
$action['enabled'] = 'javaScript:app.filemanager.paste_enabled';
|
||||
}
|
||||
$actions['paste']['children']["{$action_id}_paste"] = $action;
|
||||
}
|
||||
@ -327,7 +328,7 @@ class filemanager_ui
|
||||
'parent_id' => 'dir',
|
||||
'is_parent' => 'is_dir',
|
||||
'favorites' => true,
|
||||
'placeholder_actions' => array('mkdir','file_drop_mail','file_drop_move','file_drop_copy','file_drop_symlink')
|
||||
'placeholder_actions' => array('mkdir','paste','file_drop_mail','file_drop_move','file_drop_copy','file_drop_symlink')
|
||||
);
|
||||
$content['nm']['path'] = static::get_home_dir();
|
||||
}
|
||||
@ -893,8 +894,15 @@ class filemanager_ui
|
||||
}
|
||||
if (Vfs::is_dir($path))
|
||||
{
|
||||
$row['class'] = 'isDir';
|
||||
$row['is_dir'] = 1;
|
||||
if (!isset($dir_is_writable[$path]))
|
||||
{
|
||||
$dir_is_writable[$path] = Vfs::is_writable($path);
|
||||
}
|
||||
if(!$dir_is_writable[$path])
|
||||
{
|
||||
$row['class'] .= 'noEdit ';
|
||||
}
|
||||
$row['class'] .= 'isDir ';
|
||||
}
|
||||
$row['download_url'] = Vfs::download_url($path);
|
||||
$row['gid'] = -abs($row['gid']); // gid are positive, but we use negagive account_id for groups internal
|
||||
|
@ -788,7 +788,7 @@ app.classes.filemanager = AppJS.extend(
|
||||
},
|
||||
|
||||
/**
|
||||
* Callback to check if the drop action is enabled. We also update the
|
||||
* Callback to check if the paste action is enabled. We also update the
|
||||
* clipboard historical targets here as well
|
||||
*
|
||||
* @param {egwAction} _action drop action we're checking
|
||||
@ -797,23 +797,46 @@ app.classes.filemanager = AppJS.extend(
|
||||
*
|
||||
* @returns boolean true if enabled, false otherwise
|
||||
*/
|
||||
drop_enabled: function drop_enabled(_action, _senders, _target)
|
||||
paste_enabled: function paste_enabled(_action, _senders, _target)
|
||||
{
|
||||
// Need files in the clipboard for this
|
||||
var clipboard_files = this.get_clipboard_files();
|
||||
if(clipboard_files.length === 0)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
// Parent action (paste) gets run through here as well, but needs no
|
||||
// further processing
|
||||
if(_action.id == 'paste') return true;
|
||||
|
||||
if(_action.canHaveChildren.indexOf('drop') == -1)
|
||||
{
|
||||
_action.canHaveChildren.push('drop');
|
||||
}
|
||||
var actions = [
|
||||
// Current directory
|
||||
{id:_action.id+'_current', caption: this.get_path(), path: this.get_path()}
|
||||
];
|
||||
var actions = [];
|
||||
var dir = undefined;
|
||||
var current_dir, target_dir = false;
|
||||
|
||||
// Target, if directory
|
||||
// Current directory
|
||||
current_dir = this.get_path();
|
||||
dir = egw.dataGetUIDdata('filemanager::'+current_dir);
|
||||
var path_widget = etemplate2.getById('filemanager-index').widgetContainer.getWidgetById('button[createdir]');
|
||||
actions.push({
|
||||
id: _action.id+'_target',
|
||||
caption: this.id2path(_target.id),
|
||||
path: this.id2path(_target.id),
|
||||
enabled: _target && _target.iface && jQuery(_target.iface.getDOMNode()).hasClass('isDir')
|
||||
id:_action.id+'_current', caption: current_dir, path: current_dir,
|
||||
enabled: dir && dir.data && dir.data.class && dir.data.class.indexOf('noEdit') === -1 ||
|
||||
!dir && path_widget && !path_widget.options.readonly
|
||||
});
|
||||
|
||||
// Target, if directory
|
||||
target_dir = this.id2path(_target.id);
|
||||
dir = egw.dataGetUIDdata(_target.id);
|
||||
actions.push({
|
||||
id: _action.id+'_target',
|
||||
caption: target_dir,
|
||||
path: target_dir,
|
||||
enabled: _target && _target.iface && jQuery(_target.iface.getDOMNode()).hasClass('isDir') &&
|
||||
(dir && dir.data && dir.data.class && dir.data.class.indexOf('noEdit') === -1 || !dir)
|
||||
});
|
||||
|
||||
// Last 10 folders
|
||||
@ -827,7 +850,7 @@ app.classes.filemanager = AppJS.extend(
|
||||
caption: path,
|
||||
path: path,
|
||||
group: 2,
|
||||
enabled: path && !(path === actions[0].path || actions[1] && path === actions[1].path)
|
||||
enabled: path && !(current_dir && path === current_dir || target_dir && path === target_dir)
|
||||
});
|
||||
}
|
||||
|
||||
@ -851,6 +874,12 @@ app.classes.filemanager = AppJS.extend(
|
||||
// Set a flag so apps can tell the difference, if they need to
|
||||
action.set_onExecute(action.parent.onExecute.fnct);
|
||||
action.execute(clipboard.selected,selected[0]);
|
||||
|
||||
// Clear the clipboard, the files are not there anymore
|
||||
egw.setSessionItem('phpgwapi', 'egw_clipboard', JSON.stringify({
|
||||
type:[],
|
||||
selected:[]
|
||||
}));
|
||||
};
|
||||
for(var i = 0; i < actions.length; i++)
|
||||
{
|
||||
@ -858,7 +887,7 @@ app.classes.filemanager = AppJS.extend(
|
||||
|
||||
_action.getActionById(actions[i].id).set_onExecute(paste_exec);
|
||||
}
|
||||
return true;
|
||||
return actions.length > 0;
|
||||
},
|
||||
|
||||
/**
|
||||
|
Loading…
Reference in New Issue
Block a user