Module ordering improvements

This commit is contained in:
Shaun Walker
2019-09-10 09:56:42 -04:00
parent f60898dbc7
commit 2a691dbceb
12 changed files with 229 additions and 152 deletions

View File

@ -13,45 +13,34 @@
[Parameter]
public Module Module { get; set; }
Module ModuleState;
string container;
RenderFragment DynamicComponent { get; set; }
Module ModuleState;
protected override void OnParametersSet()
{
ModuleState = Module; // passed in from Pane component
string container = ModuleState.ContainerType;
if (PageState.ModuleId != -1 && PageState.Control != "" && ModuleState.UseAdminContainer)
{
container = Constants.DefaultAdminContainer;
}
DynamicComponent = builder =>
{
if (ModuleState != null)
Type containerType = Type.GetType(container);
if (containerType != null)
{
Type containerType = Type.GetType(container);
if (containerType != null)
{
builder.OpenComponent(0, containerType);
builder.CloseComponent();
}
else
{
// container does not exist with type specified
builder.OpenComponent(0, Type.GetType(Constants.ModuleMessageControl));
builder.AddAttribute(1, "Message", "Error Loading Module Container " + container);
builder.CloseComponent();
}
builder.OpenComponent(0, containerType);
builder.CloseComponent();
}
else
{
// container does not exist with type specified
builder.OpenComponent(0, Type.GetType(Constants.ModuleMessageControl));
builder.AddAttribute(1, "Message", "Error Loading Module Container " + container);
builder.CloseComponent();
}
};
}
protected override Task OnParametersSetAsync()
{
if (PageState.Page.PageId == Module.PageId)
{
ModuleState = Module; // passed in from Pane component
container = ModuleState.ContainerType;
if (PageState.ModuleId != -1 && PageState.Control != "" && ModuleState.UseAdminContainer)
{
container = Constants.DefaultAdminContainer;
}
}
return Task.CompletedTask;
}
}

View File

@ -1,5 +1,6 @@
@using Oqtane.Services
@using Oqtane.Models
@using Oqtane.Shared
@inject IUriHelper UriHelper
@inject IInstallationService InstallationService
@inject IUserService UserService
@ -167,8 +168,8 @@
user.Username = Email;
user.DisplayName = Email;
user.Email = Email;
user.Password = HostPassword;
user.IsHost = true;
user.Password = HostPassword;
user = await UserService.AddUserAsync(user);
UriHelper.NavigateTo("", true);

View File

@ -9,13 +9,13 @@
@inject IModuleService ModuleService
@inject IModuleDefinitionService ModuleDefinitionService
<div class="@paneadminborder">
@if (panetitle != "")
{
@((MarkupString)panetitle)
}
@DynamicComponent
</div>
<div class="@paneadminborder">
@if (panetitle != "")
{
@((MarkupString)panetitle)
}
@DynamicComponent
</div>
@code {
[CascadingParameter]
@ -129,6 +129,7 @@
{
builder.OpenComponent(0, Type.GetType(Constants.DefaultContainer));
builder.AddAttribute(1, "Module", module);
builder.SetKey(module.PageModuleId);
builder.CloseComponent();
}
}