protected override ActionResult <TreeNodeCollection> GetTreeNodes(string id, FormCollection queryStrings) { var nodes = new TreeNodeCollection(); if (id == Constants.System.RootString) { nodes.Add( CreateTreeNode( Constants.Conventions.MemberTypes.AllMembersListId, id, queryStrings, LocalizedTextService.Localize("member", "allMembers"), Constants.Icons.MemberType, true, queryStrings.GetRequiredValue <string>("application") + TreeAlias.EnsureStartsWith('/') + "/list/" + Constants.Conventions.MemberTypes.AllMembersListId)); nodes.AddRange(_memberTypeService.GetAll() .Select(memberType => CreateTreeNode( memberType.Alias, id, queryStrings, memberType.Name, memberType.Icon.IfNullOrWhiteSpace(Constants.Icons.Member), true, queryStrings.GetRequiredValue <string>("application") + TreeAlias.EnsureStartsWith('/') + "/list/" + memberType.Alias))); } //There is no menu for any of these nodes nodes.ForEach(x => x.MenuUrl = null); //All nodes are containers nodes.ForEach(x => x.AdditionalData.Add("isContainer", true)); return(nodes); }
/// <summary> /// Ensures the recycle bin is appended when required (i.e. user has access to the root and it's not in dialog mode) /// </summary> /// <param name="id"></param> /// <param name="queryStrings"></param> /// <returns></returns> /// <remarks> /// This method is overwritten strictly to render the recycle bin, it should serve no other purpose /// </remarks> protected sealed override ActionResult <TreeNodeCollection> GetTreeNodes(string id, FormCollection queryStrings) { //check if we're rendering the root if (id == Constants.System.RootString && UserStartNodes.Contains(Constants.System.Root)) { var altStartId = string.Empty; if (queryStrings.HasKey(TreeQueryStringParameters.StartNodeId)) { altStartId = queryStrings.GetValue <string>(TreeQueryStringParameters.StartNodeId); } //check if a request has been made to render from a specific start node if (string.IsNullOrEmpty(altStartId) == false && altStartId != "undefined" && altStartId != Constants.System.RootString) { id = altStartId; } var nodesResult = GetTreeNodesInternal(id, queryStrings); if (!(nodesResult.Result is null)) { return(nodesResult.Result); } var nodes = nodesResult.Value; //only render the recycle bin if we are not in dialog and the start id is still the root //we need to check for the "application" key in the queryString because its value is required here, //and for some reason when there are no dashboards, this parameter is missing if (IsDialog(queryStrings) == false && id == Constants.System.RootString && queryStrings.HasKey("application")) { nodes.Add(CreateTreeNode( RecycleBinId.ToInvariantString(), id, queryStrings, LocalizedTextService.Localize("general", "recycleBin"), "icon-trash", RecycleBinSmells, queryStrings.GetRequiredValue <string>("application") + TreeAlias.EnsureStartsWith('/') + "/recyclebin")); } return(nodes); } return(GetTreeNodesInternal(id, queryStrings)); }
/// <summary> /// Returns the menu structure for the node /// </summary> /// <param name="id"></param> /// <param name="queryStrings"></param> /// <returns></returns> protected override ActionResult <MenuItemCollection> GetMenuForNode(string id, FormCollection queryStrings) { MenuItemCollection menu = _menuItemCollectionFactory.Create(); //Create the normal create action MenuItem?item = menu.Items.Add <ActionNew>(LocalizedTextService, opensDialog: true, useLegacyIcon: false); item?.NavigateToRoute( $"{queryStrings.GetRequiredValue<string>("application")}/templates/edit/{id}?create=true"); if (id == Constants.System.RootString) { //refresh action menu.Items.Add(new RefreshNode(LocalizedTextService, separatorBefore: true)); return(menu); } ITemplate?template = _fileService.GetTemplate(int.Parse(id, CultureInfo.InvariantCulture)); if (template == null) { return(menu); } EntitySlim entity = FromTemplate(template); //don't allow delete if it has child layouts if (template.IsMasterTemplate == false) { //add delete option if it doesn't have children menu.Items.Add <ActionDelete>(LocalizedTextService, hasSeparator: true, opensDialog: true); } //add refresh menu.Items.Add(new RefreshNode(LocalizedTextService, separatorBefore: true)); return(menu); }