@using Microsoft.AspNetCore.Components.Web @using Oqtane.Themes @using Oqtane.Services @using Oqtane.Models @using Oqtane.Shared @using Oqtane.Security @namespace Oqtane.Themes.Controls @inherits ContainerBase @inject NavigationManager NavigationManager @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 = "<<", 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 = int.MaxValue; 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; NavigationManager.NavigateTo(url); } } public class ActionViewModel { public string Action { set; get; } public string Name { set; get; } } }