Branch 'roundcubemail-plugins-kolab-3.1' - plugins/kolab_files
Aleksander Machniak
machniak at kolabsys.com
Wed Oct 22 11:34:21 CEST 2014
plugins/kolab_files/kolab_files.js | 86 ++++++++++++++++++-
plugins/kolab_files/lib/kolab_files_engine.php | 33 +++++++
plugins/kolab_files/localization/en_US.inc | 4
plugins/kolab_files/skins/larry/style.css | 3
plugins/kolab_files/skins/larry/templates/files.html | 9 +
5 files changed, 128 insertions(+), 7 deletions(-)
New commits:
commit 1e2f711ff7514ca9ef5b52c769668f52edfadf55
Author: Aleksander Machniak <machniak at kolabsys.com>
Date: Wed Oct 22 05:34:03 2014 -0400
Add possibility to move/rename folders in Files (#3815)
Conflicts:
plugins/kolab_files/kolab_files.js
plugins/kolab_files/localization/en_US.inc
plugins/kolab_files/skins/larry/templates/files.html
diff --git a/plugins/kolab_files/kolab_files.js b/plugins/kolab_files/kolab_files.js
index 8f1ab7d..0fc8a1b 100644
--- a/plugins/kolab_files/kolab_files.js
+++ b/plugins/kolab_files/kolab_files.js
@@ -79,7 +79,8 @@ window.rcmail && rcmail.addEventListener('init', function() {
// document.onmouseup = function(e){ return p.doc_mouse_up(e); };
rcmail.gui_objects.filelist.parentNode.onmousedown = function(e){ return kolab_files_click_on_list(e); };
- rcmail.enable_command('menu-open', 'menu-save', 'files-sort', 'files-search', 'files-search-reset', true);
+ rcmail.enable_command('menu-open', 'menu-save', 'files-sort', 'files-search', 'files-search-reset',
+ 'folder-create', 'folder-rename', true);
rcmail.file_list.init();
kolab_files_list_coltypes();
@@ -317,6 +318,60 @@ function kolab_files_folder_create_dialog()
});
};
+// folder edit dialog
+function kolab_files_folder_edit_dialog()
+{
+ var dialog = $('#files-folder-edit-dialog'),
+ buttons = {}, options = [],
+ separator = file_api.env.directory_separator,
+ arr = file_api.env.folder.split(separator),
+ folder = arr.pop(),
+ path = arr.join(separator),
+ select = $('select[name="parent"]', dialog).html(''),
+ input = $('input[name="name"]', dialog).val(folder);
+
+ buttons[rcmail.gettext('kolab_files.save')] = function () {
+ var folder = '', name = input.val(), parent = select.val();
+
+ if (!name)
+ return;
+
+ if (parent)
+ folder = parent + separator;
+
+ folder += name;
+
+ file_api.folder_rename(file_api.env.folder, folder);
+ kolab_dialog_close(this);
+ };
+
+ buttons[rcmail.gettext('kolab_files.cancel')] = function () {
+ kolab_dialog_close(this);
+ };
+
+ // show dialog window
+ kolab_dialog_show(dialog, {
+ title: rcmail.gettext('kolab_files.folderedit'),
+ buttons: buttons
+ });
+
+ // Fix submitting form with Enter
+ $('form', dialog).submit(kolab_dialog_submit_handler);
+
+ // build parent selector
+ options.push($('<option>').val('').text('---'));
+ $.each(file_api.env.folders, function(i, f) {
+ var n, name = escapeHTML(f.name);
+
+ for (n=0; n<f.depth; n++)
+ name = ' ' + name;
+
+ options.push($('<option>').val(i).html(name));
+ });
+
+ select.append(options).val(path);
+};
+
// folder mounting dialog
function kolab_files_folder_mount_dialog()
{
@@ -832,6 +887,11 @@ rcube_webmail.prototype.folder_create = function()
kolab_files_folder_create_dialog();
};
+rcube_webmail.prototype.folder_rename = function()
+{
+ kolab_files_folder_edit_dialog();
+};
+
rcube_webmail.prototype.folder_mount = function()
{
kolab_files_folder_mount_dialog();
@@ -1020,6 +1080,30 @@ function kolab_files_ui()
this.folder_list();
};
+ // folder rename request
+ this.folder_rename = function(folder, new_name)
+ {
+ if (folder == new_name)
+ return;
+
+ this.env.folder_rename = new_name;
+ this.req = this.set_busy(true, 'kolab_files.folderupdating');
+ this.request('folder_move', {folder: folder, 'new': new_name}, 'folder_rename_response');
+ };
+
+ // folder create response handler
+ this.folder_rename_response = function(response)
+ {
+ if (!this.response(response))
+ return;
+
+ this.display_message('kolab_files.folderupdatenotice', 'confirmation');
+
+ // refresh folders and files list
+ this.env.folder = this.env.folder_rename;
+ this.folder_list();
+ };
+
// folder mount (external storage) request
this.folder_mount = function(data)
{
diff --git a/plugins/kolab_files/lib/kolab_files_engine.php b/plugins/kolab_files/lib/kolab_files_engine.php
index b345207..d9a087e 100644
--- a/plugins/kolab_files/lib/kolab_files_engine.php
+++ b/plugins/kolab_files/lib/kolab_files_engine.php
@@ -122,6 +122,7 @@ class kolab_files_engine
// register template objects for dialogs (and main interface)
$this->rc->output->add_handlers(array(
'folder-create-form' => array($this, 'folder_create_form'),
+ 'folder-edit-form' => array($this, 'folder_edit_form'),
'folder-mount-form' => array($this, 'folder_mount_form'),
'folder-auth-options'=> array($this, 'folder_auth_options'),
'file-search-form' => array($this, 'file_search_form'),
@@ -194,6 +195,38 @@ class kolab_files_engine
}
/**
+ * Template object for folder editing form
+ */
+ public function folder_edit_form($attrib)
+ {
+ $attrib['name'] = 'folder-edit-form';
+ if (empty($attrib['id'])) {
+ $attrib['id'] = 'folder-edit-form';
+ }
+
+ $input_name = new html_inputfield(array('id' => 'folder-edit-name', 'name' => 'name', 'size' => 30));
+ $select_parent = new html_select(array('id' => 'folder-edit-parent', 'name' => 'parent'));
+ $table = new html_table(array('cols' => 2, 'class' => 'propform'));
+
+ $table->add('title', html::label('folder-name', rcube::Q($this->plugin->gettext('foldername'))));
+ $table->add(null, $input_name->show());
+ $table->add('title', html::label('folder-parent', rcube::Q($this->plugin->gettext('folderinside'))));
+ $table->add(null, $select_parent->show());
+
+ $out = $table->show();
+
+ // add form tag around text field
+ if (empty($attrib['form'])) {
+ $out = $this->rc->output->form_tag($attrib, $out);
+ }
+
+ $this->plugin->add_label('folderupdating', 'folderupdatenotice', 'save', 'folderedit', 'cancel');
+ $this->rc->output->add_gui_object('folder-edit-form', $attrib['id']);
+
+ return $out;
+ }
+
+ /**
* Template object for folder mounting form
*/
public function folder_mount_form($attrib)
diff --git a/plugins/kolab_files/localization/en_US.inc b/plugins/kolab_files/localization/en_US.inc
index 53d42d4..476295e 100644
--- a/plugins/kolab_files/localization/en_US.inc
+++ b/plugins/kolab_files/localization/en_US.inc
@@ -11,8 +11,8 @@ $labels['fromcloud'] = 'From cloud...';
$labels['selectfiles'] = 'Select file(s) to attach...';
$labels['attachsel'] = 'Attach selected';
$labels['foldercreate'] = 'Create folder';
+$labels['folderedit'] = 'Edit folder';
$labels['foldermount'] = 'Add storage';
-$labels['folderrename'] = 'Rename folder';
$labels['folderdelete'] = 'Delete folder';
$labels['folderinside'] = 'Insert inside';
@@ -45,10 +45,12 @@ $labels['uploading'] = 'Uploading file(s)...';
$labels['attaching'] = 'Attaching file(s)...';
$labels['authenticating'] = 'Authenticating...';
$labels['foldercreating'] = 'Creating folder...';
+$labels['folderupdating'] = 'Updating folder...';
$labels['foldermounting'] = 'Adding external storage...';
$labels['folderdeleting'] = 'Deleting folder...';
$labels['folderdeleteconfirm'] = 'Are you sure you want to delete selected folder?';
$labels['folderdeletenotice'] = 'Folder deleted successfully.';
+$labels['folderupdatenotice'] = 'Folder updated successfully.';
$labels['foldercreatenotice'] = 'Folder created successfully.';
$labels['foldermountnotice'] = 'Storage added successfully.';
$labels['folderauthtitle'] = 'Logon to $title';
diff --git a/plugins/kolab_files/skins/larry/style.css b/plugins/kolab_files/skins/larry/style.css
index 800534c..c09e56a 100644
--- a/plugins/kolab_files/skins/larry/style.css
+++ b/plugins/kolab_files/skins/larry/style.css
@@ -276,7 +276,8 @@
#files-file-edit-dialog,
#files-folder-mount-dialog,
#files-folder-auth-dialog,
-#files-folder-create-dialog {
+#files-folder-create-dialog,
+#files-folder-edit-dialog {
display: none;
}
diff --git a/plugins/kolab_files/skins/larry/templates/files.html b/plugins/kolab_files/skins/larry/templates/files.html
index 7987260..d7e2c5d 100644
--- a/plugins/kolab_files/skins/larry/templates/files.html
+++ b/plugins/kolab_files/skins/larry/templates/files.html
@@ -47,10 +47,8 @@
<div id="folderoptions" class="popupmenu">
<ul id="folderoptionsmenu" class="toolbarmenu">
-<!--
- <li><roundcube:button command="files-folder-edit" label="edit" classAct="active" /></li>
--->
- <li><roundcube:button command="files-folder-delete" label="delete" classAct="active" /></li>
+ <li role="menuitem"><roundcube:button command="folder-rename" label="rename" classAct="active" /></li>
+ <li role="menuitem"><roundcube:button command="files-folder-delete" label="delete" classAct="active" /></li>
<roundcube:if condition="!empty(env:external_sources)" />
<li><roundcube:button command="folder-mount" label="kolab_files.foldermount" classAct="active" /></li>
<roundcube:endif />
@@ -62,6 +60,9 @@
<div id="files-folder-create-dialog">
<roundcube:object name="folder-create-form" />
</div>
+<div id="files-folder-edit-dialog">
+ <roundcube:object name="folder-edit-form" />
+</div>
<div id="files-folder-mount-dialog">
<roundcube:object name="folder-mount-form" />
</div>
More information about the commits
mailing list