Skip to content

Commit 753d0a4

Browse files
committed
Hide TopicListViewComponent if no values are returned
There will always be at least one value—for the `DefaultLabel`—so if the `TopicList.Count` isn't greater than `1` then hide the attribute from the interface entirely. This includes hiding the `Layout`, as otherwise the attribute wrapper will be displayed without the dropdown list.
1 parent b727cf1 commit 753d0a4

1 file changed

Lines changed: 12 additions & 8 deletions

File tree

  • OnTopic.Editor.AspNetCore/Areas/Editor/Views/Editor/Components/TopicList
Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,18 @@
11
@model TopicListAttributeViewModel
22

33
@{
4+
if (Model.TopicList.Count > 1) {
45
Layout = "~/Areas/Editor/Views/Editor/Components/_Layout.cshtml";
6+
}
57
}
68

7-
<select
8-
asp-for ="Value"
9-
asp-items ="Model.TopicList"
10-
class ="@Model.AttributeDescriptor.CssClass form-control form-inline"
11-
disabled =@(!Model.AttributeDescriptor.IsEnabled)
12-
required =@Model.AttributeDescriptor.IsRequired
13-
>
14-
</select>
9+
@if (Model.TopicList.Count > 1) {
10+
<select
11+
asp-for ="Value"
12+
asp-items ="Model.TopicList"
13+
class ="@Model.AttributeDescriptor.CssClass form-control form-inline"
14+
disabled =@(!Model.AttributeDescriptor.IsEnabled)
15+
required =@Model.AttributeDescriptor.IsRequired
16+
>
17+
</select>
18+
}

0 commit comments

Comments
 (0)