From cefedd56cb7e6a1b1acf2b6801168d93221201db Mon Sep 17 00:00:00 2001
From: GMrrc <143954951+GMrrc@users.noreply.github.com>
Date: Wed, 11 Dec 2024 15:38:32 +0100
Subject: [PATCH] transfert cochedList
---
src/components/FileTable.vue | 17 +++++++++++
src/components/WebContentViewer.vue | 47 +++++++++++++++++------------
2 files changed, 45 insertions(+), 19 deletions(-)
diff --git a/src/components/FileTable.vue b/src/components/FileTable.vue
index a1662ff..1f27fe9 100644
--- a/src/components/FileTable.vue
+++ b/src/components/FileTable.vue
@@ -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) => {
diff --git a/src/components/WebContentViewer.vue b/src/components/WebContentViewer.vue
index 1e3b615..eb35bad 100644
--- a/src/components/WebContentViewer.vue
+++ b/src/components/WebContentViewer.vue
@@ -18,8 +18,7 @@
+ @change="handleCheckboxChange(file, $event)" :checked="isChecked(file)">
@@ -52,8 +51,7 @@
+ @change="handleCheckboxChange(file, $event)" :checked="isChecked(file)">
@@ -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) {