| | 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" |
| 0 | 14 | | ValueChanged="x => HandlePeriodoChanged(x)" |
| | 15 | | Label="Período" |
| | 16 | | Required="true" |
| | 17 | | RequiredError="Informe!" |
| | 18 | | AdornmentColor="Color.Primary"> |
| 0 | 19 | | @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" |
| 0 | 33 | | 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" |
| 0 | 46 | | 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" |
| 0 | 67 | | 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")] |
| 0 | 85 | | public List<CourseDisciplineOut> Options { get; set; } |
| | 86 | |
|
| | 87 | | [Parameter] |
| 0 | 88 | | public EventCallback<Guid> OnDeleteClick { get; set; } |
| | 89 | |
|
| | 90 | | [Parameter] |
| 0 | 91 | | public CourseCurriculumDisciplineFillable Data { get; set; } |
| | 92 | |
|
| | 93 | | private async Task<IEnumerable<CourseCurriculumDisciplineFillable>> SearchDiscipline(string value, CancellationToken |
| | 94 | | { |
| 0 | 95 | | await Task.Delay(0); |
| | 96 | |
|
| 0 | 97 | | var filtered = Options.Where(d => !d.IsSelected || (d.IsSelected && d.Id == Data.Id)) |
| 0 | 98 | | .ToList().ConvertAll(x => new CourseCurriculumDisciplineFillable { Id = x.Id, Name = x.Name }); |
| | 99 | |
|
| 0 | 100 | | if (string.IsNullOrEmpty(value)) |
| 0 | 101 | | return filtered; |
| | 102 | |
|
| 0 | 103 | | return filtered.Where(x => x.Name.Contains(value, StringComparison.InvariantCultureIgnoreCase)); |
| 0 | 104 | | } |
| | 105 | |
|
| | 106 | | private void HandleDisciplineChanged(CourseCurriculumDisciplineFillable newValue) |
| | 107 | | { |
| 0 | 108 | | Options.First(d => d.Id == newValue.Id).IsSelected = true; |
| | 109 | |
|
| 0 | 110 | | if (Options.Any(x => x.Id == Data.Id)) |
| | 111 | | { |
| 0 | 112 | | Options.First(d => d.Id == Data.Id).IsSelected = false; |
| | 113 | | } |
| | 114 | |
|
| 0 | 115 | | Data.Id = newValue.Id; |
| 0 | 116 | | Data.Name = newValue.Name; |
| 0 | 117 | | } |
| | 118 | |
|
| | 119 | | private void HandlePeriodoChanged(byte? newValue) |
| | 120 | | { |
| 0 | 121 | | Data.Period = newValue; |
| 0 | 122 | | } |
| | 123 | |
|
| | 124 | | private void HandleCreditosChanged(byte? newValue) |
| | 125 | | { |
| 0 | 126 | | Data.Credits = newValue; |
| 0 | 127 | | } |
| | 128 | |
|
| | 129 | | private void HandleCargaHorariaChanged(ushort? newValue) |
| | 130 | | { |
| 0 | 131 | | Data.Workload = newValue; |
| 0 | 132 | | } |
| | 133 | |
|
| | 134 | | private async Task HandleDeleteClick() |
| | 135 | | { |
| 0 | 136 | | await OnDeleteClick.InvokeAsync(Data.Id); |
| 0 | 137 | | } |
| | 138 | | } |