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