/// <summary>
        /// include all the properties of the domain object as hidden fields
        /// </summary>
        public static MvcHtmlString PropertyListEditHidden(this HtmlHelper html, object domainObject)
        {
            INakedObject nakedObject = html.Framework().GetNakedObject(domainObject);
            var          fields      = html.EditObjectFields(nakedObject, null, x => false, null);

            return(MvcHtmlString.Create(ElementDescriptor.BuildElementSet(fields).ToString()));
        }
Ejemplo n.º 2
0
        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));
        }
        private static ElementDescriptor MenuItemAsElementDescriptor(this HtmlHelper html, IMenuItemImmutable item, INakedObject nakedObject, bool isEdit)
        {
            ElementDescriptor descriptor = null;

            if (item is IMenuActionImmutable)
            {
                descriptor = MenuActionAsElementDescriptor(html, item as IMenuActionImmutable, nakedObject, isEdit);
            }
            else if (item is IMenu)
            {
                descriptor = SubMenuAsElementDescriptor(html, item as IMenuImmutable, nakedObject, isEdit);
            }
            else if (item is CustomMenuItem)
            {
                descriptor = CustomMenuItemAsDescriptor(html, item as CustomMenuItem);
            }
            return(descriptor);
        }
        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);
        }