< Summary

Information
Class: Syki.Front.Features.Academic.CreateCourseCurriculum.CourseCurriculumDiscipline
Assembly: Front
File(s): /home/runner/work/syki/syki/Front/Features/Academic/CreateCourseCurriculum/CourseCurriculumDiscipline.razor
Tag: 22_11348620282
Line coverage
0%
Covered lines: 0
Uncovered lines: 29
Coverable lines: 29
Total lines: 138
Line coverage: 0%
Branch coverage
0%
Covered branches: 0
Total branches: 10
Branch coverage: 0%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
get_Options()100%210%
get_OnDeleteClick()100%210%
get_Data()100%210%
SearchDiscipline()0%620%
HandleDisciplineChanged(...)0%620%
HandlePeriodoChanged(...)100%210%
HandleCreditosChanged(...)100%210%
HandleCargaHorariaChanged(...)100%210%
HandleDeleteClick()100%210%

File(s)

/home/runner/work/syki/syki/Front/Features/Academic/CreateCourseCurriculum/CourseCurriculumDiscipline.razor

#LineLine coverage
 1@namespace Syki.Front.Features.Academic.CreateCourseCurriculum
 2
 3<MudForm Class="mx-0">
 4    <MudGrid Spacing="2">
 5        <MudItem xs="12" sm="12" md="6" lg="6">
 6            <MudStack Row="true" Spacing="2">
 7                <MudItem xs="4">
 8                    <MudSelect
 9                        Dense="true"
 10                        Margin="Margin.Dense"
 11                        Variant="Variant.Outlined"
 12                        T="byte?"
 13                        Value="@Data.Period"
 014                        ValueChanged="x => HandlePeriodoChanged(x)"
 15                        Label="Período"
 16                        Required="true"
 17                        RequiredError="Informe!"
 18                        AdornmentColor="Color.Primary">
 019                        @foreach (byte? item in Enumerable.Range(1, 10).ToList())
 20                        {
 21                        <MudSelectItem Value="@item">@($"{item}º")</MudSelectItem>
 22                        }
 23                    </MudSelect>
 24                </MudItem>
 25                <MudItem xs="4">
 26                    <MudNumericField
 27                        MaxLength="2"
 28                        HideSpinButtons="true"
 29                        Margin="Margin.Dense"
 30                        Variant="Variant.Outlined"
 31                        T="byte?"
 32                        Value="@Data.Credits"
 033                        ValueChanged="x => HandleCreditosChanged(x)"
 34                        Label="Créditos"
 35                        Required="true"
 36                        RequiredError="Informe!"/>
 37                </MudItem>
 38                <MudItem xs="4">
 39                    <MudNumericField
 40                        MaxLength="3"
 41                        HideSpinButtons="true"
 42                        Margin="Margin.Dense"
 43                        Variant="Variant.Outlined"
 44                        T="ushort?"
 45                        Value="@Data.Workload"
 046                        ValueChanged="x => HandleCargaHorariaChanged(x)"
 47                        Label="Carga"
 48                        Required="true"
 49                        RequiredError="Informe!"/>
 50                </MudItem>
 51
 52            </MudStack>
 53        </MudItem>
 54
 55        <MudItem xs="12" sm="12" md="6" lg="6">
 56            <MudStack Row="true" Spacing="2">
 57                <MudItem xs="11">
 58                    <MudAutocomplete
 59                        MaxItems="50"
 60                        T="CourseCurriculumDisciplineFillable"
 61                        SearchFunc="@SearchDiscipline"
 62                        Dense="true"
 63                        Margin="Margin.Dense"
 64                        Variant="Variant.Outlined"
 65                        Class="mb-2"
 66                        Value="@Data"
 067                        ValueChanged="(CourseCurriculumDisciplineFillable newValue) => HandleDisciplineChanged(newValue)
 68                        Label="Disciplina"
 69                        Required="true"
 70                        RequiredError="Informe!"
 71                        AdornmentColor="Color.Primary"
 72                    />
 73                </MudItem>
 74                <MudItem>
 75                    <MudIconButton Icon="@Icons.Material.Filled.Delete" Size="Size.Medium" OnClick="@HandleDeleteClick"/
 76                </MudItem>
 77            </MudStack>
 78        </MudItem>
 79    </MudGrid>
 80</MudForm>
 81
 82@code
 83{
 84    [CascadingParameter(Name = "Options")]
 085    public List<CourseDisciplineOut> Options { get; set; }
 86
 87    [Parameter]
 088    public EventCallback<Guid> OnDeleteClick { get; set; }
 89
 90    [Parameter]
 091    public CourseCurriculumDisciplineFillable Data { get; set; }
 92
 93    private async Task<IEnumerable<CourseCurriculumDisciplineFillable>> SearchDiscipline(string value, CancellationToken
 94    {
 095        await Task.Delay(0);
 96
 097        var filtered = Options.Where(d => !d.IsSelected || (d.IsSelected && d.Id == Data.Id))
 098            .ToList().ConvertAll(x => new CourseCurriculumDisciplineFillable { Id = x.Id, Name = x.Name });
 99
 0100        if (string.IsNullOrEmpty(value))
 0101            return filtered;
 102
 0103        return filtered.Where(x => x.Name.Contains(value, StringComparison.InvariantCultureIgnoreCase));
 0104    }
 105
 106    private void HandleDisciplineChanged(CourseCurriculumDisciplineFillable newValue)
 107    {
 0108        Options.First(d => d.Id == newValue.Id).IsSelected = true;
 109
 0110        if (Options.Any(x => x.Id == Data.Id))
 111        {
 0112            Options.First(d => d.Id == Data.Id).IsSelected = false;
 113        }
 114
 0115        Data.Id = newValue.Id;
 0116        Data.Name = newValue.Name;
 0117    }
 118
 119    private void HandlePeriodoChanged(byte? newValue)
 120    {
 0121        Data.Period = newValue;
 0122    }
 123
 124    private void HandleCreditosChanged(byte? newValue)
 125    {
 0126        Data.Credits = newValue;
 0127    }
 128
 129    private void HandleCargaHorariaChanged(ushort? newValue)
 130    {
 0131        Data.Workload = newValue;
 0132    }
 133
 134    private async Task HandleDeleteClick()
 135    {
 0136        await OnDeleteClick.InvokeAsync(Data.Id);
 0137    }
 138}