Edit mode improvements

This commit is contained in:
Shaun Walker
2019-09-05 13:44:27 -04:00
parent 65cb295e05
commit 22420f2b43
18 changed files with 179 additions and 82 deletions

View File

@ -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