From 07728d1048f34e1d048da63684b341ab30bc1d06 Mon Sep 17 00:00:00 2001 From: Jake Mannens Date: Mon, 16 Oct 2023 02:01:27 +1100 Subject: FeedService and AclDialog --- Pages/Component/MiniPrincipalSelect.razor | 59 ++++++++++++++++++++++--------- 1 file changed, 42 insertions(+), 17 deletions(-) (limited to 'Pages/Component/MiniPrincipalSelect.razor') diff --git a/Pages/Component/MiniPrincipalSelect.razor b/Pages/Component/MiniPrincipalSelect.razor index 2202b95..89409bd 100644 --- a/Pages/Component/MiniPrincipalSelect.razor +++ b/Pages/Component/MiniPrincipalSelect.razor @@ -1,18 +1,19 @@ @inject ISecurityService securityService +@inject IJSRuntime jsRuntime -
- @if(edit) { +
+ @if(newName is not null) { - - + + } else { - Edit(true))> + @if(SecurityIdentifier is null || SecurityIdentifier == WellKnownSid.NullSid) { Please select a user or group } else { - @securityService.TranslateName(SecurityIdentifier) + @name } } @@ -25,20 +26,44 @@ [Parameter] public EventCallback OnChange { get; set; } - private bool edit = false; - private string name; + private bool edit = false; + private string? name; + private string? newName; - public SecurityIdentifier? SecurityIdentifier { get; set; } + private ElementReference div; - private void Edit(bool enableEdit) { - edit = enableEdit; + private HyperBooru.SecurityIdentifier? securityIdentifier; - if(enableEdit) - name = SecurityIdentifier is null ? "" : - securityService.TranslateName(SecurityIdentifier); + public SecurityIdentifier? SecurityIdentifier { + get => securityIdentifier; + set { + securityIdentifier = value; + name = value is null ? null : securityService.TranslateName(value); + } } - private void Submit() { - Edit(false); + private void Edit() { + newName = SecurityIdentifier == WellKnownSid.NullSid ? "" : name; + StateHasChanged(); } -} \ No newline at end of file + + private async void Cancel() { + newName = null; + await jsRuntime.InvokeVoidAsync("removeClass", div, "bad-principal"); + StateHasChanged(); + } + + private async void Submit() { + var sid = securityService.TranslateName(newName!); + if(sid is null) { + await jsRuntime.InvokeVoidAsync("cycleClass", div, "bad-principal"); + return; + } + + await jsRuntime.InvokeVoidAsync("removeClass", div, "bad-principal"); + SecurityIdentifier = sid; + await OnChange.InvokeAsync(sid); + newName = null; + StateHasChanged(); + } +} -- cgit v1.3