Refactoring (#314)
* Refactoring * Refactoring * Check for a valid email. * Fixed missing character. * Moved logic to the Utilities class. * Rename template .sql file * Modified null and empty string check. * Check for a valid email. * Fixed missing character. * Moved logic to the Utilities class. * Added Favicon support, Progressive Web App support, page title and url support, and private/public user registration options * Refactoring * Refactoring * Check for a valid email. * Moved logic to the Utilities class. Co-authored-by: Aubrey <aubrey.b@treskcow.tech> Co-authored-by: MIchael Atwood <matwood@dragonmastery.com> Co-authored-by: Shaun Walker <shaun.walker@siliqon.com>
This commit is contained in:
@ -1,28 +1,29 @@
|
||||
@namespace Oqtane.Themes.Controls
|
||||
@inherits ThemeControlBase
|
||||
|
||||
@if (breadcrumbs != "")
|
||||
@if (breadcrumbs != string.Empty)
|
||||
{
|
||||
@((MarkupString)breadcrumbs)
|
||||
}
|
||||
|
||||
@code {
|
||||
string breadcrumbs = "";
|
||||
string breadcrumbs = string.Empty;
|
||||
|
||||
protected override void OnParametersSet()
|
||||
{
|
||||
breadcrumbs = "";
|
||||
int? pageid = PageState.Page.PageId;
|
||||
breadcrumbs = string.Empty;
|
||||
var pageid = PageState.Page.PageId;
|
||||
for (int i = PageState.Pages.Count - 1; i >= 0; i--)
|
||||
{
|
||||
Page p = PageState.Pages[i];
|
||||
var p = PageState.Pages[i];
|
||||
if (p.PageId == pageid)
|
||||
{
|
||||
breadcrumbs = "<li class=\"breadcrumb-item" + ((p.PageId == PageState.Page.PageId) ? " active" : "") +
|
||||
breadcrumbs = "<li class=\"breadcrumb-item" + ((p.PageId == PageState.Page.PageId) ? " active" : string.Empty) +
|
||||
"\"><a href=\"" + NavigateUrl(p.Path) + "\">" + p.Name + "</a></li>" + breadcrumbs;
|
||||
pageid = p.ParentId;
|
||||
}
|
||||
}
|
||||
|
||||
if (breadcrumbs != "")
|
||||
{
|
||||
breadcrumbs = "<ol class=\"breadcrumb\">" + breadcrumbs + "</ol>";
|
||||
|
@ -196,6 +196,22 @@
|
||||
}
|
||||
|
||||
@code {
|
||||
private bool _deleteConfirmation = false;
|
||||
private string _moduleType = "new";
|
||||
private List<string> _categories = new List<string>();
|
||||
private List<ModuleDefinition> _allModuleDefinitions;
|
||||
private List<ModuleDefinition> _moduleDefinitions;
|
||||
private List<Page> _pages = new List<Page>();
|
||||
private string _pageId = "-";
|
||||
private string _moduleId = "-";
|
||||
private List<Module> _modules = new List<Module>();
|
||||
private Dictionary<string, string> _containers = new Dictionary<string, string>();
|
||||
private string _moduleDefinitionName = "-";
|
||||
private string _pane = "";
|
||||
private string _title = "";
|
||||
private string _containerType = "";
|
||||
private string _display = "display: none;";
|
||||
private string _message = "";
|
||||
|
||||
[Parameter]
|
||||
public string ButtonClass { get; set; }
|
||||
@ -209,37 +225,23 @@
|
||||
[Parameter]
|
||||
public string BodyClass { get; set; }
|
||||
|
||||
bool _deleteConfirmation = false;
|
||||
string _moduleType = "new";
|
||||
List<string> _categories = new List<string>();
|
||||
List<ModuleDefinition> _allModuleDefinitions;
|
||||
List<ModuleDefinition> _moduleDefinitions;
|
||||
List<Page> _pages = new List<Page>();
|
||||
string _pageId = "-";
|
||||
string _moduleId = "-";
|
||||
List<Module> _modules = new List<Module>();
|
||||
Dictionary<string, string> _containers = new Dictionary<string, string>();
|
||||
string _moduleDefinitionName = "-";
|
||||
string _pane = "";
|
||||
string _title = "";
|
||||
string _containerType = "";
|
||||
string _display = "display: none;";
|
||||
string _message = "";
|
||||
|
||||
protected override async Task OnParametersSetAsync()
|
||||
{
|
||||
if (string.IsNullOrEmpty(ButtonClass))
|
||||
{
|
||||
ButtonClass = "btn-outline-primary";
|
||||
}
|
||||
|
||||
if (string.IsNullOrEmpty(CardClass))
|
||||
{
|
||||
CardClass = "card bg-secondary mb-3";
|
||||
}
|
||||
|
||||
if (string.IsNullOrEmpty(HeaderClass))
|
||||
{
|
||||
HeaderClass = "card-header text-white";
|
||||
}
|
||||
|
||||
if (string.IsNullOrEmpty(BodyClass))
|
||||
{
|
||||
BodyClass = "card-body";
|
||||
@ -250,6 +252,7 @@
|
||||
_pages?.Clear();
|
||||
|
||||
_allModuleDefinitions = await ModuleDefinitionService.GetModuleDefinitionsAsync(PageState.Site.SiteId);
|
||||
|
||||
foreach (ModuleDefinition moduledefinition in _allModuleDefinitions)
|
||||
{
|
||||
if (moduledefinition.Categories != "")
|
||||
@ -263,7 +266,9 @@
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
_moduleDefinitions = _allModuleDefinitions.Where(item => item.Categories == "").ToList();
|
||||
|
||||
foreach (Page p in PageState.Pages)
|
||||
{
|
||||
if (UserSecurity.IsAuthorized(PageState.User,PermissionNames.View, p.Permissions))
|
||||
@ -271,9 +276,10 @@
|
||||
_pages.Add(p);
|
||||
}
|
||||
}
|
||||
|
||||
var panes = PageState.Page.Panes.Split(new[] {';'}, StringSplitOptions.RemoveEmptyEntries);
|
||||
_pane = panes.Count() == 1 ? panes.SingleOrDefault() : "";
|
||||
List<Theme> themes = await ThemeService.GetThemesAsync();
|
||||
var themes = await ThemeService.GetThemesAsync();
|
||||
_containers = ThemeService.GetContainerTypes(themes);
|
||||
_containerType = PageState.Site.DefaultContainerType;
|
||||
}
|
||||
@ -281,7 +287,7 @@
|
||||
|
||||
private void CategoryChanged(ChangeEventArgs e)
|
||||
{
|
||||
string category = (string) e.Value;
|
||||
var category = (string) e.Value;
|
||||
if (category == "-")
|
||||
{
|
||||
_moduleDefinitions = _allModuleDefinitions.Where(item => item.Categories == "").ToList();
|
||||
@ -290,6 +296,7 @@
|
||||
{
|
||||
_moduleDefinitions = _allModuleDefinitions.Where(item => item.Categories.Contains(category)).ToList();
|
||||
}
|
||||
|
||||
_moduleDefinitionName = "-";
|
||||
StateHasChanged();
|
||||
}
|
||||
@ -298,6 +305,7 @@
|
||||
{
|
||||
_pageId = (string) e.Value;
|
||||
_modules?.Clear();
|
||||
|
||||
if (_pageId != "-")
|
||||
{
|
||||
foreach (Module module in PageState.Modules.Where(item => item.PageId == int.Parse(_pageId) && !item.IsDeleted))
|
||||
@ -308,6 +316,7 @@
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
_moduleId = "-";
|
||||
StateHasChanged();
|
||||
}
|
||||
@ -346,6 +355,7 @@
|
||||
pageModule.Title = _modules.FirstOrDefault(item => item.ModuleId == int.Parse(_moduleId))?.Title;
|
||||
}
|
||||
}
|
||||
|
||||
pageModule.Pane = _pane;
|
||||
pageModule.Order = int.MaxValue;
|
||||
pageModule.ContainerType = _containerType;
|
||||
@ -426,18 +436,21 @@
|
||||
switch (location)
|
||||
{
|
||||
case "Admin":
|
||||
// get admin dashboard moduleid
|
||||
// get admin dashboard moduleid
|
||||
module = PageState.Modules.FirstOrDefault(item => item.ModuleDefinitionName == Constants.AdminDashboardModule);
|
||||
|
||||
if (module != null)
|
||||
{
|
||||
NavigationManager.NavigateTo(EditUrl(PageState.Page.Path, module.ModuleId, "Index", ""));
|
||||
}
|
||||
|
||||
break;
|
||||
case "Add":
|
||||
case "Edit":
|
||||
string url = "";
|
||||
// get page management moduleid
|
||||
// get page management moduleid
|
||||
module = PageState.Modules.FirstOrDefault(item => item.ModuleDefinitionName == Constants.PageManagementModule);
|
||||
|
||||
if (module != null)
|
||||
{
|
||||
switch (location)
|
||||
@ -450,10 +463,12 @@
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (url != "")
|
||||
{
|
||||
NavigationManager.NavigateTo(url);
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -467,7 +482,8 @@
|
||||
private async Task DeletePage()
|
||||
{
|
||||
ConfirmDelete();
|
||||
Page page = PageState.Page;
|
||||
|
||||
var page = PageState.Page;
|
||||
try
|
||||
{
|
||||
if (page.UserId == null)
|
||||
|
@ -21,11 +21,12 @@
|
||||
@code {
|
||||
private void LoginUser()
|
||||
{
|
||||
string returnurl = PageState.Alias.Path;
|
||||
var returnurl = PageState.Alias.Path;
|
||||
if (PageState.Page.Path != "/")
|
||||
{
|
||||
returnurl += "/" + PageState.Page.Path;
|
||||
}
|
||||
|
||||
NavigationManager.NavigateTo(NavigateUrl("login", "returnurl=" + returnurl));
|
||||
}
|
||||
|
||||
|
@ -11,7 +11,7 @@
|
||||
{
|
||||
if (PageState.Site.LogoFileId != null)
|
||||
{
|
||||
Uri uri = new Uri(NavigationManager.Uri);
|
||||
var uri = new Uri(NavigationManager.Uri);
|
||||
logo = "<a href=\"" + uri.Scheme + "://" + uri.Authority + "\"><img src=\"" + ContentUrl(PageState.Site.LogoFileId.Value) + "\" alt=\"" + PageState.Site.Name + "\"/></a>";
|
||||
}
|
||||
}
|
||||
|
@ -1,7 +1,7 @@
|
||||
@namespace Oqtane.Themes.Controls
|
||||
@inherits ThemeControlBase
|
||||
|
||||
@if (menu != "")
|
||||
@if (menu != string.Empty)
|
||||
{
|
||||
<div class="app-menu">
|
||||
@((MarkupString)menu)
|
||||
@ -9,11 +9,11 @@
|
||||
}
|
||||
|
||||
@code {
|
||||
private string menu = string.Empty;
|
||||
|
||||
[Parameter]
|
||||
public string Orientation { get; set; }
|
||||
|
||||
string menu = "";
|
||||
|
||||
protected override void OnParametersSet()
|
||||
{
|
||||
switch (Orientation)
|
||||
@ -29,8 +29,8 @@
|
||||
|
||||
private void CreateVerticalMenu()
|
||||
{
|
||||
int level = -1;
|
||||
int securitylevel = int.MaxValue;
|
||||
var level = -1;
|
||||
var securitylevel = int.MaxValue;
|
||||
|
||||
menu = "<ul class=\"nav flex-column\">\n";
|
||||
|
||||
@ -47,21 +47,25 @@
|
||||
}
|
||||
else
|
||||
{
|
||||
string target = "";
|
||||
string target = String.Empty;
|
||||
if (p.Url.StartsWith("http"))
|
||||
{
|
||||
target = " target=\"_new\"";
|
||||
}
|
||||
menu += "<a href=\"" + p.Url + "\" class=\"nav-link\" style=\"padding-left: " + ((p.Level + 1) * 15).ToString() + "px !important;\"" + target + ">";
|
||||
}
|
||||
menu += "<a href=\string.Empty + NavigateUrl(p.Path) + "\" class=\"nav-link\" style=\"padding-left: " + ((p.Level + 1) * 15).ToString() + "px !important;\">";
|
||||
|
||||
if (p.HasChildren)
|
||||
{
|
||||
menu += "<i class=\"oi oi-chevron-right\"></i>";
|
||||
}
|
||||
if (p.Icon != "")
|
||||
|
||||
if (p.Icon != string.Empty)
|
||||
{
|
||||
menu += "<span class=\"oi oi-" + p.Icon + "\" aria-hidden=\"true\"></span>";
|
||||
}
|
||||
|
||||
menu += p.Name;
|
||||
menu += "</a>\n";
|
||||
menu += "</li>\n";
|
||||
@ -76,17 +80,19 @@
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
menu += "</ul>";
|
||||
}
|
||||
|
||||
private void CreateHorizontalMenu()
|
||||
{
|
||||
string url = "";
|
||||
string target = "";
|
||||
var url = String.Empty;
|
||||
var target = String.Empty;
|
||||
|
||||
menu = "<button class=\"navbar-toggler\" type=\"button\" data-toggle=\"collapse\" data-target=\"#Menu\" aria-controls=\"Menu\" aria-expanded=\"false\" aria-label=\"Toggle navigation\"><span class=\"navbar-toggler-icon\"></span></button>";
|
||||
menu += "<div class=\"collapse navbar-collapse\" id=\"Menu\">";
|
||||
menu += "<ul class=\"navbar-nav mr-auto\">";
|
||||
|
||||
foreach (Page p in PageState.Pages.Where(item => item.IsNavigation && !item.IsDeleted))
|
||||
{
|
||||
if (UserSecurity.IsAuthorized(PageState.User,PermissionNames.View, p.Permissions) && p.ParentId == PageState.Page.ParentId && p.Level == PageState.Page.Level)
|
||||
@ -94,7 +100,7 @@
|
||||
if (string.IsNullOrEmpty(p.Url))
|
||||
{
|
||||
url = NavigateUrl(p.Path);
|
||||
target = "";
|
||||
target = String.Empty;
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -108,19 +114,20 @@
|
||||
if (p.PageId == PageState.Page.PageId)
|
||||
{
|
||||
menu += "<li class=\"nav-item active\">" +
|
||||
"<a class=\"nav-link\" href=\"" + url + "\"" + target + ">" +
|
||||
((p.Icon != "") ? "<span class=\"oi oi-" + p.Icon + "\" aria-hidden=\"true\"></span> " : "") +
|
||||
"<a class=\"nav-link\" href=\string.Empty + NavigateUrl(p.Path) + "\">" +
|
||||
((p.Icon != string.Empty) ? "<span class=\"oi oi-" + p.Icon + "\" aria-hidden=\"true\"></span> " : string.Empty) +
|
||||
p.Name + " <span class=\"sr-only\">(current)</span></a></li>";
|
||||
}
|
||||
else
|
||||
{
|
||||
menu += "<li class=\"nav-item\">" +
|
||||
"<a class=\"nav-link\" href=\"" + url + "\"" + target + ">" +
|
||||
((p.Icon != "") ? "<span class=\"oi oi-" + p.Icon + "\" aria-hidden=\"true\"></span> " : "") +
|
||||
"<a class=\"nav-link\" href=\string.Empty + NavigateUrl(p.Path) + "\">" +
|
||||
((p.Icon != string.Empty) ? "<span class=\"oi oi-" + p.Icon + "\" aria-hidden=\"true\"></span> " : string.Empty) +
|
||||
p.Name + "</a></li>";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
menu += "</ul>";
|
||||
menu += "</div>";
|
||||
}
|
||||
|
@ -23,7 +23,7 @@
|
||||
}
|
||||
|
||||
@code {
|
||||
List<ActionViewModel> actions;
|
||||
private List<ActionViewModel> actions;
|
||||
|
||||
protected override void OnParametersSet()
|
||||
{
|
||||
@ -31,29 +31,36 @@
|
||||
{
|
||||
actions = new List<ActionViewModel>();
|
||||
actions.Add(new ActionViewModel { Action = "settings", Name = "Manage Settings" });
|
||||
|
||||
if (ModuleState.ModuleDefinition != null && ModuleState.ModuleDefinition.ServerAssemblyName != "")
|
||||
{
|
||||
actions.Add(new ActionViewModel { Action = "import", Name = "Import Content" });
|
||||
actions.Add(new ActionViewModel { Action = "export", Name = "Export Content" });
|
||||
}
|
||||
|
||||
actions.Add(new ActionViewModel { Action = "delete", Name = "Delete Module" });
|
||||
actions.Add(new ActionViewModel { Action = "", Name = "" });
|
||||
|
||||
if (ModuleState.PaneModuleIndex > 0)
|
||||
{
|
||||
actions.Add(new ActionViewModel { Action = "<<", Name = "Move To Top" });
|
||||
}
|
||||
|
||||
if (ModuleState.PaneModuleIndex > 0)
|
||||
{
|
||||
actions.Add(new ActionViewModel { Action = "<", Name = "Move Up" });
|
||||
}
|
||||
|
||||
if (ModuleState.PaneModuleIndex < (ModuleState.PaneModuleCount - 1))
|
||||
{
|
||||
actions.Add(new ActionViewModel { Action = ">", Name = "Move Down" });
|
||||
}
|
||||
|
||||
if (ModuleState.PaneModuleIndex < (ModuleState.PaneModuleCount - 1))
|
||||
{
|
||||
actions.Add(new ActionViewModel { Action = ">>", Name = "Move To Bottom" });
|
||||
}
|
||||
|
||||
foreach (string pane in PageState.Page.Panes.Split(new[] { ';' }, StringSplitOptions.RemoveEmptyEntries))
|
||||
{
|
||||
if (pane != ModuleState.Pane)
|
||||
|
@ -4,7 +4,7 @@
|
||||
@((MarkupString)title)
|
||||
|
||||
@code {
|
||||
string title = "";
|
||||
private title = "";
|
||||
|
||||
protected override Task OnParametersSetAsync()
|
||||
{
|
||||
|
Reference in New Issue
Block a user