diff --git a/foreign dlls/ClientDependency.Core.dll b/foreign dlls/ClientDependency.Core.dll index 236b624c30..0b863dd257 100644 Binary files a/foreign dlls/ClientDependency.Core.dll and b/foreign dlls/ClientDependency.Core.dll differ diff --git a/umbraco/businesslogic/BasePages/ClientTools.cs b/umbraco/businesslogic/BasePages/ClientTools.cs index cf890660f1..80b90eb6ea 100644 --- a/umbraco/businesslogic/BasePages/ClientTools.cs +++ b/umbraco/businesslogic/BasePages/ClientTools.cs @@ -54,6 +54,8 @@ namespace umbraco.BasePages public static string MoveNode { get { return GetMainTree + ".moveNode('{0}', '{1}');"; } } public static string ReloadActionNode { get { return GetMainTree + ".reloadActionNode({0}, {1}, null);"; } } public static string SetActiveTreeType { get { return GetMainTree + ".setActiveTreeType('{0}');"; } } + public static string RefreshTree { get { return GetMainTree + ".refreshTree();"; } } + public static string RefreshTreeType { get { return GetMainTree + ".refreshTree('{0}');"; } } public static string CloseModalWindow() { return string.Format("{0}.closeModalWindow();", ClientMgrScript); @@ -106,6 +108,22 @@ namespace umbraco.BasePages RegisterClientScript(string.Format(Scripts.RefreshAdmin, seconds * 1000)); return this; } + + /// + /// Refreshes the entire current tree + /// + /// + public ClientTools RefreshTree() + { + RegisterClientScript(Scripts.RefreshTree); + return this; + } + + public ClientTools RefreshTree(string treeType) + { + RegisterClientScript(string.Format(Scripts.RefreshTreeType, treeType)); + return this; + } /// /// A reference to the umbraco UI component "speechbubble". The speechbubble appears in the lower right corner of the screen, notifying users of events @@ -212,7 +230,7 @@ namespace umbraco.BasePages } /// - /// Reloads only the active node in the tree. + /// Reloads only the last node that the user interacted with via the context menu. To reload a specify node, use SyncTree. /// /// /// @@ -285,13 +303,23 @@ namespace umbraco.BasePages return HttpContext.Current.CurrentHandler as Page; } - private void RegisterClientScript(string script) + /// + /// This will use the ScriptManager to register the script if one is available, otherwise will default to the ClientScript + /// class of the page. + /// + /// + private void RegisterClientScript(string script) { //use the hash code of the script to generate the key, this way, the exact same script won't be //inserted more than once. - //m_page.ClientScript.RegisterClientScriptBlock(m_page.GetType(), script.GetHashCode().ToString(), script, true); - m_page.ClientScript.RegisterStartupScript(m_page.GetType(), script.GetHashCode().ToString(), script, true); - + if (ScriptManager.GetCurrent(m_page) != null) + { + ScriptManager.RegisterStartupScript(m_page, m_page.GetType(), script.GetHashCode().ToString(), script, true); + } + else + { + m_page.ClientScript.RegisterStartupScript(m_page.GetType(), script.GetHashCode().ToString(), script, true); + } } diff --git a/umbraco/presentation/config/ClientDependency.config b/umbraco/presentation/config/ClientDependency.config index dcf453f35f..4378c78ef4 100644 --- a/umbraco/presentation/config/ClientDependency.config +++ b/umbraco/presentation/config/ClientDependency.config @@ -10,9 +10,9 @@ NOTES: * Compression/Combination/Minification is not enabled unless debug="false" is specified on the 'compiliation' element in the web.config * A new version will invalidate both client and server cache and create new persisted files --> - + - + diff --git a/umbraco/presentation/umbraco/members/EditMemberGroup.aspx.cs b/umbraco/presentation/umbraco/members/EditMemberGroup.aspx.cs index 05457ab628..9c25fa137c 100644 --- a/umbraco/presentation/umbraco/members/EditMemberGroup.aspx.cs +++ b/umbraco/presentation/umbraco/members/EditMemberGroup.aspx.cs @@ -57,7 +57,9 @@ namespace umbraco.presentation.members memberGroupName.Value = NameTxt.Text; _memberGroup.Save(); this.ClientTools.ShowSpeechBubble(speechBubbleIcon.save, ui.Text("speechBubbles", "editMemberGroupSaved", base.getUser()),""); - ClientTools.ReloadActionNode(true, true); + + ClientTools + .RefreshTree(TreeDefinitionCollection.Instance.FindTree().Tree.Alias); } diff --git a/umbraco/presentation/umbraco/members/EditMemberType.aspx.cs b/umbraco/presentation/umbraco/members/EditMemberType.aspx.cs index 5020980604..b133fef9a3 100644 --- a/umbraco/presentation/umbraco/members/EditMemberType.aspx.cs +++ b/umbraco/presentation/umbraco/members/EditMemberType.aspx.cs @@ -44,11 +44,17 @@ namespace umbraco.cms.presentation.members { saveExtras(); - base.speechBubble(BasePages.BasePage.speechBubbleIcon.save,"Memebertype saved",""); + ClientTools + .ShowSpeechBubble(speechBubbleIcon.save, "Memebertype saved", "") + .SyncTree(dt.Id.ToString(), true); + } else { - base.speechBubble(BasePages.BasePage.speechBubbleIcon.save,e.Message,""); + ClientTools + .ShowSpeechBubble(speechBubbleIcon.save, e.Message, "") + .SyncTree(dt.Id.ToString(), true); + } handled = true; } diff --git a/umbraco/presentation/umbraco_client/Tree/UmbracoTree.js b/umbraco/presentation/umbraco_client/Tree/UmbracoTree.js index 62ad5f0441..7395ca6b7e 100644 --- a/umbraco/presentation/umbraco_client/Tree/UmbracoTree.js +++ b/umbraco/presentation/umbraco_client/Tree/UmbracoTree.js @@ -67,7 +67,7 @@ Umbraco.Sys.registerNamespace("Umbraco.Controls"); _activeTreeType: "content", //tracks which is the active tree type, this is used in searching and syncing. _tree: null, //reference to the jsTree object _isEditMode: false, //not really used YET - _isDebug: false, //set to true to enable alert debugging + _isDebug: true, //set to true to enable alert debugging _loadedApps: [], //stores the application names that have been loaded to track which JavaScript code has been inserted into the DOM _treeClass: "umbTree", //used for other libraries to detect which elements are an umbraco tree _currenAJAXRequest: false, //used to determine if there is currently an ajax request being executed. @@ -147,10 +147,28 @@ Umbraco.Sys.registerNamespace("Umbraco.Controls"); this._opts.appActions.showSpeachBubble("info", "Tree Edit Mode", "The tree is now operating in edit mode"); }, - refreshTree: function() { - /// This wraps the standard jsTree functionality - this._debug("refreshTree"); - this._tree.refresh(); + refreshTree: function(treeType) { + /// This wraps the standard jsTree functionality unless a treeType is specified. If one is, then it will just reload that nodes children + this._debug("refreshTree: " + treeType); + if (!treeType) { + this._tree.refresh(); + } + else { + var allRoots = this._getContainer().find("li[rel='rootNode']"); + var _this = this; + var root = allRoots.filter(function() { + return ($(this).attr("umb:type") == _this._activeTreeType); //filter based on custom namespace requires custom function + }); + if (root.length == 1) { + this._debug("refreshTree: reloading tree type: " + treeType); + this._loadChildNodes(root); + } + else { + //couldn't find it, so refresh the whole tree + this._tree.refresh(); + } + } + }, rebuildTree: function(app, callback) { /// This will rebuild the tree structure for the application specified @@ -389,7 +407,7 @@ Umbraco.Sys.registerNamespace("Umbraco.Controls"); return ($(this).attr("umb:type") == _this._activeTreeType); //filter based on custom namespace requires custom function }); var found = branch.length > 0 ? branch : false; - this._debug("findNode: " + nodeId + " in '" + this._activeTreeType + "' tree. Found? " + found.length); + this._debug("findNode: " + nodeId + " in '" + this._activeTreeType + "' tree. Found? " + found); return found; }, @@ -831,7 +849,7 @@ Umbraco.Sys.registerNamespace("Umbraco.Controls"); else { //only force the reload of this nodes data if forceReload is specified and the node has not already come from the server var doReload = (forceReload && (numAsync == null || numAsync < 1)); - this._debug("_syncTree: found! numAsync: " + numAsync + ", forceReload: " + forceReload); + this._debug("_syncTree: found! numAsync: " + numAsync + ", forceReload: " + forceReload + ", doReload: " + doReload); if (doReload) { this._actionNode = this.getNodeDef(found); this.reloadActionNode(false, true, null);