split the role tables from RaidDetails into their own razor files
This commit is contained in:
parent
75b8fd13fc
commit
c298f4d20e
5 changed files with 204 additions and 107 deletions
|
@ -7,6 +7,9 @@
|
|||
@inject RaidRandomizerService RaidRandomizerService
|
||||
|
||||
<body>
|
||||
|
||||
<label>@_errorMessage</label>
|
||||
|
||||
<h5>@_raid.Title</h5>
|
||||
|
||||
<div>@_raid.Description</div>
|
||||
|
@ -37,115 +40,23 @@
|
|||
</div>
|
||||
</div>
|
||||
|
||||
<AuthorizeView Policy="@Constants.Roles.User">
|
||||
<Authorized>
|
||||
@{
|
||||
ulong discordId = ulong.Parse(@context.User.Claims.FirstOrDefault(c => c.Type == ClaimTypes.NameIdentifier).Value);
|
||||
LiebUser user = UserService.GetLiebUser(discordId);
|
||||
RaidSignUp userRole = _raid.SignUps.Where(s => s.LiebUserId == user.LiebUserId).FirstOrDefault();
|
||||
bool isSignedUp = userRole != null;
|
||||
bool isRaidSignUpAllowed = RaidService.IsRaidSignUpAllowed(user.LiebUserId, _raid.RaidId, out string errorMessage);
|
||||
}
|
||||
<label>@errorMessage</label>
|
||||
<table class="table">
|
||||
<tbody>
|
||||
@foreach (var role in _raid.Roles)
|
||||
@if(_isRaidSignUpAllowed)
|
||||
{
|
||||
RaidSignUp[] signUps = _raid.SignUps.Where(s => s.PlannedRaidRoleId == role.PlannedRaidRoleId).ToArray();
|
||||
int usedSpots = signUps.Where(s => s.SignUpType == SignUpType.SignedUp).Count();
|
||||
|
||||
<tr>
|
||||
@if (isRaidSignUpAllowed)
|
||||
if(_raid.RaidType == RaidType.Planned)
|
||||
{
|
||||
@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>
|
||||
<RaidRolesPlanned _raid=@_raid _user=@_user/>
|
||||
}
|
||||
else
|
||||
{
|
||||
<td></td>
|
||||
<td></td>
|
||||
<RaidRolesPlanned _raid=@_raid _user=@_user/>
|
||||
}
|
||||
<td><button @onclick="() => SignUpClicked(role, user, isSignedUp, SignUpType.Backup)">Backup</button></td>
|
||||
<td><button @onclick="() => SignUpClicked(role, user, isSignedUp, SignUpType.Flex)">Flex</button></td>
|
||||
}
|
||||
<td><h5>@role.Name: @role.Description (@usedSpots /@role.Spots)</h5></td>
|
||||
</tr>
|
||||
|
||||
@foreach (var signUp in signUps)
|
||||
{
|
||||
@if(signUp.SignUpType != SignUpType.SignedOff)
|
||||
{
|
||||
<tr>
|
||||
@{bool isUser = isSignedUp && userRole.PlannedRaidRole.PlannedRaidRoleId == role.PlannedRaidRoleId && signUp.LiebUserId == user.LiebUserId;}
|
||||
@if (isRaidSignUpAllowed)
|
||||
{
|
||||
<td></td>
|
||||
<td></td>
|
||||
<td></td>
|
||||
@if(isUser)
|
||||
{
|
||||
<td><button @onclick="() => SignOffClicked(role, user)">Sign Off</button></td>
|
||||
}
|
||||
else
|
||||
{
|
||||
<td></td>
|
||||
<RaidRolesNoSignUp _raid=@_raid/>
|
||||
}
|
||||
}
|
||||
@{string signUpStatus = string.Empty;}
|
||||
@if (signUp.SignUpType != SignUpType.SignedUp) signUpStatus = $" - {signUp.SignUpType}";
|
||||
|
||||
@if (isUser)
|
||||
{
|
||||
<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>
|
||||
}
|
||||
}
|
||||
}
|
||||
</tbody>
|
||||
</table>
|
||||
</Authorized>
|
||||
<NotAuthorized>
|
||||
<div>
|
||||
<table class="table">
|
||||
<tbody>
|
||||
@foreach (var role in _raid.Roles)
|
||||
{
|
||||
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><h5>@role.Name: @role.Description (@usedSpots /@role.Spots)</h5></td>
|
||||
</tr>
|
||||
@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>
|
||||
}
|
||||
}
|
||||
}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</NotAuthorized>
|
||||
</AuthorizeView>
|
||||
<AuthorizeView Policy="@Constants.Roles.RaidLead">
|
||||
<div class="nav-item px-3">
|
||||
@{string navLink = $"raidedit/{_raid.RaidId}";}
|
||||
|
@ -168,6 +79,15 @@
|
|||
[Parameter]
|
||||
public LiebUser? _user { get; set; }
|
||||
|
||||
bool _isRaidSignUpAllowed;
|
||||
|
||||
string _errorMessage;
|
||||
|
||||
protected override async Task OnInitializedAsync()
|
||||
{
|
||||
_isRaidSignUpAllowed = _user != null && RaidService.IsRaidSignUpAllowed(_user.LiebUserId, _raid.RaidId, out string _errorMessage);
|
||||
}
|
||||
|
||||
async Task SignUpClicked(PlannedRaidRole role, LiebUser liebUser, bool isSignedUp, SignUpType signUpType)
|
||||
{
|
||||
if(isSignedUp)
|
||||
|
|
35
Lieb/Pages/Raids/RaidRolesNoSignUp.razor
Normal file
35
Lieb/Pages/Raids/RaidRolesNoSignUp.razor
Normal file
|
@ -0,0 +1,35 @@
|
|||
@using Lieb.Models.GuildWars2.Raid
|
||||
|
||||
<div>
|
||||
<table class="roleTable">
|
||||
<tbody>
|
||||
@foreach (var role in _raid.Roles)
|
||||
{
|
||||
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><h5>@role.Name: @role.Description (@usedSpots /@role.Spots)</h5></td>
|
||||
</tr>
|
||||
@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>
|
||||
}
|
||||
}
|
||||
}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
|
||||
@code {
|
||||
[Parameter]
|
||||
public Raid _raid { get; set; }
|
||||
|
||||
}
|
9
Lieb/Pages/Raids/RaidRolesNoSignUp.razor.css
Normal file
9
Lieb/Pages/Raids/RaidRolesNoSignUp.razor.css
Normal file
|
@ -0,0 +1,9 @@
|
|||
h5 {
|
||||
color: lightgrey;
|
||||
}
|
||||
|
||||
table {
|
||||
column-width: auto;
|
||||
color: lightgray;
|
||||
width: max-content;
|
||||
}
|
114
Lieb/Pages/Raids/RaidRolesPlanned.razor
Normal file
114
Lieb/Pages/Raids/RaidRolesPlanned.razor
Normal file
|
@ -0,0 +1,114 @@
|
|||
@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)
|
||||
{
|
||||
RaidSignUp[] signUps = _raid.SignUps.Where(s => s.PlannedRaidRoleId == role.PlannedRaidRoleId).ToArray();
|
||||
int usedSpots = signUps.Where(s => s.SignUpType == SignUpType.SignedUp).Count();
|
||||
|
||||
<tr>
|
||||
@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>
|
||||
}
|
||||
<td><h5>@role.Name: @role.Description (@usedSpots /@role.Spots)</h5></td>
|
||||
</tr>
|
||||
|
||||
@foreach (var signUp in signUps)
|
||||
{
|
||||
@if(signUp.SignUpType != SignUpType.SignedOff)
|
||||
{
|
||||
<tr>
|
||||
@{bool isUser = isSignedUp && userRole.PlannedRaidRole.PlannedRaidRoleId == role.PlannedRaidRoleId && signUp.LiebUserId == _user.LiebUserId;}
|
||||
<td></td>
|
||||
<td></td>
|
||||
@if (isSignedUp && userRole.SignUpType != SignUpType.SignedOff)
|
||||
{
|
||||
<td></td>
|
||||
}
|
||||
@if(isUser)
|
||||
{
|
||||
<td><button @onclick="() => SignOffClicked(role, _user)">Sign Off</button></td>
|
||||
}
|
||||
else
|
||||
{
|
||||
<td></td>
|
||||
}
|
||||
@{string signUpStatus = string.Empty;}
|
||||
@if (signUp.SignUpType != SignUpType.SignedUp) signUpStatus = $" - {signUp.SignUpType}";
|
||||
|
||||
@if (isUser)
|
||||
{
|
||||
<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>
|
||||
}
|
||||
}
|
||||
}
|
||||
</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 SignOffClicked(PlannedRaidRole role, LiebUser liebUser)
|
||||
{
|
||||
await RaidService.SignOff(_raid.RaidId, liebUser.LiebUserId, role.PlannedRaidRoleId);
|
||||
_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);
|
||||
}
|
||||
}
|
19
Lieb/Pages/Raids/RaidRolesPlanned.razor.css
Normal file
19
Lieb/Pages/Raids/RaidRolesPlanned.razor.css
Normal file
|
@ -0,0 +1,19 @@
|
|||
|
||||
h5 {
|
||||
color: lightgrey;
|
||||
}
|
||||
|
||||
table {
|
||||
column-width: auto;
|
||||
color: lightgray;
|
||||
/* border-top: none;
|
||||
border-bottom: none;*/
|
||||
}
|
||||
|
||||
/*.roleTable table tr:not(:first-child) > td {
|
||||
border-top: none;
|
||||
}
|
||||
|
||||
.roleTable table tr:not(:last-child) > td {
|
||||
border-bottom: none;
|
||||
}*/
|
Loading…
Add table
Add a link
Reference in a new issue