| | 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="true" Loading="@_loading" Den |
| | 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 | | </Columns> |
| | 23 | | <NoRecordsContent> |
| | 24 | | @(GetNotFoundMessage()) |
| | 25 | | </NoRecordsContent> |
| | 26 | | <PagerContent> |
| | 27 | | <SykiDataGridPager T="DisciplineOut"/> |
| | 28 | | </PagerContent> |
| | 29 | | </MudDataGrid> |
| | 30 | | </MudContainer> |
| | 31 | | </MudContainer> |
| | 32 | |
|
| | 33 | | @inject GetDisciplinesClient Client |
| | 34 | | @inject IDialogService DialogService |
| | 35 | | @inject IBrowserViewportService BrowserViewportService |
| | 36 | |
|
| | 37 | | @code |
| | 38 | | { |
| | 39 | | private bool _loading; |
| | 40 | | private string _searchString; |
| 0 | 41 | | private List<DisciplineOut> _disciplines = []; |
| | 42 | |
|
| | 43 | | protected override async Task OnInitializedAsync() |
| | 44 | | { |
| 0 | 45 | | _loading = true; |
| 0 | 46 | | _disciplines = await Client.Get(); |
| 0 | 47 | | _loading = false; |
| 0 | 48 | | } |
| | 49 | |
|
| | 50 | | private async Task OpenDialog() |
| | 51 | | { |
| 0 | 52 | | var breakpoint = await BrowserViewportService.GetCurrentBreakpointAsync(); |
| 0 | 53 | | var options = new DialogOptions { |
| 0 | 54 | | MaxWidth = MaxWidth.Small, |
| 0 | 55 | | FullWidth = true, |
| 0 | 56 | | FullScreen = breakpoint == Breakpoint.Xs, |
| 0 | 57 | | }; |
| 0 | 58 | | var dialog = await DialogService.ShowAsync<CreateDisciplineDialog>("", options); |
| | 59 | |
|
| 0 | 60 | | var result = await dialog.Result; |
| | 61 | |
|
| 0 | 62 | | if (result!.Canceled) return; |
| | 63 | |
|
| 0 | 64 | | await OnInitializedAsync(); |
| 0 | 65 | | } |
| | 66 | |
|
| 0 | 67 | | private Func<DisciplineOut, bool> _quickFilter => x => _searchString.IsIn(x.Name, x.Code); |
| | 68 | |
|
| | 69 | | private string GetNotFoundMessage() |
| | 70 | | { |
| 0 | 71 | | return (_searchString.IsEmpty()) ? "Não existem disciplinas cadastradas ainda." : "Nenhuma disciplina encontrada |
| | 72 | | } |
| | 73 | | } |