Skip to content

Commit

Permalink
Merge pull request #617 from cloudscribe/feature/616
Browse files Browse the repository at this point in the history
#616 updates to pagecontroller as 'Edit' is actually used when a page…
  • Loading branch information
markidox authored Dec 13, 2024
2 parents 9965cc9 + ff7f2ee commit 3470beb
Show file tree
Hide file tree
Showing 5 changed files with 67 additions and 46 deletions.
107 changes: 63 additions & 44 deletions src/cloudscribe.SimpleContent.Web/Controllers/PageController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -572,17 +572,34 @@ public virtual async Task<IActionResult> Edit(
}

Dictionary<string, bool?> editEditorialItems = EditEditorialItemsResolver(editContext.CurrentPage, editContext.Project);
PageEditViewModel model;

var model = new PageEditViewModel
if (editEditorialItems.Count > 0)
{
ProjectId = editContext.Project.Id,
DisqusShortname = editContext.Project.DisqusShortName,
ProjectDefaultSlug = editContext.Project.DefaultPageSlug,
ShowCreatedBy = editEditorialItems["ShowCreatedBy"],
ShowCreatedDate = editEditorialItems["ShowCreatedDate"],
ShowLastModifiedBy = editEditorialItems["ShowLastModifiedBy"],
ShowLastModifiedDate = editEditorialItems["ShowLastModifiedDate"]
};
model = new PageEditViewModel
{
ProjectId = editContext.Project.Id,
DisqusShortname = editContext.Project.DisqusShortName,
ProjectDefaultSlug = editContext.Project.DefaultPageSlug,
ShowCreatedBy = editEditorialItems["ShowCreatedBy"],
ShowCreatedDate = editEditorialItems["ShowCreatedDate"],
ShowLastModifiedBy = editEditorialItems["ShowLastModifiedBy"],
ShowLastModifiedDate = editEditorialItems["ShowLastModifiedDate"]
};
}
else
{
model = new PageEditViewModel
{
ProjectId = editContext.Project.Id,
DisqusShortname = editContext.Project.DisqusShortName,
ProjectDefaultSlug = editContext.Project.DefaultPageSlug,
ShowCreatedBy = null,
ShowCreatedDate = null,
ShowLastModifiedBy = null,
ShowLastModifiedDate = null
};
}

var routeVals = new RouteValueDictionary
{
Expand Down Expand Up @@ -1372,46 +1389,48 @@ public virtual async Task<IActionResult> CanEdit(CancellationToken cancellationT
{
Dictionary<string, bool?> showItems = [];

if (page.ShowCreatedBy.HasValue)
if (page != null) //check if new page
{
//page has setting so must have been overidden so use it
showItems.Add("ShowCreatedBy", (bool)page.ShowCreatedBy);
}
else
{
showItems.Add("ShowCreatedBy", null);
}
if (page.ShowCreatedBy != null && page.ShowCreatedBy.HasValue)
{
//page has setting so must have been overidden so use it
showItems.Add("ShowCreatedBy", (bool)page.ShowCreatedBy);
}
else
{
showItems.Add("ShowCreatedBy", null);
}

if (page.ShowCreatedDate.HasValue)
{
//page has setting so must have been overidden so use it
showItems.Add("ShowCreatedDate", (bool)page.ShowCreatedDate);
}
else
{
showItems.Add("ShowCreatedDate", null);
}
if (page.ShowCreatedDate != null && page.ShowCreatedDate.HasValue)
{
//page has setting so must have been overidden so use it
showItems.Add("ShowCreatedDate", (bool)page.ShowCreatedDate);
}
else
{
showItems.Add("ShowCreatedDate", null);
}

if (page.ShowLastModifiedBy.HasValue)
{
//page has setting so must have been overidden so use it
showItems.Add("ShowLastModifiedBy", (bool)page.ShowLastModifiedBy);
}
else
{
showItems.Add("ShowLastModifiedBy", null);
}
if (page.ShowLastModifiedBy != null && page.ShowLastModifiedBy.HasValue)
{
//page has setting so must have been overidden so use it
showItems.Add("ShowLastModifiedBy", (bool)page.ShowLastModifiedBy);
}
else
{
showItems.Add("ShowLastModifiedBy", null);
}

if (page.ShowLastModifiedDate.HasValue)
{
//page has setting so must have been overidden so use it
showItems.Add("ShowLastModifiedDate", (bool)page.ShowLastModifiedDate);
}
else
{
showItems.Add("ShowLastModifiedDate", null);
if (page.ShowLastModifiedDate != null && page.ShowLastModifiedDate.HasValue)
{
//page has setting so must have been overidden so use it
showItems.Add("ShowLastModifiedDate", (bool)page.ShowLastModifiedDate);
}
else
{
showItems.Add("ShowLastModifiedDate", null);
}
}

return showItems;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<PropertyGroup>
<Description>A simple, yet flexible content and blog engine for ASP.NET Core that can work with or without a database</Description>
<Version>8.0.4</Version>
<Version>8.0.5</Version>
<TargetFramework>net8.0</TargetFramework>
<Authors>Joe Audette</Authors>
<PackageTags>cloudscribe;blog,content</PackageTags>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"Id":"test-2","ProjectId":"f83067b4-919d-4910-acd1-4b3b1c210ecf","ParentId":"0","ParentSlug":"","PageOrder":23,"Title":"test 123","Author":"Admin","Slug":"test-2","ExternalUrl":null,"CorrelationKey":null,"MetaDescription":null,"MetaJson":null,"MetaHtml":null,"Content":"<p>testing, testing, 123</p>\r\n","PubDate":"2024-12-13T08:56:01.33245Z","LastModified":"2024-12-13T08:56:21.0955713Z","IsPublished":true,"MenuOnly":false,"ShowMenu":false,"ViewRoles":null,"Categories":[],"Comments":[],"ShowHeading":true,"ShowPubDate":false,"ShowLastModified":false,"ShowCategories":false,"ShowComments":false,"MenuFilters":null,"DisableEditor":false,"Resources":[],"ContentType":"html","CreatedUtc":"2024-12-13T08:56:01.3305956Z","CreatedByUser":"admin","LastModifiedByUser":"admin","DraftContent":null,"DraftAuthor":null,"DraftPubDate":null,"TemplateKey":null,"SerializedModel":null,"DraftSerializedModel":null,"Serializer":null,"ShowCreatedBy":null,"ShowCreatedDate":null,"ShowLastModifiedBy":null,"ShowLastModifiedDate":null}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"Id":"test-gallery","ProjectId":"f83067b4-919d-4910-acd1-4b3b1c210ecf","ParentId":"test-2","ParentSlug":"test-2","PageOrder":2,"Title":"test gallery","Author":"","Slug":"test-gallery","ExternalUrl":"","CorrelationKey":"","MetaDescription":"","MetaJson":null,"MetaHtml":null,"Content":"<div class=\"content-top\">\r\n \r\n</div>\r\n<div class=\"row gallery-block cards-gallery simple-gallery\">\r\n</div>\r\n<div class=\"content-bottom\">\r\n \r\n</div>\r\n\r\n\r\n\r\n","PubDate":null,"LastModified":"2024-12-13T08:56:36.7069859Z","IsPublished":false,"MenuOnly":false,"ShowMenu":false,"ViewRoles":"","Categories":[],"Comments":[],"ShowHeading":true,"ShowPubDate":false,"ShowLastModified":false,"ShowCategories":false,"ShowComments":false,"MenuFilters":null,"DisableEditor":false,"Resources":[],"ContentType":"html","CreatedUtc":"2024-12-13T08:56:36.6412535Z","CreatedByUser":"admin","LastModifiedByUser":"admin","DraftContent":null,"DraftAuthor":"Admin","DraftPubDate":null,"TemplateKey":"sct-GalleryWithContent","SerializedModel":null,"DraftSerializedModel":"{\"Layout\":\"GalleryWithContentRenderCardsPartial\",\"CarouselIntervalInMilliseconds\":5000,\"ContentAbove\":null,\"ContentBelow\":null,\"Items\":[]}","Serializer":"Json","ShowCreatedBy":null,"ShowCreatedDate":null,"ShowLastModifiedBy":null,"ShowLastModifiedDate":null}
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"AuthorBio":"","Comment":"","NormalizedEmail":"[email protected]","NormalizedUserName":"ADMIN","EmailConfirmed":true,"EmailConfirmSentUtc":null,"AgreementAcceptedUtc":null,"LockoutEndDateUtc":null,"NewEmail":"","NewEmailApproved":false,"LastPasswordChangeUtc":"2024-06-03T14:17:55.2771124Z","MustChangePwd":false,"PasswordHash":"AQAAAAIAAYagAAAAEGVnALS6pFN3EERYv0nYhCQ4jy0t3WB+uYVRUM40L55rqYdKv3yw1MmjWvEYd6x2Pw==","CanAutoLockout":true,"AccessFailedCount":0,"RolesChanged":false,"SecurityStamp":"S7ZJ6RCVYLDHBWTECX2S2GQXJKWUXNSL","Signature":"","TwoFactorEnabled":false,"BrowserKey":"fb4ead8f-7afd-4cd9-84b0-3718d71fa575","Id":"17595de8-d27a-4304-bded-76b61a16ad19","SiteId":"f83067b4-919d-4910-acd1-4b3b1c210ecf","Email":"[email protected]","UserName":"admin","DisplayName":"Admin","FirstName":"","LastName":"","AvatarUrl":"","DateOfBirth":null,"CreatedUtc":"2016-08-04T12:03:50.2175089Z","LastModifiedUtc":"2016-08-04T12:03:50.2175089Z","DisplayInMemberList":true,"Gender":"","IsLockedOut":false,"LastLoginUtc":"2024-11-27T08:52:25.2785938Z","PhoneNumber":"","PhoneNumberConfirmed":false,"AccountApproved":true,"TimeZoneId":"","WebSiteUrl":""}
{"AuthorBio":"","Comment":"","NormalizedEmail":"[email protected]","NormalizedUserName":"ADMIN","EmailConfirmed":true,"EmailConfirmSentUtc":null,"AgreementAcceptedUtc":null,"LockoutEndDateUtc":null,"NewEmail":"","NewEmailApproved":false,"LastPasswordChangeUtc":"2024-06-03T14:17:55.2771124Z","MustChangePwd":false,"PasswordHash":"AQAAAAIAAYagAAAAEGVnALS6pFN3EERYv0nYhCQ4jy0t3WB+uYVRUM40L55rqYdKv3yw1MmjWvEYd6x2Pw==","CanAutoLockout":true,"AccessFailedCount":0,"RolesChanged":false,"SecurityStamp":"S7ZJ6RCVYLDHBWTECX2S2GQXJKWUXNSL","Signature":"","TwoFactorEnabled":false,"BrowserKey":"73126636-c1ad-47c8-8f1d-9f229911e67a","Id":"17595de8-d27a-4304-bded-76b61a16ad19","SiteId":"f83067b4-919d-4910-acd1-4b3b1c210ecf","Email":"[email protected]","UserName":"admin","DisplayName":"Admin","FirstName":"","LastName":"","AvatarUrl":"","DateOfBirth":null,"CreatedUtc":"2016-08-04T12:03:50.2175089Z","LastModifiedUtc":"2016-08-04T12:03:50.2175089Z","DisplayInMemberList":true,"Gender":"","IsLockedOut":false,"LastLoginUtc":"2024-12-13T08:41:39.832239Z","PhoneNumber":"","PhoneNumberConfirmed":false,"AccountApproved":true,"TimeZoneId":"","WebSiteUrl":""}

0 comments on commit 3470beb

Please sign in to comment.