Skip to content

Commit 2f44fc1

Browse files
committed
Introduced the ReflexiveAttribute view
The `ReflexiveAttribute` view is pretty straight forward: It simply invokes the attribute type view component associated with the `CurrentTopic` (which we assume to be an `AttributeDescriptor`) If the `CurrentTopic` is _not_ an `AttributeDescriptor`, or it is the `ReflexiveAttribute` itself, a warning is displayed. Otherwise, the `CurrentTopic` is rendered as a view component, thus reflecting itself, and fulfilling the requirements of #44.
1 parent 3efa14f commit 2f44fc1

1 file changed

Lines changed: 22 additions & 0 deletions

File tree

  • OnTopic.Editor.AspNetCore.Attributes/Views/Editor/Components/Reflexive
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
@model AttributeViewModel<AttributeDescriptorViewModel>
2+
3+
@{
4+
var isReflexive = Model.CurrentTopic.ContentType == "ReflexiveAttributeDescriptor" || !Model.CurrentTopic.ContentType.EndsWith("AttributeDescriptor");
5+
if (isReflexive) {
6+
Layout = "~/Areas/Editor/Views/Editor/Components/_Layout.cshtml";
7+
}
8+
}
9+
10+
@if (!isReflexive) {
11+
<text>
12+
@await Component.InvokeAsync(
13+
Model.CurrentTopic.ContentType.Replace("AttributeDescriptor", ""),
14+
new { CurrentTopic = Model.CurrentTopic, Attribute = Model.AttributeDescriptor, HtmlFieldPrefix = Html.ViewData.TemplateInfo.HtmlFieldPrefix }
15+
)
16+
</text>
17+
}
18+
else {
19+
<div class="alert alert-warning" role="alert">
20+
<strong>Note:</strong> This attribute cannot be displayed on topics implementing the @Model.CurrentTopic.ContentType content type.
21+
</div>
22+
}

0 commit comments

Comments
 (0)