Exemplo n.º 1
0
        protected override void RenderContentAreaItems(HtmlHelper htmlHelper, IEnumerable <ContentAreaItem> contentAreaItems)
        {
            bool?result      = null;
            var  actualValue = htmlHelper.ViewContext.ViewData["rowsupport"];

            if (actualValue is bool)
            {
                result = (bool)actualValue;
            }
            var isRowSupported = result;
            var addRowMarkup   = ConfigurationContext.Current.RowSupportEnabled && isRowSupported.HasValue && isRowSupported.Value;

            // there is no need to proceed if row rendering support is disabled
            if (!addRowMarkup)
            {
                CustomizedRenderContentAreaItems(htmlHelper, contentAreaItems);
                return;
            }

            var rowRender = new RowRenderer();

            rowRender.Render(contentAreaItems,
                             htmlHelper,
                             GetContentAreaItemTemplateTag,
                             GetColumnWidth,
                             CustomizedRenderContentAreaItems);
        }
        public static void RenderFormElements(
            this HtmlHelper html,
            int currentStepIndex,
            IEnumerable <IFormElement> elements,
            FormContainerBlock model,
            object additionalValues = null)
        {
            // this means that somebody else took renderer seat and we need to find way around it
            // essentially the only thing that is needed is access to renderer instance - we can create one from scratch here also
            var renderer = ServiceLocator.Current.GetInstance <ContentAreaRenderer>() as BootstrapAwareContentAreaRenderer
                           ?? new BootstrapAwareContentAreaRenderer(SetupBootstrapRenderer.AllDisplayOptions);

            var additionalParameters = new RouteValueDictionary(additionalValues);

            var isRowSupported = additionalParameters.GetValueFromDictionary("rowsupport");
            var addRowMarkup   = ConfigurationContext.Current.RowSupportEnabled && isRowSupported.HasValue && isRowSupported.Value;

            if (!addRowMarkup)
            {
                foreach (var element in elements)
                {
                    var areaItem = model
                                   .ElementsArea
                                   .Items
                                   .FirstOrDefault(i => i.ContentLink == element.SourceContent.ContentLink);

                    RenderAreaItem(html, areaItem, renderer, element);
                }
            }
            else
            {
                var rowRenderer = new RowRenderer();
                rowRenderer.Render(
                    model.ElementsArea.Items,
                    html,
                    renderer.ContentAreaItemTemplateTagCore,
                    renderer.GetColumnWidth,
                    (_, items) => RenderItems(html, items, renderer, elements));
            }
        }