From db11f5c99e211e24eadd1ad34e0ecb2cdfe196d7 Mon Sep 17 00:00:00 2001 From: Thorsten Sommer Date: Wed, 17 Dec 2025 19:46:26 +0100 Subject: [PATCH] Enhanced drag-and-drop functionality in AttachDocuments --- .../Assistants/I18N/allTexts.lua | 9 ++++--- .../Components/AttachDocuments.razor | 22 +++++++++++++++- .../Components/AttachDocuments.razor.cs | 25 +++++++++++++++++-- 3 files changed, 50 insertions(+), 6 deletions(-) diff --git a/app/MindWork AI Studio/Assistants/I18N/allTexts.lua b/app/MindWork AI Studio/Assistants/I18N/allTexts.lua index 30796ee7..2a0bee91 100644 --- a/app/MindWork AI Studio/Assistants/I18N/allTexts.lua +++ b/app/MindWork AI Studio/Assistants/I18N/allTexts.lua @@ -1501,6 +1501,9 @@ UI_TEXT_CONTENT["AISTUDIO::COMPONENTS::ATTACHDOCUMENTS::T1637046680"] = "Click t -- Drag and drop files into the marked area or click here to attach documents: UI_TEXT_CONTENT["AISTUDIO::COMPONENTS::ATTACHDOCUMENTS::T230755331"] = "Drag and drop files into the marked area or click here to attach documents:" +-- Click here to attach files +UI_TEXT_CONTENT["AISTUDIO::COMPONENTS::ATTACHDOCUMENTS::T2393263310"] = "Click here to attach files" + -- Document Preview UI_TEXT_CONTENT["AISTUDIO::COMPONENTS::ATTACHDOCUMENTS::T285154968"] = "Document Preview" @@ -1510,9 +1513,6 @@ UI_TEXT_CONTENT["AISTUDIO::COMPONENTS::ATTACHDOCUMENTS::T2928927510"] = "Videos -- Images are not supported yet UI_TEXT_CONTENT["AISTUDIO::COMPONENTS::ATTACHDOCUMENTS::T298062956"] = "Images are not supported yet" --- Click to attach files -UI_TEXT_CONTENT["AISTUDIO::COMPONENTS::ATTACHDOCUMENTS::T3521845090"] = "Click to attach files" - -- Clear file list UI_TEXT_CONTENT["AISTUDIO::COMPONENTS::ATTACHDOCUMENTS::T3759696136"] = "Clear file list" @@ -1525,6 +1525,9 @@ UI_TEXT_CONTENT["AISTUDIO::COMPONENTS::ATTACHDOCUMENTS::T4167762413"] = "Executa -- Select a file to attach UI_TEXT_CONTENT["AISTUDIO::COMPONENTS::ATTACHDOCUMENTS::T595772870"] = "Select a file to attach" +-- Drop files here to attach them +UI_TEXT_CONTENT["AISTUDIO::COMPONENTS::ATTACHDOCUMENTS::T602877785"] = "Drop files here to attach them" + -- Changelog UI_TEXT_CONTENT["AISTUDIO::COMPONENTS::CHANGELOG::T3017574265"] = "Changelog" diff --git a/app/MindWork AI Studio/Components/AttachDocuments.razor b/app/MindWork AI Studio/Components/AttachDocuments.razor index 5b7156c3..21f7dc13 100644 --- a/app/MindWork AI Studio/Components/AttachDocuments.razor +++ b/app/MindWork AI Studio/Components/AttachDocuments.razor @@ -3,7 +3,27 @@ @if (this.UseSmallForm) {
- @if (this.DocumentPaths.Any()) + @if (this.isDraggingOver) + { + + + + + + } + else if (this.DocumentPaths.Any()) { I18N.I.T(fallbackEN, typeof(AttachDocuments).Namespace, nameof(AttachDocuments)); + [Parameter] public string Name { get; set; } = string.Empty; @@ -41,6 +44,11 @@ public partial class AttachDocuments : MSGComponentBase private IDialogService DialogService { get; init; } = null!; private const Placement TOOLBAR_TOOLTIP_PLACEMENT = Placement.Top; + + private static readonly string DROP_FILES_HERE_TEXT = TB("Drop files here to attach them"); + + private bool isComponentHovered; + private bool isDraggingOver; #region Overrides of MSGComponentBase @@ -61,10 +69,23 @@ public partial class AttachDocuments : MSGComponentBase return; } + this.isDraggingOver = true; this.SetDragClass(); this.StateHasChanged(); break; + case Event.TAURI_EVENT_RECEIVED when data is TauriEvent { EventType: TauriEventType.FILE_DROP_CANCELED }: + this.isDraggingOver = false; + this.StateHasChanged(); + break; + + case Event.TAURI_EVENT_RECEIVED when data is TauriEvent { EventType: TauriEventType.WINDOW_NOT_FOCUSED }: + this.isDraggingOver = false; + this.isComponentHovered = false; + this.ClearDragClass(); + this.StateHasChanged(); + break; + case Event.TAURI_EVENT_RECEIVED when data is TauriEvent { EventType: TauriEventType.FILE_DROP_DROPPED, Payload: var paths }: if(!this.isComponentHovered && !this.CatchAllDocuments) { @@ -82,6 +103,8 @@ public partial class AttachDocuments : MSGComponentBase await this.DocumentPathsChanged.InvokeAsync(this.DocumentPaths); await this.OnChange(this.DocumentPaths); + this.isDraggingOver = false; + this.ClearDragClass(); this.StateHasChanged(); break; } @@ -93,8 +116,6 @@ public partial class AttachDocuments : MSGComponentBase private string dragClass = DEFAULT_DRAG_CLASS; - private bool isComponentHovered; - private async Task AddFilesManually() { var selectedFile = await this.RustService.SelectFile(T("Select a file to attach"));