public static MvcHtmlString RenderPopup(HtmlHelper helper, TypeContext typeContext, RenderPopupMode mode, EntityBase line, bool isTemplate = false) { TypeContext tc = TypeContextUtilities.CleanTypeContext((TypeContext)typeContext); ViewDataDictionary vdd = GetViewData(helper, line, tc); string partialViewName = line.PartialViewName ?? OnPartialViewName(tc); vdd[ViewDataKeys.PartialViewName] = partialViewName; vdd[ViewDataKeys.ViewMode] = !line.ReadOnly; vdd[ViewDataKeys.ViewMode] = ViewMode.View; vdd[ViewDataKeys.ShowOperations] = true; vdd[ViewDataKeys.SaveProtected] = OperationLogic.IsSaveProtected(tc.UntypedValue.GetType()); vdd[ViewDataKeys.WriteEntityState] = !isTemplate && !(tc.UntypedValue is EmbeddedEntity) && ((ModifiableEntity)tc.UntypedValue).Modified == ModifiedState.SelfModified; switch (mode) { case RenderPopupMode.Popup: return helper.Partial(Navigator.Manager.PopupControlView, vdd); case RenderPopupMode.PopupInDiv: return helper.Div(typeContext.Compose(EntityBaseKeys.Entity), helper.Partial(Navigator.Manager.PopupControlView, vdd), "", new Dictionary<string, object> { { "style", "display:none" } }); default: throw new InvalidOperationException(); } }
public static MvcHtmlString RenderContent(HtmlHelper helper, TypeContext typeContext, RenderContentMode mode, EntityBase line) { TypeContext tc = TypeContextUtilities.CleanTypeContext((TypeContext)typeContext); ViewDataDictionary vdd = GetViewData(helper, line, tc); string partialViewName = line.PartialViewName ?? OnPartialViewName(tc); switch (mode) { case RenderContentMode.Content: return helper.Partial(partialViewName, vdd); case RenderContentMode.ContentInVisibleDiv: return helper.Div(typeContext.Compose(EntityBaseKeys.Entity), helper.Partial(partialViewName, vdd), "", null); case RenderContentMode.ContentInInvisibleDiv: return helper.Div(typeContext.Compose(EntityBaseKeys.Entity), helper.Partial(partialViewName, vdd), "", new Dictionary<string, object> { { "style", "display:none" } }); default: throw new InvalidOperationException(); } }
private static ViewDataDictionary GetViewData(HtmlHelper helper, EntityBase line, TypeContext tc) { ViewDataDictionary vdd; if (line.PreserveViewData) { vdd = helper.ViewData; vdd.Model = tc; } else { vdd = new ViewDataDictionary(tc); } return vdd; }
public static MvcHtmlString Remove(HtmlHelper helper, EntityBase entityBase, bool btn) { if (!entityBase.Remove) return MvcHtmlString.Empty; return new HtmlTag("a", entityBase.Compose("btnRemove")) .Class(btn ? "btn btn-default" : null) .Class("sf-line-button sf-remove") .Attr("onclick", entityBase.SFControlThen("remove_click()")) .Attr("title", EntityControlMessage.Remove.NiceToString()) .InnerHtml(new HtmlTag("span").Class("glyphicon glyphicon-remove")); }
public static MvcHtmlString View(HtmlHelper helper, EntityBase entityBase, bool btn) { if (!entityBase.View) return MvcHtmlString.Empty; return new HtmlTag("a", entityBase.Compose("btnView")) .Class(btn ? "btn btn-default" : null) .Class("sf-line-button sf-view") .Attr("onclick", entityBase.SFControlThen("view_click()")) .Attr("title", EntityControlMessage.View.NiceToString()) .InnerHtml(new HtmlTag("span").Class("glyphicon glyphicon-arrow-right")); }
public static void ConfigureEntityButtons(EntityBase eb, Type cleanType) { eb.Create &= cleanType.IsEmbeddedEntity() ? Navigator.IsCreable(cleanType, isSearchEntity: false) : eb.Implementations.Value.IsByAll ? false : eb.Implementations.Value.Types.Any(t => Navigator.IsCreable(t, isSearchEntity: false)); eb.View &= cleanType.IsEmbeddedEntity() ? Navigator.IsViewable(cleanType, eb.PartialViewName) : eb.Implementations.Value.IsByAll ? true : eb.Implementations.Value.Types.Any(t => Navigator.IsViewable(t, eb.PartialViewName)); eb.Navigate &= cleanType.IsEmbeddedEntity() ? Navigator.IsNavigable(cleanType, eb.PartialViewName, isSearchEntity: false) : eb.Implementations.Value.IsByAll ? true : eb.Implementations.Value.Types.Any(t => Navigator.IsNavigable(t, eb.PartialViewName, isSearchEntity: false)); eb.Find &= cleanType.IsEmbeddedEntity() ? false : eb.Implementations.Value.IsByAll ? false : eb.Implementations.Value.Types.Any(t => Navigator.IsFindable(t)); }
public static void ConfigureEntityBase(EntityBase eb, Type cleanType) { Common.TaskSetImplementations(eb); ConfigureEntityButtons(eb, cleanType); }
public static MvcHtmlString EmbeddedTemplate(EntityBase entityBase, MvcHtmlString template, string defaultString) { return MvcHtmlString.Create("<script type=\"template\" id=\"{0}\" data-toString=\"{2}\">{1}</script>".Formato( entityBase.Compose(EntityBaseKeys.Template), regex.Replace(template.ToHtmlString(), m => m.Value + "X"), defaultString)); }