Edit mode improvements
This commit is contained in:
@ -27,7 +27,7 @@
|
||||
Type containerType = Type.GetType(container);
|
||||
if (containerType != null)
|
||||
{
|
||||
builder.OpenComponent(0, containerType);
|
||||
builder.OpenComponent(0, containerType);
|
||||
builder.CloseComponent();
|
||||
}
|
||||
else
|
||||
@ -49,7 +49,11 @@
|
||||
container = ModuleState.ContainerType;
|
||||
if (PageState.ModuleId != -1 && PageState.Control != "")
|
||||
{
|
||||
container = Constants.DefaultAdminContainer;
|
||||
container = ModuleState.AdminContainerType;
|
||||
if (container == "")
|
||||
{
|
||||
container = Constants.DefaultAdminContainer;
|
||||
}
|
||||
}
|
||||
}
|
||||
return Task.CompletedTask;
|
||||
|
@ -20,6 +20,7 @@ namespace Oqtane.Shared
|
||||
public int ModuleId { get; set; }
|
||||
public string Control { get; set; }
|
||||
public bool EditMode { get; set; }
|
||||
public bool DesignMode { get; set; }
|
||||
public int Reload { get; set; }
|
||||
}
|
||||
}
|
||||
|
@ -9,10 +9,13 @@
|
||||
@inject IModuleService ModuleService
|
||||
@inject IModuleDefinitionService ModuleDefinitionService
|
||||
|
||||
<div class="@paneadminborder">
|
||||
@((MarkupString)panetitle)
|
||||
@DynamicComponent
|
||||
</div>
|
||||
<div class="@paneadminborder">
|
||||
@if (panetitle != "")
|
||||
{
|
||||
@((MarkupString)panetitle)
|
||||
}
|
||||
@DynamicComponent
|
||||
</div>
|
||||
|
||||
@code {
|
||||
[CascadingParameter]
|
||||
@ -28,11 +31,16 @@
|
||||
|
||||
protected override void OnParametersSet()
|
||||
{
|
||||
if (PageState.EditMode && UserSecurity.IsAuthorized(PageState.User, "Edit", PageState.Page.Permissions) && Name != Constants.AdminPane)
|
||||
if (PageState.DesignMode && UserSecurity.IsAuthorized(PageState.User, "Edit", PageState.Page.Permissions) && Name != Constants.AdminPane)
|
||||
{
|
||||
paneadminborder = "pane-admin-border";
|
||||
panetitle = "<div class=\"pane-admin-title\">" + Name + " Pane</div>";
|
||||
}
|
||||
else
|
||||
{
|
||||
paneadminborder = "";
|
||||
panetitle = "";
|
||||
}
|
||||
|
||||
DynamicComponent = builder =>
|
||||
{
|
||||
@ -51,38 +59,38 @@
|
||||
Type moduleType = Type.GetType(typename);
|
||||
if (moduleType != null)
|
||||
{
|
||||
var moduleobject = Activator.CreateInstance(moduleType);
|
||||
// verify security access level for this module control
|
||||
SecurityAccessLevel SecurityAccessLevel = (SecurityAccessLevel)moduleType.GetProperty("SecurityAccessLevel").GetValue(moduleobject, null);
|
||||
bool authorized = false;
|
||||
switch (SecurityAccessLevel)
|
||||
if (PageState.Control == "Settings")
|
||||
{
|
||||
case SecurityAccessLevel.Anonymous:
|
||||
authorized = true;
|
||||
break;
|
||||
case SecurityAccessLevel.View:
|
||||
authorized = UserSecurity.IsAuthorized(PageState.User, "View", module.Permissions);
|
||||
break;
|
||||
case SecurityAccessLevel.Edit:
|
||||
authorized = UserSecurity.IsAuthorized(PageState.User, "Edit", module.Permissions);
|
||||
break;
|
||||
case SecurityAccessLevel.Admin:
|
||||
authorized = UserSecurity.IsAuthorized(PageState.User, Constants.AdminRole);
|
||||
break;
|
||||
case SecurityAccessLevel.Host:
|
||||
authorized = UserSecurity.IsAuthorized(PageState.User, Constants.HostRole);
|
||||
break;
|
||||
authorized = UserSecurity.IsAuthorized(PageState.User, "Edit", PageState.Page.Permissions);
|
||||
}
|
||||
else
|
||||
{
|
||||
// verify security access level for this module control
|
||||
switch (module.SecurityAccessLevel)
|
||||
{
|
||||
case SecurityAccessLevel.Anonymous:
|
||||
authorized = true;
|
||||
break;
|
||||
case SecurityAccessLevel.View:
|
||||
authorized = UserSecurity.IsAuthorized(PageState.User, "View", module.Permissions);
|
||||
break;
|
||||
case SecurityAccessLevel.Edit:
|
||||
authorized = UserSecurity.IsAuthorized(PageState.User, "Edit", module.Permissions);
|
||||
break;
|
||||
case SecurityAccessLevel.Admin:
|
||||
authorized = UserSecurity.IsAuthorized(PageState.User, Constants.AdminRole);
|
||||
break;
|
||||
case SecurityAccessLevel.Host:
|
||||
authorized = UserSecurity.IsAuthorized(PageState.User, Constants.HostRole);
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (authorized)
|
||||
{
|
||||
if (PageState.Control != "Settings")
|
||||
if (PageState.Control != "Settings" && module.ControlTitle != "")
|
||||
{
|
||||
// get module control title
|
||||
string title = (string)moduleType.GetProperty("Title").GetValue(moduleobject);
|
||||
if (title != "")
|
||||
{
|
||||
module.Title = title;
|
||||
}
|
||||
module.Title = module.ControlTitle;
|
||||
}
|
||||
builder.OpenComponent(0, Type.GetType(Constants.DefaultContainer));
|
||||
builder.AddAttribute(1, "Module", module);
|
||||
|
@ -1,6 +1,7 @@
|
||||
@using System
|
||||
@using Oqtane.Services
|
||||
@using Oqtane.Models
|
||||
@using Oqtane.Modules
|
||||
@using System.Linq
|
||||
@using System.Collections.Generic
|
||||
@using Oqtane.Shared
|
||||
@ -25,10 +26,10 @@
|
||||
|
||||
@code {
|
||||
|
||||
[CascadingParameter]
|
||||
[CascadingParameter]
|
||||
PageState PageState { get; set; }
|
||||
|
||||
[Parameter]
|
||||
[Parameter]
|
||||
public Action<PageState> OnStateChange { get; set; }
|
||||
|
||||
PageState pagestate;
|
||||
@ -58,7 +59,7 @@
|
||||
}
|
||||
|
||||
protected override async Task OnParametersSetAsync()
|
||||
{
|
||||
{
|
||||
if (PageState == null)
|
||||
{
|
||||
// misconfigured api calls should not be processed through the router
|
||||
@ -68,7 +69,7 @@
|
||||
}
|
||||
else
|
||||
{
|
||||
System.Diagnostics.Debug.WriteLine(this.GetType().FullName + ": Error: " + _absoluteUri + " is not mapped to a Controller");
|
||||
System.Diagnostics.Debug.WriteLine(this.GetType().FullName + ": Error: API call to " + _absoluteUri + " is not mapped to a Controller");
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -87,12 +88,14 @@
|
||||
int moduleid = -1;
|
||||
string control = "";
|
||||
bool editmode = false;
|
||||
bool designmode = false;
|
||||
int reload = 0;
|
||||
|
||||
if (PageState != null)
|
||||
{
|
||||
reload = PageState.Reload;
|
||||
editmode = PageState.EditMode;
|
||||
designmode = PageState.DesignMode;
|
||||
}
|
||||
|
||||
if (PageState == null || reload == Constants.ReloadApplication)
|
||||
@ -190,7 +193,8 @@
|
||||
{
|
||||
page = pages.Where(item => item.Path == path).FirstOrDefault();
|
||||
reload = Constants.ReloadPage;
|
||||
editmode = false;
|
||||
editmode = page.EditMode;
|
||||
designmode = false;
|
||||
}
|
||||
|
||||
user = null;
|
||||
@ -242,7 +246,8 @@
|
||||
}
|
||||
pagestate.Modules = modules;
|
||||
pagestate.EditMode = editmode;
|
||||
pagestate.Reload = 0;
|
||||
pagestate.DesignMode = designmode;
|
||||
pagestate.Reload = Constants.ReloadReset;
|
||||
|
||||
OnStateChange?.Invoke(pagestate);
|
||||
}
|
||||
@ -330,6 +335,22 @@
|
||||
}
|
||||
}
|
||||
module.ModuleType = typename.Replace("{Control}", control);
|
||||
|
||||
// get IModuleControl properties
|
||||
typename = module.ModuleType;
|
||||
if (control == "Settings")
|
||||
{
|
||||
typename = Constants.DefaultSettingsControl;
|
||||
}
|
||||
Type moduletype = Type.GetType(typename);
|
||||
if (moduletype != null)
|
||||
{
|
||||
var moduleobject = Activator.CreateInstance(moduletype);
|
||||
module.SecurityAccessLevel = (SecurityAccessLevel)moduletype.GetProperty("SecurityAccessLevel").GetValue(moduleobject, null);
|
||||
module.ControlTitle = (string)moduletype.GetProperty("Title").GetValue(moduleobject);
|
||||
module.Actions = (string)moduletype.GetProperty("Actions").GetValue(moduleobject);
|
||||
module.AdminContainerType = (string)moduletype.GetProperty("ContainerType").GetValue(moduleobject);
|
||||
}
|
||||
}
|
||||
|
||||
// ensure module's pane exists in current page and if not, assign it to the Admin pane
|
||||
|
Reference in New Issue
Block a user