BlazorStart/Start/Client/Components/CreateBookmark.razor

98 lines
3.6 KiB
Plaintext
Raw Normal View History

2021-12-17 06:06:41 +00:00
@using Start.Client.Components.Shared
@using Start.Client.Store.Features.CreateBookmark
2021-12-14 00:27:13 +00:00
@using Fluxor
@inherits Fluxor.Blazor.Web.Components.FluxorComponent
@inject IActionSubscriber actionSubscriber
@inject IDispatcher dispatch
@inject IState<CreateBookmarkState> state
2021-12-17 06:06:41 +00:00
<Dialog Active="this.state.Value.ShowCreateBookmarkForm" OnClose="this.OnDialogClose">
<Header>
Create Bookmark
</Header>
<Body>
<EditForm Model="this.Model" OnValidSubmit="this.OnSubmit">
<DataAnnotationsValidator />
2021-12-14 00:27:13 +00:00
2021-12-17 06:06:41 +00:00
@if (this.state.Value.CreateBookmarkErrorMessage != null)
{
<Alert Type="Alert.AlertType.Error">
@this.state.Value.CreateBookmarkErrorMessage
</Alert>
}
2021-12-14 00:27:13 +00:00
2021-12-17 06:06:41 +00:00
<ValidationSummary />
2021-12-14 00:27:13 +00:00
2021-12-17 06:06:41 +00:00
<div class="form-group">
<div class="container">
<div class="columns">
<div class="column col-12">
<label for="createBookmarkTitle">Title</label>
<InputText id="createBookmarkTitle" name="createBookmarkTitle"
class="form-input" @bind-Value="this.Model.Title" />
</div>
2021-12-14 00:27:13 +00:00
</div>
2021-12-17 06:06:41 +00:00
<div class="columns">
<div class="column col-12">
<label for="createBookmarkUrl">URL</label>
<input type="url" name="createBookmarkUrl" class="form-input"
@bind-value="this.Model.Url" />
</div>
2021-12-14 00:27:13 +00:00
</div>
2021-12-17 06:06:41 +00:00
<div class="columns">
<div class="column col-12">
<label for="createBookmarkNotes">Notes</label>
<InputTextArea name="createBookmarkNotes" class="form-input"
@bind-Value="this.Model.Notes" />
</div>
2021-12-14 00:27:13 +00:00
</div>
</div>
2021-12-17 06:06:41 +00:00
<div class="container">
<div class="columns">
<div class="column col-12 text-right">
@if (this.state.Value.IsLoadingCreateBookmark)
{
<button type="submit" disabled class="btn btn-primary loading">
<i class="icon icon-plus"></i> Create
</button>
}
else
{
<button type="submit" class="btn btn-primary">
<i class="icon icon-plus"></i> Create
</button>
}
</div>
2021-12-14 00:27:13 +00:00
</div>
</div>
</div>
2021-12-17 06:06:41 +00:00
</EditForm>
</Body>
2021-12-14 00:27:13 +00:00
</Dialog>
@code {
2022-04-19 20:04:38 +00:00
protected BookmarkDto Model { get; set; } = new BookmarkDto("", "", null, 0, 0);
2021-12-14 00:27:13 +00:00
protected override void OnInitialized()
{
base.OnInitialized();
2022-04-19 20:04:38 +00:00
this.Model = new BookmarkDto("", "", null, 0, this.state.Value.GroupId);
2021-12-14 00:27:13 +00:00
actionSubscriber.SubscribeToAction<ShowCreateBookmarkFormAction>(this,
a => this.Model.BookmarkGroupId = a.GroupId);
}
protected void OnSubmit()
{
dispatch.Dispatch(new SubmitCreateBookmarkAction(this.Model));
}
protected void OnDialogClose()
{
dispatch.Dispatch(new HideCreateBookmarkFormAction());
}
}