Пример #1
0
        public virtual void Visit(FormTitle formTitle, HtmlContainer htmlContainer)
        {
            HtmlDiv htmlDiv = verbose ? new HtmlDiv(formTitle.Path) : new HtmlDiv();

            htmlDiv.Class.Add("formTitle");

            if (!string.IsNullOrWhiteSpace(formTitle.CssClass))
            {
                htmlDiv.Class.AddRange(formTitle.CssClass.Split(' ').Where(s => s != string.Empty));
            }

            htmlDiv.Class.Add("card-title");

            if (!string.IsNullOrWhiteSpace(formTitle.Path))
            {
                htmlDiv.Class.Add(string.Format("{0}{1}", "formId", formTitle.Path));
            }

            htmlDiv.Hidden.Value = formTitle.IsHidden;

            htmlContainer.Add(htmlDiv);

            HtmlH3 htmlH3 = new HtmlH3();

            htmlDiv.Add(htmlH3);

            htmlH3.Add(new HtmlText(formTitle.Content));

            HtmlHR htmlHR = new HtmlHR();

            htmlHR.Class.AddRange(new string[] { "m-0", "mb-3" });
            htmlDiv.Add(htmlHR);
        }
        public void InsertOutOfRange2()
        {
            HtmlDiv g = new HtmlDiv("");

            g.Add(new HtmlLabel(""));
            g.Add(new HtmlLabel(""));
            g.Add(new HtmlLabel(""));

            g.Insert(4, new HtmlLabel(""));
        }
        public void AddSame()
        {
            HtmlDiv g = new HtmlDiv("");

            HtmlLabel l = new HtmlLabel("");

            g.Add(l);
            g.Add(l);

            Assert.AreSame(l.Container, g);
            Assert.IsTrue(g.Contents.Any(c => ReferenceEquals(c, l)));
            Assert.AreEqual(g.Contents.Count, 1);
        }
Пример #4
0
        public virtual void Visit(FormTitle formTitle, HtmlContainer htmlContainer)
        {
            HtmlDiv htmlDiv = verbose ? new HtmlDiv(formTitle.Path) : new HtmlDiv();

            htmlDiv.Class.Add("formTitle");

            if (!string.IsNullOrWhiteSpace(formTitle.CssClass))
            {
                htmlDiv.Class.AddRange(formTitle.CssClass.Split(' ').Where(s => s != string.Empty));
            }

            if (!string.IsNullOrWhiteSpace(formTitle.Path))
            {
                htmlDiv.Class.Add(string.Format("{0}{1}", "formId", formTitle.Path));
            }

            htmlDiv.Hidden.Value = formTitle.IsHidden;

            htmlContainer.Add(htmlDiv);

            HtmlLabel htmlLabel = new HtmlLabel(verbose ? formTitle.Path : string.Empty);

            htmlDiv.Add(htmlLabel);

            htmlLabel.Add(new HtmlText(formTitle.Content));
        }
Пример #5
0
        public virtual void Visit(FormButton formButton, HtmlContainer htmlContainer)
        {
            HtmlDiv htmlDiv = verbose ? new HtmlDiv(formButton.Path) : new HtmlDiv();

            htmlDiv.Class.Add("formButton");

            if (!string.IsNullOrWhiteSpace(formButton.CssClass))
            {
                htmlDiv.Class.AddRange(formButton.CssClass.Split(' ').Where(s => s != string.Empty));
            }

            if (!string.IsNullOrWhiteSpace(formButton.Path))
            {
                htmlDiv.Class.Add(string.Format("{0}{1}", "formId", formButton.Path));
            }

            htmlDiv.Hidden.Value = formButton.IsHidden;

            htmlContainer.Add(htmlDiv);

            HtmlButton htmlButton = new HtmlButton(formButton.Path);

            htmlButton.Disabled.Value = formButton.IsDisabled;
            htmlDiv.Add(htmlButton);

            htmlButton.Add(new HtmlText(formButton.Content));
        }
        public void Remove()
        {
            HtmlDiv g = new HtmlDiv("");

            HtmlLabel l = new HtmlLabel("");

            g.Add(l);
            g.Remove(l);

            Assert.IsNull(l.Container);
            Assert.IsFalse(g.Contents.Any(c => ReferenceEquals(c, l)));
            Assert.AreEqual(g.Contents.Count, 0);
        }
        public void AddContained()
        {
            HtmlDiv g1 = new HtmlDiv("");
            HtmlDiv g2 = new HtmlDiv("");

            HtmlLabel l = new HtmlLabel("");

            g1.Add(l);
            g2.Add(l);

            Assert.AreSame(l.Container, g2);
            Assert.IsFalse(g1.Contents.Any(c => ReferenceEquals(c, l)));
            Assert.IsTrue(g2.Contents.Any(c => ReferenceEquals(c, l)));
        }
Пример #8
0
        public virtual void Visit(FormSubmit formSubmit, HtmlContainer htmlContainer)
        {
            HtmlDiv htmlDiv = verbose ? new HtmlDiv(formSubmit.Path) : new HtmlDiv();

            htmlDiv.Class.Add("formButton");

            if (!string.IsNullOrWhiteSpace(formSubmit.CssClass))
            {
                htmlDiv.Class.AddRange(formSubmit.CssClass.Split(' ').Where(s => s != string.Empty));
            }

            if (!string.IsNullOrWhiteSpace(formSubmit.Path))
            {
                htmlDiv.Class.Add(string.Format("{0}{1}", "formId", formSubmit.Path));
            }

            htmlDiv.Hidden.Value = formSubmit.IsHidden;

            htmlContainer.Add(htmlDiv);

            HtmlSubmit htmlSubmit = new HtmlSubmit(formSubmit.Path, verbose, formSubmit.Parameter);

            htmlSubmit.Class.AddRange(new string[] { "btnFix", "btn", "mt-2" });

            switch (formSubmit.Type)
            {
            case ButtonType.Primary:
            case ButtonType.Secondary:
            case ButtonType.Success:
            case ButtonType.Danger:
                htmlSubmit.Class.Add(string.Format("btn-{0}", formSubmit.Type.ToString().ToLower()));
                break;

            default:
            case ButtonType.NotSet:
                break;
            }

            htmlSubmit.Disabled.Value = formSubmit.IsDisabled;
            htmlDiv.Add(htmlSubmit);

            htmlSubmit.Add(new HtmlText(formSubmit.Content));
        }
Пример #9
0
        public virtual void Visit(FormDatePicker formDatePicker, HtmlContainer htmlContainer)
        {
            if (formDatePicker.Icon == FormIcon.NotSet)
            {
                return;
            }

            HtmlTextBox htmlTextBox = null;
            int         i;

            for (i = 0; i < htmlContainer.Contents.Count; i++)
            {
                if (htmlContainer.Contents[i] is HtmlTextBox)
                {
                    htmlTextBox = (HtmlTextBox)htmlContainer.Contents[i];
                    break;
                }
            }

            if (htmlTextBox == null)
            {
                return;
            }

            htmlContainer.Remove(htmlTextBox);

            HtmlItalic htmlItalic = new HtmlItalic();

            htmlItalic.Class.AddRange(IconClass(formDatePicker.Icon));

            HtmlDiv htmlDiv = new HtmlDiv();

            htmlDiv.Add(htmlTextBox);
            htmlDiv.Insert(prepend ? 0 : 1, htmlItalic);

            htmlContainer.Insert(i, htmlDiv);
        }
Пример #10
0
        public virtual void Visit(FormHeader formHeader, HtmlContainer htmlContainer)
        {
            HtmlDiv htmlDiv = verbose ? new HtmlDiv(formHeader.Path) : new HtmlDiv();

            htmlDiv.Class.Add("formHeader");

            if (!string.IsNullOrWhiteSpace(formHeader.CssClass))
            {
                htmlDiv.Class.AddRange(formHeader.CssClass.Split(' ').Where(s => s != string.Empty));
            }

            htmlDiv.Class.AddRange(new string[] { "card-header", "mb-3" });

            if (!string.IsNullOrWhiteSpace(formHeader.Path))
            {
                htmlDiv.Class.Add(string.Format("{0}{1}", "formId", formHeader.Path));
            }

            htmlDiv.Hidden.Value = formHeader.IsHidden;

            htmlContainer.Add(htmlDiv);

            htmlDiv.Add(new HtmlText(formHeader.Content));
        }
Пример #11
0
        public virtual void Visit(FormDateBox formDateBox, HtmlContainer htmlContainer)
        {
            HtmlDiv htmlDiv = verbose ? new HtmlDiv(formDateBox.Path) : new HtmlDiv();

            htmlDiv.Class.Add("formDateBox");

            if (!string.IsNullOrWhiteSpace(formDateBox.CssClass))
            {
                htmlDiv.Class.AddRange(formDateBox.CssClass.Split(' ').Where(s => s != string.Empty));
            }

            if (!string.IsNullOrWhiteSpace(formDateBox.Path))
            {
                htmlDiv.Class.Add(string.Format("{0}{1}", "formId", formDateBox.Path));
            }

            htmlDiv.Class.Add("formField");

            if (initialize)
            {
                htmlDiv.Class.Add(formDateBox.IsRequired ? "formRequired" : "formOptional");
            }
            else
            {
                if (!formDateBox.IsRequired || formDateBox.HasValue)
                {
                    htmlDiv.Class.Add(formDateBox.IsValid ? "formValid" : "formInvalid");
                }
                else
                {
                    htmlDiv.Class.Add(formDateBox.IsRequired ? "formNotEntered" : "formOptional");
                }
            }

            htmlDiv.Hidden.Value = formDateBox.IsHidden;

            htmlContainer.Add(htmlDiv);

            HtmlDateBox htmlDateBox = new HtmlDateBox(formDateBox.Path);

            htmlDateBox.Disabled.Value = formDateBox.IsDisabled;
            htmlDateBox.ReadOnly.Value = formDateBox.IsReadOnly;
            htmlDateBox.Value.Value    = formDateBox.HasValue ? formDateBox.Value.ToString("yyyy-MM-dd") : "";

            if (!initialize && firstInvalidId == null)
            {
                if (formDateBox.IsRequired && !formDateBox.HasValue || !formDateBox.IsValid)
                {
                    firstInvalidId = htmlDateBox.Id.Value;
                }
            }

            switch (formDateBox.OrderElements)
            {
            case OrderElements.LabelMarkInput:

                AddLabelMark(formDateBox, htmlDateBox, htmlDiv);
                htmlDiv.Add(htmlDateBox);

                break;

            case OrderElements.MarkLabelInput:

                AddMarkLabel(formDateBox, htmlDateBox, htmlDiv);
                htmlDiv.Add(htmlDateBox);

                break;

            case OrderElements.InputLabelMark:

                htmlDiv.Add(htmlDateBox);
                AddLabelMark(formDateBox, htmlDateBox, htmlDiv);

                break;

            case OrderElements.InputMarkLabel:

                htmlDiv.Add(htmlDateBox);
                AddMarkLabel(formDateBox, htmlDateBox, htmlDiv);

                break;

            case OrderElements.LabelInputMark:

                AddLabel(formDateBox, htmlDateBox, htmlDiv);
                htmlDiv.Add(htmlDateBox);
                AddMark(formDateBox, htmlDateBox, htmlDiv);

                break;

            case OrderElements.MarkInputLabel:

                AddMark(formDateBox, htmlDateBox, htmlDiv);
                htmlDiv.Add(htmlDateBox);
                AddLabel(formDateBox, htmlDateBox, htmlDiv);

                break;

            default:
            case OrderElements.NotSet:

                break;
            }

            if (initialize)
            {
                return;
            }

            string message = null;

            if (formDateBox.UseLastMessage)
            {
                if (!string.IsNullOrEmpty(formDateBox.LastMessage))
                {
                    message = formDateBox.LastMessage;
                }
            }
            else if (formDateBox.IsRequired && !formDateBox.HasValue)
            {
                message = formDateBox.RequiredMessage;
            }
            else if (!formDateBox.IsValid)
            {
                message = formDateBox.ValidationMessage;
            }

            if (message == null)
            {
                return;
            }

            HtmlLabel htmlLabelMessage = new HtmlLabel(verbose ? string.Format("{0}{1}", formDateBox.Path, "Message") : "");

            htmlLabelMessage.For.Value = htmlDateBox.Id.Value;
            htmlLabelMessage.Add(new HtmlText(message));
            htmlDiv.Add(htmlLabelMessage);
        }
Пример #12
0
        private HtmlDiv BuildDivNumberSpinner(FormNumberSpinner formNumberSpinner, HtmlTextBox htmlTextBox)
        {
            HtmlDiv htmlDivNumberSpinner = new HtmlDiv();

            string btnDecrName = verbose ? string.Format("{0}{1}", "Decr", formNumberSpinner.Path) : "";
            string btnIncrName = verbose ? string.Format("{0}{1}", "Incr", formNumberSpinner.Path) : "";

            string btnDecrOnClick = null;
            string btnIncrOnClick = null;

            if (formNumberSpinner.Update)
            {
                btnDecrOnClick = string.Format("__doPostBack('{0}', 'Decr');", formNumberSpinner.Path);
                btnIncrOnClick = string.Format("__doPostBack('{0}', 'Incr');", formNumberSpinner.Path);
            }
            else if (htmlTextBox.Id.IsSet)
            {
                btnDecrOnClick = string.Format("NumberSpinnerDecr('{0}');", htmlTextBox.Id.Value);
                btnIncrOnClick = string.Format("NumberSpinnerIncr('{0}');", htmlTextBox.Id.Value);

                scriptRegistry.Include("NumberSpinnerDecr");
                scriptRegistry.Include("NumberSpinnerIncr");
            }

            HtmlButton htmlButtonDecr = new HtmlButton(btnDecrName, btnDecrOnClick);
            HtmlButton htmlButtonIncr = new HtmlButton(btnIncrName, btnIncrOnClick);

            htmlButtonDecr.Value.Value = formNumberSpinner.DecrText;
            htmlButtonIncr.Value.Value = formNumberSpinner.IncrText;

            htmlButtonDecr.Disabled.Value = htmlButtonIncr.Disabled.Value = formNumberSpinner.IsReadOnly || (formNumberSpinner.Update && !formNumberSpinner.HasValue);

            if (!initialize && firstInvalidId == null)
            {
                if (formNumberSpinner.IsRequired && !formNumberSpinner.HasValue || !formNumberSpinner.IsValid)
                {
                    firstInvalidId = htmlTextBox.Id.Value;
                }
            }

            switch (formNumberSpinner.OrderNumberSpinner)
            {
            case OrderNumberSpinner.NumberDecrIncr:

                htmlDivNumberSpinner.Add(htmlTextBox);
                htmlDivNumberSpinner.Add(htmlButtonDecr);
                htmlDivNumberSpinner.Add(htmlButtonIncr);

                break;

            case OrderNumberSpinner.NumberIncrDecr:

                htmlDivNumberSpinner.Add(htmlTextBox);
                htmlDivNumberSpinner.Add(htmlButtonIncr);
                htmlDivNumberSpinner.Add(htmlButtonDecr);

                break;

            case OrderNumberSpinner.DecrNumberIncr:

                htmlDivNumberSpinner.Add(htmlButtonDecr);
                htmlDivNumberSpinner.Add(htmlTextBox);
                htmlDivNumberSpinner.Add(htmlButtonIncr);

                break;

            case OrderNumberSpinner.IncrNumberDecr:

                htmlDivNumberSpinner.Add(htmlButtonIncr);
                htmlDivNumberSpinner.Add(htmlTextBox);
                htmlDivNumberSpinner.Add(htmlButtonDecr);

                break;

            case OrderNumberSpinner.DecrIncrNumber:

                htmlDivNumberSpinner.Add(htmlButtonDecr);
                htmlDivNumberSpinner.Add(htmlButtonIncr);
                htmlDivNumberSpinner.Add(htmlTextBox);

                break;

            case OrderNumberSpinner.IncrDecrNumber:

                htmlDivNumberSpinner.Add(htmlButtonIncr);
                htmlDivNumberSpinner.Add(htmlButtonDecr);
                htmlDivNumberSpinner.Add(htmlTextBox);

                break;

            default:
            case OrderNumberSpinner.NotSet:

                break;
            }

            return(htmlDivNumberSpinner);
        }
Пример #13
0
        public virtual void Visit(FormTextArea formTextArea, HtmlContainer htmlContainer)
        {
            HtmlDiv htmlDiv = verbose ? new HtmlDiv(formTextArea.Path) : new HtmlDiv();

            htmlDiv.Class.Add("formTextArea");

            if (!string.IsNullOrWhiteSpace(formTextArea.CssClass))
            {
                htmlDiv.Class.AddRange(formTextArea.CssClass.Split(' ').Where(s => s != string.Empty));
            }

            if (!string.IsNullOrWhiteSpace(formTextArea.Path))
            {
                htmlDiv.Class.Add(string.Format("{0}{1}", "formId", formTextArea.Path));
            }

            htmlDiv.Class.Add("formField");

            if (initialize)
            {
                htmlDiv.Class.Add(formTextArea.IsRequired ? "formRequired" : "formOptional");
            }
            else
            {
                if (formTextArea.HasValue)
                {
                    htmlDiv.Class.Add(formTextArea.IsValid ? "formValid" : "formInvalid");
                }
                else
                {
                    htmlDiv.Class.Add(formTextArea.IsRequired ? "formNotEntered" : "formOptional");
                }
            }

            htmlDiv.Hidden.Value = formTextArea.IsHidden;

            htmlContainer.Add(htmlDiv);

            HtmlTextArea htmlTextArea = new HtmlTextArea(formTextArea.Path);

            htmlTextArea.Disabled.Value = formTextArea.IsDisabled;
            htmlTextArea.ReadOnly.Value = formTextArea.IsReadOnly;
            htmlTextArea.Value.Value    = formTextArea.Value;

            string placeholder = null;

            if (!string.IsNullOrWhiteSpace(formTextArea.Placeholder))
            {
                if (formTextArea.IsRequired && formTextArea.IsRequiredInPlaceholder && !string.IsNullOrWhiteSpace(formTextArea.RequiredMark))
                {
                    placeholder = string.Format("{0} {1}", formTextArea.Placeholder, formTextArea.RequiredMark);
                }
                else if (!formTextArea.IsRequired && formTextArea.IsOptionalInPlaceholder && !string.IsNullOrWhiteSpace(formTextArea.OptionalMark))
                {
                    placeholder = string.Format("{0} {1}", formTextArea.Placeholder, formTextArea.OptionalMark);
                }
                else
                {
                    placeholder = formTextArea.Placeholder;
                }
            }

            htmlTextArea.Placeholder.Value = placeholder;

            htmlTextArea.Rows.Value = formTextArea.Rows;
            htmlTextArea.Cols.Value = formTextArea.Columns;

            if (!initialize && firstInvalidId == null)
            {
                if (formTextArea.IsRequired && !formTextArea.HasValue || !formTextArea.IsValid)
                {
                    firstInvalidId = htmlTextArea.Id.Value;
                }
            }

            switch (formTextArea.OrderElements)
            {
            case OrderElements.LabelMarkInput:

                AddLabelMark(formTextArea, htmlTextArea, htmlDiv);
                htmlDiv.Add(htmlTextArea);

                break;

            case OrderElements.MarkLabelInput:

                AddMarkLabel(formTextArea, htmlTextArea, htmlDiv);
                htmlDiv.Add(htmlTextArea);

                break;

            case OrderElements.InputLabelMark:

                htmlDiv.Add(htmlTextArea);
                AddLabelMark(formTextArea, htmlTextArea, htmlDiv);

                break;

            case OrderElements.InputMarkLabel:

                htmlDiv.Add(htmlTextArea);
                AddMarkLabel(formTextArea, htmlTextArea, htmlDiv);

                break;

            case OrderElements.LabelInputMark:

                AddLabel(formTextArea, htmlTextArea, htmlDiv);
                htmlDiv.Add(htmlTextArea);
                AddMark(formTextArea, htmlTextArea, htmlDiv);

                break;

            case OrderElements.MarkInputLabel:

                AddMark(formTextArea, htmlTextArea, htmlDiv);
                htmlDiv.Add(htmlTextArea);
                AddLabel(formTextArea, htmlTextArea, htmlDiv);

                break;

            default:
            case OrderElements.NotSet:

                break;
            }

            if (initialize)
            {
                return;
            }

            string message = null;

            if (formTextArea.UseLastMessage)
            {
                if (!string.IsNullOrEmpty(formTextArea.LastMessage))
                {
                    message = formTextArea.LastMessage;
                }
            }
            else if (formTextArea.IsRequired && !formTextArea.HasValue)
            {
                message = formTextArea.RequiredMessage;
            }
            else if (!formTextArea.IsValid)
            {
                message = formTextArea.ValidationMessage;
            }

            if (message == null)
            {
                return;
            }

            HtmlLabel htmlLabelMessage = new HtmlLabel(verbose ? string.Format("{0}{1}", formTextArea.Path, "Message") : "");

            htmlLabelMessage.Class.Add("formValidationMessage");
            htmlLabelMessage.For.Value = htmlTextArea.Id.Value;
            htmlLabelMessage.Add(new HtmlText(message));
            htmlDiv.Add(htmlLabelMessage);
        }
Пример #14
0
        public virtual void Visit(FormSelect formSelect, HtmlContainer htmlContainer)
        {
            HtmlDiv htmlDiv = verbose ? new HtmlDiv(formSelect.Path) : new HtmlDiv();

            htmlDiv.Class.Add("formSelect");

            if (!string.IsNullOrWhiteSpace(formSelect.CssClass))
            {
                htmlDiv.Class.AddRange(formSelect.CssClass.Split(' ').Where(s => s != string.Empty));
            }

            if (!string.IsNullOrWhiteSpace(formSelect.Path))
            {
                htmlDiv.Class.Add(string.Format("{0}{1}", "formId", formSelect.Path));
            }

            htmlDiv.Class.Add("formField");

            if (initialize)
            {
                htmlDiv.Class.Add(formSelect.IsRequired ? "formRequired" : "formOptional");
            }
            else
            {
                if (!formSelect.IsRequired || formSelect.HasValue)
                {
                    htmlDiv.Class.Add("formValid");
                }
                else
                {
                    htmlDiv.Class.Add(formSelect.IsRequired ? "formNotEntered" : "formOptional");
                }
            }

            htmlDiv.Hidden.Value = formSelect.IsHidden;

            htmlContainer.Add(htmlDiv);

            HtmlSelect htmlSelect = formSelect.Size.HasValue ?
                                    new HtmlSelect(formSelect.Path, formSelect.Size.Value, formSelect.Update) :
                                    new HtmlSelect(formSelect.Path, formSelect.IsMultiSelect, formSelect.Update);

            htmlSelect.Disabled.Value = formSelect.IsDisabled;

            if (!initialize && firstInvalidId == null)
            {
                if (formSelect.IsRequired && !formSelect.HasValue || !formSelect.IsValid)
                {
                    firstInvalidId = htmlSelect.Id.Value;
                }
            }

            switch (formSelect.OrderElements)
            {
            case OrderElements.LabelMarkInput:

                AddLabelMark(formSelect, htmlSelect, htmlDiv);
                htmlDiv.Add(htmlSelect);

                break;

            case OrderElements.MarkLabelInput:

                AddMarkLabel(formSelect, htmlSelect, htmlDiv);
                htmlDiv.Add(htmlSelect);

                break;

            case OrderElements.InputLabelMark:

                htmlDiv.Add(htmlSelect);
                AddLabelMark(formSelect, htmlSelect, htmlDiv);

                break;

            case OrderElements.InputMarkLabel:

                htmlDiv.Add(htmlSelect);
                AddMarkLabel(formSelect, htmlSelect, htmlDiv);

                break;

            case OrderElements.LabelInputMark:

                AddLabel(formSelect, htmlSelect, htmlDiv);
                htmlDiv.Add(htmlSelect);
                AddMark(formSelect, htmlSelect, htmlDiv);

                break;

            case OrderElements.MarkInputLabel:

                AddMark(formSelect, htmlSelect, htmlDiv);
                htmlDiv.Add(htmlSelect);
                AddLabel(formSelect, htmlSelect, htmlDiv);

                break;

            default:
            case OrderElements.NotSet:

                break;
            }

            foreach (var formOption in formSelect.Content)
            {
                Visit(formOption, htmlSelect);
            }

            if (initialize)
            {
                return;
            }

            string message = null;

            if (formSelect.UseLastMessage)
            {
                if (!string.IsNullOrEmpty(formSelect.LastMessage))
                {
                    message = formSelect.LastMessage;
                }
            }
            else if (formSelect.IsRequired && !formSelect.HasValue)
            {
                message = formSelect.RequiredMessage;
            }
            else if (!formSelect.IsValid)
            {
                message = formSelect.ValidationMessage;
            }

            if (message == null)
            {
                return;
            }

            HtmlLabel htmlLabelMessage = new HtmlLabel(verbose ? string.Format("{0}{1}", formSelect.Path, "Message") : "");

            htmlLabelMessage.Class.Add("formValidationMessage");
            htmlLabelMessage.For.Value = htmlSelect.Id.Value;
            htmlLabelMessage.Add(new HtmlText(message));
            htmlDiv.Add(htmlLabelMessage);
        }
Пример #15
0
        public virtual void Visit(FormDatePicker formDatePicker, HtmlContainer htmlContainer)
        {
            HtmlDiv htmlDiv = verbose ? new HtmlDiv(formDatePicker.Path) : new HtmlDiv();

            htmlDiv.Class.Add("formDatePicker");

            if (!string.IsNullOrWhiteSpace(formDatePicker.CssClass))
            {
                htmlDiv.Class.AddRange(formDatePicker.CssClass.Split(' ').Where(s => s != string.Empty));
            }

            if (!string.IsNullOrWhiteSpace(formDatePicker.Path))
            {
                htmlDiv.Class.Add(string.Format("{0}{1}", "formId", formDatePicker.Path));
            }

            htmlDiv.Class.Add("formField");

            if (initialize)
            {
                htmlDiv.Class.Add(formDatePicker.IsRequired ? "formRequired" : "formOptional");
            }
            else
            {
                if (!formDatePicker.IsRequired || formDatePicker.HasValue)
                {
                    htmlDiv.Class.Add(formDatePicker.IsValid ? "formValid" : "formInvalid");
                }
                else
                {
                    htmlDiv.Class.Add(formDatePicker.IsRequired ? "formNotEntered" : "formOptional");
                }
            }

            htmlDiv.Hidden.Value = formDatePicker.IsHidden;

            htmlContainer.Add(htmlDiv);

            HtmlDatePicker htmlDatePicker = new HtmlDatePicker(formDatePicker.Path);

            htmlDatePicker.Disabled.Value       = formDatePicker.IsDisabled;
            htmlDatePicker.ReadOnly.Value       = formDatePicker.IsReadOnly;
            htmlDatePicker.DataDateFormat.Value = formDatePicker.DateFormat;
            htmlDatePicker.Value.Value          = formDatePicker.HasValue ? formDatePicker.Value.ToString(formDatePicker.DateFormat.Replace('m', 'M'), CultureInfo.InvariantCulture) : "";
            htmlDatePicker.Placeholder.Value    = !string.IsNullOrEmpty(formDatePicker.Placeholder) ? formDatePicker.Placeholder : null;
            htmlDatePicker.AutoComplete.Value   = "off";
            if (formDatePicker.IsReadOnly)
            {
                htmlDatePicker.DataProvide.Value = null;
            }

            if (!initialize && firstInvalidId == null)
            {
                if (formDatePicker.IsRequired && !formDatePicker.HasValue || !formDatePicker.IsValid)
                {
                    firstInvalidId = htmlDatePicker.Id.Value;
                }
            }

            switch (formDatePicker.OrderElements)
            {
            case OrderElements.LabelMarkInput:

                AddLabelMark(formDatePicker, htmlDatePicker, htmlDiv);
                htmlDiv.Add(htmlDatePicker);

                break;

            case OrderElements.MarkLabelInput:

                AddMarkLabel(formDatePicker, htmlDatePicker, htmlDiv);
                htmlDiv.Add(htmlDatePicker);

                break;

            case OrderElements.InputLabelMark:

                htmlDiv.Add(htmlDatePicker);
                AddLabelMark(formDatePicker, htmlDatePicker, htmlDiv);

                break;

            case OrderElements.InputMarkLabel:

                htmlDiv.Add(htmlDatePicker);
                AddMarkLabel(formDatePicker, htmlDatePicker, htmlDiv);

                break;

            case OrderElements.LabelInputMark:

                AddLabel(formDatePicker, htmlDatePicker, htmlDiv);
                htmlDiv.Add(htmlDatePicker);
                AddMark(formDatePicker, htmlDatePicker, htmlDiv);

                break;

            case OrderElements.MarkInputLabel:

                AddMark(formDatePicker, htmlDatePicker, htmlDiv);
                htmlDiv.Add(htmlDatePicker);
                AddLabel(formDatePicker, htmlDatePicker, htmlDiv);

                break;

            default:
            case OrderElements.NotSet:

                break;
            }

            if (initialize)
            {
                return;
            }

            string message = null;

            if (formDatePicker.UseLastMessage)
            {
                if (!string.IsNullOrEmpty(formDatePicker.LastMessage))
                {
                    message = formDatePicker.LastMessage;
                }
            }
            else if (formDatePicker.IsRequired && !formDatePicker.HasValue)
            {
                message = formDatePicker.RequiredMessage;
            }
            else if (!formDatePicker.IsValid)
            {
                message = formDatePicker.ValidationMessage;
            }

            if (message == null)
            {
                return;
            }

            HtmlLabel htmlLabelMessage = new HtmlLabel(verbose ? string.Format("{0}{1}", formDatePicker.Path, "Message") : "");

            htmlLabelMessage.Class.Add("formValidationMessage");
            htmlLabelMessage.For.Value = htmlDatePicker.Id.Value;
            htmlLabelMessage.Add(new HtmlText(message));
            htmlDiv.Add(htmlLabelMessage);
        }
Пример #16
0
        public virtual void Visit(FormButton formButton, HtmlContainer htmlContainer)
        {
            HtmlDiv htmlDiv = verbose ? new HtmlDiv(formButton.Path) : new HtmlDiv();

            htmlDiv.Class.Add("formButton");

            if (!string.IsNullOrWhiteSpace(formButton.CssClass))
            {
                htmlDiv.Class.AddRange(formButton.CssClass.Split(' ').Where(s => s != string.Empty));
            }

            if (!string.IsNullOrWhiteSpace(formButton.Path))
            {
                htmlDiv.Class.Add(string.Format("{0}{1}", "formId", formButton.Path));
            }

            htmlDiv.Hidden.Value = formButton.IsHidden;

            htmlContainer.Add(htmlDiv);

            HtmlButton htmlButton;

            string proceed = "Proceed";
            string cancel  = "Cancel";

            switch (formButton.ConfirmationType)
            {
            case ConfirmationType.BootBox:
                htmlButton = new HtmlButton(formButton.Path, string.Format("ButtonConfirmBootbox('{0}', '{1}', '{2}');", formButton.ConfirmationMessage, formButton.Path, formButton.Parameter));
                scriptRegistry.Include("ButtonConfirmBootbox", proceed, cancel);
                break;

            case ConfirmationType.Gritter:
                htmlButton = new HtmlButton(formButton.Path);
                scriptRegistry.Include("ButtonConfirmGritter", proceed, cancel);
                break;

            default:
            case ConfirmationType.NotSet:
                htmlButton = new HtmlButton(formButton.Path);
                break;
            }

            htmlButton.Class.AddRange(new string[] { "btnFix", "btn", "mt-2" });

            switch (formButton.Type)
            {
            case ButtonType.Primary:
            case ButtonType.Secondary:
            case ButtonType.Success:
            case ButtonType.Danger:
                htmlButton.Class.Add(string.Format("btn-{0}", formButton.Type.ToString().ToLower()));
                break;

            default:
            case ButtonType.NotSet:
                break;
            }

            htmlButton.Disabled.Value = formButton.IsDisabled;
            htmlDiv.Add(htmlButton);

            htmlButton.Value.Value = formButton.Content;
        }
Пример #17
0
        public virtual void Visit(FormNumberSpinner formNumberSpinner, HtmlContainer htmlContainer)
        {
            HtmlDiv htmlDiv = verbose ? new HtmlDiv(formNumberSpinner.Path) : new HtmlDiv();

            htmlDiv.Class.Add("formNumberSpinner");

            if (!string.IsNullOrWhiteSpace(formNumberSpinner.CssClass))
            {
                htmlDiv.Class.AddRange(formNumberSpinner.CssClass.Split(' ').Where(s => s != string.Empty));
            }

            if (!string.IsNullOrWhiteSpace(formNumberSpinner.Path))
            {
                htmlDiv.Class.Add(string.Format("{0}{1}", "formId", formNumberSpinner.Path));
            }

            htmlDiv.Class.Add("formField");

            if (initialize)
            {
                htmlDiv.Class.Add(formNumberSpinner.IsRequired ? "formRequired" : "formOptional");
            }
            else
            {
                if (formNumberSpinner.HasValue)
                {
                    htmlDiv.Class.Add(formNumberSpinner.IsValid ? "formValid" : "formInvalid");
                }
                else
                {
                    htmlDiv.Class.Add(formNumberSpinner.IsRequired ? "formNotEntered" : "formOptional");
                }
            }

            htmlDiv.Hidden.Value = formNumberSpinner.IsHidden;

            htmlContainer.Add(htmlDiv);

            HtmlTextBox htmlTextBox = new HtmlTextBox(formNumberSpinner.Path);

            htmlTextBox.Disabled.Value = formNumberSpinner.IsDisabled;
            htmlTextBox.ReadOnly.Value = formNumberSpinner.IsReadOnly || !formNumberSpinner.IsDirectInput;
            htmlTextBox.Value.Value    = formNumberSpinner.HasValue ? formNumberSpinner.Value.ToString(string.Format("F{0}", formNumberSpinner.Precision)) : "";

            string placeholder = null;

            if (!string.IsNullOrWhiteSpace(formNumberSpinner.Placeholder))
            {
                if (formNumberSpinner.IsRequired && formNumberSpinner.IsRequiredInPlaceholder && !string.IsNullOrWhiteSpace(formNumberSpinner.RequiredMark))
                {
                    placeholder = string.Format("{0} {1}", formNumberSpinner.Placeholder, formNumberSpinner.RequiredMark);
                }
                else if (!formNumberSpinner.IsRequired && formNumberSpinner.IsOptionalInPlaceholder && !string.IsNullOrWhiteSpace(formNumberSpinner.OptionalMark))
                {
                    placeholder = string.Format("{0} {1}", formNumberSpinner.Placeholder, formNumberSpinner.OptionalMark);
                }
                else
                {
                    placeholder = formNumberSpinner.Placeholder;
                }
            }

            htmlTextBox.Placeholder.Value = placeholder;

            if (formNumberSpinner.Update)
            {
                htmlTextBox.Change.Value = string.Format("__doPostBack('{0}', '');", formNumberSpinner.Path);
            }
            else
            {
                if (formNumberSpinner.HasValue)
                {
                    htmlTextBox.DataNumber.Value = formNumberSpinner.Value;
                }

                if (formNumberSpinner.Min.HasValue)
                {
                    htmlTextBox.DataMin.Value = formNumberSpinner.Min.Value;
                }

                if (formNumberSpinner.Max.HasValue)
                {
                    htmlTextBox.DataMax.Value = formNumberSpinner.Max.Value;
                }

                htmlTextBox.DataStep.Value = formNumberSpinner.Step;

                htmlTextBox.DataPrecision.Value = formNumberSpinner.Precision;

                htmlTextBox.Blur.Value = string.Format("NumberSpinnerBlur('{0}')", htmlTextBox.Id.Value);

                scriptRegistry.Include("NumberSpinnerBlur");
            }

            HtmlDiv htmlDivNumberSpinner = BuildDivNumberSpinner(formNumberSpinner, htmlTextBox);

            switch (formNumberSpinner.OrderElements)
            {
            case OrderElements.LabelMarkInput:

                AddLabelMark(formNumberSpinner, htmlTextBox, htmlDiv);
                htmlDiv.Add(htmlDivNumberSpinner);

                break;

            case OrderElements.MarkLabelInput:

                AddMarkLabel(formNumberSpinner, htmlTextBox, htmlDiv);
                htmlDiv.Add(htmlDivNumberSpinner);

                break;

            case OrderElements.InputLabelMark:

                htmlDiv.Add(htmlTextBox);
                AddLabelMark(formNumberSpinner, htmlTextBox, htmlDiv);

                break;

            case OrderElements.InputMarkLabel:

                htmlDiv.Add(htmlDivNumberSpinner);
                AddMarkLabel(formNumberSpinner, htmlTextBox, htmlDiv);

                break;

            case OrderElements.LabelInputMark:

                AddLabel(formNumberSpinner, htmlTextBox, htmlDiv);
                htmlDiv.Add(htmlDivNumberSpinner);
                AddMark(formNumberSpinner, htmlTextBox, htmlDiv);

                break;

            case OrderElements.MarkInputLabel:

                AddMark(formNumberSpinner, htmlTextBox, htmlDiv);
                htmlDiv.Add(htmlDivNumberSpinner);
                AddLabel(formNumberSpinner, htmlTextBox, htmlDiv);

                break;

            default:
            case OrderElements.NotSet:

                break;
            }

            if (initialize)
            {
                return;
            }

            string message = null;

            if (formNumberSpinner.UseLastMessage)
            {
                if (!string.IsNullOrEmpty(formNumberSpinner.LastMessage))
                {
                    message = formNumberSpinner.LastMessage;
                }
            }
            else if (formNumberSpinner.IsRequired && !formNumberSpinner.HasValue)
            {
                message = formNumberSpinner.RequiredMessage;
            }
            else if (!formNumberSpinner.IsValid)
            {
                message = formNumberSpinner.ValidationMessage;
            }

            if (message == null)
            {
                return;
            }

            HtmlLabel htmlLabelMessage = new HtmlLabel(verbose ? string.Format("{0}{1}", formNumberSpinner.Path, "Message") : "");

            htmlLabelMessage.Class.Add("formValidationMessage");
            htmlLabelMessage.For.Value = htmlTextBox.Id.Value;
            htmlLabelMessage.Add(new HtmlText(message));
            htmlDiv.Add(htmlLabelMessage);
        }
Пример #18
0
        public void AddNull()
        {
            HtmlDiv g = new HtmlDiv("");

            g.Add(null);
        }