Skip to content

Commit 3470beb

Browse files
authored
Merge pull request #617 from cloudscribe/feature/616
#616 updates to pagecontroller as 'Edit' is actually used when a page…
2 parents 9965cc9 + ff7f2ee commit 3470beb

5 files changed

Lines changed: 67 additions & 46 deletions

File tree

src/cloudscribe.SimpleContent.Web/Controllers/PageController.cs

Lines changed: 63 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -572,17 +572,34 @@ public virtual async Task<IActionResult> Edit(
572572
}
573573

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

576-
var model = new PageEditViewModel
577+
if (editEditorialItems.Count > 0)
577578
{
578-
ProjectId = editContext.Project.Id,
579-
DisqusShortname = editContext.Project.DisqusShortName,
580-
ProjectDefaultSlug = editContext.Project.DefaultPageSlug,
581-
ShowCreatedBy = editEditorialItems["ShowCreatedBy"],
582-
ShowCreatedDate = editEditorialItems["ShowCreatedDate"],
583-
ShowLastModifiedBy = editEditorialItems["ShowLastModifiedBy"],
584-
ShowLastModifiedDate = editEditorialItems["ShowLastModifiedDate"]
585-
};
579+
model = new PageEditViewModel
580+
{
581+
ProjectId = editContext.Project.Id,
582+
DisqusShortname = editContext.Project.DisqusShortName,
583+
ProjectDefaultSlug = editContext.Project.DefaultPageSlug,
584+
ShowCreatedBy = editEditorialItems["ShowCreatedBy"],
585+
ShowCreatedDate = editEditorialItems["ShowCreatedDate"],
586+
ShowLastModifiedBy = editEditorialItems["ShowLastModifiedBy"],
587+
ShowLastModifiedDate = editEditorialItems["ShowLastModifiedDate"]
588+
};
589+
}
590+
else
591+
{
592+
model = new PageEditViewModel
593+
{
594+
ProjectId = editContext.Project.Id,
595+
DisqusShortname = editContext.Project.DisqusShortName,
596+
ProjectDefaultSlug = editContext.Project.DefaultPageSlug,
597+
ShowCreatedBy = null,
598+
ShowCreatedDate = null,
599+
ShowLastModifiedBy = null,
600+
ShowLastModifiedDate = null
601+
};
602+
}
586603

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

1375-
if (page.ShowCreatedBy.HasValue)
1392+
if (page != null) //check if new page
13761393
{
1377-
//page has setting so must have been overidden so use it
1378-
showItems.Add("ShowCreatedBy", (bool)page.ShowCreatedBy);
1379-
}
1380-
else
1381-
{
1382-
showItems.Add("ShowCreatedBy", null);
1383-
}
1394+
if (page.ShowCreatedBy != null && page.ShowCreatedBy.HasValue)
1395+
{
1396+
//page has setting so must have been overidden so use it
1397+
showItems.Add("ShowCreatedBy", (bool)page.ShowCreatedBy);
1398+
}
1399+
else
1400+
{
1401+
showItems.Add("ShowCreatedBy", null);
1402+
}
13841403

1385-
if (page.ShowCreatedDate.HasValue)
1386-
{
1387-
//page has setting so must have been overidden so use it
1388-
showItems.Add("ShowCreatedDate", (bool)page.ShowCreatedDate);
1389-
}
1390-
else
1391-
{
1392-
showItems.Add("ShowCreatedDate", null);
1393-
}
1404+
if (page.ShowCreatedDate != null && page.ShowCreatedDate.HasValue)
1405+
{
1406+
//page has setting so must have been overidden so use it
1407+
showItems.Add("ShowCreatedDate", (bool)page.ShowCreatedDate);
1408+
}
1409+
else
1410+
{
1411+
showItems.Add("ShowCreatedDate", null);
1412+
}
13941413

1395-
if (page.ShowLastModifiedBy.HasValue)
1396-
{
1397-
//page has setting so must have been overidden so use it
1398-
showItems.Add("ShowLastModifiedBy", (bool)page.ShowLastModifiedBy);
1399-
}
1400-
else
1401-
{
1402-
showItems.Add("ShowLastModifiedBy", null);
1403-
}
1414+
if (page.ShowLastModifiedBy != null && page.ShowLastModifiedBy.HasValue)
1415+
{
1416+
//page has setting so must have been overidden so use it
1417+
showItems.Add("ShowLastModifiedBy", (bool)page.ShowLastModifiedBy);
1418+
}
1419+
else
1420+
{
1421+
showItems.Add("ShowLastModifiedBy", null);
1422+
}
14041423

1405-
if (page.ShowLastModifiedDate.HasValue)
1406-
{
1407-
//page has setting so must have been overidden so use it
1408-
showItems.Add("ShowLastModifiedDate", (bool)page.ShowLastModifiedDate);
1409-
}
1410-
else
1411-
{
1412-
showItems.Add("ShowLastModifiedDate", null);
1424+
if (page.ShowLastModifiedDate != null && page.ShowLastModifiedDate.HasValue)
1425+
{
1426+
//page has setting so must have been overidden so use it
1427+
showItems.Add("ShowLastModifiedDate", (bool)page.ShowLastModifiedDate);
1428+
}
1429+
else
1430+
{
1431+
showItems.Add("ShowLastModifiedDate", null);
1432+
}
14131433
}
1414-
14151434
return showItems;
14161435
}
14171436
}

src/cloudscribe.SimpleContent.Web/cloudscribe.SimpleContent.Web.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
<PropertyGroup>
44
<Description>A simple, yet flexible content and blog engine for ASP.NET Core that can work with or without a database</Description>
5-
<Version>8.0.4</Version>
5+
<Version>8.0.5</Version>
66
<TargetFramework>net8.0</TargetFramework>
77
<Authors>Joe Audette</Authors>
88
<PackageTags>cloudscribe;blog,content</PackageTags>
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
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}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
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 numberDiff line numberDiff line change
@@ -1 +1 @@
1-
{"AuthorBio":"","Comment":"","NormalizedEmail":"ADMIN@ADMIN.COM","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":"admin@admin.com","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":""}
1+
{"AuthorBio":"","Comment":"","NormalizedEmail":"ADMIN@ADMIN.COM","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":"admin@admin.com","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 commit comments

Comments
 (0)