Skip to content

Commit

Permalink
Merge branch 'release/4.2.0'
Browse files Browse the repository at this point in the history
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
JeremyCaney committed Apr 22, 2020
2 parents 3aa2d24 + c696e7a commit 1fc52c0
Show file tree
Hide file tree
Showing 85 changed files with 833 additions and 573 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="OnTopic" Version="4.1.0" />
<PackageReference Include="OnTopic.ViewModels" Version="4.1.0" />
<PackageReference Include="OnTopic.AspNetCore.Mvc" Version="4.1.0" />
<PackageReference Include="OnTopic.Data.Caching" Version="4.1.0" />
<PackageReference Include="OnTopic.Data.Sql" Version="4.1.0" />
<PackageReference Include="OnTopic" Version="4.2.0" />
<PackageReference Include="OnTopic.ViewModels" Version="4.2.0" />
<PackageReference Include="OnTopic.AspNetCore.Mvc" Version="4.2.0" />
<PackageReference Include="OnTopic.Data.Caching" Version="4.2.0" />
<PackageReference Include="OnTopic.Data.Sql" Version="4.2.0" />
</ItemGroup>

<ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion OnTopic.Editor.AspNetCore.Host/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,4 +40,4 @@ public static IHostBuilder CreateHostBuilder(string[] args) =>
});

} //Class
} //Namespace
} //Namespace
2 changes: 1 addition & 1 deletion OnTopic.Editor.AspNetCore.Host/Startup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -142,4 +142,4 @@ public static void Configure(IApplicationBuilder app, IWebHostEnvironment env) {
}

} //Class
} //Namespace
} //Namespace
2 changes: 1 addition & 1 deletion OnTopic.Editor.AspNetCore.Host/Web.config
Original file line number Diff line number Diff line change
Expand Up @@ -61,4 +61,4 @@
<compiler language="vb;vbs;visualbasic;vbscript" extension=".vb" type="Microsoft.CodeDom.Providers.DotNetCompilerPlatform.VBCodeProvider, Microsoft.CodeDom.Providers.DotNetCompilerPlatform, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" warningLevel="4" compilerOptions="/langversion:default /nowarn:41008 /define:_MYTYPE=\&quot;Web\&quot; /optionInfer+"/>
</compilers>
</system.codedom>
</configuration>
</configuration>
2 changes: 1 addition & 1 deletion OnTopic.Editor.AspNetCore.Host/appsettings.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@
}
},
"AllowedHosts": "*"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,4 @@
<label class="form-check-label">
<input type="radio" asp-for="Value" value="Mobile" class="form-check-input" disabled=@(!Model.AttributeDescriptor.IsEnabled) required=@Model.AttributeDescriptor.IsRequired /> Mobile
</label>
</div>
</div>
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@
placeholder =@Model.InheritedValue
disabled =@(!Model.AttributeDescriptor.IsEnabled)
required =@Model.AttributeDescriptor.IsRequired
/>
/>
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@

<style type="text/css">
.Content div.x-tab-panel {
margin-top: 30px;
margin-top : 30px;
}
.Content ul.x-tab-strip {
list-style-image: none;
padding-left: 0px;
list-style-image : none;
padding-left : 0px;
}
</style>

Expand All @@ -28,7 +28,7 @@
<script type="text/javascript">
(function ($) {
var textareaId = '@Html.IdFor(m => m.Value)';
var textareaId = '@Html.IdFor(m => m.Value)';
$('[id*="EditorModal"]').on('shown.bs.modal', function(e) {
$('.Modal [id*="@Html.IdFor(m => m.Value)"]').attr('id', '@Html.IdFor(m => m.Value)_Modal');
Expand All @@ -44,11 +44,10 @@
})(jQuery);
function setEditorInstance(textareaId) {
//console.log(textareaId + ' on setEditorInstance');
CKEDITOR.replace(textareaId, {
height : '@Model.AttributeDescriptor.Height',
resize_maxHeight : '@(Model.AttributeDescriptor.Height+300)',
customConfig : '/_content/OnTopic.Editor.AspNetCore/Shared/Scripts/CkEditor/customConfig.js'
height : '@Model.AttributeDescriptor.Height',
resize_maxHeight : '@(Model.AttributeDescriptor.Height+300)',
customConfig : '/_content/OnTopic.Editor.AspNetCore/Shared/Scripts/CkEditor/customConfig.js'
});
}
</script>
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>
}
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Loading

0 comments on commit 1fc52c0

Please sign in to comment.