fixed moving multiple folders list
This commit is contained in:
@@ -222,15 +222,13 @@ class FolderController {
|
||||
const userID = req.user._id;
|
||||
const parent = (req.query.parent as string) || undefined;
|
||||
const search = (req.query.search as string) || undefined;
|
||||
const folderID = (req.query.folderID as string) || undefined;
|
||||
const currentParent = (req.query.currentParent as string) || undefined;
|
||||
const folderIDs = (req.query.folderIDs as string[]) || [];
|
||||
|
||||
const folderList = await folderService.getMoveFolderList(
|
||||
userID,
|
||||
parent,
|
||||
search,
|
||||
folderID,
|
||||
currentParent
|
||||
folderIDs
|
||||
);
|
||||
|
||||
res.send(folderList);
|
||||
|
||||
@@ -48,25 +48,29 @@ class DbUtil {
|
||||
userID: string,
|
||||
parent = "/",
|
||||
search?: string,
|
||||
folderID?: string,
|
||||
currentParent?: string
|
||||
folderIDs?: string[]
|
||||
) => {
|
||||
let query: any = {
|
||||
owner: userID,
|
||||
};
|
||||
|
||||
const idQuery = [];
|
||||
// const idQuery = [];
|
||||
|
||||
// if (currentParent && currentParent !== "/") {
|
||||
// idQuery.push(currentParent);
|
||||
// }
|
||||
|
||||
if (folderID) {
|
||||
query.parentList = { $ne: folderID };
|
||||
idQuery.push(folderID);
|
||||
// if (folderID) {
|
||||
// query.parentList = { $ne: folderID };
|
||||
// idQuery.push(folderID);
|
||||
// }
|
||||
|
||||
if (folderIDs && folderIDs.length > 0) {
|
||||
query._id = { $nin: folderIDs };
|
||||
query.parentList = { $nin: folderIDs };
|
||||
}
|
||||
|
||||
query._id = { $nin: idQuery };
|
||||
// query._id = { $nin: idQuery };
|
||||
|
||||
if (!search || search === "") {
|
||||
query.parent = parent;
|
||||
|
||||
@@ -7,6 +7,10 @@ import { middlewareValidationFunction } from "../utils/middleware-utils";
|
||||
export const moveFolderListValidationRules = [
|
||||
query("parent").optional().isString().withMessage("Parent must be a string"),
|
||||
query("search").optional().isString().withMessage("Search must be a string"),
|
||||
query("folderIDs")
|
||||
.isArray()
|
||||
.isLength({ min: 1 })
|
||||
.withMessage("FolderIDs must be an array of strings"),
|
||||
middlewareValidationFunction,
|
||||
];
|
||||
|
||||
|
||||
@@ -102,15 +102,13 @@ class FolderService {
|
||||
userID: string,
|
||||
parent?: string,
|
||||
search?: string,
|
||||
folderID?: string,
|
||||
currentParent?: string
|
||||
folderIDs?: string[]
|
||||
) => {
|
||||
const folderList = await folderDB.getMoveFolderList(
|
||||
userID,
|
||||
parent,
|
||||
search,
|
||||
folderID,
|
||||
currentParent
|
||||
folderIDs
|
||||
);
|
||||
|
||||
return folderList;
|
||||
|
||||
@@ -41,15 +41,20 @@ export const getMoveFolderListAPI = async ({
|
||||
}: QueryFunctionContext<
|
||||
[
|
||||
string,
|
||||
{ parent: string; search: string; folderID?: string; currentParent: string }
|
||||
{
|
||||
parent: string;
|
||||
search: string;
|
||||
folderIDs?: string[];
|
||||
currentParent: string;
|
||||
}
|
||||
]
|
||||
>) => {
|
||||
const [_key, { parent, search, folderID, currentParent }] = queryKey;
|
||||
const [_key, { parent, search, folderIDs, currentParent }] = queryKey;
|
||||
const response = await axios.get(`/folder-service/move-folder-list`, {
|
||||
params: {
|
||||
parent,
|
||||
search,
|
||||
folderID,
|
||||
folderIDs,
|
||||
currentParent,
|
||||
},
|
||||
});
|
||||
|
||||
@@ -37,10 +37,18 @@ const MoverPopup = () => {
|
||||
folderID: "",
|
||||
});
|
||||
|
||||
const foldersToMove = useAppSelector((state) => {
|
||||
if (state.selected.multiSelectMode) {
|
||||
return Object.keys(state.selected.multiSelectMap);
|
||||
} else {
|
||||
return [state.selected.mainSection.id];
|
||||
}
|
||||
});
|
||||
|
||||
const { data: folderList, isLoading: isLoadingFolders } = useMoveFolders(
|
||||
parent?._id || "/",
|
||||
debouncedSearch,
|
||||
folder?._id
|
||||
foldersToMove
|
||||
);
|
||||
|
||||
const debouncedSetSearchText = useMemo(
|
||||
|
||||
@@ -75,7 +75,7 @@ export const useFolder = () => {
|
||||
export const useMoveFolders = (
|
||||
parent: string,
|
||||
search: string,
|
||||
folderID?: string
|
||||
folderIDs?: string[]
|
||||
) => {
|
||||
const params = useParams();
|
||||
const moveFoldersQuery = useQuery(
|
||||
@@ -84,7 +84,7 @@ export const useMoveFolders = (
|
||||
{
|
||||
parent,
|
||||
search,
|
||||
folderID,
|
||||
folderIDs,
|
||||
currentParent: params.id || "/",
|
||||
},
|
||||
],
|
||||
|
||||
Reference in New Issue
Block a user