예제 #1
0
        protected internal async Task <SectionUI> GetSectionUIAsync(PaneSetup pane, FormEditContext editContext)
        {
            var fields = pane.Fields.Select(field =>
            {
                var dataProvider = _dataProviderResolver.GetDataProvider(field);
                if (dataProvider != null)
                {
                    editContext.DataProviders.Add(dataProvider);
                }

                return(index: field.Index, element: (ElementUI)GetField(field, dataProvider));
            });

            var subCollections = pane.SubCollectionLists.Select(subCollection =>
            {
                return(index: subCollection.Index, element: (ElementUI) new SubCollectionUI(subCollection));
            });

            var relatedCollections = pane.RelatedCollectionLists.Select(relatedCollection =>
            {
                return(index: relatedCollection.Index, element: (ElementUI) new RelatedCollectionUI(relatedCollection));
            });

            return(new SectionUI(pane.IsVisible)
            {
                Buttons = await GetButtonsAsync(pane.Buttons, editContext),
                CustomType = pane.CustomType,
                Label = pane.Label,

                Elements = fields
                           .Union(subCollections)
                           .Union(relatedCollections)
                           .OrderBy(x => x.index)
                           .ToList(x => x.element)
            });
        }
예제 #2
0
        protected internal async Task <SectionUI> GetSectionUIAsync(PaneSetup pane, FormEditContext editContext, NavigationState navigationState)
        {
            var fields = await pane.Fields.ToListAsync(async field =>
            {
                var dataProvider = await _dataProviderResolver.GetDataProviderAsync(field);
                if (dataProvider != null)
                {
                    editContext.DataProviders.Add(dataProvider);
                }

                return(index : field.Index, element : (ElementUI)GetField(field, dataProvider));
            });

            var subCollections = pane.SubCollectionLists
                                 .Where(subCollection => subCollection.SupportsUsageType.FindSupportedUsageType(editContext.UsageType) > UsageType.None)
                                 .Select(subCollection =>
            {
                var parentPath = ParentPath.AddLevel(editContext.Parent?.GetParentPath(), editContext.RepositoryAlias, editContext.Entity.Id !);

                // TODO: this does not read back the state (needed when nested states are saved in url)
                var nestedState = new NavigationState(
                    subCollection.CollectionAlias,
                    parentPath,
                    subCollection.SupportsUsageType.FindSupportedUsageType(editContext.UsageType) | UsageType.List);

                _navigationStateProvider.NestNavigationState(navigationState, nestedState);

                return(index: subCollection.Index, element: (ElementUI) new SubCollectionUI(subCollection, nestedState));
            });

            var relatedCollections = pane.RelatedCollectionLists
                                     .Where(relatedCollection => relatedCollection.SupportsUsageType.FindSupportedUsageType(editContext.UsageType) > UsageType.None)
                                     .Select(relatedCollection =>
            {
                var parentPath = ParentPath.AddLevel(editContext.Parent?.GetParentPath(), editContext.RepositoryAlias, editContext.Entity.Id !);

                // TODO: this does not read back the state (needed when nested states are saved in url)
                var nestedState = new NavigationState(
                    relatedCollection.CollectionAlias,
                    parentPath,
                    new RelatedEntity(editContext),
                    relatedCollection.SupportsUsageType.FindSupportedUsageType(editContext.UsageType) | UsageType.List,
                    PageType.Collection);

                _navigationStateProvider.NestNavigationState(navigationState, nestedState);

                return(index: relatedCollection.Index, element: (ElementUI) new RelatedCollectionUI(relatedCollection, nestedState));
            });

            return(new SectionUI(pane.IsVisible)
            {
                Buttons = await GetButtonsAsync(pane.Buttons, editContext),
                CustomType = pane.CustomType,
                Label = pane.Label,

                Elements = fields
                           .Union(subCollections)
                           .Union(relatedCollections)
                           .OrderBy(x => x.index)
                           .ToList(x => x.element)
            });
        }