Compressed RaidRole components to a single component to make layout changes easier
This commit is contained in:
parent
8d443781a4
commit
b714249e4c
7 changed files with 42 additions and 177 deletions
|
@ -41,21 +41,7 @@
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@if(_isRaidSignUpAllowed)
|
<RaidRoles _raid=@_raid _user=@_user/>
|
||||||
{
|
|
||||||
if(_raid.RaidType == RaidType.Planned)
|
|
||||||
{
|
|
||||||
<RaidRolesPlanned _raid=@_raid _user=@_user/>
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
<RaidRolesRandom _raid=@_raid _user=@_user/>
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
<RaidRolesNoSignUp _raid=@_raid/>
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
<AuthorizeView Policy="@Constants.Roles.RaidLead">
|
<AuthorizeView Policy="@Constants.Roles.RaidLead">
|
||||||
|
|
|
@ -7,7 +7,7 @@
|
||||||
<table class="table">
|
<table class="table">
|
||||||
<tbody>
|
<tbody>
|
||||||
@{
|
@{
|
||||||
RaidSignUp userRole = _raid.SignUps.Where(s => s.LiebUserId == _user.LiebUserId).FirstOrDefault();
|
RaidSignUp userRole = _raid.SignUps.Where(s => s.LiebUserId == _liebUserId).FirstOrDefault();
|
||||||
bool isSignedUp = userRole != null;
|
bool isSignedUp = userRole != null;
|
||||||
}
|
}
|
||||||
@foreach (PlannedRaidRole role in _raid.Roles.OrderBy(r => r.PlannedRaidRoleId))
|
@foreach (PlannedRaidRole role in _raid.Roles.OrderBy(r => r.PlannedRaidRoleId))
|
||||||
|
@ -16,14 +16,14 @@
|
||||||
int usedSpots = signUps.Where(s => s.SignUpType == SignUpType.SignedUp).Count();
|
int usedSpots = signUps.Where(s => s.SignUpType == SignUpType.SignedUp).Count();
|
||||||
|
|
||||||
<tr>
|
<tr>
|
||||||
<td> <b>@role.Name</b> (@usedSpots /@role.Spots) <br> @role.Description </td>
|
<td><b>@role.Name</b> (@usedSpots /@role.Spots) <br> @role.Description </td>
|
||||||
<td>
|
<td>
|
||||||
@foreach (var signUp in signUps)
|
@foreach (var signUp in signUps)
|
||||||
{
|
{
|
||||||
@if(signUp.SignUpType != SignUpType.SignedOff)
|
@if(signUp.SignUpType != SignUpType.SignedOff)
|
||||||
{
|
{
|
||||||
<tr>
|
<tr>
|
||||||
@{bool isUser = isSignedUp && userRole.PlannedRaidRole.PlannedRaidRoleId == role.PlannedRaidRoleId && signUp.LiebUserId == _user.LiebUserId;}
|
@{bool isUser = isSignedUp && userRole.PlannedRaidRole.PlannedRaidRoleId == role.PlannedRaidRoleId && signUp.LiebUserId == _liebUserId;}
|
||||||
@{string signUpStatus = string.Empty;}
|
@{string signUpStatus = string.Empty;}
|
||||||
@if (signUp.SignUpType != SignUpType.SignedUp) signUpStatus = $" - {signUp.SignUpType}";
|
@if (signUp.SignUpType != SignUpType.SignedUp) signUpStatus = $" - {signUp.SignUpType}";
|
||||||
|
|
||||||
|
@ -45,11 +45,35 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</td>
|
</td>
|
||||||
@if (role.IsRandomSignUpRole && _raid.SignUps.Where(s => s.SignUpType == SignUpType.SignedUp).Count() < role.Spots)
|
@if(_liebUserId > 0)
|
||||||
{
|
{
|
||||||
<td><button @onclick="() => SignUpClicked(role, _user, isSignedUp, SignUpType.SignedUp)">Sign Up</button></td>
|
@if(_raid.RaidType == RaidType.Planned)
|
||||||
<td><button @onclick="() => SignUpClicked(role, _user, isSignedUp, SignUpType.Maybe)">Maybe</button></td>
|
{
|
||||||
<td><button @onclick="() => SignUpClicked(role, _user, isSignedUp, SignUpType.Backup)">Backup</button></td>
|
@if (RaidService.IsRoleSignUpAllowed(_raid.RaidId, _user.LiebUserId, role.PlannedRaidRoleId, SignUpType.SignedUp, false))
|
||||||
|
{
|
||||||
|
<td><button @onclick="() => SignUpClicked(role, _user, isSignedUp, SignUpType.SignedUp)">Sign Up</button></td>
|
||||||
|
<td><button @onclick="() => SignUpClicked(role, _user, isSignedUp, SignUpType.Maybe)">Maybe</button></td>
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
<td></td>
|
||||||
|
<td></td>
|
||||||
|
}
|
||||||
|
<td><button @onclick="() => SignUpClicked(role, _user, isSignedUp, SignUpType.Backup)">Backup</button></td>
|
||||||
|
@if (isSignedUp && userRole.SignUpType != SignUpType.SignedOff && _raid.RaidType == RaidType.Planned)
|
||||||
|
{
|
||||||
|
<td><button @onclick="() => SignUpClicked(role, _user, isSignedUp, SignUpType.Flex)">Flex</button></td>
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
@if (role.IsRandomSignUpRole && _raid.SignUps.Where(s => s.SignUpType == SignUpType.SignedUp).Count() < role.Spots)
|
||||||
|
{
|
||||||
|
<td><button @onclick="() => SignUpClicked(role, _user, isSignedUp, SignUpType.SignedUp)">Sign Up</button></td>
|
||||||
|
<td><button @onclick="() => SignUpClicked(role, _user, isSignedUp, SignUpType.Maybe)">Maybe</button></td>
|
||||||
|
<td><button @onclick="() => SignUpClicked(role, _user, isSignedUp, SignUpType.Backup)">Backup</button></td>
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
</tr>
|
</tr>
|
||||||
}
|
}
|
||||||
|
@ -63,18 +87,24 @@
|
||||||
public Raid _raid { get; set; }
|
public Raid _raid { get; set; }
|
||||||
|
|
||||||
[Parameter]
|
[Parameter]
|
||||||
public LiebUser _user { get; set; }
|
public LiebUser? _user { get; set; }
|
||||||
|
|
||||||
|
private int _liebUserId { get; set; } = -1;
|
||||||
|
|
||||||
private List<GuildWars2Account> _usableAccounts;
|
private List<GuildWars2Account> _usableAccounts;
|
||||||
|
|
||||||
protected override async Task OnParametersSetAsync()
|
protected override async Task OnParametersSetAsync()
|
||||||
{
|
{
|
||||||
_usableAccounts = _user.GuildWars2Accounts.Where(a => a.EquippedBuilds.Count > 0).ToList();
|
if (_user != null)
|
||||||
|
{
|
||||||
|
_usableAccounts = _user.GuildWars2Accounts.Where(a => a.EquippedBuilds.Count > 0).ToList();
|
||||||
|
_liebUserId = _user.LiebUserId;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async Task SignUpClicked(PlannedRaidRole role, LiebUser liebUser, bool isSignedUp, SignUpType signUpType)
|
async Task SignUpClicked(PlannedRaidRole role, LiebUser liebUser, bool isSignedUp, SignUpType signUpType)
|
||||||
{
|
{
|
||||||
if(isSignedUp)
|
if(isSignedUp && signUpType != SignUpType.Flex)
|
||||||
{
|
{
|
||||||
await RaidService.ChangeSignUpType(_raid.RaidId, liebUser.LiebUserId, role.PlannedRaidRoleId, signUpType);
|
await RaidService.ChangeSignUpType(_raid.RaidId, liebUser.LiebUserId, role.PlannedRaidRoleId, signUpType);
|
||||||
}
|
}
|
|
@ -1,37 +0,0 @@
|
||||||
@using Lieb.Models.GuildWars2.Raid
|
|
||||||
|
|
||||||
<div>
|
|
||||||
<table class="table">
|
|
||||||
<tbody>
|
|
||||||
@foreach (var role in _raid.Roles.OrderBy(r => r.PlannedRaidRoleId))
|
|
||||||
{
|
|
||||||
Models.GuildWars2.Raid.RaidSignUp[] signUps = _raid.SignUps.Where(s => s.PlannedRaidRoleId == role.PlannedRaidRoleId).ToArray();
|
|
||||||
int usedSpots = signUps.Where(s => s.SignUpType == SignUpType.SignedUp).Count();
|
|
||||||
|
|
||||||
<tr>
|
|
||||||
<td><b>@role.Name</b> (@usedSpots /@role.Spots) <br> @role.Description </td>
|
|
||||||
<td>
|
|
||||||
@foreach (var signUp in signUps)
|
|
||||||
{
|
|
||||||
if(signUp.SignUpType != SignUpType.SignedOff)
|
|
||||||
{
|
|
||||||
string signUpStatus = string.Empty;
|
|
||||||
if (signUp.SignUpType != SignUpType.SignedUp) signUpStatus = $" - {signUp.SignUpType}";
|
|
||||||
<tr>
|
|
||||||
<td>@signUp.LiebUser.Name (@signUp.GuildWars2Account.AccountName) @signUpStatus</td>
|
|
||||||
</tr>
|
|
||||||
}
|
|
||||||
}
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
}
|
|
||||||
</tbody>
|
|
||||||
</table>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
|
|
||||||
@code {
|
|
||||||
[Parameter]
|
|
||||||
public Raid _raid { get; set; }
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,9 +0,0 @@
|
||||||
h5 {
|
|
||||||
color: lightgrey;
|
|
||||||
}
|
|
||||||
|
|
||||||
table {
|
|
||||||
column-width: auto;
|
|
||||||
color: lightgray;
|
|
||||||
width: max-content;
|
|
||||||
}
|
|
|
@ -1,96 +0,0 @@
|
||||||
@using Lieb.Data
|
|
||||||
@using Lieb.Models
|
|
||||||
@using Lieb.Models.GuildWars2.Raid
|
|
||||||
@inject RaidService RaidService
|
|
||||||
|
|
||||||
<table class="table">
|
|
||||||
<tbody>
|
|
||||||
@{
|
|
||||||
RaidSignUp userRole = _raid.SignUps.Where(s => s.LiebUserId == _user.LiebUserId).FirstOrDefault();
|
|
||||||
bool isSignedUp = userRole != null;
|
|
||||||
}
|
|
||||||
@foreach (var role in _raid.Roles.OrderBy(r => r.PlannedRaidRoleId))
|
|
||||||
{
|
|
||||||
RaidSignUp[] signUps = _raid.SignUps.Where(s => s.PlannedRaidRoleId == role.PlannedRaidRoleId).ToArray();
|
|
||||||
int usedSpots = signUps.Where(s => s.SignUpType == SignUpType.SignedUp).Count();
|
|
||||||
|
|
||||||
<tr>
|
|
||||||
<td><b>@role.Name</b> (@usedSpots /@role.Spots) <br> @role.Description </td>
|
|
||||||
<td>
|
|
||||||
@foreach (var signUp in signUps)
|
|
||||||
{
|
|
||||||
@if(signUp.SignUpType != SignUpType.SignedOff)
|
|
||||||
{
|
|
||||||
<tr>
|
|
||||||
@{bool isUser = isSignedUp && userRole.PlannedRaidRole.PlannedRaidRoleId == role.PlannedRaidRoleId && signUp.LiebUserId == _user.LiebUserId;}
|
|
||||||
@{string signUpStatus = string.Empty;}
|
|
||||||
@if (signUp.SignUpType != SignUpType.SignedUp) signUpStatus = $" - {signUp.SignUpType}";
|
|
||||||
|
|
||||||
@if (isUser && _user.GuildWars2Accounts.Count > 1)
|
|
||||||
{
|
|
||||||
<td>@signUp.LiebUser.Name
|
|
||||||
<select value=@signUp.GuildWars2AccountId @onchange="args => ChangeAccount(_user, args)">
|
|
||||||
@foreach (var account in _user.GuildWars2Accounts)
|
|
||||||
{
|
|
||||||
<option value=@account.GuildWars2AccountId>@account.AccountName</option>
|
|
||||||
}
|
|
||||||
</select> @signUpStatus </td>
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
<td>@signUp.LiebUser.Name (@signUp.GuildWars2Account.AccountName) @signUpStatus</td>
|
|
||||||
}
|
|
||||||
</tr>
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
</td>
|
|
||||||
@if (RaidService.IsRoleSignUpAllowed(_raid.RaidId, _user.LiebUserId, role.PlannedRaidRoleId, SignUpType.SignedUp, false))
|
|
||||||
{
|
|
||||||
<td><button @onclick="() => SignUpClicked(role, _user, isSignedUp, SignUpType.SignedUp)">Sign Up</button></td>
|
|
||||||
<td><button @onclick="() => SignUpClicked(role, _user, isSignedUp, SignUpType.Maybe)">Maybe</button></td>
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
<td></td>
|
|
||||||
<td></td>
|
|
||||||
}
|
|
||||||
<td><button @onclick="() => SignUpClicked(role, _user, isSignedUp, SignUpType.Backup)">Backup</button></td>
|
|
||||||
@if (isSignedUp && userRole.SignUpType != SignUpType.SignedOff)
|
|
||||||
{
|
|
||||||
<td><button @onclick="() => SignUpClicked(role, _user, isSignedUp, SignUpType.Flex)">Flex</button></td>
|
|
||||||
}
|
|
||||||
</tr>
|
|
||||||
}
|
|
||||||
</tbody>
|
|
||||||
</table>
|
|
||||||
|
|
||||||
|
|
||||||
@code {
|
|
||||||
|
|
||||||
[Parameter]
|
|
||||||
public Raid _raid { get; set; }
|
|
||||||
|
|
||||||
[Parameter]
|
|
||||||
public LiebUser _user { get; set; }
|
|
||||||
|
|
||||||
async Task SignUpClicked(PlannedRaidRole role, LiebUser liebUser, bool isSignedUp, SignUpType signUpType)
|
|
||||||
{
|
|
||||||
if(isSignedUp && signUpType != SignUpType.Flex)
|
|
||||||
{
|
|
||||||
await RaidService.ChangeSignUpType(_raid.RaidId, liebUser.LiebUserId, role.PlannedRaidRoleId, signUpType);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
await RaidService.SignUp(_raid.RaidId, liebUser.LiebUserId, liebUser.GuildWars2Accounts.FirstOrDefault().GuildWars2AccountId, role.PlannedRaidRoleId, signUpType);
|
|
||||||
}
|
|
||||||
_raid = RaidService.GetRaid(_raid.RaidId);
|
|
||||||
}
|
|
||||||
|
|
||||||
async Task ChangeAccount(LiebUser liebUser, ChangeEventArgs e)
|
|
||||||
{
|
|
||||||
int accountId = int.Parse(e.Value.ToString());
|
|
||||||
await RaidService.ChangeAccount(_raid.RaidId, liebUser.LiebUserId, accountId);
|
|
||||||
_raid = RaidService.GetRaid(_raid.RaidId);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,9 +0,0 @@
|
||||||
h5 {
|
|
||||||
color: lightgrey;
|
|
||||||
}
|
|
||||||
|
|
||||||
table {
|
|
||||||
column-width: auto;
|
|
||||||
color: lightgray;
|
|
||||||
width: max-content;
|
|
||||||
}
|
|
Loading…
Add table
Add a link
Reference in a new issue