Create a Ladill folder when uploading a local folder and place files inside it.
Deploy Ladill Transfer / deploy (push) Successful in 27s
Deploy Ladill Transfer / deploy (push) Successful in 27s
Folder upload now names and creates the destination folder from the picked directory, uploads all files into it, and redirects to the new folder view. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
+19
-4
@@ -647,6 +647,7 @@ Alpine.data('filesManager', (config = {}) => ({
|
||||
pendingUploads: null,
|
||||
pendingResolutions: {},
|
||||
duplicateQueue: [],
|
||||
pendingUploadFolderName: null,
|
||||
uploadConfirmOpen: false,
|
||||
pendingConfirmFiles: null,
|
||||
uploadConfirmFolderName: '',
|
||||
@@ -781,9 +782,10 @@ Alpine.data('filesManager', (config = {}) => ({
|
||||
|
||||
confirmUpload() {
|
||||
const files = this.pendingConfirmFiles;
|
||||
const uploadFolderName = this.uploadConfirmIsFolder ? this.uploadConfirmFolderName : null;
|
||||
this.cancelUploadConfirm();
|
||||
if (files?.length) {
|
||||
this.processUploadQueue(files);
|
||||
this.processUploadQueue(files, { uploadFolderName });
|
||||
}
|
||||
},
|
||||
|
||||
@@ -804,8 +806,10 @@ Alpine.data('filesManager', (config = {}) => ({
|
||||
return formatUploadBytes(bytes);
|
||||
},
|
||||
|
||||
async processUploadQueue(files) {
|
||||
async processUploadQueue(files, options = {}) {
|
||||
this.uploading = true;
|
||||
this.pendingUploadFolderName = options.uploadFolderName || null;
|
||||
|
||||
try {
|
||||
const checkRes = await fetch(this.routes.uploadCheck, {
|
||||
method: 'POST',
|
||||
@@ -817,7 +821,8 @@ Alpine.data('filesManager', (config = {}) => ({
|
||||
},
|
||||
body: JSON.stringify({
|
||||
filenames: files.map((f) => this.fileBasename(f)),
|
||||
folder: this.currentFolderId || null,
|
||||
folder: this.pendingUploadFolderName ? null : (this.currentFolderId || null),
|
||||
upload_folder_name: this.pendingUploadFolderName,
|
||||
}),
|
||||
});
|
||||
const checkData = await checkRes.json();
|
||||
@@ -847,6 +852,7 @@ Alpine.data('filesManager', (config = {}) => ({
|
||||
this.uploading = false;
|
||||
this.pendingUploads = null;
|
||||
this.pendingResolutions = {};
|
||||
this.pendingUploadFolderName = null;
|
||||
});
|
||||
return;
|
||||
}
|
||||
@@ -869,9 +875,12 @@ Alpine.data('filesManager', (config = {}) => ({
|
||||
const name = this.fileBasename(file);
|
||||
formData.append('files[]', file, name);
|
||||
});
|
||||
if (this.currentFolderId) {
|
||||
if (this.currentFolderId && !this.pendingUploadFolderName) {
|
||||
formData.append('folder', this.currentFolderId);
|
||||
}
|
||||
if (this.pendingUploadFolderName) {
|
||||
formData.append('upload_folder_name', this.pendingUploadFolderName);
|
||||
}
|
||||
Object.entries(resolutions).forEach(([name, action]) => {
|
||||
formData.append(`resolutions[${name}]`, action);
|
||||
});
|
||||
@@ -893,6 +902,12 @@ Alpine.data('filesManager', (config = {}) => ({
|
||||
}
|
||||
|
||||
this.showToast(data.message || 'Upload complete.');
|
||||
|
||||
if (data.folder_id && this.routes.filesIndex) {
|
||||
window.location.href = `${this.routes.filesIndex}?folder=${data.folder_id}`;
|
||||
return;
|
||||
}
|
||||
|
||||
window.location.reload();
|
||||
},
|
||||
}));
|
||||
|
||||
Reference in New Issue
Block a user