| | 1 | | @inject Services.DelegationService delegationService |
| | 2 | |
|
| | 3 | | <div class="col-xl-3 col-lg-3 col-sm-6"> |
| | 4 | | <div class="card border-0 mb-3 bg-gray-900 text-white"> |
| | 5 | | <!-- BEGIN card-body --> |
| | 6 | | <div class="card-body"> |
| | 7 | | <!-- BEGIN title --> |
| | 8 | | <div class="mb-3 text-gray-300"> |
| | 9 | | <div class="d-flex align-items-center"> |
| | 10 | | <div class="text-truncate"> |
| 0 | 11 | | <div>@Info.DelegationName (@Info.DelegationShort)</div> |
| | 12 | | </div> |
| | 13 | | <div class="ms-auto text-center"> |
| 0 | 14 | | <div class="text-gray-300">@Info.Roles.Count Slots</div> |
| | 15 | | </div> |
| | 16 | | </div> |
| | 17 | |
|
| | 18 | | </div> |
| | 19 | |
|
| | 20 | |
|
| 0 | 21 | | @if (isExpanded) |
| 0 | 22 | | { |
| 0 | 23 | | @foreach (var role in Info.Roles) |
| 0 | 24 | | { |
| | 25 | | <div class="d-flex align-items-center mb-15px"> |
| | 26 | | <div class="text-truncate"> |
| 0 | 27 | | <div>@role.RoleName</div> |
| 0 | 28 | | <div class="text-gray-300">@((!string.IsNullOrEmpty(role.RoleCommitteeName) ? role.RoleCommi |
| | 29 | | </div> |
| | 30 | | <div class="ms-auto text-center"> |
| 0 | 31 | | <div class="fs-13px">@((role.HasParicipant) ? "Ist besetzt" : "Rolle ist verfügbar")</div> |
| | 32 | | <div class="text-gray-300 fs-10px">Bewerbung erlaubt</div> |
| | 33 | | </div> |
| | 34 | | </div> |
| | 35 | |
|
| 0 | 36 | | } |
| | 37 | | <hr /> |
| | 38 | | <div class="row mb-3"> |
| | 39 | | <EditForm Model="@form" OnValidSubmit="AddRoleToDelegation"> |
| | 40 | | <div class="col-12 mb-1"> |
| | 41 | | <InputSelect class="form-select" @bind-Value="@form.SelectedRoleId"> |
| | 42 | | <option value="-1">Rolle zum Hinzufügen auswählen</option> |
| 0 | 43 | | @foreach (var role in availableRoles) |
| 0 | 44 | | { |
| 0 | 45 | | <option value="@role.RoleId">@role.RoleName @((!string.IsNullOrEmpty(role.RoleCo |
| 0 | 46 | | } |
| | 47 | | </InputSelect> |
| | 48 | | </div> |
| | 49 | | <div class="col-12"> |
| | 50 | | <button class="btn btn-block btn-sm btn-success w-100 @((form.SelectedRoleId == -1) ? "disab |
| | 51 | | </div> |
| | 52 | | </EditForm> |
| | 53 | |
|
| | 54 | | </div> |
| 0 | 55 | | } |
| | 56 | | <hr /> |
| | 57 | | <div class="row"> |
| | 58 | | <div class="col-12"> |
| | 59 | | <div class="text-center text-gray-300-600 text-decoration-underline" |
| 0 | 60 | | style="cursor: pointer;" @onclick="() => Toggle()"> |
| 0 | 61 | | @((!isExpanded) ? "Rollen anzeigen" : "Rollen ausblenden") |
| | 62 | | </div> |
| | 63 | | </div> |
| | 64 | |
|
| | 65 | |
|
| | 66 | | </div> |
| | 67 | | </div> |
| | 68 | | <!-- END card-body --> |
| | 69 | | </div> |
| | 70 | | </div> |
| | 71 | |
|
| | 72 | | @code { |
| 0 | 73 | | private bool isExpanded = false; |
| | 74 | |
|
| 0 | 75 | | [Parameter] public MUNity.Schema.Conference.ManageDelegationInfo Info { get; set; } |
| | 76 | |
|
| 0 | 77 | | [CascadingParameter] public Task<AuthenticationState> AuthStateTask { get; set; } |
| | 78 | |
|
| 0 | 79 | | [Parameter] public string ConferenceId { get; set; } |
| | 80 | |
|
| 0 | 81 | | private List<MUNity.Schema.Conference.ManageDelegationRoleInfo> availableRoles = new List<Schema.Conference.ManageDe |
| | 82 | |
|
| | 83 | |
|
| | 84 | |
|
| | 85 | | private class AddRoleForm |
| | 86 | | { |
| 0 | 87 | | public int SelectedRoleId { get; set; } = -1; |
| | 88 | | } |
| | 89 | |
|
| 0 | 90 | | private AddRoleForm form = new AddRoleForm(); |
| | 91 | |
|
| | 92 | | protected override void OnInitialized() |
| 0 | 93 | | { |
| 0 | 94 | | base.OnInitialized(); |
| 0 | 95 | | } |
| | 96 | |
|
| | 97 | | private async Task Toggle() |
| 0 | 98 | | { |
| 0 | 99 | | if (!isExpanded) |
| 0 | 100 | | { |
| 0 | 101 | | var claim = (await AuthStateTask)?.User; |
| 0 | 102 | | availableRoles = await delegationService.GetAvailableRoles(ConferenceId, claim); |
| 0 | 103 | | } |
| 0 | 104 | | isExpanded = !isExpanded; |
| 0 | 105 | | } |
| | 106 | |
|
| | 107 | | private async Task AddRoleToDelegation() |
| 0 | 108 | | { |
| 0 | 109 | | var claim = (await AuthStateTask)?.User; |
| 0 | 110 | | var result = await delegationService.AddRoleToDelegation(form.SelectedRoleId, Info.DelegationId, claim); |
| 0 | 111 | | if (result) |
| 0 | 112 | | { |
| 0 | 113 | | var role = availableRoles.FirstOrDefault(n => n.RoleId == form.SelectedRoleId); |
| 0 | 114 | | Info.Roles.Add(role); |
| 0 | 115 | | form.SelectedRoleId = -1; |
| | 116 | |
|
| 0 | 117 | | availableRoles.Remove(role); |
| 0 | 118 | | } |
| 0 | 119 | | } |
| | 120 | |
|
| | 121 | |
|
| | 122 | | } |