|
|
@ -1,16 +1,19 @@
|
|
|
|
using Connected.Services.Modal;
|
|
|
|
using Connected.Services.Modal;
|
|
|
|
using Microsoft.AspNetCore.Components;
|
|
|
|
using Microsoft.AspNetCore.Components;
|
|
|
|
|
|
|
|
using Microsoft.AspNetCore.Components.Web;
|
|
|
|
|
|
|
|
|
|
|
|
namespace Connected.Components;
|
|
|
|
namespace Connected.Components;
|
|
|
|
public partial class ModalDialog: IDisposable
|
|
|
|
public partial class ModalDialog: IDisposable
|
|
|
|
{
|
|
|
|
{
|
|
|
|
[Inject] ModalDialogService? ModalService { get; set; }
|
|
|
|
[Inject] ModalDialogService? ModalService { get; set; }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
protected ElementReference root;
|
|
|
|
protected bool IsVisible { get; set; }
|
|
|
|
protected bool IsVisible { get; set; }
|
|
|
|
protected string? Title { get; set; }
|
|
|
|
protected string? Title { get; set; }
|
|
|
|
protected RenderFragment? Content { get; set; }
|
|
|
|
protected RenderFragment? Content { get; set; }
|
|
|
|
|
|
|
|
|
|
|
|
protected EventCallback OnConfirm { get; set; }
|
|
|
|
protected bool OverlayClickToClose { get; set; } = true;
|
|
|
|
|
|
|
|
protected Event OnConfirm { get; set; }
|
|
|
|
|
|
|
|
|
|
|
|
protected override void OnInitialized()
|
|
|
|
protected override void OnInitialized()
|
|
|
|
{
|
|
|
|
{
|
|
|
@ -18,30 +21,17 @@ public partial class ModalDialog: IDisposable
|
|
|
|
ModalService.OnClose += CloseModal;
|
|
|
|
ModalService.OnClose += CloseModal;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public void ShowModal(string title, RenderFragment content, EventCallback o, string CancelButtonText = "Cancel", string OKButtonText = "OK")
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
Title = title;
|
|
|
|
|
|
|
|
Content = content;
|
|
|
|
|
|
|
|
IsVisible = true;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
this.OKButtonText = OKButtonText;
|
|
|
|
|
|
|
|
this.CancelButtonText = CancelButtonText;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
OnConfirm = o;
|
|
|
|
public void ShowModal(string title, RenderFragment content, Event onConfirm, string CancelButtonText = "Cancel", string OKButtonText = "OK")
|
|
|
|
|
|
|
|
|
|
|
|
StateHasChanged();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public void ShowModal(string title, MarkupString content, EventCallback o, string CancelButtonText = "Cancel", string OKButtonText = "OK")
|
|
|
|
|
|
|
|
{
|
|
|
|
{
|
|
|
|
Title = title;
|
|
|
|
Title = title;
|
|
|
|
Content = new RenderFragment(x => x.AddContent(1, content));
|
|
|
|
Content = content;
|
|
|
|
IsVisible = true;
|
|
|
|
IsVisible = true;
|
|
|
|
|
|
|
|
|
|
|
|
this.OKButtonText = OKButtonText;
|
|
|
|
this.OKButtonText = OKButtonText;
|
|
|
|
this.CancelButtonText = CancelButtonText;
|
|
|
|
this.CancelButtonText = CancelButtonText;
|
|
|
|
|
|
|
|
|
|
|
|
OnConfirm = o;
|
|
|
|
OnConfirm = onConfirm;
|
|
|
|
|
|
|
|
|
|
|
|
StateHasChanged();
|
|
|
|
StateHasChanged();
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -52,7 +42,7 @@ public partial class ModalDialog: IDisposable
|
|
|
|
Title = "";
|
|
|
|
Title = "";
|
|
|
|
Content = null;
|
|
|
|
Content = null;
|
|
|
|
if (OkClicked)
|
|
|
|
if (OkClicked)
|
|
|
|
OnConfirm.InvokeAsync();
|
|
|
|
OnConfirm.Delegate.DynamicInvoke(OnConfirm.args);
|
|
|
|
StateHasChanged();
|
|
|
|
StateHasChanged();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -65,13 +55,31 @@ public partial class ModalDialog: IDisposable
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
[Parameter]
|
|
|
|
|
|
|
|
public EventCallback OnOkClick { get; set; }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
[Parameter]
|
|
|
|
|
|
|
|
public string OKButtonText { get; set; } ="OK";
|
|
|
|
public string OKButtonText { get; set; } ="OK";
|
|
|
|
|
|
|
|
|
|
|
|
[Parameter]
|
|
|
|
|
|
|
|
public string CancelButtonText { get; set; } = "Cancel";
|
|
|
|
public string CancelButtonText { get; set; } = "Cancel";
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public void CheckEscape(KeyboardEventArgs args)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
var key = args.Key.ToLower();
|
|
|
|
|
|
|
|
if (key.Equals("escape"))
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
CloseModal();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public void CloseIfEnabled(MouseEventArgs args)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
if (OverlayClickToClose)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
CloseModal();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
OverlayClickToClose = true;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public void PreventClose(MouseEventArgs args)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
OverlayClickToClose = false;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|