@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))
{
}
@code {
List actions;
protected override void OnParametersSet()
{
if (PageState.EditMode && UserSecurity.IsAuthorized(PageState.User, "Edit", ModuleState.Permissions))
{
actions = new List();
if (ModuleState.PaneModuleIndex > 0)
{
actions.Add(new ActionViewModel { Action = "up", Name = "Move Up" });
}
if (ModuleState.PaneModuleIndex < (ModuleState.PaneModuleCount - 1))
{
actions.Add(new ActionViewModel { Action = "down", Name = "Move Down" });
}
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 "up":
pagemodule.Order += -1;
await PageModuleService.UpdatePageModuleAsync(pagemodule);
break;
case "down":
pagemodule.Order += 1;
await PageModuleService.UpdatePageModuleAsync(pagemodule);
break;
case "settings":
url = EditUrl(pagemodule.ModuleId, "Settings");
break;
case "delete":
await PageModuleService.DeletePageModuleAsync(pagemodule.PageModuleId);
break;
default: // move to pane
pagemodule.Pane = action;
await PageModuleService.UpdatePageModuleAsync(pagemodule);
break;
}
PageState.Reload = Constants.ReloadPage;
UriHelper.NavigateTo(url);
}
}
public class ActionViewModel
{
public string Action { set; get; }
public string Name { set; get; }
}
}