Skip to content

Commit

Permalink
allow module to be inserted at top of pane
Browse files Browse the repository at this point in the history
  • Loading branch information
sbwalker committed Oct 9, 2023
1 parent 575bbdb commit 2d4bf17
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 24 deletions.
9 changes: 9 additions & 0 deletions Oqtane.Client/Resources/Themes/Controls/ControlPanel.resx
Original file line number Diff line number Diff line change
Expand Up @@ -189,4 +189,13 @@
<data name="Confirm.Page.Delete" xml:space="preserve">
<value>Are You Sure You Want To Delete This Page?</value>
</data>
<data name="Location" xml:space="preserve">
<value>Location:</value>
</data>
<data name="LocationBottom" xml:space="preserve">
<value>Bottom</value>
</data>
<data name="LocationTop" xml:space="preserve">
<value>Top</value>
</data>
</root>
54 changes: 30 additions & 24 deletions Oqtane.Client/Themes/Controls/Theme/ControlPanel.razor
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@

<div class="row">
<div class="col text-center">
<label for="Module" class="control-label">@Localizer["Module.Manage"] </label>
<label for="Module" class="control-label">@Localizer["Module.Manage"]</label>
<select class="form-select" @bind="@ModuleType">
<option value="new">@Localizer["Module.AddNew"]</option>
<option value="existing">@Localizer["Module.AddExisting"]</option>
Expand Down Expand Up @@ -179,27 +179,33 @@
</div>
<div class="row">
<div class="col text-center">
<label for="Title" class="control-label">@Localizer["Title"] </label>
<label for="Title" class="control-label">@Localizer["Title"]</label>
<input type="text" name="Title" class="form-control" @bind="@Title" />
</div>
</div>
@if (_pane.Length > 1)
{
<div class="row">
<div class="col text-center">
<label for="Pane" class="control-label">@Localizer["Pane"] </label>
<select class="form-select" @bind="@Pane">
@foreach (string pane in PageState.Page.Panes)
{
<option value="@pane">@pane Pane</option>
}
</select>
</div>
<div class="row">
<div class="col text-center">
<label for="Pane" class="control-label">@Localizer["Pane"]</label>
<select class="form-select" @bind="@Pane">
@foreach (string pane in PageState.Page.Panes)
{
<option value="@pane">@pane Pane</option>
}
</select>
</div>
}
</div>
<div class="row">
<div class="col text-center">
<label for="Insert" class="control-label">@Localizer["Location"]</label>
<select class="form-select" @bind="@Location">
<option value="@int.MinValue">@Localizer["LocationTop"]</option>
<option value="@int.MaxValue">@Localizer["LocationBottom"]</option>
</select>
</div>
</div>
<div class="row">
<div class="col text-center">
<label for="Container" class="control-label">@Localizer["Container"] </label>
<label for="Container" class="control-label">@Localizer["Container"]</label>
<select class="form-select" @bind="@ContainerType">
@foreach (var container in _containers)
{
Expand Down Expand Up @@ -243,6 +249,7 @@
private List<Module> _modules = new List<Module>();
private List<ThemeControl> _containers = new List<ThemeControl>();
private string _category = "Common";
private string _pane = "";

protected string PageId { get; private set; } = "-";
protected string ModuleId { get; private set; } = "-";
Expand All @@ -251,12 +258,12 @@

protected string Title { get; private set; } = "";
protected string ContainerType { get; private set; } = "";
protected int Location { get; private set; } = int.MaxValue;
protected string Visibility { get; private set; } = "view";
protected string Message { get; private set; } = "";

private string settingCategory = "CP-category";
private string settingPane = "CP-pane";
private string _pane = "";

protected string Category
{
Expand Down Expand Up @@ -310,16 +317,16 @@
if (UserSecurity.IsAuthorized(PageState.User, PermissionNames.Edit, PageState.Page.PermissionList))
{
_showEditMode = true;
_pages?.Clear();
LoadSettingsAsync();

_pages?.Clear();
foreach (Page p in PageState.Pages)
{
if (UserSecurity.IsAuthorized(PageState.User, PermissionNames.View, p.PermissionList))
{
_pages.Add(p);
}
}
await LoadSettingsAsync();

var themes = await ThemeService.GetThemesAsync();
_containers = ThemeService.GetContainerControls(themes, PageState.Page.ThemeType);
Expand Down Expand Up @@ -443,7 +450,7 @@
}

pageModule.Pane = Pane;
pageModule.Order = int.MaxValue;
pageModule.Order = Location;
pageModule.ContainerType = ContainerType;

if (pageModule.ContainerType == PageState.Site.DefaultContainerType)
Expand Down Expand Up @@ -653,11 +660,10 @@
}
}

private async Task LoadSettingsAsync()
private void LoadSettingsAsync()
{
Dictionary<string, string> settings = await SettingService.GetUserSettingsAsync(PageState.User.UserId);
_category = SettingService.GetSetting(settings, settingCategory, "Common");
var pane = SettingService.GetSetting(settings, settingPane, "");
_category = SettingService.GetSetting(PageState.User.Settings, settingCategory, "Common");
var pane = SettingService.GetSetting(PageState.User.Settings, settingPane, "");
if (PageState.Page.Panes.Contains(pane))
{
_pane = pane;
Expand Down

0 comments on commit 2d4bf17

Please sign in to comment.