| | 1 | | @namespace Syki.Front.Pages.Teacher |
| | 2 | |
|
| | 3 | | @page "/teacher/classes" |
| | 4 | | @attribute [Authorize(Roles = "Teacher")] |
| | 5 | |
|
| | 6 | | <SykiPageTitle Title="Turmas" /> |
| | 7 | |
|
| | 8 | | <MudContainer Class="my-4 px-4"> |
| | 9 | | <SykiPageHeader Icon="@Icons.Material.Filled.CenterFocusStrong" Title="Turmas" /> |
| | 10 | | <SykiPageAlert Text="Em uma mesma turma podem estudar alunos de diferentes cursos." /> |
| | 11 | | <MudContainer Class="px-0 mb-4"> |
| | 12 | | <MudDataGrid Class="pa-4" Items="@_classes" QuickFilter="@_quickFilter" Hover="true" Loading="@_loading" Dense=" |
| | 13 | | <ToolBarContent> |
| | 14 | | <SykiDataGridSearchTextField @bind-Value="@_searchString" Placeholder="Busque por qualquer atributo" /> |
| | 15 | | </ToolBarContent> |
| | 16 | | <Columns> |
| | 17 | | <PropertyColumn Property="x => x.Discipline" Title="Disciplina" /> |
| | 18 | | <PropertyColumn Property="x => x.Period" Title="Período" /> |
| | 19 | | <PropertyColumn Property="x => x.SchedulesInline" Title="Horário" /> |
| | 20 | | <TemplateColumn CellClass="d-flex justify-end"> |
| | 21 | | <CellTemplate> |
| 0 | 22 | | <MudIconButton Size="@Size.Small" Icon="@Icons.Material.Filled.RemoveRedEye" OnClick="@(() => Go |
| | 23 | | </CellTemplate> |
| | 24 | | </TemplateColumn> |
| | 25 | | </Columns> |
| | 26 | | <NoRecordsContent> |
| | 27 | | @(GetNotFoundMessage()) |
| | 28 | | </NoRecordsContent> |
| | 29 | | <PagerContent> |
| | 30 | | <SykiDataGridPager T="TeacherClassesOut" /> |
| | 31 | | </PagerContent> |
| | 32 | | </MudDataGrid> |
| | 33 | | </MudContainer> |
| | 34 | | </MudContainer> |
| | 35 | |
|
| | 36 | | @inject NavigationManager Nav |
| | 37 | | @inject GetTeacherClassesClient GetTeacherClassesClient |
| | 38 | |
|
| | 39 | | @code |
| | 40 | | { |
| | 41 | | private bool _loading; |
| | 42 | | private string _searchString; |
| 0 | 43 | | private List<TeacherClassesOut> _classes = []; |
| | 44 | |
|
| | 45 | | protected override async Task OnInitializedAsync() |
| | 46 | | { |
| 0 | 47 | | _loading = true; |
| 0 | 48 | | _classes = await GetTeacherClassesClient.Get(); |
| 0 | 49 | | _loading = false; |
| 0 | 50 | | } |
| | 51 | |
|
| | 52 | | private void GoToClass(TeacherClassesOut item) |
| | 53 | | { |
| 0 | 54 | | Nav.NavigateTo($"/teacher/classes/{item.Id}"); |
| 0 | 55 | | } |
| | 56 | |
|
| 0 | 57 | | private Func<TeacherClassesOut, bool> _quickFilter => x => _searchString.IsIn(x.Discipline, x.Period); |
| | 58 | |
|
| | 59 | | private string GetNotFoundMessage() |
| | 60 | | { |
| 0 | 61 | | return _searchString.IsEmpty() ? "Não existem turmas cadastradas ainda." : "Nenhuma turma encontrada."; |
| | 62 | | } |
| | 63 | | } |