Files
lmxopcua/docs/ui-consistency/evidence/ot13-simple-modals/canary/Components/Fixture.razor
T

25 lines
2.0 KiB
Plaintext

@page "/"
@rendermode InteractiveServer
@inject FixtureState State
<h1>Local synthetic modal fixture</h1>
<button type="button" id="open" @onclick="() => _visible=true">Open fixture</button>
<button type="button" id="outside">Outside fixture control</button>
<output id="ready">@(_ready ? "ready" : "loading")</output><output id="operations">@(State.Operations + _callbacks)</output><output id="closes">@_closes</output>
@if (Kind == "name") { <RawNameDialog Visible="_visible" VisibleChanged="SetVisible" Title="New fixture folder" OnSubmit="SubmitName" /> }
else if (Kind == "driver") { <RawDriverTypeDialog Visible="_visible" VisibleChanged="SetVisible" OnSubmit="SubmitDriver" /> }
else if (Kind == "message") { <RawStubModal Visible="_visible" Title="Fixture warning" Message="Synthetic read-only warning. No operational changes." NodeName="fixture-node" OnClose="Close"/> }
else if (Kind == "area") { <AreaModal Visible="_visible" IsNew="true" ClusterId="C1" Clusters="_clusters" OnSaved="Close" OnCancel="Close"/> }
else if (Kind == "line") { <LineModal Visible="_visible" IsNew="true" UnsAreaId="A1" Areas="_areas" OnSaved="Close" OnCancel="Close"/> }
else { <p>Unknown fixture kind. No component is rendered.</p> }
@code {
[SupplyParameterFromQuery(Name="kind")] public string Kind {get;set;}="name";
private bool _visible,_ready;private int _callbacks,_closes;
private readonly (string Id,string Display)[] _clusters=[("C1","Synthetic cluster")];
private readonly (string Id,string Display)[] _areas=[("A1","Synthetic area")];
protected override void OnAfterRender(bool firstRender){if(firstRender){_ready=true;StateHasChanged();}}
private Task SetVisible(bool value){_visible=value;return Task.CompletedTask;}
private async Task Close(){_closes++;await Task.Delay(600);_visible=false;}
private async Task SubmitName(string value){_callbacks++;await Task.Delay(600);}
private async Task SubmitDriver((string DriverType,string Name) value){_callbacks++;await Task.Delay(600);}
}