Skip to content

Commit 867026d

Browse files
authored
Создание контрола JoinTextInput (#3035)
1 parent ae46070 commit 867026d

File tree

3 files changed

+36
-8
lines changed

3 files changed

+36
-8
lines changed

src/JoinRpg.Web.ProjectCommon/Projects/CreateProjectPanel.razor

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,12 +34,12 @@
3434
<JoinPanel>
3535
<Header>Создание новой базы заявок</Header>
3636
<Body>
37-
<EditForm FormName="CreateProject" EditContext="@editContext" method="post" action="/game/create" OnValidSubmit="HandleValidSubmit">
37+
<EditForm FormName="CreateProject" EditContext="@editContext" OnValidSubmit="HandleValidSubmit">
3838
<FormHorizontal>
3939
<ValidationSummary />
4040
<DataAnnotationsValidator />
4141
<FormRowFor For="@(() => Model.ProjectName)">
42-
<InputText @bind-Value="Model.ProjectName" class="form-control" />
42+
<JoinTextInput @bind-Value="Model.ProjectName" />
4343
</FormRowFor>
4444
<FormRowFor For="@(() => Model.RulesApproved)">
4545
<CheckboxInput @bind-Value="Model.RulesApproved" />
@@ -49,7 +49,7 @@
4949
<JoinAlert Variation="VariationStyleEnum.Info">Все настройки можно будет изменить после создания проекта.</JoinAlert>
5050
</FormRowFor>
5151
<FormRowFor For="@(() => Model.CopyFromProjectId)" hidden="@(Model.ProjectType != ProjectTypeViewModel.CopyFromAnother)">
52-
<ProjectSelector @bind-ProjectId="Model.CopyFromProjectId" Name="CopyFromProjectId" />
52+
<ProjectSelector @bind-ProjectId="Model.CopyFromProjectId" />
5353
</FormRowFor>
5454
<FormRow>
5555
<JoinCreateButton Submit="true" Disabled="@formInvalid" />

src/JoinRpg.WebComponents/JoinRpg.WebComponents.csproj

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,4 @@
2626
<None Update="libman.json" />
2727
</ItemGroup>
2828

29-
<ItemGroup>
30-
<UpToDateCheckInput Remove="HelpLink.razor" />
31-
<_ContentIncludedByDefault Remove="HelpLink.razor" />
32-
</ItemGroup>
33-
3429
</Project>
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
@using System.Linq.Expressions
2+
<input type="text" name="@FieldIdentifier.FieldName" value="@internalValue" @onchange="UpdateValue" class="form-control" />
3+
4+
@code {
5+
[CascadingParameter]
6+
private EditContext? EditContext {get;set;}
7+
8+
[Parameter]
9+
public string Value { get; set; }
10+
11+
[Parameter]
12+
public EventCallback<string> ValueChanged { get; set; }
13+
14+
[Parameter]
15+
public Expression<Func<string>> ValueExpression { get; set; } = default!;
16+
17+
private FieldIdentifier FieldIdentifier { get; set; }
18+
19+
private string internalValue = "";
20+
21+
protected override void OnInitialized()
22+
{
23+
internalValue = Value;
24+
FieldIdentifier = FieldIdentifier.Create(ValueExpression);
25+
}
26+
27+
private async Task UpdateValue(ChangeEventArgs eventArgs)
28+
{
29+
internalValue = (string?) eventArgs.Value ?? "";
30+
await ValueChanged.InvokeAsync(internalValue);
31+
EditContext?.NotifyFieldChanged(FieldIdentifier);
32+
}
33+
}

0 commit comments

Comments
 (0)