Comments: Creating separate Comments.Count Detail display shape so it can be overridden without overriding ListOfComments

It's a breaking change, because Parts.Comments.Count was used for Summary display,
but it's now for Detail display and a separate Parts.Comments.Count.Summary was added.
This commit is contained in:
Lombiq
2019-08-22 17:46:56 +02:00
committed by Benedek Farkas
parent 0913d78951
commit 035a47a911
6 changed files with 24 additions and 18 deletions

View File

@@ -70,14 +70,10 @@ namespace Orchard.Comments.Drivers {
return shapeHelper.Parts_CommentForm(EditorShape: editorShape, CanStillComment: _commentService.CanStillCommentOn(part));
}),
ContentShape("Parts_Comments_Count",
() => {
if (part.CommentsShown == false)
return null;
return shapeHelper.Parts_Comments_Count(
CommentCount: part.CommentsCount);
}),
ContentShape("Parts_Comments_Count", () =>
part.CommentsShown ? shapeHelper.Parts_Comments_Count(CommentCount: part.CommentsCount) : null),
ContentShape("Parts_Comments_Count_Summary", () =>
part.CommentsShown ? shapeHelper.Parts_Comments_Count_Summary(CommentCount: part.CommentsCount) : null),
ContentShape("Parts_Comments_Count_SummaryAdmin",
() => {

View File

@@ -231,6 +231,9 @@
<ItemGroup>
<Content Include="Assets.json" />
</ItemGroup>
<ItemGroup>
<Content Include="Views\Parts.Comments.Count.Summary.cshtml" />
</ItemGroup>
<PropertyGroup>
<VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">10.0</VisualStudioVersion>
<VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath>

View File

@@ -3,6 +3,7 @@
<!--
Parts_Comments
Parts_Comments_Count
Parts_Comments_Count_Summary
Parts_Comments_Count_SummaryAdmin
-->
<!-- widget and edit shapes just get default placement -->
@@ -17,17 +18,23 @@
<Place Content_SaveButton="-"/><!--Show default save button only on admin-->
</Match>
<Match DisplayType="Detail">
<Place Parts_ListOfComments="Content:10.2" />
<Place Parts_CommentForm="Content:10.3" />
</Match>
<Match ContentPart="CommentsPart">
<Match DisplayType="Detail">
<Place Parts_Comments_Count="Content:10.1"
Parts_ListOfComments="Content:10.2"
Parts_CommentForm="Content:10.3" />
</Match>
<Match DisplayType="Summary">
<Place Parts_Comments_Count="Meta:5" />
<Match DisplayType="Summary">
<Place Parts_Comments_Count_Summary="Meta:5" />
</Match>
<Match DisplayType="SummaryAdmin">
<Place Parts_Comments_Count_SummaryAdmin="Meta:4" />
</Match>
</Match>
<Match DisplayType="SummaryAdmin">
<Place Parts_Comment_SummaryAdmin="Actions:6"
Parts_Comments_Count_SummaryAdmin="Meta:4" />
<Place Parts_Comment_SummaryAdmin="Actions:6" />
</Match>
</Placement>

View File

@@ -0,0 +1 @@
<span class="comment-count">@T.Plural("No Comments", "1 Comment", "{0} Comments", (int)Model.CommentCount)</span>

View File

@@ -1 +1 @@
<span class="comment-count">@T.Plural("No Comments", "1 Comment", "{0} Comments", (int)Model.CommentCount)</span>
<h2 class="comment-count">@T.Plural("No Comments", "1 Comment", "{0} Comments", (int)Model.CommentCount)</h2>

View File

@@ -7,7 +7,6 @@
Model.List.Id = string.Format("comments_{0}", commentsPart.ContentItem.Id);
}
<h2 class="comment-count">@T.Plural("No Comments", "1 Comment", "{0} Comments", (int)Model.CommentCount)</h2>
@Display(Model.List)
@* render reply button if threaded comments enabled *@