1
0

Create templated generic component for Fields for EditServer page.

This commit is contained in:
Kevin Matsubara 2025-03-28 20:39:30 +01:00
parent 9396e98eea
commit 6b3b08b07a
3 changed files with 45 additions and 27 deletions

View File

@ -0,0 +1,24 @@
@namespace ServerManagement.Components.Controls.Generic
<div class="row mb-3">
<div class="col-2">
<label class="col-form-label">@Label</label>
</div>
<div class="col-6 input-width">
@Control
</div>
<div class="col">
@ValidationControl
</div>
</div>
@code {
[Parameter]
public string? Label { get; set; }
[Parameter]
public RenderFragment? Control { get; set; }
[Parameter]
public RenderFragment? ValidationControl { get; set; }
}

View File

@ -15,37 +15,30 @@
<DataAnnotationsValidator></DataAnnotationsValidator>
<ValidationSummary></ValidationSummary>
<InputNumber @bind-Value="server.Id" hidden></InputNumber>
<div class="row mb-3">
<div class="col-2">
<label class="col-form-label">Name</label>
</div>
<div class="col-6 input-width">
<InputText @bind-Value="server.Name" class="form-control"></InputText>
</div>
<div class="col">
<ValidationMessage For="() => server.Name"></ValidationMessage>
</div>
</div>
<div class="row mb-3">
<div class="col-2">
<label class="col-form-label">City</label>
</div>
<div class="col-6 input-width">
<FieldComponent Label="Name">
<Control>
<InputText @bind-Value="server.Name" class="form-control"></InputText>
</Control>
<ValidationControl>
<ValidationMessage For="() => server.Name"></ValidationMessage>
</ValidationControl>
</FieldComponent>
<FieldComponent Label="City">
<Control>
<InputText @bind-Value="server.City" class="form-control"></InputText>
</div>
<div class="col">
</Control>
<ValidationControl>
<ValidationMessage For="() => server.City"></ValidationMessage>
</div>
</div>
<div class="row mb-3">
<div class="col-2">
<label class="col-form-label">Online</label>
</div>
<div class="col-6">
</ValidationControl>
</FieldComponent>
<FieldComponent Label="Online">
<Control>
<InputCheckbox @bind-Value="server.IsOnline" class="form-check-input"></InputCheckbox>
</div>
</div>
</Control>
</FieldComponent>
<br/>
<button class="btn btn-primary" type="submit">Update</button>
&nbsp;

View File

@ -9,4 +9,5 @@
@using ServerManagement
@using ServerManagement.Components
@using ServerManagement.Components.Controls
@using ServerManagement.Components.Controls.Generic
@using ServerManagement.Models