96 lines
3.4 KiB
Plaintext
96 lines
3.4 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.Components.BaseModal
|
|
|
|
<h1 class="mb-5 font-semibold text-xl">Update variable</h1>
|
|
|
|
<HandleForm @ref="HandleForm" Model="Form" OnValidSubmit="OnValidSubmit">
|
|
<div class="grid grid-cols-1 md:grid-cols-2 gap-2">
|
|
<div class="col-span-1">
|
|
<label class="block text-sm font-medium leading-6 text-base-content">Name</label>
|
|
<input @bind="Form.Name" type="text" class="input w-full"/>
|
|
</div>
|
|
|
|
<div class="col-span-1">
|
|
<label class="block text-sm font-medium leading-6 text-base-content">Description</label>
|
|
<input @bind="Form.Description" type="text" class="input w-full"/>
|
|
</div>
|
|
|
|
<div class="col-span-1">
|
|
<label class="block text-sm font-medium leading-6 text-base-content">Key</label>
|
|
<input @bind="Form.Key" type="text" class="input w-full"/>
|
|
</div>
|
|
|
|
<div class="col-span-1">
|
|
<label class="block text-sm font-medium leading-6 text-base-content">Default Value</label>
|
|
<input @bind="Form.DefaultValue" type="text" class="input w-full"/>
|
|
</div>
|
|
|
|
<div class="col-span-1">
|
|
<label class="block text-sm font-medium leading-6 text-base-content">Allow Viewing</label>
|
|
<Switch @bind-Value="Form.AllowViewing"/>
|
|
</div>
|
|
|
|
<div class="col-span-1">
|
|
<label class="block text-sm font-medium leading-6 text-base-content">Allow Editing</label>
|
|
<Switch @bind-Value="Form.AllowEditing"/>
|
|
</div>
|
|
|
|
<div class="col-span-1">
|
|
<label class="block text-sm font-medium leading-6 text-base-content">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="block text-sm font-medium leading-6 text-base-content">Filter</label>
|
|
<input @bind="Form.Filter" type="text" class="input w-full"/>
|
|
</div>
|
|
</div>
|
|
</HandleForm>
|
|
|
|
<div class="mt-5 flex space-x-2">
|
|
<WButton OnClick="_ => Hide()" CssClasses="btn btn-secondary grow">Cancel</WButton>
|
|
<WButton OnClick="_ => Submit()" CssClasses="btn btn-primary grow">Update</WButton>
|
|
</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 Hide();
|
|
}
|
|
|
|
private Task Submit() => HandleForm.Submit();
|
|
}
|