e53403c934
This commit updates several components to replace traditional HTML layout elements with MudBlazor's MudStack component for improved styling and responsiveness. Changes include the CareerMapping.razor, Index.razor, Registration.razor, TeamStudents.razor, and TeamToggleSelector.razor files. These modifications enhance the visual consistency and maintainability of the UI by adhering to the project's design standards.
118 lines
4.9 KiB
Plaintext
118 lines
4.9 KiB
Plaintext
@page "/students"
|
|
@attribute [Authorize]
|
|
@using Microsoft.EntityFrameworkCore
|
|
@using WebApp.Models
|
|
@using WebApp.Components.Shared.Components
|
|
@inject AppDbContext Context
|
|
@inject IDialogService DialogService
|
|
@inject ISnackbar Snackbar
|
|
|
|
<PageHeader Title="Students">
|
|
<ActionButtons>
|
|
<MudButton StartIcon="@Icons.Material.Filled.Create" Href="students/create" Variant="Variant.Filled" Color="Color.Primary">Create New</MudButton>
|
|
<MudButton StartIcon="@AppIcons.EventRank" Href="students/event-ranking" Variant="Variant.Outlined">Event Rankings</MudButton>
|
|
<MudButton StartIcon="@AppIcons.Registration" Href="students/teams" Variant="Variant.Outlined">Registration</MudButton>
|
|
</ActionButtons>
|
|
</PageHeader>
|
|
|
|
<MudPaper Elevation="2" Class="pa-3 pa-md-6">
|
|
<MudDataGrid T="Student"
|
|
ServerData="ServerReload"
|
|
@ref="_dataGrid"
|
|
Filterable="true"
|
|
RowsPerPage="25"
|
|
Dense="true"
|
|
Striped="true"
|
|
Hover="true"
|
|
Loading="@_isLoading"
|
|
LoadingProgressColor="Color.Primary">
|
|
<Columns>
|
|
<PropertyColumn Property="@(e => e.LastName)" Title="Name" Sortable="true">
|
|
<CellTemplate>
|
|
<MudStack Row="true" AlignItems="AlignItems.Center" Justify="Justify.SpaceBetween" Spacing="1">
|
|
<MudStack Row="true" AlignItems="AlignItems.Center" Spacing="1" Wrap="Wrap.Wrap">
|
|
<MudLink Href="@($"/students/details?id={context.Item.Id}&returnUrl=/students")"
|
|
Underline="Underline.Hover"
|
|
Color="Color.Primary">
|
|
@context.Item.LastNameFirstName
|
|
</MudLink>
|
|
@if (context.Item.OfficerRole != null)
|
|
{
|
|
<MudChip T="string" Size="Size.Small" Icon="@(AppIcons.OfficerRoleIcon(context.Item.OfficerRole.Value))">@context.Item.OfficerRole</MudChip>
|
|
}
|
|
</MudStack>
|
|
<MudStack Row="true" AlignItems="AlignItems.Center" Spacing="1">
|
|
<IconButtonWithTooltip Icon="@Icons.Material.Filled.Edit"
|
|
TooltipText="Edit"
|
|
Href="@($"/students/edit?id={context.Item.Id}&returnUrl=/students")" />
|
|
<IconButtonWithTooltip Icon="@Icons.Material.Outlined.Delete"
|
|
TooltipText="Delete"
|
|
HoverColor="Color.Error"
|
|
OnClick="() => DeleteStudent(context.Item!)" />
|
|
</MudStack>
|
|
</MudStack>
|
|
</CellTemplate>
|
|
</PropertyColumn>
|
|
<PropertyColumn Property="@(e => e.Grade)" Title="Grade (TSA Year)" Sortable="true">
|
|
<CellTemplate>
|
|
<span style="white-space: nowrap;">@((MarkupString)AppIcons.GetOrdinalSuperscript(context.Item.Grade))</span> (@context.Item.TsaYear)
|
|
</CellTemplate>
|
|
</PropertyColumn>
|
|
</Columns>
|
|
<PagerContent>
|
|
<MudDataGridPager T="Student"></MudDataGridPager>
|
|
</PagerContent>
|
|
</MudDataGrid>
|
|
</MudPaper>
|
|
|
|
@code {
|
|
MudDataGrid<Student> _dataGrid = null!;
|
|
private bool _isLoading = true;
|
|
|
|
private async Task<GridData<Student>> ServerReload(GridState<Student> state)
|
|
{
|
|
_isLoading = true;
|
|
try
|
|
{
|
|
var query =
|
|
Context.Students.OrderBy(e => e.LastName)
|
|
.Where(state.FilterDefinitions).OrderBy(state.SortDefinitions);
|
|
|
|
var totalItems = await query.CountAsync();
|
|
var pagedData = await query.Skip(state.Page * state.PageSize).Take(state.PageSize).ToArrayAsync();
|
|
|
|
return new GridData<Student>
|
|
{
|
|
TotalItems = totalItems,
|
|
Items = pagedData
|
|
};
|
|
}
|
|
finally
|
|
{
|
|
_isLoading = false;
|
|
}
|
|
}
|
|
|
|
private async Task DeleteStudent(Student student)
|
|
{
|
|
//_isRowBlocked = true;
|
|
|
|
var result = await DialogService
|
|
.ShowMessageBox("Delete student",
|
|
(MarkupString)$"Are you sure want to delete <b>{student.Name}</b>? This cannot be undone.",
|
|
yesText:"Yes",
|
|
noText:"Cancel");
|
|
|
|
if (result == true)
|
|
{
|
|
Context.Students.Remove(student!);
|
|
await Context.SaveChangesAsync();
|
|
Snackbar.Add($"Delete event: Delete of Student {student.Name}", Severity.Info);
|
|
}
|
|
|
|
//_isRowBlocked = false;
|
|
StateHasChanged();
|
|
await _dataGrid.ReloadServerData();
|
|
}
|
|
}
|