예제 #1
0
        /// <summary>
        /// In HTML konvertieren
        /// </summary>
        /// <param name="context">Der Kontext, indem das Steuerelement dargestellt wird</param>
        /// <returns>Das Control als HTML</returns>
        public override IHtmlNode Render(RenderContextFormular context)
        {
            var renderContext = new RenderContextFormularGroup(context, this);

            var html = new HtmlElementTextContentDiv()
            {
                ID    = ID,
                Class = Css.Concatenate("form-group-column", GetClasses()),
                Style = GetStyles(),
            };

            var max    = 100;
            var offset = 0;

            foreach (var item in Items)
            {
                var input = item as ControlFormularItemInput;
                var div   = new HtmlElementTextContentDiv()
                {
                    Style = ""
                };
                var width = -1;

                if (Distribution.Count > offset)
                {
                    width     = Distribution.Skip(offset).Take(1).FirstOrDefault();
                    div.Style = $"width: { width }%";
                    max       = max - width;

                    offset++;
                }
                else if (Items.Count > offset)
                {
                    width     = max / (Items.Count - offset);
                    div.Style = $"width: { width }%";
                }

                if (input != null)
                {
                    var icon = new ControlIcon()
                    {
                        Icon = input?.Icon
                    };
                    var label    = new ControlFormularItemLabel(!string.IsNullOrEmpty(item.ID) ? item.ID + "_label" : string.Empty);
                    var help     = new ControlFormularItemHelpText(!string.IsNullOrEmpty(item.ID) ? item.ID + "_help" : string.Empty);
                    var fieldset = new HtmlElementFormFieldset()
                    {
                        Class = "form-group"
                    };

                    label.Initialize(renderContext);
                    help.Initialize(renderContext);

                    label.Text         = context.I18N(input?.Label);
                    label.FormularItem = item;
                    help.Text          = context.I18N(input?.Help);

                    if (icon.Icon != null)
                    {
                        icon.Classes.Add("mr-2 pt-1");
                        fieldset.Elements.Add(new HtmlElementTextSemanticsSpan(icon.Render(renderContext), label.Render(renderContext))
                        {
                            Style = "display: flex;"
                        });
                    }
                    else
                    {
                        fieldset.Elements.Add(label.Render(renderContext));
                    }

                    fieldset.Elements.Add(item.Render(renderContext));

                    if (!string.IsNullOrWhiteSpace(input?.Help))
                    {
                        fieldset.Elements.Add(help.Render(renderContext));
                    }

                    div.Elements.Add(fieldset);
                }
                else
                {
                    div.Elements.Add(item.Render(context));
                }

                html.Elements.Add(div);
            }

            return(html);
        }
예제 #2
0
        /// <summary>
        /// In HTML konvertieren
        /// </summary>
        /// <param name="context">Der Kontext, indem das Steuerelement dargestellt wird</param>
        /// <returns>Das Control als HTML</returns>
        public override IHtmlNode Render(RenderContextFormular context)
        {
            var renderContext = new RenderContextFormularGroup(context, this);

            var html = new HtmlElementTextContentDiv()
            {
                ID    = ID,
                Class = Css.Concatenate("", GetClasses()),
                Style = GetStyles(),
            };

            foreach (var item in Items)
            {
                var input = item as ControlFormularItemInput;

                if (input != null)
                {
                    var icon = new ControlIcon()
                    {
                        Icon = input?.Icon
                    };
                    var label    = new ControlFormularItemLabel(!string.IsNullOrEmpty(item.ID) ? item.ID + "_label" : string.Empty);
                    var help     = new ControlFormularItemHelpText(!string.IsNullOrEmpty(item.ID) ? item.ID + "_help" : string.Empty);
                    var fieldset = new HtmlElementFormFieldset()
                    {
                        Class = "form-group"
                    };

                    label.Initialize(renderContext);
                    help.Initialize(renderContext);

                    label.Text         = context.I18N(input?.Label);
                    label.FormularItem = item;
                    help.Text          = context.I18N(input?.Help);

                    if (icon.Icon != null)
                    {
                        icon.Classes.Add("mr-2 pt-1");
                        fieldset.Elements.Add(new HtmlElementTextSemanticsSpan(icon.Render(renderContext), label.Render(renderContext))
                        {
                            Style = "display: flex;"
                        });
                    }
                    else
                    {
                        fieldset.Elements.Add(label.Render(renderContext));
                    }

                    fieldset.Elements.Add(item.Render(renderContext));

                    if (!string.IsNullOrWhiteSpace(input?.Help))
                    {
                        fieldset.Elements.Add(help.Render(renderContext));
                    }

                    html.Elements.Add(fieldset);
                }
                else
                {
                    html.Elements.Add(item?.Render(context));
                }
            }

            return(html);
        }
예제 #3
0
        /// <summary>
        /// In HTML konvertieren
        /// </summary>
        /// <param name="context">Der Kontext, indem das Steuerelement dargestellt wird</param>
        /// <returns>Das Control als HTML</returns>
        public override IHtmlNode Render(RenderContextFormular context)
        {
            var renderContext = new RenderContextFormularGroup(context, this);

            var html = new HtmlElementTextContentDiv()
            {
                ID    = ID,
                Class = Css.Concatenate("form-group-mix", GetClasses()),
                Style = GetStyles(),
            };

            var body = new HtmlElementTextContentDiv()
            {
            };

            foreach (var item in Items)
            {
                var input = item as ControlFormularItemInput;
                var row   = new HtmlElementTextContentDiv()
                {
                };

                if (input != null)
                {
                    var icon = new ControlIcon()
                    {
                        Icon = input?.Icon
                    };
                    var label = new ControlFormularItemLabel(!string.IsNullOrEmpty(item.ID) ? item.ID + "_label" : string.Empty);
                    var help  = new ControlFormularItemHelpText(!string.IsNullOrEmpty(item.ID) ? item.ID + "_help" : string.Empty);

                    label.Initialize(renderContext);
                    help.Initialize(renderContext);

                    label.Text         = context.I18N(input?.Label);
                    label.FormularItem = item;
                    label.Classes.Add("mr-2");
                    help.Text = context.I18N(input?.Help);

                    if (icon.Icon != null)
                    {
                        icon.Classes.Add("mr-2 pt-1");

                        row.Elements.Add(new HtmlElementTextContentDiv(icon.Render(renderContext), label.Render(renderContext)));
                    }
                    else
                    {
                        row.Elements.Add(new HtmlElementTextContentDiv(label.Render(renderContext)));
                    }

                    if (!string.IsNullOrWhiteSpace(input?.Help))
                    {
                        row.Elements.Add(new HtmlElementTextContentDiv(item.Render(renderContext), help.Render(renderContext)));
                    }
                    else
                    {
                        row.Elements.Add(new HtmlElementTextContentDiv(item.Render(renderContext)));
                    }
                }
                else
                {
                    row.Elements.Add(new HtmlElementTextContentDiv());
                    row.Elements.Add(item.Render(context));
                    row.Elements.Add(new HtmlElementTextContentDiv());
                }

                body.Elements.Add(row);
            }

            html.Elements.Add(body);

            return(html);
        }
예제 #4
0
        /// <summary>
        /// In HTML konvertieren
        /// </summary>
        /// <param name="context">Der Kontext, indem das Steuerelement dargestellt wird</param>
        /// <returns>Das Control als HTML</returns>
        public override IHtmlNode Render(RenderContext context)
        {
            var renderContext = new RenderContextFormular(context, this);
            var formName      = $"form_{ Name }";

            Initialize(context);
            (Items as List <ControlFormularItem>).ForEach(x => x.Initialize(renderContext));
            OnInitialize();
            SubmitButton.Initialize(renderContext);

            // Prüfe ob Formular abgeschickt wurde -> Fomular mit Daten füllen
            if (!context.Page.HasParam(formName))
            {
                OnFill();
            }

            PreProcess(renderContext);

            var button = SubmitButton.Render(renderContext);

            var html = new HtmlElementFormForm()
            {
                ID      = ID,
                Class   = Css.Concatenate("form-inline", GetClasses()),
                Style   = GetStyles(),
                Role    = Role,
                Name    = Name.ToLower() != "form" ? "form_" + Name.ToLower() : Name.ToLower(),
                Action  = Uri?.ToString(),
                Method  = "post",
                Enctype = TypeEnctype.None
            };

            html.Elements.Add(new ControlFormularItemInputHidden(formName)
            {
                Value = Name
            }.Render(renderContext));

            foreach (var item in Items)
            {
                if (item is ControlFormularItemInput input)
                {
                    var icon = new ControlIcon()
                    {
                        Icon = input?.Icon
                    };
                    var label    = new ControlFormularItemLabel(!string.IsNullOrEmpty(item.ID) ? item.ID + "_label" : string.Empty);
                    var help     = new ControlFormularItemHelpText(!string.IsNullOrEmpty(item.ID) ? item.ID + "_help" : string.Empty);
                    var fieldset = new HtmlElementFormFieldset()
                    {
                        Class = "form-group"
                    };

                    label.Initialize(renderContext);
                    help.Initialize(renderContext);

                    label.Text         = context.I18N(input?.Label);
                    label.FormularItem = item;
                    label.Classes.Add("mr-2");
                    help.Text = context.I18N(input?.Help);
                    help.Classes.Add("ml-2");

                    if (icon.Icon != null)
                    {
                        icon.Classes.Add("mr-2 pt-1");
                        fieldset.Elements.Add(new HtmlElementTextSemanticsSpan(icon.Render(renderContext), label.Render(renderContext))
                        {
                            Style = "display: flex;"
                        });
                    }
                    else
                    {
                        fieldset.Elements.Add(label.Render(renderContext));
                    }

                    fieldset.Elements.Add(item.Render(renderContext));

                    if (input != null)
                    {
                        fieldset.Elements.Add(help.Render(renderContext));
                    }

                    html.Elements.Add(fieldset);
                }
                else
                {
                    html.Elements.Add(item.Render(context));
                }
            }

            html.Elements.Add(button);

            return(html);
        }