public static ComponentBuilder <MvcBootstrapConfig <TModel>, TForm> HideValidationSummary <TModel, TForm>(
     this ComponentBuilder <MvcBootstrapConfig <TModel>, TForm> builder, bool hideValidationSummary = true)
     where TForm : Form
 {
     builder.GetComponent().GetOverride <FormOverride <TModel> >().HideValidationSummary = hideValidationSummary;
     return(builder);
 }
 public static ComponentBuilder <MvcBootstrapConfig <TModel>, TForm> SetFormMethod <TModel, TForm>(
     this ComponentBuilder <MvcBootstrapConfig <TModel>, TForm> builder, FormMethod method)
     where TForm : Form
 {
     builder.GetComponent().MergeAttribute("method", HtmlHelper.GetFormMethodString(method));
     return(builder);
 }
 public static ComponentBuilder <MvcBootstrapConfig <TModel>, TFormControlFor> AddDescription <TModel, TFormControlFor>(
     this ComponentBuilder <MvcBootstrapConfig <TModel>, TFormControlFor> builder, bool addDescription = true)
     where TFormControlFor : FormControlForBase
 {
     builder.GetComponent().AddDescription = addDescription;
     return(builder);
 }
        // Tag

        public static ComponentBuilder <TConfig, TTag> AddHtml <TConfig, TTag>(this ComponentBuilder <TConfig, TTag> builder, Func <dynamic, HelperResult> content)
            where TConfig : BootstrapConfig
            where TTag : Tag
        {
            builder.GetComponent().AddChild(builder.GetHelper().Content(content(null).ToHtmlString()).GetComponent());
            return(builder);
        }
 public static ComponentBuilder <MvcBootstrapConfig <TModel>, TFormControlFor> AddValidationMessage <TModel, TFormControlFor>(
     this ComponentBuilder <MvcBootstrapConfig <TModel>, TFormControlFor> builder, bool addValidationMessage = true)
     where TFormControlFor : FormControlForBase
 {
     builder.GetComponent().AddValidationMessage = addValidationMessage;
     return(builder);
 }
 public static ComponentBuilder <MvcBootstrapConfig <TModel>, TFormControlFor> SetTemplateName <TModel, TFormControlFor>(
     this ComponentBuilder <MvcBootstrapConfig <TModel>, TFormControlFor> builder, string templateName)
     where TFormControlFor : FormControlForBase
 {
     builder.GetComponent().TemplateName = templateName;
     return(builder);
 }
 public static ComponentBuilder <MvcBootstrapConfig <TModel>, TFormControlFor> AddAdditionalViewData <TModel, TFormControlFor>(
     this ComponentBuilder <MvcBootstrapConfig <TModel>, TFormControlFor> builder, object additionalViewData)
     where TFormControlFor : FormControlForBase
 {
     builder.GetComponent().AdditionalViewData = additionalViewData;
     return(builder);
 }
 public static ComponentBuilder <MvcBootstrapConfig <TModel>, TFormControlFor> AddStaticClass <TModel, TFormControlFor>(
     this ComponentBuilder <MvcBootstrapConfig <TModel>, TFormControlFor> builder, bool addStaticClass = true)
     where TFormControlFor : FormControlForBase
 {
     builder.GetComponent().ToggleCss(Css.FormControlStatic, addStaticClass);
     return(builder);
 }
Esempio n. 9
0
        public static ComponentBuilder <TConfig, TTag> AddContent <TConfig, TTag>(this ComponentBuilder <TConfig, TTag> builder, object content)
            where TConfig : BootstrapConfig
            where TTag : Tag
        {
            if (content != null)
            {
                // Make sure that this isn't a component
                ComponentBuilder contentBuilder = content as ComponentBuilder;
                if (contentBuilder != null)
                {
                    builder.Component.AddChild(contentBuilder.GetComponent());
                }

                // Now check if it's an IHtmlString
                string      str;
                IHtmlString htmlString = content as IHtmlString;
                if (htmlString != null)
                {
                    str = htmlString.ToHtmlString();
                }
                else
                {
                    // Just convert to a string using the standard conversion logic
                    str = Convert.ToString(content, CultureInfo.InvariantCulture);
                }

                if (!string.IsNullOrEmpty(str))
                {
                    builder.Component.AddChild(builder.GetHelper().Content(str));
                }
            }
            return(builder);
        }
 public static ComponentBuilder <MvcBootstrapConfig <TModel>, Pagination> AddPages <TModel>(
     this ComponentBuilder <MvcBootstrapConfig <TModel>, Pagination> builder, IEnumerable <KeyValuePair <string, ActionResult> > textAndResults, int?activePageNumber = null, int?firstPageNumber = null)
 {
     if (firstPageNumber.HasValue)
     {
         builder.GetComponent().AutoPageNumber = firstPageNumber.Value - 1;
     }
     foreach (KeyValuePair <string, ActionResult> textAndResult in textAndResults)
     {
         KeyValuePair <string, ActionResult> localTextAndResult = textAndResult;  // avoid access in closure
         builder.GetComponent().AutoPageNumber++;
         builder.AddChild(x => x.PageNum(localTextAndResult.Key ?? builder.GetComponent().AutoPageNumber.ToString(), localTextAndResult.Value)
                          .SetActive(builder.GetComponent().AutoPageNumber == activePageNumber)
                          .SetDisabled(localTextAndResult.Value == null));
     }
     return(builder);
 }
        public static ComponentBuilder <MvcBootstrapConfig <TModel>, FormGroup> FormGroup <TComponent, TModel, TValue>(
            this BootstrapHelper <MvcBootstrapConfig <TModel>, TComponent> helper, Expression <Func <TModel, TValue> > labelExpression)
            where TComponent : Component, ICanCreate <FormGroup>
        {
            ComponentBuilder <MvcBootstrapConfig <TModel>, FormGroup> builder = helper.FormGroup();

            builder.GetComponent().ControlLabel = builder.GetHelper().ControlLabel(labelExpression).GetComponent();
            return(builder);
        }
        public static ComponentBuilder <TConfig, TTag> AddLabelCss <TConfig, TTag>(this ComponentBuilder <TConfig, TTag> builder, params string[] cssClasses)
            where TConfig : BootstrapConfig
            where TTag : FormControl
        {
            var formControl = builder.GetComponent();

            formControl.AddLabelCss(cssClasses);

            return(builder);
        }
        public static ComponentBuilder <MvcBootstrapConfig <TModel>, FormGroup> SetGroupLabel <TModel, TValue, TThis>(
            this ComponentBuilder <MvcBootstrapConfig <TModel>, FormGroup> builder, Expression <Func <TModel, TValue> > expression, Action <ControlLabel> labelAction = null)
        {
            ControlLabel controlLabel = GetControlLabel(builder.GetHelper(), expression).GetComponent();

            builder.GetComponent().ControlLabel = controlLabel;
            if (labelAction != null)
            {
                labelAction(controlLabel);
            }
            return(builder);
        }
        public static ComponentBuilder <MvcBootstrapConfig <TModel>, TFormControl> SetControlLabel <TModel, TValue, TFormControl>(
            this ComponentBuilder <MvcBootstrapConfig <TModel>, TFormControl> builder, Expression <Func <TModel, TValue> > expression, Action <ControlLabel> labelAction = null)
            where TFormControl : FormControl
        {
            ControlLabel controlLabel = GetControlLabel(builder.GetHelper(), expression).For(builder.GetComponent().GetAttribute("name")).GetComponent();

            if (labelAction != null)
            {
                labelAction(controlLabel);
            }
            builder.GetComponent().Label = controlLabel;
            return(builder);
        }
        public static ComponentBuilder <MvcBootstrapConfig <TModel>, FormControlListFor <TModel, TValue> > EditorOrDisplayListFor <TComponent, TModel, TValue>(
            this BootstrapHelper <MvcBootstrapConfig <TModel>, TComponent> helper, bool editor, Expression <Func <TModel, IEnumerable <TValue> > > expression,
            ListType listType = ListType.Unstyled, bool addDescription = true, bool addValidationMessage = true, string templateName = null, object additionalViewData = null, bool addHidden = true)
            where TComponent : Component, ICanCreate <FormControl>
        {
            ComponentBuilder <MvcBootstrapConfig <TModel>, FormControlListFor <TModel, TValue> > builder =
                new ComponentBuilder <MvcBootstrapConfig <TModel>, FormControlListFor <TModel, TValue> >(helper.GetConfig(), new FormControlListFor <TModel, TValue>(helper, editor, expression, listType))
                .AddHidden(addHidden)
                .AddDescription(addDescription)
                .AddValidationMessage(addValidationMessage)
                .SetTemplateName(templateName)
                .AddAdditionalViewData(additionalViewData);

            builder.GetComponent().Label = GetControlLabel(helper, expression).GetComponent();
            return(builder);
        }
        public static ComponentBuilder <MvcBootstrapConfig <TModel>, Select> SelectFor <TComponent, TModel, TValue>(
            this BootstrapHelper <MvcBootstrapConfig <TModel>, TComponent> helper, Expression <Func <TModel, TValue> > expression, IEnumerable <SelectListItem> selectList = null)
            where TComponent : Component, ICanCreate <Select>
        {
            ModelMetadata metadata       = ModelMetadata.FromLambdaExpression(expression, helper.GetConfig().HtmlHelper.ViewData);
            string        expressionText = ExpressionHelper.GetExpressionText(expression);
            string        name           = GetControlName(helper, expressionText);
            string        label          = GetControlLabel(metadata, expressionText);
            ComponentBuilder <MvcBootstrapConfig <TModel>, Select> builder = helper.Select(name, label);

            if (metadata.Model != null && !string.IsNullOrEmpty(name))
            {
                // Add the model value before adding options so they'll get selected on a match
                builder.GetComponent().ModelValue = metadata.Model.ToString();
            }
            return(builder.AddOptions(selectList));
        }
Esempio n. 17
0
        public static ComponentBuilder <MvcBootstrapConfig <TModel>, FormButton> ButtonFor <TComponent, TModel, TValue>(
            this BootstrapHelper <MvcBootstrapConfig <TModel>, TComponent> helper,
            Expression <Func <TModel, TValue> > expression, params string[] options)
            where TComponent : Component, ICanCreate <FormButton>
        {
            var    metadata       = ModelMetadata.FromLambdaExpression(expression, helper.GetConfig().HtmlHelper.ViewData);
            string expressionText = ExpressionHelper.GetExpressionText(expression);
            var    name           = helper.ViewContext.ViewData.TemplateInfo.GetFullHtmlFieldName(expressionText);
            string name           = GetControlName(helper, expressionText);
            string label          = GetControlLabel(metadata, expressionText);
            ComponentBuilder <MvcBootstrapConfig <TModel>, Select> builder = helper.Select(name, label);

            if (metadata.Model != null && !string.IsNullOrEmpty(name))
            {
                // Add the model value before adding options so they'll get selected on a match
                builder.GetComponent().ModelValue = metadata.Model.ToString();
            }
            return(builder.AddOptions(options));
        }
Esempio n. 18
0
 public void AddChildAtEnd(ComponentBuilder builder)
 {
     _endChildren.Add(builder.GetComponent());
 }
 public static ComponentBuilder <MvcBootstrapConfig <TModel>, Pagination> AddPage <TModel>(
     this ComponentBuilder <MvcBootstrapConfig <TModel>, Pagination> builder, string actionName, string controllerName, object routeValues = null, bool active = false, bool disabled = false)
 {
     builder.AddChild(x => x.PageNum((++builder.GetComponent().AutoPageNumber).ToString(), actionName, controllerName, routeValues).SetActive(active).SetDisabled(disabled));
     return(builder);
 }
 public static ComponentBuilder <MvcBootstrapConfig <TModel>, Pagination> AddPage <TModel>(
     this ComponentBuilder <MvcBootstrapConfig <TModel>, Pagination> builder, ActionResult result, bool active = false, bool disabled = false)
 {
     builder.AddChild(x => x.PageNum((++builder.GetComponent().AutoPageNumber).ToString(), result).SetActive(active).SetDisabled(disabled));
     return(builder);
 }