|
|
|
@ -1,4 +1,5 @@ |
|
|
|
using System.Collections.Generic; |
|
|
|
using System.Linq; |
|
|
|
using System.Threading.Tasks; |
|
|
|
using Microsoft.AspNetCore.Razor.TagHelpers; |
|
|
|
using Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.TagHelpers.Extensions; |
|
|
|
@ -13,7 +14,7 @@ namespace Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.TagHelpers.Tab |
|
|
|
|
|
|
|
var innerContent = await output.GetChildContentAsync(); |
|
|
|
var tabHeader = GetTabHeaderItem(context, output); |
|
|
|
var tabContent = GetTabContentItem(innerContent.GetContent()); |
|
|
|
var tabContent = GetTabContentItem(context, output, innerContent.GetContent()); |
|
|
|
|
|
|
|
var tabHeaderItems = context.GetValue<List<TabItem>>(TabItems); |
|
|
|
|
|
|
|
@ -30,23 +31,31 @@ namespace Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.TagHelpers.Tab |
|
|
|
var link = TagHelper.Name; |
|
|
|
var control = TagHelper.Name; |
|
|
|
var title = TagHelper.Title; |
|
|
|
var attributes = GetTabHeaderAttributes(context, output); |
|
|
|
|
|
|
|
var classAttributesAsString = attributes.Where(a=>a.Name == "class").ToList().Select(a=>a.Value).JoinAsString(" "); |
|
|
|
var otherAttributesAsString = attributes.Where(a => a.Name != "class").ToList().ToHtmlAttributesAsString(); |
|
|
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(TagHelper.ParentDropdownName)) |
|
|
|
{ |
|
|
|
return "<a class=\"dropdown-item\" id=\"" + id + "\" href=\"#" + link + "\" data-toggle=\"tab\" role=\"tab\" aria-controls=\"" + control + "\" aria-selected=\"false\">" + title + "</a>"; |
|
|
|
return "<a class=\"dropdown-item "+ classAttributesAsString + "\" id=\"" + id + "\" href=\"#" + link + "\" data-toggle=\"tab\" role=\"tab\" aria-controls=\"" + control + "\" aria-selected=\"false\" "+ otherAttributesAsString + ">" + title + "</a>"; |
|
|
|
} |
|
|
|
|
|
|
|
return "<li class=\"nav-item\"><a class=\"nav-link" + AbpTabItemActivePlaceholder + "\" id=\"" + id + "\" data-toggle=\"" + TabItemsDataTogglePlaceHolder + "\" href=\"#" + link + "\" role=\"tab\" aria-controls=\"" + control + "\" aria-selected=\"" + AbpTabItemSelectedPlaceholder + "\">" + |
|
|
|
return "<li class=\"nav-item\"><a class=\"nav-link " + classAttributesAsString + " " + AbpTabItemActivePlaceholder + "\" id=\"" + id + "\" data-toggle=\"" + TabItemsDataTogglePlaceHolder + "\" href=\"#" + link + "\" role=\"tab\" aria-controls=\"" + control + "\" aria-selected=\"" + AbpTabItemSelectedPlaceholder + "\" "+ otherAttributesAsString + ">" + |
|
|
|
title + |
|
|
|
"</a></li>"; |
|
|
|
} |
|
|
|
|
|
|
|
protected virtual string GetTabContentItem(string content) |
|
|
|
protected virtual string GetTabContentItem(TagHelperContext context, TagHelperOutput output, string content) |
|
|
|
{ |
|
|
|
var headerId = TagHelper.Name + "-tab"; |
|
|
|
var id = TagHelper.Name; |
|
|
|
var attributes = GetTabContentAttributes(context, output); |
|
|
|
|
|
|
|
var classAttributesAsString = attributes.Where(a => a.Name == "class").ToList().Select(a => a.Name).JoinAsString(" "); |
|
|
|
var otherAttributesAsString = attributes.Where(a => a.Name != "class").ToList().ToHtmlAttributesAsString(); |
|
|
|
|
|
|
|
return "<div class=\"tab-pane fade" + AbpTabItemShowActivePlaceholder + "\" id=\"" + id + "\" role=\"tabpanel\" aria-labelledby=\"" + headerId + "\">" + |
|
|
|
return "<div class=\"tab-pane fade " + classAttributesAsString + " " + AbpTabItemShowActivePlaceholder + "\" id=\"" + id + "\" role=\"tabpanel\" aria-labelledby=\"" + headerId + "\" " + otherAttributesAsString + ">" + |
|
|
|
content + |
|
|
|
"</div>"; |
|
|
|
} |
|
|
|
@ -58,5 +67,20 @@ namespace Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.TagHelpers.Tab |
|
|
|
TagHelper.Name = TabItemNamePlaceHolder; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
protected virtual List<TagHelperAttribute> GetTabContentAttributes(TagHelperContext context, TagHelperOutput output) { |
|
|
|
var contentprefix = "content-"; |
|
|
|
return GetTabAttributesByPrefix(output.Attributes, contentprefix); |
|
|
|
} |
|
|
|
|
|
|
|
protected virtual List<TagHelperAttribute> GetTabHeaderAttributes(TagHelperContext context, TagHelperOutput output) { |
|
|
|
var headerprefix = "header-"; |
|
|
|
return GetTabAttributesByPrefix(output.Attributes, headerprefix); |
|
|
|
} |
|
|
|
|
|
|
|
private List<TagHelperAttribute> GetTabAttributesByPrefix(TagHelperAttributeList attributes, string prefix) { |
|
|
|
return attributes.Where(a=>a.Name.StartsWith(prefix)) |
|
|
|
.Select(a=> new TagHelperAttribute(a.Name.Substring(prefix.Length), a.Value)).ToList(); |
|
|
|
} |
|
|
|
} |
|
|
|
} |