| | 1 | | @using Syki.Front.Features.Academic.CreateCourseOffering |
| | 2 | |
|
| | 3 | | @namespace Syki.Front.Pages.Academic |
| | 4 | |
|
| | 5 | | @page "/academic/course-offerings" |
| | 6 | | @attribute [Authorize(Roles = "Academic")] |
| | 7 | |
|
| | 8 | | <SykiPageTitle Title="Ofertas" /> |
| | 9 | |
|
| | 10 | | <MudContainer Class="my-4 px-4"> |
| | 11 | | <SykiPageHeader Icon="@Icons.Material.Filled.PlaylistAddCheck" Title="Ofertas" ButtonText="Nova Oferta" OnClick="@Op |
| | 12 | | <SykiPageAlert Text="Uma oferta de curso pode acontecer a cada período, com variações de campus, turno e grade." /> |
| | 13 | | <MudContainer Class="px-0 mb-4"> |
| | 14 | | <MudDataGrid Class="pa-4" Items="@_ofertas" QuickFilter="@_quickFilter" Hover="true" Loading="@_loading" Dense=" |
| | 15 | | <ToolBarContent> |
| | 16 | | <SykiDataGridSearchTextField @bind-Value="@_searchString" Placeholder="Busque por qualquer atributo" /> |
| | 17 | | </ToolBarContent> |
| | 18 | | <Columns> |
| | 19 | | <PropertyColumn Property="x => x.Campus" Title="Campus" /> |
| | 20 | | <PropertyColumn Property="x => x.Period" Title="Período" /> |
| | 21 | | <PropertyColumn Property="x => x.Shift.GetDescription()" Title="Turno" /> |
| | 22 | | <PropertyColumn Property="x => x.Course" Title="Curso" /> |
| | 23 | | <PropertyColumn Property="x => x.CourseCurriculum" Title="Grade" /> |
| | 24 | | </Columns> |
| | 25 | | <NoRecordsContent> |
| | 26 | | @(GetNotFoundMessage()) |
| | 27 | | </NoRecordsContent> |
| | 28 | | <PagerContent> |
| | 29 | | <SykiDataGridPager T="CourseOfferingOut" /> |
| | 30 | | </PagerContent> |
| | 31 | | </MudDataGrid> |
| | 32 | | </MudContainer> |
| | 33 | | </MudContainer> |
| | 34 | |
|
| | 35 | | @inject IDialogService DialogService |
| | 36 | | @inject GetCourseOfferingsClient GetCourseOfferingsClient |
| | 37 | | @inject IBrowserViewportService BrowserViewportService |
| | 38 | |
|
| | 39 | | @code |
| | 40 | | { |
| | 41 | | private bool _loading; |
| | 42 | | private string _searchString; |
| 0 | 43 | | private List<CourseOfferingOut> _ofertas = []; |
| | 44 | |
|
| | 45 | | protected override async Task OnInitializedAsync() |
| | 46 | | { |
| 0 | 47 | | _loading = true; |
| 0 | 48 | | _ofertas = await GetCourseOfferingsClient.Get(); |
| 0 | 49 | | _loading = false; |
| 0 | 50 | | } |
| | 51 | |
|
| 0 | 52 | | private Func<CourseOfferingOut, bool> _quickFilter => x => |
| 0 | 53 | | _searchString.IsIn(x.Campus, x.Period, x.Shift.GetDescription(), x.Course, x.CourseCurriculum); |
| | 54 | |
|
| | 55 | | private async Task OpenDialog() |
| | 56 | | { |
| 0 | 57 | | var breakpoint = await BrowserViewportService.GetCurrentBreakpointAsync(); |
| 0 | 58 | | var options = new DialogOptions { |
| 0 | 59 | | MaxWidth = MaxWidth.Small, |
| 0 | 60 | | FullWidth = true, |
| 0 | 61 | | FullScreen = breakpoint == Breakpoint.Xs, |
| 0 | 62 | | }; |
| 0 | 63 | | var dialog = await DialogService.ShowAsync<CreateCourseOfferingDialog>("", options); |
| | 64 | |
|
| 0 | 65 | | var result = await dialog.Result; |
| | 66 | |
|
| 0 | 67 | | if (result!.Canceled) return; |
| | 68 | |
|
| 0 | 69 | | await OnInitializedAsync(); |
| 0 | 70 | | } |
| | 71 | |
|
| | 72 | | private string GetNotFoundMessage() |
| | 73 | | { |
| 0 | 74 | | return (_searchString.IsEmpty()) ? "Não existem ofertas cadastradas ainda." : "Nenhuma oferta encontrada."; |
| | 75 | | } |
| | 76 | | } |