This commit is contained in:
mmrbnjd
2024-04-16 16:44:37 +03:30
parent 2d2f7ea3b2
commit 7cc8b3efde

View File

@@ -29,6 +29,8 @@
</div> </div>
</div> </div>
<div class="col-xl-7 col-lg-6"> <div class="col-xl-7 col-lg-6">
<Toasts class="p-3" Messages="messages" AutoHide="true" Delay="6000" Placement="ToastsPlacement.TopRight" />
<div class="contact-form-right-warp"> <div class="contact-form-right-warp">
<div class="postbox__comment-form"> <div class="postbox__comment-form">
<EditForm EditContext="editContext" OnValidSubmit="newTicket"> <EditForm EditContext="editContext" OnValidSubmit="newTicket">
@@ -81,12 +83,7 @@
</div> </div>
<Modal @ref="_modal" <Modal @ref="_modal"
title="Modal title" title="Modal title">
OnShowing="OnModalShowing"
OnShown="OnModalShown"
OnHiding="OnModalHiding"
OnHidden="OnModalHidden"
OnHidePrevented="OnModalHidePrevented">
<BodyTemplate> <BodyTemplate>
Modal body text goes here. Modal body text goes here.
@@ -94,15 +91,15 @@
<FooterTemplate> <FooterTemplate>
<Button Color="ButtonColor.Secondary" @onclick="OnHideModalClick">Close</Button> <Button Color="ButtonColor.Secondary" @onclick="OnHideModalClick">Close</Button>
<Button Color="ButtonColor.Primary">Save changes</Button> <Button Color="ButtonColor.Primary" @onclick="testhand">Save changes</Button>
</FooterTemplate> </FooterTemplate>
</Modal> </Modal>
@code { @code {
List<ToastMessage> messages = new List<ToastMessage>();
private Modal _modal = default!; private Modal _modal = default!;
[Inject] ToastService ToastService { get; set; } = default!;
//------------------------------- //-------------------------------
string type = "NewTicketNoAuthentication"; string type = "NewTicketNoAuthentication";
private EditContext? editContext; private EditContext? editContext;
@@ -140,38 +137,28 @@
} }
} }
private async Task testhand()
{
ShowMessage(ToastType.Warning);
}
private async Task OnShowModalClick() private async Task OnShowModalClick()
{ {
await _modal.ShowAsync(); await _modal.ShowAsync();
} }
private async Task OnHideModalClick() private async Task OnHideModalClick()
{ {
await _modal.HideAsync(); await _modal.HideAsync();
} }
private void OnModalShowing() private void ShowMessage(ToastType toastType) => messages.Add(CreateToastMessage(toastType));
{
ToastService.Notify(new(ToastType.Primary, $"Event: Showing called. DateTime: {DateTime.Now}"));
}
private void OnModalShown() private ToastMessage CreateToastMessage(ToastType toastType)
{ => new ToastMessage
ToastService.Notify(new(ToastType.Success, $"Event: Show called. DateTime: {DateTime.Now}")); {
} Type = toastType,
Title = "Blazor Bootstrap",
HelpText = $"{DateTime.Now}",
Message = $"Hello, world! This is a toast message. DateTime: {DateTime.Now}",
};
private void OnModalHiding()
{
ToastService.Notify(new(ToastType.Danger, $"Event: Hiding called. DateTime: {DateTime.Now}"));
}
private void OnModalHidden()
{
ToastService.Notify(new(ToastType.Warning, $"Event: Hide called. DateTime: {DateTime.Now}"));
}
private void OnModalHidePrevented()
{
ToastService.Notify(new(ToastType.Info, $"Event: Hide Prevented called. DateTime: {DateTime.Now}"));
}
} }