| | 1 | | @using Syki.Front.Features.Academic.CreateCourseCurriculum |
| | 2 | |
|
| | 3 | | @namespace Syki.Front.Pages.Academic |
| | 4 | |
|
| | 5 | | @page "/academic/course-curriculums" |
| | 6 | | @attribute [Authorize(Roles = "Academic")] |
| | 7 | |
|
| | 8 | | <SykiPageTitle Title="Grades" /> |
| | 9 | |
|
| | 10 | | <MudContainer Class="my-4 px-4"> |
| | 11 | | <SykiPageHeader Icon="@Icons.Material.Filled.AccountTree" Title="Grades" ButtonText="Nova Grade" OnClick="@OpenDialo |
| | 12 | | <SykiPageAlert Text="Um mesmo curso pode ter várias grades diferentes ao longo do tempo, com diferentes disciplinas. |
| | 13 | | <MudContainer Class="px-0 mb-4"> |
| | 14 | | <MudDataGrid Class="pa-4" T="CourseCurriculumOut" Items="@_grades" QuickFilter="@_quickFilter" Hover="true" Load |
| | 15 | | <ToolBarContent> |
| | 16 | | <SykiDataGridSearchTextField @bind-Value="@_searchString" Placeholder="Busque por curso ou grade" /> |
| | 17 | | </ToolBarContent> |
| | 18 | | <Columns> |
| | 19 | | <PropertyColumn Property="x => x.Name" Title="Nome" /> |
| | 20 | | <PropertyColumn Property="x => x.CourseName" Title="Curso" /> |
| | 21 | | <TemplateColumn CellClass="d-flex justify-end"> |
| | 22 | | <CellTemplate> |
| | 23 | | <MudIconButton |
| | 24 | | Size="@Size.Small" |
| | 25 | | Icon="@Icons.Material.Filled.RemoveRedEye" |
| 0 | 26 | | OnClick="@(() => OpenDisciplinesDialog(context.Item))" |
| | 27 | | /> |
| | 28 | | </CellTemplate> |
| | 29 | | </TemplateColumn> |
| | 30 | | </Columns> |
| | 31 | | <NoRecordsContent> |
| | 32 | | @(GetNotFoundMessage()) |
| | 33 | | </NoRecordsContent> |
| | 34 | | <PagerContent> |
| | 35 | | <SykiDataGridPager T="CourseCurriculumOut" /> |
| | 36 | | </PagerContent> |
| | 37 | | </MudDataGrid> |
| | 38 | | </MudContainer> |
| | 39 | | </MudContainer> |
| | 40 | |
|
| | 41 | | @inject IDialogService DialogService |
| | 42 | | @inject GetCourseCurriculumsClient Client |
| | 43 | | @inject IBrowserViewportService BrowserViewportService |
| | 44 | |
|
| | 45 | | @code |
| | 46 | | { |
| | 47 | | private bool _loading; |
| | 48 | | private string _searchString; |
| 0 | 49 | | private List<CourseCurriculumOut> _grades = []; |
| | 50 | |
|
| | 51 | | protected override async Task OnInitializedAsync() |
| | 52 | | { |
| 0 | 53 | | _loading = true; |
| 0 | 54 | | _grades = await Client.Get(); |
| 0 | 55 | | _loading = false; |
| 0 | 56 | | } |
| | 57 | |
|
| | 58 | | private async Task OpenDisciplinesDialog(CourseCurriculumOut courseCurriculum) |
| | 59 | | { |
| 0 | 60 | | var parameters = new DialogParameters<CourseCurriculumDisciplinesDialog>(); |
| 0 | 61 | | parameters.Add(x => x.Disciplines, courseCurriculum.Disciplines); |
| | 62 | |
|
| 0 | 63 | | var breakpoint = await BrowserViewportService.GetCurrentBreakpointAsync(); |
| 0 | 64 | | var options = new DialogOptions { |
| 0 | 65 | | MaxWidth = MaxWidth.Medium, |
| 0 | 66 | | FullWidth = true, |
| 0 | 67 | | FullScreen = breakpoint == Breakpoint.Xs, |
| 0 | 68 | | }; |
| 0 | 69 | | await DialogService.ShowAsync<CourseCurriculumDisciplinesDialog>(courseCurriculum.Name, parameters, options); |
| 0 | 70 | | } |
| | 71 | |
|
| 0 | 72 | | private Func<CourseCurriculumOut, bool> _quickFilter => x => _searchString.IsIn(x.Name, x.CourseName); |
| | 73 | |
|
| | 74 | | private async Task OpenDialog() |
| | 75 | | { |
| 0 | 76 | | var breakpoint = await BrowserViewportService.GetCurrentBreakpointAsync(); |
| 0 | 77 | | var options = new DialogOptions { |
| 0 | 78 | | MaxWidth = MaxWidth.Medium, |
| 0 | 79 | | FullWidth = true, |
| 0 | 80 | | FullScreen = breakpoint.IsIn(Breakpoint.Xs, Breakpoint.Sm), |
| 0 | 81 | | }; |
| 0 | 82 | | var dialog = await DialogService.ShowAsync<CreateCourseCurriculumDialog>("", options); |
| | 83 | |
|
| 0 | 84 | | var result = await dialog.Result; |
| | 85 | |
|
| 0 | 86 | | if (result!.Canceled) return; |
| | 87 | |
|
| 0 | 88 | | await OnInitializedAsync(); |
| 0 | 89 | | } |
| | 90 | |
|
| | 91 | | private string GetNotFoundMessage() |
| | 92 | | { |
| 0 | 93 | | return (_searchString.IsEmpty()) ? "Não existem grades cadastradas ainda." : "Nenhuma grade encontrada."; |
| | 94 | | } |
| | 95 | | } |