private static void AddAutoCompleteControl(this HtmlHelper html, TagBuilder tag, RouteValueDictionary htmlAttributes, ParameterContext context, IObjectFacade valueNakedObject) {
     tag.InnerHtml += html.GetAutoCompleteTextBox(context, htmlAttributes, valueNakedObject) + html.GetMandatoryIndicator(context) + html.ValidationMessage(context.GetParameterAutoCompleteId());
 }
 private static string GetAutoCompleteTextBox(this HtmlHelper html, ParameterContext context, RouteValueDictionary htmlAttributes, IObjectFacade valueNakedObject) {
     string completionAjaxUrl = html.GenerateUrl("GetActionCompletions", "Ajax", new RouteValueDictionary(new { id = Encode(html.Facade().OidTranslator.GetOidTranslation(context.Target)), actionName = context.Action.Id, parameterIndex = context.Parameter.Number }));
     RouteValueDictionary attrs = CreateAutoCompleteAttributes(context.Parameter, completionAjaxUrl);
     attrs.ForEach(kvp => htmlAttributes.Add(kvp.Key, kvp.Value));
     string title = valueNakedObject == null ? "" : html.GetDisplayTitle(context.Parameter, valueNakedObject);
     return html.TextBox(context.GetParameterAutoCompleteId(), title, htmlAttributes).ToHtmlString();
 }
        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();
        }
Exemplo n.º 4
0
        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();
        }