From d849c224120d934b943d9d3cd05436e7c65b0613 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=ADctor=20Mart=C3=ADnez?= Date: Fri, 9 Feb 2024 13:19:35 +0100 Subject: [PATCH] [FIX] dms: Set the correct directory_id value according to the domain to Upload button Example use case: - Go to Documents > Files menu. - Select a directory in search_panel (or from the Files smart-button of a directory). - Click on the "Upload" button - The file has been successfully added to the directory --- dms/static/src/js/views/dms_file_upload.esm.js | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/dms/static/src/js/views/dms_file_upload.esm.js b/dms/static/src/js/views/dms_file_upload.esm.js index 68a35b4ed..38890d7b9 100644 --- a/dms/static/src/js/views/dms_file_upload.esm.js +++ b/dms/static/src/js/views/dms_file_upload.esm.js @@ -111,10 +111,16 @@ export const FileUpload = { return; } - if (this.props.domain.length === 1) { - ctx.default_directory_id = this.props.domain[0][2]; - } else { - ctx.default_directory_id = this.props.domain[2][2]; + // Search the correct directory_id value according to the domain + ctx.default_directory_id = false; + if (this.props.domain) { + for (const domain_item of this.props.domain) { + if (domain_item.length === 3) { + if (domain_item[0] === "directory_id" && domain_item[1] === "=") { + ctx.default_directory_id = domain_item[2]; + } + } + } } if (ctx.default_directory_id === false) {