Exemplo n.º 1
0
        // Input

        public static ComponentBuilder <TConfig, Input> Input <TConfig, TComponent>(this BootstrapHelper <TConfig, TComponent> helper, string name = null, string label = null, object value = null, string valueFormat = null, FormInputType inputType = FormInputType.Text, bool addValidateMessage = false, HtmlString validateMassegeTag = null, bool isRequired = false)
            where TConfig : BootstrapConfig
            where TComponent : Component, ICanCreate <Input>
        {
            ComponentBuilder <TConfig, Input> nhelper = new ComponentBuilder <TConfig, Input>(helper.Config, new Input(helper, inputType))
                                                        .SetName(name)
                                                        .SetControlLabel(label)
                                                        .SetValue(value, valueFormat)
                                                        .SetValidateMassage(addValidateMessage, validateMassegeTag)
                                                        .SetRequired(isRequired)
                                                        .SetSize(InputSize.Sm);

            if (!string.IsNullOrEmpty(valueFormat))
            {
                Regex regex = new Regex(@"\{\d:([^)]+)\}$");
                var   match = regex.Match(valueFormat);
                if (match.Success)
                {
                    nhelper.AddAttribute("data-format", match.Groups[1].Value);
                }
            }
            if (isRequired)
            {
                nhelper.SetPlaceholder(Translation.CenterLang.Center.InputPlaceholderRequired);
            }
            return(nhelper);
        }
Exemplo n.º 2
0
        // TextArea

        public static ComponentBuilder <TConfig, TextArea> TextArea <TConfig, TComponent>(this BootstrapHelper <TConfig, TComponent> helper, string name = null, string label = null, object value = null, string valueFormat = null, int?rows = null, bool addValidateMessage = false, HtmlString validateMassegeTag = null, bool isRequired = false)
            where TConfig : BootstrapConfig
            where TComponent : Component, ICanCreate <TextArea>
        {
            ComponentBuilder <TConfig, TextArea> nhelper = new ComponentBuilder <TConfig, TextArea>(helper.Config, new TextArea(helper))
                                                           .SetName(name)
                                                           .SetControlLabel(label)
                                                           .SetValue(value, valueFormat)
                                                           .SetRows(rows)
                                                           .SetValidateMassage(addValidateMessage, validateMassegeTag)
                                                           .SetRequired(isRequired);

            if (isRequired)
            {
                nhelper.SetPlaceholder(Translation.CenterLang.Center.InputPlaceholderRequired);
            }
            return(nhelper);
        }
Exemplo n.º 3
0
        public static ComponentBuilder <TConfig, Input> InputNumber <TConfig, TComponent>(this BootstrapHelper <TConfig, TComponent> helper, string name = null, string label = null, object value = null, string valueFormat = null, bool addValidateMessage = false, HtmlString validateMassegeTag = null, bool isRequired = false, int digits = 0, bool positiveInt = false)
            where TConfig : BootstrapConfig
            where TComponent : Component, ICanCreate <Input>
        {
            ComponentBuilder <TConfig, Input> nhelper = new ComponentBuilder <TConfig, Input>(helper.Config, new Input(helper, FormInputType.Text))
                                                        .SetName(name)
                                                        .AddCss("input-number", "number-format", Css.TextRight)
                                                        .SetControlLabel(label)
                                                        .SetValue(value, valueFormat)
                                                        .SetValidateMassage(addValidateMessage, validateMassegeTag)
                                                        .SetRequired(isRequired)
                                                        .SetDigits(digits)
                                                        .SetSize(InputSize.Sm)
                                                        .SetPositiveInt(positiveInt);

            if (isRequired)
            {
                nhelper.SetPlaceholder(Translation.CenterLang.Center.InputPlaceholderRequired);
            }
            return(nhelper);
        }
Exemplo n.º 4
0
        public static ComponentBuilder <TConfig, Input> InputJAutocomplete <TConfig, TComponent>(this BootstrapHelper <TConfig, TComponent> helper, string name = null, string label = null, object value = null, string valueFormat = null, bool addValidateMessage = false, HtmlString validateMassegeTag = null, bool isRequired = false, bool isCustom = false)
            where TConfig : BootstrapConfig
            where TComponent : Component, ICanCreate <Input>
        {
            ComponentBuilder <TConfig, Input> nhelper = new ComponentBuilder <TConfig, Input>(helper.Config, new Input(helper, FormInputType.Text))
                                                        .SetName(name)
                                                        .SetControlLabel(label)
                                                        .SetValue(value, valueFormat)
                                                        .SetValidateMassage(addValidateMessage, validateMassegeTag)
                                                        .SetRequired(isRequired)
                                                        .AddAttribute("data-valuebeforeselected", value)
                                                        .SetSize(InputSize.Sm);

            if (!isCustom)
            {
                nhelper.AddCss("autocomplete-input");
            }
            if (isRequired)
            {
                nhelper.SetPlaceholder(Translation.CenterLang.Center.InputPlaceholderRequired);
            }
            return(nhelper);
        }
Exemplo n.º 5
0
        public static ComponentBuilder <TConfig, Input> InputFileupload <TConfig, TComponent>(this BootstrapHelper <TConfig, TComponent> helper, string name = null, string label = null, object value = null, string valueFormat = null, bool addValidateMessage = false, HtmlString validateMassegeTag = null, bool isRequired = false, string allowFile = null)
            where TConfig : BootstrapConfig
            where TComponent : Component, ICanCreate <Input>
        {
            ComponentBuilder <TConfig, Input> nhelper = new ComponentBuilder <TConfig, Input>(helper.Config, new Input(helper, FormInputType.File))
                                                        .SetName(name)
                                                        .AddCss("input-fileupload")
                                                        .SetControlLabel(label)
                                                        .SetValue(value, valueFormat)
                                                        .SetValidateMassage(addValidateMessage, validateMassegeTag)
                                                        .SetRequired(isRequired)
                                                        .SetSize(InputSize.Sm);

            if (isRequired)
            {
                nhelper.SetPlaceholder(Translation.CenterLang.Center.InputPlaceholderRequired);
            }
            if (!string.IsNullOrEmpty(allowFile))
            {
                nhelper.Component.MergeAttribute("accept", allowFile);
            }
            return(nhelper);
        }