plugins/kolab_files

Aleksander Machniak machniak at kolabsys.com
Wed Mar 6 19:32:31 CET 2013


 plugins/kolab_files/kolab_files.js             |   62 +++++++++++++++++++++----
 plugins/kolab_files/lib/kolab_files_engine.php |    5 +-
 plugins/kolab_files/localization/en_US.inc     |    7 ++
 3 files changed, 64 insertions(+), 10 deletions(-)

New commits:
commit 1e242544333fcb5062ce874d20c16f3bf07deda2
Author: Aleksander Machniak <machniak at kolabsys.com>
Date:   Wed Mar 6 19:32:10 2013 +0100

    Implemented files deletion, small improvements

diff --git a/plugins/kolab_files/kolab_files.js b/plugins/kolab_files/kolab_files.js
index a1c72fa..d4d6122 100644
--- a/plugins/kolab_files/kolab_files.js
+++ b/plugins/kolab_files/kolab_files.js
@@ -83,7 +83,10 @@ window.rcmail && rcmail.addEventListener('init', function() {
       kolab_files_list_coltypes();
     }
 
+    // "one file only" commands
     rcmail.env.file_commands = ['files-get'];
+    // "one or more file" commands
+    rcmail.env.file_commands_all = ['files-delete'];
 
     kolab_files_init();
     file_api.folder_list();
@@ -346,6 +349,7 @@ kolab_files_list_select = function(list)
 {
   var selected = list.selection.length;
 
+  rcmail.enable_command(rcmail.env.file_commands_all, selected);
   rcmail.enable_command(rcmail.env.file_commands, selected == 1);
 
     // reset all-pages-selection
@@ -353,6 +357,19 @@ kolab_files_list_select = function(list)
 //    rcmail.select_all_mode = false;
 };
 
+kolab_files_selected = function()
+{
+  var files = [];
+  $.each(rcmail.file_list.get_selection(), function(i, v) {
+    var name, row = $('#rcmrow'+v);
+
+    if (row.length == 1 && (name = row.data('file')))
+      files.push(name);
+  });
+
+  return files;
+};
+
 rcube_webmail.prototype.files_sort = function(props)
 {
   var params = {},
@@ -392,10 +409,19 @@ rcube_webmail.prototype.files_search_reset = function()
 
 rcube_webmail.prototype.files_folder_delete = function()
 {
-  if (confirm(this.get_label('deletefolderconfirm')))
+  if (confirm(this.get_label('kolab_files.folderdeleteconfirm')))
     file_api.folder_delete(file_api.env.folder);
 };
 
+rcube_webmail.prototype.files_delete = function()
+{
+  if (!confirm(this.get_label('kolab_files.filedeleteconfirm')))
+    return;
+
+  var files = kolab_files_selected();
+  file_api.file_delete(files);
+};
+
 rcube_webmail.prototype.files_upload = function(form)
 {
   if (form)
@@ -414,11 +440,10 @@ rcube_webmail.prototype.files_list_update = function(head)
 
 rcube_webmail.prototype.files_get = function()
 {
-  var id = this.file_list.get_selection();
+  var files = kolab_files_selected();
 
-  if (id = $('#rcmrow'+id).data('file')) {
-    file_api.file_get(id, {'force-download': true});
-  }
+  if (files.length == 1)
+    file_api.file_get(files[0], {'force-download': true});
 };
 
 
@@ -451,9 +476,9 @@ function kolab_files_ui()
   };
 
   // displays error message
-  this.display_message = function(label)
+  this.display_message = function(label, type)
   {
-    return rcmail.display_message(this.t(label));
+    return rcmail.display_message(this.t(label), type);
   };
 
   this.http_error = function(request, status, err)
@@ -544,6 +569,7 @@ function kolab_files_ui()
     this.req = this.set_busy(true, 'loading');
 
     rcmail.enable_command(rcmail.env.file_commands, false);
+    rcmail.enable_command(rcmail.env.file_commands_all, false);
     rcmail.file_list.clear();
 
     this.get('file_list', params, 'file_list_response');
@@ -610,6 +636,8 @@ function kolab_files_ui()
     if (!this.response(response))
       return;
 
+    this.display_message('kolab_files.foldercreatenotice', 'confirmation');
+
     // refresh folders list
     this.folder_list();
   };
@@ -617,7 +645,7 @@ function kolab_files_ui()
   // folder delete request
   this.folder_delete = function(folder)
   {
-    this.req = this.set_busy(true, 'folderdeleting');
+    this.req = this.set_busy(true, 'kolab_files.folderdeleting');
     this.get('folder_delete', {folder: folder}, 'folder_delete_response');
   };
 
@@ -629,6 +657,7 @@ function kolab_files_ui()
 
     this.env.folder = null;
     rcmail.enable_command('files-folder-delete', 'files-folder-rename', false);
+    this.display_message('kolab_files.folderdeletenotice', 'confirmation');
 
     // refresh folders list
     this.folder_list();
@@ -664,6 +693,23 @@ function kolab_files_ui()
     rcmail.redirect(this.env.url + this.url('file_get', params));
   };
 
+  // file(s) delete request
+  this.file_delete = function(files)
+  {
+    this.req = this.set_busy(true, 'kolab_files.filedeleting');
+    this.get('file_delete', {folder: this.env.folder, file: files}, 'file_delete_response');
+  };
+
+  // file(s) delete response handler
+  this.file_delete_response = function(response)
+  {
+    if (!this.response(response))
+      return;
+
+    this.display_message('kolab_files.filedeletenotice', 'confirmation');
+    this.file_list();
+  };
+
   // file upload request
   this.file_upload = function(form)
   {
diff --git a/plugins/kolab_files/lib/kolab_files_engine.php b/plugins/kolab_files/lib/kolab_files_engine.php
index fa46ac8..3e6f99b 100644
--- a/plugins/kolab_files/lib/kolab_files_engine.php
+++ b/plugins/kolab_files/lib/kolab_files_engine.php
@@ -460,8 +460,9 @@ class kolab_files_engine
         ));
 
 
-        $this->rc->output->add_label('deletefolderconfirm', 'folderdeleting',
-          'kolab_files.foldercreating', 'kolab_files.uploading');
+        $this->rc->output->add_label('deletefolderconfirm', 'kolab_files.folderdeleting',
+          'kolab_files.foldercreating', 'kolab_files.uploading', 'kolab_files.filedeleteconfirm',
+          'kolab_files.folderdeleteconfirm', 'kolab_files.filedeleting');
 
         $this->rc->output->set_pagetitle($this->plugin->gettext('files'));
         $this->rc->output->send('kolab_files.files');
diff --git a/plugins/kolab_files/localization/en_US.inc b/plugins/kolab_files/localization/en_US.inc
index 2233f30..e453f5e 100644
--- a/plugins/kolab_files/localization/en_US.inc
+++ b/plugins/kolab_files/localization/en_US.inc
@@ -26,8 +26,15 @@ $labels['deletefile'] = 'Delete selected file(s)';
 
 $labels['uploading'] = 'Uploading file(s)...';
 $labels['foldercreating'] = 'Creating folder...';
+$labels['folderdeleting'] = 'Deleting folder...';
+$labels['folderdeleteconfirm'] = 'Are you sure you want to delete selected folder?';
+$labels['folderdeletenotice'] = 'Folder deleted successfully.';
+$labels['foldercreatenotice'] = 'Folder created successfully.';
 $labels['saveallnotice'] = 'Successfully saved $n file(s).';
 $labels['saveallerror'] = 'Saving $n file(s) failed.';
 $labels['attacherror'] = 'Failed to attach file(s) from the cloud';
+$labels['filedeleting'] = 'Deleting file(s)...';
+$labels['filedeleteconfirm'] = 'Are you sure you want to delete selected files?';
+$labels['filedeletenotice'] = 'File(s) deleted successfully.';
 
 ?>





More information about the commits mailing list