< Summary

Information
Class: Syki.Front.Pages.Academic.AcademicCampiPage
Assembly: Front
File(s): /home/runner/work/syki/syki/Front/Pages/Academic/AcademicCampiPage.razor
Tag: 22_11348620282
Line coverage
0%
Covered lines: 0
Uncovered lines: 32
Coverable lines: 32
Total lines: 109
Line coverage: 0%
Branch coverage
0%
Covered branches: 0
Total branches: 6
Branch coverage: 0%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
.ctor()100%210%
OnInitializedAsync()100%210%
get__quickFilter()100%210%
OpenDialog()0%620%
OpenEditDialog()0%620%
GetNotFoundMessage()0%620%

File(s)

/home/runner/work/syki/syki/Front/Pages/Academic/AcademicCampiPage.razor

#LineLine coverage
 1@using Syki.Front.Features.Academic.GetCampi
 2@using Syki.Front.Features.Academic.CreateCampus
 3@using Syki.Front.Features.Academic.UpdateCampus
 4
 5@namespace Syki.Front.Pages.Academic
 6
 7@page "/academic/campi"
 8@attribute [Authorize(Roles = "Academic")]
 9
 10<SykiPageTitle Title="Campi" />
 11
 12<MudContainer Class="my-4 px-4">
 13    <SykiPageHeader Icon="@Icons.Material.Filled.GroupWork" Title="Campi" ButtonText="Novo Campus" OnClick="@OpenDialog"
 14    <SykiPageAlert Text="Sua instituição pode ser formada por vários campus." />
 15    <MudContainer Class="px-0 mb-4">
 16        <MudDataGrid
 17            T="CampusOut"
 18            Class="pa-4"
 19            Items="@_campi"
 20            QuickFilter="@_quickFilter"
 21            Dense="true"
 22            Hover="true"
 23            ReadOnly="true"
 24            Loading="@_loading"
 25            RowsPerPage="10"
 26        >
 27            <ToolBarContent>
 28                <SykiDataGridSearchTextField @bind-Value="@_searchString" Placeholder="Busque por nome ou cidade" />
 29            </ToolBarContent>
 30            <Columns>
 31                <PropertyColumn Property="x => x.Name" Title="Nome" />
 32                <PropertyColumn Property="x => x.City" Title="Cidade" />
 33                <TemplateColumn CellClass="d-flex justify-end">
 34                    <CellTemplate>
 035                        <MudIconButton Size="@Size.Small" Icon="@Icons.Material.Outlined.Edit" OnClick="@(() => OpenEdit
 36                    </CellTemplate>
 37                </TemplateColumn>
 38            </Columns>
 39            <NoRecordsContent>
 40                @(GetNotFoundMessage())
 41            </NoRecordsContent>
 42            <PagerContent>
 43                <SykiDataGridPager T="@CampusOut" />
 44            </PagerContent>
 45        </MudDataGrid>
 46    </MudContainer>
 47</MudContainer>
 48
 49@inject GetCampiClient Client
 50@inject IDialogService DialogService
 51@inject IBrowserViewportService BrowserViewportService
 52
 53@code
 54{
 55    private bool _loading;
 56    private string _searchString;
 057    private List<CampusOut> _campi = [];
 58
 59    protected override async Task OnInitializedAsync()
 60    {
 061        _loading = true;
 062        _campi = await Client.Get();
 063        _loading = false;
 064    }
 65
 066    private Func<CampusOut, bool> _quickFilter => x => _searchString.IsIn(x.Name, x.City);
 67
 68    private async Task OpenDialog()
 69    {
 070        var breakpoint = await BrowserViewportService.GetCurrentBreakpointAsync();
 071        var options = new DialogOptions {
 072            MaxWidth = MaxWidth.Small,
 073            FullWidth = true,
 074            FullScreen = breakpoint == Breakpoint.Xs,
 075        };
 076        var dialog = await DialogService.ShowAsync<CreateCampusDialog>("", options);
 77
 078        var result = await dialog.Result;
 79
 080        if (result!.Canceled) return;
 81
 082        await OnInitializedAsync();
 083    }
 84
 85    private async Task OpenEditDialog(CampusOut item)
 86    {
 087        var parameters = new DialogParameters<UpdateCampusDialog>();
 088        parameters.Add(x => x.Campus, item);
 89
 090        var breakpoint = await BrowserViewportService.GetCurrentBreakpointAsync();
 091        var options = new DialogOptions {
 092            MaxWidth = MaxWidth.Small,
 093            FullWidth = true,
 094            FullScreen = breakpoint == Breakpoint.Xs,
 095        };
 096        var dialog = await DialogService.ShowAsync<UpdateCampusDialog>("", parameters, options);
 97
 098        var result = await dialog.Result;
 99
 0100        if (result!.Canceled) return;
 101
 0102        await OnInitializedAsync();
 0103    }
 104
 105    private string GetNotFoundMessage()
 106    {
 0107        return (_searchString.IsEmpty()) ? "Não existem campus cadastrados ainda." : "Nenhum campus encontrado.";
 108    }
 109}