Add modal size and abp-input disabled attributes

pull/279/head
Halil İbrahim Kalkan 8 years ago
parent bcab297d7b
commit 2e25a4a4a5

@ -13,7 +13,7 @@
case AbpButtonSize.Default:
return "";
default:
throw new AbpException("Unknown AbpButtonSize: " + size);
throw new AbpException($"Unknown {nameof(AbpButtonSize)}: {size}");
}
}
}

@ -10,6 +10,9 @@ namespace Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.TagHelpers.Form
public string Label { get; set; }
[HtmlAttributeName("disabled")]
public bool IsDisabled { get; set; }
[HtmlAttributeNotBound]
[ViewContext]
public ViewContext ViewContext { get; set; }

@ -25,7 +25,13 @@ namespace Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.TagHelpers.Form
var order = GetInputOrder(TagHelper.AspFor.ModelExplorer);
AddGroupToFormGroupContents(context, TagHelper.AspFor.Name, SurroundInnerHtmlAndGet(context, output, innerHtml, isCheckbox), order, out var surpress);
AddGroupToFormGroupContents(
context,
TagHelper.AspFor.Name,
SurroundInnerHtmlAndGet(context, output, innerHtml, isCheckbox),
order,
out var surpress
);
if (surpress)
{
@ -89,9 +95,14 @@ namespace Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.TagHelpers.Form
};
var inputTagHelperOutput = GetInnerTagHelper(new TagHelperAttributeList(), context, inputTagHelper, "input");
isCheckbox = IsInputCheckbox(context, output,inputTagHelperOutput.Attributes);
inputTagHelperOutput.Attributes.Add("class", isCheckbox ? "form-check-input" : "form-control");
if (!inputTagHelperOutput.Attributes.ContainsName("disabled") && TagHelper.IsDisabled)
{
inputTagHelperOutput.Attributes.Add("disabled", "true");
}
isCheckbox = IsInputCheckbox(context, output, inputTagHelperOutput.Attributes);
inputTagHelperOutput.Attributes.AddClass(isCheckbox ? "form-check-input" : "form-control");
return inputTagHelperOutput;
}
@ -111,7 +122,7 @@ namespace Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.TagHelpers.Form
var checkboxClass = isCheckbox ? "class=\"form-check-label\" " : "";
return "<label " + checkboxClass + GetIdAttributeAsString(inputTag) + ">"
+ GetLabelValue(context,output) +
+ GetLabelValue(context, output) +
"</label>";
}

@ -0,0 +1,9 @@
namespace Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.TagHelpers.Modal
{
public enum AbpModalSize
{
Default,
Small,
Large
}
}

@ -0,0 +1,20 @@
namespace Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.TagHelpers.Modal
{
public static class AbpModalSizeExtensions
{
public static string ToClassName(this AbpModalSize size)
{
switch (size)
{
case AbpModalSize.Small:
return "modal-sm";
case AbpModalSize.Large:
return "modal-lg";
case AbpModalSize.Default:
return "";
default:
throw new AbpException($"Unknown {nameof(AbpModalSize)}: {size}");
}
}
}
}

@ -2,6 +2,8 @@
{
public class AbpModalTagHelper : AbpTagHelper<AbpModalTagHelper, AbpModalTagHelperService>
{
public AbpModalSize Size { get; set; } = AbpModalSize.Default;
public AbpModalTagHelper(AbpModalTagHelperService tagHelperService)
: base(tagHelperService)
{

@ -16,13 +16,36 @@ namespace Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.TagHelpers.Modal
{
var sb = new StringBuilder();
sb.AppendLine("<div class=\"modal fade\" tabindex=\"-1\" role=\"dialog\" aria-hidden=\"true\">");
sb.AppendLine(" <div class=\"modal-dialog\" role=\"document\">");
sb.AppendLine(" <div class=\"modal-content\">");
sb.AppendLine("<div class=\""+ GetModalClasses() + "\" tabindex=\"-1\" role=\"dialog\" aria-hidden=\"true\">");
sb.AppendLine(" <div class=\"" + GetModalDialogClasses() + "\" role=\"document\">");
sb.AppendLine(" <div class=\"" + GetModalContentClasses() + "\">");
return sb.ToString();
}
protected virtual string GetModalClasses()
{
return "modal fade";
}
protected virtual string GetModalDialogClasses()
{
var classNames = new StringBuilder("modal-dialog");
if (TagHelper.Size != AbpModalSize.Default)
{
classNames.Append(" ");
classNames.Append(TagHelper.Size.ToClassName());
}
return classNames.ToString();
}
protected virtual string GetModalContentClasses()
{
return "modal-content";
}
protected virtual string CreatePostContent()
{
var sb = new StringBuilder();

Loading…
Cancel
Save