@@ -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 == ">"))
+
+
+
+
-
- }
- else
- {
-
-
-
- ParentChanged(e))" disabled>
-
- @if (_parent != null)
- {
-
- }
-
-
-
-
-
-
-
-
-
-
-
- }
-
-
-
-
-
-
-
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+ @foreach (var container in _containers)
+ {
+
+ }
-
-
-
-
-
-
- ThemeChanged(e))" required>
- @foreach (var theme in _themes)
- {
-
- }
-
-
-
-
-
-
-
-
- @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 @@
-
ThemeChanged(e))" required>
+
@foreach (var theme in _themes)
{
@@ -257,7 +247,6 @@
-
@foreach (var container in _containers)
{
@@ -329,8 +318,6 @@
try
{
_children = PageState.Pages.Where(item => item.ParentId == null).ToList();
- _themes = ThemeService.GetThemeControls(PageState.Site.Themes);
-
_pageId = Int32.Parse(PageState.QueryString["id"]);
_page = await PageService.GetPageAsync(_pageId);
@@ -367,11 +354,12 @@
// appearance
_title = _page.Title;
- if (string.IsNullOrEmpty(_page.ThemeType))
- {
- _page.ThemeType = PageState.Site.DefaultThemeType;
- }
_themetype = _page.ThemeType;
+ if (string.IsNullOrEmpty(_themetype))
+ {
+ _themetype = PageState.Site.DefaultThemeType;
+ }
+ _themes = ThemeService.GetThemeControls(PageState.Site.Themes, _themetype);
_containers = ThemeService.GetContainerControls(PageState.Site.Themes, _themetype);
_containertype = _page.DefaultContainerType;
if (string.IsNullOrEmpty(_containertype))
@@ -475,28 +463,6 @@
}
}
- private async void ThemeChanged(ChangeEventArgs e)
- {
- try
- {
- _themetype = (string)e.Value;
- var oldTheme = PageState.Site.Themes.FirstOrDefault(item => item.Themes.Any(themecontrol => themecontrol.TypeName.Equals(_page.ThemeType)));
- var newTheme = PageState.Site.Themes.FirstOrDefault(item => item.Themes.Any(themecontrol => themecontrol.TypeName.Equals(_themetype)));
- if (oldTheme.ThemeName != newTheme.ThemeName)
- {
- _containers = ThemeService.GetContainerControls(PageState.Site.Themes, _themetype);
- _containertype = _containers.First().TypeName;
- 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;
@@ -600,17 +566,17 @@
_page.IsNavigation = (_isnavigation == null || Boolean.Parse(_isnavigation));
_page.IsClickable = (_isclickable == null ? true : Boolean.Parse(_isclickable));
_page.Url = _url;
+ _page.Icon = _icon ?? string.Empty;
_page.IsPersonalizable = (_ispersonalizable != null && Boolean.Parse(_ispersonalizable));
// appearance
_page.Title = _title;
- _page.Icon = _icon ?? string.Empty;
- _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/Site/Index.razor b/Oqtane.Client/Modules/Admin/Site/Index.razor
index 213812ad..49579b57 100644
--- a/Oqtane.Client/Modules/Admin/Site/Index.razor
+++ b/Oqtane.Client/Modules/Admin/Site/Index.razor
@@ -78,7 +78,6 @@
ThemeChanged(e))" required>
-
@foreach (var theme in _themes)
{
@@ -90,7 +89,6 @@
-
@foreach (var container in _containers)
{
@@ -102,7 +100,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 templates = await GetJsonAsync>($"{ApiUrl}/templates");
return templates;
}
+
+ //[Obsolete("This method is deprecated.", false)]
+ public List GetLayoutControls(List themes, string themeName)
+ {
+ return null;
+ }
}
}