btcpayserver/BTCPayServer/Views/UIInvoice/PosData.cshtml

53 lines
1.9 KiB
Text
Raw Normal View History

@model (Dictionary<string, object> Items, int Level)
<table class="table table-hover my-0">
@foreach (var (key, value) in Model.Items)
{
<tr>
2021-09-10 00:08:38 +09:00
@if (value is string str)
{
if (!string.IsNullOrEmpty(key))
{
<th class="w-150px">@Safe.Raw(key)</th>
}
<td>
@if (Uri.IsWellFormedUriString(str, UriKind.RelativeOrAbsolute))
{
<a href="@Safe.Raw(str)" target="_blank" rel="noreferrer noopener">@Safe.Raw(str)</a>
}
else
{
@Safe.Raw(value?.ToString())
}
</td>
}
else if (value is Dictionary<string, object>subItems)
{
@* This is the array case *@
2021-09-10 00:08:38 +09:00
if (subItems.Count == 1 && subItems.First().Value is string str2)
{
<th class="w-150px">@Safe.Raw(key)</th>
<td>
@if (Uri.IsWellFormedUriString(str2, UriKind.RelativeOrAbsolute))
2021-09-10 00:08:38 +09:00
{
<a href="@Safe.Raw(str2)" target="_blank" rel="noreferrer noopener">@Safe.Raw(str2)</a>
2021-09-10 00:08:38 +09:00
}
else
{
@Safe.Raw(subItems.First().Value?.ToString())
2021-09-10 00:08:38 +09:00
}
</td>
}
else
{
<td colspan="2" >
@Safe.Raw($"<h{Model.Level + 3} class=\"mt-4 mb-3\">{key}</h{Model.Level + 3}>")
<partial name="PosData" model="(subItems, Model.Level + 1)"/>
</td>
}
}
</tr>
}
</table>