Exemplo n.º 1
0
        public override ahsDom[] GetChilds()
        {
            ChildsNodes.Clear();
            bsFormGroupSingle groupSingle;

            foreach (bmInput input in CustomInputs)
            {
                groupSingle = new bsFormGroupSingle()
                {
                    IsHorisontal = false
                };
                if (UseCustomisation)
                {
                    groupSingle.CustomInput = new bmCustomInput(input);
                }
                else
                {
                    groupSingle.CustomInput = input.Clone() as bmInput;
                }

                if (IsInline)
                {
                    groupSingle.CustomInput.IsHorisontalStyle = IsInline;
                    if (groupSingle.CustomInput.Input.GetType().IsSubclassOf(typeof(ahsCheckableInputs)))
                    {
                        groupSingle.AddCSS("form-check-inline");
                        ChildsNodes.AddRange(groupSingle.GetChilds());
                    }
                    else
                    {
                        groupSingle.AddCSS(("col " + input.AddedWrapCSS).Trim());
                        ChildsNodes.Add(groupSingle);
                    }
                }
                else
                {
                    ChildsNodes.AddRange(groupSingle.GetChilds());
                }
            }
            return(base.GetChilds());
        }
        public override ahsDom[] GetChilds()
        {
            ChildsNodes.Clear();

            //
            Label = new hsLabelInput()
            {
                Header = CustomInput.Label, For = CustomInput.Input.ID
            };
            if (CustomInput.LabelSrOnly)
            {
                Label.AddCSS("sr-only");
            }

            HelpCaptionId = CustomInput.Input.ID + "-" + nameof(CustomInput.HelpCaption);
            wInput        = CustomInput.Input.Clone() as ahsInputs;

            /*
             * if (UseCustomisation)
             *      groupSingle.CustomInput = new bmCustomInput(input);
             *  else
             *      groupSingle.CustomInput = input.Clone() as bmInput;
             */
            //
            if (CustomInput.SizeInput != bmTwinSizingsEnum.NULL)
            {
                string SizeInputAsString = CustomInput.SizeInput.ToString().ToLower(CultureInfo.CurrentCulture);
                if (CustomInput is bmCustomInput && CustomInput.Input is hsInputSelect)
                {
                    wInput.AddCSS("custom-select-" + SizeInputAsString);
                }
                else
                {
                    wInput.AddCSS("form-control-" + SizeInputAsString);
                }

                if (IsHorisontal && !(CustomInput.Input is hsInputFile))
                {
                    Label.AddCSS("col-form-label-" + SizeInputAsString);
                }
            }

            if (!string.IsNullOrWhiteSpace(CustomInput.HelpCaption))
            {
                wInput.SetAttribute("aria-describedby", HelpCaptionId);
            }

            if (CustomInput is bmCustomInput)
            {
                WriteCustomDomSingle();
            }
            else
            {
                if (CustomInput.Input is hsInputFile)
                {
                    wInput.AddCSS("form-control-file");
                }
                else if (CustomInput.Input is hsInputRange)
                {
                    wInput.AddCSS("form-control-range");
                }
                else if (CustomInput.Input.GetType().IsSubclassOf(typeof(ahsCheckableInputs)))
                {
                    wInput.AddCSS("form-check-input");
                    if (string.IsNullOrEmpty(CustomInput.Label))
                    {
                        wInput.AddCSS("position-static");
                    }
                    else
                    {
                        Label.AddCSS("form-check-label");
                    }
                }
                else
                {
                    if (CustomInput.Input is bsPlainTextInput)
                    {
                        wInput.AddCSS("form-control-plaintext");
                    }
                    else
                    {
                        wInput.AddCSS("form-control");
                    }
                }

                if (!IsHorisontal)
                {
                    if (CustomInput.Input.GetType().IsSubclassOf(typeof(ahsCheckableInputs)))
                    {
                        WriteDomNormalSingleCheckable();
                    }
                    else
                    {
                        WriteDomNormalSingle();
                    }
                }
                else
                {
                    if (CustomInput.Input.GetType().IsSubclassOf(typeof(ahsCheckableInputs)))
                    {
                        WriteDomHorisontalSingleCheckable();
                    }
                    else
                    {
                        WriteDomHorisontalSingle();
                    }
                }
            }

            return(base.GetChilds());
        }