AddLine() public method

public AddLine ( ) : void
return void
        private static MvcHtmlString InternalTabRepeaterHeader<T>(this HtmlHelper helper, TypeElementContext<T> itemTC, EntityTabRepeater repeater)
        {
            HtmlStringBuilder sb = new HtmlStringBuilder();

            using (sb.SurroundLine(new HtmlTag("li", itemTC.Compose(EntityRepeaterKeys.RepeaterElement)).Let(h => itemTC.Index == 0 ? h.Class("active") : h)
                .Class("sf-repeater-element")))
            {
                using (sb.SurroundLine(new HtmlTag("a")
                    .Attr("href", "#" + itemTC.Compose(EntityBaseKeys.Entity))
                    .Attr("data-toggle", "tab")))
                {
                    sb.Add(new HtmlTag("span").SetInnerText(itemTC.Value.ToString()));

                    sb.AddLine(EntityBaseHelper.WriteIndex(helper, itemTC));
                    sb.AddLine(helper.HiddenRuntimeInfo(itemTC));

                    if (repeater.Move)
                    {
                        sb.AddLine(EntityButtonHelper.MoveUpItem(helper, itemTC, repeater, btn: false, elementType: "span", isVertical: false));
                        sb.AddLine(EntityButtonHelper.MoveDownItem(helper, itemTC, repeater, btn: false, elementType: "span", isVertical: false));
                    }

                    if (repeater.Remove)
                        sb.AddLine(EntityButtonHelper.RemoveItem(helper, itemTC, repeater, btn: false, elementType: "span"));
                }

            }

            return sb.ToHtml();
        }
        private static MvcHtmlString InternalListDetailElement <T>(this HtmlHelper helper, HtmlStringBuilder sbOptions, TypeElementContext <T> itemTC, EntityListDetail listDetail)
        {
            HtmlStringBuilder sb = new HtmlStringBuilder();

            sb.AddLine(EntityBaseHelper.WriteIndex(helper, itemTC));
            sb.AddLine(helper.HiddenRuntimeInfo(itemTC));

            if (EntityBaseHelper.EmbeddedOrNew((Modifiable)(object)itemTC.Value))
            {
                sb.AddLine(EntityBaseHelper.RenderContent(helper, itemTC, RenderContentMode.ContentInInvisibleDiv, listDetail));
            }
            else if (itemTC.Value != null)
            {
                sb.Add(helper.Div(itemTC.Compose(EntityBaseKeys.Entity), null, "", new Dictionary <string, object> {
                    { "style", "display:none" }
                }));
            }

            sbOptions.Add(new HtmlTag("option")
                          .Id(itemTC.Compose(EntityBaseKeys.ToStr))
                          .Class("sf-entity-list-option")
                          .Let(a => itemTC.Index > 0 ? a : a.Attr("selected", "selected"))
                          .SetInnerText(itemTC.Value?.ToString())
                          .ToHtml(TagRenderMode.Normal));

            return(sb.ToHtml());
        }
Beispiel #3
0
        public override MvcHtmlString ToHtml(HtmlHelper helper)
        {
            HtmlStringBuilder sb = new HtmlStringBuilder();
            using (sb.SurroundLine(new HtmlTag("div").Class("btn-group")))
            {
                var a = new HtmlTag("a")
                    .Id(Id)
                    .Class("btn")
                    .Class("btn-" + Style.ToString().ToLower())
                    .Class(CssClass)
                    .Class("dropdown-toggle")
                    .Attr("data-toggle", "dropdown")
                    .Attr("alt", Tooltip)
                    .Attrs(HtmlProps);

                if (!Enabled)
                    a.Attr("disabled", "disabled");

                using (sb.SurroundLine(a))
                {
                    sb.AddLine(new MvcHtmlString(Text));
                    sb.AddLine(new HtmlTag("span").Class("caret"));
                }


                using (sb.SurroundLine(new HtmlTag("ul").Class("dropdown-menu")))
                {
                    if (Items != null)
                        foreach (var ci in Items)
                            sb.Add(ci.ToHtml());
                }
            }

            return sb.ToHtml();
        }
        static MvcHtmlString QueryTokenCombo(this HtmlHelper helper, QueryToken previous, QueryToken selected, int index, Context context, QueryTokenBuilderSettings settings)
        {
            if (previous != null && AllowSubTokens != null && !AllowSubTokens(previous))
            {
                return(MvcHtmlString.Create(""));
            }

            var queryTokens = previous.SubTokens(settings.QueryDescription, settings.Options);

            if (queryTokens.IsEmpty())
            {
                return(new HtmlTag("input")
                       .Attr("type", "hidden")
                       .IdName(context.Compose("ddlTokensEnd_" + index))
                       .Attr("disabled", "disabled")
                       .Attr("data-parenttoken", previous == null ? "" : previous.FullKey()));
            }

            var options = new HtmlStringBuilder();

            options.AddLine(new HtmlTag("option").Attr("value", "").SetInnerText("-").ToHtml());
            foreach (var qt in queryTokens)
            {
                var option = new HtmlTag("option")
                             .Attr("value", previous == null ? qt.FullKey() : qt.Key)
                             .SetInnerText((previous == null && qt.Parent != null ? " - " : "") + qt.ToString());

                if (selected != null && qt.Key == selected.Key)
                {
                    option.Attr("selected", "selected");
                }

                option.Attr("title", qt.NiceTypeName);
                option.Attr("style", "color:" + qt.TypeColor);

                if (settings.Decorators != null)
                {
                    settings.Decorators(qt, option);
                }

                options.AddLine(option.ToHtml());
            }

            HtmlTag dropdown = new HtmlTag("select")
                               .Class("form-control")
                               .IdName(context.Compose("ddlTokens_" + index))
                               .InnerHtml(options.ToHtml())
                               .Attr("data-parenttoken", previous == null ? "" : previous.FullKey());

            if (selected != null)
            {
                dropdown.Attr("title", selected.NiceTypeName);
                dropdown.Attr("style", "color:" + selected.TypeColor);
            }

            return(dropdown.ToHtml());
        }
        static MvcHtmlString InternalListElement <T>(this HtmlHelper helper, HtmlStringBuilder sbOptions, TypeElementContext <T> itemTC, EntityList entityList)
        {
            HtmlStringBuilder sb = new HtmlStringBuilder();


            sb.AddLine(EntityBaseHelper.WriteIndex(helper, itemTC));
            sb.AddLine(helper.HiddenRuntimeInfo(itemTC));

            if (entityList.IsVisible == null || entityList.IsVisible(itemTC))
            {
                if (EntityBaseHelper.EmbeddedOrNew((Modifiable)(object)itemTC.Value))
                {
                    sb.AddLine(EntityBaseHelper.RenderPopup(helper, itemTC, RenderPopupMode.PopupInDiv, entityList));
                }
                else if (itemTC.Value != null)
                {
                    sb.Add(helper.Div(itemTC.Compose(EntityBaseKeys.Entity), null, "",
                                      new Dictionary <string, object> {
                        { "style", "display:none" }, { "class", "sf-entity-list" }
                    }));
                }

                var optionTag = new HtmlTag("option")
                                .Id(itemTC.Compose(EntityBaseKeys.ToStr))
                                .Class("sf-entity-list-option")
                                .Let(a => itemTC.Index > 0 ? a : a.Attr("selected", "selected"))
                                .SetInnerText(itemTC.Value?.ToString());

                if (!EntityBaseHelper.EmbeddedOrNew((Modifiable)(object)itemTC.Value))
                {
                    PrimaryKey?idOrNull = null;
                    Type       type     = itemTC.Value.GetType();
                    if (type.IsLite())
                    {
                        idOrNull = ((Lite <IEntity>)itemTC.Value).IdOrNull;
                    }

                    if (type.IsEntity())
                    {
                        idOrNull = ((Entity)(object)itemTC.Value).IdOrNull;
                    }

                    optionTag.Attr("title", " ".CombineIfNotEmpty(itemTC.Value.GetType().CleanType().NiceName(), idOrNull));
                }

                sbOptions.Add(optionTag.ToHtml(TagRenderMode.Normal));
            }

            return(sb.ToHtml());
        }
Beispiel #6
0
        public static MvcHtmlString QueryTokenBuilderOptions(this HtmlHelper helper, QueryToken queryToken, Context context, QueryTokenBuilderSettings settings)
        {
            var tokenPath = queryToken.Follow(qt => qt.Parent).Reverse().NotNull().ToList();

            HtmlStringBuilder sb = new HtmlStringBuilder();

            for (int i = 0; i < tokenPath.Count; i++)
            {
                sb.AddLine(helper.QueryTokenCombo(i == 0 ? null : tokenPath[i - 1], tokenPath[i], i, context, settings));
            }

            sb.AddLine(helper.QueryTokenCombo(queryToken, null, tokenPath.Count, context, settings));

            return sb.ToHtml();
        }
        public static MvcHtmlString QueryTokenBuilderOptions(this HtmlHelper helper, QueryToken queryToken, Context context, QueryTokenBuilderSettings settings)
        {
            var tokenPath = queryToken.Follow(qt => qt.Parent).Reverse().NotNull().ToList();

            HtmlStringBuilder sb = new HtmlStringBuilder();

            for (int i = 0; i < tokenPath.Count; i++)
            {
                sb.AddLine(helper.QueryTokenCombo(i == 0 ? null : tokenPath[i - 1], tokenPath[i], i, context, settings));
            }

            sb.AddLine(helper.QueryTokenCombo(queryToken, null, tokenPath.Count, context, settings));

            return(sb.ToHtml());
        }
Beispiel #8
0
        public static MvcHtmlString RenderWidgets(this HtmlHelper helper, WidgetContext ctx)
        {
            if (GetWidget == null)
            {
                return(MvcHtmlString.Empty);
            }

            List <IWidget> widgets = GetWidget.GetInvocationListTyped()
                                     .Select(d => d(ctx))
                                     .NotNull()
                                     .ToList();

            if (widgets.IsNullOrEmpty())
            {
                return(MvcHtmlString.Empty);
            }

            HtmlStringBuilder sb = new HtmlStringBuilder();

            using (sb.SurroundLine(new HtmlTag("ul").Class("sf-widgets")))
            {
                foreach (IWidget widget in widgets)
                {
                    sb.AddLine(widget.ToHtml(helper));
                }
            }
            return(sb.ToHtml());
        }
        public static MvcHtmlString FormGroup(this HtmlHelper html, Context context, string controlId, MvcHtmlString label, MvcHtmlString value)
        {
            if (context.FormGroupStyle == FormGroupStyle.None)
            {
                return(value);
            }

            var form = context is LineBase ? ((LineBase)context).FormGroupHtmlProps : null;

            var formSize = context.FormGroupSizeCss;

            HtmlStringBuilder sb = new HtmlStringBuilder();

            using (sb.SurroundLine(new HtmlTag("div").Class("form-group").Class(formSize).Attrs(form)))
            {
                var lbl = new HtmlTag("label").Attr("for", controlId).InnerHtml(label);

                if (context.FormGroupStyle == FormGroupStyle.SrOnly)
                {
                    lbl.Class("sr-only");
                }
                else if (context.FormGroupStyle == FormGroupStyle.LabelColumns)
                {
                    lbl.Class("control-label").Class(context.LabelColumns.ToString());
                }

                lbl.Attrs(context is LineBase ? ((LineBase)context).LabelHtmlProps : null);

                if (context.FormGroupStyle != FormGroupStyle.BasicDown)
                {
                    sb.AddLine(lbl);
                }

                using (context.FormGroupStyle == FormGroupStyle.LabelColumns ? sb.SurroundLine(new HtmlTag("div").Class(context.ValueColumns.ToString())) : null)
                {
                    sb.AddLine(value);
                }

                if (context.FormGroupStyle == FormGroupStyle.BasicDown)
                {
                    sb.AddLine(lbl);
                }
            }

            return(sb.ToHtml());
        }
Beispiel #10
0
        public virtual MvcHtmlString CombinedScript(HtmlHelper html, string[] files, ScriptType scriptType)
        {
            string scriptElement = scriptType == ScriptType.Css ? cssElement : jsElement;

            HtmlStringBuilder sb = new HtmlStringBuilder();
            foreach (var f in files)
                sb.AddLine(MvcHtmlString.Create(scriptElement.Formato(Subdomain(f + "?v=" + Version))));

            return sb.ToHtml();
        }
        public virtual MvcHtmlString CombinedScript(HtmlHelper html, string[] files, ScriptType scriptType)
        {
            string scriptElement = scriptType == ScriptType.Css ? cssElement : jsElement;

            HtmlStringBuilder sb = new HtmlStringBuilder();

            foreach (var f in files)
            {
                if (f.StartsWith("http", StringComparison.InvariantCultureIgnoreCase))
                {
                    sb.AddLine(MvcHtmlString.Create(scriptElement.FormatWith(f + "?v=" + Version)));
                }
                else
                {
                    sb.AddLine(MvcHtmlString.Create(scriptElement.FormatWith(Subdomain(f + "?v=" + Version))));
                }
            }
            return(sb.ToHtml());
        }
Beispiel #12
0
        public MvcHtmlString ToHtml(HtmlHelper helper)
        {
            HtmlStringBuilder sb = new HtmlStringBuilder();

            using (sb.SurroundLine("li"))
            {
                using (sb.SurroundLine(new HtmlTag("a", Id)
                                       .Class("badge").Class(Class).Class(Active? "sf-widget-active" : null)
                                       .Attr("title", Title)
                                       .Attr("role", "button")
                                       .Attr("href", "#")
                                       .Attr("data-toggle", "dropdown")))
                {
                    if (IconClass.HasText())
                    {
                        sb.AddLine(new HtmlTag("span").Class(IconClass));
                    }

                    if (Text.HasText())
                    {
                        sb.AddLine(new HtmlTag("span").SetInnerText(Text));
                    }

                    if (Html != null)
                    {
                        sb.AddLine(Html);
                    }
                }

                using (sb.SurroundLine(new HtmlTag("ul")
                                       .Class("dropdown-menu dropdown-menu-right")
                                       .Attr("role", "menu")
                                       .Attr("aria-labelledby", Id)))
                {
                    foreach (var mi in Items)
                    {
                        sb.AddLine(mi.ToHtml());
                    }
                }
            }

            return(sb.ToHtml());
        }
        public override MvcHtmlString ToHtml(HtmlHelper helper)
        {
            HtmlStringBuilder sb = new HtmlStringBuilder();

            using (sb.SurroundLine(new HtmlTag("div").Class("btn-group")))
            {
                var a = new HtmlTag("a")
                        .Id(Id)
                        .Class("btn")
                        .Class("btn-" + Style.ToString().ToLower())
                        .Class(CssClass)
                        .Class("dropdown-toggle")
                        .Attr("data-toggle", "dropdown")
                        .Attr("alt", Tooltip)
                        .Attrs(HtmlProps);

                if (!Enabled)
                {
                    a.Attr("disabled", "disabled");
                }

                using (sb.SurroundLine(a))
                {
                    sb.AddLine(new MvcHtmlString(Text));
                    sb.AddLine(new HtmlTag("span").Class("caret"));
                }


                using (sb.SurroundLine(new HtmlTag("ul").Class("dropdown-menu")))
                {
                    if (Items != null)
                    {
                        foreach (var ci in Items)
                        {
                            sb.Add(ci.ToHtml());
                        }
                    }
                }
            }

            return(sb.ToHtml());
        }
Beispiel #14
0
        public virtual MvcHtmlString CombinedScript(HtmlHelper html, string[] files, ScriptType scriptType)
        {
            string scriptElement = scriptType == ScriptType.Css ? cssElement : jsElement;

            HtmlStringBuilder sb = new HtmlStringBuilder();

            foreach (var f in files)
            {
                sb.AddLine(MvcHtmlString.Create(scriptElement.FormatWith(Subdomain(f + "?v=" + Version))));
            }

            return(sb.ToHtml());
        }
Beispiel #15
0
        public static MvcHtmlString ColorTextbox(this HtmlHelper helper, ValueLine valueLine)
        {
            HtmlStringBuilder sb = new HtmlStringBuilder();

            using (sb.SurroundLine(new HtmlTag("div").Class("input-group")))
            {
                valueLine.ValueHtmlProps.AddCssClass("form-control");

                ColorEmbedded color = (ColorEmbedded)valueLine.UntypedValue;

                sb.AddLine(helper.TextBox(valueLine.Prefix, color == null ? "" : color.RGBHex(), valueLine.ValueHtmlProps));

                sb.AddLine(new HtmlTag("span").Class("input-group-addon").InnerHtml(new HtmlTag("i")));
            }

            sb.AddLine(new HtmlTag("script").InnerHtml(MvcHtmlString.Create(
                                                           @" $(function(){
        $('#" + valueLine.Prefix + @"').parent().colorpicker()" + (valueLine.ReadOnly ? ".colorpicker('disable')" : null) + @";
   });")));

            return(sb.ToHtml());
        }
Beispiel #16
0
        public MvcHtmlString ToHTml(HtmlHelper helper)
        {
            HtmlStringBuilder sb = new HtmlStringBuilder();
            using (sb.Surround("li"))
            {
                using (sb.Surround(new HtmlTag("a", Id)
                    .Class("badge").Class(Class).Class(Active? "sf-widget-active" : null)
                    .Attr("title", Title)
                    .Attr("role", "button")
                    .Attr("href", "#")
                    .Attr("data-toggle", "dropdown")))
                {

                    if (IconClass.HasText())
                        sb.AddLine(new HtmlTag("span").Class(IconClass));

                    if (Text.HasText())
                        sb.AddLine(new HtmlTag("span").SetInnerText(Text));

                    if (Html != null)
                        sb.AddLine(Html);
                }

                using (sb.Surround(new HtmlTag("ul")
                    .Class("dropdown-menu dropdown-menu-right")
                    .Attr("role", "menu")
                    .Attr("aria-labelledby", Id)))
                {
                    foreach (var mi in Items)
                    {
                        sb.AddLine(mi.ToHtml());
                    }
                }
            }

            return sb.ToHtml();
        }
        private static MvcHtmlString InternalEntityRepeater<T>(this HtmlHelper helper, EntityTabRepeater repeater)
        {
            if (!repeater.Visible || repeater.HideIfNull && repeater.UntypedValue == null)
                return MvcHtmlString.Empty;

            HtmlStringBuilder sb = new HtmlStringBuilder();

            using (sb.SurroundLine(new HtmlTag("fieldset").Id(repeater.Prefix).Class("sf-tab-repeater-field SF-control-container SF-avoid-child-errors")))
            {
                using (sb.SurroundLine(new HtmlTag("legend")))
                using (sb.SurroundLine(new HtmlTag("div", repeater.Compose("header"))))
                {
                    sb.AddLine(new HtmlTag("span").InnerHtml(repeater.LabelHtml ?? repeater.LabelText.FormatHtml()).ToHtml());

                    using (sb.SurroundLine(new HtmlTag("span", repeater.Compose("shownButton")).Class("pull-right")))
                    {
                        sb.AddLine(EntityButtonHelper.Create(helper, repeater, btn: false));
                        sb.AddLine(EntityButtonHelper.Find(helper, repeater, btn: false));
                    }
                }

                sb.AddLine(helper.Hidden(repeater.Compose(EntityListBaseKeys.ListPresent), ""));

                using (sb.SurroundLine(new HtmlTag("div")))
                {
                    using (sb.SurroundLine(new HtmlTag("ul", repeater.Compose(EntityRepeaterKeys.ItemsContainer)).Class("nav nav-tabs")))
                    {
                        if (repeater.UntypedValue != null)
                        {
                            foreach (var itemTC in TypeContextUtilities.TypeElementContext((TypeContext<MList<T>>)repeater.Parent))
                                sb.Add(InternalTabRepeaterHeader(helper, itemTC, repeater));
                        }
                    }

                    using (sb.SurroundLine(new HtmlTag("div", repeater.Compose(EntityRepeaterKeys.TabsContainer)).Class("tab-content")))
                        if (repeater.UntypedValue != null)
                        {
                            foreach (var itemTC in TypeContextUtilities.TypeElementContext((TypeContext<MList<T>>)repeater.Parent))
                                using (sb.SurroundLine(new HtmlTag("div", itemTC.Compose(EntityBaseKeys.Entity)).Class("tab-pane")
                                    .Let(h => itemTC.Index == 0 ? h.Class("active") : h)))
                                    sb.Add(EntityBaseHelper.RenderContent(helper, itemTC, RenderContentMode.Content, repeater));
                        }
                }

                if (repeater.ElementType.IsEmbeddedEntity() && repeater.Create)
                {
                    T embedded = (T)(object)new ConstructorContext(helper.ViewContext.Controller).ConstructUntyped(typeof(T));
                    TypeElementContext<T> templateTC = new TypeElementContext<T>(embedded, (TypeContext)repeater.Parent, 0, null);
                    sb.AddLine(EntityBaseHelper.EmbeddedTemplate(repeater, EntityBaseHelper.RenderContent(helper, templateTC, RenderContentMode.Content, repeater), templateTC.Value.ToString()));
                }

                sb.AddLine(repeater.ConstructorScript(JsModule.Lines, "EntityTabRepeater"));
            }

            return sb.ToHtml();
        }
Beispiel #18
0
        static MvcHtmlString QueryTokenCombo(this HtmlHelper helper, QueryToken previous, QueryToken selected, int index, Context context, QueryTokenBuilderSettings settings)
        {
            if (previous != null && AllowSubTokens != null && !AllowSubTokens(previous))
                return MvcHtmlString.Create("");

            var queryTokens = previous.SubTokens(settings.QueryDescription, settings.CanAggregate);

            if (queryTokens.IsEmpty())
                return new HtmlTag("input")
                .Attr("type", "hidden")
                .IdName(context.Compose("ddlTokensEnd_" + index))
                .Attr("disabled", "disabled")
                .Attr("data-parenttoken", previous == null ? "" : previous.FullKey());

            var options = new HtmlStringBuilder();
            options.AddLine(new HtmlTag("option").Attr("value", "").SetInnerText("-").ToHtml());
            foreach (var qt in queryTokens)
            {
                var option = new HtmlTag("option")
                    .Attr("value", previous == null ? qt.FullKey() : qt.Key)
                    .SetInnerText((previous == null && qt.Parent != null ? " - " : "") + qt.ToString());

                if (selected != null && qt.Key == selected.Key)
                    option.Attr("selected", "selected");

                option.Attr("title", qt.NiceTypeName);
                option.Attr("style", "color:" + qt.TypeColor);

                if (settings.Decorators != null)
                    settings.Decorators(qt, option); 

                options.AddLine(option.ToHtml());
            }

            HtmlTag dropdown = new HtmlTag("select")
                .Class("form-control")
                .IdName(context.Compose("ddlTokens_" + index))
                .InnerHtml(options.ToHtml()) 
                .Attr("data-parenttoken", previous == null ? "" : previous.FullKey());

            if (selected != null)
            {
                dropdown.Attr("title", selected.NiceTypeName);
                dropdown.Attr("style", "color:" + selected.TypeColor);
            }

            return dropdown.ToHtml();
        }
Beispiel #19
0
        private static MvcHtmlString InternalRepeaterElement <T>(this HtmlHelper helper, TypeElementContext <T> itemTC, EntityRepeater repeater)
        {
            HtmlStringBuilder sb = new HtmlStringBuilder();

            if (repeater.IsVisible == null || repeater.IsVisible(itemTC))
            {
                using (sb.SurroundLine(new HtmlTag("fieldset", itemTC.Compose(EntityRepeaterKeys.RepeaterElement)).Class("sf-repeater-element")))
                {
                    using (sb.SurroundLine(new HtmlTag("legend")))
                    {
                        if (repeater.Remove)
                        {
                            sb.AddLine(EntityButtonHelper.RemoveItem(helper, itemTC, repeater, btn: false, elementType: "a"));
                        }

                        if (repeater.Move)
                        {
                            sb.AddLine(EntityButtonHelper.MoveUpItem(helper, itemTC, repeater, btn: false, elementType: "a", isVertical: true));
                            sb.AddLine(EntityButtonHelper.MoveDownItem(helper, itemTC, repeater, btn: false, elementType: "a", isVertical: true));
                        }
                    }

                    sb.AddLine(EntityBaseHelper.WriteIndex(helper, itemTC));
                    sb.AddLine(helper.HiddenRuntimeInfo(itemTC));

                    sb.AddLine(EntityBaseHelper.RenderContent(helper, itemTC, RenderContentMode.ContentInVisibleDiv, repeater));
                }
            }
            else
            {
                using (sb.SurroundLine(new HtmlTag("fieldset", itemTC.Compose(EntityRepeaterKeys.RepeaterElement)).Class("sf-repeater-element hidden")))
                {
                    sb.AddLine(EntityBaseHelper.WriteIndex(helper, itemTC));
                    sb.AddLine(helper.HiddenRuntimeInfo(itemTC));
                }
            }

            return(sb.ToHtml());
        }
Beispiel #20
0
        internal static MvcHtmlString InternalEntityCombo(this HtmlHelper helper, EntityCombo entityCombo)
        {
            if (!entityCombo.Visible || entityCombo.HideIfNull && entityCombo.UntypedValue == null)
            {
                return(MvcHtmlString.Empty);
            }

            if (!entityCombo.Type.IsIEntity() && !entityCombo.Type.IsLite())
            {
                throw new InvalidOperationException("EntityCombo can only be done for an identifiable or a lite, not for {0}".FormatWith(entityCombo.Type.CleanType()));
            }

            HtmlStringBuilder sb = new HtmlStringBuilder();

            using (sb.SurroundLine(new HtmlTag("div", entityCombo.Prefix).Class("SF-entity-combo SF-control-container")))
            {
                sb.AddLine(helper.HiddenRuntimeInfo(entityCombo));

                using (sb.SurroundLine(new HtmlTag("div", entityCombo.Compose("hidden")).Class("hide")))
                {
                    if (entityCombo.UntypedValue != null)
                    {
                        sb.AddLine(EntityButtonHelper.Create(helper, entityCombo, btn: true));
                        sb.AddLine(EntityButtonHelper.Find(helper, entityCombo, btn: true));
                    }
                    else
                    {
                        sb.AddLine(EntityButtonHelper.View(helper, entityCombo, btn: true));
                        sb.AddLine(EntityButtonHelper.Remove(helper, entityCombo, btn: true));
                    }
                }

                using (sb.SurroundLine(new HtmlTag("div", entityCombo.Compose("inputGroup")).Class("input-group")))
                {
                    if (entityCombo.ReadOnly)
                    {
                        sb.AddLine(helper.FormControlStatic(entityCombo, entityCombo.Compose(EntityBaseKeys.ToStr), entityCombo.UntypedValue?.ToString()));
                    }
                    else
                    {
                        sb.AddLine(DropDownList(helper, entityCombo));
                    }

                    using (sb.SurroundLine(new HtmlTag("span", entityCombo.Compose("shownButton")).Class("input-group-btn")))
                    {
                        if (entityCombo.UntypedValue == null)
                        {
                            sb.AddLine(EntityButtonHelper.Create(helper, entityCombo, btn: true));
                            sb.AddLine(EntityButtonHelper.Find(helper, entityCombo, btn: true));
                        }
                        else
                        {
                            sb.AddLine(EntityButtonHelper.View(helper, entityCombo, btn: true));
                            sb.AddLine(EntityButtonHelper.Remove(helper, entityCombo, btn: true));
                        }
                    }
                }

                if (entityCombo.Type.IsEmbeddedEntity() && entityCombo.Create)
                {
                    EmbeddedEntity embedded   = (EmbeddedEntity) new ConstructorContext(helper.ViewContext.Controller).ConstructUntyped(entityCombo.Type.CleanType());
                    TypeContext    templateTC = ((TypeContext)entityCombo.Parent).Clone(embedded);
                    sb.AddLine(EntityBaseHelper.EmbeddedTemplate(entityCombo, EntityBaseHelper.RenderPopup(helper, templateTC, RenderPopupMode.Popup, entityCombo, isTemplate: true), null));
                }

                if (EntityBaseHelper.EmbeddedOrNew((Modifiable)entityCombo.UntypedValue))
                {
                    sb.AddLine(EntityBaseHelper.RenderPopup(helper, (TypeContext)entityCombo.Parent, RenderPopupMode.PopupInDiv, entityCombo));
                }

                sb.AddLine(entityCombo.ConstructorScript(JsModule.Lines, "EntityCombo"));
            }

            return(helper.FormGroup(entityCombo, entityCombo.Prefix, entityCombo.LabelHtml ?? entityCombo.LabelText.FormatHtml(), sb.ToHtml()));
        }
        private static MvcHtmlString InternalEntityList <T>(this HtmlHelper helper, EntityList entityList)
        {
            if (!entityList.Visible || entityList.HideIfNull && entityList.UntypedValue == null)
            {
                return(MvcHtmlString.Empty);
            }

            HtmlStringBuilder sb = new HtmlStringBuilder();

            using (sb.SurroundLine(new HtmlTag("div", entityList.Prefix).Class("SF-entity-list SF-control-container")))
            {
                sb.AddLine(helper.Hidden(entityList.Compose(EntityListBaseKeys.ListPresent), ""));

                using (sb.SurroundLine(new HtmlTag("div", entityList.Compose("hidden")).Class("hide")))
                {
                }

                HtmlStringBuilder sbSelect = new HtmlStringBuilder();

                var sbSelectContainer = new HtmlTag("select").Attr("size", "6").Class("form-control")
                                        .IdName(entityList.Compose(EntityListBaseKeys.List));

                if (entityList.ListHtmlProps.Any())
                {
                    sbSelectContainer.Attrs(entityList.ListHtmlProps);
                }

                using (sbSelect.SurroundLine(sbSelectContainer))
                {
                    if (entityList.UntypedValue != null)
                    {
                        foreach (var itemTC in TypeContextUtilities.TypeElementContext((TypeContext <MList <T> >)entityList.Parent))
                        {
                            sb.Add(InternalListElement(helper, sbSelect, itemTC, entityList));
                        }
                    }
                }

                using (sb.SurroundLine(new HtmlTag("div", entityList.Compose("inputGroup")).Class("input-group")))
                {
                    sb.Add(sbSelect.ToHtml());

                    using (sb.SurroundLine(new HtmlTag("span", entityList.Compose("shownButton")).Class("input-group-btn btn-group-vertical")))
                    {
                        sb.AddLine(EntityButtonHelper.Create(helper, entityList, btn: true));
                        sb.AddLine(EntityButtonHelper.Find(helper, entityList, btn: true));
                        sb.AddLine(EntityButtonHelper.View(helper, entityList, btn: true));
                        sb.AddLine(EntityButtonHelper.Remove(helper, entityList, btn: true));
                        sb.AddLine(EntityButtonHelper.MoveUp(helper, entityList, btn: true));
                        sb.AddLine(EntityButtonHelper.MoveDown(helper, entityList, btn: true));
                    }
                }

                if (entityList.ElementType.IsEmbeddedEntity() && entityList.Create)
                {
                    T embedded = (T)(object)new ConstructorContext(helper.ViewContext.Controller).ConstructUntyped(typeof(T));
                    TypeElementContext <T> templateTC = new TypeElementContext <T>(embedded, (TypeContext)entityList.Parent, 0, null);
                    sb.AddLine(EntityBaseHelper.EmbeddedTemplate(entityList, EntityBaseHelper.RenderPopup(helper, templateTC, RenderPopupMode.Popup, entityList, isTemplate: true), null));
                }
                sb.AddLine(entityList.ConstructorScript(JsModule.Lines, "EntityList"));
            }

            return(helper.FormGroup(entityList, entityList.Prefix, entityList.LabelHtml ?? entityList.LabelText.FormatHtml(), sb.ToHtml()));
        }
Beispiel #22
0
        public string Class { get; set; } //is applied to link

     
        public void Write(HtmlStringBuilder sb, string currentUrl, int depth)
        {
            if (!this.Visible)
                throw new InvalidOperationException("Invisible menu");

            bool isActive = this.Link != null && this.Link.ToString() == currentUrl ||
                children.HasItems() && children.Any(a => a.Link != null && a.Link.ToString() == currentUrl);

            bool isHeader = IsHeader(depth);

            using (sb.SurroundLine(new HtmlTag("li").Class(isActive ? "active" : null).Class(isHeader ? "dropdown-header" : this.children.HasItems() ? "dropdown" : null)))
            {
                if (Link != null)
                {
                    string link = Link.ToString();

                    if (ManualA != null)
                        sb.AddLine(ManualA(link, title, " ".CombineIfNotEmpty(Class, "selected")));
                    else
                    {
                        HtmlTag tbA = new HtmlTag("a")
                                .Attrs(new { href = link, title = Title, id = Id })
                                .Class(Class);

                        if (Html != null)
                            tbA.InnerHtml(Html);
                        else
                            tbA.SetInnerText(Text);

                        sb.AddLine(tbA.ToHtml());
                    }
                }
                else if (this.children.HasItems() && !isHeader)
                {
                    using (sb.SurroundLine(new HtmlTag("a").Attr("href", "#")
                        .Class("dropdown-toggle")
                        .Class(Class)
                        .Attr("data-toggle", "dropdown")))
                    {
                        if (Html != null)
                            sb.Add(Html);
                        else 
                            sb.Add(new HtmlTag("span").SetInnerText(Text));

                        sb.Add(new HtmlTag("b").Class("caret"));
                    }
                }
                else if (Html != null)
                    sb.AddLine(Html);
                else
                    sb.AddLine(new HtmlTag("span").SetInnerText(Text));

                if (this.children.HasItems() && !isHeader)
                {
                    using (sb.SurroundLine(new HtmlTag("ul").Class("dropdown-menu")))
                    {
                        bool lastHeader = false;
                        foreach (WebMenuItem menu in this.children)
                        {
                            if (menu.Visible)
                            {
                                if(lastHeader)
                                    sb.AddLine(new HtmlTag("li").Class("divider")); 

                                menu.Write(sb, currentUrl, depth + 1);

                                lastHeader = menu.IsHeader(depth + 1);
                            }
                        }
                    }
                }
            }

            if (isHeader)
            {
                foreach (WebMenuItem menu in this.children)
                {
                    if (menu.Visible)
                        menu.Write(sb, currentUrl, depth + 1);
                }

               
            }
        }
Beispiel #23
0
        }                                 //is applied to link


        public void Write(HtmlStringBuilder sb, string currentUrl, int depth)
        {
            if (!this.Visible)
            {
                throw new InvalidOperationException("Invisible menu");
            }

            bool isActive = this.Link != null && this.Link.ToString() == currentUrl ||
                            children.HasItems() && children.Any(a => a.Link != null && a.Link.ToString() == currentUrl);

            bool isHeader = IsHeader(depth);

            using (sb.SurroundLine(new HtmlTag("li").Class(isActive ? "active" : null).Class(isHeader ? "dropdown-header" : this.children.HasItems() ? "dropdown" : null)))
            {
                if (Link != null)
                {
                    string link = Link.ToString();

                    if (ManualA != null)
                    {
                        sb.AddLine(ManualA(link, title, " ".CombineIfNotEmpty(Class, "selected")));
                    }
                    else
                    {
                        HtmlTag tbA = new HtmlTag("a")
                                      .Attrs(new { href = link, title = Title, id = Id })
                                      .Class(Class);

                        if (Html != null)
                        {
                            tbA.InnerHtml(Html);
                        }
                        else
                        {
                            tbA.SetInnerText(Text);
                        }

                        sb.AddLine(tbA.ToHtml());
                    }
                }
                else if (this.children.HasItems() && !isHeader)
                {
                    using (sb.SurroundLine(new HtmlTag("a").Attr("href", "#")
                                           .Class("dropdown-toggle")
                                           .Class(Class)
                                           .Attr("data-toggle", "dropdown")))
                    {
                        if (Html != null)
                        {
                            sb.Add(Html);
                        }
                        else
                        {
                            sb.Add(new HtmlTag("span").SetInnerText(Text));
                        }

                        sb.Add(new HtmlTag("b").Class("caret"));
                    }
                }
                else if (Html != null)
                {
                    sb.AddLine(Html);
                }
                else
                {
                    sb.AddLine(new HtmlTag("span").SetInnerText(Text));
                }

                if (this.children.HasItems() && !isHeader)
                {
                    using (sb.SurroundLine(new HtmlTag("ul").Class("dropdown-menu")))
                    {
                        bool lastHeader = false;
                        foreach (WebMenuItem menu in this.children)
                        {
                            if (menu.Visible)
                            {
                                if (lastHeader)
                                {
                                    sb.AddLine(new HtmlTag("li").Class("divider"));
                                }

                                menu.Write(sb, currentUrl, depth + 1);

                                lastHeader = menu.IsHeader(depth + 1);
                            }
                        }
                    }
                }
            }

            if (isHeader)
            {
                foreach (WebMenuItem menu in this.children)
                {
                    if (menu.Visible)
                    {
                        menu.Write(sb, currentUrl, depth + 1);
                    }
                }
            }
        }
        private static MvcHtmlString InternalEntityListDetail <T>(this HtmlHelper helper, EntityListDetail listDetail)
        {
            if (!listDetail.Visible || listDetail.HideIfNull && listDetail.UntypedValue == null)
            {
                return(MvcHtmlString.Empty);
            }

            HtmlStringBuilder sb = new HtmlStringBuilder();

            using (sb.SurroundLine(new HtmlTag("div", listDetail.Prefix).Class("SF-entity-list-detail SF-control-container")))
            {
                sb.AddLine(helper.Hidden(listDetail.Compose(EntityListBaseKeys.ListPresent), ""));

                using (sb.SurroundLine(new HtmlTag("div", listDetail.Compose("hidden")).Class("hide")))
                {
                }

                HtmlStringBuilder sbSelect = new HtmlStringBuilder();

                var sbSelectContainer = new HtmlTag("select").Attr("size", "6").Class("form-control")
                                        .IdName(listDetail.Compose(EntityListBaseKeys.List));

                if (listDetail.ListHtmlProps.Any())
                {
                    sbSelectContainer.Attrs(listDetail.ListHtmlProps);
                }

                using (sbSelect.SurroundLine(sbSelectContainer))
                {
                    if (listDetail.UntypedValue != null)
                    {
                        foreach (var itemTC in TypeContextUtilities.TypeElementContext((TypeContext <MList <T> >)listDetail.Parent))
                        {
                            sb.Add(InternalListDetailElement(helper, sbSelect, itemTC, listDetail));
                        }
                    }
                }

                using (sb.SurroundLine(new HtmlTag("div", listDetail.Compose("inputGroup")).Class("input-group")))
                {
                    sb.Add(sbSelect.ToHtml());

                    using (sb.SurroundLine(new HtmlTag("span", listDetail.Compose("shownButton")).Class("input-group-btn btn-group-vertical")))
                    {
                        sb.AddLine(EntityButtonHelper.Create(helper, listDetail, btn: true));
                        sb.AddLine(EntityButtonHelper.Find(helper, listDetail, btn: true));
                        sb.AddLine(EntityButtonHelper.Remove(helper, listDetail, btn: true));
                        sb.AddLine(EntityButtonHelper.MoveUp(helper, listDetail, btn: true));
                        sb.AddLine(EntityButtonHelper.MoveDown(helper, listDetail, btn: true));
                    }
                }

                if (listDetail.ElementType.IsEmbeddedEntity() && listDetail.Create)
                {
                    T embedded = (T)(object)new ConstructorContext(helper.ViewContext.Controller).ConstructUntyped(typeof(T));
                    TypeElementContext <T> templateTC = new TypeElementContext <T>(embedded, (TypeContext)listDetail.Parent, 0, null);
                    sb.AddLine(EntityBaseHelper.EmbeddedTemplate(listDetail, EntityBaseHelper.RenderContent(helper, templateTC, RenderContentMode.Content, listDetail), templateTC.Value.ToString()));
                }

                sb.AddLine(listDetail.ConstructorScript(JsModule.Lines, "EntityListDetail"));
            }

            var formGroup = helper.FormGroup(listDetail, listDetail.Prefix, listDetail.LabelHtml ?? listDetail.LabelText.FormatHtml(), sb.ToHtml());

            if (listDetail.DetailDiv != listDetail.Compose(EntityBaseKeys.Detail))
            {
                return(formGroup);
            }

            HtmlStringBuilder sb2 = new HtmlStringBuilder();

            sb2.Add(formGroup);
            using (sb2.SurroundLine(new HtmlTag("fieldset")))
                sb2.AddLine(helper.Div(listDetail.DetailDiv, null, "SF-entity-list-detail-detaildiv"));

            return(sb2.ToHtml());
        }
Beispiel #25
0
        public static MvcHtmlString NewFilter(this HtmlHelper helper, FilterOption filterOptions, Context context, int index)
        {
            HtmlStringBuilder sb = new HtmlStringBuilder();

            FilterType             filterType         = QueryUtils.GetFilterType(filterOptions.Token.Type);
            List <FilterOperation> possibleOperations = QueryUtils.GetFilterOperations(filterType);

            var id = context.Compose("trFilter", index.ToString());

            using (sb.SurroundLine(new HtmlTag("tr").Id(id)))
            {
                using (sb.SurroundLine("td"))
                {
                    if (!filterOptions.Frozen)
                    {
                        sb.AddLine(new HtmlTag("a", context.Compose("btnDelete", index.ToString()))
                                   .Attr("title", SearchMessage.DeleteFilter.NiceToString())
                                   .Attr("onclick", JsModule.Finder["deleteFilter"](id).ToString())
                                   .Class("sf-line-button sf-remove")
                                   .InnerHtml(new HtmlTag("span").Class("glyphicon glyphicon-remove")));
                    }
                }

                using (sb.SurroundLine(new HtmlTag("td")))
                {
                    sb.AddLine(new HtmlTag("input")
                               .Attr("type", "hidden")
                               .Attr("value", filterOptions.Token.FullKey())
                               .ToHtmlSelf());

                    foreach (var t in filterOptions.Token.Follow(tok => tok.Parent).Reverse())
                    {
                        sb.AddLine(new HtmlTag("span")
                                   .Class("sf-filter-token")
                                   .Attr("title", t.NiceTypeName)
                                   .Attr("style", "color:" + t.TypeColor)
                                   .SetInnerText(t.ToString()).ToHtml());
                    }
                }

                using (sb.SurroundLine("td"))
                {
                    var dic = new Dictionary <string, object> {
                        { "class", "form-control" }
                    };
                    if (filterOptions.Frozen)
                    {
                        dic.Add("disabled", "disabled");
                    }

                    sb.AddLine(
                        helper.SafeDropDownList(
                            context.Compose("ddlSelector", index.ToString()),
                            possibleOperations.Select(fo =>
                                                      new SelectListItem
                    {
                        Text     = fo.NiceToString(),
                        Value    = fo.ToString(),
                        Selected = fo == filterOptions.Operation
                    }),
                            dic));
                }

                using (sb.SurroundLine("td"))
                {
                    Context valueContext = new Context(context, "value_" + index.ToString());

                    if (filterOptions.Frozen && !filterOptions.Token.Type.IsLite())
                    {
                        string txtValue = (filterOptions.Value != null) ? filterOptions.Value.ToString() : "";
                        sb.AddLine(helper.TextBox(valueContext.Prefix, txtValue, new { @readonly = "readonly" }));
                    }
                    else
                    {
                        sb.AddLine(PrintValueField(helper, valueContext, filterOptions));
                    }
                }
            }

            return(sb.ToHtml());
        }
Beispiel #26
0
        internal static MvcHtmlString InternalEntityLine(this HtmlHelper helper, EntityLine entityLine)
        {
            if (!entityLine.Visible || (entityLine.HideIfNull && entityLine.UntypedValue == null))
            {
                return(MvcHtmlString.Empty);
            }

            HtmlStringBuilder sb = new HtmlStringBuilder();

            using (sb.SurroundLine(new HtmlTag("div", entityLine.Prefix).Class("SF-entity-line SF-control-container")))
            {
                sb.AddLine(helper.HiddenRuntimeInfo(entityLine));

                using (sb.SurroundLine(new HtmlTag("div", entityLine.Compose("hidden")).Class("hide")))
                {
                    if (entityLine.UntypedValue != null)
                    {
                        sb.AddLine(AutocompleteTextBox(helper, entityLine));
                        sb.AddLine(EntityButtonHelper.Create(helper, entityLine, btn: true));
                        sb.AddLine(EntityButtonHelper.Find(helper, entityLine, btn: true));
                    }
                    else
                    {
                        sb.AddLine(LinkOrSpan(helper, entityLine));
                        sb.AddLine(EntityButtonHelper.View(helper, entityLine, btn: true));
                        sb.AddLine(EntityButtonHelper.Remove(helper, entityLine, btn: true));
                    }
                }

                using (sb.SurroundLine(new HtmlTag("div", entityLine.Compose("inputGroup")).Class("input-group")))
                {
                    if (entityLine.UntypedValue == null)
                    {
                        sb.AddLine(AutocompleteTextBox(helper, entityLine));
                    }
                    else
                    {
                        sb.AddLine(LinkOrSpan(helper, entityLine));
                    }

                    using (sb.SurroundLine(new HtmlTag("span", entityLine.Compose("shownButton")).Class("input-group-btn")))
                    {
                        if (entityLine.UntypedValue == null)
                        {
                            sb.AddLine(EntityButtonHelper.Create(helper, entityLine, btn: true));
                            sb.AddLine(EntityButtonHelper.Find(helper, entityLine, btn: true));
                        }
                        else
                        {
                            sb.AddLine(EntityButtonHelper.View(helper, entityLine, btn: true));
                            sb.AddLine(EntityButtonHelper.Remove(helper, entityLine, btn: true));
                        }
                    }
                }

                if (entityLine.Type.IsEmbeddedEntity() && entityLine.Create)
                {
                    EmbeddedEntity embedded   = (EmbeddedEntity) new ConstructorContext(helper.ViewContext.Controller).ConstructUntyped(entityLine.Type.CleanType());
                    TypeContext    templateTC = ((TypeContext)entityLine.Parent).Clone(embedded);
                    sb.AddLine(EntityBaseHelper.EmbeddedTemplate(entityLine, EntityBaseHelper.RenderPopup(helper, templateTC, RenderPopupMode.Popup, entityLine, isTemplate: true), null));
                }

                if (EntityBaseHelper.EmbeddedOrNew((Modifiable)entityLine.UntypedValue))
                {
                    sb.AddLine(EntityBaseHelper.RenderPopup(helper, (TypeContext)entityLine.Parent, RenderPopupMode.PopupInDiv, entityLine));
                }


                sb.AddLine(entityLine.ConstructorScript(JsModule.Lines, "EntityLine"));
            }

            return(helper.FormGroup(entityLine, entityLine.Prefix, entityLine.LabelHtml ?? entityLine.LabelText.FormatHtml(), sb.ToHtml()));
        }
Beispiel #27
0
        public static MvcHtmlString NewFilter(this HtmlHelper helper, FilterOption filterOptions, Context context, int index)
        {
            HtmlStringBuilder sb = new HtmlStringBuilder();

            FilterType filterType = QueryUtils.GetFilterType(filterOptions.Token.Type);
            List<FilterOperation> possibleOperations = QueryUtils.GetFilterOperations(filterType);

            var id = context.Compose("trFilter", index.ToString());

            using (sb.SurroundLine(new HtmlTag("tr").Id(id)))
            {
                using (sb.SurroundLine("td"))
                {
                    if (!filterOptions.Frozen)
                    {
                        sb.AddLine(new HtmlTag("a", context.Compose("btnDelete", index.ToString()))
                        .Attr("title",  SearchMessage.DeleteFilter.NiceToString())
                        .Attr("onclick", JsModule.Finder["deleteFilter"](id).ToString())
                        .Class("sf-line-button sf-remove")
                        .InnerHtml(new HtmlTag("span").Class("glyphicon glyphicon-remove")));
                    }
                }

                using (sb.SurroundLine(new HtmlTag("td")))
                {
                    sb.AddLine(new HtmlTag("input")
                        .Attr("type", "hidden")
                        .Attr("value", filterOptions.Token.FullKey())
                        .ToHtmlSelf());
                        
                    foreach (var t in filterOptions.Token.Follow(tok => tok.Parent).Reverse())
                    {
                        sb.AddLine(new HtmlTag("span")
                            .Class("sf-filter-token")
                            .Attr("title", t.NiceTypeName)
                            .Attr("style", "color:" + t.TypeColor)
                            .SetInnerText(t.ToString()).ToHtml());
                    }
                }

                using (sb.SurroundLine("td"))
                {
                    var dic = new Dictionary<string, object> { { "class", "form-control" } };
                    if (filterOptions.Frozen)
                        dic.Add("disabled", "disabled");

                    sb.AddLine(
                        helper.SafeDropDownList(
                        context.Compose("ddlSelector", index.ToString()),
                        possibleOperations.Select(fo =>
                            new SelectListItem
                            {
                                Text = fo.NiceToString(),
                                Value = fo.ToString(),
                                Selected = fo == filterOptions.Operation
                            }),
                            dic));
                }

                using (sb.SurroundLine("td"))
                {
                    Context valueContext = new Context(context, "value_" + index.ToString());

                    if (filterOptions.Frozen && !filterOptions.Token.Type.IsLite())
                    {
                        string txtValue = (filterOptions.Value != null) ? filterOptions.Value.ToString() : "";
                        sb.AddLine(helper.TextBox(valueContext.Prefix, txtValue, new { @readonly = "readonly" }));
                    }
                    else
                        sb.AddLine(PrintValueField(helper, valueContext, filterOptions));
                }
            }

            return sb.ToHtml();
        }
        internal static MvcHtmlString InternalEntityDetail(this HtmlHelper helper, EntityDetail entityDetail)
        {
            if (!entityDetail.Visible || entityDetail.HideIfNull && entityDetail.UntypedValue == null)
            {
                return(MvcHtmlString.Empty);
            }

            HtmlStringBuilder sb = new HtmlStringBuilder();

            using (sb.SurroundLine(new HtmlTag("fieldset", entityDetail.Prefix).Class("SF-entity-line-details SF-control-container")))
            {
                sb.AddLine(helper.HiddenRuntimeInfo(entityDetail));

                using (sb.SurroundLine(new HtmlTag("div", entityDetail.Compose("hidden")).Class("hide")))
                {
                    if (entityDetail.UntypedValue != null)
                    {
                        sb.AddLine(EntityButtonHelper.Create(helper, entityDetail, btn: false));
                        sb.AddLine(EntityButtonHelper.Find(helper, entityDetail, btn: false));
                    }
                    else
                    {
                        sb.AddLine(EntityButtonHelper.Remove(helper, entityDetail, btn: false));
                    }
                }

                using (sb.SurroundLine(new HtmlTag("legend")))
                    using (sb.SurroundLine(new HtmlTag("div", entityDetail.Compose("header"))))
                    {
                        sb.AddLine(new HtmlTag("span").InnerHtml(entityDetail.LabelHtml ?? entityDetail.LabelText.FormatHtml()).ToHtml());

                        using (sb.SurroundLine(new HtmlTag("span", entityDetail.Compose("shownButton")).Class("pull-right")))
                        {
                            if (entityDetail.UntypedValue == null)
                            {
                                sb.AddLine(EntityButtonHelper.Create(helper, entityDetail, btn: false));
                                sb.AddLine(EntityButtonHelper.Find(helper, entityDetail, btn: false));
                            }
                            else
                            {
                                sb.AddLine(EntityButtonHelper.Remove(helper, entityDetail, btn: false));
                            }
                        }
                    }

                using (sb.SurroundLine(new HtmlTag("div", entityDetail.Compose(EntityBaseKeys.Detail))))
                {
                    if (entityDetail.UntypedValue != null)
                    {
                        sb.AddLine(EntityBaseHelper.RenderContent(helper, (TypeContext)entityDetail.Parent, RenderContentMode.Content, entityDetail));
                    }
                }

                if (entityDetail.Type.IsEmbeddedEntity() && entityDetail.Create)
                {
                    EmbeddedEntity embedded   = (EmbeddedEntity) new ConstructorContext(helper.ViewContext.Controller).ConstructUntyped(entityDetail.Type.CleanType());
                    TypeContext    templateTC = ((TypeContext)entityDetail.Parent).Clone(embedded);
                    sb.AddLine(EntityBaseHelper.EmbeddedTemplate(entityDetail, EntityBaseHelper.RenderContent(helper, templateTC, RenderContentMode.Content, entityDetail), null));
                }

                sb.AddLine(entityDetail.ConstructorScript(JsModule.Lines, "EntityDetail"));
            }

            return(sb.ToHtml());
        }
Beispiel #29
0
        public static MvcHtmlString RenderWidgetsForEntity(this HtmlHelper helper, WidgetContext ctx)
        {
            if (GetWidget == null)
                return MvcHtmlString.Empty;

            List<IWidget> widgets = GetWidget.GetInvocationList()
                .Cast<Func<WidgetContext, IWidget>>()
                .Select(d => d(ctx))
                .NotNull()
                .ToList();

            if (widgets.IsNullOrEmpty())
                return MvcHtmlString.Empty;

            HtmlStringBuilder sb = new HtmlStringBuilder();
            using (sb.Surround(new HtmlTag("ul").Class("sf-widgets")))
            {
                foreach (Widget widget in widgets)
                {
                    sb.AddLine(widget.ToHTml(helper));
                }
            }
            return sb.ToHtml();
        }
Beispiel #30
0
        private static MvcHtmlString InternalGridRepeater<T>(this HtmlHelper helper, GridRepeater repeater)
            where T : ModifiableEntity, IGridEntity
        {
            if (!repeater.Visible || repeater.HideIfNull && repeater.UntypedValue == null)
                return MvcHtmlString.Empty;

            HtmlStringBuilder sb = new HtmlStringBuilder();
            using (sb.SurroundLine(new HtmlTag("fieldset", repeater.Prefix).Class("SF-grid-repeater-field SF-control-container")))
            {
                sb.AddLine(helper.Hidden(repeater.Compose(EntityListBaseKeys.ListPresent), ""));

                using (sb.SurroundLine(new HtmlTag("div", repeater.Compose("hidden")).Class("hide")))
                {
                }

                using (sb.SurroundLine(new HtmlTag("legend")))
                using (sb.SurroundLine(new HtmlTag("div", repeater.Compose("header"))))
                {
                    sb.AddLine(new HtmlTag("span").InnerHtml(repeater.LabelHtml ?? repeater.LabelText.FormatHtml()).ToHtml());

                    using (sb.SurroundLine(new HtmlTag("span", repeater.Compose("shownButton")).Class("pull-right")))
                    {
                        sb.AddLine(EntityButtonHelper.Create(helper, repeater, btn: false));
                        sb.AddLine(EntityButtonHelper.Find(helper, repeater, btn: false));
                    }
                }

                using (sb.SurroundLine(new HtmlTag("div").Class("row rule")))
                {
                    for (int i = 0; i < 12; i++)
                    {
                        using (sb.SurroundLine(new HtmlTag("div").Class("col-sm-1")))
                        using (sb.SurroundLine(new HtmlTag("div").Class("ruleItem")))
                        {
                        }
                    }
                }

                using (sb.SurroundLine(new HtmlTag("div").Id(repeater.Compose(EntityRepeaterKeys.ItemsContainer))))
                {
                    if (repeater.UntypedValue != null)
                    {
                        foreach (var gr in TypeContextUtilities.TypeElementContext((TypeContext<MList<T>>)repeater.Parent).GroupBy(a => a.Value.Row).OrderBy(a => a.Key))
                        {
                            using (sb.SurroundLine(new HtmlTag("div").Class("row separator-row")))
                            {
                            }

                            using (sb.SurroundLine(new HtmlTag("div").Class("row items-row")))
                            {
                                var lastEnd = 0;
                                foreach (var itemTC in gr.OrderBy(a => a.Value.StartColumn))
                                {
                                    helper.ViewData[LastEnd] = lastEnd;
                                    sb.Add(EntityBaseHelper.RenderContent(helper, itemTC, RenderContentMode.Content, repeater));
                                    lastEnd = itemTC.Value.StartColumn + itemTC.Value.Columns;
                                }
                            }
                        }

                        helper.ViewData.Remove("lastEnd");
                    }

                    using (sb.SurroundLine(new HtmlTag("div").Class("row separator-row")))
                    {
                    }
                }

                sb.AddLine(repeater.ConstructorScript(DashboardClient.GridRepeater, "GridRepeater"));
            }

            return sb.ToHtml();
        }