Prevent dropping files to read-only folders (T115)
This commit is contained in:
parent
e22d4aafab
commit
4b727c45cd
1 changed files with 34 additions and 10 deletions
|
@ -878,7 +878,7 @@ kolab_files_drag_drop_init = function(container)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
$(document.body).bind('dragover dragleave drop', function(e) {
|
$(document.body).bind('dragover dragleave drop', function(e) {
|
||||||
if (!file_api.env.folder)
|
if (!kolab_files_current_folder_is_writable())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
|
@ -898,10 +898,21 @@ kolab_files_drag_drop_init = function(container)
|
||||||
}, false);
|
}, false);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
function kolab_files_current_folder_is_writable()
|
||||||
|
{
|
||||||
|
if (!file_api.env.folder)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
if (file_api.env.folders[file_api.env.folder].readonly)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
// handler for drag/drop on element
|
// handler for drag/drop on element
|
||||||
kolab_files_drag_hover = function(e)
|
kolab_files_drag_hover = function(e)
|
||||||
{
|
{
|
||||||
if (!file_api.env.folder)
|
if (!kolab_files_current_folder_is_writable())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
|
@ -1271,6 +1282,7 @@ function kolab_files_ui()
|
||||||
check_droptarget: function(node) {
|
check_droptarget: function(node) {
|
||||||
return !node.virtual
|
return !node.virtual
|
||||||
&& node.id != file_api.env.folder
|
&& node.id != file_api.env.folder
|
||||||
|
&& $.inArray('readonly', node.classes) == -1
|
||||||
&& $.inArray('collection', node.classes) == -1;
|
&& $.inArray('collection', node.classes) == -1;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -1360,16 +1372,23 @@ function kolab_files_ui()
|
||||||
|
|
||||||
this.folder_list_row = function(i, folder, parent)
|
this.folder_list_row = function(i, folder, parent)
|
||||||
{
|
{
|
||||||
var toggle, sublist, collapsed, parent, parent_name,
|
var toggle, sublist, collapsed, parent, parent_name, classes = ['mailbox'],
|
||||||
row = $('<li class="mailbox"></li>'),
|
row = $('<li>'),
|
||||||
id = 'rcmli' + rcmail.html_identifier_encode(i);
|
id = 'rcmli' + rcmail.html_identifier_encode(i);
|
||||||
|
|
||||||
row.attr('id', id).append($('<a>').text(folder.name));
|
row.attr('id', id).append($('<a>').text(folder.name));
|
||||||
|
|
||||||
if (folder.virtual)
|
if (folder.virtual)
|
||||||
row.addClass('virtual');
|
classes.push('virtual');
|
||||||
else if (folder.subscribed !== undefined)
|
else {
|
||||||
row.append(this.folder_list_subscription_button(folder.subscribed));
|
if (folder.subscribed !== undefined)
|
||||||
|
row.append(this.folder_list_subscription_button(folder.subscribed));
|
||||||
|
|
||||||
|
if (folder.readonly)
|
||||||
|
classes.push('readonly');
|
||||||
|
}
|
||||||
|
|
||||||
|
row.addClass(classes.join(' '));
|
||||||
|
|
||||||
folder.ref = row;
|
folder.ref = row;
|
||||||
|
|
||||||
|
@ -1535,17 +1554,22 @@ function kolab_files_ui()
|
||||||
$.each(folders, function(i, folder) {
|
$.each(folders, function(i, folder) {
|
||||||
var node, separator = file_api.env.directory_separator,
|
var node, separator = file_api.env.directory_separator,
|
||||||
path = i.split(separator),
|
path = i.split(separator),
|
||||||
|
classes = ['mailbox'],
|
||||||
html = [$('<a>').text(folder.name)];
|
html = [$('<a>').text(folder.name)];
|
||||||
|
|
||||||
// add subscription button
|
if (!folder.virtual) {
|
||||||
if (!folder.virtual)
|
// add subscription button
|
||||||
html.push(file_api.folder_list_subscription_button(false));
|
html.push(file_api.folder_list_subscription_button(false));
|
||||||
|
|
||||||
|
if (folder.readonly)
|
||||||
|
classes.push('readonly');
|
||||||
|
}
|
||||||
|
|
||||||
path.pop();
|
path.pop();
|
||||||
|
|
||||||
file_api.search_results_widget.insert({
|
file_api.search_results_widget.insert({
|
||||||
id: i,
|
id: i,
|
||||||
classes: ['mailbox'],
|
classes: classes,
|
||||||
text: folder.name,
|
text: folder.name,
|
||||||
html: html,
|
html: html,
|
||||||
collapsed: false,
|
collapsed: false,
|
||||||
|
|
Loading…
Add table
Reference in a new issue