@@ -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 }
0 commit comments