/// <summary> /// Display Naked Objects Framework messages and warnings from ViewData /// </summary> public static MvcHtmlString UserMessages(this HtmlHelper html) { string[] messages = (string[])html.ViewData[IdHelper.NofMessages] ?? new string[0]; string[] warnings = (string[])html.ViewData[IdHelper.NofWarnings] ?? new string[0]; return(MvcHtmlString.Create(CommonHtmlHelper.UserMessages(messages, IdHelper.NofMessages) + CommonHtmlHelper.UserMessages(warnings, IdHelper.NofWarnings))); }
public static MvcHtmlString Collection(this HtmlHelper html, IEnumerable collection, IActionSpec action, string defaultTo = IdHelper.ListDisplayFormat) { bool renderEagerly = CommonHtmlHelper.RenderEagerly(action); string displayType = DefaultFormat(html, renderEagerly ? IdHelper.TableDisplayFormat : defaultTo); return(displayType == IdHelper.TableDisplayFormat ? CollectionTableInternal(html, collection, action) : CollectionListInternal(html, collection, action)); }
private static ElementDescriptor SubMenuAsElementDescriptor( this HtmlHelper html, IMenuImmutable subMenu, INakedObject nakedObject, bool isEdit) { string tagType = "div"; string value = CommonHtmlHelper.WrapInDiv(subMenu.Name, IdHelper.MenuNameLabel).ToString(); RouteValueDictionary attributes = new RouteValueDictionary(new { @class = IdHelper.SubMenuName, @id = subMenu.Id }); var visibleSubMenuItems = subMenu.MenuItems.Select(item => html.MenuItemAsElementDescriptor(item, nakedObject, isEdit)); if (visibleSubMenuItems.Any(x => x != null)) { return(new ElementDescriptor { TagType = tagType, Value = value, Attributes = attributes, Children = visibleSubMenuItems.WrapInCollection("div", new { @class = IdHelper.SubMenuItemsName }) }); } else { return(null); } }
public static MvcHtmlString ActionResult(this HtmlHelper html, ActionResultModel model) { INakedObject nakedObject = html.Framework().NakedObjectManager.CreateAdapter(model.Result, null, null); string title = GetCollectionTitle(nakedObject, html); title = model.Action.Name + ": " + (string.IsNullOrWhiteSpace(title) ? nakedObject.Spec.UntitledName : title); return(CommonHtmlHelper.WrapInDiv(title, IdHelper.ObjectName)); }
/// <summary> /// Display name of object with icon /// </summary> public static MvcHtmlString Object(this HtmlHelper html, object model) { INakedObject nakedObject = html.Framework().NakedObjectManager.CreateAdapter(model, null, null); string title = nakedObject.Spec.IsCollection ? GetCollectionTitle(nakedObject, html) : nakedObject.TitleString(); title = string.IsNullOrWhiteSpace(title) ? nakedObject.Spec.UntitledName : title; return(CommonHtmlHelper.WrapInDiv(html.ObjectIcon(nakedObject) + title, IdHelper.ObjectName)); }
public static MvcHtmlString ActionResult(this HtmlHelper html, ActionResultModel model) { var nakedObject = html.Facade().GetObject(model.Result); string title = GetCollectionTitle(nakedObject, html); title = model.Action.Name + ": " + (string.IsNullOrWhiteSpace(title) ? nakedObject.Specification.UntitledName : title); return(CommonHtmlHelper.WrapInDiv(title, IdConstants.ObjectName)); }
//TODO: Mark obsolete when Menus refactoring complete //[Obsolete("Add CustomMenuItems into an IMenu directly when constructing menus")] public static MvcHtmlString Service(this HtmlHelper html, object service, params CustomMenuItem[] menuItems) { INakedObject nakedObject = html.Framework().GetNakedObject(service); return(CommonHtmlHelper.BuildMenuContainer(html.ObjectActions(nakedObject, false, menuItems), IdHelper.MenuContainerName, IdHelper.GetServiceContainerId(nakedObject), nakedObject.TitleString())); }
//TODO: Mark obsolete when Menus refactoring complete //[Obsolete("Add CustomMenuItems into an IMenu directly when constructing menus")] public static MvcHtmlString Service(this HtmlHelper html, object service, params CustomMenuItem[] menuItems) { var nakedObject = html.Facade().GetObject(service); return(CommonHtmlHelper.BuildMenuContainer(html.ObjectActions(nakedObject, false, menuItems), IdConstants.MenuContainerName, html.IdHelper().GetServiceContainerId(nakedObject), nakedObject.TitleString)); }
/// <summary> /// Display name of object with icon /// </summary> public static MvcHtmlString Object(this HtmlHelper html, object model) { var nakedObject = html.Facade().GetObject(model); string title = nakedObject.Specification.IsCollection ? GetCollectionTitle(nakedObject, html) : nakedObject.TitleString; title = string.IsNullOrWhiteSpace(title) ? nakedObject.Specification.UntitledName : title; return(CommonHtmlHelper.WrapInDiv(html.ObjectIcon(nakedObject) + title, IdConstants.ObjectName)); }
private static MvcHtmlString MenuAsHtml(this HtmlHelper html, IMenuFacade menu, IObjectFacade nakedObject, bool isEdit, bool defaultToEmptyMenu) { var descriptors = new List <ElementDescriptor>(); foreach (IMenuItemFacade item in menu.MenuItems) { ElementDescriptor descriptor; if (IsDuplicateAndIsVisibleActions(html, item, menu.MenuItems, nakedObject)) { //Test that both items are in fact visible //The Id is set just to preseve backwards compatiblity string id = menu.Id; if (id.EndsWith("Actions")) { id = id.Split('-').First() + "-DuplicateAction"; } descriptor = new ElementDescriptor { TagType = "div", Value = item.Name, Attributes = new RouteValueDictionary(new { id, @class = IdConstants.ActionName, title = MvcUi.DuplicateAction }) }; } else { descriptor = MenuItemAsElementDescriptor(html, item, nakedObject, isEdit); } if (descriptor != null) { //Would be null for an invisible action descriptors.Add(descriptor); } } if (descriptors.Count == 0 && !defaultToEmptyMenu) { return(null); } return(CommonHtmlHelper.BuildMenuContainer(descriptors, IdConstants.MenuContainerName, menu.Id, menu.Name)); }
internal static MvcHtmlString CollectionTableInternal(this HtmlHelper html, IEnumerable collection, IActionFacade action = null) { var nakedObject = html.Facade().GetObject(collection); Func <IAssociationFacade, bool> filterFunc; Func <IAssociationFacade, int> orderFunc; bool withTitle; if (action == null || action.ReturnType.IsVoid) { // todo investigate other ways to do this action = nakedObject.MementoAction; } CommonHtmlHelper.GetTableColumnInfo(action, out filterFunc, out orderFunc, out withTitle); return(html.GetStandaloneCollection(nakedObject, filterFunc, orderFunc, withTitle)); }
/// <summary> /// Get the object type in a format suitable for use as a css id /// </summary> public static MvcHtmlString ObjectTypeAsCssId(this HtmlHelper html, object model) { if (model.GetType().IsGenericType) { var gType = new StringBuilder(CommonHtmlHelper.GetObjectType(model.GetType().GetGenericTypeDefinition())); gType.Append("[["); foreach (Type gTypeParm in model.GetType().GetGenericArguments()) { gType.Append(CommonHtmlHelper.GetObjectType(gTypeParm)).Append(", "); } gType.Remove(gType.Length - 2, 2); gType.Append("]]"); return(MvcHtmlString.Create(gType.ToString())); } return(MvcHtmlString.Create(CommonHtmlHelper.GetObjectType(model))); }
internal static MvcHtmlString CollectionTableInternal(this HtmlHelper html, IEnumerable collection, IActionSpec action = null) { INakedObject nakedObject = html.Framework().GetNakedObject(collection); Func <IAssociationSpec, bool> filterFunc; Func <IAssociationSpec, int> orderFunc; bool withTitle; if (action == null || action.ReturnSpec.IsVoid) { var memento = nakedObject.Oid as CollectionMemento; if (memento != null) { action = memento.Action; } } CommonHtmlHelper.GetTableColumnInfo(action, out filterFunc, out orderFunc, out withTitle); return(html.GetStandaloneCollection(nakedObject, filterFunc, orderFunc, withTitle)); }
/// <summary> /// Display Naked Objects Framework messages and warnings from ViewData /// </summary> public static MvcHtmlString SystemMessages(this HtmlHelper html) { string[] messages = (string[])html.ViewData[IdConstants.SystemMessages] ?? new string[0]; return(MvcHtmlString.Create(CommonHtmlHelper.UserMessages(messages, IdConstants.NofMessages))); }
public static MvcHtmlString Tab(this HtmlHelper html, string linkText, string actionName, object model) { return(CommonHtmlHelper.WrapInDiv(html.ObjectIconAndLink(linkText, actionName, model, true), "nof-tab")); }
/// <summary> /// Display link to object with icon /// </summary> public static MvcHtmlString Object(this HtmlHelper html, string linkText, string actionName, object model) { return(CommonHtmlHelper.WrapInDiv(html.ObjectIconAndLink(linkText, actionName, model), IdHelper.ObjectName)); }