internal static string GetActionAsForm(this HtmlHelper html, ActionContext actionContext, string controllerName, object routeValues, out string value, out RouteValueDictionary attributes) {
            const string tagType = "form";

            IEnumerable<ElementDescriptor> concurrencyElements = html.GetConcurrencyElements(actionContext.Target, actionContext.GetConcurrencyActionInputId);

            string elements = concurrencyElements.Aggregate(String.Empty, (s, t) => s + t.BuildElement());

            RouteValueDictionary routeValueDictionary;
            if (actionContext.ParameterValues != null && actionContext.ParameterValues.Any()) {
                // custom values have been set so push the values into view data 
                // fields will be hidden and action will be 'none' so that action goes straight through and doesn't prompt for 
                // parameters 

                foreach (var pc in actionContext.GetParameterContexts(html.Facade())) {
                    if (pc.CustomValue != null) {
                        html.ViewData[html.IdHelper().GetParameterInputId((actionContext.Action), (pc.Parameter))] = pc.CustomValue.Specification.IsParseable ? pc.CustomValue.GetDomainObject() : pc.CustomValue;
                    }
                }

                List<ElementDescriptor> paramElements = html.ActionParameterFields(actionContext).ToList();
                elements = paramElements.Aggregate(String.Empty, (s, t) => s + t.BuildElement());
                routeValueDictionary = new RouteValueDictionary();
            } else {
                routeValueDictionary = new RouteValueDictionary(new { action = "action" });
            }

            value = (elements + GetSubmitButton(null, actionContext.Action.Name, IdConstants.ActionInvokeAction, routeValueDictionary)).WrapInDivTag();

            attributes = new RouteValueDictionary(new {
                action = html.GenerateUrl(Action(actionContext.Action.Id), controllerName, new RouteValueDictionary(routeValues)),
                method = "post",
                id = actionContext.GetActionId(),
                @class = actionContext.GetActionClass()
            });
            return tagType;
        }
 internal static string GetVetoedAction(this HtmlHelper html, ActionContext actionContext, IConsentFacade consent, out string value, out RouteValueDictionary attributes) {
     value = actionContext.Action.Name;
     attributes = new RouteValueDictionary(new {
         id = actionContext.GetActionId(),
         @class = actionContext.GetActionClass(),
         title = consent.Reason
     });
     return "div";
 }
 internal static string GetDuplicateAction(this HtmlHelper html, ActionContext actionContext, string reason, out string value, out RouteValueDictionary attributes) {
     value = actionContext.Action.Name;
     attributes = new RouteValueDictionary(new {
         id = actionContext.GetActionId(),
         @class = actionContext.GetActionClass(),
         title = reason
     });
     return "div";
 }
        private static RouteValueDictionary GetActionAttributes(this HtmlHelper html,
                                                                string name,
                                                                ActionContext targetActionContext,
                                                                ActionContext actionContext,
                                                                string propertyName) {
            var actionContextAction = actionContext.Action;
            var actionContextTarget = actionContext.Target;
            var targetActionContextTarget = targetActionContext.Target;
            var targetActionContextAction = targetActionContext.Action;

            return new RouteValueDictionary(new {
                @class = targetActionContext.GetActionClass(),
                id = html.IdHelper().GetActionId(propertyName, actionContextAction, actionContextTarget, targetActionContextTarget, targetActionContextAction),
                name,
                type = "submit",
                value = html.GetButtonNameValues(targetActionContext, actionContext, null, propertyName)
            });
        }
        internal static MvcHtmlString ObjectActionAsDialog(this HtmlHelper html, ActionContext actionContext) {
            bool allowed = actionContext.Action.IsUsable(actionContext.Target).IsAllowed;

            if (allowed) {
                return html.WrapInForm(Action(actionContext.Action.Id),
                    html.Facade().GetObjectTypeShortName(actionContext.Target.Object),
                    html.ParameterList(actionContext).ToString(),
                    actionContext.GetActionClass(),
                    new RouteValueDictionary(new { id = Encode(html.Facade().OidTranslator.GetOidTranslation(actionContext.Target)) }));
            }
            return html.ObjectAction(actionContext);
        }
 private static ElementDescriptor RecentlyViewedAction(this HtmlHelper html, ITypeFacade spec, ActionContext actionContext, string propertyName) {
     return new ElementDescriptor {
         TagType = "button",
         Value = MvcUi.RecentlyViewed,
         Attributes = new RouteValueDictionary(new {
             title = MvcUi.RecentlyViewed,
             name = IdConstants.FindAction,
             type = "submit",
             @class = actionContext.GetActionClass(),
             value = ToNameValuePairs(new {
                 spec = spec.FullName,
                 contextObjectId = Encode(html.Facade().OidTranslator.GetOidTranslation(actionContext.Target)),
                 contextActionId = actionContext.Action == null ? "" : actionContext.Action.Id,
                 propertyName
             })
         })
     };
 }
Пример #7
0
 private static string GetVetoedAction(ActionContext actionContext, IConsent consent, out string value, out RouteValueDictionary attributes) {
     value = actionContext.Action.Name;
     attributes = new RouteValueDictionary(new {
         id = actionContext.GetActionId(),
         @class =  actionContext.GetActionClass(), 
         title = consent.Reason
     });
     return "div";
 }
Пример #8
0
        internal static MvcHtmlString ObjectActionAsDialog(this HtmlHelper html, ActionContext actionContext) {
            bool allowed = actionContext.Action.IsUsable(NakedObjectsContext.Session, actionContext.Target).IsAllowed;

            if (allowed) {
                return html.WrapInForm(Action(actionContext.Action.Id),
                                       FrameworkHelper.GetObjectTypeName(actionContext.Target.Object),
                                       html.ParameterList(actionContext).ToString(),
                                       actionContext.GetActionClass(),
                                       new RouteValueDictionary(new {id = FrameworkHelper.GetObjectId(actionContext.Target)}));
            }
            return html.ObjectAction(actionContext);
        }
Пример #9
0
 private static RouteValueDictionary GetActionAttributes(this HtmlHelper html,
                                                         string name,
                                                         ActionContext targetActionContext,
                                                         ActionContext actionContext,
                                                         string propertyName) {
     return new RouteValueDictionary(new {
         @class = (targetActionContext.Action is NakedObjectActionSet) ? IdHelper.SubMenuName : targetActionContext.GetActionClass(),
         id = IdHelper.GetActionId(targetActionContext, actionContext, propertyName),
         name,
         type = "submit",
         value = html.GetButtonNameValues(targetActionContext, actionContext, null, propertyName)
     });
 }
Пример #10
0
 private static ElementDescriptor RecentlyViewedAction(INakedObjectSpecification spec, ActionContext actionContext, string propertyName) {
     return new ElementDescriptor {
         TagType = "button",
         Value = MvcUi.RecentlyViewed,
         Attributes = new RouteValueDictionary(new {
             title = MvcUi.RecentlyViewed,
             name = IdHelper.FindAction,
             type = "submit",
             @class = actionContext.GetActionClass(),
             value = ToNameValuePairs(new {
                 spec = spec.FullName,
                 contextObjectId = FrameworkHelper.GetObjectId(actionContext.Target),
                 contextActionId = FrameworkHelper.GetActionId(actionContext.Action),
                 propertyName
             })
         })
     };
 }