added DefaultAction property to IModule (#765)

This commit is contained in:
Shaun Walker 2020-10-03 15:50:15 -04:00
parent 26c40fb367
commit 6a7be12758
4 changed files with 21 additions and 14 deletions

View File

@ -112,8 +112,8 @@ else
Module module = PageState.Modules.FirstOrDefault(item => item.ModuleId == PageState.ModuleId); Module module = PageState.Modules.FirstOrDefault(item => item.ModuleId == PageState.ModuleId);
if (module != null && module.Pane.ToLower() == Name.ToLower() && !module.IsDeleted) if (module != null && module.Pane.ToLower() == Name.ToLower() && !module.IsDeleted)
{ {
// check if user is authorized to view module // check if user is authorized to view module
if (UserSecurity.IsAuthorized(PageState.User, PermissionNames.View, module.Permissions)) if (UserSecurity.IsAuthorized(PageState.User, PermissionNames.View, module.Permissions))
{ {
CreateComponent(builder, module); CreateComponent(builder, module);
} }
@ -123,8 +123,8 @@ else
{ {
foreach (Module module in PageState.Modules.Where(item => item.PageId == PageState.Page.PageId && item.Pane.ToLower() == Name.ToLower() && !item.IsDeleted).OrderBy(x => x.Order).ToArray()) foreach (Module module in PageState.Modules.Where(item => item.PageId == PageState.Page.PageId && item.Pane.ToLower() == Name.ToLower() && !item.IsDeleted).OrderBy(x => x.Order).ToArray())
{ {
// check if user is authorized to view module // check if user is authorized to view module
if (UserSecurity.IsAuthorized(PageState.User, PermissionNames.View, module.Permissions)) if (UserSecurity.IsAuthorized(PageState.User, PermissionNames.View, module.Permissions))
{ {
CreateComponent(builder, module); CreateComponent(builder, module);
} }

View File

@ -202,21 +202,15 @@
{ {
modIdPos = i + 1; modIdPos = i + 1;
actionPos = modIdPos + 1; actionPos = modIdPos + 1;
// Route to index page if no action is specifed if (actionPos <= segments.Length - 1)
if (actionPos > segments.Length - 1)
{
action = Constants.DefaultAction;
}
else
{ {
action = segments[actionPos]; action = segments[actionPos];
} }
} }
} }
// check if path has moduleid and action specification ie. pagename/moduleid/action/ // check if path has moduleid and action specification ie. pagename/*/moduleid/action/
if (modIdPos > 0) if (modIdPos > 0)
{ {
int.TryParse(segments[modIdPos], out result); int.TryParse(segments[modIdPos], out result);
@ -460,7 +454,13 @@
typename = Constants.ErrorModule; typename = Constants.ErrorModule;
} }
// check if the module defines custom routes*@ // handle default action
if (action == Constants.DefaultAction && !string.IsNullOrEmpty(module.ModuleDefinition.DefaultAction))
{
action = module.ModuleDefinition.DefaultAction;
}
// check if the module defines custom action routes
if (module.ModuleDefinition.ControlTypeRoutes != "") if (module.ModuleDefinition.ControlTypeRoutes != "")
{ {
foreach (string route in module.ModuleDefinition.ControlTypeRoutes.Split(new[] { ';' }, StringSplitOptions.RemoveEmptyEntries)) foreach (string route in module.ModuleDefinition.ControlTypeRoutes.Split(new[] { ';' }, StringSplitOptions.RemoveEmptyEntries))

View File

@ -1,8 +1,8 @@
{ {
"Runtime": "Server",
"ConnectionStrings": { "ConnectionStrings": {
"DefaultConnection": "" "DefaultConnection": ""
}, },
"Runtime": "Server",
"Installation": { "Installation": {
"DefaultAlias": "", "DefaultAlias": "",
"HostPassword": "", "HostPassword": "",
@ -11,5 +11,9 @@
"DefaultTheme": "", "DefaultTheme": "",
"DefaultLayout": "", "DefaultLayout": "",
"DefaultContainer": "" "DefaultContainer": ""
},
"Localization": {
"DefaultCulture": "",
"SupportedCultures": []
} }
} }

View File

@ -20,6 +20,7 @@ namespace Oqtane.Models
ServerManagerType = ""; ServerManagerType = "";
ControlTypeRoutes = ""; ControlTypeRoutes = "";
ReleaseVersions = ""; ReleaseVersions = "";
DefaultAction = "";
Runtimes = ""; Runtimes = "";
Template = ""; Template = "";
} }
@ -57,6 +58,8 @@ namespace Oqtane.Models
public string ControlTypeRoutes { get; set; } public string ControlTypeRoutes { get; set; }
[NotMapped] [NotMapped]
public string ReleaseVersions { get; set; } public string ReleaseVersions { get; set; }
[NotMapped]
public string DefaultAction { get; set; }
// internal properties // internal properties
[NotMapped] [NotMapped]