From 45430717d50ecfdc7bed1e2664357eac5f6b1e24 Mon Sep 17 00:00:00 2001 From: Aleksander Machniak Date: Fri, 13 Nov 2015 15:20:46 +0100 Subject: [PATCH] Add "Rename" button, remove edit icon from the list --- plugins/kolab_files/kolab_files.js | 24 ++++++++++--------- .../kolab_files/lib/kolab_files_engine.php | 18 +++++++------- plugins/kolab_files/localization/en_US.inc | 4 ++-- plugins/kolab_files/skins/larry/style.css | 10 +------- .../skins/larry/templates/files.html | 7 +++--- 5 files changed, 29 insertions(+), 34 deletions(-) diff --git a/plugins/kolab_files/kolab_files.js b/plugins/kolab_files/kolab_files.js index 24131c7b..82dc2f17 100644 --- a/plugins/kolab_files/kolab_files.js +++ b/plugins/kolab_files/kolab_files.js @@ -102,7 +102,7 @@ window.rcmail && window.files_api && rcmail.addEventListener('init', function() } // "one file only" commands - rcmail.env.file_commands = ['files-get']; + rcmail.env.file_commands = ['files-get', 'files-rename']; // "one or more file" commands rcmail.env.file_commands_all = ['files-delete', 'files-move', 'files-copy']; @@ -504,10 +504,10 @@ function kolab_files_folder_mount_dialog() }); }; -// file edition dialog -function kolab_files_file_edit_dialog(file) +// file rename dialog +function kolab_files_file_rename_dialog(file) { - var dialog = $('#files-file-edit-dialog'), + var dialog = $('#files-file-rename-dialog'), buttons = {}, name = file_api.file_name(file) input = $('input[name="name"]', dialog).val(name); @@ -519,9 +519,9 @@ function kolab_files_file_edit_dialog(file) name = folder + file_api.env.directory_separator + name; - // @TODO: now we only update filename if (name != file) file_api.file_rename(file, name); + kolab_dialog_close(this); }; buttons[rcmail.gettext('kolab_files.cancel')] = function () { @@ -533,7 +533,7 @@ function kolab_files_file_edit_dialog(file) // show dialog window kolab_dialog_show(dialog, { - title: rcmail.gettext('kolab_files.fileedit'), + title: rcmail.gettext('kolab_files.renamefile'), buttons: buttons, button_classes: ['mainaction'] }); @@ -829,7 +829,7 @@ function kolab_files_list_select(list) rcmail.env.viewer = file_api.file_type_supported(type, rcmail.env.files_caps); if (!file_api.is_writable(file.replace(/\/[^/]+$/, ''))) - rcmail.enable_command('files-delete', false); + rcmail.enable_command('files-delete', 'files-rename', false); } else rcmail.env.viewer = 0; @@ -1239,6 +1239,12 @@ rcube_webmail.prototype.files_create = function() kolab_files_file_create_dialog(); }; +rcube_webmail.prototype.files_rename = function() +{ + var files = kolab_files_selected(); + kolab_files_file_rename_dialog(files[0]); +}; + rcube_webmail.prototype.folder_create = function() { kolab_files_folder_create_dialog(); @@ -2155,10 +2161,6 @@ function kolab_files_ui() .html(row) .attr({id: 'rcmrow' + index, 'data-file': file, 'data-type': data.type}); - $('td.options > span', row).click(function(e) { - kolab_files_file_edit_dialog(file); - }); - // collection (or search) lists files from all folders // display file name with full path as title if (!this.env.folder) diff --git a/plugins/kolab_files/lib/kolab_files_engine.php b/plugins/kolab_files/lib/kolab_files_engine.php index ba325715..e21e4519 100644 --- a/plugins/kolab_files/lib/kolab_files_engine.php +++ b/plugins/kolab_files/lib/kolab_files_engine.php @@ -142,7 +142,7 @@ class kolab_files_engine 'folder-mount-form' => array($this, 'folder_mount_form'), 'folder-auth-options'=> array($this, 'folder_auth_options'), 'file-search-form' => array($this, 'file_search_form'), - 'file-edit-form' => array($this, 'file_edit_form'), + 'file-rename-form' => array($this, 'file_rename_form'), 'file-create-form' => array($this, 'file_create_form'), 'filelist' => array($this, 'file_list'), 'filequotadisplay' => array($this, 'quota_display'), @@ -329,19 +329,19 @@ class kolab_files_engine } /** - * Template object for file_edit form + * Template object for file_rename form */ - public function file_edit_form($attrib) + public function file_rename_form($attrib) { - $attrib['name'] = 'file-edit-form'; + $attrib['name'] = 'file-rename-form'; if (empty($attrib['id'])) { - $attrib['id'] = 'file-edit-form'; + $attrib['id'] = 'file-rename-form'; } - $input_name = new html_inputfield(array('id' => 'file-edit-name', 'name' => 'name', 'size' => 30)); + $input_name = new html_inputfield(array('id' => 'file-rename-name', 'name' => 'name', 'size' => 30)); $table = new html_table(array('cols' => 2, 'class' => 'propform')); - $table->add('title', html::label('file-edit-name', rcube::Q($this->plugin->gettext('filename')))); + $table->add('title', html::label('file-rename-name', rcube::Q($this->plugin->gettext('filename')))); $table->add(null, $input_name->show()); $out = $table->show(); @@ -351,8 +351,8 @@ class kolab_files_engine $out = $this->rc->output->form_tag($attrib, $out); } - $this->plugin->add_label('save', 'cancel', 'fileupdating', 'fileedit'); - $this->rc->output->add_gui_object('file-edit-form', $attrib['id']); + $this->plugin->add_label('save', 'cancel', 'fileupdating', 'renamefile'); + $this->rc->output->add_gui_object('file-rename-form', $attrib['id']); return $out; } diff --git a/plugins/kolab_files/localization/en_US.inc b/plugins/kolab_files/localization/en_US.inc index 2d3b1acf..e9eeeee7 100644 --- a/plugins/kolab_files/localization/en_US.inc +++ b/plugins/kolab_files/localization/en_US.inc @@ -36,14 +36,14 @@ $labels['get'] = 'Download'; $labels['getfile'] = 'Download file'; $labels['view'] = 'View'; $labels['viewfile'] = 'View file'; -$labels['rename'] = 'Rename file'; +$labels['rename'] = 'Rename'; $labels['deletefile'] = 'Delete file(s)'; $labels['edit'] = 'Edit'; $labels['editfile'] = 'Edit file'; $labels['save'] = 'Save'; $labels['savefile'] = 'Save file'; $labels['printfile'] = 'Print file'; -$labels['fileedit'] = 'File properties'; +$labels['renamefile'] = 'Rename a file'; $labels['createfile'] = 'Create a file'; $labels['createandedit'] = 'Create and Edit'; $labels['documenttitle'] = 'Title:'; diff --git a/plugins/kolab_files/skins/larry/style.css b/plugins/kolab_files/skins/larry/style.css index c992f090..de18dcfc 100644 --- a/plugins/kolab_files/skins/larry/style.css +++ b/plugins/kolab_files/skins/larry/style.css @@ -256,7 +256,6 @@ .filelist tr > .options { width: 32px; - cursor: pointer; } .filelist thead tr th.filename, @@ -318,13 +317,6 @@ border-radius: 4px 0 0 0; } -.filelist tbody tr td.options:hover span { - width: 26px; - height: 18px; - background: url(../../../../skins/larry/images/buttons.png) -5px -417px no-repeat; - display: block; -} - .filelist td.filename { padding: 0 4px; } @@ -387,7 +379,7 @@ #files-dialog, #files-compose-dialog, -#files-file-edit-dialog, +#files-file-rename-dialog, #files-file-create-dialog, #files-folder-mount-dialog, #files-folder-auth-dialog, diff --git a/plugins/kolab_files/skins/larry/templates/files.html b/plugins/kolab_files/skins/larry/templates/files.html index df92e0b0..0d1a6da2 100644 --- a/plugins/kolab_files/skins/larry/templates/files.html +++ b/plugins/kolab_files/skins/larry/templates/files.html @@ -22,6 +22,7 @@ + @@ -92,9 +93,9 @@

-