115 lines
4.9 KiB
Plaintext
115 lines
4.9 KiB
Plaintext
@using Oqtane.Themes
|
|
@using Oqtane.Services
|
|
@using Oqtane.Models
|
|
@using Oqtane.Shared
|
|
@using Oqtane.Security
|
|
@inherits ContainerBase
|
|
@inject IUriHelper UriHelper
|
|
@inject IUserService UserService
|
|
@inject IPageModuleService PageModuleService
|
|
|
|
@if (PageState.DesignMode && UserSecurity.IsAuthorized(PageState.User, "Edit", ModuleState.Permissions))
|
|
{
|
|
<div class="dropdown">
|
|
<button type="button" class="btn dropdown-toggle" id="dropdownMenuButton" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false"></button>
|
|
<div class="dropdown-menu" aria-labelledby="dropdownMenuButton">
|
|
@foreach (var action in actions)
|
|
{
|
|
<a class="dropdown-item" @onclick="@(async () => await ModuleAction(action.Action))">@action.Name</a>
|
|
}
|
|
</div>
|
|
</div>
|
|
}
|
|
|
|
@code {
|
|
List<ActionViewModel> actions;
|
|
|
|
protected override void OnParametersSet()
|
|
{
|
|
if (PageState.EditMode && UserSecurity.IsAuthorized(PageState.User, "Edit", ModuleState.Permissions))
|
|
{
|
|
actions = new List<ActionViewModel>();
|
|
if (ModuleState.PaneModuleIndex > 0)
|
|
{
|
|
actions.Add(new ActionViewModel { Action = "<<", Name = "Move To Top" });
|
|
}
|
|
if (ModuleState.PaneModuleIndex > 0)
|
|
{
|
|
actions.Add(new ActionViewModel { Action = "<", Name = "Move Up" });
|
|
}
|
|
if (ModuleState.PaneModuleIndex < (ModuleState.PaneModuleCount - 1))
|
|
{
|
|
actions.Add(new ActionViewModel { Action = ">", Name = "Move Down" });
|
|
}
|
|
if (ModuleState.PaneModuleIndex < (ModuleState.PaneModuleCount - 1))
|
|
{
|
|
actions.Add(new ActionViewModel { Action = ">>", Name = "Move To Bottom" });
|
|
}
|
|
foreach (string pane in PageState.Page.Panes.Split(new[] { ';' }, StringSplitOptions.RemoveEmptyEntries))
|
|
{
|
|
if (pane != ModuleState.Pane)
|
|
{
|
|
actions.Add(new ActionViewModel { Action = pane, Name = "Move To " + pane + " Pane" });
|
|
}
|
|
}
|
|
actions.Add(new ActionViewModel { Action = "settings", Name = "Settings" });
|
|
actions.Add(new ActionViewModel { Action = "delete", Name = "Delete" });
|
|
}
|
|
}
|
|
|
|
protected async Task ModuleAction(string action)
|
|
{
|
|
if (PageState.EditMode && UserSecurity.IsAuthorized(PageState.User, "Edit", ModuleState.Permissions))
|
|
{
|
|
PageModule pagemodule = await PageModuleService.GetPageModuleAsync(ModuleState.PageModuleId);
|
|
|
|
string url = NavigateUrl();
|
|
switch (action)
|
|
{
|
|
case "<<":
|
|
pagemodule.Order = 0;
|
|
await PageModuleService.UpdatePageModuleAsync(pagemodule);
|
|
await PageModuleService.UpdatePageModuleOrderAsync(pagemodule.PageId, pagemodule.Pane);
|
|
break;
|
|
case "<":
|
|
pagemodule.Order -= 3;
|
|
await PageModuleService.UpdatePageModuleAsync(pagemodule);
|
|
await PageModuleService.UpdatePageModuleOrderAsync(pagemodule.PageId, pagemodule.Pane);
|
|
break;
|
|
case ">":
|
|
pagemodule.Order += 3;
|
|
await PageModuleService.UpdatePageModuleAsync(pagemodule);
|
|
await PageModuleService.UpdatePageModuleOrderAsync(pagemodule.PageId, pagemodule.Pane);
|
|
break;
|
|
case ">>":
|
|
pagemodule.Order = ModuleState.PaneModuleCount * 2;
|
|
await PageModuleService.UpdatePageModuleAsync(pagemodule);
|
|
await PageModuleService.UpdatePageModuleOrderAsync(pagemodule.PageId, pagemodule.Pane);
|
|
break;
|
|
case "settings":
|
|
url = EditUrl(pagemodule.ModuleId, "Settings");
|
|
break;
|
|
case "delete":
|
|
await PageModuleService.DeletePageModuleAsync(pagemodule.PageModuleId);
|
|
await PageModuleService.UpdatePageModuleOrderAsync(pagemodule.PageId, pagemodule.Pane);
|
|
break;
|
|
default: // move to pane
|
|
string pane = pagemodule.Pane;
|
|
pagemodule.Pane = action;
|
|
pagemodule.Order = int.MaxValue; // add to bottom of pane
|
|
await PageModuleService.UpdatePageModuleAsync(pagemodule);
|
|
await PageModuleService.UpdatePageModuleOrderAsync(pagemodule.PageId, pagemodule.Pane);
|
|
await PageModuleService.UpdatePageModuleOrderAsync(pagemodule.PageId, pane);
|
|
break;
|
|
}
|
|
PageState.Reload = Constants.ReloadPage;
|
|
UriHelper.NavigateTo(url);
|
|
}
|
|
}
|
|
|
|
public class ActionViewModel
|
|
{
|
|
public string Action { set; get; }
|
|
public string Name { set; get; }
|
|
}
|
|
} |