@inherits ComponentBase

<TableContainer T="ViewModel"
    @ref="_container" 
    @bind-Search="_search" 
    Title="@_title" 
    Breadcrumbs="@_breadcrumbs"
    Data="LoadDataAsync"
    OnAdd="()=>_createDialog?.ToggleAsync()">
    <Header>
        <MudTh>
            <MudTableSortLabel SortLabel="Name" T="ViewModel">
                Name
            </MudTableSortLabel>
        </MudTh>
        <MudTh>
            <MudTableSortLabel SortLabel="Description" T="ViewModel">
                Description
            </MudTableSortLabel>
        </MudTh>
        <MudTh>
            <MudTableSortLabel SortLabel="Jobs" T="ViewModel">
                Jobs
            </MudTableSortLabel>
        </MudTh>
    </Header>
    <RowTemplate>
        <MudTd DataLabel="Name">
            <MudLink Href="@Navigation.Management.Scheduler.Tasks.DetailsHref(context?.Id)" Typo="Typo.inherit" Underline="Underline.None">
                @context?.Name
            </MudLink>
        </MudTd>
        <MudTd DataLabel="Description">
            @context?.Description
        </MudTd>
        <MudTd DataLabel="Jobs">
            <MudLink Href="@Navigation.Management.Scheduler.Tasks.JobsHref(context.Id)" Typo="Typo.inherit" Underline="Underline.None">
                @(context.Jobs?.ToString() ?? "0")
            </MudLink>
        </MudTd>
    </RowTemplate>
    <ActionTemplate>
        <MudMenuItem OnClick="@(()=>_editDialog?.ToggleAsync(context.Id))">
            Edit
        </MudMenuItem>
        <MudMenuItem OnClick="@(()=>_deleteDialog?.ToggleAsync(context.Id))">
            Delete
        </MudMenuItem>
    </ActionTemplate>
</TableContainer>

<TaskCreateDialog @ref="_createDialog" OnChanges="OnRefreshAsync" />
<TaskEditDialog @ref="_editDialog" OnChanges="OnRefreshAsync" />
<TaskDeleteDialog @ref="_deleteDialog" OnChanges="OnRefreshAsync" />

@code{
    private TaskCreateDialog? _createDialog;
    private TaskEditDialog? _editDialog;
    private TaskDeleteDialog? _deleteDialog;
}