diff --git a/Oqtane.Client/Modules/Admin/Pages/Add.razor b/Oqtane.Client/Modules/Admin/Pages/Add.razor index 23253039..5832f45d 100644 --- a/Oqtane.Client/Modules/Admin/Pages/Add.razor +++ b/Oqtane.Client/Modules/Admin/Pages/Add.razor @@ -11,173 +11,169 @@
- @if (PageState.Site.Themes != null) - { +
+
+ +
+ +
+
+ @if (UserSecurity.IsAuthorized(PageState.User, RoleNames.Admin)) + { +
+ +
+ +
+
+
+ +
+ + @if (_children != null && _children.Count > 0 && (_insert == "<" || _insert == ">")) + { + + } +
+
+ } + else + { +
+ +
+ +
+
+
+ +
+ +
+
+ } +
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
- +
- +
- @if (UserSecurity.IsAuthorized(PageState.User, RoleNames.Admin)) - { -
- -
- -
-
-
- -
- - @if (_children != null && _children.Count > 0 && (_insert == "<" || _insert == ">")) +
+ +
+ - - @foreach (Page page in _children) - { - - } - + } -
-
- } - else - { -
- -
- -
-
-
- -
- -
-
- } -
- -
-
- +
- -
-
-
- -
- -
-
-
- -
- -
-
-
- -
- -
-
-
- -
- + @foreach (var container in _containers) + { + + }
- -
-
-
- -
- -
-
-
- -
- -
-
-
- -
- -
+
+
+
+
+ +
+
-
-
-
-
- -
- -
-
-
- -
- -
+
+ +
+
-
- } +
+
@@ -249,8 +245,8 @@ // if admin or user has edit access to parent page if (UserSecurity.IsAuthorized(PageState.User, RoleNames.Admin) || (_parent != null && UserSecurity.IsAuthorized(PageState.User, PermissionNames.Edit, _parent.PermissionList))) { - _themes = ThemeService.GetThemeControls(PageState.Site.Themes); _themetype = PageState.Site.DefaultThemeType; + _themes = ThemeService.GetThemeControls(PageState.Site.Themes, _themetype); _containers = ThemeService.GetContainerControls(PageState.Site.Themes, _themetype); _containertype = PageState.Site.DefaultContainerType; _children = PageState.Pages.Where(item => item.ParentId == null).ToList(); @@ -305,23 +301,6 @@ } } - private async void ThemeChanged(ChangeEventArgs e) - { - try - { - _themetype = (string)e.Value; - _containers = ThemeService.GetContainerControls(PageState.Site.Themes, _themetype); - _containertype = "-"; - ThemeSettings(); - StateHasChanged(); - } - catch (Exception ex) - { - await logger.LogError(ex, "Error Loading Pane Layouts For Theme {ThemeType} {Error}", _themetype, ex.Message); - AddModuleMessage(Localizer["Error.Pane.Load"], MessageType.Error); - } - } - private void ThemeSettings() { _themeSettingsType = null; @@ -351,7 +330,7 @@ Page page = null; try { - if (!string.IsNullOrEmpty(_themetype) && _containertype != "-") + if (!string.IsNullOrEmpty(_themetype) && !string.IsNullOrEmpty(_containertype)) { page = new Page(); page.SiteId = PageState.Page.SiteId; @@ -430,12 +409,12 @@ // appearance page.Title = _title; page.Icon = (_icon == null ? string.Empty : _icon); - page.ThemeType = (_themetype != "-") ? _themetype : string.Empty; + page.ThemeType = _themetype; if (!string.IsNullOrEmpty(page.ThemeType) && page.ThemeType == PageState.Site.DefaultThemeType) { page.ThemeType = string.Empty; } - page.DefaultContainerType = (_containertype != "-") ? _containertype : string.Empty; + page.DefaultContainerType = _containertype; if (!string.IsNullOrEmpty(page.DefaultContainerType) && page.DefaultContainerType == PageState.Site.DefaultContainerType) { page.DefaultContainerType = string.Empty; diff --git a/Oqtane.Client/Modules/Admin/Pages/Edit.razor b/Oqtane.Client/Modules/Admin/Pages/Edit.razor index 4d9c791c..7ff54a15 100644 --- a/Oqtane.Client/Modules/Admin/Pages/Edit.razor +++ b/Oqtane.Client/Modules/Admin/Pages/Edit.razor @@ -15,212 +15,202 @@ { - @if (PageState.Site.Themes != null) - { +
+
+ +
+ +
+
+ @if (UserSecurity.IsAuthorized(PageState.User, RoleNames.Admin)) + { +
+ +
+ +
+
+
+ +
+ + @if (_children != null && _children.Count > 0 && (_insert == "<" || _insert == ">")) + { + + } +
+
+ } + else + { +
+ +
+ +
+
+
+ +
+ +
+
+ } +
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+
- +
- +
- @if (UserSecurity.IsAuthorized(PageState.User, RoleNames.Admin)) - { -
- -
- -
-
-
- -
- - @if (_children != null && _children.Count > 0 && (_insert == "<" || _insert == ">")) +
+ +
+ - - @foreach (Page page in _children) - { - - } - + } -
-
- } - else - { -
- -
- -
-
-
- -
- -
-
- } -
- -
-
- +
- -
-
-
- -
- -
-
-
- -
- -
-
-
- -
- -
-
-
- -
- + @foreach (var container in _containers) + { + + }
-
-
-
- -
- -
-
-
- -
- -
-
-
- -
- -
+
+
+
+
+ +
+
-
-
-
-
- -
- -
-
-
- -
- -
+
+ +
+
-
-
-
- - } +
+
+
+
+
- @if (_permissions != null) - { -
-
- -
+
+
+
- } +
- @if (_pageModules != null) - { - -
-   -   - @Localizer["ModuleTitle"] - @Localizer["ModuleDefinition"] -
- - - - @context.Title - @context.ModuleDefinition?.Name - -
- } + +
+   +   + @Localizer["ModuleTitle"] + @Localizer["ModuleDefinition"] +
+ + + + @context.Title + @context.ModuleDefinition?.Name + +
@if (_themeSettingsType != null) { @@ -245,7 +235,7 @@
- @foreach (var theme in _themes) { @@ -257,7 +247,6 @@
- @foreach (var theme in _themes) { @@ -90,7 +89,6 @@
- @foreach (var container in _containers) { @@ -356,9 +353,9 @@ private FileManager _logofilemanager; private int _faviconfileid = -1; private FileManager _faviconfilemanager; - private string _themetype = "-"; - private string _containertype = "-"; - private string _admincontainertype = "-"; + private string _themetype = ""; + private string _containertype = ""; + private string _admincontainertype = ""; private string _headcontent = string.Empty; private string _bodycontent = string.Empty; private string _smtphost = string.Empty; @@ -499,15 +496,8 @@ try { _themetype = (string)e.Value; - if (_themetype != "-") - { - _containers = ThemeService.GetContainerControls(PageState.Site.Themes, _themetype); - } - else - { - _containers = new List(); - } - _containertype = "-"; + _containers = ThemeService.GetContainerControls(PageState.Site.Themes, _themetype); + _containertype = _containers.First().TypeName; _admincontainertype = Constants.DefaultAdminContainer; StateHasChanged(); } diff --git a/Oqtane.Client/Services/Interfaces/IThemeService.cs b/Oqtane.Client/Services/Interfaces/IThemeService.cs index 8c5ac457..aafff7b2 100644 --- a/Oqtane.Client/Services/Interfaces/IThemeService.cs +++ b/Oqtane.Client/Services/Interfaces/IThemeService.cs @@ -32,20 +32,19 @@ namespace Oqtane.Services List GetThemeControls(List themes); /// - /// Returns a list of layouts () from the given themes with a matching theme name + /// Returns a list of s from the given themes with a matching theme type /// /// - /// /// - List GetLayoutControls(List themes, string themeName); + List GetThemeControls(List themes, string themeType); /// - /// Returns a list of containers () from the given themes with a matching theme name + /// Returns a list of containers () from the given themes with a matching theme type /// /// /// /// - List GetContainerControls(List themes, string themeName); + List GetContainerControls(List themes, string themeType); /// /// Updates a existing theem @@ -73,5 +72,14 @@ namespace Oqtane.Services /// /// Task> GetThemeTemplatesAsync(); + + + /// + /// Returns a list of layouts () from the given themes with a matching theme name + /// + /// + /// + /// + List GetLayoutControls(List themes, string themeName); } } diff --git a/Oqtane.Client/Services/ThemeService.cs b/Oqtane.Client/Services/ThemeService.cs index 6bf99a34..b86b63e1 100644 --- a/Oqtane.Client/Services/ThemeService.cs +++ b/Oqtane.Client/Services/ThemeService.cs @@ -5,6 +5,7 @@ using System.Threading.Tasks; using Oqtane.Documentation; using Oqtane.Models; using Oqtane.Shared; +using Oqtane.UI; namespace Oqtane.Services { @@ -30,16 +31,15 @@ namespace Oqtane.Services return themes.SelectMany(item => item.Themes).OrderBy(item => item.Name).ToList(); } - //[Obsolete("This method is deprecated.", false)] - public List GetLayoutControls(List themes, string themeName) + public List GetThemeControls(List themes, string themeType) { - return null; + return themes.First(item => item.Themes.Any(item => item.TypeName == themeType)).Themes.OrderBy(item => item.Name).ToList(); } - public List GetContainerControls(List themes, string themeName) + + public List GetContainerControls(List themes, string themeType) { - return themes.Where(item => Utilities.GetTypeName(themeName).StartsWith(Utilities.GetTypeName(item.ThemeName))) - .SelectMany(item => item.Containers).OrderBy(item => item.Name).ToList(); + return themes.First(item => item.Themes.Any(item => item.TypeName == themeType)).Containers.OrderBy(item => item.Name).ToList(); } public async Task UpdateThemeAsync(Theme theme) @@ -62,5 +62,11 @@ namespace Oqtane.Services List