From a4fdc052abf51e83af899bb31aa040bec5fef08c Mon Sep 17 00:00:00 2001 From: Hadi Nategh Date: Tue, 26 Sep 2017 18:41:57 +0200 Subject: [PATCH] Filemanager "New" actions: - Add "New" actions into nm header as drop down list - Re-arrange actions in contextmenu - Let Etemplate modifies sel_options if extra changes are available --- api/src/Etemplate.php | 7 +- filemanager/inc/class.filemanager_ui.inc.php | 71 +++++++++++++------- filemanager/js/app.js | 30 ++++++--- filemanager/templates/default/app.css | 13 +++- filemanager/templates/default/index.xet | 2 +- filemanager/templates/mobile/app.css | 26 +++---- filemanager/templates/pixelegg/app.css | 26 +++---- filemanager/templates/pixelegg/app.less | 15 +++-- 8 files changed, 120 insertions(+), 70 deletions(-) diff --git a/api/src/Etemplate.php b/api/src/Etemplate.php index ce1eaa6034..323a730d2c 100644 --- a/api/src/Etemplate.php +++ b/api/src/Etemplate.php @@ -129,6 +129,11 @@ class Etemplate extends Etemplate\Widget\Template { $readonlys = array_merge($readonlys, $extra['readonlys']); } + + if ($extra['sel_options'] && is_array($extra['sel_options'])) + { + $sel_options = array_merge($sel_options, $extra['sel_options']); + } } } unset($hook_data); @@ -515,7 +520,7 @@ class Etemplate extends Etemplate\Widget\Template { $this->dom_id = $new_id; } - + /** * Make sure there's a new request, in case of multiple Etemplates in one call. * Normally this isn't a problem, but if you've got an etemplate in the sidebox, diff --git a/filemanager/inc/class.filemanager_ui.inc.php b/filemanager/inc/class.filemanager_ui.inc.php index e35160ad26..3fd65691ab 100644 --- a/filemanager/inc/class.filemanager_ui.inc.php +++ b/filemanager/inc/class.filemanager_ui.inc.php @@ -115,6 +115,24 @@ class filemanager_ui return $view; } + /** + * Method to build select options out of actions + * @param type $actions + * @return type + */ + public static function convertActionsToselOptions ($actions) + { + $sel_options = array (); + foreach ($actions as $action => $value) + { + $sel_options[$action] = array ( + 'label' => $value['caption'], + 'icon' => $value['icon'] + ); + } + return $sel_options; + } + /** * Context menu * @@ -138,33 +156,10 @@ class filemanager_ui 'document' => array ( 'caption' => 'Document', 'icon' => 'new', - 'onExecute' => 'javaScript:app.filemanager.editor_new', + 'onExecute' => 'javaScript:app.filemanager.create_new', ) ) ), - 'saveas' => array( - 'caption' => lang('Save as'), - 'group' => $group, - 'allowOnMultiple' => true, - 'icon' => 'filesave', - 'onExecute' => 'javaScript:app.filemanager.force_download', - 'disableClass' => 'isDir', - 'enabled' => 'javaScript:app.filemanager.is_multiple_allowed' - ), - 'saveaszip' => array( - 'caption' => lang('Save as ZIP'), - 'group' => $group, - 'allowOnMultiple' => true, - 'icon' => 'save_zip', - 'postSubmit' => true - ), - 'edit' => array( - 'caption' => lang('Edit settings'), - 'group' => $group, - 'allowOnMultiple' => false, - 'onExecute' => Api\Header\UserAgent::mobile()?'javaScript:app.filemanager.viewEntry':'javaScript:app.filemanager.editprefs', - 'mobileViewTemplate' => 'file?'.filemtime(Api\Etemplate\Widget\Template::rel2path('/filemanager/templates/mobile/file.xet')) - ), 'mkdir' => array( 'caption' => lang('Create directory'), 'icon' => 'filemanager/button_createdir', @@ -172,6 +167,13 @@ class filemanager_ui 'allowOnMultiple' => false, 'onExecute' => 'javaScript:app.filemanager.createdir' ), + 'edit' => array( + 'caption' => lang('Edit settings'), + 'group' => $group, + 'allowOnMultiple' => false, + 'onExecute' => Api\Header\UserAgent::mobile()?'javaScript:app.filemanager.viewEntry':'javaScript:app.filemanager.editprefs', + 'mobileViewTemplate' => 'file?'.filemtime(Api\Etemplate\Widget\Template::rel2path('/filemanager/templates/mobile/file.xet')) + ), 'mail' => array( 'caption' => lang('Share files'), 'icon' => 'filemanager/mail_post_to', @@ -186,6 +188,24 @@ class filemanager_ui 'onExecute' => 'javaScript:app.filemanager.share_link' )), ), + 'saveas' => array( + 'caption' => lang('Save as'), + 'group' => $group, + 'allowOnMultiple' => true, + 'icon' => 'filesave', + 'onExecute' => 'javaScript:app.filemanager.force_download', + 'disableClass' => 'isDir', + 'enabled' => 'javaScript:app.filemanager.is_multiple_allowed', + 'shortcut' => array('ctrl' => true, 'shift' => true, 'keyCode' => 83, 'caption' => 'Ctrl + Shift + S'), + ), + 'saveaszip' => array( + 'caption' => lang('Save as ZIP'), + 'group' => $group, + 'allowOnMultiple' => true, + 'icon' => 'save_zip', + 'postSubmit' => true, + 'shortcut' => array('ctrl' => true, 'shift' => true, 'keyCode' => 90, 'caption' => 'Ctrl + Shift + Z'), + ), 'egw_paste' => array( 'enabled' => false, 'group' => $group + 0.5, @@ -546,6 +566,9 @@ class filemanager_ui '5' => 'Files from links', '0' => 'Files from subdirectories', ); + + $sel_options['new'] = self::convertActionsToselOptions($content['nm']['actions']['new']['children']); + // sharing has no divAppbox, we need to set popupMainDiv instead, to be able to drop files everywhere if (substr($_SERVER['SCRIPT_FILENAME'], -10) == '/share.php') { diff --git a/filemanager/js/app.js b/filemanager/js/app.js index 4288620ee7..23a9e69d3c 100644 --- a/filemanager/js/app.js +++ b/filemanager/js/app.js @@ -102,6 +102,13 @@ app.classes.filemanager = AppJS.extend( this.set_readonly.apply(this, this.readonly); delete this.readonly; } + + if (name == 'filemanager.index') + { + var new_options = this.et2.getArrayMgr('sel_options').getEntry('new'); + var new_widget = this.et2.getWidgetById('new'); + new_widget.set_select_options(new_options); + } }, /** @@ -1262,15 +1269,6 @@ app.classes.filemanager = AppJS.extend( } }, - /** - * Method to create a new document - */ - editor_new: function () { - egw.open_link(egw.link('/index.php', { - menuaction: 'filemanager.filemanager_ui.editor' - }), '', egw.link_get_registry('filemanager','view_popup')); - }, - /** * Function to check wheter selected file is editable. ATM only .odt is supported. * @@ -1285,5 +1283,19 @@ app.classes.filemanager = AppJS.extend( mime = this.et2._inst.widgetContainer.getWidgetById('$row'); return data.data.mime.match(mime.mime_odf_regex)?true:false; + }, + + /** + * Method to create a new document + * @param {object} _action either action or node + * @param {object} _selected either widget or selected row + * + * @return {boolean} returns true + */ + create_new: function (_action, _selected) { + egw.open_link(egw.link('/index.php', { + menuaction: 'filemanager.filemanager_ui.editor' + }), '', egw.link_get_registry('filemanager','view_popup')); + return true; } }); diff --git a/filemanager/templates/default/app.css b/filemanager/templates/default/app.css index c7e9f08ef8..9163930681 100644 --- a/filemanager/templates/default/app.css +++ b/filemanager/templates/default/app.css @@ -85,7 +85,7 @@ table.egwGridView_grid .tile .file_tile { * Select file dialog */ .selectPath { font-weight: bold; width: 98% } -.selectPathContainer { width: 470px; overflow: auto; } + .selectName input { width: 100%; } .selectMime select { width: 100%; } .displayNone input, input.displayNone { display: none; } @@ -177,4 +177,13 @@ div.editInfoMarker { width:5px; border-radius: none; } -#filemanager-index_nm .et2_file div.progress {position:absolute;} \ No newline at end of file +#filemanager-index_nm .et2_file div.progress {position:absolute;} + +#filemanager-index_new_wrapper { + float: left; + margin-right: 6px; +} + +#filemanager-index_new_wrapper .ui-icon-triangle-1-s { + background-position: 0px -192px; +} \ No newline at end of file diff --git a/filemanager/templates/default/index.xet b/filemanager/templates/default/index.xet index b33ff73f35..eb7b4e07fa 100644 --- a/filemanager/templates/default/index.xet +++ b/filemanager/templates/default/index.xet @@ -54,7 +54,7 @@