Browse Source
Add 'use-switch-checkbox' attribute to AbpInputTagHelper.
pull/22835/head
maliming
1 year ago
No known key found for this signature in database
GPG Key ID: A646B9CB645ECEA4
2 changed files with
15 additions and
5 deletions
-
framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Form/AbpInputTagHelper.cs
-
framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Form/AbpInputTagHelperService.cs
|
|
|
@ -47,11 +47,13 @@ public class AbpInputTagHelper : AbpTagHelper<AbpInputTagHelper, AbpInputTagHelp |
|
|
|
public bool SuppressLabel { get; set; } |
|
|
|
|
|
|
|
[HtmlAttributeName("floating-label")] |
|
|
|
|
|
|
|
public bool FloatingLabel { get; set; } |
|
|
|
|
|
|
|
public CheckBoxHiddenInputRenderMode? CheckBoxHiddenInputRenderMode { get; set; } |
|
|
|
|
|
|
|
[HtmlAttributeName("use-switch-checkbox")] |
|
|
|
public bool UseSwitchCheckBox { get; set; } = false; |
|
|
|
|
|
|
|
public bool AddMarginBottomClass { get; set; } = true; |
|
|
|
|
|
|
|
public AbpInputTagHelper(AbpInputTagHelperService tagHelperService) |
|
|
|
|
|
|
|
@ -66,8 +66,16 @@ public class AbpInputTagHelperService : AbpTagHelperService<AbpInputTagHelper> |
|
|
|
} |
|
|
|
if (isCheckBox) |
|
|
|
{ |
|
|
|
output.Attributes.AddClass("custom-checkbox"); |
|
|
|
output.Attributes.AddClass("custom-control"); |
|
|
|
if (!TagHelper.UseSwitchCheckBox) |
|
|
|
{ |
|
|
|
output.Attributes.AddClass("custom-checkbox"); |
|
|
|
output.Attributes.AddClass("custom-control"); |
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
|
output.Attributes.AddClass("form-switch"); |
|
|
|
} |
|
|
|
|
|
|
|
output.Attributes.AddClass("form-check"); |
|
|
|
} |
|
|
|
} |
|
|
|
@ -266,7 +274,7 @@ public class AbpInputTagHelperService : AbpTagHelperService<AbpInputTagHelper> |
|
|
|
} |
|
|
|
|
|
|
|
protected virtual async Task<string> GetLabelAsHtmlAsync(TagHelperContext context, TagHelperOutput output, TagHelperOutput inputTag, bool isCheckbox) |
|
|
|
{ |
|
|
|
{ |
|
|
|
if (IsOutputHidden(inputTag) || TagHelper.SuppressLabel) |
|
|
|
{ |
|
|
|
return string.Empty; |
|
|
|
@ -395,7 +403,7 @@ public class AbpInputTagHelperService : AbpTagHelperService<AbpInputTagHelper> |
|
|
|
} |
|
|
|
innerOutput.Content.AppendHtml($" <i class=\"{iconClass}\"></i>"); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
innerOutput.Content.AppendHtml(GetRequiredSymbol(context, output)); |
|
|
|
|
|
|
|
return innerOutput.Render(_encoder); |
|
|
|
|