private IResolvedSetup <CollectionSetup> ConvertConfig(CollectionConfig config)
        {
            var collection = new CollectionSetup(
                config.Icon,
                config.Name,
                config.Alias,
                config.RepositoryType,
                isRecursive: config.Recursive,
                isResolverCachable: true) // TODO
            {
                DataViews       = config.DataViews,
                DataViewBuilder = config.DataViewBuilder
            };

            var cacheable = true;

            collection.EntityVariant = _entityVariantResolver.ResolveSetup(config.EntityVariant, collection).CheckIfCachable(ref cacheable);
            if (config.SubEntityVariants.Any())
            {
                collection.SubEntityVariants = _entityVariantResolver.ResolveSetup(config.SubEntityVariants, collection).CheckIfCachable(ref cacheable).ToList();
            }

            collection.TreeView = config.TreeView == null ? null : _treeViewResolver.ResolveSetup(config.TreeView, collection).CheckIfCachable(ref cacheable);

            collection.ListView   = config.ListView == null ? null : _listResolver.ResolveSetup(config.ListView, collection).CheckIfCachable(ref cacheable);
            collection.ListEditor = config.ListEditor == null ? null : _listResolver.ResolveSetup(config.ListEditor, collection).CheckIfCachable(ref cacheable);

            collection.NodeView   = config.NodeView == null ? null : _nodeResolver.ResolveSetup(config.NodeView, collection).CheckIfCachable(ref cacheable);
            collection.NodeEditor = config.NodeEditor == null ? null : _nodeResolver.ResolveSetup(config.NodeEditor, collection).CheckIfCachable(ref cacheable);

            collection.Collections = _treeElementResolver.ResolveSetup(config.CollectionsAndPages, collection).CheckIfCachable(ref cacheable).ToList();

            return(new ResolvedSetup <CollectionSetup>(collection, cacheable));
        }
        public void Setup()
        {
            _serviceProviderMock = new Mock <IServiceProvider>();

            _navigationStateProvider = new Mock <INavigationStateProvider>();

            _entityVariant = new EntityVariantSetup("ev", "icon", typeof(IEntity), "alias");
            _collection    = new CollectionSetup("icon", "color", "name", "alias", "repo")
            {
                EntityVariant = _entityVariant
            };
            _collectionResolver = new Mock <ISetupResolver <CollectionSetup> >();
            _collectionResolver
            .Setup(x => x.ResolveSetupAsync(It.IsAny <string>()))
            .ReturnsAsync(_collection);

            _repositoryResolver = new Mock <IRepositoryResolver>();
            _concurrencyService = new ConcurrencyService(new SemaphoreSlim(1, 1));
            _buttonInteraction  = new Mock <IButtonInteraction>();
            _editContextFactory = new Mock <IEditContextFactory>();
            _mediator           = new Mock <IMediator>();

            _subject = new EntityInteractionDispatcher(
                _navigationStateProvider.Object,
                _collectionResolver.Object,
                _repositoryResolver.Object,
                _concurrencyService,
                _buttonInteraction.Object,
                _editContextFactory.Object,
                _mediator.Object);
        }
 private Task <IEnumerable <IDataView> > GetDataViewsAsync(CollectionSetup collection)
 {
     if (collection.DataViewBuilder == null)
     {
         return(Task.FromResult(collection.DataViews ?? Enumerable.Empty <IDataView>()));
     }
     else
     {
         var builder = _serviceProvider.GetService <IDataViewBuilder>(collection.DataViewBuilder);
         return(builder.GetDataViewsAsync());
     }
 }
Beispiel #4
0
        internal static List <ITreeElementSetup> ProcessCollections(this ICollectionConfig root)
        {
            var list = new List <ITreeElementSetup>();

            foreach (var element in root.CollectionsAndPages)
            {
                if (element is CollectionConfig collectionConfigReceiver)
                {
                    var collection = new CollectionSetup(
                        collectionConfigReceiver.Icon,
                        collectionConfigReceiver.Name,
                        collectionConfigReceiver.Alias,
                        new EntityVariantSetup(collectionConfigReceiver.EntityVariant),
                        collectionConfigReceiver.RepositoryType,
                        collectionConfigReceiver.Recursive)
                    {
                        DataViews       = collectionConfigReceiver.DataViews,
                        DataViewBuilder = collectionConfigReceiver.DataViewBuilder
                    };

                    if (collectionConfigReceiver.SubEntityVariants.Any())
                    {
                        collection.SubEntityVariants = collectionConfigReceiver.SubEntityVariants.ToList(variant => new EntityVariantSetup(variant));
                    }

                    collection.TreeView = collectionConfigReceiver.TreeView == null ? null : new TreeViewSetup(collectionConfigReceiver.TreeView);

                    collection.ListView   = collectionConfigReceiver.ListView == null ? null : new ListSetup(collectionConfigReceiver.ListView, collection);
                    collection.ListEditor = collectionConfigReceiver.ListEditor == null ? null : new ListSetup(collectionConfigReceiver.ListEditor, collection);

                    collection.NodeView   = collectionConfigReceiver.NodeView == null ? null : new NodeSetup(collectionConfigReceiver.NodeView, collection);
                    collection.NodeEditor = collectionConfigReceiver.NodeEditor == null ? null : new NodeSetup(collectionConfigReceiver.NodeEditor, collection);

                    // nested pages are not supported
                    collection.Collections = collectionConfigReceiver.ProcessCollections().SelectNotNull(x => x as CollectionSetup).ToList();

                    list.Add(collection);
                }
                else if (element is IPageConfig pageConfigReceiver)
                {
                    list.Add(new PageRegistrationSetup(pageConfigReceiver));
                }
            }

            return(list);
        }
Beispiel #5
0
        private IResolvedSetup <CollectionSetup> ConvertConfig(CollectionConfig config)
        {
            var repositoryAlias = _repositoryTypeResolver.GetAlias(config.RepositoryType);

            var collection = new CollectionSetup(
                config.Icon,
                config.Color,
                config.Name,
                config.Alias,
                repositoryAlias,
                isRecursive: config.Recursive,
                isResolverCachable: true) // TODO
            {
                DataViews       = config.DataViews,
                DataViewBuilder = config.DataViewBuilder,
                UsageType       = GetCollectionUsage(config)
            };

            var cacheable = true;

            if (!string.IsNullOrWhiteSpace(config.ParentAlias) && _collectionMap.TryGetValue(config.ParentAlias, out var collectionConfig))
            {
                collection.Parent = new TreeElementSetup(collectionConfig.Alias, PageType.Collection); // TODO: enum
            }
            collection.Collections = _treeElementResolver.ResolveSetup(config.CollectionsAndPages, collection).CheckIfCachable(ref cacheable).ToList();

            collection.EntityVariant = _entityVariantResolver.ResolveSetup(config.EntityVariant, collection).CheckIfCachable(ref cacheable);
            if (config.SubEntityVariants.Any())
            {
                collection.SubEntityVariants = _entityVariantResolver.ResolveSetup(config.SubEntityVariants, collection).CheckIfCachable(ref cacheable).ToList();
            }

            collection.TreeView = config.TreeView == null ? null : _treeViewResolver.ResolveSetup(config.TreeView, collection).CheckIfCachable(ref cacheable);

            collection.ListView   = config.ListView == null ? null : _listResolver.ResolveSetup(config.ListView, collection).CheckIfCachable(ref cacheable);
            collection.ListEditor = config.ListEditor == null ? null : _listResolver.ResolveSetup(config.ListEditor, collection).CheckIfCachable(ref cacheable);

            collection.NodeView   = config.NodeView == null ? null : _nodeResolver.ResolveSetup(config.NodeView, collection).CheckIfCachable(ref cacheable);
            collection.NodeEditor = config.NodeEditor == null ? null : _nodeResolver.ResolveSetup(config.NodeEditor, collection).CheckIfCachable(ref cacheable);

            return(new ResolvedSetup <CollectionSetup>(collection, cacheable));
        }
Beispiel #6
0
        public void Setup()
        {
            _button = new ButtonSetup
            {
                ButtonId = "123",
                Buttons  = new List <ButtonSetup>()
            };

            _collection = new CollectionSetup("icon", "color", "name", "alias", "repo")
            {
                ListEditor = new ListSetup(
                    null,
                    null,
                    null,
                    ListType.Table,
                    EmptyVariantColumnVisibility.Visible,
                    new List <PaneSetup>(),
                    new List <ButtonSetup>
                {
                    _button
                })
            };

            _collectionResolver = new Mock <ISetupResolver <CollectionSetup> >();
            _collectionResolver
            .Setup(x => x.ResolveSetupAsync(It.IsAny <string>()))
            .ReturnsAsync(_collection);

            _buttonActionHandler         = new Mock <IButtonActionHandler>();
            _buttonActionHandlerResolver = new Mock <IButtonActionHandlerResolver>();
            _buttonActionHandlerResolver
            .Setup(x => x.GetButtonActionHandler(It.IsAny <ButtonSetup>()))
            .Returns(_buttonActionHandler.Object);

            _authService     = new Mock <IAuthService>();
            _serviceProvider = new ServiceCollection().AddTransient <DataAnnotationEntityValidator>().BuildServiceProvider();

            _subject = new ButtonInteraction(_collectionResolver.Object, _buttonActionHandlerResolver.Object, _authService.Object);
        }
        public void Setup()
        {
            _collection = new CollectionSetup("icon", "color", "name", "alias", "repo")
            {
                ListEditor = new ListSetup(
                    null,
                    null,
                    null,
                    ListType.Table,
                    EmptyVariantColumnVisibility.Visible,
                    new List <PaneSetup>(),
                    new List <ButtonSetup>
                {
                    new ButtonSetup
                    {
                        ButtonId = "abc",
                        Buttons  = new List <ButtonSetup>()
                    },
                    new ButtonSetup
                    {
                        ButtonId = "def",
                        Buttons  = new List <ButtonSetup>()
                    }
                })
            };

            _collectionResolver = new Mock <ISetupResolver <CollectionSetup> >();
            _collectionResolver
            .Setup(x => x.ResolveSetupAsync(It.IsAny <string>()))
            .ReturnsAsync(_collection);

            _buttonActionHandlerResolver = new Mock <IButtonActionHandlerResolver>();

            _authService     = new Mock <IAuthService>();
            _serviceProvider = new Mock <IServiceProvider>();

            _subject = new ButtonInteraction(_collectionResolver.Object, _buttonActionHandlerResolver.Object, _authService.Object);
        }
Beispiel #8
0
        internal static List <CollectionSetup> ProcessCollections(this ICollectionConfig root)
        {
            var list = new List <CollectionSetup>();

            foreach (var configReceiver in root.Collections.Cast <CollectionConfig>())
            {
                var collection = new CollectionSetup(
                    configReceiver.Icon,
                    configReceiver.Name,
                    configReceiver.Alias,
                    new EntityVariantSetup(configReceiver.EntityVariant),
                    configReceiver.RepositoryType,
                    configReceiver.Recursive)
                {
                    DataViews       = configReceiver.DataViews,
                    DataViewBuilder = configReceiver.DataViewBuilder
                };

                if (configReceiver.SubEntityVariants.Any())
                {
                    collection.SubEntityVariants = configReceiver.SubEntityVariants.ToList(variant => new EntityVariantSetup(variant));
                }

                collection.TreeView = configReceiver.TreeView == null ? null : new TreeViewSetup(configReceiver.TreeView);

                collection.ListView   = configReceiver.ListView == null ? null : new ListSetup(configReceiver.ListView, collection);
                collection.ListEditor = configReceiver.ListEditor == null ? null : new ListSetup(configReceiver.ListEditor, collection);

                collection.NodeView   = configReceiver.NodeView == null ? null : new NodeSetup(configReceiver.NodeView, collection);
                collection.NodeEditor = configReceiver.NodeEditor == null ? null : new NodeSetup(configReceiver.NodeEditor, collection);

                collection.Collections = configReceiver.ProcessCollections();

                list.Add(collection);
            }

            return(list);
        }
Beispiel #9
0
 public Collection(IEnumerable <TData> collection, CollectionSetup setupAction)
 {
     _collection = collection;
     SetupAction = setupAction;
 }
 private static bool ShouldFallbackToNavigatingToNodeEditor(CollectionSetup collection)
 {
     return(collection.NodeEditor != null);
 }
 IRepository IRepositoryResolver.GetRepository(CollectionSetup collection)
 => (this as IRepositoryResolver).GetRepository(collection.RepositoryAlias);