IW4M-Admin/WebfrontCore/Views/Shared/_DataTable.cshtml

110 lines
3.9 KiB
Plaintext
Raw Normal View History

2022-06-05 17:27:56 -04:00
@using WebfrontCore.ViewModels
@model WebfrontCore.ViewModels.TableInfo
2022-04-19 19:43:58 -04:00
@{
Layout = null;
}
<h4 class="content-title mb-15 mt-15">
<color-code value="@Model.Header"></color-code>
</h4>
<table class="table">
<thead>
<tr class="bg-primary text-light d-none d-lg-table-row">
@foreach (var column in Model.Columns)
{
<th>@column.Title</th>
}
</tr>
</thead>
<tbody>
2022-06-05 17:27:56 -04:00
@{ var start = 0; }
2022-04-19 19:43:58 -04:00
@if (!Model.Rows.Any())
{
<!-- desktop -->
<tr class="bg-dark-dm bg-light-lm d-none d-lg-table-row">
<td colspan="@Model.Columns.Count">No data...</td>
</tr>
<!-- mobile -->
<tr class="d-flex d-table-row d-lg-none">
<td class="bg-primary text-light text-right w-125">
&mdash;
</td>
<td class="bg-dark-dm bg-light-lm flex-fill w-200">No data...</td>
</tr>
}
@foreach (var row in Model.Rows)
{
<!-- desktop -->
2022-06-05 17:27:56 -04:00
<tr class="bg-dark-dm bg-light-lm @(Model.InitialRowCount > 0 && start >= Model.InitialRowCount ? "d-none hidden-row-lg" : "d-none d-lg-table-row")">
2022-04-19 19:43:58 -04:00
@for (var i = 0; i < Model.Columns.Count; i++)
{
2022-06-05 17:27:56 -04:00
var data = row.Datum[i];
<td>
@if (data.Template is null)
{
if (data.Type == ColumnType.Text)
{
<span>@data.Value</span>
}
if (data.Type == ColumnType.Link)
{
<a href="@data.Data" class="no-decoration">@data.Value</a>
}
if (data.Type == ColumnType.Icon)
{
<span class="oi @data.Value profile-action" data-action="@data.Data" data-action-id="@data.Id"></span>
}
if (data.Type == ColumnType.Button)
{
<div class="btn profile-action" data-action="@data.Data" data-action-id="@data.Id">@data.Value</div>
}
}
else
{
@data.Template
}
</td>
2022-04-19 19:43:58 -04:00
}
</tr>
<!-- mobile -->
2022-06-05 17:27:56 -04:00
<tr class="@(Model.InitialRowCount > 0 && start >= Model.InitialRowCount ? "d-none hidden-row" : "d-flex d-table-row d-lg-none")">
2022-04-19 19:43:58 -04:00
<td class="bg-primary text-light text-right w-125">
@foreach (var column in Model.Columns)
{
<div class="mt-5 mb-5 text-truncate">@column.Title</div>
}
</td>
<td class="bg-dark-dm bg-light-lm flex-fill w-200">
@for (var i = 0; i < Model.Columns.Count; i++)
{
2022-06-05 17:27:56 -04:00
var data = row.Datum[i];
<div class="mt-5 mb-5 text-truncate" style="min-width:0">
@if (data.Type == ColumnType.Text)
{
<span>@data.Value</span>
}
@if (data.Type == ColumnType.Link)
{
<a href="@data.Data">@data.Value</a>
}
@if (data.Type == ColumnType.Icon)
{
<span class="oi @data.Value profile-action" data-action="@data.Data" data-action-id="@data.Id"></span>
}
</div>
2022-04-19 19:43:58 -04:00
}
</td>
</tr>
start++;
}
</tbody>
</table>
@if (Model.InitialRowCount > 0 && Model.Rows.Count > 0)
{
<button class="btn btn-block table-slide" data-toggle="tooltip" data-title="Show @(Model.Rows.Count - Model.InitialRowCount) more rows">
<span class="oi oi-chevron-bottom"></span>
</button>
}