| | 1 | | @namespace Syki.Front.Pages.Academic |
| | 2 | |
|
| | 3 | | @page "/academic/academic-periods" |
| | 4 | | @attribute [Authorize(Roles = "Academic")] |
| | 5 | |
|
| | 6 | | <SykiPageTitle Title="Períodos" /> |
| | 7 | |
|
| | 8 | | <MudContainer Class="my-4 px-4"> |
| | 9 | | <SykiPageHeader Icon="@Icons.Material.Filled.CalendarMonth" Title="Períodos" ButtonText="Período Acadêmico" OnClick= |
| | 10 | | <SykiPageAlert Text="Utilize os períodos acadêmicos para organizar as informações durante o ano letivo." /> |
| | 11 | | <MudContainer Class="px-0 mb-4"> |
| | 12 | | <MudDataGrid Class="pa-4" Items="@_periods" 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 | | </Columns> |
| | 21 | | <NoRecordsContent> |
| | 22 | | @(GetNotFoundMessage()) |
| | 23 | | </NoRecordsContent> |
| | 24 | | <PagerContent> |
| | 25 | | <SykiDataGridPager T="@AcademicPeriodOut" /> |
| | 26 | | </PagerContent> |
| | 27 | | </MudDataGrid> |
| | 28 | | </MudContainer> |
| | 29 | | </MudContainer> |
| | 30 | |
|
| | 31 | | @inject IDialogService DialogService |
| | 32 | | @inject GetAcademicPeriodsClient Client |
| | 33 | | @inject IBrowserViewportService BrowserViewportService |
| | 34 | |
|
| | 35 | | @code |
| | 36 | | { |
| | 37 | | private bool _loading; |
| | 38 | | private string _searchString; |
| 0 | 39 | | private List<AcademicPeriodOut> _periods = []; |
| | 40 | |
|
| | 41 | | protected override async Task OnInitializedAsync() |
| | 42 | | { |
| 0 | 43 | | _loading = true; |
| 0 | 44 | | _periods = await Client.Get(); |
| 0 | 45 | | _loading = false; |
| 0 | 46 | | } |
| | 47 | |
|
| 0 | 48 | | private Func<AcademicPeriodOut, bool> _quickFilter => x => _searchString.IsIn(x.Id); |
| | 49 | |
|
| | 50 | | private async Task OpenDialog() |
| | 51 | | { |
| 0 | 52 | | var breakpoint = await BrowserViewportService.GetCurrentBreakpointAsync(); |
| 0 | 53 | | var options = new DialogOptions { |
| 0 | 54 | | MaxWidth = MaxWidth.ExtraSmall, |
| 0 | 55 | | FullWidth = true, |
| 0 | 56 | | FullScreen = breakpoint == Breakpoint.Xs, |
| 0 | 57 | | }; |
| | 58 | |
|
| 0 | 59 | | var dialog = await DialogService.ShowAsync<CreateAcademicPeriodDialog>("", options); |
| | 60 | |
|
| 0 | 61 | | var result = await dialog.Result; |
| | 62 | |
|
| 0 | 63 | | if (result!.Canceled) return; |
| | 64 | |
|
| 0 | 65 | | await OnInitializedAsync(); |
| 0 | 66 | | } |
| | 67 | |
|
| | 68 | | private string GetNotFoundMessage() |
| | 69 | | { |
| 0 | 70 | | return (_searchString.IsEmpty()) ? "Não existem períodos acadêmicos cadastrados ainda." : "Nenhum período acadêm |
| | 71 | | } |
| | 72 | | } |