Remove the unowned pads category
This commit is contained in:
parent
cb85ad3fdf
commit
f42665ba49
6 changed files with 89 additions and 87 deletions
|
@ -202,7 +202,7 @@ define(function () {
|
||||||
out.fm_noname = "Document sans titre";
|
out.fm_noname = "Document sans titre";
|
||||||
out.fm_emptyTrashDialog = "Êtes-vous sûr de vouloir vider la corbeille ?";
|
out.fm_emptyTrashDialog = "Êtes-vous sûr de vouloir vider la corbeille ?";
|
||||||
out.fm_removeSeveralPermanentlyDialog = "Êtes-vous sûr de vouloir supprimer ces {0} éléments de manière permanente ?";
|
out.fm_removeSeveralPermanentlyDialog = "Êtes-vous sûr de vouloir supprimer ces {0} éléments de manière permanente ?";
|
||||||
out.fm_removePermanentlyDialog = "Êtes-vous sûr de vouloir supprimer {0} de manière permanente ?";
|
out.fm_removePermanentlyDialog = "Êtes-vous sûr de vouloir supprimer cet élément de manière permanente ?";
|
||||||
out.fm_restoreDialog = "Êtes-vous sûr de vouloir restaurer {0} à son emplacement précédent ?";
|
out.fm_restoreDialog = "Êtes-vous sûr de vouloir restaurer {0} à son emplacement précédent ?";
|
||||||
out.fm_removeSeveralDialog = "Êtes-vous sûr de vouloir déplacer ces {0} éléments vers la corbeille ?";
|
out.fm_removeSeveralDialog = "Êtes-vous sûr de vouloir déplacer ces {0} éléments vers la corbeille ?";
|
||||||
out.fm_removeDialog = "Êtes-vous sûr de vouloir déplacer {0} vers la corbeille ?";
|
out.fm_removeDialog = "Êtes-vous sûr de vouloir déplacer {0} vers la corbeille ?";
|
||||||
|
|
|
@ -199,7 +199,7 @@ define(function () {
|
||||||
out.fm_noname = "Untitled Document";
|
out.fm_noname = "Untitled Document";
|
||||||
out.fm_emptyTrashDialog = "Are you sure you want to empty the trash?";
|
out.fm_emptyTrashDialog = "Are you sure you want to empty the trash?";
|
||||||
out.fm_removeSeveralPermanentlyDialog = "Are you sure you want to remove these {0} elements from the trash permanently?";
|
out.fm_removeSeveralPermanentlyDialog = "Are you sure you want to remove these {0} elements from the trash permanently?";
|
||||||
out.fm_removePermanentlyDialog = "Are you sure you want to remove {0} permanently?";
|
out.fm_removePermanentlyDialog = "Are you sure you want to remove that element permanently?";
|
||||||
out.fm_removeSeveralDialog = "Are you sure you want to move these {0} elements to the trash?";
|
out.fm_removeSeveralDialog = "Are you sure you want to move these {0} elements to the trash?";
|
||||||
out.fm_removeDialog = "Are you sure you want to move {0} to the trash?";
|
out.fm_removeDialog = "Are you sure you want to move {0} to the trash?";
|
||||||
out.fm_restoreDialog = "Are you sure you want to restore {0} to its previous location?";
|
out.fm_restoreDialog = "Are you sure you want to restore {0} to its previous location?";
|
||||||
|
|
|
@ -407,7 +407,7 @@ define([
|
||||||
|
|
||||||
// STORAGE
|
// STORAGE
|
||||||
var setPadAttribute = common.setPadAttribute = function (attr, value, cb, legacy) {
|
var setPadAttribute = common.setPadAttribute = function (attr, value, cb, legacy) {
|
||||||
getStore(legacy).set([getHash(), attr].join('.'), value, function (err, data) {
|
getStore(legacy).setDrive([getHash(), attr].join('.'), value, function (err, data) {
|
||||||
cb(err, data);
|
cb(err, data);
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
@ -422,7 +422,7 @@ define([
|
||||||
|
|
||||||
// STORAGE
|
// STORAGE
|
||||||
var getPadAttribute = common.getPadAttribute = function (attr, cb, legacy) {
|
var getPadAttribute = common.getPadAttribute = function (attr, cb, legacy) {
|
||||||
getStore(legacy).get([getHash(), attr].join('.'), function (err, data) {
|
getStore(legacy).getDrive([getHash(), attr].join('.'), function (err, data) {
|
||||||
cb(err, data);
|
cb(err, data);
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
@ -577,7 +577,7 @@ define([
|
||||||
if (!contains) {
|
if (!contains) {
|
||||||
var data = makePad(href, name);
|
var data = makePad(href, name);
|
||||||
if (common.initialPath) {
|
if (common.initialPath) {
|
||||||
data.owner = 1; // TODO use owner id here?
|
data.owner = getStore().getLoginName(); // TODO use owner id here?
|
||||||
}
|
}
|
||||||
renamed.push(data);
|
renamed.push(data);
|
||||||
if (USE_FS_STORE && common.initialPath && typeof(getStore().addPad) === "function") {
|
if (USE_FS_STORE && common.initialPath && typeof(getStore().addPad) === "function") {
|
||||||
|
|
|
@ -8,7 +8,6 @@ define([
|
||||||
var ROOT = "root";
|
var ROOT = "root";
|
||||||
var UNSORTED = "unsorted";
|
var UNSORTED = "unsorted";
|
||||||
var FILES_DATA = "filesData";
|
var FILES_DATA = "filesData";
|
||||||
var ANON = "anon"; // virtual path
|
|
||||||
var TRASH = "trash";
|
var TRASH = "trash";
|
||||||
var TEMPLATE = "template";
|
var TEMPLATE = "template";
|
||||||
var NEW_FOLDER_NAME = Messages.fm_newFolder;
|
var NEW_FOLDER_NAME = Messages.fm_newFolder;
|
||||||
|
@ -58,9 +57,6 @@ define([
|
||||||
var isPathInTrash = exp.isPathInTrash = function (path) {
|
var isPathInTrash = exp.isPathInTrash = function (path) {
|
||||||
return path[0] && path[0] === TRASH;
|
return path[0] && path[0] === TRASH;
|
||||||
};
|
};
|
||||||
var isPathInAnon = exp.isPathInAnon = function (path) {
|
|
||||||
return path[0] && path[0] === ANON;
|
|
||||||
};
|
|
||||||
|
|
||||||
var isPathInFilesData = exp.isPathInFilesData = function (path) {
|
var isPathInFilesData = exp.isPathInFilesData = function (path) {
|
||||||
return path[0] && path[0] === FILES_DATA;
|
return path[0] && path[0] === FILES_DATA;
|
||||||
|
@ -231,13 +227,6 @@ define([
|
||||||
return ret;
|
return ret;
|
||||||
};
|
};
|
||||||
|
|
||||||
/*var getAnonFiles = exp.getAnonFiles = function () {
|
|
||||||
if (!files[ANON]) {
|
|
||||||
files[ANON] = [];
|
|
||||||
}
|
|
||||||
return files[ANON].slice();
|
|
||||||
};*///TODO
|
|
||||||
|
|
||||||
var removeFileFromRoot = function (root, href) {
|
var removeFileFromRoot = function (root, href) {
|
||||||
if (isFile(root)) { return; }
|
if (isFile(root)) { return; }
|
||||||
for (var e in root) {
|
for (var e in root) {
|
||||||
|
@ -256,6 +245,17 @@ define([
|
||||||
return path[0] === TRASH && path.length === 4;
|
return path[0] === TRASH && path.length === 4;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
var removePadAttribute = function (f) {
|
||||||
|
Object.keys(files).forEach(function (key) {
|
||||||
|
var hash = f.indexOf('#') !== -1 ? f.slice(f.indexOf('#') + 1) : null;
|
||||||
|
if (hash && key.indexOf(hash) === 0) {
|
||||||
|
debug("Deleting pad attribute in the realtime object");
|
||||||
|
files[key] = undefined;
|
||||||
|
delete files[key];
|
||||||
|
}
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
var checkDeletedFiles = function () {
|
var checkDeletedFiles = function () {
|
||||||
// Nothing in FILES_DATA for workgroups
|
// Nothing in FILES_DATA for workgroups
|
||||||
if (workgroup) { return; }
|
if (workgroup) { return; }
|
||||||
|
@ -279,14 +279,7 @@ define([
|
||||||
if (idx !== -1) {
|
if (idx !== -1) {
|
||||||
debug("Removing", f, "from filesData");
|
debug("Removing", f, "from filesData");
|
||||||
files[FILES_DATA].splice(idx, 1);
|
files[FILES_DATA].splice(idx, 1);
|
||||||
Object.keys(files).forEach(function (key) {
|
removePadAttribute(f.href);
|
||||||
var hash = f.href.indexOf('#') !== -1 ? f.href.slice(f.href.indexOf('#') + 1) : null;
|
|
||||||
if (hash && key.indexOf(hash) === 0) {
|
|
||||||
debug("Deleting pad attribute in the realtime object");
|
|
||||||
files[key] = undefined;
|
|
||||||
delete files[key];
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
@ -297,7 +290,7 @@ define([
|
||||||
var parentEl = exp.findElement(files, parentPath);
|
var parentEl = exp.findElement(files, parentPath);
|
||||||
if (path.length === 4 && path[0] === TRASH) {
|
if (path.length === 4 && path[0] === TRASH) {
|
||||||
files[TRASH][path[1]].splice(path[2], 1);
|
files[TRASH][path[1]].splice(path[2], 1);
|
||||||
} else if (path[0] === UNSORTED) { //TODO || === TEMPLATE
|
} else if (path[0] === UNSORTED || path[0] === TEMPLATE) {
|
||||||
parentEl.splice(key, 1);
|
parentEl.splice(key, 1);
|
||||||
} else {
|
} else {
|
||||||
parentEl[key] = undefined;
|
parentEl[key] = undefined;
|
||||||
|
@ -375,7 +368,6 @@ define([
|
||||||
};
|
};
|
||||||
|
|
||||||
// Move to trash
|
// Move to trash
|
||||||
// TODO: rename the function
|
|
||||||
var removeElement = exp.removeElement = function (path, cb, keepOld) {
|
var removeElement = exp.removeElement = function (path, cb, keepOld) {
|
||||||
if (!path || path.length < 2 || path[0] === TRASH) {
|
if (!path || path.length < 2 || path[0] === TRASH) {
|
||||||
debug("Calling removeElement from a wrong path: ", path);
|
debug("Calling removeElement from a wrong path: ", path);
|
||||||
|
@ -409,7 +401,7 @@ define([
|
||||||
|
|
||||||
if (isPathInHrefArray(newParentPath)) {
|
if (isPathInHrefArray(newParentPath)) {
|
||||||
if (isFolder(element)) {
|
if (isFolder(element)) {
|
||||||
log(Messages.fo_moveUnsortedError); //TODO or template
|
log(Messages.fo_moveUnsortedError);
|
||||||
return;
|
return;
|
||||||
} else {
|
} else {
|
||||||
if (elementPath[0] === newParentPath[0]) { return; }
|
if (elementPath[0] === newParentPath[0]) { return; }
|
||||||
|
@ -595,6 +587,28 @@ define([
|
||||||
if(cb) { cb(); }
|
if(cb) { cb(); }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
var deleteFileData = exp.deleteFileData = function (href, cb) {
|
||||||
|
if (workgroup) { return; }
|
||||||
|
|
||||||
|
var toRemove = [];
|
||||||
|
files[FILES_DATA].forEach(function (arr) {
|
||||||
|
var f = arr.href;
|
||||||
|
if (f === href) {
|
||||||
|
toRemove.push(arr);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
toRemove.forEach(function (f) {
|
||||||
|
var idx = files[FILES_DATA].indexOf(f);
|
||||||
|
if (idx !== -1) {
|
||||||
|
debug("Removing", f, "from filesData");
|
||||||
|
files[FILES_DATA].splice(idx, 1);
|
||||||
|
// Remove the "padAttributes" stored in the realtime object for that pad
|
||||||
|
removePadAttribute(f.href);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
if(cb) { cb(); }
|
||||||
|
};
|
||||||
|
|
||||||
var renameElement = exp.renameElement = function (path, newName, cb) {
|
var renameElement = exp.renameElement = function (path, newName, cb) {
|
||||||
if (path.length <= 1) {
|
if (path.length <= 1) {
|
||||||
|
@ -791,9 +805,6 @@ define([
|
||||||
us.splice(idx, 1);
|
us.splice(idx, 1);
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
/*var fixAnon = function () {
|
|
||||||
if (!$.isArray(files[ANON])) { debug("ANON was not an array"); files[FILES_DATA] = []; }
|
|
||||||
};*/// TODO
|
|
||||||
var fixFilesData = function () {
|
var fixFilesData = function () {
|
||||||
if (!$.isArray(files[FILES_DATA])) { debug("FILES_DATA was not an array"); files[FILES_DATA] = []; }
|
if (!$.isArray(files[FILES_DATA])) { debug("FILES_DATA was not an array"); files[FILES_DATA] = []; }
|
||||||
var fd = files[FILES_DATA];
|
var fd = files[FILES_DATA];
|
||||||
|
@ -809,8 +820,7 @@ define([
|
||||||
toClean.push(el);
|
toClean.push(el);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (el.owner
|
if (rootFiles.indexOf(el.href) === -1
|
||||||
&& rootFiles.indexOf(el.href) === -1
|
|
||||||
&& unsortedFiles.indexOf(el.href) === -1
|
&& unsortedFiles.indexOf(el.href) === -1
|
||||||
&& templateFiles.indexOf(el.href) === -1
|
&& templateFiles.indexOf(el.href) === -1
|
||||||
&& trashFiles.indexOf(el.href) === -1) {
|
&& trashFiles.indexOf(el.href) === -1) {
|
||||||
|
@ -818,9 +828,6 @@ define([
|
||||||
files[UNSORTED].push(el.href);
|
files[UNSORTED].push(el.href);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
/*if (!el.owner && anonFiles.indexOf(el.href) === -1) {
|
|
||||||
files[ANON].push(el.href);
|
|
||||||
}*/// TODO
|
|
||||||
});
|
});
|
||||||
toClean.forEach(function (el) {
|
toClean.forEach(function (el) {
|
||||||
var idx = fd.indexOf(el);
|
var idx = fd.indexOf(el);
|
||||||
|
|
|
@ -247,6 +247,10 @@ li {
|
||||||
text-align: center;
|
text-align: center;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#content .grid li .fa.listonly {
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
|
||||||
#content .list li {
|
#content .list li {
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-flow: row;
|
flex-flow: row;
|
||||||
|
|
|
@ -45,10 +45,6 @@ define([
|
||||||
var TRASH = "trash";
|
var TRASH = "trash";
|
||||||
var TRASH_NAME = Messages.fm_trashName;
|
var TRASH_NAME = Messages.fm_trashName;
|
||||||
|
|
||||||
// anon: Virtual path, not stored in the object but extracted from FILES_DATA
|
|
||||||
var ANON = "anon";
|
|
||||||
var ANON_NAME = Messages.fm_anonName || 'Anon pads......';
|
|
||||||
|
|
||||||
var LOCALSTORAGE_LAST = "cryptpad-file-lastOpened";
|
var LOCALSTORAGE_LAST = "cryptpad-file-lastOpened";
|
||||||
var LOCALSTORAGE_OPENED = "cryptpad-file-openedFolders";
|
var LOCALSTORAGE_OPENED = "cryptpad-file-openedFolders";
|
||||||
var LOCALSTORAGE_VIEWMODE = "cryptpad-file-viewMode";
|
var LOCALSTORAGE_VIEWMODE = "cryptpad-file-viewMode";
|
||||||
|
@ -173,7 +169,7 @@ define([
|
||||||
|
|
||||||
// FILE MANAGER
|
// FILE MANAGER
|
||||||
// _WORKGROUP_ and other people drive : display Documents as main page
|
// _WORKGROUP_ and other people drive : display Documents as main page
|
||||||
var currentPath = module.currentPath = APP.loggedIn ? isOwnDrive() ? getLastOpenedFolder() : [ROOT] : [ANON];
|
var currentPath = module.currentPath = isOwnDrive() ? getLastOpenedFolder() : [ROOT];
|
||||||
var lastSelectTime;
|
var lastSelectTime;
|
||||||
var selectedElement;
|
var selectedElement;
|
||||||
|
|
||||||
|
@ -192,6 +188,11 @@ define([
|
||||||
var $folderOpenedIcon = $('<span>', {"class": "fa fa-folder-open folder", style:"color:#FEDE8B;text-shadow: -1px 0 black, 0 1px black, 1px 0 black, 0 -1px black;"});
|
var $folderOpenedIcon = $('<span>', {"class": "fa fa-folder-open folder", style:"color:#FEDE8B;text-shadow: -1px 0 black, 0 1px black, 1px 0 black, 0 -1px black;"});
|
||||||
var $folderOpenedEmptyIcon = $folderOpenedIcon.clone();
|
var $folderOpenedEmptyIcon = $folderOpenedIcon.clone();
|
||||||
var $fileIcon = $('<span>', {"class": "fa fa-file-text-o file"});
|
var $fileIcon = $('<span>', {"class": "fa fa-file-text-o file"});
|
||||||
|
var $padIcon = $('<span>', {"class": "fa fa-file-word-o file"});
|
||||||
|
var $codeIcon = $('<span>', {"class": "fa fa-file-code-o file"});
|
||||||
|
var $slideIcon = $('<span>', {"class": "fa fa-file-powerpoint-o file"});
|
||||||
|
var $pollIcon = $('<span>', {"class": "fa fa-calendar file"});
|
||||||
|
var $anonIcon = $('<span>', {"class": "fa fa-user-secret file listonly"});
|
||||||
var $upIcon = $('<span>', {"class": "fa fa-arrow-circle-up"});
|
var $upIcon = $('<span>', {"class": "fa fa-arrow-circle-up"});
|
||||||
var $unsortedIcon = $('<span>', {"class": "fa fa-files-o"});
|
var $unsortedIcon = $('<span>', {"class": "fa fa-files-o"});
|
||||||
var $templateIcon = $('<span>', {"class": "fa fa-cubes"});
|
var $templateIcon = $('<span>', {"class": "fa fa-cubes"});
|
||||||
|
@ -645,6 +646,22 @@ define([
|
||||||
$span.append($name).append($subfolders).append($files);
|
$span.append($name).append($subfolders).append($files);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
var getFileIcon = function (href) {
|
||||||
|
var $icon = $fileIcon.clone();
|
||||||
|
var data = filesOp.getFileData(href);
|
||||||
|
if (!data) { return $icon; }
|
||||||
|
|
||||||
|
if (href.indexOf('/pad/') !== -1) { $icon = $padIcon.clone() }
|
||||||
|
else if (href.indexOf('/code/') !== -1) { $icon = $codeIcon.clone() }
|
||||||
|
else if (href.indexOf('/slide/') !== -1) { $icon = $slideIcon.clone() }
|
||||||
|
else if (href.indexOf('/poll/') !== -1) { $icon = $pollIcon.clone() }
|
||||||
|
|
||||||
|
if (!data.owner) {
|
||||||
|
$icon = $('<span>').append($anonIcon.clone()).append($icon);
|
||||||
|
}
|
||||||
|
return $icon;
|
||||||
|
};
|
||||||
|
|
||||||
// Create the "li" element corresponding to the file/folder located in "path"
|
// Create the "li" element corresponding to the file/folder located in "path"
|
||||||
var createElement = function (path, elPath, root, isFolder) {
|
var createElement = function (path, elPath, root, isFolder) {
|
||||||
// Forbid drag&drop inside the trash
|
// Forbid drag&drop inside the trash
|
||||||
|
@ -660,7 +677,7 @@ define([
|
||||||
}
|
}
|
||||||
|
|
||||||
var element = filesOp.findElement(files, newPath);
|
var element = filesOp.findElement(files, newPath);
|
||||||
var $icon = $fileIcon.clone();
|
var $icon = !isFolder ? getFileIcon(element) : undefined;
|
||||||
var spanClass = 'file-element element';
|
var spanClass = 'file-element element';
|
||||||
var liClass = 'file-item';
|
var liClass = 'file-item';
|
||||||
if (isFolder) {
|
if (isFolder) {
|
||||||
|
@ -732,7 +749,6 @@ define([
|
||||||
else if (name === TRASH && path.length === 1) { name = TRASH_NAME; }
|
else if (name === TRASH && path.length === 1) { name = TRASH_NAME; }
|
||||||
else if (name === UNSORTED && path.length === 1) { name = UNSORTED_NAME; }
|
else if (name === UNSORTED && path.length === 1) { name = UNSORTED_NAME; }
|
||||||
else if (name === TEMPLATE && path.length === 1) { name = TEMPLATE_NAME; }
|
else if (name === TEMPLATE && path.length === 1) { name = TEMPLATE_NAME; }
|
||||||
else if (name === ANON && path.length === 1) { name = ANON_NAME; }
|
|
||||||
else if (name === FILES_DATA && path.length === 1) { name = FILES_DATA_NAME; }
|
else if (name === FILES_DATA && path.length === 1) { name = FILES_DATA_NAME; }
|
||||||
else if (filesOp.isPathInTrash(path)) { name = getTrashTitle(path); }
|
else if (filesOp.isPathInTrash(path)) { name = getTrashTitle(path); }
|
||||||
var $title = $('<h1>').text(name);
|
var $title = $('<h1>').text(name);
|
||||||
|
@ -844,7 +860,7 @@ define([
|
||||||
options.push({tag: 'hr'});
|
options.push({tag: 'hr'});
|
||||||
}
|
}
|
||||||
AppConfig.availablePadTypes.forEach(function (type) {
|
AppConfig.availablePadTypes.forEach(function (type) {
|
||||||
var path = filesOp.comparePath(currentPath, [ANON]) ? '' : '/#?path=' + encodeURIComponent(currentPath);
|
var path = '/#?path=' + encodeURIComponent(currentPath);
|
||||||
options.push({
|
options.push({
|
||||||
tag: 'a',
|
tag: 'a',
|
||||||
attributes: {
|
attributes: {
|
||||||
|
@ -1086,7 +1102,7 @@ define([
|
||||||
//return;
|
//return;
|
||||||
}
|
}
|
||||||
var idx = files[rootName].indexOf(href);
|
var idx = files[rootName].indexOf(href);
|
||||||
var $icon = $fileIcon.clone();
|
var $icon = getFileIcon(href);
|
||||||
var $name = $('<span>', { 'class': 'file-element element' });
|
var $name = $('<span>', { 'class': 'file-element element' });
|
||||||
addFileData(href, file.title, $name, false);
|
addFileData(href, file.title, $name, false);
|
||||||
var $element = $('<li>', {
|
var $element = $('<li>', {
|
||||||
|
@ -1108,18 +1124,16 @@ define([
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
var displayAllFiles = function ($container, anon) {
|
var displayAllFiles = function ($container) {
|
||||||
var allfiles = files[FILES_DATA];
|
var allfiles = files[FILES_DATA];
|
||||||
if (allfiles.length === 0) { return; }
|
if (allfiles.length === 0) { return; }
|
||||||
var $fileHeader = getFileListHeader(false);
|
var $fileHeader = getFileListHeader(false);
|
||||||
$container.append($fileHeader);
|
$container.append($fileHeader);
|
||||||
var keys = allfiles.filter(function (el) {
|
var keys = allfiles;
|
||||||
return anon && !el.owner || !anon && el.owner;
|
|
||||||
});
|
|
||||||
|
|
||||||
var sortedFiles = sortElements(false, [FILES_DATA], keys, Cryptpad.getLSAttribute(SORT_FILE_BY), !getSortFileDesc(), false, true);
|
var sortedFiles = sortElements(false, [FILES_DATA], keys, Cryptpad.getLSAttribute(SORT_FILE_BY), !getSortFileDesc(), false, true);
|
||||||
sortedFiles.forEach(function (file) {
|
sortedFiles.forEach(function (file) {
|
||||||
var $icon = $fileIcon.clone();
|
var $icon = getFileIcon(file.href);
|
||||||
var $name = $('<span>', { 'class': 'file-element element' });
|
var $name = $('<span>', { 'class': 'file-element element' });
|
||||||
addFileData(file.href, file.title, $name, false);
|
addFileData(file.href, file.title, $name, false);
|
||||||
var $element = $('<li>').append($icon).append($name).dblclick(function () {
|
var $element = $('<li>').append($icon).append($name).dblclick(function () {
|
||||||
|
@ -1181,7 +1195,7 @@ define([
|
||||||
if (!appStatus.isReady && !force) { return; }
|
if (!appStatus.isReady && !force) { return; }
|
||||||
// Only Trash and Root are available in not-owned files manager
|
// Only Trash and Root are available in not-owned files manager
|
||||||
if (isWorkgroup() && !filesOp.isPathInTrash(path) && !filesOp.isPathInRoot(path)) {
|
if (isWorkgroup() && !filesOp.isPathInTrash(path) && !filesOp.isPathInRoot(path)) {
|
||||||
log("TRANSLATE or REMOVE: Unable to open the selected category, displaying root"); //TODO translate
|
log("Unable to open the selected category, displaying root"); //TODO translate
|
||||||
currentPath = [ROOT];
|
currentPath = [ROOT];
|
||||||
displayDirectory(currentPath);
|
displayDirectory(currentPath);
|
||||||
return;
|
return;
|
||||||
|
@ -1197,10 +1211,9 @@ define([
|
||||||
var isUnsorted = filesOp.comparePath(path, [UNSORTED]);
|
var isUnsorted = filesOp.comparePath(path, [UNSORTED]);
|
||||||
var isTemplate = filesOp.comparePath(path, [TEMPLATE]);
|
var isTemplate = filesOp.comparePath(path, [TEMPLATE]);
|
||||||
var isAllFiles = filesOp.comparePath(path, [FILES_DATA]);
|
var isAllFiles = filesOp.comparePath(path, [FILES_DATA]);
|
||||||
var isAnon = filesOp.comparePath(path, [ANON]);
|
|
||||||
|
|
||||||
var root = filesOp.findElement(files, path);
|
var root = filesOp.findElement(files, path);
|
||||||
if (typeof(root) === "undefined" && !isAnon) {
|
if (typeof(root) === "undefined") {
|
||||||
log(Messages.fm_unknownFolderError);
|
log(Messages.fm_unknownFolderError);
|
||||||
debug("Unable to locate the selected directory: ", path);
|
debug("Unable to locate the selected directory: ", path);
|
||||||
var parentPath = path.slice();
|
var parentPath = path.slice();
|
||||||
|
@ -1236,12 +1249,9 @@ define([
|
||||||
var $fileHeader = getFileListHeader(true);
|
var $fileHeader = getFileListHeader(true);
|
||||||
|
|
||||||
if (isUnsorted || isTemplate) {
|
if (isUnsorted || isTemplate) {
|
||||||
// 3rd parameter is "draggable": anon pads shouldn't be draggable
|
displayHrefArray($list, path[0]);
|
||||||
displayHrefArray($list, path[0], !isAnon);
|
|
||||||
} else if (isAllFiles) {
|
} else if (isAllFiles) {
|
||||||
displayAllFiles($list, false);
|
displayAllFiles($list);
|
||||||
} else if (isAnon) {
|
|
||||||
displayAllFiles($list, true);
|
|
||||||
} else if (isTrashRoot) {
|
} else if (isTrashRoot) {
|
||||||
displayTrashRoot($list, $folderHeader, $fileHeader);
|
displayTrashRoot($list, $folderHeader, $fileHeader);
|
||||||
} else {
|
} else {
|
||||||
|
@ -1392,18 +1402,6 @@ define([
|
||||||
$container.append($allfilesList);
|
$container.append($allfilesList);
|
||||||
};
|
};
|
||||||
|
|
||||||
var createAnonFiles = function ($container, path, anonUser) {
|
|
||||||
var $icon = $unsortedIcon.clone();
|
|
||||||
var isOpened = filesOp.comparePath(path, currentPath);
|
|
||||||
var $allfilesElement = createTreeElement(ANON_NAME, $icon, [ANON], false, false, false, isOpened);
|
|
||||||
$allfilesElement.addClass('root');
|
|
||||||
var $allfilesList = $('<ul>', { id: 'anonTree', 'class': 'category2' }).append($allfilesElement);
|
|
||||||
if (anonUser) {
|
|
||||||
$allfilesList.removeClass('category2');
|
|
||||||
}
|
|
||||||
$container.append($allfilesList);
|
|
||||||
};
|
|
||||||
|
|
||||||
var createTrash = function ($container, path) {
|
var createTrash = function ($container, path) {
|
||||||
var $icon = filesOp.isFolderEmpty(files[TRASH]) ? $trashEmptyIcon.clone() : $trashIcon.clone();
|
var $icon = filesOp.isFolderEmpty(files[TRASH]) ? $trashEmptyIcon.clone() : $trashIcon.clone();
|
||||||
var isOpened = filesOp.comparePath(path, currentPath);
|
var isOpened = filesOp.comparePath(path, currentPath);
|
||||||
|
@ -1426,15 +1424,10 @@ define([
|
||||||
|
|
||||||
var resetTree = module.resetTree = function () {
|
var resetTree = module.resetTree = function () {
|
||||||
$tree.html('');
|
$tree.html('');
|
||||||
if (!APP.loggedIn) {
|
|
||||||
createAnonFiles($tree, [ANON], true);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
createTree($tree, [ROOT]);
|
createTree($tree, [ROOT]);
|
||||||
if (!isWorkgroup()) {
|
if (!isWorkgroup()) {
|
||||||
createUnsorted($tree, [UNSORTED]);
|
createUnsorted($tree, [UNSORTED]);
|
||||||
createTemplate($tree, [TEMPLATE]);
|
createTemplate($tree, [TEMPLATE]);
|
||||||
createAnonFiles($tree, [ANON]);
|
|
||||||
createAllFiles($tree, [FILES_DATA]);
|
createAllFiles($tree, [FILES_DATA]);
|
||||||
}
|
}
|
||||||
createTrash($tree, [TRASH]);
|
createTrash($tree, [TRASH]);
|
||||||
|
@ -1636,26 +1629,23 @@ define([
|
||||||
var $selected = $iframe.find('.selected');
|
var $selected = $iframe.find('.selected');
|
||||||
if (!$selected.length) { return; }
|
if (!$selected.length) { return; }
|
||||||
var paths = [];
|
var paths = [];
|
||||||
|
var isTrash = filesOp.isPathInTrash(currentPath);
|
||||||
$selected.each(function (idx, elmt) {
|
$selected.each(function (idx, elmt) {
|
||||||
if (!$(elmt).data('path')) { return; }
|
if (!$(elmt).data('path')) { return; }
|
||||||
paths.push($(elmt).data('path'));
|
paths.push($(elmt).data('path'));
|
||||||
});
|
});
|
||||||
// If we are in the trash or if we are holding the "shift" key, delete permanently,
|
// If we are in the trash or anon pad or if we are holding the "shift" key, delete permanently,
|
||||||
// else move to trash
|
if (isTrash || e.shiftKey) {
|
||||||
if (filesOp.isPathInTrash(currentPath) || e.shiftKey) {
|
var cb = filesOp.removeFromTrash; // We're in the trash
|
||||||
var cb = filesOp.removeFromTrash;
|
if (!isTrash) {
|
||||||
if (!filesOp.isPathInTrash(currentPath)) {
|
cb = filesOp.deletePathPermanently; // We're in root/unsorted/template
|
||||||
// If we are not in the trash, we just have to remove the key from root/unsorted
|
|
||||||
cb = filesOp.deletePathPermanently;
|
|
||||||
}
|
}
|
||||||
// If we are already in the trash, delete the elements permanently
|
|
||||||
var msg = Messages._getKey("fm_removeSeveralPermanentlyDialog", [paths.length]);
|
var msg = Messages._getKey("fm_removeSeveralPermanentlyDialog", [paths.length]);
|
||||||
if (paths.length === 1) { // If we delete only one element, display its name in the popup
|
if (paths.length === 1) {
|
||||||
var path = paths[0];
|
msg = Messages.fm_removePermanentlyDialog;
|
||||||
var element = filesOp.findElement(files, path);
|
|
||||||
var name = filesOp.isInTrashRoot(path) ? path[1] : (filesOp.isPathInHrefArray(path) ? filesOp.getTitle(element) : path[path.length - 1]);
|
|
||||||
msg = Messages._getKey("fm_removePermanentlyDialog", [name]);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Cryptpad.confirm(msg, function(res) {
|
Cryptpad.confirm(msg, function(res) {
|
||||||
if (!res) { return; }
|
if (!res) { return; }
|
||||||
paths.forEach(function(p) {
|
paths.forEach(function(p) {
|
||||||
|
@ -1665,6 +1655,7 @@ define([
|
||||||
});
|
});
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
// else move to trash
|
||||||
moveElements(paths, [TRASH], false, refresh);
|
moveElements(paths, [TRASH], false, refresh);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in a new issue