93 lines
3.3 KiB
Plaintext
93 lines
3.3 KiB
Plaintext
@implements IDisposable
|
|
|
|
<div class ="d-flex w-100 h-100 flex-column">
|
|
<EditForm EditContext="EditContext">
|
|
<DataAnnotationsValidator />
|
|
|
|
<div class="mb-2">
|
|
<label class="form-label">Navigation Type</label>
|
|
<InputSelect class="form-select" @bind-Value="Model.NavigationType" TValue="NavigationType">
|
|
@foreach (var t in NavigationTypes)
|
|
{
|
|
<option value="@t">@t</option>
|
|
}
|
|
</InputSelect>
|
|
<ValidationMessage For="@(() => Model.NavigationType)" />
|
|
</div>
|
|
|
|
<div class="row g-2 mb-2">
|
|
<div class="col">
|
|
<label class="form-label">Radius (wheel)</label>
|
|
<InputNumber class="form-control" @bind-Value="Model.RadiusWheel" />
|
|
<ValidationMessage For="@(() => Model.RadiusWheel)" />
|
|
</div>
|
|
<div class="col">
|
|
<label class="form-label">Width (m)</label>
|
|
<InputNumber class="form-control" @bind-Value="Model.Width" />
|
|
<ValidationMessage For="@(() => Model.Width)" />
|
|
</div>
|
|
</div>
|
|
|
|
<div class="row g-2 mb-2">
|
|
<div class="col">
|
|
<label class="form-label">Length (m)</label>
|
|
<InputNumber class="form-control" @bind-Value="Model.Length" />
|
|
<ValidationMessage For="@(() => Model.Length)" />
|
|
</div>
|
|
<div class="col">
|
|
<label class="form-label">Height (m)</label>
|
|
<InputNumber class="form-control" @bind-Value="Model.Height" />
|
|
<ValidationMessage For="@(() => Model.Height)" />
|
|
</div>
|
|
</div>
|
|
|
|
<div class="mb-2">
|
|
<label class="form-label">Description</label>
|
|
<InputTextArea class="form-control" @bind-Value="Model.Description" />
|
|
<ValidationMessage For="@(() => Model.Description)" />
|
|
</div>
|
|
</EditForm>
|
|
<div class="flex-grow-1" />
|
|
<div>
|
|
@if (Model.CreatedAt != default || Model.UpdatedAt != default)
|
|
{
|
|
<div class="d-flex justify-content-end mt-2">
|
|
<small class="text-muted">Created: @Model.CreatedAt.ToString("dd/MM/yyyy HH:mm:ss")</small>
|
|
<small class="text-muted ms-3">Updated: @Model.UpdatedAt.ToString("dd/MM/yyyy HH:mm:ss")</small>
|
|
</div>
|
|
}
|
|
</div>
|
|
</div>
|
|
|
|
|
|
@code {
|
|
[Parameter]
|
|
public RobotConfigDto Model { get; set; } = new();
|
|
|
|
[Parameter]
|
|
public EventCallback<RobotConfigDto> ModelChanged { get; set; }
|
|
|
|
private EditContext? EditContext;
|
|
private IEnumerable<NavigationType> NavigationTypes => Enum.GetValues(typeof(NavigationType)).Cast<NavigationType>();
|
|
|
|
protected override void OnParametersSet()
|
|
{
|
|
if (EditContext is null || !EditContext.Model!.Equals(Model))
|
|
{
|
|
if (EditContext is not null) EditContext.OnFieldChanged -= EditContext_OnFieldChanged;
|
|
EditContext = new EditContext(Model);
|
|
EditContext.OnFieldChanged += EditContext_OnFieldChanged;
|
|
}
|
|
}
|
|
|
|
private void EditContext_OnFieldChanged(object? sender, FieldChangedEventArgs e)
|
|
{
|
|
_ = ModelChanged.InvokeAsync(Model);
|
|
}
|
|
|
|
public void Dispose()
|
|
{
|
|
if (EditContext is not null) EditContext.OnFieldChanged -= EditContext_OnFieldChanged;
|
|
}
|
|
}
|