| | 1 | | @namespace Syki.Front.Pages.Academic |
| | 2 | |
|
| | 3 | | @page "/academic/enrollment-periods" |
| | 4 | | @attribute [Authorize(Roles = "Academic")] |
| | 5 | |
|
| | 6 | | <SykiPageTitle Title="Matrículas" /> |
| | 7 | |
|
| | 8 | | <MudContainer Class="my-4 px-4"> |
| | 9 | | <SykiPageHeader Icon="@Icons.Material.Filled.Article" Title="Matrículas" ButtonText="Período de Matrícula" OnClick=" |
| | 10 | | <SykiPageAlert Text="Utilize os períodos de matrícula para organizar as informações durante o ano letivo."/> |
| | 11 | | <MudContainer Class="px-0 mb-4"> |
| | 12 | | <MudDataGrid Class="pa-4" Items="@_periodos" QuickFilter="@_quickFilter" Hover="true" Loading="@_loading" Dense= |
| | 13 | | <ToolBarContent> |
| | 14 | | <SykiDataGridSearchTextField @bind-Value="@_searchString" Placeholder="Busque por ano"/> |
| | 15 | | </ToolBarContent> |
| | 16 | | <Columns> |
| | 17 | | <PropertyColumn Property="x => x.Id" Title="Id" /> |
| | 18 | | <PropertyColumn Property="x => x.StartAt" Title="Início" /> |
| | 19 | | <PropertyColumn Property="x => x.EndAt" Title="Fim" /> |
| | 20 | | <TemplateColumn CellClass="d-flex justify-end"> |
| | 21 | | <CellTemplate> |
| 0 | 22 | | <MudIconButton Size="@Size.Small" Icon="@Icons.Material.Outlined.Edit" OnClick="@(() => OpenEdit |
| | 23 | | </CellTemplate> |
| | 24 | | </TemplateColumn> |
| | 25 | | </Columns> |
| | 26 | | <NoRecordsContent> |
| | 27 | | @(GetNotFoundMessage()) |
| | 28 | | </NoRecordsContent> |
| | 29 | | <PagerContent> |
| | 30 | | <SykiDataGridPager T="@EnrollmentPeriodOut" /> |
| | 31 | | </PagerContent> |
| | 32 | | </MudDataGrid> |
| | 33 | | </MudContainer> |
| | 34 | | </MudContainer> |
| | 35 | |
|
| | 36 | | @inject IDialogService DialogService |
| | 37 | | @inject GetEnrollmentPeriodsClient Client |
| | 38 | | @inject IBrowserViewportService BrowserViewportService |
| | 39 | |
|
| | 40 | | @code |
| | 41 | | { |
| | 42 | | private bool _loading; |
| | 43 | | private string _searchString; |
| 0 | 44 | | private List<EnrollmentPeriodOut> _periodos = []; |
| | 45 | |
|
| | 46 | | protected override async Task OnInitializedAsync() |
| | 47 | | { |
| 0 | 48 | | _loading = true; |
| 0 | 49 | | _periodos = await Client.Get(); |
| 0 | 50 | | _loading = false; |
| 0 | 51 | | } |
| | 52 | |
|
| 0 | 53 | | private Func<EnrollmentPeriodOut, bool> _quickFilter => x => _searchString.IsIn(x.Id); |
| | 54 | |
|
| | 55 | | private async Task OpenDialog() |
| | 56 | | { |
| 0 | 57 | | var breakpoint = await BrowserViewportService.GetCurrentBreakpointAsync(); |
| 0 | 58 | | var options = new DialogOptions { |
| 0 | 59 | | MaxWidth = MaxWidth.ExtraSmall, |
| 0 | 60 | | FullWidth = true, |
| 0 | 61 | | FullScreen = breakpoint == Breakpoint.Xs, |
| 0 | 62 | | }; |
| | 63 | |
|
| 0 | 64 | | var dialog = await DialogService.ShowAsync<CreateEnrollmentPeriodDialog>("", options); |
| | 65 | |
|
| 0 | 66 | | var result = await dialog.Result; |
| | 67 | |
|
| 0 | 68 | | if (result!.Canceled) return; |
| | 69 | |
|
| 0 | 70 | | await OnInitializedAsync(); |
| 0 | 71 | | } |
| | 72 | |
|
| | 73 | | private async Task OpenEditDialog(EnrollmentPeriodOut item) |
| | 74 | | { |
| 0 | 75 | | var parameters = new DialogParameters<UpdateEnrollmentPeriodDialog>(); |
| 0 | 76 | | parameters.Add(x => x.Period, item); |
| | 77 | |
|
| 0 | 78 | | var breakpoint = await BrowserViewportService.GetCurrentBreakpointAsync(); |
| 0 | 79 | | var options = new DialogOptions { |
| 0 | 80 | | MaxWidth = MaxWidth.ExtraSmall, |
| 0 | 81 | | FullWidth = true, |
| 0 | 82 | | FullScreen = breakpoint == Breakpoint.Xs, |
| 0 | 83 | | }; |
| 0 | 84 | | var dialog = await DialogService.ShowAsync<UpdateEnrollmentPeriodDialog>("", parameters, options); |
| | 85 | |
|
| 0 | 86 | | var result = await dialog.Result; |
| | 87 | |
|
| 0 | 88 | | if (result!.Canceled) return; |
| | 89 | |
|
| 0 | 90 | | await OnInitializedAsync(); |
| 0 | 91 | | } |
| | 92 | |
|
| | 93 | | private string GetNotFoundMessage() |
| | 94 | | { |
| 0 | 95 | | return (_searchString.IsEmpty()) ? "Não existem períodos de matrícula cadastrados ainda." : "Nenhum período de m |
| | 96 | | } |
| | 97 | | } |