Skip to content

Commit 9b21224

Browse files
committed
Merge branch 'bugfix/SelectableTreeView' into develop
Previously, there was a bug where multiple instances of a `SelectableTreeView` on a single page would not work correctly. This occurred, for instance, when multiple relationship attributes were defined for a single Content Type (either directly, or via attribute inheritance). While this scenario is rare, it should be supported. In this case, only the data from the first tree would render—but it would be associated with the attribute and backing field of the last tree, which made this bug especially confusing and potentially problematic in terms of data integrity. This was ultimately caused by the `root` node being stored as part of the `OnTopic.SelectableTreeView.defaults` object, which is shared between multiple instances. By moving the creation of a new `AsyncTreeNode` object for the root into the `OnTopic.SelectableTreeView` constructor, this is mitigated, and multiple `SelectableTreeView` instances can once again live peacefully on one topic. This resolves Issue #6.
2 parents eaf9b59 + d8c2133 commit 9b21224

3 files changed

Lines changed: 16 additions & 13 deletions

File tree

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

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@
1717
}
1818

1919
<vc:tokenized-topic-list
20-
current-topic=@Model.CurrentTopic
21-
html-field-prefix=@ViewData.TemplateInfo.HtmlFieldPrefix
22-
attribute=@attributeDescriptor>
20+
current-topic =@Model.CurrentTopic
21+
html-field-prefix =@ViewData.TemplateInfo.HtmlFieldPrefix
22+
attribute =@attributeDescriptor
23+
>
2324
</vc:tokenized-topic-list>

OnTopic.Editor.AspNetCore/Shared/Scripts/DraggableTreeView.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,8 @@ OnTopic.DraggableTreeView = Ext.extend(Ext.tree.TreePanel, {
5050
| Move on server
5151
\-------------------------------------------------------------------------------------------------------------------------*/
5252
$.ajax({
53-
method: "POST",
54-
url: "/OnTopic/Move",
53+
method : "POST",
54+
url : "/OnTopic/Move",
5555
data: {
5656
topicId : node.attributes.id,
5757
targetTopicId : newParent.attributes.id,

OnTopic.Editor.AspNetCore/Shared/Scripts/SelectableTreeView.js

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,16 @@ OnTopic.SelectableTreeView = Ext.extend(Ext.tree.TreePanel, {
6161
\-------------------------------------------------------------------------------------------------------------------------*/
6262
Ext.apply(this, options, OnTopic.SelectableTreeView.defaults);
6363

64+
/*--------------------------------------------------------------------------------------------------------------------------
65+
| Initialize root
66+
\-------------------------------------------------------------------------------------------------------------------------*/
67+
this.root = new Ext.tree.AsyncTreeNode({
68+
checked : true,
69+
text : 'Web',
70+
draggable : false,
71+
leaf : false
72+
});
73+
6474
/*--------------------------------------------------------------------------------------------------------------------------
6575
| Initialize variables
6676
\-------------------------------------------------------------------------------------------------------------------------*/
@@ -100,20 +110,12 @@ OnTopic.SelectableTreeView = Ext.extend(Ext.tree.TreePanel, {
100110
| DEFAULTS
101111
\-----------------------------------------------------------------------------------------------------------------------------*/
102112
OnTopic.SelectableTreeView.defaults = {
103-
id : 'relatedTree',
104113
useArrows : true,
105114
autoScroll : true,
106115
animate : true,
107116
enableDD : false,
108117
containerScroll : true,
109118
border : false,
110119
baseCls : 'RelationshipsTreeView',
111-
root : new Ext.tree.AsyncTreeNode({
112-
checked : true,
113-
text : 'Web',
114-
draggable : false,
115-
id : 'related',
116-
leaf : false
117-
}),
118120
rootVisible : false
119121
};

0 commit comments

Comments
 (0)