This commit is contained in:
GMrrc 2024-12-12 14:39:16 +01:00
commit 421d92ef41
2 changed files with 14 additions and 42 deletions

View File

@ -407,6 +407,7 @@ export default {
try { try {
this.isTransfering = true; this.isTransfering = true;
const file = this.file; const file = this.file;
console.log(file)
if (!file) return; if (!file) return;
if (file.isList) { if (file.isList) {
@ -442,13 +443,19 @@ export default {
this.isDroppable = true; this.isDroppable = true;
}, },
async moveListOfFiles(files) { async moveListOfFiles(files) {
let listOfFolder = [];
for (const file of files.children) { for (const file of files.children) {
this.transferProgress += 100 / files.children.length; this.transferProgress += 100 / files.children.length;
let listOfFolder = [];
if (file.isDirectory) { if (file.isDirectory) {
//just create the folder //just create the folder
await this.createFolder(file, file.parentPath + '/'); await this.createFolder(file, file.parentPath + '/');
let parentPath = file.parentPath;
if(parentPath === ''){
listOfFolder.push(file.name);
}
else{
listOfFolder.push(file.parentPath + '/' + file.name); listOfFolder.push(file.parentPath + '/' + file.name);
}
} else { } else {
if (file.content && typeof file.content.arrayBuffer === 'function') { if (file.content && typeof file.content.arrayBuffer === 'function') {
file.content = await file.content.arrayBuffer(); file.content = await file.content.arrayBuffer();

View File

@ -272,12 +272,10 @@ export default {
cocheFile(file) { cocheFile(file) {
if (!this.cochedFiles.some(f => this.getFullPath(f) === this.getFullPath(file))) { if (!this.cochedFiles.some(f => this.getFullPath(f) === this.getFullPath(file))) {
this.cochedFiles.push(file); this.cochedFiles.push(file);
console.log(this.cochedFiles);
} }
}, },
decocheFile(file) { decocheFile(file) {
this.cochedFiles = this.cochedFiles.filter(f => this.getFullPath(f) !== this.getFullPath(file)); this.cochedFiles = this.cochedFiles.filter(f => this.getFullPath(f) !== this.getFullPath(file));
console.log(this.cochedFiles);
}, },
cocheFilesRecursively(files) { cocheFilesRecursively(files) {
files.forEach(file => { files.forEach(file => {
@ -306,6 +304,7 @@ export default {
}, },
toggleFolder(file) { toggleFolder(file) {
if (!file.isDirectory) return; if (!file.isDirectory) return;
this.uncheckAll();
const currentState = this.folderMap[file.fullPath]; const currentState = this.folderMap[file.fullPath];
const parentPath = file.parentPath; const parentPath = file.parentPath;
@ -357,6 +356,7 @@ export default {
children: this.cochedFiles, children: this.cochedFiles,
unzip: Promise.all(this.cochedFiles.map(file => file.unzip)) unzip: Promise.all(this.cochedFiles.map(file => file.unzip))
}; };
try { try {
await folder.unzip; await folder.unzip;
this.$emit('file-upload', folder); this.$emit('file-upload', folder);
@ -399,6 +399,7 @@ export default {
return parts.join('/'); return parts.join('/');
}, },
handleClickBreadcrumb(index) { handleClickBreadcrumb(index) {
this.uncheckAll();
if (this.isTransfering) return; if (this.isTransfering) return;
let dir = ''; let dir = '';
if (index >= -1) { if (index >= -1) {
@ -406,7 +407,6 @@ export default {
} }
this.currentDir = dir; this.currentDir = dir;
this.breadcrumbParts = this.getBreadcrumbParts(); this.breadcrumbParts = this.getBreadcrumbParts();
//console.log('cur : ', this.currentDir)
let file = { let file = {
fullPath: dir, fullPath: dir,
parentPath: this.generateCrumbHref(index - 1), parentPath: this.generateCrumbHref(index - 1),
@ -418,43 +418,8 @@ export default {
}); });
this.toggleFolder(file) this.toggleFolder(file)
}, },
isVisible(file) { uncheckAll() {
let parentPath = file.parentPath; this.cochedFiles = [];
if (this.currentDir === parentPath) {
return true;
}
else {
return false;
}
},
getBreadcrumbParts() {
// Si le currentDir est un simple '/', on le renvoie sous forme de tableau vide.
if (this.currentDir === '') return [];
return this.currentDir.split('/').filter(part => part);
},
generateCrumbHref(index) {
const parts = this.breadcrumbParts.slice(0, index + 1);
return parts.join('/');
},
handleClickBreadcrumb(index) {
if (this.isTransfering) return;
let dir = '';
if (index >= -1) {
dir = this.generateCrumbHref(index);
}
this.currentDir = dir;
this.breadcrumbParts = this.getBreadcrumbParts();
//console.log('cur : ', this.currentDir)
let file = {
fullPath: dir,
parentPath: this.generateCrumbHref(index - 1),
isDirectory: true,
};
Object.keys(this.folderMap).forEach(key => {
this.folderMap[key] = false;
});
this.toggleFolder(file);
}, },
}, },
}; };