transfert cochedList

This commit is contained in:
GMrrc 2024-12-11 15:38:32 +01:00
parent 12a3664654
commit cefedd56cb
2 changed files with 45 additions and 19 deletions

View File

@ -408,6 +408,11 @@ export default {
this.isTransfering = true; this.isTransfering = true;
const file = this.file; const file = this.file;
if (file.isList) {
await this.moveListOfFiles(file);
return;
}
if (!file) return; if (!file) return;
if (file.isDirectory) { if (file.isDirectory) {
await this.moveFilesOfFolder(file, ''); await this.moveFilesOfFolder(file, '');
@ -437,6 +442,18 @@ export default {
} }
this.isDroppable = true; 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) { async moveFilesOfFolder(folder, parentPath) {
await this.createFolder(folder, parentPath + '/'); await this.createFolder(folder, parentPath + '/');
const checkChildrenInChildren = (folder) => { const checkChildrenInChildren = (folder) => {

View File

@ -18,8 +18,7 @@
<div class="flex items-center"> <div class="flex items-center">
<input type="checkbox" id="checkbox-file" <input type="checkbox" id="checkbox-file"
class="form-checkbox h-5 w-5 text-blue-600 transition duration-150 ease-in-out cursor-pointer" class="form-checkbox h-5 w-5 text-blue-600 transition duration-150 ease-in-out cursor-pointer"
@change="handleCheckboxChange(file, $event)" @change="handleCheckboxChange(file, $event)" :checked="isChecked(file)">
:checked="isChecked(file)">
</div> </div>
@ -52,8 +51,7 @@
<div class="flex items-center"> <div class="flex items-center">
<input type="checkbox" id="checkbox-file" <input type="checkbox" id="checkbox-file"
class="form-checkbox h-5 w-5 text-blue-600 transition duration-150 ease-in-out cursor-pointer" class="form-checkbox h-5 w-5 text-blue-600 transition duration-150 ease-in-out cursor-pointer"
@change="handleCheckboxChange(file, $event)" @change="handleCheckboxChange(file, $event)" :checked="isChecked(file)">
:checked="isChecked(file)">
</div> </div>
<template> <template>
@ -309,15 +307,6 @@ export default {
} }
}, },
async onDragStart(file, event) { async onDragStart(file, event) {
// Si des fichiers sont cochés, utiliser cette liste
if (this.cochedFiles.length > 0) {
try {
console.log('Fichiers cochés :', this.cochedFiles);
} catch (error) {
console.error('Erreur lors du drag start avec fichiers cochés :', error);
}
} else {
// Logique existante pour un seul fichier/dossier
const getFilesFromFolder = (folder) => { const getFilesFromFolder = (folder) => {
const files = []; const files = [];
if (!folder.children || folder.children.length === 0) return files; if (!folder.children || folder.children.length === 0) return files;
@ -332,6 +321,26 @@ export default {
} }
return files; 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 {
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 :', error);
}
} else {
// Logique existante pour un seul fichier/dossier
try { try {
if (file.isDirectory) { if (file.isDirectory) {