diff --git a/filemanager/inc/class.filemanager_ui.inc.php b/filemanager/inc/class.filemanager_ui.inc.php index e4cf32f9c8..cc3afd49c7 100644 --- a/filemanager/inc/class.filemanager_ui.inc.php +++ b/filemanager/inc/class.filemanager_ui.inc.php @@ -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(); } diff --git a/filemanager/js/app.js b/filemanager/js/app.js index 2837e63cde..943f92e538 100644 --- a/filemanager/js/app.js +++ b/filemanager/js/app.js @@ -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,14 +612,23 @@ 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); - // check if target is a file --> use it's directory instead - var data = egw.dataGetUIDdata(_target.id); - if (!data || data.data.mime != 'httpd/unix-directory') + + // 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.dirname(dst); + dst = this.id2path(_target.id); + + // check if target is a file --> use it's directory instead + var data = egw.dataGetUIDdata(_target.id); + if (!data || data.data.mime != 'httpd/unix-directory') + { + dst = this.dirname(dst); + } } this._do_action(_action.id.replace("file_drop_",''), src, false, dst);