protected override void modify(ElementRequest request)
        {
            var rules = request.Get<ValidationGraph>().FieldRulesFor(request.Accessor);
            var modifier = request.Get<IFieldValidationModifier>();

            rules.Each(x => modifier.ModifyFor(x, request));
        }
        public HtmlTag Build(ElementRequest request)
        {
            if (_url.IsEmpty())
            {
                _url = request.Get<IUrlRegistry>().UrlFor(_lookupType);
            }

            request.Get<IAssetRequirements>().Require("fubu.autocomplete.js");

            var label = request.Get<IDisplayFormatter>().GetDisplayForValue(request.Accessor, request.RawValue);
            var hidden = new HiddenTag()
                .Id(request.ElementId)
                .Name(request.ElementId)
                .AddClass("lookup")
                .Attr("value", request.RawValue == null ? string.Empty : request.RawValue.ToString());

            var textboxId = "{0}Value".ToFormat(request.ElementId);
            var textbox = new TextboxTag(textboxId, label)
                .Id(textboxId)
                .Data("lookup-url", _url)
                .Data("value-for", request.ElementId)
                .AddClass("autocomplete");

            hidden.After(textbox);
            
            return hidden;
        }
Example #3
0
        public override HtmlTag Build(ElementRequest request)
        {
            var entities = request.Get<IRepository>().GetAll(request.Accessor.PropertyType).Cast<Entity>();
            var stringifier = request.Get<Stringifier>();

            return new SelectTag(tag =>
                                 entities.Each(entity => tag.Option(stringifier.GetString(entity), entity.Id)));
        }
Example #4
0
        public bool Matches(ElementRequest subject)
        {
            var overrides = subject.Get<FubuCore.Reflection.AccessorRules>();


            throw new NotImplementedException();
        }
        protected override void modify(ElementRequest request)
        {
            var graph = request.Get<RemoteRuleGraph>();
            var rules = graph.RulesFor(request.Accessor);
            var data = new RemoteValidationDef
            {
                rules = rules.Select(x => x.ToHash()).ToArray(),
                url = request.Get<IUrlRegistry>().RemoteRule()
            };

            if (!data.rules.Any())
            {
                return;
            }

            request.CurrentTag.Data("remote-rule", data);
        }
        public override HtmlTags.HtmlTag Build(ElementRequest request)
        {
            HtmlTag el = new HtmlTag("ul").AddClass("pizza-type");

            IRepository repository = request.Get<IRepository>();
            IEnumerable<PizzaType> pizzaTypes = repository.GetAll<PizzaType>().Cast<PizzaType>();
            var stringifier = request.Get<Stringifier>();

            foreach (PizzaType pt in pizzaTypes)
            {
                HtmlTag radio = new HtmlTag("input");
                radio.Attr("type", "radio").Attr("name", "PizzaType");
                radio.Attr("value", pt.Id);
                radio.Text(stringifier.GetString(pt));
                el.Append(new HtmlTag("li").Append(radio));
            }

            return el;
        }
        public override HtmlTag Build(ElementRequest request)
        {
            // Add the DatePickerActivator.js into the asset pipeline for this page
            request.Get<IAssetRequirements>().Require("DatePickerActivator.js");

            string text = null == request.RawValue || DateTime.MinValue.Equals(request.RawValue)
                              ? ""
                              : request.RawValue.As<DateTime>().ToShortDateString();

            return new HtmlTag("input").Text(text).Attr("type", "text").AddClass("datepicker");
        }
        private static ListElements GetListElementTitlesOrderedByRank(ElementRequest request)
        {
            var att = request.Accessor.GetAttribute<GbstListValueAttribute>();
            var listName = att.GetListName();

            var listCache = request.Get<IListCache>();
            var gbstList = listCache.GetGbstList(listName);

            var elementTitles = gbstList.ActiveElements.OrderBy(e => e.Rank).Select(element => element.Title);

            return new ListElements { DefaultElementTitle = gbstList.DefaultElement.Title, ElementTitles = elementTitles };
        }
 public HtmlTag Build(ElementRequest request)
 {
     return new HtmlTag("div").Text(request.Get<FakeService>().Name);
 }
 public static HtmlTag BuildTag(ElementRequest request, Type listType)
 {
     var list = request.Get<IServiceLocator>().GetInstance(listType) as IFieldList;
     return BuildTag(request, list);
 }
Example #11
0
 public void Modify(ElementRequest request)
 => request.CurrentTag.Text(request.Get <ModelExplorer>().Metadata.DisplayName);
Example #12
0
 public bool Matches(ElementRequest token)
 => token.Get <ModelExplorer>()?.Metadata.DisplayName != null;
Example #13
0
        public void ForRule <T>(ElementRequest request, Action <T> continuation) where T : IFieldValidationRule
        {
            var graph = request.Get <ValidationGraph>();

            graph.Query().ForRule(request.HolderType(), request.Accessor, continuation);
        }
Example #14
0
        public HtmlTag Build(ElementRequest request)
        {
            var environment = request.Get <IDictionary <string, object> >();

            return(new FormTag(environment.RouteTo(request.Model)));
        }
 protected virtual IEnumerable <T> Source(ElementRequest request)
 {
     return(request.Get <SchoolContext>().Set <T>());
 }
 protected virtual IEnumerable <T> Source(ElementRequest request)
 {
     return(request.Get <ApplicationDbContext>().Set <T>());
 }