112 lines
3.9 KiB
Plaintext
112 lines
3.9 KiB
Plaintext
@using MoonCore.Blazor.FlyonUi.Components
|
|
@using MoonlightServers.Shared.Enums
|
|
@using MoonlightServers.Shared.Http.Requests.Admin.StarVariables
|
|
@using MoonlightServers.Frontend.UI.Components.Forms
|
|
@using MoonlightServers.Shared.Http.Responses.Admin.StarVariables
|
|
|
|
@inherits MoonCore.Blazor.FlyonUi.Modals.BaseModal
|
|
|
|
<div class="p-5">
|
|
<div class="flex items-center gap-4">
|
|
<div class="avatar avatar-placeholder max-sm:hidden">
|
|
<div class="border-base-content/20 rounded-box w-13 border-1">
|
|
<span class="icon-variable text-xl"></span>
|
|
</div>
|
|
</div>
|
|
<div class="space-y-1">
|
|
<h3 class="text-base-content text-2xl font-semibold">Update variable</h3>
|
|
<p class="text-base-content/80">Update variable properties</p>
|
|
</div>
|
|
</div>
|
|
<div class="mt-5">
|
|
<HandleForm @ref="HandleForm" Model="Form" OnValidSubmit="OnValidSubmit">
|
|
<div class="grid grid-cols-2 gap-2">
|
|
<div class="col-span-1">
|
|
<label class="label-text">Name</label>
|
|
<input @bind="Form.Name" type="text" class="input w-full"/>
|
|
</div>
|
|
|
|
<div class="col-span-1">
|
|
<label class="label-text">Description</label>
|
|
<input @bind="Form.Description" type="text" class="input w-full"/>
|
|
</div>
|
|
|
|
<div class="col-span-1">
|
|
<label class="label-text">Key</label>
|
|
<input @bind="Form.Key" type="text" class="input w-full"/>
|
|
</div>
|
|
|
|
<div class="col-span-1">
|
|
<label class="label-text">Default Value</label>
|
|
<input @bind="Form.DefaultValue" type="text" class="input w-full"/>
|
|
</div>
|
|
|
|
<div class="col-span-1">
|
|
<label class="label-text">Allow Viewing</label>
|
|
<Switch @bind-Value="Form.AllowViewing"/>
|
|
</div>
|
|
|
|
<div class="col-span-1">
|
|
<label class="label-text">Allow Editing</label>
|
|
<Switch @bind-Value="Form.AllowEditing"/>
|
|
</div>
|
|
|
|
<div class="col-span-1">
|
|
<label class="label-text">Type</label>
|
|
<select @bind="Form.Type" class="select w-full">
|
|
@foreach (var val in Enum.GetValues<StarVariableType>())
|
|
{
|
|
<option value="@val">@val</option>
|
|
}
|
|
</select>
|
|
</div>
|
|
|
|
<div class="col-span-1">
|
|
<label class="label-text">Filter</label>
|
|
<input @bind="Form.Filter" type="text" class="input w-full"/>
|
|
</div>
|
|
</div>
|
|
</HandleForm>
|
|
</div>
|
|
<div class="mt-5 flex justify-end">
|
|
<button @onclick="HideAsync" type="button" class="btn btn-secondary me-2">
|
|
Cancel
|
|
</button>
|
|
<WButton OnClick="SubmitAsync">
|
|
Update
|
|
</WButton>
|
|
</div>
|
|
</div>
|
|
|
|
@code
|
|
{
|
|
[Parameter] public Func<UpdateStarVariableRequest, Task> OnSubmit { get; set; }
|
|
[Parameter] public StarVariableResponse Variable { get; set; }
|
|
|
|
private UpdateStarVariableRequest Form;
|
|
private HandleForm HandleForm;
|
|
|
|
protected override void OnInitialized()
|
|
{
|
|
Form = new()
|
|
{
|
|
Name = Variable.Name,
|
|
AllowEditing = Variable.AllowEditing,
|
|
AllowViewing = Variable.AllowViewing,
|
|
DefaultValue = Variable.DefaultValue,
|
|
Description = Variable.Description,
|
|
Filter = Variable.Filter,
|
|
Key = Variable.Key,
|
|
Type = Variable.Type
|
|
};
|
|
}
|
|
|
|
private async Task OnValidSubmit()
|
|
{
|
|
await OnSubmit.Invoke(Form);
|
|
await HideAsync();
|
|
}
|
|
|
|
private Task SubmitAsync() => HandleForm.SubmitAsync();
|
|
}
|