Browse Source

Merge pull request #8782 from acjh/patch-6

Standardize passing and setting of content in Tag Helpers
pull/8797/head
maliming 6 years ago
committed by GitHub
parent
commit
3493016ca1
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 6
      framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Collapse/AbpAccordionItemTagHelperService.cs
  2. 4
      framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Collapse/AbpCollapseBodyTagHelperService.cs
  3. 2
      framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Dropdown/AbpDropdownButtonTagHelperService.cs
  4. 19
      framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Form/AbpDynamicformTagHelperService.cs
  5. 2
      framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Form/AbpInputTagHelperService.cs
  6. 6
      framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Tab/AbpTabTagHelperService.cs

6
framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Collapse/AbpAccordionItemTagHelperService.cs

@ -13,9 +13,9 @@ namespace Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.TagHelpers.Collapse
{ {
SetRandomIdIfNotProvided(); SetRandomIdIfNotProvided();
var innerContent = (await output.GetChildContentAsync()).GetContent(); var childContent = await output.GetChildContentAsync();
var html = GetAccordionHeaderItem(context, output) + GetAccordionContentItem(context, output, innerContent); var html = GetAccordionHeaderItem(context, output) + GetAccordionContentItem(context, output, childContent);
var tabHeaderItems = context.GetValue<List<string>>(AccordionItems); var tabHeaderItems = context.GetValue<List<string>>(AccordionItems);
tabHeaderItems.Add(html); tabHeaderItems.Add(html);
@ -46,7 +46,7 @@ namespace Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.TagHelpers.Collapse
return header.ToHtmlString(); return header.ToHtmlString();
} }
protected virtual string GetAccordionContentItem(TagHelperContext context, TagHelperOutput output, string content) protected virtual string GetAccordionContentItem(TagHelperContext context, TagHelperOutput output, TagHelperContent content)
{ {
var show = (TagHelper.Active ?? false) ? " show" : ""; var show = (TagHelper.Active ?? false) ? " show" : "";

4
framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Collapse/AbpCollapseBodyTagHelperService.cs

@ -22,9 +22,9 @@ namespace Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.TagHelpers.Collapse
output.Attributes.AddClass("multi-collapse"); output.Attributes.AddClass("multi-collapse");
} }
var innerContent = (await output.GetChildContentAsync()).GetContent(); var childContent = await output.GetChildContentAsync();
output.Content.SetHtmlContent(innerContent); output.Content.SetHtmlContent(childContent);
} }
} }
} }

2
framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Dropdown/AbpDropdownButtonTagHelperService.cs

@ -70,7 +70,7 @@ namespace Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.TagHelpers.Dropdown
var buttonTag = await abpButtonTagHelper.ProcessAndGetOutputAsync(attributes, context, "button", TagMode.StartTagAndEndTag); var buttonTag = await abpButtonTagHelper.ProcessAndGetOutputAsync(attributes, context, "button", TagMode.StartTagAndEndTag);
buttonTag.PreContent.SetHtmlContent(content.GetContent()); buttonTag.PreContent.SetHtmlContent(content);
if ((TagHelper.NavLink ?? false) || (TagHelper.Link ?? false)) if ((TagHelper.NavLink ?? false) || (TagHelper.Link ?? false))
{ {

19
framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Form/AbpDynamicformTagHelperService.cs

@ -42,7 +42,7 @@ namespace Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.TagHelpers.Form
NormalizeTagMode(context, output); NormalizeTagMode(context, output);
var childContent = (await output.GetChildContentAsync()).GetContent(); var childContent = await output.GetChildContentAsync();
await ConvertToMvcForm(context, output); await ConvertToMvcForm(context, output);
@ -78,8 +78,8 @@ namespace Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.TagHelpers.Form
await formTagOutput.GetChildContentAsync(); await formTagOutput.GetChildContentAsync();
output.PostContent.SetHtmlContent(output.PostContent.GetContent() + formTagOutput.PostContent.GetContent()); output.PostContent.AppendHtml(formTagOutput.PostContent);
output.PreContent.SetHtmlContent(output.PreContent.GetContent() + formTagOutput.PreContent.GetContent()); output.PreContent.AppendHtml(formTagOutput.PreContent);
} }
protected virtual void NormalizeTagMode(TagHelperContext context, TagHelperOutput output) protected virtual void NormalizeTagMode(TagHelperContext context, TagHelperOutput output)
@ -93,7 +93,7 @@ namespace Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.TagHelpers.Form
output.Attributes.AddIfNotContains("method", "post"); output.Attributes.AddIfNotContains("method", "post");
} }
protected virtual void SetContent(TagHelperContext context, TagHelperOutput output, List<FormGroupItem> items, string childContent) protected virtual void SetContent(TagHelperContext context, TagHelperOutput output, List<FormGroupItem> items, TagHelperContent childContent)
{ {
var contentBuilder = new StringBuilder(""); var contentBuilder = new StringBuilder("");
@ -102,16 +102,17 @@ namespace Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.TagHelpers.Form
contentBuilder.AppendLine(item.HtmlContent); contentBuilder.AppendLine(item.HtmlContent);
} }
if (childContent.Contains(AbpFormContentPlaceHolder)) var content = childContent.GetContent();
if (content.Contains(AbpFormContentPlaceHolder))
{ {
childContent = childContent.Replace(AbpFormContentPlaceHolder, contentBuilder.ToString()); content = content.Replace(AbpFormContentPlaceHolder, contentBuilder.ToString());
} }
else else
{ {
childContent = contentBuilder + childContent; content = contentBuilder + content;
} }
output.Content.SetHtmlContent(childContent); output.Content.SetHtmlContent(content);
} }
protected virtual async Task SetSubmitButton(TagHelperContext context, TagHelperOutput output) protected virtual async Task SetSubmitButton(TagHelperContext context, TagHelperOutput output)
@ -123,7 +124,7 @@ namespace Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.TagHelpers.Form
var buttonHtml = await ProcessSubmitButtonAndGetContentAsync(context, output); var buttonHtml = await ProcessSubmitButtonAndGetContentAsync(context, output);
output.PostContent.SetHtmlContent(output.PostContent.GetContent() + buttonHtml); output.PostContent.AppendHtml(buttonHtml);
} }
protected virtual List<FormGroupItem> InitilizeFormGroupContentsContext(TagHelperContext context, TagHelperOutput output) protected virtual List<FormGroupItem> InitilizeFormGroupContentsContext(TagHelperContext context, TagHelperOutput output)

2
framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Form/AbpInputTagHelperService.cs

@ -52,7 +52,7 @@ namespace Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.TagHelpers.Form
output.Attributes.AddClass(isCheckBox ? "custom-checkbox" : "form-group"); output.Attributes.AddClass(isCheckBox ? "custom-checkbox" : "form-group");
output.Attributes.AddClass(isCheckBox ? "custom-control" : ""); output.Attributes.AddClass(isCheckBox ? "custom-control" : "");
output.Attributes.AddClass(isCheckBox ? "mb-2" : ""); output.Attributes.AddClass(isCheckBox ? "mb-2" : "");
output.Content.SetHtmlContent(output.Content.GetContent() + innerHtml); output.Content.AppendHtml(innerHtml);
} }
} }

6
framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Tab/AbpTabTagHelperService.cs

@ -13,9 +13,9 @@ namespace Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.TagHelpers.Tab
{ {
SetPlaceholderForNameIfNotProvided(); SetPlaceholderForNameIfNotProvided();
var innerContent = await output.GetChildContentAsync(); var childContent = await output.GetChildContentAsync();
var tabHeader = GetTabHeaderItem(context, output); var tabHeader = GetTabHeaderItem(context, output);
var tabContent = GetTabContentItem(context, output, innerContent.GetContent()); var tabContent = GetTabContentItem(context, output, childContent);
var tabHeaderItems = context.GetValue<List<TabItem>>(TabItems); var tabHeaderItems = context.GetValue<List<TabItem>>(TabItems);
@ -83,7 +83,7 @@ namespace Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.TagHelpers.Tab
} }
} }
protected virtual string GetTabContentItem(TagHelperContext context, TagHelperOutput output, string content) protected virtual string GetTabContentItem(TagHelperContext context, TagHelperOutput output, TagHelperContent content)
{ {
var headerId = TagHelper.Name + "-tab"; var headerId = TagHelper.Name + "-tab";
var id = TagHelper.Name; var id = TagHelper.Name;

Loading…
Cancel
Save