btcpayserver/BTCPayServer/Views/Invoice/PosData.cshtml
2021-09-02 12:36:02 +02:00

52 lines
1.5 KiB
Text

@model (Dictionary<string, object> Items, int Level)
@functions{
void DisplayValue(object value)
{
if (value is string str && str.StartsWith("http"))
{
<a href="@str" target="_blank" rel="noreferrer noopener">@str</a>
}
else
{
@value
}
}
}
<table class="table table-hover table-responsive-md removetopborder">
@foreach (var (key, value) in Model.Items)
{
<tr>
@if (value is string)
{
if (!string.IsNullOrEmpty(key))
{
<th class="w-150px">@key</th>
}
<td>
@{ DisplayValue(value); }
</td>
}
else if (value is Dictionary<string, object>subItems)
{
@* This is the array case *@
if (subItems.Count == 1 && subItems.First().Value is string)
{
<th class="w-150px">@key</th>
<td>
@{ DisplayValue(subItems.First().Value); }
</td>
}
else
{
<td colspan="2">
@Html.Raw($"<h{Model.Level + 3} class='mt-3'>{key}</h{Model.Level + 3}>")
<partial name="PosData" model="(subItems, Model.Level + 1)"/>
</td>
}
}
</tr>
}
</table>