BlazorStart/Start/Client/Components/DeleteBookmark.razor

80 lines
2.5 KiB
Plaintext
Raw Normal View History

2021-12-17 06:06:41 +00:00
@using Start.Client.Components.Shared
@using Start.Client.Store.Features.DeleteBookmark
2021-12-16 18:46:22 +00:00
@using Fluxor
@inherits Fluxor.Blazor.Web.Components.FluxorComponent
@inject IDispatcher dispatch
@inject IState<DeleteBookmarkState> state
2021-12-17 06:06:41 +00:00
<Dialog Active="this.state.Value.ShowDeleteBookmarkForm" OnClose="this.OnClose">
<Header>
Delete Bookmark "@this.state.Value.BookmarkToDelete?.Title"
</Header>
<Body>
@if (this.state.Value.DeleteBookmarkErrorMessage != null)
{
<Alert Type="Alert.AlertType.Error">
@this.state.Value.DeleteBookmarkErrorMessage
</Alert>
}
2021-12-16 18:46:22 +00:00
2021-12-17 06:06:41 +00:00
@if (this.state.Value.BookmarkToDelete == null)
{
<Alert Type="Alert.AlertType.Error">
There is no bookmark to delete selected
</Alert>
}
else
{
<p>Are you sure you want to delete this bookmark?</p>
<dl>
<dt>Title</dt>
<dd>@this.state.Value.BookmarkToDelete.Title</dd>
2021-12-16 18:46:22 +00:00
2021-12-17 06:06:41 +00:00
<dt>URL</dt>
<dd>@this.state.Value.BookmarkToDelete.Url</dd>
2021-12-16 18:46:22 +00:00
2021-12-17 06:06:41 +00:00
@if (!string.IsNullOrWhiteSpace(this.state.Value.BookmarkToDelete.Notes))
{
<dt>Notes</dt>
<dd>@this.state.Value.BookmarkToDelete.Notes</dd>
}
</dl>
2021-12-16 18:46:22 +00:00
2021-12-17 06:06:41 +00:00
<div class="text-right">
@if (!this.state.Value.IsLoadingDeleteBookmark)
{
<button type="button" class="btn" @onclick="this.OnClose">Cancel</button>
<button type="submit" class="btn btn-error" @onclick="this.OnConfirmDelete">Delete</button>
}
else
{
<button type="button" disabled class="btn" @onclick="this.OnClose">Cancel</button>
<button type="submit" disabled class="btn btn-error loading" @onclick="this.OnConfirmDelete">Delete</button>
}
</div>
}
</Body>
2021-12-16 18:46:22 +00:00
</Dialog>
@code {
private void OnClose()
{
this.dispatch.Dispatch(new HideDeleteBookmarkFormAction());
}
private void OnConfirmDelete()
{
if (this.state.Value.BookmarkToDelete == null)
{
dispatch.Dispatch(new ErrorFetchingDeleteBookmarkAction(
"No bookmark to delete is selected"));
return;
}
this.dispatch.Dispatch(new SubmitDeleteBookmarkFormAction(
this.state.Value.BookmarkToDelete.BookmarkId));
}
}