restrict container selection to the current theme, hide layout selection if theme does not support layouts, make behavior consistent for all theme/layout/container selection

This commit is contained in:
Shaun Walker 2020-05-31 22:53:11 -04:00
parent be4813d9c0
commit 7d21cfefc1
9 changed files with 160 additions and 125 deletions

View File

@ -105,7 +105,7 @@
protected override async Task OnInitializedAsync() protected override async Task OnInitializedAsync()
{ {
_title = ModuleState.Title; _title = ModuleState.Title;
_containers = ThemeService.GetContainerTypes(await ThemeService.GetThemesAsync()); _containers = ThemeService.GetContainerTypes(await ThemeService.GetThemesAsync(), PageState.Page.ThemeType);
_containerType = ModuleState.ContainerType; _containerType = ModuleState.ContainerType;
if (!string.IsNullOrEmpty(PageState.Page.DefaultContainerType) && _containerType == PageState.Page.DefaultContainerType) if (!string.IsNullOrEmpty(PageState.Page.DefaultContainerType) && _containerType == PageState.Page.DefaultContainerType)
{ {

View File

@ -116,27 +116,30 @@
</select> </select>
</td> </td>
</tr> </tr>
<tr> @if (_panelayouts.Count > 0)
<td> {
<Label For="Layout" HelpText="Select a layout for the page (if the selected theme supports it)">Layout: </Label> <tr>
</td> <td>
<td> <Label For="Layout" HelpText="Select a layout for the page (if the selected theme supports it)">Layout: </Label>
<select id="Layout" class="form-control" @bind="@_layouttype"> </td>
<option value="-">&lt;Inherit From Site&gt;</option> <td>
@foreach (KeyValuePair<string, string> panelayout in _panelayouts) <select id="Layout" class="form-control" @bind="@_layouttype">
{ <option value="-">&lt;Inherit From Site&gt;</option>
if (panelayout.Key == _layouttype) @foreach (KeyValuePair<string, string> panelayout in _panelayouts)
{ {
<option value="@panelayout.Key" selected>@panelayout.Value</option> if (panelayout.Key == _layouttype)
{
<option value="@panelayout.Key" selected>@panelayout.Value</option>
}
else
{
<option value="@panelayout.Key">@panelayout.Value</option>
}
} }
else </select>
{ </td>
<option value="@panelayout.Key">@panelayout.Value</option> </tr>
} }
}
</select>
</td>
</tr>
<tr> <tr>
<td> <td>
<Label For="defaultContainer" HelpText="Select the default container for the page">Default Container: </Label> <Label For="defaultContainer" HelpText="Select the default container for the page">Default Container: </Label>
@ -199,8 +202,8 @@
<NavLink class="btn btn-secondary" href="@NavigateUrl()">Cancel</NavLink> <NavLink class="btn btn-secondary" href="@NavigateUrl()">Cancel</NavLink>
@code { @code {
private Dictionary<string, string> _themes; private Dictionary<string, string> _themes = new Dictionary<string, string>();
private Dictionary<string, string> _panelayouts; private Dictionary<string, string> _panelayouts = new Dictionary<string, string>();
private Dictionary<string, string> _containers = new Dictionary<string, string>(); private Dictionary<string, string> _containers = new Dictionary<string, string>();
private List<Theme> _themeList; private List<Theme> _themeList;
private List<Page> _pageList; private List<Page> _pageList;
@ -233,9 +236,6 @@
_children = PageState.Pages.Where(item => item.ParentId == null).ToList(); _children = PageState.Pages.Where(item => item.ParentId == null).ToList();
_themes = ThemeService.GetThemeTypes(_themeList); _themes = ThemeService.GetThemeTypes(_themeList);
_panelayouts = ThemeService.GetPaneLayoutTypes(_themeList, _themetype);
_containers = ThemeService.GetContainerTypes(_themeList);
_permissions = string.Empty; _permissions = string.Empty;
} }
catch (Exception ex) catch (Exception ex)
@ -288,11 +288,15 @@
if (_themetype != "-") if (_themetype != "-")
{ {
_panelayouts = ThemeService.GetPaneLayoutTypes(_themeList, _themetype); _panelayouts = ThemeService.GetPaneLayoutTypes(_themeList, _themetype);
_containers = ThemeService.GetContainerTypes(_themeList, _themetype);
} }
else else
{ {
_panelayouts = new Dictionary<string, string>(); _panelayouts = new Dictionary<string, string>();
_containers = new Dictionary<string, string>();
} }
_layouttype = "-";
_containertype = "-";
StateHasChanged(); StateHasChanged();
} }
catch (Exception ex) catch (Exception ex)

View File

@ -127,27 +127,30 @@
</select> </select>
</td> </td>
</tr> </tr>
<tr> @if (_panelayouts.Count > 0)
<td> {
<Label For="Layout" HelpText="Select a layout for the page (if the selected theme supports it)">Layout: </Label> <tr>
</td> <td>
<td> <Label For="Layout" HelpText="Select a layout for the page (if the selected theme supports it)">Layout: </Label>
<select id="Layout" class="form-control" @bind="@_layouttype"> </td>
<option value="-">&lt;Inherit From Site&gt;</option> <td>
@foreach (KeyValuePair<string, string> panelayout in _panelayouts) <select id="Layout" class="form-control" @bind="@_layouttype">
{ <option value="-">&lt;Inherit From Site&gt;</option>
if (panelayout.Key == _layouttype) @foreach (KeyValuePair<string, string> panelayout in _panelayouts)
{ {
<option value="@panelayout.Key" selected>@panelayout.Value</option> if (panelayout.Key == _layouttype)
{
<option value="@panelayout.Key" selected>@panelayout.Value</option>
}
else
{
<option value="@panelayout.Key">@panelayout.Value</option>
}
} }
else </select>
{ </td>
<option value="@panelayout.Key">@panelayout.Value</option> </tr>
} }
}
</select>
</td>
</tr>
<tr> <tr>
<td> <td>
<Label For="defaultContainer" HelpText="Select the default container for the page">Default Container: </Label> <Label For="defaultContainer" HelpText="Select the default container for the page">Default Container: </Label>
@ -212,8 +215,8 @@
<NavLink class="btn btn-secondary" href="@NavigateUrl()">Cancel</NavLink> <NavLink class="btn btn-secondary" href="@NavigateUrl()">Cancel</NavLink>
@code { @code {
private Dictionary<string, string> _themes; private Dictionary<string, string> _themes = new Dictionary<string, string>();
private Dictionary<string, string> _panelayouts; private Dictionary<string, string> _panelayouts = new Dictionary<string, string>();
private Dictionary<string, string> _containers = new Dictionary<string, string>(); private Dictionary<string, string> _containers = new Dictionary<string, string>();
private List<Theme> _themeList; private List<Theme> _themeList;
private List<Page> _pageList; private List<Page> _pageList;
@ -257,7 +260,6 @@
_children = PageState.Pages.Where(item => item.ParentId == null).ToList(); _children = PageState.Pages.Where(item => item.ParentId == null).ToList();
_themes = ThemeService.GetThemeTypes(_themeList); _themes = ThemeService.GetThemeTypes(_themeList);
_containers = ThemeService.GetContainerTypes(_themeList);
_pageId = Int32.Parse(PageState.QueryString["id"]); _pageId = Int32.Parse(PageState.QueryString["id"]);
var page = PageState.Pages.FirstOrDefault(item => item.PageId == _pageId); var page = PageState.Pages.FirstOrDefault(item => item.PageId == _pageId);
@ -291,12 +293,13 @@
{ {
_themetype = "-"; _themetype = "-";
} }
_panelayouts = ThemeService.GetPaneLayoutTypes(_themeList, _themetype); _panelayouts = ThemeService.GetPaneLayoutTypes(_themeList, page.ThemeType);
_layouttype = page.LayoutType; _layouttype = page.LayoutType;
if (_layouttype == PageState.Site.DefaultLayoutType) if (_layouttype == PageState.Site.DefaultLayoutType)
{ {
_layouttype = "-"; _layouttype = "-";
} }
_containers = ThemeService.GetContainerTypes(_themeList, page.ThemeType);
_containertype = page.DefaultContainerType; _containertype = page.DefaultContainerType;
if (string.IsNullOrEmpty(_containertype)) if (string.IsNullOrEmpty(_containertype))
{ {
@ -370,11 +373,15 @@
if (_themetype != "-") if (_themetype != "-")
{ {
_panelayouts = ThemeService.GetPaneLayoutTypes(_themeList, _themetype); _panelayouts = ThemeService.GetPaneLayoutTypes(_themeList, _themetype);
_containers = ThemeService.GetContainerTypes(_themeList, _themetype);
} }
else else
{ {
_panelayouts = new Dictionary<string, string>(); _panelayouts = new Dictionary<string, string>();
_containers = new Dictionary<string, string>();
} }
_layouttype = "-";
_containertype = "-";
StateHasChanged(); StateHasChanged();
} }
catch (Exception ex) catch (Exception ex)

View File

@ -56,6 +56,7 @@
</td> </td>
<td> <td>
<select id="defaultTheme" class="form-control" @onchange="(e => ThemeChanged(e))"> <select id="defaultTheme" class="form-control" @onchange="(e => ThemeChanged(e))">
<option value="-">&lt;Select Theme&gt;</option>
@foreach (KeyValuePair<string, string> item in _themes) @foreach (KeyValuePair<string, string> item in _themes)
{ {
if (item.Key == _themetype) if (item.Key == _themetype)
@ -70,25 +71,30 @@
</select> </select>
</td> </td>
</tr> </tr>
<tr> @if (_panelayouts.Count > 0)
<td> {
<Label For="defaultLayout" HelpText="Select the sites default layout">Default Layout: </Label> <tr>
</td> <td>
<td> <Label For="defaultLayout" HelpText="Select the sites default layout">Default Layout: </Label>
<select id="defaultLayout" class="form-control" @bind="@_layouttype"> </td>
@foreach (KeyValuePair<string, string> panelayout in _panelayouts) <td>
{ <select id="defaultLayout" class="form-control" @bind="@_layouttype">
<option value="@panelayout.Key">@panelayout.Value</option> <option value="-">&lt;Select Layout&gt;</option>
} @foreach (KeyValuePair<string, string> panelayout in _panelayouts)
</select> {
</td> <option value="@panelayout.Key">@panelayout.Value</option>
</tr> }
</select>
</td>
</tr>
}
<tr> <tr>
<td> <td>
<Label For="defaultContainer" HelpText="Select the default container for the site">Default Container: </Label> <Label For="defaultContainer" HelpText="Select the default container for the site">Default Container: </Label>
</td> </td>
<td> <td>
<select id="defaultContainer" class="form-control" @bind="@_containertype"> <select id="defaultContainer" class="form-control" @bind="@_containertype">
<option value="-">&lt;Select Container&gt;</option>
@foreach (KeyValuePair<string, string> container in _containers) @foreach (KeyValuePair<string, string> container in _containers)
{ {
<option value="@container.Key">@container.Value</option> <option value="@container.Key">@container.Value</option>
@ -205,9 +211,9 @@
} }
@code { @code {
private Dictionary<string, string> _themes; private Dictionary<string, string> _themes = new Dictionary<string, string>();
private Dictionary<string, string> _panelayouts; private Dictionary<string, string> _panelayouts = new Dictionary<string, string>();
private Dictionary<string, string> _containers; private Dictionary<string, string> _containers = new Dictionary<string, string>();
private List<Theme> _themeList; private List<Theme> _themeList;
private string _name = string.Empty; private string _name = string.Empty;
private List<Tenant> _tenantList; private List<Tenant> _tenantList;
@ -218,9 +224,9 @@
private FileManager _logofilemanager; private FileManager _logofilemanager;
private int _faviconfileid = -1; private int _faviconfileid = -1;
private FileManager _faviconfilemanager; private FileManager _faviconfilemanager;
private string _themetype; private string _themetype = "-";
private string _layouttype; private string _layouttype = "-";
private string _containertype; private string _containertype = "-";
private string _allowregistration; private string _allowregistration;
private string _smtphost = string.Empty; private string _smtphost = string.Empty;
private string _smtpport = string.Empty; private string _smtpport = string.Empty;
@ -271,6 +277,7 @@
_themetype = site.DefaultThemeType; _themetype = site.DefaultThemeType;
_panelayouts = ThemeService.GetPaneLayoutTypes(_themeList, _themetype); _panelayouts = ThemeService.GetPaneLayoutTypes(_themeList, _themetype);
_layouttype = site.DefaultLayoutType; _layouttype = site.DefaultLayoutType;
_containers = ThemeService.GetContainerTypes(_themeList, _themetype);
_containertype = site.DefaultContainerType; _containertype = site.DefaultContainerType;
_allowregistration = site.AllowRegistration.ToString(); _allowregistration = site.AllowRegistration.ToString();
@ -313,7 +320,7 @@
} }
_themes = ThemeService.GetThemeTypes(_themeList); _themes = ThemeService.GetThemeTypes(_themeList);
_containers = ThemeService.GetContainerTypes(_themeList); _containers = ThemeService.GetContainerTypes(_themeList, _themetype);
} }
catch (Exception ex) catch (Exception ex)
{ {
@ -330,11 +337,15 @@
if (_themetype != string.Empty) if (_themetype != string.Empty)
{ {
_panelayouts = ThemeService.GetPaneLayoutTypes(_themeList, _themetype); _panelayouts = ThemeService.GetPaneLayoutTypes(_themeList, _themetype);
_containers = ThemeService.GetContainerTypes(_themeList, _themetype);
} }
else else
{ {
_panelayouts = new Dictionary<string, string>(); _panelayouts = new Dictionary<string, string>();
_containers = new Dictionary<string, string>();
} }
_layouttype = "-";
_containertype = "-";
StateHasChanged(); StateHasChanged();
} }
catch (Exception ex) catch (Exception ex)
@ -348,7 +359,7 @@
{ {
try try
{ {
if (_name != string.Empty && _urls != string.Empty && !string.IsNullOrEmpty(_themetype) && (_panelayouts.Count == 0 || !string.IsNullOrEmpty(_layouttype)) && !string.IsNullOrEmpty(_containertype)) if (_name != string.Empty && _urls != string.Empty && _themetype != "-" && (_panelayouts.Count == 0 || _layouttype != "-") && _containertype != "-")
{ {
var unique = true; var unique = true;
foreach (string name in _urls.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries)) foreach (string name in _urls.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries))
@ -373,7 +384,7 @@
} }
site.DefaultThemeType = _themetype; site.DefaultThemeType = _themetype;
site.DefaultLayoutType = (_layouttype == null ? string.Empty : _layouttype); site.DefaultLayoutType = (_layouttype == "-" ? string.Empty : _layouttype);
site.DefaultContainerType = _containertype; site.DefaultContainerType = _containertype;
site.AllowRegistration = (_allowregistration == null ? true : Boolean.Parse(_allowregistration)); site.AllowRegistration = (_allowregistration == null ? true : Boolean.Parse(_allowregistration));
site.IsDeleted = (_isdeleted == null ? true : Boolean.Parse(_isdeleted)); site.IsDeleted = (_isdeleted == null ? true : Boolean.Parse(_isdeleted));

View File

@ -38,7 +38,7 @@ else
</td> </td>
<td> <td>
<select id="defaultTheme" class="form-control" @onchange="(e => ThemeChanged(e))"> <select id="defaultTheme" class="form-control" @onchange="(e => ThemeChanged(e))">
<option value="">&lt;Select Theme&gt;</option> <option value="-">&lt;Select Theme&gt;</option>
@foreach (KeyValuePair<string, string> item in _themes) @foreach (KeyValuePair<string, string> item in _themes)
{ {
<option value="@item.Key">@item.Value</option> <option value="@item.Key">@item.Value</option>
@ -46,27 +46,30 @@ else
</select> </select>
</td> </td>
</tr> </tr>
<tr> @if (_panelayouts.Count > 0)
<td> {
<Label For="defaultLayout" HelpText="Select the default layout for the site">Default Layout: </Label> <tr>
</td> <td>
<td> <Label For="defaultLayout" HelpText="Select the default layout for the site">Default Layout: </Label>
<select id="defaultLayout" class="form-control" @bind="@_layouttype"> </td>
<option value="">&lt;Select Layout&gt;</option> <td>
@foreach (KeyValuePair<string, string> panelayout in _panelayouts) <select id="defaultLayout" class="form-control" @bind="@_layouttype">
{ <option value="-">&lt;Select Layout&gt;</option>
<option value="@panelayout.Key">@panelayout.Value</option> @foreach (KeyValuePair<string, string> panelayout in _panelayouts)
} {
</select> <option value="@panelayout.Key">@panelayout.Value</option>
</td> }
</tr> </select>
</td>
</tr>
}
<tr> <tr>
<td> <td>
<Label For="defaultContainer" HelpText="Select the default container for the site">Default Container: </Label> <Label For="defaultContainer" HelpText="Select the default container for the site">Default Container: </Label>
</td> </td>
<td> <td>
<select id="defaultContainer" class="form-control" @bind="@_containertype"> <select id="defaultContainer" class="form-control" @bind="@_containertype">
<option value="">&lt;Select Container&gt;</option> <option value="-">&lt;Select Container&gt;</option>
@foreach (KeyValuePair<string, string> container in _containers) @foreach (KeyValuePair<string, string> container in _containers)
{ {
<option value="@container.Key">@container.Value</option> <option value="@container.Key">@container.Value</option>
@ -80,7 +83,7 @@ else
</td> </td>
<td> <td>
<select id="siteTemplate" class="form-control" @bind="@_sitetemplatetype"> <select id="siteTemplate" class="form-control" @bind="@_sitetemplatetype">
<option value="">&lt;Select Site Template&gt;</option> <option value="-">&lt;Select Site Template&gt;</option>
@foreach (SiteTemplate siteTemplate in _siteTemplates) @foreach (SiteTemplate siteTemplate in _siteTemplates)
{ {
<option value="@siteTemplate.TypeName">@siteTemplate.Name</option> <option value="@siteTemplate.TypeName">@siteTemplate.Name</option>
@ -218,10 +221,10 @@ else
private string _name = string.Empty; private string _name = string.Empty;
private string _urls = string.Empty; private string _urls = string.Empty;
private string _themetype = string.Empty; private string _themetype = "-";
private string _layouttype = string.Empty; private string _layouttype = "-";
private string _containertype = string.Empty; private string _containertype = "-";
private string _sitetemplatetype = string.Empty; private string _sitetemplatetype = "-";
public override SecurityAccessLevel SecurityAccessLevel => SecurityAccessLevel.Host; public override SecurityAccessLevel SecurityAccessLevel => SecurityAccessLevel.Host;
@ -231,7 +234,6 @@ else
_tenants = await TenantService.GetTenantsAsync(); _tenants = await TenantService.GetTenantsAsync();
_urls = PageState.Alias.Name; _urls = PageState.Alias.Name;
_themes = ThemeService.GetThemeTypes(_themeList); _themes = ThemeService.GetThemeTypes(_themeList);
_containers = ThemeService.GetContainerTypes(_themeList);
_siteTemplates = await SiteTemplateService.GetSiteTemplatesAsync(); _siteTemplates = await SiteTemplateService.GetSiteTemplatesAsync();
} }
@ -266,12 +268,15 @@ else
if (_themetype != string.Empty) if (_themetype != string.Empty)
{ {
_panelayouts = ThemeService.GetPaneLayoutTypes(_themeList, _themetype); _panelayouts = ThemeService.GetPaneLayoutTypes(_themeList, _themetype);
_containers = ThemeService.GetContainerTypes(_themeList, _themetype);
} }
else else
{ {
_panelayouts = new Dictionary<string, string>(); _panelayouts = new Dictionary<string, string>();
_containers = new Dictionary<string, string>();
} }
_layouttype = "-";
_containertype = "-";
StateHasChanged(); StateHasChanged();
} }
catch (Exception ex) catch (Exception ex)
@ -283,7 +288,7 @@ else
private async Task SaveSite() private async Task SaveSite()
{ {
if (_tenantid != "-" && _name != string.Empty && _urls != string.Empty && !string.IsNullOrEmpty(_themetype) && (_panelayouts.Count == 0 || !string.IsNullOrEmpty(_layouttype)) && !string.IsNullOrEmpty(_containertype) && !string.IsNullOrEmpty(_sitetemplatetype)) if (_tenantid != "-" && _name != string.Empty && _urls != string.Empty && _themetype != "-" && (_panelayouts.Count == 0 || _layouttype != "-") && _containertype != "-" && _sitetemplatetype != "-")
{ {
var duplicates = new List<string>(); var duplicates = new List<string>();
var aliases = await AliasService.GetAliasesAsync(); var aliases = await AliasService.GetAliasesAsync();

View File

@ -39,7 +39,7 @@
</td> </td>
<td> <td>
<select id="defaultTheme" class="form-control" @onchange="(e => ThemeChanged(e))"> <select id="defaultTheme" class="form-control" @onchange="(e => ThemeChanged(e))">
<option value="">&lt;Select Theme&gt;</option> <option value="-">&lt;Select Theme&gt;</option>
@foreach (KeyValuePair<string, string> item in _themes) @foreach (KeyValuePair<string, string> item in _themes)
{ {
if (item.Key == _themetype) if (item.Key == _themetype)
@ -54,27 +54,30 @@
</select> </select>
</td> </td>
</tr> </tr>
<tr> @if (_panelayouts.Count > 0)
<td> {
<Label For="defaultLayout" HelpText="Select the default layout for the site">Default Layout: </Label> <tr>
</td> <td>
<td> <Label For="defaultLayout" HelpText="Select the default layout for the site">Default Layout: </Label>
<select id="defaultLayout" class="form-control" @bind="@_layouttype"> </td>
<option value="">&lt;Select Layout&gt;</option> <td>
@foreach (KeyValuePair<string, string> panelayout in _panelayouts) <select id="defaultLayout" class="form-control" @bind="@_layouttype">
{ <option value="-">&lt;Select Layout&gt;</option>
<option value="@panelayout.Key">@panelayout.Value</option> @foreach (KeyValuePair<string, string> panelayout in _panelayouts)
} {
</select> <option value="@panelayout.Key">@panelayout.Value</option>
</td> }
</tr> </select>
</td>
</tr>
}
<tr> <tr>
<td> <td>
<Label For="defaultContainer" HelpText="Select the default container for the site">Default Container: </Label> <Label For="defaultContainer" HelpText="Select the default container for the site">Default Container: </Label>
</td> </td>
<td> <td>
<select id="defaultIdea" class="form-control" @bind="@_containertype"> <select id="defaultIdea" class="form-control" @bind="@_containertype">
<option value="">&lt;Select Container&gt;</option> <option value="-">&lt;Select Container&gt;</option>
@foreach (KeyValuePair<string, string> container in _containers) @foreach (KeyValuePair<string, string> container in _containers)
{ {
<option value="@container.Key">@container.Value</option> <option value="@container.Key">@container.Value</option>
@ -103,9 +106,9 @@
} }
@code { @code {
private Dictionary<string, string> _themes; private Dictionary<string, string> _themes = new Dictionary<string, string>();
private Dictionary<string, string> _panelayouts; private Dictionary<string, string> _panelayouts = new Dictionary<string, string>();
private Dictionary<string, string> _containers; private Dictionary<string, string> _containers = new Dictionary<string, string>();
private Alias _alias; private Alias _alias;
private List<Theme> _themeList; private List<Theme> _themeList;
private string _name = string.Empty; private string _name = string.Empty;
@ -147,9 +150,11 @@
_urls += alias.Name + "\n"; _urls += alias.Name + "\n";
} }
_themes = ThemeService.GetThemeTypes(_themeList);
_themetype = site.DefaultThemeType; _themetype = site.DefaultThemeType;
_panelayouts = ThemeService.GetPaneLayoutTypes(_themeList, _themetype); _panelayouts = ThemeService.GetPaneLayoutTypes(_themeList, _themetype);
_layouttype = site.DefaultLayoutType; _layouttype = site.DefaultLayoutType;
_containers = ThemeService.GetContainerTypes(_themeList, _themetype);
_containertype = site.DefaultContainerType; _containertype = site.DefaultContainerType;
_createdby = site.CreatedBy; _createdby = site.CreatedBy;
_createdon = site.CreatedOn; _createdon = site.CreatedOn;
@ -159,9 +164,6 @@
_deletedon = site.DeletedOn; _deletedon = site.DeletedOn;
_isdeleted = site.IsDeleted.ToString(); _isdeleted = site.IsDeleted.ToString();
} }
_themes = ThemeService.GetThemeTypes(_themeList);
_containers = ThemeService.GetContainerTypes(_themeList);
} }
catch (Exception ex) catch (Exception ex)
{ {
@ -178,12 +180,15 @@
if (_themetype != string.Empty) if (_themetype != string.Empty)
{ {
_panelayouts = ThemeService.GetPaneLayoutTypes(_themeList, _themetype); _panelayouts = ThemeService.GetPaneLayoutTypes(_themeList, _themetype);
_containers = ThemeService.GetContainerTypes(_themeList, _themetype);
} }
else else
{ {
_panelayouts = new Dictionary<string, string>(); _panelayouts = new Dictionary<string, string>();
_containers = new Dictionary<string, string>();
} }
_layouttype = "-";
_containertype = "-";
StateHasChanged(); StateHasChanged();
} }
catch (Exception ex) catch (Exception ex)
@ -197,7 +202,7 @@
{ {
try try
{ {
if (_name != string.Empty && _urls != string.Empty && !string.IsNullOrEmpty(_themetype) && (_panelayouts.Count == 0 || !string.IsNullOrEmpty(_layouttype)) && !string.IsNullOrEmpty(_containertype)) if (_name != string.Empty && _urls != string.Empty && _themetype != "-" && (_panelayouts.Count == 0 || _layouttype != "-") && _containertype != "-")
{ {
var unique = true; var unique = true;
foreach (string name in _urls.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries)) foreach (string name in _urls.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries))

View File

@ -9,7 +9,7 @@ namespace Oqtane.Services
Task<List<Theme>> GetThemesAsync(); Task<List<Theme>> GetThemesAsync();
Dictionary<string, string> GetThemeTypes(List<Theme> themes); Dictionary<string, string> GetThemeTypes(List<Theme> themes);
Dictionary<string, string> GetPaneLayoutTypes(List<Theme> themes, string themeName); Dictionary<string, string> GetPaneLayoutTypes(List<Theme> themes, string themeName);
Dictionary<string, string> GetContainerTypes(List<Theme> themes); Dictionary<string, string> GetContainerTypes(List<Theme> themes, string themeName);
Task InstallThemesAsync(); Task InstallThemesAsync();
Task DeleteThemeAsync(string themeName); Task DeleteThemeAsync(string themeName);
} }

View File

@ -43,8 +43,8 @@ namespace Oqtane.Services
{ {
var selectablePaneLayouts = new Dictionary<string, string>(); var selectablePaneLayouts = new Dictionary<string, string>();
foreach (Theme theme in themes) foreach (Theme theme in themes)
{ {
if (themeName.StartsWith(theme.ThemeName)) if (Utilities.GetTypeName(themeName).StartsWith(Utilities.GetTypeName(theme.ThemeName)))
{ {
foreach (string panelayout in theme.PaneLayouts.Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries)) foreach (string panelayout in theme.PaneLayouts.Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries))
{ {
@ -55,14 +55,17 @@ namespace Oqtane.Services
return selectablePaneLayouts; return selectablePaneLayouts;
} }
public Dictionary<string, string> GetContainerTypes(List<Theme> themes) public Dictionary<string, string> GetContainerTypes(List<Theme> themes, string themeName)
{ {
var selectableContainers = new Dictionary<string, string>(); var selectableContainers = new Dictionary<string, string>();
foreach (Theme theme in themes) foreach (Theme theme in themes)
{ {
foreach (string container in theme.ContainerControls.Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries)) if (Utilities.GetTypeName(themeName).StartsWith(Utilities.GetTypeName(theme.ThemeName)))
{ {
selectableContainers.Add(container, theme.Name + " - " + @Utilities.GetTypeNameLastSegment(container, 0)); foreach (string container in theme.ContainerControls.Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries))
{
selectableContainers.Add(container, theme.Name + " - " + @Utilities.GetTypeNameLastSegment(container, 0));
}
} }
} }
return selectableContainers; return selectableContainers;

View File

@ -301,7 +301,7 @@
var panes = PageState.Page.Panes; var panes = PageState.Page.Panes;
Pane = panes.Count() == 1 ? panes.SingleOrDefault() : ""; Pane = panes.Count() == 1 ? panes.SingleOrDefault() : "";
var themes = await ThemeService.GetThemesAsync(); var themes = await ThemeService.GetThemesAsync();
_containers = ThemeService.GetContainerTypes(themes); _containers = ThemeService.GetContainerTypes(themes, PageState.Page.ThemeType);
ContainerType = PageState.Site.DefaultContainerType; ContainerType = PageState.Site.DefaultContainerType;
_allModuleDefinitions = await ModuleDefinitionService.GetModuleDefinitionsAsync(PageState.Site.SiteId); _allModuleDefinitions = await ModuleDefinitionService.GetModuleDefinitionsAsync(PageState.Site.SiteId);