From ad2764e3acf7a1ea0e4393abfd766fb93bee48ef Mon Sep 17 00:00:00 2001 From: Jeremy Pyne Date: Mon, 24 Jun 2013 14:51:52 -0400 Subject: [PATCH 1/4] Added code to select the parent node when doing Move/Copy operations. This will save lots of time for users. This code can also be added to other places that use the TreeControl to pre-select the currently selected item(media pickers for example) so that changing content will be quicker. --- .../umbraco/controls/Tree/TreeControl.ascx | 6 ++++++ .../umbraco/controls/Tree/TreeControl.ascx.cs | 10 ++++++++++ .../umbraco/dialogs/moveOrCopy.aspx.cs | 4 ++++ 3 files changed, 20 insertions(+) diff --git a/src/Umbraco.Web/umbraco.presentation/umbraco/controls/Tree/TreeControl.ascx b/src/Umbraco.Web/umbraco.presentation/umbraco/controls/Tree/TreeControl.ascx index c7fa6aa5d5..3d379f68d8 100644 --- a/src/Umbraco.Web/umbraco.presentation/umbraco/controls/Tree/TreeControl.ascx +++ b/src/Umbraco.Web/umbraco.presentation/umbraco/controls/Tree/TreeControl.ascx @@ -47,6 +47,12 @@ jQuery(document).ready(function() { dataUrl: "<%#umbraco.IO.IOHelper.ResolveUrl(umbraco.IO.SystemDirectories.Umbraco)%>/webservices/TreeDataService.ashx", serviceUrl: "<%#umbraco.IO.IOHelper.ResolveUrl(umbraco.IO.SystemDirectories.Umbraco)%>/webservices/TreeClientService.asmx/GetInitAppTreeData"}); + <%if(!String.IsNullOrEmpty(this.SelectedNodePath)) {%> + setTimeout(function() { + jQuery("#<%=ClientID%>").UmbracoTreeAPI().syncTree('<%=this.SelectedNodePath%>', true, true); + }, 500); + <% } %> + //add event handler for ajax errors, this will refresh the whole application var mainTree = UmbClientMgr.mainTree(); if (mainTree != null) { diff --git a/src/Umbraco.Web/umbraco.presentation/umbraco/controls/Tree/TreeControl.ascx.cs b/src/Umbraco.Web/umbraco.presentation/umbraco/controls/Tree/TreeControl.ascx.cs index fd1b180005..c9d4cc8f74 100644 --- a/src/Umbraco.Web/umbraco.presentation/umbraco/controls/Tree/TreeControl.ascx.cs +++ b/src/Umbraco.Web/umbraco.presentation/umbraco/controls/Tree/TreeControl.ascx.cs @@ -62,6 +62,7 @@ namespace umbraco.controls.Tree private TreeMode m_TreeType = TreeMode.Standard; private bool m_IsInit = false; private TreeService m_TreeService = new TreeService(); + private string m_SelectedNodePath; #region Public Properties @@ -100,6 +101,15 @@ namespace umbraco.controls.Tree } } + public string SelectedNodePath + { + get { return m_SelectedNodePath; } + set + { + m_SelectedNodePath = value; + } + } + public string TreeType { get { return m_TreeService.TreeType; } diff --git a/src/Umbraco.Web/umbraco.presentation/umbraco/dialogs/moveOrCopy.aspx.cs b/src/Umbraco.Web/umbraco.presentation/umbraco/dialogs/moveOrCopy.aspx.cs index ebad6f2151..d80500870c 100644 --- a/src/Umbraco.Web/umbraco.presentation/umbraco/dialogs/moveOrCopy.aspx.cs +++ b/src/Umbraco.Web/umbraco.presentation/umbraco/dialogs/moveOrCopy.aspx.cs @@ -80,6 +80,10 @@ namespace umbraco.dialogs var cmsNode = new CMSNode(int.Parse(Request.GetItemAsString("id"))); + // Preselect the parent of the seslected item. + if(cmsNode.ParentId > 0) + JTree.SelectedNodePath = cmsNode.Parent.Path; + var validAction = true; if (CurrentApp == Constants.Applications.Content && cmsNode.HasChildren) validAction = ValidAction(Request.GetItemAsString("mode") == "cut" ? 'M' : 'O'); From fe23502e67c431d3a31b73246c038db7a8a29aaf Mon Sep 17 00:00:00 2001 From: Jeremy Pyne Date: Tue, 25 Jun 2013 15:48:16 -0400 Subject: [PATCH 2/4] Added code to actually pre-select the parent node instead of just locating it in the tree. This seams keeps the Ui in a sane state. Updated control code in Umbraco.Web.Ui from Umbraco.Web. --- .../umbraco/controls/Tree/TreeControl.ascx | 15 +++++++++++++++ .../umbraco/controls/Tree/TreeControl.ascx | 11 ++++++++++- 2 files changed, 25 insertions(+), 1 deletion(-) diff --git a/src/Umbraco.Web.UI/umbraco/controls/Tree/TreeControl.ascx b/src/Umbraco.Web.UI/umbraco/controls/Tree/TreeControl.ascx index c7fa6aa5d5..fb4fac1e2d 100644 --- a/src/Umbraco.Web.UI/umbraco/controls/Tree/TreeControl.ascx +++ b/src/Umbraco.Web.UI/umbraco/controls/Tree/TreeControl.ascx @@ -47,6 +47,21 @@ jQuery(document).ready(function() { dataUrl: "<%#umbraco.IO.IOHelper.ResolveUrl(umbraco.IO.SystemDirectories.Umbraco)%>/webservices/TreeDataService.ashx", serviceUrl: "<%#umbraco.IO.IOHelper.ResolveUrl(umbraco.IO.SystemDirectories.Umbraco)%>/webservices/TreeClientService.asmx/GetInitAppTreeData"}); + <%if(!String.IsNullOrEmpty(this.SelectedNodePath)) {%> + setTimeout(function() { + treeApi = jQuery("#<%=ClientID%>").UmbracoTreeAPI(); + treeApi.syncTree('<%=this.SelectedNodePath%>', true, true); + + // select the parent node once found. + var iv = setInterval(function() { + var node = treeApi.findNode('<%=this.SelectedNodePath%>'.split(',').pop(), true); + if(node != false) { + treeApi.selectNode(node, false, true); + clearInterval(iv); + } + }, 500); + <% } %> + //add event handler for ajax errors, this will refresh the whole application var mainTree = UmbClientMgr.mainTree(); if (mainTree != null) { diff --git a/src/Umbraco.Web/umbraco.presentation/umbraco/controls/Tree/TreeControl.ascx b/src/Umbraco.Web/umbraco.presentation/umbraco/controls/Tree/TreeControl.ascx index 3d379f68d8..fb4fac1e2d 100644 --- a/src/Umbraco.Web/umbraco.presentation/umbraco/controls/Tree/TreeControl.ascx +++ b/src/Umbraco.Web/umbraco.presentation/umbraco/controls/Tree/TreeControl.ascx @@ -49,7 +49,16 @@ jQuery(document).ready(function() { <%if(!String.IsNullOrEmpty(this.SelectedNodePath)) {%> setTimeout(function() { - jQuery("#<%=ClientID%>").UmbracoTreeAPI().syncTree('<%=this.SelectedNodePath%>', true, true); + treeApi = jQuery("#<%=ClientID%>").UmbracoTreeAPI(); + treeApi.syncTree('<%=this.SelectedNodePath%>', true, true); + + // select the parent node once found. + var iv = setInterval(function() { + var node = treeApi.findNode('<%=this.SelectedNodePath%>'.split(',').pop(), true); + if(node != false) { + treeApi.selectNode(node, false, true); + clearInterval(iv); + } }, 500); <% } %> From 7a2a4445793d680222c72cec196f31dd02e3f28e Mon Sep 17 00:00:00 2001 From: Jeremy Pyne Date: Wed, 7 Aug 2013 15:28:41 -0400 Subject: [PATCH 3/4] Fix for select parent o move or copy in 6.1.3. --- src/Umbraco.Web/Umbraco.Web.csproj | 11 +++++++---- .../umbraco/dialogs/moveOrCopy.aspx.cs | 4 ++-- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/src/Umbraco.Web/Umbraco.Web.csproj b/src/Umbraco.Web/Umbraco.Web.csproj index 67d9b6335d..2986b64059 100644 --- a/src/Umbraco.Web/Umbraco.Web.csproj +++ b/src/Umbraco.Web/Umbraco.Web.csproj @@ -291,7 +291,7 @@ - + @@ -1871,7 +1871,8 @@ - + + @@ -1935,7 +1936,9 @@ - + + ASPXCodeBehind + @@ -2058,4 +2061,4 @@ - \ No newline at end of file + diff --git a/src/Umbraco.Web/umbraco.presentation/umbraco/dialogs/moveOrCopy.aspx.cs b/src/Umbraco.Web/umbraco.presentation/umbraco/dialogs/moveOrCopy.aspx.cs index 3069d9485d..a66dd8634c 100644 --- a/src/Umbraco.Web/umbraco.presentation/umbraco/dialogs/moveOrCopy.aspx.cs +++ b/src/Umbraco.Web/umbraco.presentation/umbraco/dialogs/moveOrCopy.aspx.cs @@ -90,8 +90,8 @@ namespace umbraco.dialogs } // Preselect the parent of the seslected item. - if(cmsNode.ParentId > 0) - JTree.SelectedNodePath = cmsNode.Parent.Path; + if (currContent.ParentId > 0) + JTree.SelectedNodePath = currContent.Path.Substring(0, currContent.Path.LastIndexOf(',')); var validAction = true; if (CurrentApp == Constants.Applications.Content && Umbraco.Core.Models.ContentExtensions.HasChildren(currContent, Services)) From e65a71a05a265bda0cccfda129377cbe73602299 Mon Sep 17 00:00:00 2001 From: Jeremy Pyne Date: Thu, 29 Aug 2013 11:00:15 -0400 Subject: [PATCH 4/4] Added code to pre-select the current node in content tree pickers based on the location of the document in the tree. This is a HUGE time saver with an even moderately complex site hierarchy. --- src/Umbraco.Web.UI/umbraco/controls/Tree/TreeControl.ascx | 8 -------- .../umbraco/controls/Tree/TreeControl.ascx | 8 -------- .../umbraco/dialogs/treePicker.aspx.cs | 6 ++++++ src/umbraco.controls/TreePicker/SimpleContentPicker.cs | 4 ++++ src/umbraco.editorControls/pagepicker/pagePicker.cs | 4 ++++ 5 files changed, 14 insertions(+), 16 deletions(-) diff --git a/src/Umbraco.Web.UI/umbraco/controls/Tree/TreeControl.ascx b/src/Umbraco.Web.UI/umbraco/controls/Tree/TreeControl.ascx index fb4fac1e2d..2d143e6153 100644 --- a/src/Umbraco.Web.UI/umbraco/controls/Tree/TreeControl.ascx +++ b/src/Umbraco.Web.UI/umbraco/controls/Tree/TreeControl.ascx @@ -51,14 +51,6 @@ jQuery(document).ready(function() { setTimeout(function() { treeApi = jQuery("#<%=ClientID%>").UmbracoTreeAPI(); treeApi.syncTree('<%=this.SelectedNodePath%>', true, true); - - // select the parent node once found. - var iv = setInterval(function() { - var node = treeApi.findNode('<%=this.SelectedNodePath%>'.split(',').pop(), true); - if(node != false) { - treeApi.selectNode(node, false, true); - clearInterval(iv); - } }, 500); <% } %> diff --git a/src/Umbraco.Web/umbraco.presentation/umbraco/controls/Tree/TreeControl.ascx b/src/Umbraco.Web/umbraco.presentation/umbraco/controls/Tree/TreeControl.ascx index fb4fac1e2d..2d143e6153 100644 --- a/src/Umbraco.Web/umbraco.presentation/umbraco/controls/Tree/TreeControl.ascx +++ b/src/Umbraco.Web/umbraco.presentation/umbraco/controls/Tree/TreeControl.ascx @@ -51,14 +51,6 @@ jQuery(document).ready(function() { setTimeout(function() { treeApi = jQuery("#<%=ClientID%>").UmbracoTreeAPI(); treeApi.syncTree('<%=this.SelectedNodePath%>', true, true); - - // select the parent node once found. - var iv = setInterval(function() { - var node = treeApi.findNode('<%=this.SelectedNodePath%>'.split(',').pop(), true); - if(node != false) { - treeApi.selectNode(node, false, true); - clearInterval(iv); - } }, 500); <% } %> diff --git a/src/Umbraco.Web/umbraco.presentation/umbraco/dialogs/treePicker.aspx.cs b/src/Umbraco.Web/umbraco.presentation/umbraco/dialogs/treePicker.aspx.cs index 4a60b0605b..38518804b4 100644 --- a/src/Umbraco.Web/umbraco.presentation/umbraco/dialogs/treePicker.aspx.cs +++ b/src/Umbraco.Web/umbraco.presentation/umbraco/dialogs/treePicker.aspx.cs @@ -20,6 +20,12 @@ namespace umbraco.dialogs base.OnLoad(e); TreeParams = TreeRequestParams.FromQueryStrings().CreateTreeService(); DataBind(); + + if(Request.QueryString["selected"] != null && TreeParams.TreeType == "content") { + var currContent = Services.ContentService.GetById(int.Parse(Request.QueryString["selected"])); + if (currContent.ParentId > 0) + DialogTree.SelectedNodePath = currContent.Path; + } } protected TreeService TreeParams { get; private set; } diff --git a/src/umbraco.controls/TreePicker/SimpleContentPicker.cs b/src/umbraco.controls/TreePicker/SimpleContentPicker.cs index de93637134..3d70cbbef4 100644 --- a/src/umbraco.controls/TreePicker/SimpleContentPicker.cs +++ b/src/umbraco.controls/TreePicker/SimpleContentPicker.cs @@ -1,4 +1,5 @@ using System; +using System.Web; using System.Collections.Generic; using System.Linq; using System.Text; @@ -12,6 +13,9 @@ namespace umbraco.uicontrols.TreePicker { get { + if (HttpContext.Current.Request.QueryString["id"] != null) + return TreeUrlGenerator.GetPickerUrl(Constants.Applications.Content, "content") + "&selected=" + HttpContext.Current.Request.QueryString["id"]; + return TreeUrlGenerator.GetPickerUrl(Constants.Applications.Content, "content"); } } diff --git a/src/umbraco.editorControls/pagepicker/pagePicker.cs b/src/umbraco.editorControls/pagepicker/pagePicker.cs index 16693194dd..791bb20352 100644 --- a/src/umbraco.editorControls/pagepicker/pagePicker.cs +++ b/src/umbraco.editorControls/pagepicker/pagePicker.cs @@ -1,4 +1,5 @@ using System; +using System.Web; using System.Web.UI; using umbraco.cms.presentation.Trees; @@ -26,6 +27,9 @@ namespace umbraco.editorControls { get { + if(HttpContext.Current.Request.QueryString["id"] != null) + return TreeService.GetPickerUrl(Umbraco.Core.Constants.Applications.Content, "content") + "&selected=" + HttpContext.Current.Request.QueryString["id"]; + return TreeService.GetPickerUrl(Umbraco.Core.Constants.Applications.Content, "content"); } }