-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Maintenance release including a number of bug fixes, including those implemented in the corresponding release of the OnTopic Library 4.2.0. Of most relevance to the editor, this includes: 1. Allowing rollback of versions created since the application was last reset (37eb773) 2. Correctly refreshing the page or topic tree when moving a topic to ensure URLs are updated (a33a950) 3. Disabling required field validation for topics derived from other topics (5044e46) 4. Setting the HTML (browser) title to the name of the current topic (1ba3931) In addition to these bug fixes, there was significant refactoring of the legacy `Ext.tree.TreePanel` dependencies. These were each configured using scripts inside the views, which were difficult to validate and debug, and weren't cached. These have since been refactored as ExtJS classes using `Ext.extend()`, and rolled up into the main `Scripts.js` distribution. This code is much easier to read and update as it lends itself to a more standard commenting structure, with configuration properties and defaults separated from event properties and fields specific to the current class. It also provides better separation of backend variables by forcing them to be parameterized, instead of modifying the output of the JavaScript inside the view.
- Loading branch information
Showing
85 changed files
with
833 additions
and
573 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -40,4 +40,4 @@ public static IHostBuilder CreateHostBuilder(string[] args) => | |
}); | ||
|
||
} //Class | ||
} //Namespace | ||
} //Namespace |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,4 +5,4 @@ | |
} | ||
}, | ||
"AllowedHosts": "*" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
159 changes: 58 additions & 101 deletions
159
...pic.Editor.AspNetCore/Areas/Editor/Views/Editor/Components/NestedTopicList/Default.cshtml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,122 +1,79 @@ | ||
@model NestedTopicListAttributeViewModel | ||
|
||
@{ | ||
Layout = "~/Areas/Editor/Views/Editor/Components/_Layout.cshtml"; | ||
} | ||
|
||
<script type="text/javascript"> | ||
var @($"{Model.AttributeDescriptor.Key}Tree"); | ||
Ext.onReady(function(){ | ||
var Tree = Ext.tree; | ||
Layout = "~/Areas/Editor/Views/Editor/Components/_Layout.cshtml"; | ||
|
||
//track what nodes are moved | ||
var oldPosition = null; | ||
var oldNextSibling = null; | ||
var debugMessage = ""; | ||
var attributeKey = Model.AttributeDescriptor.Key; | ||
var containerName = ViewData.TemplateInfo.GetFullHtmlFieldName("Container"); | ||
var treeName = attributeKey + "Tree"; | ||
|
||
@($"{Model.AttributeDescriptor.Key}Tree") = new Tree.TreePanel({ | ||
useArrows : true, | ||
autoScroll : true, | ||
animate : false, | ||
enableDD : true, | ||
containerScroll : true, | ||
border : false, | ||
baseCls : 'treeview', | ||
dataUrl : '/OnTopic/Json/@Model.WebPath/@Model.AttributeDescriptor.Key?ShowAll=true', | ||
root : new Ext.tree.AsyncTreeNode({}), | ||
rootVisible : false, | ||
listeners : { | ||
click: function (n) { | ||
var targetUrl = "@($"{Url.Action("Edit")}/{Model.AttributeDescriptor.Key}/")" + n.attributes.key; | ||
@if (Model.AttributeDescriptor.EnableModal?? true) { | ||
<text> | ||
initEditorModal('@Model.AttributeDescriptor.Key', n.attributes.text, targetUrl + '?IsModal=true', @($"{Model.AttributeDescriptor.Key}Tree_refresh"));return false; | ||
</text> | ||
} | ||
else { | ||
<text> | ||
location.href = targetUrl; | ||
</text> | ||
} | ||
}, | ||
startdrag : function(tree, node, event) { | ||
oldPosition = node.parentNode.indexOf(node); | ||
oldNextSibling = node.nextSibling; | ||
}, | ||
nodedragover : function(dragOverEvent) { | ||
return dragOverEvent.point !== "append"; | ||
}, | ||
movenode : function(tree, node, oldParent, newParent, position) { | ||
} | ||
|
||
var params = {'node':node.id, 'delta':(position-oldPosition)}; | ||
@if (!Model.IsNew) { | ||
|
||
//Determine sibling ID to place node after, based off position | ||
var siblingId = -1; | ||
if (position > 0) { | ||
siblingId = newParent.childNodes[position-1].id; | ||
<div id="@containerName"></div> | ||
|
||
<script type="text/javascript"> | ||
var @($"{treeName}"); | ||
|
||
Ext.onReady(function () { | ||
|
||
@($"{treeName}") = new OnTopic.NestedTopics('@Model.UniqueKey', { | ||
dataUrl : '/OnTopic/Json/@Model.WebPath/@attributeKey?ShowAll=true', | ||
listeners : { | ||
click : function (n) { | ||
var targetUrl = "@($"{Url.Action("Edit")}/{attributeKey}/")" + n.attributes.key; | ||
@if (Model.AttributeDescriptor.EnableModal?? true) { | ||
<text> | ||
initEditorModal('@attributeKey', n.attributes.text, targetUrl + '?IsModal=true', @($"{treeName}.refresh"));return false; | ||
</text> | ||
} | ||
else { | ||
<text> | ||
location.href = targetUrl; | ||
</text> | ||
} | ||
} | ||
} | ||
}); | ||
|
||
//Ext.Msg.alert("Debugging", "Node: " + node.attributes.id + ", OldParent: " + oldParent.attributes.id + ", Parent: " + newParent.attributes.id + ", Sibling: " + siblingId); | ||
$.ajax({ | ||
method: "POST", | ||
url: "/OnTopic/Move", | ||
data: { topicId: node.attributes.id, targetTopicId: -1, siblingId } | ||
}) | ||
@($"{treeName}").render('@containerName'); | ||
|
||
} | ||
} | ||
}); | ||
|
||
@if (!Model.IsNew) { | ||
<text> | ||
@($"{Model.AttributeDescriptor.Key}Tree").render('@ViewData.TemplateInfo.GetFullHtmlFieldName("Container")'); | ||
</text> | ||
} | ||
}); | ||
</script> | ||
|
||
function @($"{Model.AttributeDescriptor.Key}Tree")_refresh() { | ||
@($"{Model.AttributeDescriptor.Key}Tree").getLoader().load(@($"{Model.AttributeDescriptor.Key}Tree").root); | ||
}; | ||
<vc:content-type-list | ||
current-topic =@Model.CurrentTopic | ||
attribute-descriptor =@Model.AttributeDescriptor | ||
on-modal-close =@($"{treeName}.refresh") | ||
values =@Model.AttributeDescriptor.PermittedContentTypes> | ||
</vc:content-type-list> | ||
|
||
<div id="@($"EditorModal_{attributeKey}")" class="modal fade" tabindex="-1" role="dialog" aria-hidden="true"> | ||
<div class="modal-dialog modal-lg"> | ||
<div class="modal-header page title"> | ||
<h2 id="@($"ModalTitle_{attributeKey}")"><!-- determined by modal open script caller --></h2> | ||
</div> | ||
<div class="modal-content"> | ||
<iframe id="@($"EditorFrame_{attributeKey}")" src="" width="100%" marginheight="0" frameborder="0"> | ||
<!-- iframe source determined by modal open script caller --> | ||
</iframe> | ||
</div> | ||
</div> | ||
</div> | ||
|
||
<script> | ||
$(function() { | ||
$('[id^="EditorModal"]').on('hide.bs.modal', function (e) { | ||
@($"{treeName}.refresh")(); | ||
}); | ||
}); | ||
</script> | ||
|
||
<div id="@ViewData.TemplateInfo.GetFullHtmlFieldName("Container")"></div> | ||
@if (!Model.IsNew) { | ||
<text> | ||
<vc:content-type-list | ||
current-topic =@Model.CurrentTopic | ||
attribute-descriptor =@Model.AttributeDescriptor | ||
on-modal-close =@($"{Model.AttributeDescriptor.Key}Tree_refresh") | ||
values =@Model.AttributeDescriptor.PermittedContentTypes> | ||
</vc:content-type-list> | ||
</text> | ||
} | ||
else { | ||
<div class="alert alert-warning"> | ||
Subtopics cannot be created until this topic has been saved. Save the topic, then add nested topics. | ||
</div> | ||
} | ||
<div id="@($"EditorModal_{Model.AttributeDescriptor.Key}")" class="modal fade" tabindex="-1" role="dialog" aria-hidden="true"> | ||
<div class="modal-dialog modal-lg"> | ||
<div class="modal-header page title"> | ||
<h2 id="@($"ModalTitle_{Model.AttributeDescriptor.Key}")"><!-- determined by modal open script caller --></h2> | ||
</div> | ||
<div class="modal-content"> | ||
<iframe id="@($"EditorFrame_{Model.AttributeDescriptor.Key}")" src="" width="100%" marginheight="0" frameborder="0"> | ||
<!-- iframe source determined by modal open script caller --> | ||
</iframe> | ||
</div> | ||
</div> | ||
</div> | ||
<script> | ||
$(function() { | ||
$('[id^="EditorModal"]').on('hide.bs.modal', function (e) { | ||
@($"{Model.AttributeDescriptor.Key}Tree_refresh")(); | ||
}); | ||
}); | ||
</script> | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,56 +2,24 @@ | |
|
||
@{ | ||
Layout = "~/Areas/Editor/Views/Editor/Components/_Layout.cshtml"; | ||
var rootTopicKey = Model.AttributeDescriptor.RootTopic?.UniqueKey.Replace(":", "/") ?? Model.AttributeDescriptor.RootTopicKey?.Replace(":", "/") ?? "Root"; | ||
|
||
var descriptor = Model.AttributeDescriptor; | ||
var rootTopicKey = descriptor.RootTopic?.UniqueKey.Replace(":", "/")?? descriptor.RootTopicKey?.Replace(":", "/")?? "Root"; | ||
var containerName = ViewData.TemplateInfo.GetFullHtmlFieldName("TreeView"); | ||
|
||
} | ||
|
||
<input asp-for="Value" type="hidden" /> | ||
<div id="@ViewData.TemplateInfo.GetFullHtmlFieldName("TreeView")"></div> | ||
|
||
<div id="@containerName"></div> | ||
|
||
<script type="text/javascript"> | ||
Ext.onReady(function(){ | ||
var Tree = Ext.tree; | ||
var Storage = Ext.get("@Html.IdFor(m => m.Value)"); | ||
var relationships = Storage.dom.value.split(","); | ||
tree = new Tree.TreePanel({ | ||
id : 'relatedTree', | ||
useArrows : true, | ||
autoScroll : true, | ||
animate : true, | ||
enableDD : false, | ||
containerScroll : true, | ||
border : false, | ||
baseCls : 'RelationshipsTreeView', | ||
dataUrl : '/OnTopic/Json/@[email protected]&ShowAll=true&[email protected]&[email protected]&[email protected]&[email protected]', | ||
root : new Ext.tree.AsyncTreeNode({ | ||
checked : true, | ||
text : 'Web', | ||
draggable : false, | ||
id : 'related', | ||
leaf : false | ||
}), | ||
rootVisible : false, | ||
listeners : { | ||
click : function(node) { | ||
node.checked = true; | ||
node.select(); | ||
return true; | ||
}, | ||
checkchange : function(node, checked) { | ||
if (checked) { | ||
relationships.push(node.attributes.id.toString()); | ||
} | ||
else { | ||
relationships.remove(node.attributes.id.toString()); | ||
} | ||
Storage.dom.value = relationships.concat(","); | ||
@(Model.AttributeDescriptor.CheckAscendants is true? "" : "return true") | ||
if (checked && node.parentNode) node.parentNode.getUI().toggleCheck(true); | ||
} | ||
} | ||
var tree = new OnTopic.SelectableTreeView({ | ||
dataUrl : '/OnTopic/Json/@[email protected]&ShowAll=true&[email protected]&[email protected]&[email protected]&[email protected]', | ||
checkAscendants : @((descriptor.CheckAscendants is true).ToString().ToLower()), | ||
backingField : '@Html.IdFor(m => m.Value)' | ||
}); | ||
tree.render('@ViewData.TemplateInfo.GetFullHtmlFieldName("TreeView")'); | ||
tree.render('@containerName'); | ||
}); | ||
</script> |
Oops, something went wrong.