internal static TreeNodeCollection ConvertFromLegacy(XmlTree xmlTree) { //TODO: Once we get the editor URL stuff working we'll need to figure out how to convert // that over to use the old school ui.xml stuff for these old trees and however the old menu items worked. var collection = new TreeNodeCollection(); foreach (var x in xmlTree.treeCollection) { var node = new TreeNode(x.NodeID, x.Source) { HasChildren = x.HasChildren, Icon = x.Icon, Title = x.Text }; //TODO: Might need to add stuff to additional attributes collection.Add(node); } return collection; }
/// <summary> /// Helper method to create tree nodes and automatically generate the json url /// </summary> /// <param name="id"></param> /// <param name="queryStrings"></param> /// <param name="title"></param> /// <param name="editorUrl"></param> /// <returns></returns> public TreeNode CreateTreeNode(string id, FormDataCollection queryStrings, string title, string editorUrl) { var jsonUrl = Url.GetTreeUrl(GetType(), id, queryStrings); //var node = new TreeNode(id, BackOfficeRequestContext.RegisteredComponents.MenuItems, jsonUrl) { Title = title, EditorUrl = editorUrl }; var node = new TreeNode(id, jsonUrl) { Title = title, EditorUrl = editorUrl }; return node; }
/// <summary> /// Helper method to create a root model for a tree /// </summary> /// <returns></returns> protected virtual TreeNode CreateRootNode(FormDataCollection queryStrings) { var getChildNodesUrl = Url.GetTreeUrl(GetType(), RootNodeId, queryStrings); var isDialog = queryStrings.GetValue<bool>(TreeQueryStringParameters.DialogMode); //var node = new TreeNode(RootNodeId, BackOfficeRequestContext.RegisteredComponents.MenuItems, jsonUrl) var node = new TreeNode(RootNodeId, getChildNodesUrl) { HasChildren = true, //THIS IS TEMPORARY UNTIL WE FIGURE OUT HOW WE ARE LOADING STUFF (I.E. VIEW NAMES, ACTION NAMES, DUNNO) 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: : "mydashboard", Title = RootNodeDisplayName }; //add the tree type to the root node.AdditionalData.Add("treeType", GetType().FullName); ////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> /// The AdditionalData of a node is always populated with the query string data, this method performs this /// operation and ensures that special values are not inserted or that duplicate keys are not added. /// </summary> /// <param name="node"></param> /// <param name="queryStrings"></param> protected virtual void AddQueryStringsToAdditionalData(TreeNode node, FormDataCollection queryStrings) { // Add additional data, ensure treeId isn't added as we've already done that foreach (var q in queryStrings .Where(x => x.Key != "treeId" && !node.AdditionalData.ContainsKey(x.Key))) { node.AdditionalData.Add(q.Key, q.Value); } }