80 lines
3.3 KiB
Text
80 lines
3.3 KiB
Text
@using Lieb.Data
|
|
@using Lieb.Models
|
|
@using Lieb.Models.GuildWars2
|
|
@using Lieb.Models.GuildWars2.Raid
|
|
@inject RaidService RaidService
|
|
|
|
<table class="table">
|
|
<thead>
|
|
<tr>
|
|
<th>Role</th>
|
|
<th>Users</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).Any();
|
|
}
|
|
@foreach (PlannedRaidRole role in _raid.Roles.OrderBy(r => r.PlannedRaidRoleId))
|
|
{
|
|
<tr>
|
|
<td class="tdRole">
|
|
<b>@role.Name</b> (@_raid.SignUps.Where(s => s.PlannedRaidRoleId == role.PlannedRaidRoleId && s.SignUpType == SignUpType.SignedUp).Count() / @role.Spots)
|
|
<br> @role.Description
|
|
</td>
|
|
<td class="tdSignUp">
|
|
<SignedUpUsers _raid=@_raid _usableAccounts=@_usableAccounts _liebUserId=@_liebUserId _currentRoleId=@role.PlannedRaidRoleId></SignedUpUsers>
|
|
</td>
|
|
@if(_liebUserId > 0)
|
|
{
|
|
bool notIsRoleSignUpAllowed = !RaidService.IsRoleSignUpAllowed(_raid.RaidId, _liebUserId, role.PlannedRaidRoleId, SignUpType.SignedUp, false);
|
|
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, SignUpType.Maybe)" disabled="@notIsRoleSignUpAllowed">Maybe</button></td>
|
|
<td class="signUpButton"><button @onclick="() => SignUpClicked(role, SignUpType.Backup)" disabled="@notIsBackupAllowed">Backup</button></td>
|
|
@if (isSignedUp && _raid.RaidType == RaidType.Planned)
|
|
{
|
|
<td><button @onclick="() => SignUpClicked(role, SignUpType.Flex)">Flex</button></td>
|
|
}
|
|
}
|
|
</tr>
|
|
}
|
|
</tbody>
|
|
</table>
|
|
|
|
|
|
@code {
|
|
|
|
[Parameter]
|
|
public Raid _raid { get; set; }
|
|
|
|
[Parameter]
|
|
public LiebUser? _user { get; set; }
|
|
|
|
private int _liebUserId { get; set; } = -1;
|
|
|
|
private List<GuildWars2Account> _usableAccounts;
|
|
|
|
protected override async Task OnParametersSetAsync()
|
|
{
|
|
if (_user != null)
|
|
{
|
|
_usableAccounts = _user.GuildWars2Accounts.Where(a => a.EquippedBuilds.Count > 0).ToList();
|
|
_liebUserId = _user.LiebUserId;
|
|
}
|
|
}
|
|
|
|
async Task SignUpClicked(PlannedRaidRole role, SignUpType signUpType)
|
|
{
|
|
if(_raid.SignUps.Where(s => s.LiebUserId == _liebUserId).Any() && signUpType != SignUpType.Flex)
|
|
{
|
|
await RaidService.ChangeSignUpType(_raid.RaidId, _liebUserId, role.PlannedRaidRoleId, signUpType);
|
|
}
|
|
else
|
|
{
|
|
await RaidService.SignUp(_raid.RaidId, _liebUserId, _usableAccounts.FirstOrDefault().GuildWars2AccountId, role.PlannedRaidRoleId, signUpType);
|
|
}
|
|
_raid = RaidService.GetRaid(_raid.RaidId);
|
|
}
|
|
}
|