mirror of
https://github.com/alexhopeoconnor/dnsmasq-webui.git
synced 2026-10-03 22:12:00 +10:00
Add readonly badge/popover guidance, pending change tracking, and save confirmation flow for effective config editing. Update field renderers and config services to commit staged changes, and remove bundled Bootstrap dist assets from wwwroot.
47 lines
1.9 KiB
Plaintext
47 lines
1.9 KiB
Plaintext
@namespace DnsmasqWebUI.Components.Dnsmasq.EffectiveConfig.CustomDisplays
|
|
@using DnsmasqWebUI.Models.Dnsmasq
|
|
|
|
@* Value-only display for int? options. When active editor: number input (unless readonly); View: value + optional suffix/unit. Metadata from EffectiveIntegerConfigFieldDescriptor. *@
|
|
@if (IsActiveEditor && Descriptor.GetSource()?.IsReadOnly != true)
|
|
{
|
|
var current = Descriptor.GetValue() is int i ? i : DefaultValue;
|
|
<input type="number" class="form-control form-control-sm" style="max-width: 8rem;"
|
|
min="@Min" max="@Max" value="@(current?.ToString() ?? "")" @oninput="OnInput" @onfocusout="OnCommitRequested" />
|
|
}
|
|
else
|
|
{
|
|
var v = Descriptor.GetValue() is int n ? n : (int?)null;
|
|
if (v is null)
|
|
{
|
|
@("(not set)")
|
|
}
|
|
else
|
|
{
|
|
@v
|
|
@if (!string.IsNullOrEmpty(ViewSuffix)) { <text> @ViewSuffix</text> }
|
|
@if (!string.IsNullOrEmpty(Unit)) { <text> @Unit</text> }
|
|
}
|
|
}
|
|
|
|
@code {
|
|
[Parameter] public EffectiveConfigFieldDescriptor Descriptor { get; set; } = null!;
|
|
[CascadingParameter] public bool IsActiveEditor { get; set; }
|
|
[CascadingParameter] public EventCallback<FocusEventArgs> OnCommitRequested { get; set; }
|
|
[Parameter] public EventCallback<object?> ValueChanged { get; set; }
|
|
|
|
private EffectiveIntegerConfigFieldDescriptor? IntDescriptor => Descriptor as EffectiveIntegerConfigFieldDescriptor;
|
|
private string? ViewSuffix => IntDescriptor?.ViewSuffix;
|
|
private string? Unit => IntDescriptor?.Unit;
|
|
private int Min => IntDescriptor?.Min ?? 0;
|
|
private int Max => IntDescriptor?.Max ?? int.MaxValue;
|
|
private int? DefaultValue => IntDescriptor?.DefaultValue;
|
|
|
|
private async Task OnInput(ChangeEventArgs e)
|
|
{
|
|
int? value = null;
|
|
if (int.TryParse(e.Value?.ToString(), out var num) && num >= Min && num <= Max)
|
|
value = num;
|
|
await ValueChanged.InvokeAsync(value);
|
|
}
|
|
}
|