Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix issue with module order in panes caused by transition from Admin to Default pane naming #3260

Merged
merged 1 commit into from
Sep 18, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 12 additions & 2 deletions Oqtane.Server/Controllers/PageModuleController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
using Oqtane.Security;
using System.Net;
using Microsoft.AspNetCore.Mvc.RazorPages;
using Microsoft.Identity.Client.Extensibility;
using System;

namespace Oqtane.Controllers
{
Expand Down Expand Up @@ -133,14 +135,22 @@ public void Put(int pageid, string pane)
var page = _pages.GetPage(pageid);
if (page != null && page.SiteId == _alias.SiteId && _userPermissions.IsAuthorized(User, page.SiteId, EntityNames.Page, pageid, PermissionNames.Edit))
{
var panes = pane;
if (pane == PaneNames.Default || pane == PaneNames.Admin)
{
// treat default and admin panes as a single pane
panes = PaneNames.Default + "," + PaneNames.Admin;
pane = PaneNames.Default;
}
int order = 1;
List<PageModule> pagemodules = _pageModules.GetPageModules(page.SiteId)
.Where(item => item.PageId == pageid && item.Pane == pane).OrderBy(item => item.Order).ToList();
.Where(item => item.PageId == pageid && panes.Split(',').Contains(item.Pane)).OrderBy(item => item.Order).ToList();
foreach (PageModule pagemodule in pagemodules)
{
if (pagemodule.Order != order)
if (pagemodule.Order != order || pagemodule.Pane != pane)
{
pagemodule.Order = order;
pagemodule.Pane = pane;
_pageModules.UpdatePageModule(pagemodule);
_syncManager.AddSyncEvent(_alias.TenantId, EntityNames.PageModule, pagemodule.PageModuleId, SyncEventActions.Update);
}
Expand Down