add validation logic to ensure page theme martches site theme
This commit is contained in:
parent
a7c5841e76
commit
6126624631
|
@ -355,7 +355,7 @@
|
|||
// appearance
|
||||
_title = _page.Title;
|
||||
_themetype = _page.ThemeType;
|
||||
if (string.IsNullOrEmpty(_themetype))
|
||||
if (string.IsNullOrEmpty(_themetype) || ThemeService.GetTheme(PageState.Site.Themes, _themetype)?.ThemeName != ThemeService.GetTheme(PageState.Site.Themes, PageState.Site.DefaultThemeType)?.ThemeName)
|
||||
{
|
||||
_themetype = PageState.Site.DefaultThemeType;
|
||||
}
|
||||
|
|
|
@ -24,6 +24,13 @@ namespace Oqtane.Services
|
|||
/// <returns></returns>
|
||||
Task<Theme> GetThemeAsync(int themeId, int siteId);
|
||||
|
||||
/// <summary>
|
||||
/// Returns a theme <see cref="ThemeControl"/>s containing a theme control type
|
||||
/// </summary>
|
||||
/// <param name="themes"></param>
|
||||
/// <returns></returns>
|
||||
Theme GetTheme(List<Theme> themes, string themeType);
|
||||
|
||||
/// <summary>
|
||||
/// Returns a list of <see cref="ThemeControl"/>s from the given themes
|
||||
/// </summary>
|
||||
|
|
|
@ -26,6 +26,11 @@ namespace Oqtane.Services
|
|||
return await GetJsonAsync<Theme>($"{ApiUrl}/{themeId}?siteid={siteId}");
|
||||
}
|
||||
|
||||
public Theme GetTheme(List<Theme> themes, string themeType)
|
||||
{
|
||||
return themes.FirstOrDefault(item => item.Themes.Any(item => item.TypeName == themeType));
|
||||
}
|
||||
|
||||
public List<ThemeControl> GetThemeControls(List<Theme> themes)
|
||||
{
|
||||
return themes.SelectMany(item => item.Themes).OrderBy(item => item.Name).ToList();
|
||||
|
@ -33,13 +38,13 @@ namespace Oqtane.Services
|
|||
|
||||
public List<ThemeControl> GetThemeControls(List<Theme> themes, string themeType)
|
||||
{
|
||||
return themes.First(item => item.Themes.Any(item => item.TypeName == themeType)).Themes.OrderBy(item => item.Name).ToList();
|
||||
return GetTheme(themes, themeType)?.Themes.OrderBy(item => item.Name).ToList();
|
||||
}
|
||||
|
||||
|
||||
public List<ThemeControl> GetContainerControls(List<Theme> themes, string themeType)
|
||||
{
|
||||
return themes.First(item => item.Themes.Any(item => item.TypeName == themeType)).Containers.OrderBy(item => item.Name).ToList();
|
||||
return GetTheme(themes, themeType)?.Containers.OrderBy(item => item.Name).ToList();
|
||||
}
|
||||
|
||||
public async Task UpdateThemeAsync(Theme theme)
|
||||
|
|
Loading…
Reference in New Issue
Block a user