Implemented files deletion, small improvements
This commit is contained in:
parent
b11f2820ad
commit
1e24254433
3 changed files with 64 additions and 10 deletions
|
@ -83,7 +83,10 @@ window.rcmail && rcmail.addEventListener('init', function() {
|
||||||
kolab_files_list_coltypes();
|
kolab_files_list_coltypes();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// "one file only" commands
|
||||||
rcmail.env.file_commands = ['files-get'];
|
rcmail.env.file_commands = ['files-get'];
|
||||||
|
// "one or more file" commands
|
||||||
|
rcmail.env.file_commands_all = ['files-delete'];
|
||||||
|
|
||||||
kolab_files_init();
|
kolab_files_init();
|
||||||
file_api.folder_list();
|
file_api.folder_list();
|
||||||
|
@ -346,6 +349,7 @@ kolab_files_list_select = function(list)
|
||||||
{
|
{
|
||||||
var selected = list.selection.length;
|
var selected = list.selection.length;
|
||||||
|
|
||||||
|
rcmail.enable_command(rcmail.env.file_commands_all, selected);
|
||||||
rcmail.enable_command(rcmail.env.file_commands, selected == 1);
|
rcmail.enable_command(rcmail.env.file_commands, selected == 1);
|
||||||
|
|
||||||
// reset all-pages-selection
|
// reset all-pages-selection
|
||||||
|
@ -353,6 +357,19 @@ kolab_files_list_select = function(list)
|
||||||
// rcmail.select_all_mode = false;
|
// 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)
|
rcube_webmail.prototype.files_sort = function(props)
|
||||||
{
|
{
|
||||||
var params = {},
|
var params = {},
|
||||||
|
@ -392,10 +409,19 @@ rcube_webmail.prototype.files_search_reset = function()
|
||||||
|
|
||||||
rcube_webmail.prototype.files_folder_delete = 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);
|
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)
|
rcube_webmail.prototype.files_upload = function(form)
|
||||||
{
|
{
|
||||||
if (form)
|
if (form)
|
||||||
|
@ -414,11 +440,10 @@ rcube_webmail.prototype.files_list_update = function(head)
|
||||||
|
|
||||||
rcube_webmail.prototype.files_get = function()
|
rcube_webmail.prototype.files_get = function()
|
||||||
{
|
{
|
||||||
var id = this.file_list.get_selection();
|
var files = kolab_files_selected();
|
||||||
|
|
||||||
if (id = $('#rcmrow'+id).data('file')) {
|
if (files.length == 1)
|
||||||
file_api.file_get(id, {'force-download': true});
|
file_api.file_get(files[0], {'force-download': true});
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -451,9 +476,9 @@ function kolab_files_ui()
|
||||||
};
|
};
|
||||||
|
|
||||||
// displays error message
|
// 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)
|
this.http_error = function(request, status, err)
|
||||||
|
@ -544,6 +569,7 @@ function kolab_files_ui()
|
||||||
this.req = this.set_busy(true, 'loading');
|
this.req = this.set_busy(true, 'loading');
|
||||||
|
|
||||||
rcmail.enable_command(rcmail.env.file_commands, false);
|
rcmail.enable_command(rcmail.env.file_commands, false);
|
||||||
|
rcmail.enable_command(rcmail.env.file_commands_all, false);
|
||||||
rcmail.file_list.clear();
|
rcmail.file_list.clear();
|
||||||
|
|
||||||
this.get('file_list', params, 'file_list_response');
|
this.get('file_list', params, 'file_list_response');
|
||||||
|
@ -610,6 +636,8 @@ function kolab_files_ui()
|
||||||
if (!this.response(response))
|
if (!this.response(response))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
this.display_message('kolab_files.foldercreatenotice', 'confirmation');
|
||||||
|
|
||||||
// refresh folders list
|
// refresh folders list
|
||||||
this.folder_list();
|
this.folder_list();
|
||||||
};
|
};
|
||||||
|
@ -617,7 +645,7 @@ function kolab_files_ui()
|
||||||
// folder delete request
|
// folder delete request
|
||||||
this.folder_delete = function(folder)
|
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');
|
this.get('folder_delete', {folder: folder}, 'folder_delete_response');
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -629,6 +657,7 @@ function kolab_files_ui()
|
||||||
|
|
||||||
this.env.folder = null;
|
this.env.folder = null;
|
||||||
rcmail.enable_command('files-folder-delete', 'files-folder-rename', false);
|
rcmail.enable_command('files-folder-delete', 'files-folder-rename', false);
|
||||||
|
this.display_message('kolab_files.folderdeletenotice', 'confirmation');
|
||||||
|
|
||||||
// refresh folders list
|
// refresh folders list
|
||||||
this.folder_list();
|
this.folder_list();
|
||||||
|
@ -664,6 +693,23 @@ function kolab_files_ui()
|
||||||
rcmail.redirect(this.env.url + this.url('file_get', params));
|
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
|
// file upload request
|
||||||
this.file_upload = function(form)
|
this.file_upload = function(form)
|
||||||
{
|
{
|
||||||
|
|
|
@ -460,8 +460,9 @@ class kolab_files_engine
|
||||||
));
|
));
|
||||||
|
|
||||||
|
|
||||||
$this->rc->output->add_label('deletefolderconfirm', 'folderdeleting',
|
$this->rc->output->add_label('deletefolderconfirm', 'kolab_files.folderdeleting',
|
||||||
'kolab_files.foldercreating', 'kolab_files.uploading');
|
'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->set_pagetitle($this->plugin->gettext('files'));
|
||||||
$this->rc->output->send('kolab_files.files');
|
$this->rc->output->send('kolab_files.files');
|
||||||
|
|
|
@ -26,8 +26,15 @@ $labels['deletefile'] = 'Delete selected file(s)';
|
||||||
|
|
||||||
$labels['uploading'] = 'Uploading file(s)...';
|
$labels['uploading'] = 'Uploading file(s)...';
|
||||||
$labels['foldercreating'] = 'Creating folder...';
|
$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['saveallnotice'] = 'Successfully saved $n file(s).';
|
||||||
$labels['saveallerror'] = 'Saving $n file(s) failed.';
|
$labels['saveallerror'] = 'Saving $n file(s) failed.';
|
||||||
$labels['attacherror'] = 'Failed to attach file(s) from the cloud';
|
$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.';
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
|
Loading…
Add table
Reference in a new issue