diff --git a/src/components/FileExistsDialog.vue b/src/components/FileExistsDialog.vue index a27ae92..faaf777 100644 --- a/src/components/FileExistsDialog.vue +++ b/src/components/FileExistsDialog.vue @@ -5,7 +5,7 @@

Le fichier "{{ fileName }}" existe déjà. Que voulez-vous faire ?

- +
@@ -49,10 +49,13 @@ export default { fileName: { type: String, required: true + }, + isDirectory:{ + type: Boolean, + required: true, } }, data() { - var oldFileName = this.fileName; var newFileName = this.fileName; var extension = ''; if(!this.isDirectory) { @@ -66,7 +69,6 @@ export default { displayRename: false, displayOverwrite: false, forAll: false, - oldFileName, newFileName, extension, } @@ -96,7 +98,7 @@ export default { this.newFileName = newFileNameWithOriginalExtension; } - this.$emit("rename", { oldFileName: this.oldFileName, newFileName: this.newFileName }); + this.$emit("rename", { newFileName: this.newFileName }); } }, onInputChange() { diff --git a/src/components/FileTable.vue b/src/components/FileTable.vue index 3bd1473..bb03fc1 100644 --- a/src/components/FileTable.vue +++ b/src/components/FileTable.vue @@ -128,7 +128,7 @@ - + @@ -196,6 +196,8 @@ export default { overwrite: false, applyToAll: false, cancelOperation: false, + rename: false, + newElemName: '', }; }, async mounted() { @@ -259,7 +261,6 @@ export default { try { const client = getClient(); let filePath = ''; - console.log(this.newFileName) if (this.current_dir[this.current_dir.length - 1] === '/') { filePath = `${this.root_path}${this.current_dir}${this.newFileName}`; } @@ -349,6 +350,8 @@ export default { } this.overwrite = false; this.applyToAll = false; + this.rename = false; + this.newElemName = ''; }, async moveFilesOfFolder(folder, parentPath) { await this.createFolder(folder, parentPath + '/'); @@ -378,13 +381,22 @@ export default { } } }, - async moveFileToTarget(file, parentPath) { + async moveFileToTarget(file, parentPath, newName = null) { + this.isDirectory = false; try { const client = getClient(); // Assurez-vous que le chemin parent est correctement formaté let fullPath = ''; - fullPath = `${this.root_path}${this.current_dir}${parentPath}${file.name}`; + if(!this.rename) { + fullPath = `${this.root_path}${this.current_dir}${parentPath}${file.name}`; + } + else if (this.rename && newName){ + fullPath = `${this.root_path}${this.current_dir}${parentPath}${newName}`; + } + else { + return null; + } if (ArrayBuffer.isView(file.content)) { file.content = Buffer.from(file.content); @@ -409,7 +421,13 @@ export default { await this.sleep(50); } if(!this.cancelOperation){ - await this.moveFileToTarget(file,parentPath); + if(this.rename) { + await this.moveFileToTarget(file, parentPath, this.newElemName); + this.rename = false; + } + else{ + await this.moveFileToTarget(file,parentPath); + } } } } catch (error) { @@ -417,6 +435,7 @@ export default { } }, async createFolder(folder, parentPath) { + this.isDirectory = true; try { const client = getClient(); let fullPath = ''; @@ -505,6 +524,11 @@ export default { this.applyToAll = options.forAll; this.fileExistDialogDisabled = true; }, + setRename(options) { + this.rename = true; + this.newElemName = options.newFileName; + this.fileExistDialogDisabled = true; + }, /** * Check si un fichier ou un dossier existe deja sur le serveur * @param path le chemin du fichier/dossier