private static string GetParameterValue(this HtmlHelper html, ParameterContext context, IObjectFacade valueNakedObject, bool noFinder) {
            string value = "";

            // Even if not autocomplete add autocomplete menu if no finder and then handle with recently viewed in ajax controller
            if (context.Parameter.IsAutoCompleteEnabled || (noFinder && !context.Parameter.Specification.IsCollection && !context.IsContributed())) {
                var htmlAttributes = new RouteValueDictionary(new { title = context.Parameter.Description });

                html.AddClientValidationAttributes(context, htmlAttributes);
                value += html.GetAutoCompleteTextBox(context, htmlAttributes, valueNakedObject);
            } else if (valueNakedObject != null) {
                string link = "{0}";

                if (context.Parameter.Specification.IsCollection) {
                    link = html.CollectionLink(link, IdConstants.ViewAction, valueNakedObject.Object);
                } else if (!context.Parameter.Specification.IsParseable && !context.Parameter.Specification.IsCollection) {
                    link = html.ObjectLink(link, IdConstants.ViewAction, valueNakedObject.Object);
                }

                string title = html.GetDisplayTitle(context.Parameter, valueNakedObject);
                value += String.Format(link, title);
            }

            if (!noFinder) {
                // append finder meu
                value += html.FinderActions(context.Parameter.Specification, context, context.Parameter.Id);
            }

            return value;
        }
        private static string GetTextParameter(this HtmlHelper html, ParameterContext context, string id, string tooltip) {
            var tag = new TagBuilder("div");
            tag.AddCssClass(IdConstants.ValueName);
            var htmlAttributes = new RouteValueDictionary(new { title = tooltip });

            html.AddClientValidationAttributes(context, htmlAttributes);

            if (context.IsHidden) {
                object obj = html.ViewData[id];
                tag.InnerHtml += html.Encrypted(id, obj.ToString());
            } else if (context.Parameter.Specification.IsBoolean) {
                if (context.Parameter.IsNullable) {
                    html.AddTriState(tag, htmlAttributes, id, null);
                } else {
                    html.AddCheckBox(tag, htmlAttributes, id, null);
                }
            } else if (context.Parameter.Specification.IsDateTime) {
                html.AddDateTimeControl(tag, htmlAttributes, context, id, html.GetFieldValue(context, id));
            } else if (context.Parameter.IsPassword) {
                html.AddPasswordControl(tag, htmlAttributes, context, id, html.GetFieldValue(context, id));
            } else if (context.Parameter.IsChoicesEnabled == Choices.Single) {
                html.AddDropDownControl(tag, htmlAttributes, context, id);
            } else if (context.Parameter.IsChoicesEnabled == Choices.Multiple) {
                html.AddListBoxControl(tag, htmlAttributes, context, id);
            } else if (context.Parameter.IsAutoCompleteEnabled) {
                html.AddAutoCompleteControl(tag, htmlAttributes, context, html.GetParameterDefaultValue(id, context));
            } else {
                html.AddTextControl(tag, htmlAttributes, context, id, null);
            }
            return tag.ToString();
        }
        private static string GetTextField(this HtmlHelper html, PropertyContext propertyContext, string id, string tooltip, bool readOnly) {
            var tag = new TagBuilder("div");
            tag.AddCssClass(IdConstants.ValueName);

            var htmlAttributes = new RouteValueDictionary(new { title = tooltip });

            html.AddClientValidationAttributes(propertyContext, htmlAttributes);

            if (!propertyContext.Property.IsVisible(propertyContext.Target)) {
                tag.InnerHtml += html.Encrypted(id, html.GetRawValue(propertyContext)).ToString();
                propertyContext.IsPropertyEdit = false;
            } else if (propertyContext.Property.Specification.IsBoolean && !readOnly) {
                var state = propertyContext.Property.GetValue(propertyContext.Target).GetDomainObject<bool?>();

                if (propertyContext.Property.IsNullable) {
                    html.AddTriState(tag, htmlAttributes, id, state);
                } else {
                    html.AddCheckBox(tag, htmlAttributes, id, state);
                }
            } else if (propertyContext.Property.Specification.IsDateTime && !readOnly) {
                html.AddDateTimeControl(tag, htmlAttributes, propertyContext, id, html.GetPropertyValue(propertyContext));
            } else if (propertyContext.Property.IsPassword && !readOnly) {
                html.AddPasswordControl(tag, htmlAttributes, propertyContext, id, html.GetPropertyValue(propertyContext));
            } else if (propertyContext.Property.IsChoicesEnabled != Choices.NotEnabled && !readOnly) {
                html.AddDropDownControl(tag, htmlAttributes, propertyContext, id);
            } else if (propertyContext.Property.IsAutoCompleteEnabled && !readOnly) {
                html.AddAutoCompleteControl(tag, htmlAttributes, propertyContext, propertyContext.Property.GetValue(propertyContext.Target));
            } else {
                string rawValue = html.GetRawValue(propertyContext);
                if (readOnly) {
                    tag.InnerHtml += html.GetFieldValue(propertyContext) + html.CustomEncrypted(id, rawValue);
                    propertyContext.IsPropertyEdit = false;
                } else {
                    html.AddTextControl(tag, htmlAttributes, propertyContext, id, html.ZeroValueIfTransientAndNotSet(propertyContext, rawValue));
                }
            }

            return tag.ToString();
        }
Exemple #4
0
        private static string GetFieldValue(this HtmlHelper html, PropertyContext context, INakedObject valueNakedObject) {
            string value = "";

            if (((IOneToOneAssociation) context.Property).IsAutoCompleteEnabled) {
                var htmlAttributes = new RouteValueDictionary(new {title = context.Property.Description});

                html.AddClientValidationAttributes(context, htmlAttributes);
                value += html.GetAutoCompleteTextBox(context, htmlAttributes, valueNakedObject);
            }
            else if (valueNakedObject != null) {
                string link = "{0}";

                if (!context.Property.Specification.IsParseable && context.Property.IsObject) {
                    link = html.ObjectLink(link, IdHelper.ViewAction, valueNakedObject.Object);
                }
                value += string.Format(link, GetDisplayTitle(context.Property, valueNakedObject));
            }

            return value;
        }