summaryrefslogtreecommitdiff
path: root/Pages/Component/MiniPrincipalSelect.razor
blob: 2202b95240d42c20f8025eb94cd3c2e03e1576ce (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
@inject ISecurityService securityService

<div>
    @if(edit) {
        <label>@Label</label>
        <input type="text" autocomplete="off" @bind=name/>
        <button class="secondary" @onclick=@(() => Edit(false))>Cancel</button>
        <button @onclick=Submit>OK</button>
    } else {
        <label>@(Label):</label>
        <a href="javascript:;" @onclick=@(() => Edit(true))>
            @if(SecurityIdentifier is null || SecurityIdentifier == WellKnownSid.NullSid) {
                <i>Please select a user or group</i>
            } else {
                @securityService.TranslateName(SecurityIdentifier)
            }
        </a>
    }
</div>

@code {
    [Parameter]
    public string Label { get; set; }

    [Parameter]
    public EventCallback<SecurityIdentifier> OnChange { get; set; }

    private bool   edit = false;
    private string name;

    public SecurityIdentifier? SecurityIdentifier { get; set; }

    private void Edit(bool enableEdit) {
        edit = enableEdit;

        if(enableEdit)
            name = SecurityIdentifier is null ? "" :
                securityService.TranslateName(SecurityIdentifier);
    }

    private void Submit() {
        Edit(false);
    }
}