Confirm Dialog delete
This commit is contained in:
@@ -8,6 +8,8 @@
|
||||
@page "/InvoiceDetails"
|
||||
<Modal @ref="modal" />
|
||||
<Preload LoadingText="در حال بارگذاری..." />
|
||||
<ConfirmDialog @ref="dialog" />
|
||||
|
||||
<form>
|
||||
@* alert *@
|
||||
<div class="row">
|
||||
@@ -183,7 +185,7 @@
|
||||
<Button class="mt-3" Color="ButtonColor.Success" @onclick="OnClickUpdate" Type="ButtonType.Button">
|
||||
ثبت تغییرات
|
||||
</Button>
|
||||
<Button class="mt-3" Color="ButtonColor.Danger" @onclick="OnClickDelete" Type="ButtonType.Button">
|
||||
<Button class="mt-3" Color="ButtonColor.Danger" @onclick="ShowConfirmationDeleteAsync" Type="ButtonType.Button">
|
||||
حذف
|
||||
</Button>
|
||||
}
|
||||
@@ -199,6 +201,8 @@
|
||||
|
||||
|
||||
@code {
|
||||
[Inject] ToastService ToastService { get; set; } = default!;
|
||||
private ConfirmDialog dialog = default!;
|
||||
private Modal modal = default!;
|
||||
[Inject] protected PreloadService PreloadService { get; set; } = default!;
|
||||
// alert
|
||||
@@ -279,16 +283,16 @@
|
||||
msg = "آیتم جدید با موفقیت اضافه شد";
|
||||
|
||||
}
|
||||
// else if (result.Action == ComponentAction.update)
|
||||
// {
|
||||
// if (result.Status == ComponentStatus.success)
|
||||
// msg = "اطلاعات آیتم با موفقیت ویرایش شد";
|
||||
// }
|
||||
// else if (result.Action == ComponentAction.delete)
|
||||
// {
|
||||
// if (result.Status == ComponentStatus.success)
|
||||
// msg = "آیتم با موفقیت حذف شد";
|
||||
// }
|
||||
else if (result.Action == ComponentAction.update)
|
||||
{
|
||||
if (result.Status == ComponentStatus.success)
|
||||
msg = "اطلاعات آیتم با موفقیت ویرایش شد";
|
||||
}
|
||||
else if (result.Action == ComponentAction.delete)
|
||||
{
|
||||
if (result.Status == ComponentStatus.success)
|
||||
msg = "آیتم با موفقیت حذف شد";
|
||||
}
|
||||
await CallBack(msg);
|
||||
// if (result.Status == ComponentStatus.success)
|
||||
// await LoadCod(1);
|
||||
@@ -327,6 +331,7 @@
|
||||
var request = await rsp.Content.ReadFromJsonAsync<bool>();
|
||||
if (request)
|
||||
{
|
||||
ToastService.Notify(new ToastMessage(ToastType.Success, $"عملیات حذف با موفقیت انجام شد"));
|
||||
hc._nav.NavigateTo("Invoice");
|
||||
}
|
||||
else ShowDangerAlert("خطایی در اجرای عملیات رخ داده");
|
||||
@@ -338,8 +343,8 @@
|
||||
}
|
||||
else ShowDangerAlert("خطایی در اجرای عملیات رخ داده");
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
public async Task OnClickUpdate()
|
||||
{
|
||||
@@ -484,4 +489,25 @@
|
||||
|
||||
return true;
|
||||
}
|
||||
private async Task ShowConfirmationDeleteAsync()
|
||||
{
|
||||
if (InvoiceID.HasValue)
|
||||
{
|
||||
var confirmation = await dialog.ShowAsync(
|
||||
title: "عملیات حذف صورتحساب",
|
||||
message1: $"از حذف صورتحساب {InvoiceID}",
|
||||
message2: "اطمینان دارید?");
|
||||
|
||||
if (confirmation)
|
||||
{
|
||||
await OnClickDelete();
|
||||
}
|
||||
else
|
||||
{
|
||||
ToastService.Notify(new ToastMessage(ToastType.Secondary, $"عملیات حذف متوقف شد"));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user