//
// Licensed under the MIT License. See LICENSE file in the project root for full license information.
//
namespace MUnique.OpenMU.Web.AdminPanel.Pages;
using System.Globalization;
using Microsoft.AspNetCore.Components;
using Microsoft.AspNetCore.Components.Rendering;
using MUnique.OpenMU.DataModel.Configuration;
using MUnique.OpenMU.DataModel.Entities;
using MUnique.OpenMU.Web.AdminPanel.Properties;
using MUnique.OpenMU.Web.Shared.Components.Form;
using MUnique.OpenMU.Web.Shared.Components.ItemEdit;
///
/// A generic edit page, which shows an for the given and .
///
[Route("/edit-config/{typeString}/")]
[Route("/edit-config/{typeString}/{id:guid}")]
[Route("/edit-config/{typeString}/{id:guid}/hide-collections")]
public sealed class EditConfig : EditBase
{
private static readonly IDictionary> EditorPages =
new Dictionary>
{
{ typeof(GameMapDefinition), new List<(string, string)> { (Resources.MapEditor, "/map-editor/{0}") } },
};
///
/// Gets or sets the optional search term to pre-filter fields.
///
[SupplyParameterFromQuery(Name = "search")]
public string? SearchTerm { get; set; }
///
protected override void AddFormToRenderTree(RenderTreeBuilder builder, ref int currentSequence)
{
var hideCollections = this.NavigationManager.Uri.EndsWith("hide-collections");
if (this.Type == typeof(Item))
{
builder.OpenComponent(++currentSequence, typeof(ItemEdit));
builder.AddAttribute(++currentSequence, nameof(ItemEdit.Item), this.Model);
builder.AddAttribute(++currentSequence, nameof(ItemEdit.OnValidSubmit), EventCallback.Factory.Create(this, this.SaveChangesAsync));
builder.CloseComponent();
}
else
{
builder.OpenComponent(++currentSequence, typeof(AutoForm<>).MakeGenericType(this.Type!));
builder.AddAttribute(++currentSequence, nameof(AutoForm