diff --git a/fs_folder/static/src/fs_folder/fs_folder.esm.js b/fs_folder/static/src/fs_folder/fs_folder.esm.js index 22283c740d..00dbb28681 100644 --- a/fs_folder/static/src/fs_folder/fs_folder.esm.js +++ b/fs_folder/static/src/fs_folder/fs_folder.esm.js @@ -22,7 +22,14 @@ export class FsFolder extends Component { this.dropzone = useRef("dropzone"); this.dialog = useService("dialog"); this.fileViewer = usePreviewIframeViewer(); - this.state = useState({path: [], data: [], copy: false, sort: [], hide: []}); + this.state = useState({ + path: [], + data: [], + copy: false, + sort: [], + hide: [], + isItemActionProcessing: false, + }); this.notificationService = useService("fs_folder_notification"); useBus(this.notificationService.bus, "folder_modified", this.onFolderModified); useEffect( @@ -36,17 +43,26 @@ export class FsFolder extends Component { ); useDropzone(this.dropzone, this.onDropFile.bind(this), ""); useSubEnv({ - onClickDirectory: (record) => { - this.onClickDirectory(record); - }, - onClickPreview: (record) => { - this.onClickPreview(record); - }, - onClickDownload: (record) => { - this.onClickDownload(record); - }, + onClickDirectory: (record) => + this.withItemActionLock(() => this.onClickDirectory(record)), + onClickPreview: (record) => + this.withItemActionLock(() => this.onClickPreview(record)), + onClickDownload: (record) => + this.withItemActionLock(() => this.onClickDownload(record)), + onRunItemAction: (callback) => this.withItemActionLock(callback), }); } + async withItemActionLock(callback) { + if (this.state.isItemActionProcessing) { + return; + } + this.state.isItemActionProcessing = true; + try { + return await callback(); + } finally { + this.state.isItemActionProcessing = false; + } + } onFolderModified(event) { const {resId, resModel, fieldName} = event.detail; if ( @@ -224,7 +240,7 @@ export class FsFolder extends Component { } async onClickDirectory(record) { this.state.path = [...this.state.path, record.name]; - this.setData(); + await this.setData(); } async onClickDownload(record) { await downloadFile( diff --git a/fs_folder/static/src/fs_folder/fs_folder.scss b/fs_folder/static/src/fs_folder/fs_folder.scss index f481b801da..a80d3018bf 100644 --- a/fs_folder/static/src/fs_folder/fs_folder.scss +++ b/fs_folder/static/src/fs_folder/fs_folder.scss @@ -1,5 +1,8 @@ .o_field_fs_folder { width: 100%; + .o_fs_folder_item_actions_locked { + pointer-events: none; + } .o_fs_folder_clickable { cursor: pointer; } diff --git a/fs_folder/static/src/fs_folder/fs_folder.xml b/fs_folder/static/src/fs_folder/fs_folder.xml index 55ea8a7880..b5522ee5f4 100644 --- a/fs_folder/static/src/fs_folder/fs_folder.xml +++ b/fs_folder/static/src/fs_folder/fs_folder.xml @@ -144,7 +144,9 @@ - +