/// <summary> /// Return the editor URL for the currrent node depending on the data found in the query strings /// </summary> /// <param name="id"></param> /// <param name="queryStrings"></param> /// <returns></returns> /// <remarks> /// This checks if the tree there is a OnNodeClick handler assigned, if so, it assigns it, /// otherwise it checks if the tree is in DialogMode, if it is then it returns an empty handler, otherwise /// it sets the Url to the editor's url. /// </remarks> public string GetEditorUrl(HiveId id, FormCollection queryStrings) { Mandate.ParameterNotEmpty(id, "id"); Mandate.ParameterNotNull(queryStrings, "queryStrings"); Mandate.That<NullReferenceException>(Url != null); var isDialog = queryStrings.GetValue<bool>(TreeQueryStringParameters.DialogMode); return queryStrings.HasKey(TreeQueryStringParameters.OnNodeClick) //has a node click handler? ? queryStrings.Get(TreeQueryStringParameters.OnNodeClick) //return node click handler : isDialog //is in dialog mode without a click handler ? ? "#" //return empty string, otherwise, return an editor URL: : Url.GetEditorUrl( id, EditorControllerId, BackOfficeRequestContext.RegisteredComponents, BackOfficeRequestContext.Application.Settings); }
/// <summary> /// Helper method to create a root model for a tree /// </summary> /// <returns></returns> protected virtual TreeNode CreateRootNode(FormCollection queryStrings) { var jsonUrl = Url.GetTreeUrl(GetType(), RootNodeId, queryStrings); var isDialog = queryStrings.GetValue<bool>(TreeQueryStringParameters.DialogMode); var node = new TreeNode(RootNodeId, BackOfficeRequestContext.RegisteredComponents.MenuItems, jsonUrl) { HasChildren = true, EditorUrl = queryStrings.HasKey(TreeQueryStringParameters.OnNodeClick) //has a node click handler? ? queryStrings.Get(TreeQueryStringParameters.OnNodeClick) //return node click handler : isDialog //is in dialog mode without a click handler ? ? "#" //return empty string, otherwise, return an editor URL: : Url.GetCurrentDashboardUrl(), Title = NodeDisplayName }; //add the tree id to the root node.AdditionalData.Add("treeId", TreeId.ToString("N")); //add the tree-root css class node.Style.AddCustom("tree-root"); //node.AdditionalData.Add("id", node.HiveId.ToString()); //node.AdditionalData.Add("title", node.Title); AddQueryStringsToAdditionalData(node, queryStrings); //check if the tree is searchable and add that to the meta data as well if (this is ISearchableTree) { node.AdditionalData.Add("searchable", "true"); } return node; }
/// <summary> /// Return the editor URL for the currrent node depending on the data found in the query strings /// </summary> /// <param name="id"></param> /// <param name="queryStrings"></param> /// <returns></returns> protected virtual string GetEditorUrl(HiveId id, FormCollection queryStrings) { var isDialog = queryStrings.GetValue<bool>(TreeQueryStringParameters.DialogMode); return queryStrings.HasKey(TreeQueryStringParameters.OnNodeClick) //has a node click handler? ? queryStrings.Get(TreeQueryStringParameters.OnNodeClick) //return node click handler : isDialog //is in dialog mode without a click handler ? ? string.Empty //return empty string, otherwise, return an editor URL: : Url.GetEditorUrl(id, EditorControllerId, BackOfficeRequestContext.RegisteredComponents, BackOfficeRequestContext.Application.Settings); }