summaryrefslogtreecommitdiff
path: root/Pages/Component/MiniPrincipalSelect.razor
diff options
context:
space:
mode:
authorJake Mannens <jake@asger.xyz>2023-10-16 02:01:27 +1100
committerJake Mannens <jake@asger.xyz>2023-10-16 02:01:27 +1100
commit07728d1048f34e1d048da63684b341ab30bc1d06 (patch)
tree9c92b30be5f3cd060827edc2ff5836b6122a9cdd /Pages/Component/MiniPrincipalSelect.razor
parentea89ec0c1b05ac246f2ffd5907daace27564100b (diff)
FeedService and AclDialog
Diffstat (limited to 'Pages/Component/MiniPrincipalSelect.razor')
-rw-r--r--Pages/Component/MiniPrincipalSelect.razor59
1 files changed, 42 insertions, 17 deletions
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
-<div>
- @if(edit) {
+<div @ref=div>
+ @if(newName is not null) {
<label>@Label</label>
- <input type="text" autocomplete="off" @bind=name/>
- <button class="secondary" @onclick=@(() => Edit(false))>Cancel</button>
+ <input type="text" autocomplete="off" @bind=newName/>
+ <button class="secondary" @onclick=Cancel>Cancel</button>
<button @onclick=Submit>OK</button>
} else {
<label>@(Label):</label>
- <a href="javascript:;" @onclick=@(() => Edit(true))>
+ <a href="javascript:;" @onclick=Edit>
@if(SecurityIdentifier is null || SecurityIdentifier == WellKnownSid.NullSid) {
<i>Please select a user or group</i>
} else {
- @securityService.TranslateName(SecurityIdentifier)
+ @name
}
</a>
}
@@ -25,20 +26,44 @@
[Parameter]
public EventCallback<SecurityIdentifier> 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();
+ }
+}