Updated ClientTools with a couple new methods.

ClientDependency lib update.
Fixes: 26892 - member type tree refresh

[TFS Changeset #65790]
This commit is contained in:
Shandem
2010-04-27 14:17:15 +00:00
parent 2c04a49ffa
commit 034fc2276c
6 changed files with 71 additions and 17 deletions

View File

@@ -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;
}
/// <summary>
/// Refreshes the entire current tree
/// </summary>
/// <returns></returns>
public ClientTools RefreshTree()
{
RegisterClientScript(Scripts.RefreshTree);
return this;
}
public ClientTools RefreshTree(string treeType)
{
RegisterClientScript(string.Format(Scripts.RefreshTreeType, treeType));
return this;
}
/// <summary>
/// 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
}
/// <summary>
/// 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.
/// </summary>
/// <param name="reselect"></param>
/// <param name="reloadChildren"></param>
@@ -285,13 +303,23 @@ namespace umbraco.BasePages
return HttpContext.Current.CurrentHandler as Page;
}
private void RegisterClientScript(string script)
/// <summary>
/// This will use the ScriptManager to register the script if one is available, otherwise will default to the ClientScript
/// class of the page.
/// </summary>
/// <param name="script"></param>
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);
}
}

View File

@@ -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
-->
<clientDependency version="25">
<clientDependency version="26">
<fileRegistration defaultProvider="PageHeaderProvider" fileDependencyExtensions=".js,.css">
<fileRegistration defaultProvider="PageHeaderProvider" fileDependencyExtensions=".js,.css">
<providers>
<add name="PageHeaderProvider" type="ClientDependency.Core.FileRegistration.Providers.PageHeaderProvider, ClientDependency.Core"/>
<add name="LazyLoadProvider" type="ClientDependency.Core.FileRegistration.Providers.LazyLoadProvider, ClientDependency.Core"/>

View File

@@ -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<loadMemberGroups>().Tree.Alias);
}

View File

@@ -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;
}

View File

@@ -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() {
/// <summary>This wraps the standard jsTree functionality</summary>
this._debug("refreshTree");
this._tree.refresh();
refreshTree: function(treeType) {
/// <summary>This wraps the standard jsTree functionality unless a treeType is specified. If one is, then it will just reload that nodes children</summary>
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) {
/// <summary>This will rebuild the tree structure for the application specified</summary>
@@ -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);