Skip to content

Commit 2123dfa

Browse files
committed
Implemented variables to simplify references
To improve readability, established a couple of variables in order to simplify complex references that were repeated within the code.
1 parent bad41b4 commit 2123dfa

1 file changed

Lines changed: 9 additions & 5 deletions

File tree

  • OnTopic.Editor.AspNetCore/Areas/Editor/Views/Editor/Components/Relationship

OnTopic.Editor.AspNetCore/Areas/Editor/Views/Editor/Components/Relationship/Default.cshtml

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,15 @@
22

33
@{
44
Layout = "~/Areas/Editor/Views/Editor/Components/_Layout.cshtml";
5-
var rootTopicKey = Model.AttributeDescriptor.RootTopic?.UniqueKey.Replace(":", "/") ?? Model.AttributeDescriptor.RootTopicKey?.Replace(":", "/") ?? "Root";
5+
6+
var descriptor = Model.AttributeDescriptor;
7+
var rootTopicKey = descriptor.RootTopic?.UniqueKey.Replace(":", "/")?? descriptor.RootTopicKey?.Replace(":", "/")?? "Root";
8+
var containerName = ViewData.TemplateInfo.GetFullHtmlFieldName("TreeView");
9+
610
}
711

812
<input asp-for="Value" type="hidden" />
9-
<div id="@ViewData.TemplateInfo.GetFullHtmlFieldName("TreeView")"></div>
13+
<div id="@containerName"></div>
1014

1115
<script type="text/javascript">
1216
Ext.onReady(function(){
@@ -23,7 +27,7 @@
2327
containerScroll : true,
2428
border : false,
2529
baseCls : 'RelationshipsTreeView',
26-
dataUrl : '/OnTopic/Json/@rootTopicKey?ShowRoot=@Model.AttributeDescriptor.ShowRoot&ShowAll=true&RelatedNamespace=@Model.AttributeDescriptor.Key&RelatedTopicID=@Model.CurrentTopic.Id&AttributeName=@Model.AttributeDescriptor.AttributeKey&AttributeValue=@Model.AttributeDescriptor.AttributeValue',
30+
dataUrl : '/OnTopic/Json/@rootTopicKey?ShowRoot=@descriptor.ShowRoot&ShowAll=true&RelatedNamespace=@descriptor.Key&RelatedTopicID=@Model.CurrentTopic.Id&AttributeName=@descriptor.AttributeKey&AttributeValue=@descriptor.AttributeValue',
2731
root : new Ext.tree.AsyncTreeNode({
2832
checked : true,
2933
text : 'Web',
@@ -46,12 +50,12 @@
4650
relationships.remove(node.attributes.id.toString());
4751
}
4852
Storage.dom.value = relationships.concat(",");
49-
@(Model.AttributeDescriptor.CheckAscendants is true? "" : "return true")
53+
@(descriptor.CheckAscendants is true? "" : "return true")
5054
if (checked && node.parentNode) node.parentNode.getUI().toggleCheck(true);
5155
}
5256
}
5357
});
54-
tree.render('@ViewData.TemplateInfo.GetFullHtmlFieldName("TreeView")');
58+
tree.render('@containerName');
5559
5660
});
5761
</script>

0 commit comments

Comments
 (0)