| | | 1 | | @using Syki.Front.Features.Academic.GetDisciplines |
| | | 2 | | @using Syki.Front.Features.Academic.CreateDiscipline |
| | | 3 | | |
| | | 4 | | @namespace Syki.Front.Pages.Academic |
| | | 5 | | |
| | | 6 | | @page "/academic/disciplines" |
| | | 7 | | @attribute [Authorize(Roles = "Academic")] |
| | | 8 | | |
| | | 9 | | <SykiPageTitle Title="Disciplinas" /> |
| | | 10 | | |
| | | 11 | | <MudContainer Class="my-4 px-4"> |
| | | 12 | | <SykiPageHeader Icon="@Icons.Material.Filled.Apps" Title="Disciplinas" ButtonText="Nova Disciplina" OnClick="@OpenDi |
| | | 13 | | <SykiPageAlert Text="Uma mesma disciplina pode compor a grade de cursos diferentes." /> |
| | | 14 | | <MudContainer Class="px-0 mb-4"> |
| | | 15 | | <MudDataGrid Class="pa-4" Items="@_disciplines" QuickFilter="@_quickFilter" Hover Loading="@_loading" Dense Rows |
| | | 16 | | <ToolBarContent> |
| | | 17 | | <SykiDataGridSearchTextField @bind-Value="@_searchString" Placeholder="Busque por nome ou código" /> |
| | | 18 | | </ToolBarContent> |
| | | 19 | | <Columns> |
| | | 20 | | <PropertyColumn Property="x => x.Name" Title="Nome" /> |
| | | 21 | | <PropertyColumn Property="x => x.Code" Title="Código" /> |
| | | 22 | | <PropertyColumn Property="x => x.Teachers.ToThousandSeparated()" Title="Professores" /> |
| | | 23 | | </Columns> |
| | | 24 | | <NoRecordsContent> |
| | 0 | 25 | | @(GetNotFoundMessage()) |
| | | 26 | | </NoRecordsContent> |
| | | 27 | | <PagerContent> |
| | | 28 | | <SykiDataGridPager T="DisciplineOut"/> |
| | | 29 | | </PagerContent> |
| | | 30 | | </MudDataGrid> |
| | | 31 | | </MudContainer> |
| | | 32 | | </MudContainer> |
| | | 33 | | |
| | | 34 | | @inject GetDisciplinesClient Client |
| | | 35 | | @inject IDialogService DialogService |
| | | 36 | | @inject IBrowserViewportService BrowserViewportService |
| | | 37 | | |
| | | 38 | | @code |
| | | 39 | | { |
| | | 40 | | private bool _loading; |
| | | 41 | | private string _searchString; |
| | 0 | 42 | | private List<DisciplineOut> _disciplines = []; |
| | | 43 | | |
| | | 44 | | protected override async Task OnInitializedAsync() |
| | | 45 | | { |
| | 0 | 46 | | _loading = true; |
| | 0 | 47 | | _disciplines = await Client.Get(); |
| | 0 | 48 | | _loading = false; |
| | 0 | 49 | | } |
| | | 50 | | |
| | | 51 | | private async Task OpenDialog() |
| | | 52 | | { |
| | 0 | 53 | | var breakpoint = await BrowserViewportService.GetCurrentBreakpointAsync(); |
| | 0 | 54 | | var options = new DialogOptions { |
| | 0 | 55 | | MaxWidth = MaxWidth.Small, |
| | 0 | 56 | | FullWidth = true, |
| | 0 | 57 | | FullScreen = breakpoint == Breakpoint.Xs, |
| | 0 | 58 | | }; |
| | 0 | 59 | | var dialog = await DialogService.ShowAsync<CreateDisciplineDialog>("", options); |
| | | 60 | | |
| | 0 | 61 | | var result = await dialog.Result; |
| | | 62 | | |
| | 0 | 63 | | if (result!.Canceled) return; |
| | | 64 | | |
| | 0 | 65 | | await OnInitializedAsync(); |
| | 0 | 66 | | } |
| | | 67 | | |
| | 0 | 68 | | private Func<DisciplineOut, bool> _quickFilter => x => _searchString.IsIn(x.Name, x.Code); |
| | | 69 | | |
| | | 70 | | private string GetNotFoundMessage() |
| | | 71 | | { |
| | 0 | 72 | | return (_searchString.IsEmpty()) ? "Não existem disciplinas cadastradas ainda." : "Nenhuma disciplina encontrada |
| | | 73 | | } |
| | | 74 | | } |