private static string FinderActions(this HtmlHelper html, ITypeFacade spec, ActionContext actionContext, string propertyName) {
            if (spec.IsCollection) {
                return String.Empty; // We don't want Finder menu rendered on any collection field
            }
            var allActions = new List<ElementDescriptor> {
                RemoveAction(propertyName),
                html.RecentlyViewedAction(spec, actionContext, propertyName)
            };
            allActions.AddRange(html.FinderActionsForField(actionContext, spec, propertyName));

            if (allActions.Any()) {
                return BuildMenuContainer(allActions,
                    IdConstants.MenuContainerName,
                    actionContext.GetFindMenuId(propertyName),
                    MvcUi.Find).ToString();
            }

            return String.Empty;
        }
Exemplo n.º 2
0
        private static string FinderActions(this HtmlHelper html, INakedObjectSpecification spec, ActionContext actionContext, string propertyName) {
            if (spec.IsCollection) {
                // no finder menu on collection parameters 
                return string.Empty;
            }

            IEnumerable<ElementDescriptor> actions = GetServices().Select(service => new ElementDescriptor {
                TagType = "div",
                Value = WrapInDiv(service.TitleString(), IdHelper.MenuNameLabel).ToString(),
                Children = html.ObjectActionsThatReturn(service, actionContext, spec, propertyName),
                Attributes = new RouteValueDictionary(new {
                    @class = IdHelper.SubMenuName,
                    id = IdHelper.GetSubMenuId(actionContext.Target, service)
                })
            }).Where(ed => ed.Children.Any());

            List<ElementDescriptor> allActions = RemoveAction(propertyName).InList();
            allActions.Add(RecentlyViewedAction(spec, actionContext, propertyName));
            allActions.AddRange(actions);

            if (allActions.Any()) {
                return BuildMenuContainer(allActions,
                                          IdHelper.MenuContainerName,
                                          actionContext.GetFindMenuId(propertyName),
                                          MvcUi.Find).ToString();
            }

            return string.Empty;
        }