Browse Source
Merge pull request #3257 from gterdem/gterdem/modal_tag_enhancement
Abp-Modal Tag helper extra features
pull/3266/head
Yunus Emre Kalkan
6 years ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with
53 additions and
16 deletions
-
framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Modal/AbpModalFooterTagHelper.cs
-
framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Modal/AbpModalFooterTagHelperService.cs
-
framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Modal/AbpModalTagHelper.cs
-
framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Modal/AbpModalTagHelperService.cs
-
framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Modal/ButtonsAlign.cs
-
framework/test/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.Demo/Pages/Components/Modals.cshtml
|
|
|
@ -1,8 +1,12 @@ |
|
|
|
namespace Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.TagHelpers.Modal |
|
|
|
using Microsoft.AspNetCore.Razor.TagHelpers; |
|
|
|
|
|
|
|
namespace Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.TagHelpers.Modal |
|
|
|
{ |
|
|
|
[HtmlTargetElement("abp-modal-footer")] |
|
|
|
public class AbpModalFooterTagHelper : AbpTagHelper<AbpModalFooterTagHelper, AbpModalFooterTagHelperService> |
|
|
|
{ |
|
|
|
public AbpModalButtons Buttons { get; set; } |
|
|
|
public ButtonsAlign ButtonAlignment { get; set; } = ButtonsAlign.Default; |
|
|
|
|
|
|
|
public AbpModalFooterTagHelper(AbpModalFooterTagHelperService tagHelperService) |
|
|
|
: base(tagHelperService) |
|
|
|
|
|
|
|
@ -24,6 +24,7 @@ namespace Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.TagHelpers.Modal |
|
|
|
{ |
|
|
|
output.PostContent.SetHtmlContent(CreateContent()); |
|
|
|
} |
|
|
|
ProcessButtonsAlignment(output); |
|
|
|
} |
|
|
|
|
|
|
|
protected virtual string CreateContent() |
|
|
|
@ -49,9 +50,18 @@ namespace Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.TagHelpers.Modal |
|
|
|
sb.AppendLine("<button type=\"button\" class=\"btn btn-secondary\" data-dismiss=\"modal\">" + _localizer["Close"] + "</button>"); |
|
|
|
sb.AppendLine("<button type=\"submit\" class=\"btn btn-primary\" data-busy-text=\"" + _localizer["SavingWithThreeDot"] + "\"><i class=\"fa fa-check\"></i> <span>" + _localizer["Save"] + "</span></button>"); |
|
|
|
break; |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
return sb.ToString(); |
|
|
|
} |
|
|
|
|
|
|
|
protected virtual void ProcessButtonsAlignment(TagHelperOutput output) |
|
|
|
{ |
|
|
|
if (TagHelper.ButtonAlignment == ButtonsAlign.Default) |
|
|
|
{ |
|
|
|
return; |
|
|
|
} |
|
|
|
output.Attributes.AddClass("justify-content-" + TagHelper.ButtonAlignment.ToString().ToLowerInvariant()); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
@ -6,6 +6,8 @@ |
|
|
|
|
|
|
|
public bool? Centered { get; set; } = false; |
|
|
|
|
|
|
|
public bool? Static { get; set; } = false; |
|
|
|
|
|
|
|
public AbpModalTagHelper(AbpModalTagHelperService tagHelperService) |
|
|
|
: base(tagHelperService) |
|
|
|
{ |
|
|
|
|
|
|
|
@ -18,9 +18,9 @@ namespace Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.TagHelpers.Modal |
|
|
|
var sb = new StringBuilder(); |
|
|
|
|
|
|
|
var attritubutes = output.Attributes.Select(a => " " + a.Name + "=\"" + a.Value + "\" ").ToList(); |
|
|
|
var attritubutesAsJoin = string.Join(" ", attritubutes.ToArray()); |
|
|
|
|
|
|
|
sb.AppendLine("<div class=\""+ GetModalClasses() + "\" tabindex=\"-1\" role=\"dialog\" aria-hidden=\"true\" "+ attritubutesAsJoin + ">"); |
|
|
|
var attritubutesAsJoin = string.Join(" ", attritubutes.ToArray()); |
|
|
|
|
|
|
|
sb.AppendLine("<div class=\"" + GetModalClasses() + "\" tabindex=\"-1\" role=\"dialog\" aria-hidden=\"true\" " + attritubutesAsJoin + GetDataAttributes() + ">"); |
|
|
|
sb.AppendLine(" <div class=\"" + GetModalDialogClasses() + "\" role=\"document\">"); |
|
|
|
sb.AppendLine(" <div class=\"" + GetModalContentClasses() + "\">"); |
|
|
|
|
|
|
|
@ -56,6 +56,15 @@ namespace Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.TagHelpers.Modal |
|
|
|
return "modal-content"; |
|
|
|
} |
|
|
|
|
|
|
|
protected virtual string GetDataAttributes() |
|
|
|
{ |
|
|
|
if (TagHelper.Static == true) |
|
|
|
{ |
|
|
|
return "data-backdrop=\"static\" "; |
|
|
|
} |
|
|
|
return string.Empty; |
|
|
|
} |
|
|
|
|
|
|
|
protected virtual string CreatePostContent() |
|
|
|
{ |
|
|
|
var sb = new StringBuilder(); |
|
|
|
|
|
|
|
@ -0,0 +1,12 @@ |
|
|
|
namespace Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.TagHelpers.Modal |
|
|
|
{ |
|
|
|
public enum ButtonsAlign |
|
|
|
{ |
|
|
|
Default, |
|
|
|
Start, |
|
|
|
Center, |
|
|
|
Around, |
|
|
|
Between, |
|
|
|
End |
|
|
|
} |
|
|
|
} |
|
|
|
@ -45,16 +45,16 @@ |
|
|
|
<div class="code-area"> |
|
|
|
<abp-tabs> |
|
|
|
<abp-tab title="Tag Helper"> |
|
|
|
<pre><code> |
|
|
|
<abp-button button-type="Primary" data-toggle="modal" data-target="#myModal">Launch modal</abp-button> |
|
|
|
|
|
|
|
<abp-modal centered="true" size="Large" id="myModal"> |
|
|
|
<abp-modal-header title="Modal title"></abp-modal-header> |
|
|
|
<abp-modal-body> |
|
|
|
Woohoo, you're reading this text in a modal! |
|
|
|
</abp-modal-body> |
|
|
|
<abp-modal-footer buttons="(AbpModalButtons.Save|AbpModalButtons.Close)"></abp-modal-footer> |
|
|
|
</abp-modal> |
|
|
|
<pre><code> |
|
|
|
<abp-button button-type="Primary" data-toggle="modal" data-target="#myModal">Launch modal</abp-button> |
|
|
|
|
|
|
|
<abp-modal centered="true" size="Large" id="myModal"> |
|
|
|
<abp-modal-header title="Modal title"></abp-modal-header> |
|
|
|
<abp-modal-body> |
|
|
|
Woohoo, you're reading this text in a modal! |
|
|
|
</abp-modal-body> |
|
|
|
<abp-modal-footer buttons="@(AbpModalButtons.Save|AbpModalButtons.Close)"></abp-modal-footer> |
|
|
|
</abp-modal> |
|
|
|
</code></pre> |
|
|
|
</abp-tab> |
|
|
|
<abp-tab title="Rendered"> |
|
|
|
|