transfert cochedList
This commit is contained in:
		@@ -408,6 +408,11 @@ export default {
 | 
			
		||||
                    this.isTransfering = true;
 | 
			
		||||
                    const file = this.file;
 | 
			
		||||
 | 
			
		||||
                    if (file.isList) {
 | 
			
		||||
                        await this.moveListOfFiles(file);
 | 
			
		||||
                        return;
 | 
			
		||||
                    }
 | 
			
		||||
 | 
			
		||||
                    if (!file) return;
 | 
			
		||||
                    if (file.isDirectory) {
 | 
			
		||||
                        await this.moveFilesOfFolder(file, '');
 | 
			
		||||
@@ -437,6 +442,18 @@ export default {
 | 
			
		||||
            }
 | 
			
		||||
            this.isDroppable = true;
 | 
			
		||||
        },
 | 
			
		||||
        async moveListOfFiles(files) {
 | 
			
		||||
            for (const file of files) {
 | 
			
		||||
                if (file.isDirectory) {
 | 
			
		||||
                    await this.moveFilesOfFolder(file, '');
 | 
			
		||||
                } else {
 | 
			
		||||
                    if (file.content && typeof file.content.arrayBuffer === 'function') {
 | 
			
		||||
                        file.content = await file.content.arrayBuffer();
 | 
			
		||||
                    }
 | 
			
		||||
                    await this.moveFileToTarget(file, '');
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
        },
 | 
			
		||||
        async moveFilesOfFolder(folder, parentPath) {
 | 
			
		||||
            await this.createFolder(folder, parentPath + '/');
 | 
			
		||||
            const checkChildrenInChildren = (folder) => {
 | 
			
		||||
 
 | 
			
		||||
@@ -18,8 +18,7 @@
 | 
			
		||||
                    <div class="flex items-center">
 | 
			
		||||
                        <input type="checkbox" id="checkbox-file"
 | 
			
		||||
                            class="form-checkbox h-5 w-5 text-blue-600 transition duration-150 ease-in-out cursor-pointer"
 | 
			
		||||
                            @change="handleCheckboxChange(file, $event)" 
 | 
			
		||||
                            :checked="isChecked(file)">
 | 
			
		||||
                            @change="handleCheckboxChange(file, $event)" :checked="isChecked(file)">
 | 
			
		||||
                    </div>
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@@ -52,8 +51,7 @@
 | 
			
		||||
                    <div class="flex items-center">
 | 
			
		||||
                        <input type="checkbox" id="checkbox-file"
 | 
			
		||||
                            class="form-checkbox h-5 w-5 text-blue-600 transition duration-150 ease-in-out cursor-pointer"
 | 
			
		||||
                            @change="handleCheckboxChange(file, $event)" 
 | 
			
		||||
                            :checked="isChecked(file)">
 | 
			
		||||
                            @change="handleCheckboxChange(file, $event)" :checked="isChecked(file)">
 | 
			
		||||
                    </div>
 | 
			
		||||
 | 
			
		||||
                    <template>
 | 
			
		||||
@@ -309,29 +307,40 @@ export default {
 | 
			
		||||
            }
 | 
			
		||||
        },
 | 
			
		||||
        async onDragStart(file, event) {
 | 
			
		||||
            const getFilesFromFolder = (folder) => {
 | 
			
		||||
                const files = [];
 | 
			
		||||
                if (!folder.children || folder.children.length === 0) return files;
 | 
			
		||||
 | 
			
		||||
                for (let i = 0; i < folder.children.length; i++) {
 | 
			
		||||
                    const child = folder.children[i];
 | 
			
		||||
                    if (child.isDirectory) {
 | 
			
		||||
                        files.push(...getFilesFromFolder(child));
 | 
			
		||||
                    } else {
 | 
			
		||||
                        files.push(child);
 | 
			
		||||
                    }
 | 
			
		||||
                }
 | 
			
		||||
                return files;
 | 
			
		||||
            };
 | 
			
		||||
            // Si des fichiers sont cochés, utiliser cette liste
 | 
			
		||||
            if (this.cochedFiles.length > 0) {
 | 
			
		||||
                const folder = {
 | 
			
		||||
                    name: file.name,
 | 
			
		||||
                    isDirectory: true,
 | 
			
		||||
                    children: this.cochedFiles,
 | 
			
		||||
                    unzip: Promise.all(this.cochedFiles.map(file => file.unzip))
 | 
			
		||||
                };
 | 
			
		||||
                try {
 | 
			
		||||
                    console.log('Fichiers cochés :', this.cochedFiles);
 | 
			
		||||
                    const files = getFilesFromFolder(folder);
 | 
			
		||||
                    const filesToUnzip = files.map(file => file.unzip);
 | 
			
		||||
                    await Promise.all(filesToUnzip);
 | 
			
		||||
                    this.$emit('file-upload', folder);
 | 
			
		||||
                } catch (error) {
 | 
			
		||||
                    console.error('Erreur lors du drag start avec fichiers cochés :', error);
 | 
			
		||||
                    console.error('Erreur lors du drag start :', error);
 | 
			
		||||
                }
 | 
			
		||||
 | 
			
		||||
            } else {
 | 
			
		||||
                // Logique existante pour un seul fichier/dossier
 | 
			
		||||
                const getFilesFromFolder = (folder) => {
 | 
			
		||||
                    const files = [];
 | 
			
		||||
                    if (!folder.children || folder.children.length === 0) return files;
 | 
			
		||||
 | 
			
		||||
                    for (let i = 0; i < folder.children.length; i++) {
 | 
			
		||||
                        const child = folder.children[i];
 | 
			
		||||
                        if (child.isDirectory) {
 | 
			
		||||
                            files.push(...getFilesFromFolder(child));
 | 
			
		||||
                        } else {
 | 
			
		||||
                            files.push(child);
 | 
			
		||||
                        }
 | 
			
		||||
                    }
 | 
			
		||||
                    return files;
 | 
			
		||||
                };
 | 
			
		||||
 | 
			
		||||
                try {
 | 
			
		||||
                    if (file.isDirectory) {
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user