| | | 1 | | @namespace Syki.Front.Features.Academic.ReleaseClassesForEnrollment |
| | | 2 | | |
| | | 3 | | <MudDialog Class="pb-2"> |
| | | 4 | | <TitleContent> |
| | | 5 | | <SykiDialogTitle Text="Liberar matrícula" Icon="@Icons.Material.Filled.Article" /> |
| | | 6 | | </TitleContent> |
| | | 7 | | <DialogContent> |
| | | 8 | | <style>.mud-table-toolbar { height: auto }</style> |
| | | 9 | | <MudTable |
| | | 10 | | T="ClassOut" |
| | | 11 | | Class="pa-4 mb-2" |
| | | 12 | | Items="@_classes" |
| | | 13 | | Filter="@_quickFilter" |
| | | 14 | | Hover |
| | | 15 | | Dense |
| | | 16 | | Loading="@_loading" |
| | | 17 | | RowsPerPage="100" |
| | | 18 | | ContainerClass="pt-0" |
| | | 19 | | > |
| | | 20 | | <ToolBarContent> |
| | | 21 | | <MudGrid Class="align-center" Spacing="3"> |
| | | 22 | | <MudItem xs="12" sm="5" md="5" lg="5"> |
| | 0 | 23 | | @if (_showButtons) |
| | | 24 | | { |
| | | 25 | | <MudStack Row AlignItems="AlignItems.Center" Spacing="3"> |
| | | 26 | | <MudButton OnClick="@SelectAll" Variant="Variant.Filled" StartIcon="@Icons.Material.Fill |
| | | 27 | | <MudButton OnClick="@UnselectAll" Variant="Variant.Filled" StartIcon="@Icons.Material.Fi |
| | | 28 | | </MudStack> |
| | | 29 | | } |
| | | 30 | | </MudItem> |
| | | 31 | | <MudItem xs="12" sm="7" md="7" lg="7" Class="d-flex justify-end"> |
| | | 32 | | <SykiDataGridSearchTextField @bind-Value="@_searchString" Placeholder="Busque por nome"/> |
| | | 33 | | </MudItem> |
| | | 34 | | </MudGrid> |
| | | 35 | | </ToolBarContent> |
| | | 36 | | <HeaderContent> |
| | | 37 | | <MudTh>Nome</MudTh> |
| | | 38 | | <MudTh>Professor</MudTh> |
| | | 39 | | <MudTh>Selecionada</MudTh> |
| | | 40 | | </HeaderContent> |
| | | 41 | | <RowTemplate> |
| | 0 | 42 | | <MudTd DataLabel="Disciplina">@context.Discipline</MudTd> |
| | 0 | 43 | | <MudTd DataLabel="Professor">@context.Teacher</MudTd> |
| | | 44 | | <MudTd DataLabel="Selecionada"> |
| | | 45 | | <MudCheckBox |
| | | 46 | | T="bool" |
| | | 47 | | Class="pl-7 pr-1" |
| | | 48 | | Dense |
| | | 49 | | Size="Size.Small" |
| | | 50 | | Color="Color.Success" |
| | | 51 | | Value="@context.IsSelected" |
| | 0 | 52 | | ValueChanged="x => { context.IsSelected = x; }"/> |
| | | 53 | | </MudTd> |
| | | 54 | | </RowTemplate> |
| | | 55 | | <NoRecordsContent> |
| | 0 | 56 | | @(GetNotFoundMessage()) |
| | | 57 | | </NoRecordsContent> |
| | | 58 | | <LoadingContent> |
| | 0 | 59 | | @if (_breakpoint == Breakpoint.Xs) |
| | | 60 | | { |
| | | 61 | | <MudProgressLinear Color="Color.Info" Indeterminate /> |
| | | 62 | | } |
| | | 63 | | </LoadingContent> |
| | | 64 | | <PagerContent> |
| | | 65 | | <MudDivider/> |
| | 0 | 66 | | @if (_showButtons) |
| | | 67 | | { |
| | | 68 | | <MudStack Row Class="mt-4"> |
| | | 69 | | <DialogCancelButton OnClick="@Cancel" /> |
| | | 70 | | <SykiProgressCircular Loading="@_loading" /> |
| | | 71 | | <DialogSaveButton Class="mr-2" OnClick="@Submit" Text="Liberar" /> |
| | | 72 | | </MudStack> |
| | | 73 | | } |
| | | 74 | | </PagerContent> |
| | | 75 | | </MudTable> |
| | | 76 | | </DialogContent> |
| | | 77 | | </MudDialog> |
| | | 78 | | |
| | | 79 | | @inject ISnackbar Snackbar |
| | | 80 | | @inject GetAcademicClassesClient GetClient |
| | | 81 | | @inject IBrowserViewportService BrowserViewportService |
| | | 82 | | @inject ReleaseClassesForEnrollmentClient ReleaseClient |
| | | 83 | | |
| | | 84 | | @code |
| | | 85 | | { |
| | | 86 | | [CascadingParameter] |
| | 0 | 87 | | IMudDialogInstance MudDialog { get; set; } |
| | | 88 | | |
| | | 89 | | private bool _loading; |
| | | 90 | | private bool _showButtons; |
| | | 91 | | private string _searchString; |
| | 0 | 92 | | private List<ClassOut> _classes = []; |
| | | 93 | | |
| | | 94 | | private Breakpoint _breakpoint; |
| | | 95 | | |
| | | 96 | | protected override async Task OnInitializedAsync() |
| | | 97 | | { |
| | 0 | 98 | | _loading = true; |
| | 0 | 99 | | _breakpoint = await BrowserViewportService.GetCurrentBreakpointAsync(); |
| | 0 | 100 | | _classes = await GetClient.Get(new() { Status = ClassStatus.OnPreEnrollment }); |
| | 0 | 101 | | _loading = false; |
| | 0 | 102 | | _showButtons = true; |
| | 0 | 103 | | } |
| | | 104 | | |
| | | 105 | | private void SelectAll() |
| | | 106 | | { |
| | 0 | 107 | | _classes.ForEach(x => x.IsSelected = true); |
| | 0 | 108 | | } |
| | | 109 | | private void UnselectAll() |
| | | 110 | | { |
| | 0 | 111 | | _classes.ForEach(x => x.IsSelected = false); |
| | 0 | 112 | | } |
| | | 113 | | |
| | | 114 | | private async Task Submit() |
| | | 115 | | { |
| | 0 | 116 | | if (_loading) return; |
| | | 117 | | |
| | 0 | 118 | | _loading = true; |
| | 0 | 119 | | var ids = _classes.Where(c => c.IsSelected).Select(c => c.Id).ToList(); |
| | 0 | 120 | | var response = await ReleaseClient.Release(ids); |
| | 0 | 121 | | if (response.IsSuccess) |
| | | 122 | | { |
| | 0 | 123 | | MudDialog.Close(DialogResult.Ok(true)); |
| | 0 | 124 | | Snackbar.Add("Turmas liberadas com sucesso!", Severity.Success); |
| | | 125 | | } |
| | | 126 | | else |
| | | 127 | | { |
| | 0 | 128 | | Snackbar.Add(response.Error.Message, Severity.Error); |
| | | 129 | | } |
| | 0 | 130 | | _loading = false; |
| | 0 | 131 | | } |
| | | 132 | | |
| | 0 | 133 | | private void Cancel() => MudDialog.Cancel(); |
| | | 134 | | |
| | 0 | 135 | | private Func<ClassOut, bool> _quickFilter => x => _searchString.IsIn(x.Discipline); |
| | | 136 | | |
| | | 137 | | private string GetNotFoundMessage() |
| | | 138 | | { |
| | 0 | 139 | | return (_searchString.IsEmpty()) ? "Não existem turmas para liberar." : "Nenhuma turma encontrada."; |
| | | 140 | | } |
| | | 141 | | } |