/// <summary> /// Gets tree nodes for self managed collection providers. /// </summary> /// <param name="currentTree"> /// The current tree. /// </param> /// <param name="info"> /// The info. /// </param> /// <param name="splitId"> /// The split id. /// </param> /// <param name="collectionId"> /// The collection id. /// </param> /// <param name="parentRouteId"> /// The parent route id. /// </param> /// <param name="queryStrings"> /// The query strings. /// </param> /// <returns> /// The <see cref="IEnumerable{TreeNode}"/>. /// </returns> private IEnumerable <TreeNode> GetTreeNodesForSelfManagedProviders( TreeElement currentTree, CollectionProviderInfo info, SplitRoutePath splitId, string collectionId, string parentRouteId, FormDataCollection queryStrings) { var treeNodes = new List <TreeNode>(); if (splitId.IsChildCollection) { return(treeNodes); } // if there are no self managed providers - return if (currentTree.SelfManagedEntityCollectionProviderCollections == null || !currentTree.SelfManagedEntityCollectionProviderCollections.EntityCollectionProviders().Any(x => x.Visible)) { return(treeNodes); } return(this.GetTreeNodeForConfigurationEntityCollectionProviders(currentTree, collectionId, info, queryStrings, parentRouteId)); }
/// <summary> /// The get tree nodes. /// </summary> /// <param name="id"> /// The id. /// </param> /// <param name="queryStrings"> /// The query strings. /// </param> /// <returns> /// The <see cref="TreeNodeCollection"/>. /// </returns> protected override TreeNodeCollection GetTreeNodes(string id, FormDataCollection queryStrings) { var collection = new TreeNodeCollection(); var backoffice = MerchelloConfiguration.Current.BackOffice; var currentTree = _rootTrees.FirstOrDefault(x => x.Id == id && x.Visible); var splitId = new SplitRoutePath(id); collection.AddRange( currentTree != null ? _collectiontrees.Contains(splitId.CollectionId) ? this.GetTreeNodesForCollections(splitId.CollectionId, MakeCollectionRoutePathId(splitId.CollectionId, splitId.CollectionKey), queryStrings) : currentTree.SubTree.GetTrees().Where(x => x.Visible) .Select(tree => GetTreeNodeFromConfigurationElement(tree, queryStrings, currentTree)) : _collectiontrees.Contains(splitId.CollectionId) ? this.GetTreeNodesForCollections(splitId.CollectionId, MakeCollectionRoutePathId(splitId.CollectionId, splitId.CollectionKey), queryStrings, false) : backoffice.GetTrees().Where(x => x.Visible) .Select(tree => GetTreeNodeFromConfigurationElement(tree, queryStrings))); return(collection); }
/// <summary> /// Gets tree nodes for collections. /// </summary> /// <param name="collectionId"> /// The collection id. /// </param> /// <param name="parentRouteId"> /// The parent route id. /// </param> /// <param name="queryStrings"> /// The query strings. /// </param> /// <param name="collectionRoots"> /// Indicates this is a collection root node /// </param> /// <returns> /// The <see cref="IEnumerable{TreeNode}"/>. /// </returns> private IEnumerable <TreeNode> GetTreeNodesForCollections(string collectionId, string parentRouteId, FormDataCollection queryStrings, bool collectionRoots = true) { var info = this.GetCollectionProviderInfo(collectionId); var splitId = new SplitRoutePath(parentRouteId); // add any configured dynamic collections var currentTree = _rootTrees.FirstOrDefault(x => x.Id == splitId.CollectionId && x.Visible); var treeNodes = new List <TreeNode>(); if (currentTree == null) { return(treeNodes); } var managedFirst = true; if (currentTree.ChildSettings.Count > 0) { var setting = currentTree.ChildSettings.AllSettings() .First(x => x.Alias == "selfManagedProvidersBeforeStaticProviders"); if (setting != null) { managedFirst = bool.Parse(setting.Value); } } if (managedFirst) { var sm = GetTreeNodesForSelfManagedProviders(currentTree, info, splitId, collectionId, parentRouteId, queryStrings).ToArray(); if (sm.Any()) { treeNodes.AddRange(sm); } var sc = GetTreeNodesFromCollection(info, splitId, collectionId, parentRouteId, queryStrings, collectionRoots).ToArray(); if (sc.Any()) { treeNodes.AddRange(sc); } } else { var sc = GetTreeNodesFromCollection(info, splitId, collectionId, parentRouteId, queryStrings, collectionRoots).ToArray(); if (sc.Any()) { treeNodes.AddRange(sc); } var sm = GetTreeNodesForSelfManagedProviders(currentTree, info, splitId, collectionId, parentRouteId, queryStrings).ToArray(); if (sm.Any()) { treeNodes.AddRange(sm); } } return(treeNodes); }
/// <summary> /// The get tree nodes. /// </summary> /// <param name="id"> /// The id. /// </param> /// <param name="queryStrings"> /// The query strings. /// </param> /// <returns> /// The <see cref="TreeNodeCollection"/>. /// </returns> protected override TreeNodeCollection GetTreeNodes(string id, FormDataCollection queryStrings) { var collection = new TreeNodeCollection(); var currentTree = _rootTrees.FirstOrDefault(x => x.Id == id && x.Visible); var splitId = new SplitRoutePath(id); collection.AddRange( currentTree != null ? InitializeTree(currentTree, splitId, queryStrings) : InitializeTree(splitId, queryStrings)); return(collection); }
/// <summary> /// Initializes the tree with a current starting node. /// </summary> /// <param name="currentTree"> /// The current Tree. /// </param> /// <param name="splitId"> /// The split id. /// </param> /// <param name="queryStrings"> /// The query strings. /// </param> /// <returns> /// The <see cref="IEnumerable{TreeNode}"/>. /// </returns> private IEnumerable <TreeNode> InitializeTree(TreeElement currentTree, SplitRoutePath splitId, FormDataCollection queryStrings) { // collection tree if (_collectiontrees.Contains(splitId.CollectionId)) { return(this.GetTreeNodesForCollections( splitId.CollectionId, MakeCollectionRoutePathId(splitId.CollectionId, splitId.CollectionKey), queryStrings)); } if (_attributetrees.Contains(splitId.CollectionId)) { return(GetAttributeDefinedTrees(queryStrings)); } return(currentTree.SubTree.GetTrees() .Where(x => x.Visible) .Select(tree => GetTreeNodeFromConfigurationElement(tree, queryStrings, currentTree))); }
/// <summary> /// Initializes the tree without a current starting node. /// </summary> /// <param name="splitId"> /// The split id. /// </param> /// <param name="queryStrings"> /// The query strings. /// </param> /// <returns> /// The <see cref="IEnumerable{TreeNode}"/>. /// </returns> private IEnumerable <TreeNode> InitializeTree(SplitRoutePath splitId, FormDataCollection queryStrings) { var backoffice = MerchelloConfiguration.Current.BackOffice; if (_collectiontrees.Contains(splitId.CollectionId)) { return(this.GetTreeNodesForCollections( splitId.CollectionId, MakeCollectionRoutePathId(splitId.CollectionId, splitId.CollectionKey), queryStrings, false)); } if (_attributetrees.Contains(splitId.CollectionId)) { return(GetAttributeDefinedTrees(queryStrings)); } return(backoffice.GetTrees() .Where(x => x.Visible) .Select(tree => GetTreeNodeFromConfigurationElement(tree, queryStrings))); }
/// <summary> /// Gets tree nodes for static collections. /// </summary> /// <param name="info"> /// The info. /// </param> /// <param name="splitId"> /// The split id. /// </param> /// <param name="collectionId"> /// The collection id. /// </param> /// <param name="parentRouteId"> /// The parent route id. /// </param> /// <param name="queryStrings"> /// The query strings. /// </param> /// <param name="collectionRoots"> /// The collection roots. /// </param> /// <returns> /// The <see cref="IEnumerable{TreeNode}"/>. /// </returns> private IEnumerable<TreeNode> GetTreeNodesFromCollection(CollectionProviderInfo info, SplitRoutePath splitId, string collectionId, string parentRouteId, FormDataCollection queryStrings, bool collectionRoots = true) { var collections = collectionRoots ? info.ManagedCollections.Where(x => x.ParentKey == null).OrderBy(x => x.SortOrder) : info.ManagedCollections.Where(x => x.ParentKey == splitId.CollectionKeyAsGuid()) .OrderBy(x => x.SortOrder); var treeNodes = collections.Any() ? collections.Select( collection => CreateTreeNode( MakeCollectionRoutePathId(collectionId, collection.Key.ToString()), parentRouteId, queryStrings, collection.Name, "icon-list", info.ManagedCollections.Any(x => x.ParentKey == collection.Key), string.Format("/merchello/merchello/{0}/{1}", info.ViewName, collection.Key))).ToArray() : new TreeNode[] { }; if (!treeNodes.Any()) return treeNodes; //// need to tag these nodes so that they can be filtered by the directive to select which //// collections entities can be assigned to via the back office foreach (var tn in treeNodes) { tn.CssClasses.Add("static-collection"); } return treeNodes; }
/// <summary> /// Gets tree nodes for self managed collection providers. /// </summary> /// <param name="currentTree"> /// The current tree. /// </param> /// <param name="info"> /// The info. /// </param> /// <param name="splitId"> /// The split id. /// </param> /// <param name="collectionId"> /// The collection id. /// </param> /// <param name="parentRouteId"> /// The parent route id. /// </param> /// <param name="queryStrings"> /// The query strings. /// </param> /// <returns> /// The <see cref="IEnumerable{TreeNode}"/>. /// </returns> private IEnumerable<TreeNode> GetTreeNodesForSelfManagedProviders( TreeElement currentTree, CollectionProviderInfo info, SplitRoutePath splitId, string collectionId, string parentRouteId, FormDataCollection queryStrings) { var treeNodes = new List<TreeNode>(); if (splitId.IsChildCollection) return treeNodes; // if there are no self managed providers - return if (currentTree.SelfManagedEntityCollectionProviderCollections == null || !currentTree.SelfManagedEntityCollectionProviderCollections.EntityCollectionProviders().Any(x => x.Visible)) return treeNodes; return this.GetTreeNodeForConfigurationEntityCollectionProviders(currentTree, collectionId, info, queryStrings, parentRouteId); }
/// <summary> /// Gets tree nodes for collections. /// </summary> /// <param name="collectionId"> /// The collection id. /// </param> /// <param name="parentRouteId"> /// The parent route id. /// </param> /// <param name="queryStrings"> /// The query strings. /// </param> /// <param name="collectionRoots"> /// Indicates this is a collection root node /// </param> /// <returns> /// The <see cref="IEnumerable{TreeNode}"/>. /// </returns> private IEnumerable<TreeNode> GetTreeNodesForCollections(string collectionId, string parentRouteId, FormDataCollection queryStrings, bool collectionRoots = true) { var info = this.GetCollectionProviderInfo(collectionId); var splitId = new SplitRoutePath(parentRouteId); // add any configured dynamic collections var currentTree = _rootTrees.FirstOrDefault(x => x.Id == splitId.CollectionId && x.Visible); var treeNodes = new List<TreeNode>(); if (currentTree == null) return treeNodes; var managedFirst = true; if (currentTree.ChildSettings.Count > 0) { var setting = currentTree.ChildSettings.AllSettings() .First(x => x.Alias == "selfManagedProvidersBeforeStaticProviders"); if (setting != null) managedFirst = bool.Parse(setting.Value); } if (managedFirst) { var sm = GetTreeNodesForSelfManagedProviders(currentTree, info, splitId, collectionId, parentRouteId, queryStrings).ToArray(); if (sm.Any()) treeNodes.AddRange(sm); var sc = GetTreeNodesFromCollection(info, splitId, collectionId, parentRouteId, queryStrings, collectionRoots).ToArray(); if (sc.Any()) treeNodes.AddRange(sc); } else { var sc = GetTreeNodesFromCollection(info, splitId, collectionId, parentRouteId, queryStrings, collectionRoots).ToArray(); if (sc.Any()) treeNodes.AddRange(sc); var sm = GetTreeNodesForSelfManagedProviders(currentTree, info, splitId, collectionId, parentRouteId, queryStrings).ToArray(); if (sm.Any()) treeNodes.AddRange(sm); } return treeNodes; }
/// <summary> /// The get tree nodes. /// </summary> /// <param name="id"> /// The id. /// </param> /// <param name="queryStrings"> /// The query strings. /// </param> /// <returns> /// The <see cref="TreeNodeCollection"/>. /// </returns> protected override TreeNodeCollection GetTreeNodes(string id, FormDataCollection queryStrings) { var collection = new TreeNodeCollection(); var backoffice = MerchelloConfiguration.Current.BackOffice; var currentTree = _rootTrees.FirstOrDefault(x => x.Id == id && x.Visible); var splitId = new SplitRoutePath(id); collection.AddRange( currentTree != null ? currentTree.Id == "reports" ? GetAttributeDefinedTrees(queryStrings) : _collectiontrees.Contains(splitId.CollectionId) ? this.GetTreeNodesForCollections(splitId.CollectionId, MakeCollectionRoutePathId(splitId.CollectionId, splitId.CollectionKey), queryStrings) : currentTree.SubTree.GetTrees().Where(x => x.Visible) .Select(tree => GetTreeNodeFromConfigurationElement(tree, queryStrings, currentTree)) : _collectiontrees.Contains(splitId.CollectionId) ? this.GetTreeNodesForCollections(splitId.CollectionId, MakeCollectionRoutePathId(splitId.CollectionId, splitId.CollectionKey), queryStrings, false) : backoffice.GetTrees().Where(x => x.Visible) .Select(tree => GetTreeNodeFromConfigurationElement(tree, queryStrings))); return collection; }
/// <summary> /// The get menu for node. /// </summary> /// <param name="id"> /// The id. /// </param> /// <param name="queryStrings"> /// The query strings. /// </param> /// <returns> /// The <see cref="MenuItemCollection"/>. /// </returns> protected override MenuItemCollection GetMenuForNode(string id, FormDataCollection queryStrings) { var menu = new MenuItemCollection(); // Products if (id == "products") { menu.Items.Add<NewCollectionAction>( _textService.Localize("merchelloVariant/newProduct", _culture), false).NavigateToRoute("merchello/merchello/productedit/create"); menu.Items.Add<NewProductContentTypeAction>( _textService.Localize("merchelloDetachedContent/productContentType", _culture), false) .LaunchDialogView(DialogsPath + "productcontenttype.add.html", _textService.Localize("merchelloDetachedContent/productContentType", _culture)); } if (id == "customers") { menu.Items.Add<NewCollectionAction>( _textService.Localize("merchelloCustomers/newCustomer", _culture), false) .LaunchDialogView(DialogsPath + "customer.newcustomer.html", _textService.Localize("merchelloCustomers/newCustomer", _culture)); } if (id == "marketing") { menu.Items.Add<NewOfferSettingsAction>( _textService.Localize("merchelloMarketing/newOffer", _culture), false) .LaunchDialogView( DialogsPath + "marketing.newofferproviderselection.html", _textService.Localize("merchelloMarketing/newOffer", _culture)); } //// child nodes will have an id separated with a hypen and key //// e.g. products_[GUID] var splitId = new SplitRoutePath(id); if (_collectiontrees.Contains(splitId.CollectionId) && !id.EndsWith("_resolved")) { menu.Items.Add<NewCollectionAction>( _textService.Localize(string.Format("merchelloCollections/{0}", NewCollectionAction.Instance.Alias), _culture), _collectiontrees.Contains(id), new Dictionary<string, object>() { { "dialogData", new { entityType = splitId.CollectionId, parentKey = splitId.CollectionKey } } }).LaunchDialogView(DialogsPath + "create.staticcollection.html", _textService.Localize(string.Format("merchelloCollections/{0}", NewCollectionAction.Instance.Alias), _culture)); if (!_collectiontrees.Contains(id)) // don't show this on root nodes menu.Items.Add<ManageEntitiesAction>( _textService.Localize(string.Format("merchelloCollections/{0}", ManageEntitiesAction.Instance.Alias), _culture), false, new Dictionary<string, object>() { { "dialogData", new { entityType = splitId.CollectionId, collectionKey = splitId.CollectionKey } } }).LaunchDialogView(DialogsPath + "manage.staticcollection.html", _textService.Localize(string.Format("merchelloCollections/{0}", ManageEntitiesAction.Instance.Alias), _culture)); menu.Items.Add<SortCollectionAction>( _textService.Localize("actions/sort", _culture), false, new Dictionary<string, object>() { { "dialogData", new { entityType = splitId.CollectionId, parentKey = splitId.CollectionKey } } }).LaunchDialogView(DialogsPath + "sort.staticcollection.html", _textService.Localize(string.Format("merchelloCollections/{0}", SortCollectionAction.Instance.Alias), _culture)); if (splitId.IsChildCollection) { // add the delete button menu.Items.Add<DeleteCollectionAction>( _textService.Localize("actions/delete", _culture), false, new Dictionary<string, object>() { { "dialogData", new { entityType = splitId.CollectionId, collectionKey = splitId.CollectionKey } } }) .LaunchDialogView(DialogsPath + "delete.staticcollection.html", _textService.Localize("actions/delete", _culture)); } } menu.Items.Add<RefreshNode, ActionRefresh>(_textService.Localize(string.Format("actions/{0}", ActionRefresh.Instance.Alias), _culture), id != "gateways" && !id.EndsWith("_resolved")); return menu; }
/// <summary> /// Gets tree nodes for static collections. /// </summary> /// <param name="info"> /// The info. /// </param> /// <param name="splitId"> /// The split id. /// </param> /// <param name="collectionId"> /// The collection id. /// </param> /// <param name="parentRouteId"> /// The parent route id. /// </param> /// <param name="queryStrings"> /// The query strings. /// </param> /// <param name="collectionRoots"> /// The collection roots. /// </param> /// <returns> /// The <see cref="IEnumerable{TreeNode}"/>. /// </returns> private IEnumerable <TreeNode> GetTreeNodesFromCollection(CollectionProviderInfo info, SplitRoutePath splitId, string collectionId, string parentRouteId, FormDataCollection queryStrings, bool collectionRoots = true) { var collections = collectionRoots ? info.ManagedCollections.Where(x => x.ParentKey == null).OrderBy(x => x.SortOrder) : info.ManagedCollections.Where(x => x.ParentKey == splitId.CollectionKeyAsGuid()) .OrderBy(x => x.SortOrder); var treeNodes = collections.Any() ? collections.Select( collection => CreateTreeNode( MakeCollectionRoutePathId(collectionId, collection.Key.ToString()), parentRouteId, queryStrings, collection.Name, "icon-list", info.ManagedCollections.Any(x => x.ParentKey == collection.Key), string.Format("/merchello/merchello/{0}/{1}", info.ViewName, collection.Key))).ToArray() : new TreeNode[] { }; if (!treeNodes.Any()) { return(treeNodes); } //// need to tag these nodes so that they can be filtered by the directive to select which //// collections entities can be assigned to via the back office foreach (var tn in treeNodes) { tn.CssClasses.Add("static-collection"); } return(treeNodes); }
/// <summary> /// The get menu for node. /// </summary> /// <param name="id"> /// The id. /// </param> /// <param name="queryStrings"> /// The query strings. /// </param> /// <returns> /// The <see cref="MenuItemCollection"/>. /// </returns> protected override MenuItemCollection GetMenuForNode(string id, FormDataCollection queryStrings) { var menu = new MenuItemCollection(); // Products if (id == "products") { menu.Items.Add <NewCollectionAction>( _textService.Localize("merchelloVariant/newProduct", _culture), false) .LaunchDialogView( DialogsPath + "product.add.html", _textService.Localize("merchelloVariant/newProduct", _culture)); //.NavigateToRoute("merchello/merchello/productedit/create"); menu.Items.Add <NewProductContentTypeAction>( _textService.Localize("merchelloDetachedContent/associateContentType", _culture), false) .LaunchDialogView(DialogsPath + "productcontenttype.add.html", _textService.Localize("merchelloDetachedContent/associateContentType", _culture)); } if (id == "customers") { menu.Items.Add <NewCollectionAction>( _textService.Localize("merchelloCustomers/newCustomer", _culture), false) .LaunchDialogView(DialogsPath + "customer.newcustomer.html", _textService.Localize("merchelloCustomers/newCustomer", _culture)); } if (id == "marketing") { menu.Items.Add <NewOfferSettingsAction>( _textService.Localize("merchelloMarketing/newOffer", _culture), false) .LaunchDialogView( DialogsPath + "marketing.newofferproviderselection.html", _textService.Localize("merchelloMarketing/newOffer", _culture)); } //// child nodes will have an id separated with a hypen and key //// e.g. products_[GUID] var splitId = new SplitRoutePath(id); if (_collectiontrees.Contains(splitId.CollectionId) && !id.EndsWith("_resolved")) { menu.Items.Add <NewCollectionAction>( _textService.Localize(string.Format("merchelloCollections/{0}", NewCollectionAction.Instance.Alias), _culture), _collectiontrees.Contains(id), new Dictionary <string, object>() { { "dialogData", new { entityType = splitId.CollectionId, parentKey = splitId.CollectionKey } } }).LaunchDialogView(DialogsPath + "create.staticcollection.html", _textService.Localize(string.Format("merchelloCollections/{0}", NewCollectionAction.Instance.Alias), _culture)); if (!_collectiontrees.Contains(id)) // don't show this on root nodes { menu.Items.Add <ManageEntitiesAction>( _textService.Localize(string.Format("merchelloCollections/{0}", ManageEntitiesAction.Instance.Alias), _culture), false, new Dictionary <string, object>() { { "dialogData", new { entityType = splitId.CollectionId, collectionKey = splitId.CollectionKey } } }).LaunchDialogView(DialogsPath + "manage.staticcollection.html", _textService.Localize(string.Format("merchelloCollections/{0}", ManageEntitiesAction.Instance.Alias), _culture)); } menu.Items.Add <SortCollectionAction>( _textService.Localize("actions/sort", _culture), false, new Dictionary <string, object>() { { "dialogData", new { entityType = splitId.CollectionId, parentKey = splitId.CollectionKey } } }).LaunchDialogView(DialogsPath + "sort.staticcollection.html", _textService.Localize(string.Format("merchelloCollections/{0}", SortCollectionAction.Instance.Alias), _culture)); if (splitId.IsChildCollection) { // add the delete button menu.Items.Add <DeleteCollectionAction>( _textService.Localize("actions/delete", _culture), false, new Dictionary <string, object>() { { "dialogData", new { entityType = splitId.CollectionId, collectionKey = splitId.CollectionKey } } }) .LaunchDialogView(DialogsPath + "delete.staticcollection.html", _textService.Localize("actions/delete", _culture)); } } menu.Items.Add <RefreshNode, ActionRefresh>(_textService.Localize(string.Format("actions/{0}", ActionRefresh.Instance.Alias), _culture), id != "gateways" && !id.EndsWith("_resolved")); return(menu); }