From b0f05f52afe0d0b9a1bbb40562ca93ceffd97fb9 Mon Sep 17 00:00:00 2001 From: Aleksander Machniak Date: Thu, 28 Feb 2013 17:26:33 +0100 Subject: [PATCH] Implemented Download button action --- plugins/kolab_files/kolab_files.js | 28 +++++++++++++++++++++++++--- 1 file changed, 25 insertions(+), 3 deletions(-) diff --git a/plugins/kolab_files/kolab_files.js b/plugins/kolab_files/kolab_files.js index 677731fd..ded719a8 100644 --- a/plugins/kolab_files/kolab_files.js +++ b/plugins/kolab_files/kolab_files.js @@ -81,6 +81,8 @@ window.rcmail && rcmail.addEventListener('init', function() { kolab_files_list_coltypes(); } + rcmail.env.file_commands = ['files-get']; + kolab_files_init(); file_api.folder_list(); } @@ -308,10 +310,8 @@ kolab_files_click_on_list = function(e) kolab_files_list_select = function(list) { var selected = list.selection.length; -// this.enable_command(this.env.message_commands, selected != null); - // Multi-message commands -// this.enable_command('delete', 'moveto', 'copy', list.selection.length > 0); + rcmail.enable_command(rcmail.env.file_commands, selected == 1); // reset all-pages-selection // if (list.selection.length && list.selection.length != list.rowcount) @@ -377,6 +377,15 @@ rcube_webmail.prototype.files_list_update = function(head) file_api.file_list(); }; +rcube_webmail.prototype.files_get = function() +{ + var id = this.file_list.get_selection(); + + if (id = $('#rcmrow'+id).data('file')) { + file_api.file_get(id, {'force-download': true}); + } +}; + /**********************************************************/ /********* Files API handler **********/ @@ -501,6 +510,7 @@ function kolab_files_ui() this.req = this.set_busy(true, 'loading'); + rcmail.enable_command(rcmail.env.file_commands, false); rcmail.file_list.clear(); this.get('file_list', params, 'file_list_response'); @@ -614,6 +624,18 @@ function kolab_files_ui() } }; + this.file_get = function(file, params) + { + if (!params) + params = {}; + + params.folder = this.env.folder; + params.token = this.env.token; + params.file = file; + + rcmail.redirect(this.env.url + this.url('file_get', params)); + }; + // file upload request this.file_upload = function(form) {