public DefaultAspNetMvcHtmlConventions() { Editors.IfPropertyIs <bool>().BuildBy(req => { var check = new CheckboxTag(req.Value <bool>()).Attr("value", req.StringValue()); var hidden = new HiddenTag().Attr("name", req.ElementId).Attr("value", false); return(check.Append(hidden)); }); Editors.IfPropertyIs <IEnumerable <SelectListItem> >().BuildBy(req => { var list = req.Value <IEnumerable <SelectListItem> >(); var drop = new SelectTag(); foreach (var item in list) { drop.Add("option").Attr("value", item.Value).Attr("selected", item.Selected).Text(item.Text); } return(drop); }); Editors.Always.ModifyWith(AddElementName); //Editors.Always.BuildBy(TagActionExpression.BuildTextbox); //Displays.Always.BuildBy(req => new HtmlTag("span").Text(req.StringValue())); //Labels.Always.BuildBy(req => new HtmlTag("span").Text(req.Accessor.Name)); }
public DefaultAspNetMvcHtmlConventions() { Editors.Always.AddClass("form-control"); Editors.IfPropertyIs <DateTimeOffset>().ModifyWith(m => m.CurrentTag.Attr("type", "datetime-local").Value(m.Value <DateTimeOffset?>()?.ToLocalTime().DateTime.ToString("s"))); Editors.IfPropertyIs <DateTime?>().ModifyWith(m => m.CurrentTag .AddPattern("9{1,2}/9{1,2}/9999") .AddPlaceholder("MM/DD/YYYY") .AddClass("datepicker") .Value(m.Value <DateTime?>() != null ? m.Value <DateTime>().ToShortDateString() : string.Empty)); Editors.If(er => er.Accessor.Name.EndsWith("id", StringComparison.OrdinalIgnoreCase)).BuildBy(a => new HiddenTag().Value(a.StringValue())); Editors.IfPropertyIs <byte[]>().BuildBy(a => new HiddenTag().Value(Convert.ToBase64String(a.Value <byte[]>()))); Editors.BuilderPolicy <UserPhoneNumberSelectElementBuilder>(); Editors.BuilderPolicy <TeamSelectElementBuilder>(); Labels.Always.AddClass("control-label"); Labels.Always.AddClass("col-md-2"); Labels.ModifyForAttribute <DisplayAttribute>((t, a) => t.Text(a.Name)); DisplayLabels.Always.BuildBy <DefaultDisplayLabelBuilder>(); DisplayLabels.ModifyForAttribute <DisplayAttribute>((t, a) => t.Text(a.Name)); Displays.IfPropertyIs <DateTimeOffset>().BuildBy <DateTimeBuilder>(); Displays.IfPropertyIs <DateTimeOffset?>().BuildBy <DateTimeBuilder>(); Displays.IfPropertyIs <DateTime>().BuildBy <DateTimeBuilder>(); Displays.IfPropertyIs <DateTime?>().BuildBy <DateTimeBuilder>(); Displays.IfPropertyIs <decimal>().ModifyWith(m => m.CurrentTag.Text(m.Value <decimal>().ToString("C"))); Displays.IfPropertyIs <bool>().BuildBy <BoolDisplayBuilder>(); this.Defaults(); }
public KnowYourTurfHtmlConventions() { numbers(); Editors.Builder <SelectFromEnumerationBuilder>(); Editors.Builder <SelectFromIEnumerableBuilder>(); Editors.Builder <GroupSelectedBuilder>(); Editors.Builder <RadioButtonListBuilder>(); Editors.Builder <TextAreaBuilder>(); Editors.Builder <DatePickerBuilder>(); Editors.Builder <TimePickerBuilder>(); Editors.IfPropertyIs <bool>().BuildBy(TagActionExpression.BuildCheckbox); Editors.If(x => x.Accessor.Name.ToLowerInvariant().Contains("password")).BuildBy(r => new PasswordTag().Attr("value", r.RawValue)); Editors.Always.BuildBy(TagActionExpression.BuildTextbox); Editors.Always.Modify(AddElementName); Displays.Builder <ImageBuilder>(); Displays.Builder <EmailDisplayBuilder>(); Displays.Builder <ListDisplayBuilder>(); Displays.Builder <DateTimeDisplayBuilder>(); Displays.Builder <ImageFileDisplayBuilder>(); Displays.If(x => x.Accessor.PropertyType == typeof(DateTime) || x.Accessor.PropertyType == typeof(DateTime?)) .BuildBy(req => req.RawValue != null ? new HtmlTag("span").Text(DateTime.Parse(req.RawValue.ToString()).ToLongDateString()) : new HtmlTag("span")); Displays.Always.BuildBy(req => new HtmlTag("span").Text(req.StringValue())); Labels.Always.BuildBy(req => new HtmlTag("label").Attr("for", req.Accessor.Name).Text(req.Accessor.FieldName.ToSeperateWordsFromPascalCase())); validationAttributes(); }
private void numbers() { Editors.IfPropertyIs <Int32>().Modify(x => { if (x.TagName() == new TextboxTag().TagName()) { x.Attr("max", Int32.MaxValue); } }); Editors.IfPropertyIs <Int16>().Modify(x => { if (x.TagName() == new TextboxTag().TagName()) { x.Attr("max", Int16.MaxValue); } }); Editors.IfPropertyIs <Int64>().Modify(x => { if (x.TagName() == new TextboxTag().TagName()) { x.Attr("max", Int64.MaxValue); } }); Editors.IfPropertyTypeIs(IsIntegerBased).Modify(x => { if (x.TagName() == new TextboxTag().TagName()) { x.AddClass("integer"); } }); Editors.IfPropertyTypeIs(IsFloatingPoint).Modify(x => { if (x.TagName() == new TextboxTag().TagName()) { x.AddClass("number"); } }); Editors.IfPropertyTypeIs(IsIntegerBased).Modify(x => { if (x.TagName() == new TextboxTag().TagName()) { x.Attr("mask", "wholeNumber"); } }); }
public TagConventions() { Editors.Always.AddClass("form-control"); Editors.IfPropertyIs <DateTime?>().ModifyWith(m => m.CurrentTag .AddPattern("9{1,2}/9{1,2}/9999") .AddPlaceholder("MM/DD/YYYY") .AddClass("datepicker") .Value(m.Value <DateTime?>() != null ? m.Value <DateTime>().ToShortDateString() : string.Empty)); Editors.If(er => er.Accessor.Name.EndsWith("id", StringComparison.OrdinalIgnoreCase)).BuildBy(a => new HiddenTag().Value(a.StringValue())); Editors.IfPropertyIs <byte[]>().BuildBy(a => new HiddenTag().Value(Convert.ToBase64String(a.Value <byte[]>()))); //Editors.BuilderPolicy<EnumSelectElementBuilder>(); Labels.Always.AddClass("control-label"); Labels.Always.AddClass("col-md-2"); Labels.ModifyForAttribute <DisplayAttribute>((t, a) => t.Text(a.Name)); //Editors.BuilderPolicy<InstructorSelectElementBuilder>(); //Editors.BuilderPolicy<DepartmentSelectElementBuilder>(); DisplayLabels.Always.BuildBy <DefaultDisplayLabelBuilder>(); DisplayLabels.ModifyForAttribute <DisplayAttribute>((t, a) => t.Text(a.Name)); Displays.IfPropertyIs <DateTime>().ModifyWith(m => m.CurrentTag.Text(m.Value <DateTime>().ToShortDateString())); Displays.IfPropertyIs <DateTime?>().ModifyWith(m => m.CurrentTag.Text(m.Value <DateTime?>() == null ? null : m.Value <DateTime?>().Value.ToShortDateString())); Displays.IfPropertyIs <decimal>().ModifyWith(m => m.CurrentTag.Text(m.Value <decimal>().ToString("C"))); this.Defaults(); }
public AppHtmlConventions() { Editors.IfPropertyIs <bool>() .BuildBy(e => new CheckboxTag(e.Value <bool>())); Editors.If(x => x.Accessor.Name.Contains("Password")) .BuildBy(e => new TextboxTag(e.ElementId, e.StringValue()).Attr("type", "password")); }
public DefaultHtmlConventions() { Editors.IfPropertyIs <bool>().BuildBy(TagActionExpression.BuildCheckbox); Editors.Always.BuildBy(TagActionExpression.BuildTextbox); Editors.Always.Modify(AddElementName); Displays.Always.BuildBy((req => new HtmlTag("span").Text(req.StringValue()))); Labels.Always.BuildBy((req => new HtmlTag("span").Text(req.Accessor.Name))); }
public SampleHtmlConventions() { BeforeEachOfPartial.Builder <BeforeEachOfPartialBuilder>(); BeforeEachOfPartial.Modifier <OddEvenLiModifier>(); //BeforeEachOfPartial.If(x => x.Is<ProjectListModel>()).Modify(); AfterEachOfPartial.Builder <AfterEachOfPartialBuilder>(); Editors.IfPropertyIs <int>().Modify(tag => tag.AddClass("number")); }
private void numbers() { Editors.IfPropertyIs <Int32>().Attr("max", Int32.MaxValue); Editors.IfPropertyIs <Int16>().Attr("max", Int16.MaxValue); //Editoin.IfPropertyIs<Int64>().Attr("max", Int64.MaxValue); Editors.IfPropertyTypeIs(IsIntegerBased).AddClass("integer"); Editors.IfPropertyTypeIs(IsFloatingPoint).AddClass("number"); Editors.IfPropertyTypeIs(IsIntegerBased).Attr("mask", "wholeNumber"); }
public AspNetMvcHtmlConventions(Action <AspNetMvcHtmlConventions> configurator = null) { if (configurator != null) { configurator(this); } Validators.Always.BuildBy <SpanValidatorBuilder>(); Editors.Always.ModifyWith(er => er.CurrentTag.Id(er.ElementId)); // Labels Labels.ModifyForAttribute <DisplayAttribute>((t, a) => t.Text(a.Name)); Labels.IfPropertyIs <bool>() .ModifyWith(er => er.CurrentTag.Text(er.OriginalTag.Text() + "?")); // Checkboxes Editors.IfPropertyIs <bool>().Attr("type", "checkbox"); // Color //Editors.IfPropertyIs<Color>().Attr("type", "color"); // Date TODO: bring in Noda time //Editors.IfPropertyIs<LocalDate>().Attr("type", "date"); //Editors.IfPropertyIs<LocalTime>().Attr("type", "time"); //Editors.IfPropertyIs<LocalDateTime>().Attr("type", "datetime-local"); //Editors.IfPropertyIs<OffsetDateTime>().Attr("type", "datetime"); // Email Editors.If(er => er.Accessor.Name.Contains("Email")) .Attr("type", "email"); // Hidden Editors.IfPropertyIs <Guid>().Attr("type", "hidden"); Editors.IfPropertyIs <Guid?>().Attr("type", "hidden"); Editors.IfPropertyHasAttribute <HiddenInputAttribute>().Attr("type", "hidden"); Editors.IfPropertyIs <decimal?>().ModifyWith(m => m.CurrentTag.Data("pattern", "9{1,9}.99").Data("placeholder", "0.00")); // Password Conventions Editors.If(er => er.Accessor.Name.Contains("Password")).Attr("type", "password"); Editors.If(er => { var attr = er.Accessor.GetAttribute <DataTypeAttribute>(); return(attr != null && attr.DataType == DataType.Password); }).Attr("type", "password"); Editors.Modifier <EnumDropDownModifier>(); Editors.Modifier <HtmlTagAttributeModifier>(); Editors.Modifier <TextAreaPropertyNameModifier>(); }
public DefaultHtmlConventions() { Editors.IfPropertyIs <bool>().BuildBy(req => new CheckboxTag(req.Value <bool>())); // Relax, this is just the default fall through action Editors.Always.BuildBy(TagActionExpression.BuildTextbox); Editors.Always.Modify(AddElementName); Displays.Always.BuildBy(req => new HtmlTag("span").Text(req.StringValue())); Labels.Always.BuildBy(req => new HtmlTag("span").Text(req.Accessor.Name)); }
public CommonConventions() { Editors.Always.Attr("class", "test"); Editors.IfPropertyIs <DateTime>().Modify(tag => tag.AddClass("picker")); Editors.IfPropertyIs <bool>().BuildBy(req => new CheckboxTag(req.Value <bool>())); // Relax, this is just the default fall through action Editors.Always.BuildBy(TagActionExpression.BuildTextbox); Editors.Always.Modify(AddElementName); Displays.Always.BuildBy(req => new HtmlTag("span").Text(req.StringValue())); Labels.Always.BuildBy(req => new HtmlTag("span").Text(req.Accessor.Name)); }
public HtmlConfig() { this.AddTwitterBootstrap(); this.AddMiruBootstrapLayout(); Editors.IfPropertyNameIs("Description").ModifyTag(tag => tag.MultilineMode()); Editors.IfPropertyIs <IFormFile>().Attr("type", "file"); // To avoid someone adding a real credit card Editors .IfPropertyNameIs(nameof(DonationNew.Command.CreditCard)) .ModifyTag(tag => tag.MaxLength(10)); }
public TestHtmlConventions() { Editors.IfPropertyIs <string>().UseTextbox(); Editors.IfPropertyIs <bool>().BuildBy(req => new CheckboxTag(req.Value <bool>())); Editors.AddClassForAttribute <FakeRequiredAttribute>("required"); Editors.ModifyForAttribute <FakeMaximumStringLength>((tag, att) => tag.Attr("maxlength", att.MaxLength)); Labels.Always.BuildBy(req => new HtmlTag("span").Text(req.Accessor.Name)); Labels.Always.AddClass("label"); Displays.Always.BuildBy(req => new HtmlTag("span").Text(req.StringValue())); Profile("edit", x => { x.Editors.IfPropertyTypeIs(o => o.CanBeCastTo <TagProfile>()).AddClass("class1"); }); }
public DefaultHtmlConventions() { Editors.IfPropertyIs <bool>().BuildBy(TagActionExpression.BuildCheckbox); // Relax, this is just the default fall through action Editors.Always.BuildBy(TagActionExpression.BuildTextbox); Editors.Always.Modify(AddElementName); Displays.Always.BuildBy(req => new HtmlTag("span").Text(req.StringValue())); Labels.Always.BuildBy(req => new HtmlTag("label").Text(BreakUpCamelCase(req.Accessor.FieldName))); BeforePartial.Always.BuildBy(req => new NoTag()); AfterPartial.Always.BuildBy(req => new NoTag()); BeforeEachOfPartial.Always.BuildBy((req, index, count) => new NoTag()); AfterEachOfPartial.Always.BuildBy((req, index, count) => new NoTag()); }
private void ConfigEditors() { Editors.Always.AddClass("form-control"); // TODO: Scan all modifiers? Editors.Modifier <EnumDropDownModifier>(); //Editors.Modifier<LookupDropDownModifier>(); Editors.BuilderPolicy <CategorySelectElementBuilder>(); Editors.Modifier <CurrencyDropDownModifier>(); Editors.Modifier <LanguageDropDownModifier>(); Editors.Modifier <CultureDropDownModifier>(); Editors.Modifier <TimeZoneDropDownModifier>(); Editors.IfPropertyIs <DateTime?>().ModifyWith(m => m .CurrentTag .AddPattern("9{1,2}/9{1,2}/9999") .Data("provide", "datepicker") .AddClass("datepicker") .Data("date-format", "mm/dd/yyyy") .Value(m.Value <DateTime?>() != null ? m.Value <DateTime>().ToShortDateString() : string.Empty)); Editors .If(er => er.Accessor.Name.EndsWith("id", StringComparison.OrdinalIgnoreCase)) .BuildBy(a => new HiddenTag().Value(a.StringValue())); Editors .IfPropertyIs <byte[]>() .BuildBy(a => new HiddenTag().Value(Convert.ToBase64String(a.Value <byte[]>()))); Editors .If(er => er.Accessor.Name.EndsWith("password", StringComparison.OrdinalIgnoreCase)) .ModifyWith(x => x.CurrentTag.Attr("type", "password")); Editors .IfPropertyIs <bool>() .ModifyWith(m => { m.CurrentTag.Attr("class", "").Attr("type", "checkbox").Attr("value", "true"); m.WrapWith(new HtmlTag("label")); }); Editors.IfPropertyIs <decimal>() .ModifyWith(m => m.CurrentTag.Value(m.Value <decimal>() == 0 ? string.Empty : m.Value <decimal>().ToString("F2"))); }
public HtmlConfig() { this.AddTwitterBootstrap(); this.AddMiruBootstrapLayout(); this.AddRailsUjs(); Displays .If(m => m.Accessor.PropertyType == typeof(decimal) && m.Accessor.Name.ToLower().Contains("percent")) .ModifyWith(m => m.CurrentTag.Text(m.Value <decimal>().ToString("#") + "%")); Editors.IfPropertyIs <bool>().ModifyWith(m => { var value = m.Value <bool>(); if (value) { m.CurrentTag.Attr("checked", "checked"); } }); }
public TagConventions() { Editors.Always.AddClass("form-control"); Editors.IfPropertyIs <DateTime?>().ModifyWith(m => m.CurrentTag .AddPattern("9{1,2}/9{1,2}/9999") .AddPlaceholder("MM/DD/YYYY") .AddClass("datepicker") .Value(m.Value <DateTime?>() != null ? m.Value <DateTime>().ToString("d") : string.Empty)); Editors.IfPropertyIs <byte[]>().BuildBy(a => new HiddenTag().Value(Convert.ToBase64String(a.Value <byte[]>()))); Labels.Always.AddClass("control-label"); Labels.Always.AddClass("col-md-2"); Labels.ModifyForAttribute <DisplayAttribute>((t, a) => t.Text(a.Name)); DisplayLabels.ModifyForAttribute <DisplayAttribute>((t, a) => t.Text(a.Name)); Displays.IfPropertyIs <DateTime>().ModifyWith(m => m.CurrentTag.Text(m.Value <DateTime>().ToString("d"))); Displays.IfPropertyIs <DateTime?>().ModifyWith(m => m.CurrentTag.Text(m.Value <DateTime?>() == null ? null : m.Value <DateTime?>().Value.ToString("d"))); Displays.IfPropertyIs <decimal>().ModifyWith(m => m.CurrentTag.Text(m.Value <decimal>().ToString("C"))); this.Defaults(); }
public OdsAdminHtmlTagConventions() { Editors.If(e => e.Accessor.PropertyType != typeof(bool) && e.Accessor.PropertyType != typeof(bool?)) .AddClass("form-control"); Editors.IfPropertyIs <bool>().BuildBy(BuildCheckBox); Editors.If(e => e.Accessor.PropertyType == typeof(DateTime) || e.Accessor.PropertyType == typeof(DateTime?)) .ModifyWith(m => m.CurrentTag .AddPattern("9{1,2}/9{1,2}/9999") .AddPlaceholder("MM/DD/YYYY") .AddClass("datepicker") .Value(m.Value <DateTime?>() != null ? m.Value <DateTime>().ToShortDateString() : string.Empty)); Editors.If(e => e.Accessor.GetAttribute <DataTypeAttribute>()?.DataType == DataType.Password) .ModifyWith(m => m.CurrentTag.PasswordMode()); Editors.If(e => e.Accessor.PropertyType == typeof(decimal) || e.Accessor.PropertyType == typeof(decimal?)) .ModifyWith(m => m.CurrentTag.Value(m.Value <decimal?>() != null ? m.Value <decimal>().ToString("F") : "")); Labels.Always.BuildBy <DefaultDisplayLabelBuilder>(); Labels.Always.AddClass("control-label"); Labels.ModifyForAttribute <DisplayAttribute>((t, a) => t.Text($"{a.Name}:")); }
public SampleHtmlConventions() { Editors.IfPropertyIs <int>().Modify(tag => tag.AddClass("number")); }
public MoreConvs() { Editors.IfPropertyIs <DateTime>().AddClass("datepicker"); }