Beispiel #1
0
        internal override void RenderElement(RenderContext context, Action <TagBuilder> onRender = null)
        {
            if (SkipRender(context))
            {
                return;
            }
            TagBuilder page       = null;
            Boolean    isGridPage = (Toolbar != null) || (Taskpad != null) || (Pager != null);

            // render page OR colleciton view

            void addGridAction(TagBuilder tag)
            {
                if (!isGridPage)
                {
                    return;
                }
                tag.AddCssClass("page-grid");
                if (Taskpad != null)
                {
                    if (Taskpad is Taskpad tp && tp.Width != null)
                    {
                        tag.MergeStyle("grid-template-columns", $"1fr {tp.Width.Value}");
                    }
                }
            }

            if (CollectionView != null)
            {
                CollectionView.RenderStart(context, (tag) =>
                {
                    tag.AddCssClass("page").AddCssClass("absolute");
                    addGridAction(tag);
                    AddAttributes(tag);
                    tag.MergeAttribute("id", context.RootId);
                });
            }
            else
            {
                page = new TagBuilder("div", "page absolute");
                page.MergeAttribute("id", context.RootId);
                addGridAction(page);
                AddAttributes(page);
                page.RenderStart(context);
            }


            RenderTitle(context);

            if (isGridPage)
            {
                Toolbar?.RenderElement(context, (tag) => tag.AddCssClass("page-toolbar"));
                Taskpad?.RenderElement(context, (tag) => tag.AddCssClass("page-taskpad"));
                Pager?.RenderElement(context, (tag) => tag.AddCssClass("page-pager"));
                var content = new TagBuilder("div", "page-content").RenderStart(context);
                RenderChildren(context);
                content.RenderEnd(context);
            }
            else
            {
                RenderChildren(context);
            }

            if (CollectionView != null)
            {
                CollectionView.RenderEnd(context);
            }
            else
            {
                if (page == null)
                {
                    throw new InvalidProgramException();
                }
                page.RenderEnd(context);
            }
        }