insight/src/Web/Insight.Web/Pages/Management/Customers/Index.razor

71 lines
2.2 KiB
Text
Raw Normal View History

2023-09-21 18:58:32 +02:00
@inherits ComponentBase
<TableContainer T="CustomerEntity"
@ref="Container"
@bind-Search="Search"
Title="@Title"
Breadcrumbs="@Breadcrumbs"
Data="LoadDataAsync"
OnAdd="OnCreate">
<Header>
<MudTh>
<MudTableSortLabel SortLabel="Name" T="CustomerEntity">
Name
</MudTableSortLabel>
</MudTh>
<MudTh>
<MudTableSortLabel SortLabel="Tag" T="CustomerEntity">
Tag
</MudTableSortLabel>
</MudTh>
<MudTh>
<MudTableSortLabel SortLabel="Hosts" T="CustomerEntity">
Hosts
</MudTableSortLabel>
</MudTh>
</Header>
<RowTemplate>
<MudTd DataLabel="Name">
<MudLink Href="@Navigation.Management.Customers.DetailsHref(context?.Id)" Typo="Typo.inherit" Underline="Underline.None">
@context?.Name
</MudLink>
</MudTd>
<MudTd DataLabel="Tag">
@context?.Tag
</MudTd>
<MudTd DataLabel="Hosts">
@{
var value = "0";
if (context.Hosts is not null && context.Hosts.Any())
{
value = @context.Hosts.Count.ToString();
}
<MudLink Href="@Navigation.Management.Customers.HostsHref(context.Id)" Typo="Typo.inherit" Underline="Underline.None">
@value
</MudLink>
}
</MudTd>
</RowTemplate>
<ActionTemplate>
<MudMenuItem OnClick="@(()=>OnEdit(context))">
Edit
</MudMenuItem>
<MudMenuItem OnClick="@(()=>OnDelete(context))">
Delete
</MudMenuItem>
</ActionTemplate>
</TableContainer>
<CascadingValue Name="Customer" Value="@Model">
<CustomerCreateDialog @ref="_createDialog" OnChanges="OnRefreshAsync" />
<CustomerEditDialog @ref="_editDialog" OnChanges="OnRefreshAsync" />
<CustomerDeleteDialog @ref="_deleteDialog" OnChanges="OnRefreshAsync" />
</CascadingValue>
@code{
private CustomerCreateDialog? _createDialog;
private CustomerEditDialog? _editDialog;
private CustomerDeleteDialog? _deleteDialog;
}