示例#1
0
        /// <summary>
        /// Resolves a provider and view for collection node.
        /// </summary>
        /// <param name="collectionId">
        /// The collection id.
        /// </param>
        /// <returns>
        /// The <see cref="CollectionProviderInfo"/>.
        /// </returns>
        private CollectionProviderInfo GetCollectionProviderInfo(string collectionId)
        {
            collectionId = collectionId.ToLowerInvariant();
            var info = new CollectionProviderInfo();

            switch (collectionId)
            {
            case "sales":
                info.ManagedCollections =
                    this._entityCollectionProviderResolver.GetProviderAttribute <StaticInvoiceCollectionProvider>()
                    .ToEntityCollectionProviderDisplay().ManagedCollections;

                info.ViewName = "saleslist";
                break;

            case "customers":
                info.ManagedCollections =
                    this._entityCollectionProviderResolver.GetProviderAttribute <StaticCustomerCollectionProvider>()
                    .ToEntityCollectionProviderDisplay().ManagedCollections;
                info.ViewName = "customerlist";
                break;

            default:
                info.ManagedCollections =
                    this._entityCollectionProviderResolver.GetProviderAttribute <StaticProductCollectionProvider>()
                    .ToEntityCollectionProviderDisplay().ManagedCollections;
                info.ViewName = "productlist";
                break;
            }

            return(info);
        }
示例#2
0
        /// <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));
        }
示例#3
0
        /// <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 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>
        /// The get tree node from configuration element.
        /// </summary>
        /// <param name="tree">
        /// The tree.
        /// </param>
        /// <param name="collectionId">
        /// The root collection type (e.g. sales, product, customer)
        /// </param>
        /// <param name="info">
        /// The info.
        /// </param>
        /// <param name="queryStrings">
        /// The query strings.
        /// </param>
        /// <param name="parentRouteId">The parent route id</param>
        /// <returns>
        /// The <see cref="IEnumerable{TreeNode}"/>.
        /// </returns>
        private IEnumerable<TreeNode> GetTreeNodeForConfigurationEntityCollectionProviders(TreeElement tree, string collectionId, CollectionProviderInfo info, FormDataCollection queryStrings, string parentRouteId)
        {
            // get the self managed providers
            var grouping = new List<Tuple<EntityCollectionProviderElement, EntityCollectionProviderDisplay>>();
            foreach (var element in
                tree.SelfManagedEntityCollectionProviderCollections.EntityCollectionProviders().Where(x => x.Visible))
            {
                Guid elementKey;
                if (!Guid.TryParse(element.Key, out elementKey))
                {
                    continue;
                }

                var providerDisplay =
                    this._entityCollectionProviderResolver.GetProviderAttributes()
                        .First(x => x.Key == elementKey)
                        .ToEntityCollectionProviderDisplay();
                if (providerDisplay != null)
                {
                    grouping.Add(new Tuple<EntityCollectionProviderElement, EntityCollectionProviderDisplay>(element, providerDisplay));
                }
            }

            if (!grouping.Any()) return Enumerable.Empty<TreeNode>();

            var treeNodes = new List<TreeNode>();

            // ReSharper disable once LoopCanBeConvertedToQuery
            foreach (var g in grouping)
            {
                if (!g.Item2.ManagedCollections.Any()) continue;

                var element = g.Item1;
                var provider = g.Item2;
                var collection = g.Item2.ManagedCollections.First();

                treeNodes.Add(
                    this.CreateTreeNode(
                        MakeCollectionRoutePathId(collectionId, collection.Key.ToString()) + "_resolved",
                        parentRouteId,
                        queryStrings,
                        provider.LocalizedNameKey.IsNullOrWhiteSpace() ? provider.Name : this._textService.Localize(provider.LocalizedNameKey, this._culture),
                        element.Icon,
                        false,
                        string.Format("/merchello/merchello/{0}/{1}", info.ViewName, collection.Key)));
            }

            return treeNodes;
        }
        /// <summary>
        /// Resolves a provider and view for collection node.
        /// </summary>
        /// <param name="collectionId">
        /// The collection id.
        /// </param>
        /// <returns>
        /// The <see cref="CollectionProviderInfo"/>.
        /// </returns>
        private CollectionProviderInfo GetCollectionProviderInfo(string collectionId)
        {
            collectionId = collectionId.ToLowerInvariant();
            var info = new CollectionProviderInfo();

            switch (collectionId)
            {
                case "sales":
                    info.ManagedCollections =
                        this._entityCollectionProviderResolver.GetProviderAttribute<StaticInvoiceCollectionProvider>()
                            .ToEntityCollectionProviderDisplay().ManagedCollections;
                    info.ViewName = "saleslist";
                    break;
                case "customers":
                    info.ManagedCollections =
                        this._entityCollectionProviderResolver.GetProviderAttribute<StaticCustomerCollectionProvider>()
                            .ToEntityCollectionProviderDisplay().ManagedCollections;
                    info.ViewName = "customerlist";
                    break;
                default:
                    info.ManagedCollections =
                        this._entityCollectionProviderResolver.GetProviderAttribute<StaticProductCollectionProvider>()
                            .ToEntityCollectionProviderDisplay().ManagedCollections;
                    info.ViewName = "productlist";
                    break;
            }

            return info;
        }
示例#8
0
        /// <summary>
        /// The get tree node from configuration element.
        /// </summary>
        /// <param name="tree">
        /// The tree.
        /// </param>
        /// <param name="collectionId">
        /// The root collection type (e.g. sales, product, customer)
        /// </param>
        /// <param name="info">
        /// The info.
        /// </param>
        /// <param name="queryStrings">
        /// The query strings.
        /// </param>
        /// <param name="parentRouteId">The parent route id</param>
        /// <returns>
        /// The <see cref="IEnumerable{TreeNode}"/>.
        /// </returns>
        private IEnumerable <TreeNode> GetTreeNodeForConfigurationEntityCollectionProviders(TreeElement tree, string collectionId, CollectionProviderInfo info, FormDataCollection queryStrings, string parentRouteId)
        {
            // get the self managed providers
            var grouping = new List <Tuple <EntityCollectionProviderElement, EntityCollectionProviderDisplay> >();

            foreach (var element in
                     tree.SelfManagedEntityCollectionProviderCollections.EntityCollectionProviders().Where(x => x.Visible))
            {
                Guid elementKey;
                if (!Guid.TryParse(element.Key, out elementKey))
                {
                    continue;
                }

                var providerDisplay =
                    this._entityCollectionProviderResolver.GetProviderAttributes()
                    .First(x => x.Key == elementKey)
                    .ToEntityCollectionProviderDisplay();
                if (providerDisplay != null)
                {
                    grouping.Add(new Tuple <EntityCollectionProviderElement, EntityCollectionProviderDisplay>(element, providerDisplay));
                }
            }

            if (!grouping.Any())
            {
                return(Enumerable.Empty <TreeNode>());
            }

            var treeNodes = new List <TreeNode>();

            // ReSharper disable once LoopCanBeConvertedToQuery
            foreach (var g in grouping)
            {
                if (!g.Item2.ManagedCollections.Any())
                {
                    continue;
                }

                var element    = g.Item1;
                var provider   = g.Item2;
                var collection = g.Item2.ManagedCollections.First();

                treeNodes.Add(
                    this.CreateTreeNode(
                        MakeCollectionRoutePathId(collectionId, collection.Key.ToString()) + "_resolved",
                        parentRouteId,
                        queryStrings,
                        provider.LocalizedNameKey.IsNullOrWhiteSpace() ? provider.Name : this._textService.Localize(provider.LocalizedNameKey, this._culture),
                        element.Icon,
                        false,
                        string.Format("/merchello/merchello/{0}/{1}", info.ViewName, collection.Key)));
            }

            return(treeNodes);
        }