summaryrefslogtreecommitdiff
path: root/plugins/kolab_files
diff options
context:
space:
mode:
authorAleksander Machniak <machniak@kolabsys.com>2014-10-22 09:28:07 (GMT)
committerAleksander Machniak <machniak@kolabsys.com>2014-10-22 09:28:07 (GMT)
commita4ec2d2287db4264f9ba9130b9f3f51f6cc99e56 (patch)
tree27fc6847794b5fd353b397ad112422120b6c24e4 /plugins/kolab_files
parent9763bb1d1d35163925a3dc300602881178e122be (diff)
downloadroundcubemail-plugins-kolab-a4ec2d2287db4264f9ba9130b9f3f51f6cc99e56.tar.gz
Add possibility to move/rename folders in Files (#3815)
Diffstat (limited to 'plugins/kolab_files')
-rw-r--r--plugins/kolab_files/kolab_files.js86
-rw-r--r--plugins/kolab_files/lib/kolab_files_engine.php33
-rw-r--r--plugins/kolab_files/localization/en_US.inc4
-rw-r--r--plugins/kolab_files/skins/larry/style.css3
-rw-r--r--plugins/kolab_files/skins/larry/templates/files.html8
5 files changed, 129 insertions, 5 deletions
diff --git a/plugins/kolab_files/kolab_files.js b/plugins/kolab_files/kolab_files.js
index 21ef475..66d2e66 100644
--- a/plugins/kolab_files/kolab_files.js
+++ b/plugins/kolab_files/kolab_files.js
@@ -99,7 +99,8 @@ window.rcmail && rcmail.addEventListener('init', function() {
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', 'folder-create', 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();
@@ -362,6 +363,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 = '&nbsp;&nbsp;&nbsp;' + name;
+
+ options.push($('<option>').val(i).html(name));
+ });
+
+ select.append(options).val(path);
+};
+
// folder mounting dialog
function kolab_files_folder_mount_dialog()
{
@@ -957,6 +1012,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();
@@ -1157,6 +1217,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 d319fe7..f4c78ef 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 9ddecef..fa15086 100644
--- a/plugins/kolab_files/localization/en_US.inc
+++ b/plugins/kolab_files/localization/en_US.inc
@@ -20,6 +20,7 @@ $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';
@@ -54,10 +55,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';
@@ -90,6 +93,7 @@ $labels['arialabellistoptions'] = 'Files list options';
$labels['arialabelfolderoptions'] = 'Folder actions';
$labels['arialabelfileeditform'] = 'File editing form';
$labels['arialabelfoldercreateform'] = 'Folder creation form';
+$labels['arialabelfoldereditform'] = 'Folder editing form';
$labels['arialabelfoldermountform'] = 'External storage form';
$labels['arialabelfolderauthform'] = 'External storage authentication form';
$labels['arialabelfolderlist'] = 'Folder/Collection selection';
diff --git a/plugins/kolab_files/skins/larry/style.css b/plugins/kolab_files/skins/larry/style.css
index 526395e..94ae49e 100644
--- a/plugins/kolab_files/skins/larry/style.css
+++ b/plugins/kolab_files/skins/larry/style.css
@@ -295,7 +295,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 4494e3e..149826b 100644
--- a/plugins/kolab_files/skins/larry/templates/files.html
+++ b/plugins/kolab_files/skins/larry/templates/files.html
@@ -56,9 +56,7 @@
<div id="folderoptions" class="popupmenu" data-editable="true" aria-hidden="true">
<h3 id="aria-label-folderoptions" class="voice"><roundcube:label name="kolab_files.folderoptions" /></h3>
<ul id="folderoptionsmenu" class="toolbarmenu" role="menu" aria-labelledby="aria-label-folderoptions">
-<!--
- <li role="menuitem"><roundcube:button command="files-folder-edit" label="edit" 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 role="menuitem"><roundcube:button command="folder-mount" label="kolab_files.foldermount" classAct="active" /></li>
@@ -72,6 +70,10 @@
<h3 id="aria-label-foldercreateform" class="voice"><roundcube:label name="kolab_files.arialabelfoldercreateform" /></h3>
<roundcube:object name="folder-create-form" />
</div>
+<div id="files-folder-edit-dialog" role="dialog" aria-labelledby="aria-label-foldereditform" aria-hidden="true">
+ <h3 id="aria-label-foldereditform" class="voice"><roundcube:label name="kolab_files.arialabelfoldereditform" /></h3>
+ <roundcube:object name="folder-edit-form" />
+</div>
<div id="files-folder-mount-dialog" role="dialog" aria-labelledby="aria-label-foldermountform" aria-hidden="true">
<h3 id="aria-label-foldermountform" class="voice"><roundcube:label name="kolab_files.arialabelfoldermountform" /></h3>
<roundcube:object name="folder-mount-form" />