Added new Flex column, added colapsable Rule Descriptions

changed color of user name
This commit is contained in:
t.ruspekhofer 2022-03-17 23:11:33 +01:00
parent 2d8a0850eb
commit 853dd6eec7
3 changed files with 109 additions and 19 deletions

View file

@ -5,10 +5,27 @@
@inject RaidService RaidService @inject RaidService RaidService
<table class="table"> <table class="table">
@{
bool flexExists = _raid.SignUps.Where(s => s.SignUpType == SignUpType.Flex).Any();
}
<thead> <thead>
<tr> <tr @onclick="() => ExpandAll()">
<th>Role</th> <th>
@if(@_expandableRoles.FirstOrDefault().IsRowExpanded)
{
<span class="oi oi-chevron-top" style="margin-right:7px"> </span>
}
else
{
<span class="oi oi-chevron-bottom" style="margin-right:7px"> </span>
}
Role
</th>
<th>Users</th> <th>Users</th>
@if (flexExists)
{
<th>Flex</th>
}
<th>(@_raid.SignUps.Where(s => s.SignUpType == SignUpType.SignedUp).Count()/@_raid.Roles.Sum(r => r.Spots))</th> <th>(@_raid.SignUps.Where(s => s.SignUpType == SignUpType.SignedUp).Count()/@_raid.Roles.Sum(r => r.Spots))</th>
</tr> </tr>
</thead> </thead>
@ -16,28 +33,51 @@
@{ @{
bool isSignedUp = _raid.SignUps.Where(s => s.LiebUserId == _liebUserId && s.SignUpType != SignUpType.SignedOff).Any(); bool isSignedUp = _raid.SignUps.Where(s => s.LiebUserId == _liebUserId && s.SignUpType != SignUpType.SignedOff).Any();
} }
@foreach (PlannedRaidRole role in _raid.Roles.OrderBy(r => r.PlannedRaidRoleId)) @foreach (ExpandableRole role in _expandableRoles.OrderBy(r => r.Role.PlannedRaidRoleId))
{ {
<tr> <tr>
<td class="tdRole"> @{
<b>@role.Name</b> (@_raid.SignUps.Where(s => s.PlannedRaidRoleId == role.PlannedRaidRoleId && s.SignUpType == SignUpType.SignedUp).Count() / @role.Spots) <td class="tdRole" @onclick="() => role.IsRowExpanded = !role.IsRowExpanded">
<br> @role.Description @if(@role.IsRowExpanded)
{
<span class="oi oi-chevron-top" style="margin-right:7px"> </span>
}
else
{
<span class="oi oi-chevron-bottom" style="margin-right:7px"> </span>
}
<b>@role.Role.Name</b> (@_raid.SignUps.Where(s => s.PlannedRaidRoleId == role.Role.PlannedRaidRoleId && s.SignUpType == SignUpType.SignedUp).Count() / @role.Role.Spots)
@if (@role.IsRowExpanded)
{
<br> @role.Role.Description
}
</td> </td>
}
<td class="tdSignUp"> <td class="tdSignUp">
@{List<SignUpType> signUpTypes =new List<SignUpType>(){SignUpType.SignedUp, SignUpType.Maybe, SignUpType.Backup};}
<CascadingValue Value="this"> <CascadingValue Value="this">
<SignedUpUsers _raid=@_raid _usableAccounts=@_usableAccounts _liebUserId=@_liebUserId _currentRoleId=@role.PlannedRaidRoleId></SignedUpUsers> <SignedUpUsers _raid=@_raid _usableAccounts=@_usableAccounts _liebUserId=@_liebUserId _currentRoleId=@role.Role.PlannedRaidRoleId _signUpTypes=@signUpTypes _showToolTip=@true></SignedUpUsers>
</CascadingValue> </CascadingValue>
</td> </td>
@if(_liebUserId > 0) @if (flexExists)
{ {
bool notIsRoleSignUpAllowed = !RaidService.IsRoleSignUpAllowed(_raid.RaidId, _liebUserId, role.PlannedRaidRoleId, SignUpType.SignedUp, false); List<SignUpType> flexSignUpTypes =new List<SignUpType>(){SignUpType.Flex};
<td class="tdSignUp">
<CascadingValue Value="this">
<SignedUpUsers _raid=@_raid _usableAccounts=@_usableAccounts _liebUserId=@_liebUserId _currentRoleId=@role.Role.PlannedRaidRoleId _signUpTypes=@flexSignUpTypes></SignedUpUsers>
</CascadingValue>
</td>
}
@if(_liebUserId > 0 && _isRaidSignUpAllowed)
{
bool notIsRoleSignUpAllowed = !RaidService.IsRoleSignUpAllowed(_raid.RaidId, _liebUserId, role.Role.PlannedRaidRoleId, SignUpType.SignedUp, false);
bool notIsBackupAllowed = _raid.RaidType != RaidType.Planned && notIsRoleSignUpAllowed; bool notIsBackupAllowed = _raid.RaidType != RaidType.Planned && notIsRoleSignUpAllowed;
<td class="signUpButton"><button @onclick="() => SignUpClicked(role, SignUpType.SignedUp)" disabled="@notIsRoleSignUpAllowed">Sign Up</button></td> <td class="signUpButton"><button @onclick="() => SignUpClicked(role.Role, SignUpType.SignedUp)" disabled="@notIsRoleSignUpAllowed">Sign Up</button></td>
<td class="signUpButton"><button @onclick="() => SignUpClicked(role, SignUpType.Maybe)" disabled="@notIsRoleSignUpAllowed">Maybe</button></td> <td class="signUpButton"><button @onclick="() => SignUpClicked(role.Role, SignUpType.Maybe)" disabled="@notIsRoleSignUpAllowed">Maybe</button></td>
<td class="signUpButton"><button @onclick="() => SignUpClicked(role, SignUpType.Backup)" disabled="@notIsBackupAllowed">Backup</button></td> <td class="signUpButton"><button @onclick="() => SignUpClicked(role.Role, SignUpType.Backup)" disabled="@notIsBackupAllowed">Backup</button></td>
@if (isSignedUp && _raid.RaidType == RaidType.Planned) @if (isSignedUp && _raid.RaidType == RaidType.Planned)
{ {
<td><button @onclick="() => SignUpClicked(role, SignUpType.Flex)">Flex</button></td> <td><button @onclick="() => SignUpClicked(role.Role, SignUpType.Flex)">Flex</button></td>
} }
} }
</tr> </tr>
@ -54,10 +94,21 @@
[Parameter] [Parameter]
public LiebUser? _user { get; set; } public LiebUser? _user { get; set; }
[Parameter]
public bool _isRaidSignUpAllowed { get; set; }
private int _liebUserId { get; set; } = -1; private int _liebUserId { get; set; } = -1;
private List<GuildWars2Account> _usableAccounts; private List<GuildWars2Account> _usableAccounts;
private List<ExpandableRole> _expandableRoles;
private class ExpandableRole
{
public PlannedRaidRole Role;
public bool IsRowExpanded = false;
}
protected override async Task OnParametersSetAsync() protected override async Task OnParametersSetAsync()
{ {
if (_user != null) if (_user != null)
@ -72,13 +123,21 @@
} }
_liebUserId = _user.LiebUserId; _liebUserId = _user.LiebUserId;
} }
_expandableRoles = new List<ExpandableRole>();
foreach(PlannedRaidRole role in _raid.Roles)
{
_expandableRoles.Add(new ExpandableRole()
{
Role = role
});
}
} }
async Task SignUpClicked(PlannedRaidRole role, SignUpType signUpType) async Task SignUpClicked(PlannedRaidRole role, SignUpType signUpType)
{ {
if(_raid.SignUps.Where(s => s.LiebUserId == _liebUserId).Any() && signUpType != SignUpType.Flex) if(_raid.SignUps.Where(s => s.LiebUserId == _liebUserId).Any() && signUpType != SignUpType.Flex)
{ {
await RaidService.ChangeSignUpType(_raid.RaidId, _liebUserId, role.PlannedRaidRoleId, signUpType); RaidService.ChangeSignUpType(_raid.RaidId, _liebUserId, role.PlannedRaidRoleId, signUpType);
} }
else else
{ {
@ -94,4 +153,13 @@
_raid = RaidService.GetRaid(_raid.RaidId); _raid = RaidService.GetRaid(_raid.RaidId);
this.StateHasChanged(); this.StateHasChanged();
} }
public async Task ExpandAll()
{
bool newStatus = !_expandableRoles.FirstOrDefault().IsRowExpanded;
foreach(ExpandableRole role in _expandableRoles)
{
role.IsRowExpanded = newStatus;
}
}
} }

View file

@ -7,15 +7,15 @@
<table> <table>
@{RaidSignUp[] signUps = _raid.SignUps.Where(s => s.PlannedRaidRoleId == _currentRoleId).ToArray();} @{RaidSignUp[] signUps = _raid.SignUps.Where(s => s.PlannedRaidRoleId == _currentRoleId).ToArray();}
@foreach (var signUp in signUps) @foreach (var signUp in signUps.OrderBy(s => s.SignUpType))
{ {
@if(signUp.SignUpType != SignUpType.SignedOff) @if(_signUpTypes.Contains(signUp.SignUpType))
{ {
<tr> <tr>
@{ @{
bool isUser = signUp.LiebUserId == _liebUserId; bool isUser = signUp.LiebUserId == _liebUserId;
string signUpStatus = string.Empty; string signUpStatus = string.Empty;
@if (signUp.SignUpType != SignUpType.SignedUp) signUpStatus = $" - {signUp.SignUpType}"; @if (signUp.SignUpType != SignUpType.SignedUp && _signUpTypes.Count > 1) signUpStatus = $" - {signUp.SignUpType}";
} }
@if (isUser && _usableAccounts.Count > 1 && signUp.SignUpType != SignUpType.Flex) @if (isUser && _usableAccounts.Count > 1 && signUp.SignUpType != SignUpType.Flex)
@ -29,11 +29,24 @@
</select> @signUpStatus </select> @signUpStatus
</td> </td>
} }
else if(isUser)
{
<td class="nametooltip username">
@signUp.GuildWars2Account.AccountName @signUpStatus
@if(_showToolTip)
{
<span class="tooltiptext">@signUp.LiebUser.Name</span>
}
</td>
}
else else
{ {
<td class="nametooltip"> <td class="nametooltip">
@signUp.GuildWars2Account.AccountName @signUpStatus @signUp.GuildWars2Account.AccountName @signUpStatus
<span class="tooltiptext">@signUp.LiebUser.Name</span> @if(_showToolTip)
{
<span class="tooltiptext">@signUp.LiebUser.Name</span>
}
</td> </td>
} }
</tr> </tr>
@ -55,4 +68,10 @@
[Parameter] [Parameter]
public int _currentRoleId { get; set; } public int _currentRoleId { get; set; }
[Parameter]
public List<SignUpType> _signUpTypes { get; set; }
[Parameter]
public bool _showToolTip { get; set; } = false;
} }

View file

@ -1,4 +1,7 @@
 .username {
color: lightgreen;
}
.nametooltip { .nametooltip {
position: relative; position: relative;
display: inline-block; display: inline-block;