BlazorStart/Start/Client/Components/CreateContainer.razor
2022-04-19 13:04:38 -07:00

80 lines
2.8 KiB
Plaintext

@using Start.Client.Components.Shared
@using Start.Client.Store.Features.CreateContainer
@using Fluxor
@inherits Fluxor.Blazor.Web.Components.FluxorComponent
@inject IDispatcher dispatch
@inject IState<CreateContainerState> state
<Dialog Active="this.state.Value.ShowCreateContainerForm" OnClose="this.OnDialogClose">
<Header>
Create Container
</Header>
<Body>
<EditForm Model="this.Model" OnValidSubmit="this.OnSubmit">
<DataAnnotationsValidator />
@if (this.state.Value.CreateContainerErrorMessage != null)
{
<Alert Type="Alert.AlertType.Error">
@this.state.Value.CreateContainerErrorMessage
</Alert>
}
<ValidationSummary />
<div class="form-group">
<div class="container">
<div class="columns">
<div class="column col-12">
<div>
<label for="createBookmarkContainerTitle" class="form-label">Title</label>
<InputText id="createBookmarkContainerTitle" name="createBookmarkContainerTitle"
class="form-input" @bind-Value="this.Model.Title" />
</div>
</div>
</div>
</div>
<div class="container">
<div class="columns">
<div class="column col-12 text-right">
<div>
@if (this.state.Value.IsLoadingCreateContainer)
{
<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>
</div>
</div>
</div>
</div>
</EditForm>
</Body>
</Dialog>
@code {
[Parameter]
public EventCallback<BookmarkContainerDto> OnCreated { get; set; }
private BookmarkContainerDto Model { get; set; } = new BookmarkContainerDto("", 0);
protected void OnSubmit()
{
dispatch.Dispatch(new SubmitCreateContainerAction(this.Model));
}
protected void OnDialogClose()
{
dispatch.Dispatch(new HideCreateContainerFormAction());
}
}