Fixes up tree syncing for views, stylesheets and partial views. Now ensures we can actually
sync a tree for a file based node that doesn't have a static id. Also ensures that when we change a Partial view name that we don't end up duplicating some files when we change it twice in the same session.
This commit is contained in:
@@ -140,7 +140,7 @@
|
||||
<templates>
|
||||
<useAspNetMasterPages>true</useAspNetMasterPages>
|
||||
<enableSkinSupport>true</enableSkinSupport>
|
||||
<defaultRenderingEngine>Webforms</defaultRenderingEngine>
|
||||
<defaultRenderingEngine>Mvc</defaultRenderingEngine>
|
||||
</templates>
|
||||
|
||||
<!-- this is used by Umbraco to determine if there's valid classes in the /App_Code folder to be used for Rest/XSLT extensions -->
|
||||
|
||||
@@ -24,6 +24,8 @@
|
||||
$(document).ready(function () {
|
||||
//create and assign a new EditView object
|
||||
editViewEditor = new Umbraco.Editors.EditView({
|
||||
treeSyncPath: "<%=TemplateTreeSyncPath%>",
|
||||
currentTreeType: "<%=CurrentTreeType%>",
|
||||
editorType: "<%= EditorType.ToString() %>",
|
||||
originalFileName: "<%=OriginalFileName %>",
|
||||
restServiceLocation: "<%= Url.GetSaveFileServicePath() %>",
|
||||
|
||||
@@ -45,6 +45,23 @@ namespace Umbraco.Web.UI.Umbraco.Settings.Views
|
||||
get { return _template == null ? ViewEditorType.PartialView : ViewEditorType.Template; }
|
||||
}
|
||||
|
||||
protected string TemplateTreeSyncPath { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// This view is shared between different trees so we'll look for the query string
|
||||
/// </summary>
|
||||
protected string CurrentTreeType
|
||||
{
|
||||
get
|
||||
{
|
||||
if (Request.QueryString["treeType"].IsNullOrWhiteSpace())
|
||||
{
|
||||
return TreeDefinitionCollection.Instance.FindTree<PartialViewsTree>().Tree.Alias;
|
||||
}
|
||||
return Request.QueryString["treeType"];
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the original file name that the editor was loaded with
|
||||
/// </summary>
|
||||
@@ -89,9 +106,6 @@ namespace Umbraco.Web.UI.Umbraco.Settings.Views
|
||||
AliasTxt.Text = _template.Alias;
|
||||
editorSource.Text = _template.Design;
|
||||
|
||||
ClientTools
|
||||
.SetActiveTreeType(TreeDefinitionCollection.Instance.FindTree<PartialViewsTree>().Tree.Alias)
|
||||
.SyncTree("-1,init," + _template.Path.Replace("-1,", ""), false);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -105,13 +119,13 @@ namespace Umbraco.Web.UI.Umbraco.Settings.Views
|
||||
var s = sr.ReadToEnd();
|
||||
editorSource.Text = s;
|
||||
}
|
||||
|
||||
//string path = DeepLink.GetTreePathFromFilePath(file);
|
||||
//ClientTools
|
||||
// .SetActiveTreeType(TreeDefinitionCollection.Instance.FindTree<loadPython>().Tree.Alias)
|
||||
// .SyncTree(path, false);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
ClientTools
|
||||
.SetActiveTreeType(CurrentTreeType)
|
||||
.SyncTree(TemplateTreeSyncPath, false);
|
||||
}
|
||||
|
||||
|
||||
@@ -122,12 +136,14 @@ namespace Umbraco.Web.UI.Umbraco.Settings.Views
|
||||
//check if a templateId is assigned, meaning we are editing a template
|
||||
if (!Request.QueryString["templateID"].IsNullOrWhiteSpace())
|
||||
{
|
||||
_template = new Template(int.Parse(Request.QueryString["templateID"]));
|
||||
_template = new Template(int.Parse(Request.QueryString["templateID"]));
|
||||
TemplateTreeSyncPath = "-1,init," + _template.Path.Replace("-1,", "");
|
||||
}
|
||||
else if (!Request.QueryString["file"].IsNullOrWhiteSpace())
|
||||
{
|
||||
//we are editing a view (i.e. partial view)
|
||||
OriginalFileName = HttpUtility.UrlDecode(Request.QueryString["file"]);
|
||||
TemplateTreeSyncPath = "-1,init," + Path.GetFileName(OriginalFileName);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -39,9 +39,6 @@
|
||||
|
||||
submitFailure: function(t) {
|
||||
top.UmbSpeechBubble.ShowMessage('error', this._opts.text.cssErrorHeader, this._opts.text.cssErrorText);
|
||||
|
||||
UmbClientMgr.mainTree().setActiveTreeType('stylesheets');
|
||||
UmbClientMgr.mainTree().syncTree("-1,init," + this._opts.cssId, true);
|
||||
}
|
||||
},
|
||||
{
|
||||
|
||||
@@ -122,9 +122,6 @@
|
||||
|
||||
submitFailure: function(t) {
|
||||
top.UmbSpeechBubble.ShowMessage('error', this._opts.text.templateErrorHeader, this._opts.text.templateErrorText);
|
||||
|
||||
UmbClientMgr.mainTree().setActiveTreeType('templates');
|
||||
UmbClientMgr.mainTree().syncTree(this._opts.treeSyncPath, true);
|
||||
}
|
||||
});
|
||||
})(jQuery);
|
||||
@@ -8,6 +8,21 @@
|
||||
//private methods/variables
|
||||
_opts: null,
|
||||
|
||||
_updateNewProperties: function(filePath) {
|
||||
/// <summary>Updates the current treeSyncPath and original file name to have the new file name</summary>
|
||||
|
||||
//update the originalFileName prop
|
||||
this._opts.originalFileName = filePath;
|
||||
|
||||
//re-create the new path
|
||||
var subPath = this._opts.treeSyncPath.split(",");
|
||||
//remove the last element
|
||||
subPath.pop();
|
||||
//add the new element
|
||||
subPath.push(filePath.split("/")[1]);
|
||||
this._opts.treeSyncPath = subPath.join();
|
||||
},
|
||||
|
||||
// Constructor
|
||||
constructor: function (opts) {
|
||||
// Merge options with default
|
||||
@@ -92,10 +107,20 @@
|
||||
|
||||
submitSuccess: function (err, header) {
|
||||
top.UmbSpeechBubble.ShowMessage('save', header, err);
|
||||
|
||||
UmbClientMgr.mainTree().setActiveTreeType(this._opts.currentTreeType);
|
||||
|
||||
var newFilePath = this._opts.nameTxtBox.val();
|
||||
//we need to pass in the newId parameter so it knows which node to resync after retreival from the server
|
||||
UmbClientMgr.mainTree().syncTree(this._opts.treeSyncPath, true, null, newFilePath.split("/")[1]);
|
||||
|
||||
//then we need to update our current tree sync path to represent the new one
|
||||
this._updateNewProperties(newFilePath);
|
||||
|
||||
},
|
||||
|
||||
submitFailure: function (err, header) {
|
||||
top.UmbSpeechBubble.ShowMessage('error', header, err);
|
||||
top.UmbSpeechBubble.ShowMessage('error', header, err);
|
||||
},
|
||||
|
||||
changeMasterPageFile: function ( ) {
|
||||
|
||||
@@ -51,7 +51,7 @@ Umbraco.Sys.registerNamespace("Umbraco.Controls");
|
||||
functionToCall: "",
|
||||
nodeKey: ""
|
||||
};
|
||||
}
|
||||
};
|
||||
|
||||
Umbraco.Controls.UmbracoTree = function() {
|
||||
/// <summary>
|
||||
@@ -100,10 +100,10 @@ Umbraco.Sys.registerNamespace("Umbraco.Controls");
|
||||
if (this._opts.appActions != null) {
|
||||
var _this = this;
|
||||
//wrapped functions maintain scope
|
||||
this._opts.appActions.addEventHandler("nodeDeleting", function(E) { _this.onNodeDeleting(E) });
|
||||
this._opts.appActions.addEventHandler("nodeDeleted", function(E) { _this.onNodeDeleted(E) });
|
||||
this._opts.appActions.addEventHandler("nodeRefresh", function(E) { _this.onNodeRefresh(E) });
|
||||
this._opts.appActions.addEventHandler("publicError", function(E, err) { _this.onPublicError(E, err) });
|
||||
this._opts.appActions.addEventHandler("nodeDeleting", function (E) { _this.onNodeDeleting(E); });
|
||||
this._opts.appActions.addEventHandler("nodeDeleted", function (E) { _this.onNodeDeleted(E); });
|
||||
this._opts.appActions.addEventHandler("nodeRefresh", function (E) { _this.onNodeRefresh(E); });
|
||||
this._opts.appActions.addEventHandler("publicError", function (E, err) { _this.onPublicError(E, err); });
|
||||
}
|
||||
|
||||
this._containerId = jItem.attr("id");
|
||||
@@ -309,19 +309,20 @@ Umbraco.Sys.registerNamespace("Umbraco.Controls");
|
||||
}
|
||||
},
|
||||
|
||||
syncTree: function(path, forceReload, supressChildReload) {
|
||||
syncTree: function(path, forceReload, supressChildReload, newId) {
|
||||
/// <summary>
|
||||
/// Syncronizes the tree with the path supplied and makes that node visible/selected.
|
||||
/// </summary>
|
||||
/// <param name="path">The path of the node</param>
|
||||
/// <param name="forceReload">If true, will ensure that the node to be synced is synced with data from the server</param>
|
||||
/// <param name="newId">This parameter is only used when we don't have a real unique ID for a node, for example for a file. If a filename changes we don't know what the new one is since we are syncing the tree to the old original path. Once we retreive the results the sync the tree we need to find the result by it's new id and update the node.</param>
|
||||
|
||||
this._debug("syncTree: " + path + ", " + forceReload);
|
||||
|
||||
//set the flag so that multiple synces aren't attempted
|
||||
this._isSyncing = true;
|
||||
|
||||
this._syncTree.call(this, path, forceReload, null, null, supressChildReload);
|
||||
this._syncTree.call(this, path, forceReload, null, null, supressChildReload, newId);
|
||||
|
||||
},
|
||||
|
||||
@@ -864,7 +865,7 @@ Umbraco.Sys.registerNamespace("Umbraco.Controls");
|
||||
this._tree.open_branch(liNode, false, callback);
|
||||
},
|
||||
|
||||
_syncTree: function(path, forceReload, numPaths, numAsync, supressChildReload) {
|
||||
_syncTree: function(path, forceReload, numPaths, numAsync, supressChildReload, newId) {
|
||||
/// <summary>
|
||||
/// This is the internal method that will recursively search for the nodes to sync. If an invalid path is
|
||||
/// passed to this method, it will raise an event which can be handled.
|
||||
@@ -873,6 +874,7 @@ Umbraco.Sys.registerNamespace("Umbraco.Controls");
|
||||
/// <param name="forceReload">If true, will ensure that the node to be synced is synced with data from the server</param>
|
||||
/// <param name="numPaths">the number of id's deep to search starting from the end of the path. Used in recursion.</param>
|
||||
/// <param name="numAsync">the number of async calls made so far to sync. Used in recursion and used to determine if the found node has been loaded by ajax.</param>
|
||||
/// <param name="newId">This parameter is only used when we don't have a real unique ID for a node, for example for a file. If a filename changes we don't know what the new one is since we are syncing the tree to the old original path. Once we retreive the results the sync the tree we need to find the result by it's new id and update the node.</param>
|
||||
|
||||
this._debug("_syncTree");
|
||||
|
||||
@@ -917,6 +919,10 @@ Umbraco.Sys.registerNamespace("Umbraco.Controls");
|
||||
this._debug("_syncTree: found! numAsync: " + numAsync + ", forceReload: " + forceReload + ", doReload: " + doReload);
|
||||
if (doReload) {
|
||||
this._actionNode = this.getNodeDef(found);
|
||||
//we need to change the id if the newId parameter is set
|
||||
if (newId) {
|
||||
this._actionNode.nodeId = newId;
|
||||
}
|
||||
if (supressChildReload === undefined) {
|
||||
this.reloadActionNode(false, true, null);
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user