BlazorStart/Start/Client/Components/CreateGroup.razor

89 lines
3.1 KiB
Plaintext
Raw Normal View History

2021-12-17 06:06:41 +00:00
@using Start.Client.Components.Shared
@using Start.Client.Store.Features.CreateGroup
2021-12-05 23:50:48 +00:00
@using Fluxor
@inherits Fluxor.Blazor.Web.Components.FluxorComponent
@inject IActionSubscriber actionSubscriber
@inject IDispatcher dispatch
@inject IState<CreateGroupState> state
2021-12-17 06:06:41 +00:00
<Dialog Active="this.state.Value.ShowCreateGroupForm" OnClose="this.OnDialogClose">
<Header>
Create Bookmark Group
</Header>
<Body>
<EditForm Model="this.Model" OnValidSubmit="this.OnSubmit">
<DataAnnotationsValidator />
2021-12-05 23:50:48 +00:00
2021-12-17 06:06:41 +00:00
@if (this.state.Value.CreateGroupErrorMessage != null)
{
<Alert Type="Alert.AlertType.Error">
@this.state.Value.CreateGroupErrorMessage
</Alert>
}
2021-12-05 23:50:48 +00:00
2021-12-17 06:06:41 +00:00
<ValidationSummary />
2021-12-05 23:50:48 +00:00
2021-12-17 06:06:41 +00:00
<div class="form-group">
<div class="container">
<div class="columns">
<div class="column col-10">
<label for="createBookmarkGroupTitle">Title</label>
<InputText id="createBookmarkGroupTitle" name="createBookmarkGroupTitle"
class="form-input" @bind-Value="this.Model.Title" />
</div>
<div class="column col-2">
<label for="createBookmarkGroupColor">Color</label>
<input type="color" name="createBookmarkGroupColor" @bind="this.Model.Color" />
</div>
2021-12-05 23:50:48 +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.IsLoadingCreateGroup)
{
<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-05 23:50:48 +00:00
</div>
</div>
</div>
2021-12-17 06:06:41 +00:00
</EditForm>
</Body>
2021-12-05 23:50:48 +00:00
</Dialog>
@code {
2022-04-19 20:04:38 +00:00
private BookmarkGroupDto Model { get; set; } = new("", "", 0, 0);
2021-12-05 23:50:48 +00:00
protected override void OnInitialized()
{
base.OnInitialized();
2022-04-19 20:04:38 +00:00
this.Model = new BookmarkGroupDto("", "", 0, state.Value.ContainerId);
2021-12-05 23:50:48 +00:00
// Keep the model's container ID up to date
actionSubscriber.SubscribeToAction<ShowCreateGroupFormAction>(this,
(a) => this.Model.BookmarkContainerId = a.ContainerId);
}
protected void OnSubmit()
{
dispatch.Dispatch(new SubmitCreateGroupAction(this.Model));
}
protected void OnDialogClose()
{
dispatch.Dispatch(new HideCreateGroupFormAction());
}
}