< Summary

Class:MUNity.BlazorServer.Components.Conference.Application.SelectableDelegationsComponent
Assembly:MUNity.BlazorServer
File(s):C:\Users\aeuke\source\repos\PeerConradi\munity\src\MUNity.BlazorServer\Components\Conference\Application\SelectableDelegationsComponent.razor
Covered lines:0
Uncovered lines:74
Coverable lines:74
Total lines:169
Line coverage:0% (0 of 74)
Covered branches:0
Total branches:36
Branch coverage:0% (0 of 36)
Covered methods:0
Total methods:10
Method coverage:0% (0 of 10)

Metrics

MethodBranch coverage Cyclomatic complexity Line coverage
BuildRenderTree(...)0%260%
get_ConferenceId()100%10%
get_Application()100%10%
get_DelegationsAdded()100%10%
get_UseOnlineMode()100%10%
.ctor()100%10%
DelegationSelected(...)100%10%
Finish()0%40%
get_displayDelegation()0%40%
OnInitialized()0%20%

File(s)

C:\Users\aeuke\source\repos\PeerConradi\munity\src\MUNity.BlazorServer\Components\Conference\Application\SelectableDelegationsComponent.razor

#LineLine coverage
 1@layout MUNity.BlazorServer.Shared.ConferenceFrontEndLayout
 2@inject Services.ConferenceApplicationService applicationService
 3@inject MUNity.Database.Context.MunityContext context
 4
 5<div class="pos-booking">
 6    <div class="pos-booking-body" style="margin-top: 0px;">
 7        <!-- BEGIN pos-booking-content -->
 8        <div class="pos-booking-content" style="margin-top: 0px;">
 9            <div class="pos-booking-content-container" style="margin-top: 0px;">
 10                <div class="row">
 011                    <h4>Bitte wählen Sie @maxPickDelegations Delegationen, welche sie gerne belegen möchten</h4>
 12                    <p>Hierbei bitte die angezeigte Nummer beachten. Diese ist die Priorität mit welcher Sie diese Deleg
 13                </div>
 14                <div class="row">
 015                    @foreach (var delegation in pickedDelegations)
 016                    {
 17                        <SelectableDelegationComponent SelectionText="@((pickedDelegations.IndexOf(delegation) + 1).ToSt
 18                                                       Delegation="delegation"
 019                                                       Clicked="(n) => this.pickedDelegations.Remove(n)"/>
 020                    }
 21                </div>
 22
 23
 024                @if (pickedDelegations.Count < this.maxPickDelegations && AllDeleations.Count >= this.maxPickDelegations
 025                    (pickedDelegations.Count < this.AllDeleations.Count && this.AllDeleations.Count < this.maxPickDelega
 026                {
 27                    <div class="d-md-flex align-items-center mb-4">
 28                        <div class="pos-booking-title flex-1">
 29                            <div class="fs-24px mb-1">Verfügbare Delegationen</div>
 30                            <div class="mb-2 mb-md-0 d-flex">
 31                                <div class="d-flex align-items-center me-3">
 32                                    <i class="fa fa-circle fa-fw text-gray-700 fs-9px me-1"></i> Passend
 33                                </div>
 34                                <div class="d-flex align-items-center me-3">
 35                                    <i class="fa fa-circle fa-fw text-warning fs-9px me-1"></i> Unzureichende Anzahl Plä
 36                                </div>
 37                                <div class="d-flex align-items-center me-3">
 38                                    <i class="fa fa-circle fa-fw text-success fs-9px me-1"></i> In-progress
 39                                </div>
 40                            </div>
 41                        </div>
 42                        <div>
 43                            <div class="input-group date mb-0">
 44                                <input type="text" class="form-control" placeholder="Suchen" @bind="@searchTerm" @bind:e
 45                            </div>
 46                        </div>
 47                    </div>
 48
 49                    <div class="row">
 050                        @if (AllDeleations != null && AllDeleations.Count > 0)
 051                        {
 052                            @foreach (var delegation in displayDelegation)
 053                            {
 054                                <SelectableDelegationComponent IsSelected="@(Application.DelegationWishes.Any(n => n.Del
 55                                                               Delegation="delegation"
 56                                                               Clicked="DelegationSelected" />
 057                            }
 058                        }
 59                        else
 060                        {
 061                            <div class="alert alert-info">Es wurden keine Delegationen gefunden. Möglicherweise existier
 062                        }
 63
 64                    </div>
 065                }
 66                else
 067                {
 68
 069                    @if (!Application.OpenToPublic && pickedDelegations.Any(n => n.Roles.Count > Application.Users.Count
 070                    {
 71                        <div class="alert alert-warning">
 72                            <h4>Warnung</h4>
 73                            <p>
 074                                @string.Join(", ", pickedDelegations.Where(n => n.Roles.Count > Application.Users.Count)
 75                            Öffentlichkeit freigegeben. Wenn Sie diese Bewerbung freigeben, können andere Interessierte 
 76                        </p>
 77                    </div>
 078                    }
 79
 080                    @if (AllDeleations.Count < this.maxPickDelegations)
 081                {
 82                    <div class="alert alert-cyan">
 083                        Offenbar stehen weniger Delegationen zur Verfügung als eigentlich angegeben werden sollten (@max
 84                    </div>
 085                }
 86
 087                    if (pickedDelegations.Count == maxPickDelegations || pickedDelegations.Count == AllDeleations.Count)
 088                    {
 89                        <button class="btn btn-primary" @onclick="Finish">Auswahl bestätigen</button>
 90
 091                    }
 092                }
 93
 94            </div>
 95        </div>
 96        <!-- END pos-counter-content -->
 97    </div>
 98</div>
 99
 100
 101@code {
 0102    [Parameter] public string ConferenceId { get; set; }
 103
 0104    [Parameter] public MUNity.Database.Models.Conference.DelegationApplication Application { get; set; }
 105
 0106    [Parameter] public EventCallback DelegationsAdded { get; set; }
 107
 0108    [Parameter] public bool UseOnlineMode { get; set; }
 109
 0110    private List<MUNity.Schema.Conference.ApplicationAvailableDelegation> pickedDelegations = new List<Schema.Conference
 111
 112    private int maxPickDelegations;
 113
 114    private void DelegationSelected(MUNity.Schema.Conference.ApplicationAvailableDelegation delegation)
 0115    {
 116        //
 117        //InvokeAsync(StateHasChanged);
 0118        pickedDelegations.Add(delegation);
 0119        InvokeAsync(StateHasChanged);
 0120    }
 121
 122    private void Finish()
 0123    {
 0124        foreach(var delegation in pickedDelegations)
 0125        {
 126
 0127            var realDelegation = context.Delegations.Find(delegation.DelegationId);
 0128            if (realDelegation != null)
 0129            {
 0130                this.Application.DelegationWishes.Add(new Database.Models.Conference.DelegationApplicationPickedDelegati
 0131                {
 0132                    Application = this.Application,
 0133                    Delegation = realDelegation,
 0134                    Priority = (byte)this.Application.DelegationWishes.Count
 0135                });
 0136            }
 0137        }
 0138        DelegationsAdded.InvokeAsync();
 0139    }
 140
 141    private List<MUNity.Schema.Conference.ApplicationAvailableDelegation> AllDeleations;
 142
 0143    private string searchTerm = "";
 144
 145    private IEnumerable<MUNity.Schema.Conference.ApplicationAvailableDelegation> displayDelegation
 146    {
 147        get
 0148        {
 0149            if (AllDeleations == null) return null;
 0150            var termLowered = searchTerm.ToLower();
 0151            var dels = searchTerm.Length > 2 ? AllDeleations.Where(n => n.Name.ToLower().Contains(termLowered)) : AllDel
 0152            return dels.Except(pickedDelegations).OrderBy(n => n.Roles.Count).ThenBy(n => n.Name);
 0153        }
 154    }
 155
 156    protected override void OnInitialized()
 0157    {
 0158        base.OnInitialized();
 0159        if (UseOnlineMode)
 0160            AllDeleations = applicationService.AvailableDelegations(ConferenceId, Application.Users.Count, Services.Conf
 161        else
 0162            AllDeleations = applicationService.AvailableDelegations(ConferenceId, Application.Users.Count, Services.Conf
 163
 0164        maxPickDelegations = context.ConferenceApplicationFormulas.Where(n => n.Options.ConferenceId == this.ConferenceI
 0165            n.FormulaType == ConferenceApplicationFormulaTypes.Delegation)
 0166        .Select(n => n.MaxWishes)
 0167        .FirstOrDefault().Value;
 0168    }
 169}