private static MvcHtmlString ObjectMenu(this HtmlHelper html, object domainObject, bool isEdit) { INakedObject nakedObject = html.Framework().GetNakedObject(domainObject); IMenuImmutable objectMenu = nakedObject.Spec.ObjectMenu; return(html.MenuAsHtml(objectMenu, nakedObject, isEdit)); }
public MenuFacade(IMenuImmutable wrapped, IFrameworkFacade facade, INakedObjectsFramework framework) { Wrapped = wrapped; MenuItems = wrapped.MenuItems.Select(i => Wrap(i, facade, framework)).ToList(); Name = wrapped.Name; Id = wrapped.Id; }
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 void Compare(IMenuImmutable menu1, IMenuImmutable menu2) { if (menu1 == null && menu2 == null) { return; } Compare(menu1 as IMenuItemImmutable, menu2); Compare(menu1.MenuItems, menu2.MenuItems); }
private static MvcHtmlString MenuAsHtml(this HtmlHelper html, IMenuImmutable menu, INakedObject nakedObject, bool isEdit) { var descriptors = new List <ElementDescriptor>(); foreach (IMenuItemImmutable item in menu.MenuItems) { var descriptor = MenuItemAsElementDescriptor(html, item, nakedObject, isEdit); 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 = id, @class = IdHelper.ActionName, title = MvcUi.DuplicateAction }) }; } if (descriptor != null) //Would be null for an invisible action { descriptors.Add(descriptor); } } return(CommonHtmlHelper.BuildMenuContainer(descriptors, IdHelper.MenuContainerName, menu.Id, menu.Name)); }
public void Cache(IMenuImmutable mainMenu) { mainMenus = mainMenus.Add(mainMenu); }
public void AddMainMenu(IMenuImmutable menu) => cache.Cache(menu);
private readonly ITestHasActions owningObject; //May be null if it is a MainMenu public TestMenu(IMenuImmutable menu, ITestObjectFactory factory, ITestHasActions owningObject) { this.menu = menu; this.factory = factory; this.owningObject = owningObject; }
public ITestMenu CreateTestMenuMain(IMenuImmutable menu) { return(new TestMenu(menu, this, null)); }
public ITestMenu GetMenu() { IMenuImmutable menu = NakedObject.Spec.Menu; return(new TestMenu(menu, Factory, this)); }
public ITestMenu CreateTestMenuForObject(IMenuImmutable menu, ITestHasActions owningObject) { return new TestMenu(menu, this, owningObject); }
public ITestMenu CreateTestMenuMain(IMenuImmutable menu) { return new TestMenu(menu, this, null); }
public ITestMenu CreateTestMenuMain(IMenuImmutable menu) => new TestMenu(menu, this, null);
public ITestMenu CreateTestMenuForObject(IMenuImmutable menu, ITestHasActions owningObject) => new TestMenu(menu, this, owningObject);
public void AddMainMenu(IMenuImmutable menu) { cache.Cache(menu); }