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(); }
private static string GetReferenceParameter(this HtmlHelper html, ParameterContext context, string id, string tooltip, IList<ElementDescriptor> childElements, bool addToThis) { var tag = new TagBuilder("div"); tag.AddCssClass(IdConstants.ObjectName); if (context.IsHidden) { var suggestedItem = html.GetSuggestedItem(id, null); string valueId = suggestedItem == null ? String.Empty : Encode(html.Facade().OidTranslator.GetOidTranslation(suggestedItem)); tag.InnerHtml += html.CustomEncrypted(id, valueId); } else if (context.Parameter.IsChoicesEnabled == Choices.Single) { var htmlAttributes = new RouteValueDictionary(new { title = tooltip }); html.AddDropDownControl(tag, htmlAttributes, context, id); } else if (context.Parameter.IsChoicesEnabled == Choices.Multiple) { var htmlAttributes = new RouteValueDictionary(new { title = tooltip }); html.AddListBoxControl(tag, htmlAttributes, context, id); } else { var existingValue = html.GetParameterExistingValue(id, context); var suggestedItem = html.GetSuggestedItem(id, existingValue); string valueId = suggestedItem == null ? String.Empty : Encode(html.Facade().OidTranslator.GetOidTranslation(suggestedItem)); string url = html.GenerateUrl("ValidateParameter", "Ajax", new RouteValueDictionary(new { id = Encode(html.Facade().OidTranslator.GetOidTranslation(context.Target)), actionName = context.Action.Id, parameterName = context.Parameter.Id })); tag.MergeAttribute("data-validate", url); bool noFinder = context.EmbeddedInObject || !context.IsFindMenuEnabled(); tag.InnerHtml += html.ObjectIcon(suggestedItem) + html.GetParameterValue(context, suggestedItem, noFinder) + html.GetMandatoryIndicator(context) + html.ValidationMessage(context.Parameter.IsAutoCompleteEnabled ? context.GetParameterAutoCompleteId() : id) + html.CustomEncrypted(id, valueId); context.IsParameterEdit = false; } AddInsertedElements(childElements, addToThis, tag); return tag.ToString(); }
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 GetReferenceParameter(this HtmlHelper html, ParameterContext context, string id, string tooltip, IList<ElementDescriptor> childElements, bool addToThis) { var tag = new TagBuilder("div"); tag.AddCssClass(IdHelper.ObjectName); if (context.IsHidden) { INakedObject suggestedItem = html.GetSuggestedItem(id, null); string valueId = suggestedItem == null ? string.Empty : FrameworkHelper.GetObjectId(suggestedItem); tag.InnerHtml += html.CustomEncrypted(id, valueId); } else if (context.Parameter.IsChoicesEnabled) { var htmlAttributes = new RouteValueDictionary(new {title = tooltip}); html.AddDropDownControl(tag, htmlAttributes, context, id); } else if (context.Parameter.IsMultipleChoicesEnabled) { var htmlAttributes = new RouteValueDictionary(new {title = tooltip}); html.AddListBoxControl(tag, htmlAttributes, context, id); } else { INakedObject existingValue = html.GetParameterExistingValue(id, context); INakedObject suggestedItem = html.GetSuggestedItem(id, existingValue); string valueId = suggestedItem == null ? string.Empty : FrameworkHelper.GetObjectId(suggestedItem); string url = html.GenerateUrl("ValidateParameter", "Ajax", new RouteValueDictionary(new { id = FrameworkHelper.GetObjectId(context.Target), actionName = context.Action.Id, parameterName = context.Parameter.Id, })); tag.MergeAttribute("data-validate", url); tag.InnerHtml += html.ObjectIcon(suggestedItem) + html.GetFieldValue(context, suggestedItem) + (context.EmbeddedInObject ? string.Empty : html.FinderActions(context.Parameter.Specification, context, context.Parameter.Id)) + GetMandatoryIndicator(context) + html.ValidationMessage(context.Parameter.IsAutoCompleteEnabled ? context.GetParameterAutoCompleteId() : id) + html.CustomEncrypted(id, valueId); context.IsParameterEdit = false; } AddInsertedElements(childElements, addToThis, tag); return tag.ToString(); }