mirror of
https://github.com/EGroupware/egroupware.git
synced 2024-11-26 01:43:47 +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
4cd0d35ff7
commit
7738de2dec
@ -195,6 +195,7 @@ class filemanager_ui
|
|||||||
'acceptedTypes' => 'file',
|
'acceptedTypes' => 'file',
|
||||||
'group' => $group + 0.5,
|
'group' => $group + 0.5,
|
||||||
'order' => 10,
|
'order' => 10,
|
||||||
|
'enabled' => 'javaScript:app.filemanager.paste_enabled',
|
||||||
'children' => array()
|
'children' => array()
|
||||||
),
|
),
|
||||||
'documents' => filemanager_merge::document_action(
|
'documents' => filemanager_merge::document_action(
|
||||||
@ -266,7 +267,7 @@ class filemanager_ui
|
|||||||
$action['type'] = 'popup';
|
$action['type'] = 'popup';
|
||||||
if($action['acceptedTypes'] == 'file')
|
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;
|
$actions['paste']['children']["{$action_id}_paste"] = $action;
|
||||||
}
|
}
|
||||||
@ -347,7 +348,7 @@ class filemanager_ui
|
|||||||
'is_parent' => 'mime',
|
'is_parent' => 'mime',
|
||||||
'is_parent_value'=> Vfs::DIR_MIME_TYPE,
|
'is_parent_value'=> Vfs::DIR_MIME_TYPE,
|
||||||
'favorites' => true,
|
'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();
|
$content['nm']['path'] = static::get_home_dir();
|
||||||
}
|
}
|
||||||
@ -913,7 +914,15 @@ class filemanager_ui
|
|||||||
}
|
}
|
||||||
if (Vfs::is_dir($path))
|
if (Vfs::is_dir($path))
|
||||||
{
|
{
|
||||||
$row['class'] = 'isDir';
|
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['download_url'] = Vfs::download_url($path);
|
||||||
$row['gid'] = -abs($row['gid']); // gid are positive, but we use negagive account_id for groups internal
|
$row['gid'] = -abs($row['gid']); // gid are positive, but we use negagive account_id for groups internal
|
||||||
|
@ -799,7 +799,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
|
* clipboard historical targets here as well
|
||||||
*
|
*
|
||||||
* @param {egwAction} _action drop action we're checking
|
* @param {egwAction} _action drop action we're checking
|
||||||
@ -808,23 +808,46 @@ app.classes.filemanager = AppJS.extend(
|
|||||||
*
|
*
|
||||||
* @returns boolean true if enabled, false otherwise
|
* @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)
|
if(_action.canHaveChildren.indexOf('drop') == -1)
|
||||||
{
|
{
|
||||||
_action.canHaveChildren.push('drop');
|
_action.canHaveChildren.push('drop');
|
||||||
}
|
}
|
||||||
var actions = [
|
var actions = [];
|
||||||
|
var dir = undefined;
|
||||||
|
var current_dir, target_dir = false;
|
||||||
|
|
||||||
// Current directory
|
// Current directory
|
||||||
{id:_action.id+'_current', caption: this.get_path(), path: this.get_path()}
|
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+'_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, if directory
|
||||||
|
target_dir = this.id2path(_target.id);
|
||||||
|
dir = egw.dataGetUIDdata(_target.id);
|
||||||
actions.push({
|
actions.push({
|
||||||
id: _action.id+'_target',
|
id: _action.id+'_target',
|
||||||
caption: this.id2path(_target.id),
|
caption: target_dir,
|
||||||
path: this.id2path(_target.id),
|
path: target_dir,
|
||||||
enabled: _target && _target.iface && jQuery(_target.iface.getDOMNode()).hasClass('isDir')
|
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
|
// Last 10 folders
|
||||||
@ -838,7 +861,7 @@ app.classes.filemanager = AppJS.extend(
|
|||||||
caption: path,
|
caption: path,
|
||||||
path: path,
|
path: path,
|
||||||
group: 2,
|
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)
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -862,6 +885,12 @@ app.classes.filemanager = AppJS.extend(
|
|||||||
// Set a flag so apps can tell the difference, if they need to
|
// Set a flag so apps can tell the difference, if they need to
|
||||||
action.set_onExecute(action.parent.onExecute.fnct);
|
action.set_onExecute(action.parent.onExecute.fnct);
|
||||||
action.execute(clipboard.selected,selected[0]);
|
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++)
|
for(var i = 0; i < actions.length; i++)
|
||||||
{
|
{
|
||||||
@ -869,7 +898,7 @@ app.classes.filemanager = AppJS.extend(
|
|||||||
|
|
||||||
_action.getActionById(actions[i].id).set_onExecute(paste_exec);
|
_action.getActionById(actions[i].id).set_onExecute(paste_exec);
|
||||||
}
|
}
|
||||||
return true;
|
return actions.length > 0;
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
Reference in New Issue
Block a user