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()); }
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(); }
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()); }
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()); }
private static MvcHtmlString InternalStripElement <T>(this HtmlHelper helper, TypeElementContext <T> itemTC, EntityStrip entityStrip) { HtmlStringBuilder sb = new HtmlStringBuilder(); if (entityStrip.IsVisible == null || entityStrip.IsVisible(itemTC)) { using (sb.SurroundLine(new HtmlTag("li").IdName(itemTC.Compose(EntityStripKeys.StripElement)).Class("sf-strip-element input-group"))) { var lite = (itemTC.UntypedValue as Lite <IEntity>) ?? (itemTC.UntypedValue as IEntity)?.Let(i => i.ToLite(i.IsNew)); if (lite != null && (entityStrip.Navigate || entityStrip.View)) { var dic = new Dictionary <string, object> { { "onclick", entityStrip.SFControlThen("viewItem_click(\"" + itemTC.Prefix + "\", event)") } }; sb.AddLine( helper.Href(itemTC.Compose(EntityBaseKeys.Link), lite.ToString(), "#", lite.ToString(), "sf-entitStrip-link", dic)); } else { sb.AddLine( helper.Span(itemTC.Compose(EntityBaseKeys.Link), itemTC.UntypedValue.ToString() ?? " ", "sf-entitStrip-link")); } sb.AddLine(EntityBaseHelper.WriteIndex(helper, itemTC)); sb.AddLine(helper.HiddenRuntimeInfo(itemTC)); if (EntityBaseHelper.EmbeddedOrNew((Modifiable)(object)itemTC.Value)) { sb.AddLine(EntityBaseHelper.RenderPopup(helper, itemTC, RenderPopupMode.PopupInDiv, entityStrip)); } using (sb.SurroundLine(new HtmlTag("span"))) { if (entityStrip.Move) { sb.AddLine(EntityButtonHelper.MoveUpItem(helper, itemTC, entityStrip, btn: false, elementType: "a", isVertical: entityStrip.Vertical)); sb.AddLine(EntityButtonHelper.MoveDownItem(helper, itemTC, entityStrip, btn: false, elementType: "a", isVertical: entityStrip.Vertical)); } if (entityStrip.View) { sb.AddLine(EntityButtonHelper.ViewItem(helper, itemTC, entityStrip, btn: false)); } if (entityStrip.Remove) { sb.AddLine(EntityButtonHelper.RemoveItem(helper, itemTC, entityStrip, btn: false)); } } } } else { using (sb.SurroundLine(new HtmlTag("li").IdName(itemTC.Compose(EntityStripKeys.StripElement)).Class("sf-strip-element input-group hidden"))) { sb.AddLine(EntityBaseHelper.WriteIndex(helper, itemTC)); sb.AddLine(helper.HiddenRuntimeInfo(itemTC)); } } return(sb.ToHtml()); }