mirror of
https://github.com/MindWorkAI/AI-Studio.git
synced 2026-02-12 23:21:37 +00:00
Enhanced drag-and-drop functionality in AttachDocuments
This commit is contained in:
parent
12b5f060eb
commit
db11f5c99e
@ -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:
|
-- 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:"
|
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
|
-- Document Preview
|
||||||
UI_TEXT_CONTENT["AISTUDIO::COMPONENTS::ATTACHDOCUMENTS::T285154968"] = "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
|
-- Images are not supported yet
|
||||||
UI_TEXT_CONTENT["AISTUDIO::COMPONENTS::ATTACHDOCUMENTS::T298062956"] = "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
|
-- Clear file list
|
||||||
UI_TEXT_CONTENT["AISTUDIO::COMPONENTS::ATTACHDOCUMENTS::T3759696136"] = "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
|
-- Select a file to attach
|
||||||
UI_TEXT_CONTENT["AISTUDIO::COMPONENTS::ATTACHDOCUMENTS::T595772870"] = "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
|
-- Changelog
|
||||||
UI_TEXT_CONTENT["AISTUDIO::COMPONENTS::CHANGELOG::T3017574265"] = "Changelog"
|
UI_TEXT_CONTENT["AISTUDIO::COMPONENTS::CHANGELOG::T3017574265"] = "Changelog"
|
||||||
|
|
||||||
|
|||||||
@ -3,7 +3,27 @@
|
|||||||
@if (this.UseSmallForm)
|
@if (this.UseSmallForm)
|
||||||
{
|
{
|
||||||
<div @onmouseenter="@this.OnMouseEnter" @onmouseleave="@this.OnMouseLeave">
|
<div @onmouseenter="@this.OnMouseEnter" @onmouseleave="@this.OnMouseLeave">
|
||||||
@if (this.DocumentPaths.Any())
|
@if (this.isDraggingOver)
|
||||||
|
{
|
||||||
|
<MudBadge
|
||||||
|
Content="@this.DocumentPaths.Count"
|
||||||
|
Color="Color.Primary"
|
||||||
|
Overlap="true"
|
||||||
|
Class="cursor-pointer"
|
||||||
|
OnClick="@this.OpenAttachmentsDialog">
|
||||||
|
<MudLink OnClick="@this.AddFilesManually" Style="text-decoration: none;">
|
||||||
|
<MudTextField T="string"
|
||||||
|
Text="@DROP_FILES_HERE_TEXT"
|
||||||
|
Adornment="Adornment.Start"
|
||||||
|
AdornmentIcon="@Icons.Material.Filled.AttachFile"
|
||||||
|
Typo="Typo.body2"
|
||||||
|
Variant="Variant.Outlined"
|
||||||
|
ReadOnly="true"
|
||||||
|
/>
|
||||||
|
</MudLink>
|
||||||
|
</MudBadge>
|
||||||
|
}
|
||||||
|
else if (this.DocumentPaths.Any())
|
||||||
{
|
{
|
||||||
<MudTooltip Text="@T("Click the paperclip to attach files, or click the number to see your attached files")" Placement="@TOOLBAR_TOOLTIP_PLACEMENT">
|
<MudTooltip Text="@T("Click the paperclip to attach files, or click the number to see your attached files")" Placement="@TOOLBAR_TOOLTIP_PLACEMENT">
|
||||||
<MudBadge
|
<MudBadge
|
||||||
|
|||||||
@ -1,4 +1,5 @@
|
|||||||
using AIStudio.Dialogs;
|
using AIStudio.Dialogs;
|
||||||
|
using AIStudio.Tools.PluginSystem;
|
||||||
using AIStudio.Tools.Rust;
|
using AIStudio.Tools.Rust;
|
||||||
using AIStudio.Tools.Services;
|
using AIStudio.Tools.Services;
|
||||||
|
|
||||||
@ -10,6 +11,8 @@ using DialogOptions = Dialogs.DialogOptions;
|
|||||||
|
|
||||||
public partial class AttachDocuments : MSGComponentBase
|
public partial class AttachDocuments : MSGComponentBase
|
||||||
{
|
{
|
||||||
|
private static string TB(string fallbackEN) => I18N.I.T(fallbackEN, typeof(AttachDocuments).Namespace, nameof(AttachDocuments));
|
||||||
|
|
||||||
[Parameter]
|
[Parameter]
|
||||||
public string Name { get; set; } = string.Empty;
|
public string Name { get; set; } = string.Empty;
|
||||||
|
|
||||||
@ -41,6 +44,11 @@ public partial class AttachDocuments : MSGComponentBase
|
|||||||
private IDialogService DialogService { get; init; } = null!;
|
private IDialogService DialogService { get; init; } = null!;
|
||||||
|
|
||||||
private const Placement TOOLBAR_TOOLTIP_PLACEMENT = Placement.Top;
|
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
|
#region Overrides of MSGComponentBase
|
||||||
|
|
||||||
@ -61,10 +69,23 @@ public partial class AttachDocuments : MSGComponentBase
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this.isDraggingOver = true;
|
||||||
this.SetDragClass();
|
this.SetDragClass();
|
||||||
this.StateHasChanged();
|
this.StateHasChanged();
|
||||||
break;
|
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 }:
|
case Event.TAURI_EVENT_RECEIVED when data is TauriEvent { EventType: TauriEventType.FILE_DROP_DROPPED, Payload: var paths }:
|
||||||
if(!this.isComponentHovered && !this.CatchAllDocuments)
|
if(!this.isComponentHovered && !this.CatchAllDocuments)
|
||||||
{
|
{
|
||||||
@ -82,6 +103,8 @@ public partial class AttachDocuments : MSGComponentBase
|
|||||||
|
|
||||||
await this.DocumentPathsChanged.InvokeAsync(this.DocumentPaths);
|
await this.DocumentPathsChanged.InvokeAsync(this.DocumentPaths);
|
||||||
await this.OnChange(this.DocumentPaths);
|
await this.OnChange(this.DocumentPaths);
|
||||||
|
this.isDraggingOver = false;
|
||||||
|
this.ClearDragClass();
|
||||||
this.StateHasChanged();
|
this.StateHasChanged();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -93,8 +116,6 @@ public partial class AttachDocuments : MSGComponentBase
|
|||||||
|
|
||||||
private string dragClass = DEFAULT_DRAG_CLASS;
|
private string dragClass = DEFAULT_DRAG_CLASS;
|
||||||
|
|
||||||
private bool isComponentHovered;
|
|
||||||
|
|
||||||
private async Task AddFilesManually()
|
private async Task AddFilesManually()
|
||||||
{
|
{
|
||||||
var selectedFile = await this.RustService.SelectFile(T("Select a file to attach"));
|
var selectedFile = await this.RustService.SelectFile(T("Select a file to attach"));
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user