| | 1 | | @using Syki.Front.Features.Teacher.CreateClassActivity |
| | 2 | |
|
| | 3 | | @namespace Syki.Front.Pages.Teacher |
| | 4 | |
|
| | 5 | | <MudContainer Class="mb-4 px-0"> |
| | 6 | | <MudCard> |
| | 7 | | <MudCardContent Class="px-6"> |
| | 8 | | <SykiPageHeader Icon="@Icons.Material.Filled.EditNote" Title="Atividades" ButtonText="Nova Atividade" OnClic |
| | 9 | | </MudCardContent> |
| | 10 | | </MudCard> |
| | 11 | |
|
| | 12 | | <style>.mud-table-toolbar { height: auto }</style> |
| | 13 | | <MudDataGrid |
| | 14 | | T="TeacherClassActivityOut" |
| | 15 | | Class="pa-4 mt-4" |
| | 16 | | Items="@GetActivities()" |
| | 17 | | QuickFilter="@_quickFilter" |
| | 18 | | Hover="true" |
| | 19 | | Dense="true" |
| | 20 | | Loading="@_loading" |
| | 21 | | SortMode="@SortMode.None" |
| | 22 | | RowsPerPage="100" |
| | 23 | | > |
| | 24 | | <ToolBarContent> |
| | 25 | | <MudGrid Class="align-center" Spacing="3"> |
| | 26 | | <MudItem xs="12" sm="3" md="3" lg="3"> |
| | 27 | | <MudStack Row="true" AlignItems="AlignItems.Center" Spacing="3" Style="width: 100%;"> |
| | 28 | | <MudToggleGroup T="ClassNoteType" SelectionMode="SelectionMode.MultiSelection" Values="@_notesFi |
| | 29 | | <MudToggleItem Value="@(ClassNoteType.N1)" UnselectedIcon="@Icons.Material.Filled.CheckBoxOu |
| | 30 | | <MudToggleItem Value="@(ClassNoteType.N2)" UnselectedIcon="@Icons.Material.Filled.CheckBoxOu |
| | 31 | | <MudToggleItem Value="@(ClassNoteType.N3)" UnselectedIcon="@Icons.Material.Filled.CheckBoxOu |
| | 32 | | </MudToggleGroup> |
| | 33 | | </MudStack> |
| | 34 | | </MudItem> |
| | 35 | | <MudItem xs="12" sm="9" md="9" lg="9" Class="d-flex justify-end"> |
| | 36 | | <SykiDataGridSearchTextField @bind-Value="@_searchString" Placeholder="Busque por título" /> |
| | 37 | | </MudItem> |
| | 38 | | </MudGrid> |
| | 39 | | </ToolBarContent> |
| | 40 | | <Columns> |
| | 41 | | <PropertyColumn Property="x => x.Title" Title="Título" /> |
| | 42 | | <PropertyColumn Property="x => x.Type.GetDescription()" Title="Tipo" /> |
| | 43 | | <PropertyColumn Property="x => x.Note.GetDescription()" Title="Nota" /> |
| | 44 | | <PropertyColumn Property="x => x.Weight" Title="Peso (%)" /> |
| | 45 | | <PropertyColumn Property="x => x.CreatedAt.ToLocalTime().Format()" Title="Criada em" /> |
| | 46 | | <PropertyColumn Property="x => x.GetDueDate()" Title="Data de entrega" /> |
| | 47 | | <TemplateColumn Title="Entregas"> |
| | 48 | | <CellTemplate> |
| | 49 | | <MudProgressLinear Color="@GetDeliveryRateColor(context.Item.GetDeliveryRate())" Rounded="true" Size |
| | 50 | | <MudText Typo="Typo.body1"> |
| 0 | 51 | | <b>@GetDeliveryRateFraction(context.Item)</b> |
| | 52 | | </MudText> |
| | 53 | | </MudProgressLinear> |
| | 54 | | </CellTemplate> |
| | 55 | | </TemplateColumn> |
| | 56 | | <TemplateColumn> |
| | 57 | | <CellTemplate> |
| 0 | 58 | | <MudIconButton Size="@Size.Small" Icon="@Icons.Material.Filled.RemoveRedEye" OnClick="@(() => GoToDe |
| | 59 | | </CellTemplate> |
| | 60 | | </TemplateColumn> |
| | 61 | | </Columns> |
| | 62 | | <NoRecordsContent> |
| 0 | 63 | | @(GetNotFoundMessage()) |
| | 64 | | </NoRecordsContent> |
| | 65 | | <PagerContent> |
| | 66 | | </PagerContent> |
| | 67 | | </MudDataGrid> |
| | 68 | | </MudContainer> |
| | 69 | |
|
| | 70 | | @inject NavigationManager Nav |
| | 71 | | @inject IDialogService DialogService |
| | 72 | | @inject GetTeacherClassActivitiesClient GetTeacherClassActivitiesClient |
| | 73 | |
|
| | 74 | | @code |
| | 75 | | { |
| | 76 | | [Parameter] |
| 0 | 77 | | public Guid ClassId { get; set; } |
| | 78 | |
|
| | 79 | | private bool _loading; |
| | 80 | | private string _searchString; |
| 0 | 81 | | private List<TeacherClassActivityOut> _activities = []; |
| 0 | 82 | | private IEnumerable<ClassNoteType> _notesFilter = [ClassNoteType.N1, ClassNoteType.N2, ClassNoteType.N3]; |
| | 83 | |
|
| | 84 | | protected override async Task OnParametersSetAsync() |
| | 85 | | { |
| 0 | 86 | | await Load(); |
| 0 | 87 | | } |
| | 88 | |
|
| | 89 | | private async Task Load() |
| | 90 | | { |
| 0 | 91 | | _loading = true; |
| 0 | 92 | | _searchString = string.Empty; |
| 0 | 93 | | _notesFilter = [ClassNoteType.N1, ClassNoteType.N2, ClassNoteType.N3]; |
| 0 | 94 | | var response = await GetTeacherClassActivitiesClient.Get(ClassId); |
| 0 | 95 | | if (response.IsSuccess) |
| | 96 | | { |
| 0 | 97 | | _activities = response.Success; |
| | 98 | | } |
| 0 | 99 | | _loading = false; |
| 0 | 100 | | } |
| | 101 | |
|
| | 102 | | private void HandleNotesFilterChange(IEnumerable<ClassNoteType> newValues) |
| | 103 | | { |
| 0 | 104 | | if (!newValues.Any()) |
| | 105 | | { |
| 0 | 106 | | _notesFilter = _notesFilter.ToList(); |
| 0 | 107 | | return; |
| | 108 | | } |
| | 109 | |
|
| 0 | 110 | | _notesFilter = newValues; |
| 0 | 111 | | } |
| | 112 | |
|
| | 113 | | private List<TeacherClassActivityOut> GetActivities() |
| | 114 | | { |
| 0 | 115 | | return _activities.Where(x => _notesFilter.Contains(x.Note)).ToList(); |
| | 116 | | } |
| | 117 | |
|
| | 118 | | private void GoToDetails(Guid activityId) |
| | 119 | | { |
| 0 | 120 | | Nav.NavigateTo($"/teacher/classes/{ClassId}/activities/{activityId}"); |
| 0 | 121 | | } |
| | 122 | |
|
| | 123 | | private Task NewActivity() |
| | 124 | | { |
| 0 | 125 | | var parameters = new DialogParameters<CreateClassActivityDialog> |
| 0 | 126 | | { |
| 0 | 127 | | { x => x.ClassId, ClassId }, |
| 0 | 128 | | { x => x.AfterSubmit, EventCallback.Factory.Create(this, Load) } |
| 0 | 129 | | }; |
| | 130 | |
|
| 0 | 131 | | return DialogService.ShowAsync<CreateClassActivityDialog>("", parameters); |
| | 132 | | } |
| | 133 | |
|
| | 134 | | private string GetDeliveryRateFraction(TeacherClassActivityOut activity) |
| | 135 | | { |
| 0 | 136 | | return $"{activity.DeliveredWorks} / {activity.TotalWorks}"; |
| | 137 | | } |
| | 138 | |
|
| | 139 | | private Color GetDeliveryRateColor(decimal deliveryRate) |
| | 140 | | { |
| 0 | 141 | | if (deliveryRate == 100M) return Color.Success; |
| | 142 | |
|
| 0 | 143 | | return deliveryRate >= 70 ? Color.Warning : Color.Error; |
| | 144 | | } |
| | 145 | |
|
| 0 | 146 | | private Func<TeacherClassActivityOut, bool> _quickFilter => x => _searchString.IsIn(x.Title, x.Description); |
| | 147 | | private string GetNotFoundMessage() |
| | 148 | | { |
| 0 | 149 | | return _searchString.IsEmpty() && _notesFilter.Count() == 3 ? "Não existem atividades ainda." : "Nenhuma ativid |
| | 150 | | } |
| | 151 | | } |