- Add 'Create directory' to context menu and placeholder actions

- Hide mail drop action when not allowed
- Fix dropping in empty directory gave an error
This commit is contained in:
Nathan Gray 2014-11-19 17:58:02 +00:00
parent 3eb9f04221
commit 57f2e3c859
2 changed files with 33 additions and 9 deletions

View File

@ -144,6 +144,12 @@ class filemanager_ui
'allowOnMultiple' => false,
'onExecute' => 'javaScript:app.filemanager.editprefs',
),
'mkdir' => array(
'caption' => lang('Create directory'),
'group' => $group,
'allowOnMultiple' => false,
'onExecute' => 'javaScript:app.filemanager.createdir'
),
'mail' => array(
'caption' => lang('Mail files'),
'icon' => 'filemanager/mail_post_to',
@ -176,7 +182,8 @@ class filemanager_ui
'file_drop_mail' => array(
'type' => 'drop',
'acceptedTypes' => 'mail',
'onExecute' => 'javaScript:app.filemanager.drop'
'onExecute' => 'javaScript:app.filemanager.drop',
'hideOnDisabled' => true
),
'file_drop_move' => array(
'icon' => 'stylite/move',
@ -282,7 +289,7 @@ class filemanager_ui
'is_parent_value'=> egw_vfs::DIR_MIME_TYPE,
'header_left' => 'filemanager.index.header_left',
'favorites' => true,
'placeholder_actions' => array('file_drop_mail','file_drop_move','file_drop_copy','file_drop_symlink')
'placeholder_actions' => array('mkdir','file_drop_mail','file_drop_move','file_drop_copy','file_drop_symlink')
);
$content['nm']['path'] = static::get_home_dir();
}

View File

@ -433,14 +433,22 @@ app.classes.filemanager = AppJS.extend(
/**
* Prompt user for directory to create
*
* @param {egwAction|undefined} action Action, or undefined if called directly
* @param {egwActionObject[] | undefined} selected Selected row, or undefined if called directly
*/
createdir: function()
createdir: function(action, selected)
{
var dir = prompt(this.egw.lang('New directory'));
if (dir)
{
var path = this.get_path();
if(action)
{
var paths = this._elems2paths(selected);
if(paths[0]) path = paths[0];
}
this._do_action('createdir', dir, true); // true=synchronous request
this.change_dir((path == '/' ? '' : path)+'/'+dir);
}
@ -604,8 +612,16 @@ app.classes.filemanager = AppJS.extend(
drop: function(_action, _elems, _target)
{
var src = this._elems2paths(_elems);
var dst = this.id2path(_target.id);
//alert(_action.id+': '+src.join(', ')+' --> '+dst);
// Target will be missing ID if directory is empty
// so start with the current directory
var dst = this.get_path();
// File(s) were dropped on a row, they want them inside
if(_target && _target.id)
{
dst = this.id2path(_target.id);
// check if target is a file --> use it's directory instead
var data = egw.dataGetUIDdata(_target.id);
@ -613,6 +629,7 @@ app.classes.filemanager = AppJS.extend(
{
dst = this.dirname(dst);
}
}
this._do_action(_action.id.replace("file_drop_",''), src, false, dst);
},