Ejemplo n.º 1
0
        private string RenderPropertiesTab(FormEditorRenderingOptions renderingOptions)
        {
            var propertiesContainerBuilder = new TagBuilder("div");
            var toolbarBuilder             = GetToolbarBuilder("Properties", renderingOptions);
            var settingsContainerBuilder   = new TagBuilder("div");

            settingsContainerBuilder.AddCssClass("form_builder-settingsContainer row");

            var controls = this.Builder.GetControlsMetadata();

            foreach (var control in controls)
            {
                var metadataBuilder = new TagBuilder("div");

                metadataBuilder.AddCssClass("col-lg-12 col-md-12 col-sm-12");

                var propertiesTabs = from prop in control.GetType().GetProperties()
                                     let propertiesAttributes = prop.GetCustomAttributes(typeof(FormBuilderPropertiesTab), true)
                                                                let displayAttributes = prop.GetCustomAttributes(typeof(DisplayAttribute), true)
                                                                                        where propertiesAttributes.Length == 1
                                                                                        select new
                {
                    PropertiesAttribute = propertiesAttributes.FirstOrDefault() as FormBuilderPropertiesTab,
                    DisplayAttribute    = displayAttributes.Select(x => x as DisplayAttribute).FirstOrDefault(),
                    PropertyInfo        = prop
                };

                propertiesTabs = propertiesTabs.OrderBy(x => x.PropertiesAttribute.Order);

                foreach (var propertiesTab in propertiesTabs)
                {
                    var title = propertiesTab.DisplayAttribute.GetName();

                    var titleBuilder          = new TagBuilder("h3");
                    var titleGlyphiconBuilder = new TagBuilder("span");
                    var arrowGlyphiconBuilder = new TagBuilder("span");

                    titleGlyphiconBuilder.AddCssClass("glyphicon " + propertiesTab.PropertiesAttribute.Glyphicon.GetDescription());
                    arrowGlyphiconBuilder.AddCssClass("pull-right glyphicon " + Glyphicon.ChevronUp.GetDescription());

                    titleBuilder.InnerHtml = titleGlyphiconBuilder.ToString() + " " + title +
                                             arrowGlyphiconBuilder.ToString();

                    var formModel = propertiesTab.PropertyInfo.GetValue(control);

                    if (formModel != null)
                    {
                        var propertiesFormString = FormHtmlRenderer.RenderForm(formModel, renderingOptions.Theme, true, propertiesTab.PropertyInfo.Name);

                        metadataBuilder.InnerHtml += titleBuilder.ToString() + propertiesFormString;
                    }
                }

                metadataBuilder.MergeAttribute("data-properties-for", ((int)control.Type).ToString());
                metadataBuilder.MergeAttribute("style", "display:none;");

                settingsContainerBuilder.InnerHtml += metadataBuilder.ToString();
            }

            var panelBuilder  = new BsPanelHtmlBuilder(this.Builder.GetViewContext());
            var panelRenderer = new BsPanelLightRenderer(panelBuilder);

            panelBuilder.InitialEditable().Id("").Name("Settings").Glyphicon(Glyphicon.Cog);

            propertiesContainerBuilder.AddCssClass("form_builder-tab form_builder-properties col-lg-3 col-md-3 col-sm-3");
            propertiesContainerBuilder.InnerHtml = toolbarBuilder.ToString() + settingsContainerBuilder.ToString();

            return(propertiesContainerBuilder.ToString());
        }
Ejemplo n.º 2
0
 public BsPanelLightRenderer(BsPanelHtmlBuilder builder)
     : base(builder)
 {
 }
Ejemplo n.º 3
0
 public BsPanelLightRenderer(BsPanelHtmlBuilder builder) : base(builder)
 {
 }