reorganized Raid pages
This commit is contained in:
parent
f40903851e
commit
d0ff8251a2
16 changed files with 174 additions and 53 deletions
175
Lieb/Pages/Raids/RaidOverview/RaidRoles.razor
Normal file
175
Lieb/Pages/Raids/RaidOverview/RaidRoles.razor
Normal file
|
@ -0,0 +1,175 @@
|
|||
@using Lieb.Data
|
||||
@using Lieb.Models
|
||||
@using Lieb.Models.GuildWars2
|
||||
@using Lieb.Models.GuildWars2.Raid
|
||||
@inject RaidService RaidService
|
||||
|
||||
<table class="table">
|
||||
@{
|
||||
bool flexExists = _raid.SignUps.Where(s => s.SignUpType == SignUpType.Flex).Any();
|
||||
}
|
||||
<thead>
|
||||
<tr @onclick="() => ToggleAll()">
|
||||
<th>
|
||||
@if(_allExpanded)
|
||||
{
|
||||
<span class="oi oi-collapse-up" style="margin-right:7px"> </span>
|
||||
}
|
||||
else
|
||||
{
|
||||
<span class="oi oi-expand-down" style="margin-right:7px"> </span>
|
||||
}
|
||||
Role
|
||||
</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>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@{
|
||||
bool isSignedUp = _raid.SignUps.Where(s => s.LiebUserId == _liebUserId && s.SignUpType != SignUpType.SignedOff && s.LiebUserId > 0).Any();
|
||||
}
|
||||
@foreach (ExpandableRole role in _expandableRoles.OrderBy(r => r.Role.RaidRoleId))
|
||||
{
|
||||
<tr>
|
||||
@{
|
||||
<td class="tdRole" @onclick="() => ToggleRow(role)">
|
||||
@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.RaidRoleId == role.Role.RaidRoleId && s.SignUpType == SignUpType.SignedUp).Count() / @role.Role.Spots)
|
||||
@if (@role.IsRowExpanded)
|
||||
{
|
||||
<br> @role.Role.Description
|
||||
}
|
||||
</td>
|
||||
}
|
||||
<td class="tdSignUp">
|
||||
@{List<SignUpType> signUpTypes =new List<SignUpType>(){SignUpType.SignedUp, SignUpType.Maybe, SignUpType.Backup};}
|
||||
<CascadingValue Value="this">
|
||||
<SignedUpUsers _raid=@_raid _usableAccounts=@_usableAccounts _liebUserId=@_liebUserId _currentRoleId=@role.Role.RaidRoleId _signUpTypes=@signUpTypes _showToolTip=@true _showUserColor=@true></SignedUpUsers>
|
||||
</CascadingValue>
|
||||
</td>
|
||||
@if (flexExists)
|
||||
{
|
||||
List<SignUpType> flexSignUpTypes =new List<SignUpType>(){SignUpType.Flex};
|
||||
<td class="tdSignUp">
|
||||
<CascadingValue Value="this">
|
||||
<SignedUpUsers _raid=@_raid _usableAccounts=@_usableAccounts _liebUserId=@_liebUserId _currentRoleId=@role.Role.RaidRoleId _signUpTypes=@flexSignUpTypes></SignedUpUsers>
|
||||
</CascadingValue>
|
||||
</td>
|
||||
}
|
||||
@if(_liebUserId > 0 && _isRaidSignUpAllowed)
|
||||
{
|
||||
bool notIsRoleSignUpAllowed = !RaidService.IsRoleSignUpAllowed(_raid.RaidId, _liebUserId, role.Role.RaidRoleId, SignUpType.SignedUp, false);
|
||||
bool notIsBackupAllowed = _raid.RaidType != RaidType.Planned && notIsRoleSignUpAllowed;
|
||||
<td><button class="raidButton" @onclick="() => SignUpClicked(role.Role, SignUpType.SignedUp)" disabled="@notIsRoleSignUpAllowed">Sign Up</button></td>
|
||||
<td><button class="raidButton" @onclick="() => SignUpClicked(role.Role, SignUpType.Maybe)" disabled="@notIsRoleSignUpAllowed">Maybe</button></td>
|
||||
<td><button class="raidButton" @onclick="() => SignUpClicked(role.Role, SignUpType.Backup)" disabled="@notIsBackupAllowed">Backup</button></td>
|
||||
@if (isSignedUp && _raid.RaidType == RaidType.Planned)
|
||||
{
|
||||
<td><button class="raidButton" @onclick="() => SignUpClicked(role.Role, SignUpType.Flex)">Flex</button></td>
|
||||
}
|
||||
}
|
||||
</tr>
|
||||
}
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
|
||||
@code {
|
||||
[Parameter]
|
||||
public RaidDetails _Parent { get; set; }
|
||||
|
||||
[Parameter]
|
||||
public Raid _raid { get; set; }
|
||||
|
||||
[Parameter]
|
||||
public LiebUser? _user { get; set; }
|
||||
|
||||
[Parameter]
|
||||
public bool _isRaidSignUpAllowed { get; set; }
|
||||
|
||||
private ulong _liebUserId { get; set; } = 0;
|
||||
|
||||
private List<GuildWars2Account> _usableAccounts;
|
||||
|
||||
private List<ExpandableRole> _expandableRoles;
|
||||
|
||||
private bool _allExpanded = false;
|
||||
|
||||
private class ExpandableRole
|
||||
{
|
||||
public RaidRole Role;
|
||||
public bool IsRowExpanded = false;
|
||||
}
|
||||
|
||||
protected override async Task OnParametersSetAsync()
|
||||
{
|
||||
if (_user != null)
|
||||
{
|
||||
if (_raid.RaidType == RaidType.Planned)
|
||||
{
|
||||
_usableAccounts = _user.GuildWars2Accounts.ToList();
|
||||
}
|
||||
else
|
||||
{
|
||||
_usableAccounts = _user.GuildWars2Accounts.Where(a => a.EquippedBuilds.Count > 0).ToList();
|
||||
}
|
||||
_liebUserId = _user.Id;
|
||||
}
|
||||
_expandableRoles = new List<ExpandableRole>();
|
||||
foreach(RaidRole role in _raid.Roles)
|
||||
{
|
||||
_expandableRoles.Add(new ExpandableRole()
|
||||
{
|
||||
Role = role
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
async Task SignUpClicked(RaidRole role, SignUpType signUpType)
|
||||
{
|
||||
if(_raid.SignUps.Where(s => s.LiebUserId == _liebUserId).Any() && signUpType != SignUpType.Flex)
|
||||
{
|
||||
await RaidService.ChangeSignUpType(_raid.RaidId, _liebUserId, role.RaidRoleId, signUpType);
|
||||
}
|
||||
else
|
||||
{
|
||||
await RaidService.SignUp(_raid.RaidId, _liebUserId, _usableAccounts.FirstOrDefault().GuildWars2AccountId, role.RaidRoleId, signUpType);
|
||||
}
|
||||
_Parent.HasChanged();
|
||||
}
|
||||
|
||||
public async Task ChangeAccount(ChangeEventArgs e)
|
||||
{
|
||||
int accountId = int.Parse(e.Value.ToString());
|
||||
await RaidService.ChangeAccount(_raid.RaidId, _liebUserId, accountId);
|
||||
_raid = RaidService.GetRaid(_raid.RaidId);
|
||||
this.StateHasChanged();
|
||||
}
|
||||
|
||||
private async Task ToggleRow(ExpandableRole role)
|
||||
{
|
||||
role.IsRowExpanded = !role.IsRowExpanded;
|
||||
_allExpanded = !_expandableRoles.Where(r => !r.IsRowExpanded).Any();
|
||||
}
|
||||
|
||||
private async Task ToggleAll()
|
||||
{
|
||||
foreach(ExpandableRole role in _expandableRoles)
|
||||
{
|
||||
role.IsRowExpanded = !_allExpanded;
|
||||
}
|
||||
_allExpanded = !_allExpanded;
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue