Web: Client: Added destination folder for folder operations.

This commit is contained in:
Tatiana Lopaeva 2023-06-02 15:55:54 +03:00
parent 9ed72fa92f
commit fb40d5b542
5 changed files with 49 additions and 39 deletions

View File

@ -344,35 +344,29 @@ export default function withFileActions(WrappedFileItem) {
const isFolder = selectedItem ? false : !item.isFolder ? false : true;
const isProgress = (index, items) => {
if (index === -1) return false;
const destFolderId = items[index].destFolderId;
if (!destFolderId) return true;
return destFolderId.toString() !== id.toString();
};
const activeFileIndex = activeFiles.findIndex((x) => x.id === item.id);
const activeFolderIndex = activeFolders.findIndex(
(x) =>
x.id === item.id &&
(item.isFolder || (!item.fileExst && item.id === -1))
);
const isNeedProgressLoader =
activeFileIndex !== -1
? activeFiles[activeFileIndex].destFolderId?.toString() !==
id.toString()
: false;
const isFileProgress = isProgress(activeFileIndex, activeFiles);
const isFolderProgress = isProgress(activeFolderIndex, activeFolders);
const inProgress =
isNeedProgressLoader ||
activeFolders.findIndex(
(x) =>
x === item.id &&
(item.isFolder || (!item.fileExst && item.id === -1))
) !== -1;
const inProgress = isFileProgress || isFolderProgress;
let isActive = false;
// console.log(
// "activeFiles",
// activeFiles,
// item.id,
// activeFiles.some(
// (elem) =>
// elem.id === item.id &&
// elem.destFolderId?.toString() !== id.toString()
// )
// );
if (
bufferSelection &&
bufferSelection.id === item.id &&

View File

@ -139,7 +139,9 @@ const FilesMediaViewer = (props) => {
if (file) {
// try to fix with one check later (see deleteAction)
const isActiveFile = activeFiles.find((elem) => elem.id === file.id);
const isActiveFolder = activeFolders.find((id) => id === file.id);
const isActiveFolder = activeFolders.find(
(elem) => elem.id === file.id
);
if (isActiveFile || isActiveFolder) return;

View File

@ -303,7 +303,7 @@ class FilesActionStore {
} else {
// try to fix with one check later (see onDeleteMediaFile)
const isActiveFolder = activeFolders.find(
(id) => id === selection[i].id
(elem) => elem.id === selection[i].id
);
!isActiveFolder && folderIds.push(selection[i].id);
}
@ -326,7 +326,7 @@ class FilesActionStore {
const destFolderId = immediately ? null : recycleBinFolderId;
addActiveItems(fileIds, null, destFolderId);
addActiveItems(null, folderIds);
addActiveItems(null, folderIds, destFolderId);
if (this.dialogsStore.isFolderActions && withoutDialog) {
folderIds = [];
@ -1104,7 +1104,9 @@ class FilesActionStore {
operationId,
});
//debugger;
addActiveItems(null, items);
const destFolder = action === "archive" ? archiveRoomsId : myRoomsId;
addActiveItems(null, items, destFolder);
switch (action) {
case "archive":
@ -1430,7 +1432,7 @@ class FilesActionStore {
checkFileConflicts = (destFolderId, folderIds, fileIds) => {
this.filesStore.addActiveItems(fileIds, null, destFolderId);
this.filesStore.addActiveItems(null, folderIds);
this.filesStore.addActiveItems(null, folderIds, destFolderId);
return checkFileConflicts(destFolderId, folderIds, fileIds);
};

View File

@ -572,9 +572,11 @@ class FilesStore {
addActiveItems = (files, folders, destFolderId) => {
if (folders && folders.length) {
if (!this.activeFolders.length) {
this.setActiveFolders(folders);
this.setActiveFolders(folders, destFolderId);
} else {
folders.map((item) => this.activeFolders.push(item));
folders.map((item) =>
this.activeFolders.push({ id: item, destFolderId })
);
}
}
@ -595,12 +597,17 @@ class FilesStore {
id,
destFolderId,
}));
console.log("arrayFormation", arrayFormation);
this.activeFiles = arrayFormation;
};
setActiveFolders = (activeFolders) => {
this.activeFolders = activeFolders;
setActiveFolders = (activeFolders, destFolderId) => {
const arrayFormation = activeFolders.map((id) => ({
id,
destFolderId,
}));
console.log("arrayFormation", arrayFormation);
this.activeFolders = arrayFormation;
};
setIsLoaded = (isLoaded) => {
@ -865,9 +872,9 @@ class FilesStore {
getFilesChecked = (file, selected) => {
if (!file.parentId) {
if (this.activeFiles.some((elem) => elem.id === file.id)) return false;
if (this.activeFiles.find((elem) => elem.id === file.id)) return false;
} else {
if (this.activeFolders.includes(file.id)) return false;
if (this.activeFolders.find((elem) => elem.id === file.id)) return false;
}
const type = file.fileType;
@ -977,7 +984,7 @@ class FilesStore {
this.filesList.find((f) => f.id == id && !f.isFolder)
);
}
} else if (this.activeFolders.findIndex((f) => f == id) === -1) {
} else if (this.activeFolders.findIndex((f) => f.id == id) === -1) {
const isFound =
this.selection.findIndex((f) => f.id == id && f.isFolder) === -1;
@ -1011,7 +1018,7 @@ class FilesStore {
(f) => !(f.id == id && !f.isFolder)
);
}
} else if (this.activeFolders.findIndex((f) => f == id) === -1) {
} else if (this.activeFolders.findIndex((f) => f.id == id) === -1) {
newSelections = newSelections.filter(
(f) => !(f.id == id && f.isFolder)
);

View File

@ -1640,9 +1640,14 @@ class UploadDataStore {
(el) => !fileIds?.includes(el.id)
);
const newActiveFolders = activeFolders.filter(
(el) => !folderIds.includes(el)
(el) => !folderIds.includes(el.id)
);
console.log(
"clearActiveOperations newActiveFiles",
newActiveFiles,
"newActiveFolders",
newActiveFolders
);
console.log("clearActiveOperations", newActiveFiles);
setActiveFiles(newActiveFiles);
setActiveFolders(newActiveFolders);
};