diff --git a/FluentBootstrap.Mvc.T4MVC/T4MVCExtensions.cs b/FluentBootstrap.Mvc.T4MVC/T4MVCExtensions.cs index 339b9e2..d7b4e84 100644 --- a/FluentBootstrap.Mvc.T4MVC/T4MVCExtensions.cs +++ b/FluentBootstrap.Mvc.T4MVC/T4MVCExtensions.cs @@ -30,11 +30,11 @@ public static class T4MVCExtensions where TComponent : Component, ICanCreate { return new ComponentBuilder, Link>(helper.GetConfig(), helper.Link(text, (string)null).GetComponent()) - .SetAction(result) + .SetLinkAction(result) .SetText(text); } - public static ComponentBuilder, TTag> SetAction( + public static ComponentBuilder, TTag> SetLinkAction( this ComponentBuilder, TTag> builder, ActionResult result) where TTag : Tag, IHasLinkExtensions { @@ -51,7 +51,7 @@ public static class T4MVCExtensions where TComponent : Component, ICanCreate { return new ComponentBuilder, Crumb>(helper.GetConfig(), helper.Crumb(text, (string)null).GetComponent()) - .SetAction(result) + .SetLinkAction(result) .SetText(text); } @@ -62,7 +62,7 @@ public static class T4MVCExtensions where TComponent : Component, ICanCreate { return new ComponentBuilder, LinkButton>(helper.GetConfig(), helper.LinkButton(text, (string)null).GetComponent()) - .SetAction(result); + .SetLinkAction(result); } // Dropdown @@ -72,7 +72,7 @@ public static class T4MVCExtensions where TComponent : Component, ICanCreate { return new ComponentBuilder, DropdownLink>(helper.GetConfig(), helper.DropdownLink(text, (string)null).GetComponent()) - .SetAction(result) + .SetLinkAction(result) .SetText(text); } @@ -83,7 +83,7 @@ public static class T4MVCExtensions where TComponent : Component, ICanCreate { return new ComponentBuilder, ListGroupItem>(helper.GetConfig(), helper.ListGroupItem(text, (string)null).GetComponent()) - .SetAction(result); + .SetLinkAction(result); } // MediaObject @@ -93,7 +93,7 @@ public static class T4MVCExtensions where TComponent : Component, ICanCreate { return new ComponentBuilder, MediaObject>(helper.GetConfig(), helper.MediaObject(src, (string)null, alt).GetComponent()) - .SetAction(result); + .SetLinkAction(result); } // Navbar @@ -111,7 +111,7 @@ public static class T4MVCExtensions where TComponent : Component, ICanCreate { return new ComponentBuilder, Brand>(helper.GetConfig(), helper.Brand(text, (string)null).GetComponent()) - .SetAction(result) + .SetLinkAction(result) .SetText(text); } @@ -120,7 +120,7 @@ public static class T4MVCExtensions where TComponent : Component, ICanCreate { return new ComponentBuilder, NavbarLink>(helper.GetConfig(), helper.NavbarLink(text, (string)null).GetComponent()) - .SetAction(result) + .SetLinkAction(result) .SetText(text); } @@ -131,7 +131,7 @@ public static class T4MVCExtensions where TComponent : Component, ICanCreate { return new ComponentBuilder, Pill>(helper.GetConfig(), helper.Pill(text, (string)null).GetComponent()) - .SetAction(result); + .SetLinkAction(result); } public static ComponentBuilder, Tab> Tab( @@ -139,7 +139,7 @@ public static class T4MVCExtensions where TComponent : Component, ICanCreate { return new ComponentBuilder, Tab>(helper.GetConfig(), helper.Tab(text, (string)null).GetComponent()) - .SetAction(result); + .SetLinkAction(result); } public static ComponentBuilder, Pager> AddPrevious( @@ -170,7 +170,7 @@ public static class T4MVCExtensions where TComponent : Component, ICanCreate { return new ComponentBuilder, Page>(helper.GetConfig(), helper.Page(text, (string)null).GetComponent()) - .SetAction(result); + .SetLinkAction(result); } // Pagination @@ -201,7 +201,7 @@ public static class T4MVCExtensions where TComponent : Component, ICanCreate { return new ComponentBuilder, PageNum>(helper.GetConfig(), helper.PageNum(text, (string)null).GetComponent()) - .SetAction(result); + .SetLinkAction(result); } // Form @@ -215,8 +215,9 @@ public static class T4MVCExtensions .SetFormMethod(method); } - public static ComponentBuilder, Form> SetAction( - this ComponentBuilder, Form> builder, ActionResult result) + public static ComponentBuilder, TForm> SetAction( + this ComponentBuilder, TForm> builder, ActionResult result) + where TForm : Form { IT4MVCActionResult callInfo = result.GetT4MVCResult(); builder.SetAction(UrlHelper.GenerateUrl(null, callInfo.Action, callInfo.Controller, callInfo.Protocol, null, null, result.GetRouteValueDictionary(), diff --git a/FluentBootstrap.Mvc/Forms/MvcFormExtensions.cs b/FluentBootstrap.Mvc/Forms/MvcFormExtensions.cs index 24263a2..1aadd57 100644 --- a/FluentBootstrap.Mvc/Forms/MvcFormExtensions.cs +++ b/FluentBootstrap.Mvc/Forms/MvcFormExtensions.cs @@ -41,15 +41,17 @@ public static class MvcFormExtensions .SetFormMethod(method); } - public static ComponentBuilder, Form> SetFormMethod( - this ComponentBuilder, Form> builder, FormMethod method) + public static ComponentBuilder, TForm> SetFormMethod( + this ComponentBuilder, TForm> builder, FormMethod method) + where TForm : Form { builder.GetComponent().MergeAttribute("method", HtmlHelper.GetFormMethodString(method)); return builder; } - public static ComponentBuilder, Form> SetAction( - this ComponentBuilder, Form> builder, string actionName, string controllerName, object routeValues = null) + public static ComponentBuilder, TForm> SetAction( + this ComponentBuilder, TForm> builder, string actionName, string controllerName, object routeValues = null) + where TForm : Form { RouteValueDictionary routeValueDictionary = routeValues == null ? new RouteValueDictionary() : routeValues as RouteValueDictionary; if (routeValueDictionary == null) @@ -61,8 +63,9 @@ public static class MvcFormExtensions return builder; } - public static ComponentBuilder, Form> SetRoute( - this ComponentBuilder, Form> builder, string routeName, object routeValues = null) + public static ComponentBuilder, TForm> SetRoute( + this ComponentBuilder, TForm> builder, string routeName, object routeValues = null) + where TForm : Form { RouteValueDictionary routeValueDictionary = routeValues == null ? new RouteValueDictionary() : routeValues as RouteValueDictionary; if (routeValueDictionary == null) @@ -73,8 +76,9 @@ public static class MvcFormExtensions return builder; } - public static ComponentBuilder, Form> HideValidationSummary( - this ComponentBuilder, Form> builder, bool hideValidationSummary = true) + public static ComponentBuilder, TForm> HideValidationSummary( + this ComponentBuilder, TForm> builder, bool hideValidationSummary = true) + where TForm : Form { builder.GetComponent().GetOverride>().HideValidationSummary = hideValidationSummary; return builder; diff --git a/FluentBootstrap.Mvc/MvcExtensions.cs b/FluentBootstrap.Mvc/MvcExtensions.cs index b526d06..ac10017 100644 --- a/FluentBootstrap.Mvc/MvcExtensions.cs +++ b/FluentBootstrap.Mvc/MvcExtensions.cs @@ -41,11 +41,11 @@ public static class MvcExtensions where TComponent : Component, ICanCreate { return new ComponentBuilder, Link>(helper.GetConfig(), helper.Link(text, null).GetComponent()) - .SetAction(actionName, controllerName, routeValues) + .SetLinkAction(actionName, controllerName, routeValues) .SetText(text); } - public static ComponentBuilder, TTag> SetAction( + public static ComponentBuilder, TTag> SetLinkAction( this ComponentBuilder, TTag> builder, string actionName, string controllerName, object routeValues = null) where TTag : Tag, IHasLinkExtensions { @@ -80,7 +80,7 @@ public static class MvcExtensions where TComponent : Component, ICanCreate { return new ComponentBuilder, Crumb>(helper.GetConfig(), helper.Crumb(text, null).GetComponent()) - .SetAction(actionName, controllerName, routeValues) + .SetLinkAction(actionName, controllerName, routeValues) .SetText(text); } @@ -91,7 +91,7 @@ public static class MvcExtensions where TComponent : Component, ICanCreate { return new ComponentBuilder, LinkButton>(helper.GetConfig(), helper.LinkButton(text, null).GetComponent()) - .SetAction(actionName, controllerName, routeValues); + .SetLinkAction(actionName, controllerName, routeValues); } // Dropdown @@ -101,7 +101,7 @@ public static class MvcExtensions where TComponent : Component, ICanCreate { return new ComponentBuilder, DropdownLink>(helper.GetConfig(), helper.DropdownLink(text, null).GetComponent()) - .SetAction(actionName, controllerName, routeValues) + .SetLinkAction(actionName, controllerName, routeValues) .SetText(text); } @@ -112,7 +112,7 @@ public static class MvcExtensions where TComponent : Component, ICanCreate { return new ComponentBuilder, ListGroupItem>(helper.GetConfig(), helper.ListGroupItem(text, null).GetComponent()) - .SetAction(actionName, controllerName, routeValues); + .SetLinkAction(actionName, controllerName, routeValues); } // MediaObject @@ -122,7 +122,7 @@ public static class MvcExtensions where TComponent : Component, ICanCreate { return new ComponentBuilder, MediaObject>(helper.GetConfig(), helper.MediaObject(src, null, alt).GetComponent()) - .SetAction(actionName, controllerName, routeValues); + .SetLinkAction(actionName, controllerName, routeValues); } // Navbar @@ -140,7 +140,7 @@ public static class MvcExtensions where TComponent : Component, ICanCreate { return new ComponentBuilder, Brand>(helper.GetConfig(), helper.Brand(text, null).GetComponent()) - .SetAction(actionName, controllerName, routeValues) + .SetLinkAction(actionName, controllerName, routeValues) .SetText(text); } @@ -149,7 +149,7 @@ public static class MvcExtensions where TComponent : Component, ICanCreate { return new ComponentBuilder, NavbarLink>(helper.GetConfig(), helper.NavbarLink(text, null).GetComponent()) - .SetAction(actionName, controllerName, routeValues) + .SetLinkAction(actionName, controllerName, routeValues) .SetText(text); } @@ -160,7 +160,7 @@ public static class MvcExtensions where TComponent : Component, ICanCreate { return new ComponentBuilder, Pill>(helper.GetConfig(), helper.Pill(text, null).GetComponent()) - .SetAction(actionName, controllerName, routeValues); + .SetLinkAction(actionName, controllerName, routeValues); } public static ComponentBuilder, Tab> Tab( @@ -168,7 +168,7 @@ public static class MvcExtensions where TComponent : Component, ICanCreate { return new ComponentBuilder, Tab>(helper.GetConfig(), helper.Tab(text, null).GetComponent()) - .SetAction(actionName, controllerName, routeValues); + .SetLinkAction(actionName, controllerName, routeValues); } public static ComponentBuilder, Pager> AddPrevious( @@ -199,7 +199,7 @@ public static class MvcExtensions where TComponent : Component, ICanCreate { return new ComponentBuilder, Page>(helper.GetConfig(), helper.Page(text, null).GetComponent()) - .SetAction(actionName, controllerName, routeValues); + .SetLinkAction(actionName, controllerName, routeValues); } // Pagination @@ -230,7 +230,7 @@ public static class MvcExtensions where TComponent : Component, ICanCreate { return new ComponentBuilder, PageNum>(helper.GetConfig(), helper.PageNum(text, null).GetComponent()) - .SetAction(actionName, controllerName, routeValues); + .SetLinkAction(actionName, controllerName, routeValues); } // Typography diff --git a/FluentBootstrap.Tests.Web/Views/Tests/Typography.cshtml b/FluentBootstrap.Tests.Web/Views/Tests/Typography.cshtml index 292de72..aa433d0 100644 --- a/FluentBootstrap.Tests.Web/Views/Tests/Typography.cshtml +++ b/FluentBootstrap.Tests.Web/Views/Tests/Typography.cshtml @@ -127,7 +127,7 @@ @Html.Bootstrap().Heading1("Horizontal Description List") using (Html.Bootstrap().Div().SetId("test-horizontal-description-list").Begin()) { - using (var list = Html.Bootstrap().DescriptionList().SetHorizontal().Begin()) + using (var list = Html.Bootstrap().DescriptionList().SetHorizontalDescription().Begin()) { @list.DescriptionTerm("Term") @list.Description("Desc") diff --git a/FluentBootstrap/Forms/FormExtensions.cs b/FluentBootstrap/Forms/FormExtensions.cs index 6ab4085..0163b1c 100644 --- a/FluentBootstrap/Forms/FormExtensions.cs +++ b/FluentBootstrap/Forms/FormExtensions.cs @@ -33,15 +33,17 @@ public static class FormExtensions .SetMethod(method); } - public static ComponentBuilder SetInline(this ComponentBuilder builder, bool inline = true) + public static ComponentBuilder SetInline(this ComponentBuilder builder, bool inline = true) where TConfig : BootstrapConfig + where TForm : Form { builder.Component.ToggleCss(Css.FormInline, inline, Css.FormHorizontal); return builder; } - public static ComponentBuilder SetHorizontal(this ComponentBuilder builder, int? defaultlabelWidth = null, bool horizontal = true) + public static ComponentBuilder SetHorizontal(this ComponentBuilder builder, int? defaultlabelWidth = null, bool horizontal = true) where TConfig : BootstrapConfig + where TForm : Form { builder.Component.ToggleCss(Css.FormHorizontal, horizontal, Css.FormInline); if (defaultlabelWidth.HasValue) @@ -52,15 +54,17 @@ public static class FormExtensions } // Use action = null to reset form action to current request url - public static ComponentBuilder SetAction(this ComponentBuilder builder, string action) + public static ComponentBuilder SetAction(this ComponentBuilder builder, string action) where TConfig : BootstrapConfig + where TForm : Form { builder.Component.MergeAttribute("action", action); return builder; } - public static ComponentBuilder SetMethod(this ComponentBuilder builder, string method) + public static ComponentBuilder SetMethod(this ComponentBuilder builder, string method) where TConfig : BootstrapConfig + where TForm : Form { builder.Component.MergeAttribute("method", method); return builder; diff --git a/FluentBootstrap/Typography/TypographyExtensions.cs b/FluentBootstrap/Typography/TypographyExtensions.cs index b483714..ee9e2e4 100644 --- a/FluentBootstrap/Typography/TypographyExtensions.cs +++ b/FluentBootstrap/Typography/TypographyExtensions.cs @@ -306,7 +306,7 @@ public static class TypographyExtensions return new ComponentBuilder(helper.Config, new DescriptionList(helper)); } - public static ComponentBuilder SetHorizontal(this ComponentBuilder builder, bool horizontal = true) + public static ComponentBuilder SetHorizontalDescription(this ComponentBuilder builder, bool horizontal = true) where TConfig : BootstrapConfig { builder.Component.ToggleCss(Css.DlHorizontal, horizontal);