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 #3936 - parent page default when adding new pages #3940

Merged
merged 1 commit into from
Mar 4, 2024
Merged
Show file tree
Hide file tree
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
23 changes: 11 additions & 12 deletions Oqtane.Client/Modules/Admin/Pages/Add.razor
Original file line number Diff line number Diff line change
Expand Up @@ -256,9 +256,8 @@
{
_pageId = Int32.Parse(PageState.QueryString["id"]);
_parent = await PageService.GetPageAsync(_pageId);
if (_parent != null && !UserSecurity.IsAuthorized(PageState.User, RoleNames.Admin))
if (_parent != null)
{
// non-admins are authorized to create child pages of current page
_parentid = _parent.PageId.ToString();
}
}
Expand Down Expand Up @@ -376,6 +375,15 @@
page.SiteId = PageState.Page.SiteId;
page.Name = _name;

if (_parentid == "-1")
{
page.ParentId = null;
}
else
{
page.ParentId = Int32.Parse(_parentid);
}

// path can be a link to an external url
if (!_path.Contains("://"))
{
Expand All @@ -400,7 +408,7 @@
}
else
{
Page parent = PageState.Pages.FirstOrDefault(item => item.PageId == Int32.Parse(_parentid));
Page parent = PageState.Pages.FirstOrDefault(item => item.PageId == page.ParentId);
if (parent.Path == string.Empty)
{
page.Path = Utilities.GetFriendlyUrl(parent.Name) + "/" + Utilities.GetFriendlyUrl(_path);
Expand All @@ -417,15 +425,6 @@
page.Path = _path;
}

if (_parentid == "-1")
{
page.ParentId = null;
}
else
{
page.ParentId = Int32.Parse(_parentid);
}

var _pages = await PageService.GetPagesAsync(PageState.Site.SiteId);
if (_pages.Any(item => item.Path == page.Path))
{
Expand Down
20 changes: 10 additions & 10 deletions Oqtane.Client/Modules/Admin/Pages/Edit.razor
Original file line number Diff line number Diff line change
Expand Up @@ -518,6 +518,15 @@

_page.Name = _name;

if (_parentid == "-1")
{
_page.ParentId = null;
}
else
{
_page.ParentId = Int32.Parse(_parentid);
}

// path can be a link to an external url
if (!_path.Contains("://"))
{
Expand All @@ -542,7 +551,7 @@
}
else
{
Page parent = PageState.Pages.FirstOrDefault(item => item.PageId == Int32.Parse(_parentid));
Page parent = PageState.Pages.FirstOrDefault(item => item.PageId == _page.ParentId);
if (parent.Path == string.Empty)
{
_page.Path = Utilities.GetFriendlyUrl(parent.Name) + "/" + Utilities.GetFriendlyUrl(_path);
Expand All @@ -559,15 +568,6 @@
_page.Path = _path;
}

if (_parentid == "-1")
{
_page.ParentId = null;
}
else
{
_page.ParentId = Int32.Parse(_parentid);
}

var _pages = await PageService.GetPagesAsync(PageState.Site.SiteId);
if (_pages.Any(item => item.Path == _page.Path && item.PageId != _page.PageId))
{
Expand Down