Browse Source
Merge pull request #5770 from abpframework/dev-fix-message-alert
Fixed Blazor Confirmation dialog
pull/5786/head
Halil İbrahim Kalkan
5 years ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with
9 additions and
17 deletions
-
framework/src/Volo.Abp.BlazoriseUI/BlazoriseUiMessageService.cs
-
templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Blazor/Pages/Index.razor.cs
|
|
|
@ -69,16 +69,16 @@ namespace Volo.Abp.BlazoriseUI |
|
|
|
return Task.CompletedTask; |
|
|
|
} |
|
|
|
|
|
|
|
public async Task<bool> ConfirmAsync(string message, string title = null, Action<UiMessageOptions> options = null) |
|
|
|
public Task<bool> ConfirmAsync(string message, string title = null, Action<UiMessageOptions> options = null) |
|
|
|
{ |
|
|
|
var uiMessageOptions = CreateDefaultOptions(); |
|
|
|
options?.Invoke(uiMessageOptions); |
|
|
|
|
|
|
|
var callback = new TaskCompletionSource<bool>(); |
|
|
|
|
|
|
|
MessageReceived?.Invoke(this, new UiMessageEventArgs(UiMessageType.Confirmation, message, title, uiMessageOptions)); |
|
|
|
MessageReceived?.Invoke(this, new UiMessageEventArgs(UiMessageType.Confirmation, message, title, uiMessageOptions, callback)); |
|
|
|
|
|
|
|
return await callback.Task; |
|
|
|
return callback.Task; |
|
|
|
} |
|
|
|
|
|
|
|
protected virtual UiMessageOptions CreateDefaultOptions() |
|
|
|
|
|
|
|
@ -45,24 +45,16 @@ namespace MyCompanyName.MyProjectName.Blazor.Pages |
|
|
|
return UiMessageService.ErrorAsync( "This is the Error message", "Error" ); |
|
|
|
} |
|
|
|
|
|
|
|
Task OnConfirmTestClicked() |
|
|
|
async Task OnConfirmTestClicked() |
|
|
|
{ |
|
|
|
return UiMessageService.ConfirmAsync( "Are you sure you want to delete the item?", "Confirm", options => |
|
|
|
if ( await UiMessageService.ConfirmAsync( "Are you sure you want to delete the item?", "Confirm", options => |
|
|
|
{ |
|
|
|
options.CancelButtonText = "Do not delete it"; |
|
|
|
options.ConfirmButtonText = "Yes I'm sure"; |
|
|
|
} ) |
|
|
|
.ContinueWith( result => |
|
|
|
{ |
|
|
|
if ( result.Result ) |
|
|
|
{ |
|
|
|
Console.WriteLine( "Confirmed" ); |
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
|
Console.WriteLine( "Cancelled" ); |
|
|
|
} |
|
|
|
} ); |
|
|
|
} ) ) |
|
|
|
{ |
|
|
|
Console.WriteLine( "Confirmed" ); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
[Inject] IUiMessageService UiMessageService { get; set; } |
|
|
|
|