Skip to content

Commit 7bcd4a3

Browse files
committed
Excluded relationships and nested topics from ReflexiveAttribute
In general, the use cases for the `ReflexiveAttribute`—such as a `DefaultValue` or an `ImplicitValue`—don't really make sense with relationships or nested topics. We may revisit this later, but for now we're excluding `AttributeDescriptorViewModel`s with a `ModelType` of either `Relationship` or `NestedTopic`. As part of this, I refactored the `isReflexive` variable to a new `isSupported` variable, which relies on the `Model.AttributeDescriptor.ModelType` instead of the `Model.CurrentTopic.ContentType`. This effectively accomplishes the same thing, but allows isn't specific to any one attribute type, instead factoring in how the data is stored. This finalize the implementation of #44.
1 parent 0a216eb commit 7bcd4a3

1 file changed

Lines changed: 11 additions & 5 deletions

File tree

  • OnTopic.Editor.AspNetCore.Attributes/Views/Editor/Components/Reflexive

OnTopic.Editor.AspNetCore.Attributes/Views/Editor/Components/Reflexive/Default.cshtml

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,19 @@
1-
@model AttributeViewModel<AttributeDescriptorViewModel>
1+
@using OnTopic.Metadata;
2+
@model AttributeViewModel<AttributeDescriptorViewModel>
23

34
@{
4-
var isReflexive = Model.CurrentTopic.ContentType == "ReflexiveAttributeDescriptor" || !Model.CurrentTopic.ContentType.EndsWith("AttributeDescriptor");
5-
if (isReflexive) {
6-
Layout = "~/Areas/Editor/Views/Editor/Components/_Layout.cshtml";
5+
6+
var excludedModelTypes = new ModelType[] { ModelType.Reflexive, ModelType.Relationship, ModelType.NestedTopic };
7+
var modelType = Model.AttributeDescriptor.ModelType;
8+
var isSupported = !excludedModelTypes.Contains(modelType);
9+
10+
if (!isSupported) {
11+
Layout = "~/Areas/Editor/Views/Editor/Components/_Layout.cshtml";
712
}
13+
814
}
915

10-
@if (!isReflexive) {
16+
@if (isSupported) {
1117
<text>
1218
@await Component.InvokeAsync(
1319
Model.CurrentTopic.ContentType.Replace("AttributeDescriptor", ""),

0 commit comments

Comments
 (0)