| | 1 | | @namespace Syki.Front.Features.Teacher.AddExamGradeNote |
| | 2 | |
|
| | 3 | | <MudDialog Class="pb-2" @bind-Visible="@_visible" Options="@_options"> |
| | 4 | | <TitleContent> |
| | 5 | | <SykiDialogTitle Text="Adicionar notas" /> |
| | 6 | | </TitleContent> |
| | 7 | | <DialogContent> |
| | 8 | | <MudText Typo="Typo.h6" Class="px-0 py-2">@_item.Name</MudText> |
| 0 | 9 | | <MudForm @ref="@_form" Class="px-0 pt-2"> |
| 0 | 10 | | @foreach (var grade in _item.ExamGrades) |
| 0 | 11 | | { |
| 0 | 12 | | <ExamGradeNoteField Data="@grade" /> |
| 0 | 13 | | } |
| 0 | 14 | | </MudForm> |
| | 15 | | </DialogContent> |
| | 16 | | <DialogActions> |
| | 17 | | <DialogCancelButton OnClick="@Close" /> |
| | 18 | | <SykiProgressCircular Loading="@_loading" /> |
| | 19 | | <DialogSaveButton OnClick="@Submit" /> |
| | 20 | | </DialogActions> |
| | 21 | | </MudDialog> |
| | 22 | |
|
| | 23 | | @inject AddExamGradeNoteClient Client |
| | 24 | | @inject IBrowserViewportService BrowserViewportService |
| | 25 | |
|
| | 26 | | @code |
| | 27 | | { |
| | 28 | | private bool _visible; |
| | 29 | | private MudForm _form; |
| | 30 | | private bool _loading; |
| 0 | 31 | | private TeacherClassStudentOut _item = new(); |
| 0 | 32 | | private List<CompareExamGradeOut> _initialValues = []; |
| | 33 | |
|
| 0 | 34 | | private readonly DialogOptions _options = new() |
| 0 | 35 | | { |
| 0 | 36 | | FullWidth = true, |
| 0 | 37 | | CloseButton = true, |
| 0 | 38 | | MaxWidth = MaxWidth.ExtraSmall, |
| 0 | 39 | | }; |
| | 40 | |
|
| | 41 | | [Parameter] |
| 0 | 42 | | public EventCallback AfterSubmit { get; set; } |
| | 43 | |
|
| | 44 | | public async Task Open(TeacherClassStudentOut item) |
| | 45 | | { |
| 0 | 46 | | var breakpoint = await BrowserViewportService.GetCurrentBreakpointAsync(); |
| 0 | 47 | | _options.FullScreen = breakpoint == Breakpoint.Xs; |
| 0 | 48 | | _item = item; |
| 0 | 49 | | _initialValues = item.ExamGrades.Select(x => new CompareExamGradeOut() { ExamType = x.ExamType, Note = x.Note }) |
| 0 | 50 | | _visible = true; |
| 0 | 51 | | } |
| | 52 | |
|
| | 53 | | private void Close() |
| | 54 | | { |
| 0 | 55 | | _visible = false; |
| 0 | 56 | | } |
| | 57 | |
|
| | 58 | | private async Task Submit() |
| | 59 | | { |
| 0 | 60 | | _loading = true; |
| 0 | 61 | | foreach (var examGrade in _item.ExamGrades) |
| | 62 | | { |
| 0 | 63 | | var initial = _initialValues.First(x => x.ExamType == examGrade.ExamType); |
| 0 | 64 | | if (examGrade.Note == initial.Note) continue; |
| | 65 | |
|
| 0 | 66 | | await Client.Add(examGrade.Id, new(examGrade.Note)); |
| | 67 | | } |
| | 68 | |
|
| 0 | 69 | | Close(); |
| 0 | 70 | | await AfterSubmit.InvokeAsync(); |
| 0 | 71 | | _loading = false; |
| 0 | 72 | | } |
| | 73 | | } |