Fix context menu issues with shared folders in the tree

pull/1/head
yflory 6 years ago
parent fddff11fae
commit 630a2dab78

@ -2668,7 +2668,7 @@ define([
}); });
}; };
var createTreeElement = function (name, $icon, path, draggable, droppable, collapsable, active) { var createTreeElement = function (name, $icon, path, draggable, droppable, collapsable, active, isSharedFolder) {
var $name = $('<span>', { 'class': 'cp-app-drive-element' }).text(name); var $name = $('<span>', { 'class': 'cp-app-drive-element' }).text(name);
var $collapse; var $collapse;
if (collapsable) { if (collapsable) {
@ -2707,7 +2707,8 @@ define([
$collapse.click(); $collapse.click();
} }
} }
$elementRow.data('path', path); var dataPath = isSharedFolder ? path.slice(0, -1) : path;
$elementRow.data('path', dataPath);
addDragAndDropHandlers($elementRow, path, true, droppable); addDragAndDropHandlers($elementRow, path, true, droppable);
if (active) { if (active) {
$elementRow.addClass('cp-app-drive-element-active cp-leftside-active'); $elementRow.addClass('cp-app-drive-element-active cp-leftside-active');
@ -2755,13 +2756,12 @@ define([
if (!manager.isFolder(root[key])) { return; } if (!manager.isFolder(root[key])) { return; }
var newPath = path.slice(); var newPath = path.slice();
newPath.push(key); newPath.push(key);
var nextPath = newPath.slice();
var isSharedFolder = manager.isSharedFolder(root[key]); var isSharedFolder = manager.isSharedFolder(root[key]);
var $icon, isCurrentFolder, subfolder; var $icon, isCurrentFolder, subfolder;
if (isSharedFolder) { if (isSharedFolder) {
var fId = root[key]; var fId = root[key];
// Fix path // Fix path
nextPath.push(manager.user.userObject.ROOT); newPath.push(manager.user.userObject.ROOT);
isCurrentFolder = manager.comparePath(newPath, currentPath); isCurrentFolder = manager.comparePath(newPath, currentPath);
// Subfolders? // Subfolders?
var newRoot = manager.folders[fId].proxy[manager.user.userObject.ROOT]; var newRoot = manager.folders[fId].proxy[manager.user.userObject.ROOT];
@ -2778,14 +2778,14 @@ define([
(isCurrentFolder ? $folderOpenedEmptyIcon : $folderEmptyIcon) : (isCurrentFolder ? $folderOpenedEmptyIcon : $folderEmptyIcon) :
(isCurrentFolder ? $folderOpenedIcon : $folderIcon); (isCurrentFolder ? $folderOpenedIcon : $folderIcon);
} }
var $element = createTreeElement(key, $icon.clone(), newPath, true, true, subfolder, isCurrentFolder); var $element = createTreeElement(key, $icon.clone(), newPath, true, true, subfolder, isCurrentFolder, isSharedFolder);
$element.appendTo($list); $element.appendTo($list);
$element.find('>.cp-app-drive-element-row').contextmenu(openContextMenu('tree')); $element.find('>.cp-app-drive-element-row').contextmenu(openContextMenu('tree'));
if (isSharedFolder) { if (isSharedFolder) {
$element.find('>.cp-app-drive-element-row') $element.find('>.cp-app-drive-element-row')
.addClass('cp-app-drive-element-sharedf'); .addClass('cp-app-drive-element-sharedf');
} }
createTree($element, nextPath); createTree($element, newPath);
}); });
}; };
@ -3042,6 +3042,10 @@ define([
APP.newFolder = info.newPath; APP.newFolder = info.newPath;
APP.displayDirectory(paths[0].path); APP.displayDirectory(paths[0].path);
}; };
el = manager.find(paths[0].path);
if (manager.isSharedFolder(el)) {
paths[0].path.push(ROOT);
}
manager.addFolder(paths[0].path, null, onFolderCreated); manager.addFolder(paths[0].path, null, onFolderCreated);
} }
else if ($(this).hasClass('cp-app-drive-context-newsharedfolder')) { else if ($(this).hasClass('cp-app-drive-context-newsharedfolder')) {

Loading…
Cancel
Save