Changed Formatting, Added SignedUpUSers.razor to split up RaidRoles.razor

This commit is contained in:
t.ruspekhofer 2022-03-15 22:24:42 +01:00
parent 529236e68d
commit bca069db78
8 changed files with 111 additions and 63 deletions

View file

@ -14,7 +14,7 @@
<h5>@_raid.Title</h5> <h5>@_raid.Title</h5>
<div>@_raid.Description</div> <label style="white-space: pre-line">@_raid.Description</label>
<div > <div >
<div class="times"> <div class="times">
@ -44,13 +44,13 @@
<RaidRoles _raid=@_raid _user=@_user/> <RaidRoles _raid=@_raid _user=@_user/>
<div class="controlButtons"> <div>
<button @onclick="() => SignOffClicked()">Sign Off</button> <button class="controlButton" @onclick="() => SignOffClicked()">Sign Off</button>
<AuthorizeView Policy="@Constants.Roles.RaidLead"> <AuthorizeView Policy="@Constants.Roles.RaidLead">
<button @onclick="() => EditClicked()">Edit</button> <button class="controlButton" @onclick="() => EditClicked()">Edit</button>
@if(_raid.RaidType != RaidType.Planned) @if(_raid.RaidType != RaidType.Planned)
{ {
<button type=button @onclick="() => RandomizeClicked()">Randomize</button> <button class="controlButton" type=button @onclick="() => RandomizeClicked()">Randomize</button>
} }
</AuthorizeView> </AuthorizeView>
</div> </div>

View file

@ -2,8 +2,8 @@
background-color: rgb(38 38 38); background-color: rgb(38 38 38);
border-radius: 25px; border-radius: 25px;
padding: 25px; padding: 25px;
width: 900px; /*width: 900px;*/
/*width: fit-content;*/ width: stretch;
color: lightgray; color: lightgray;
} }
@ -27,7 +27,7 @@ h5 {
} }
.controlButtons { .controlButton {
margin-right: 10px; margin-right: 10px;
} }

View file

@ -28,7 +28,7 @@
<p> <p>
<label> <label>
Description: Description:
<InputTextArea @bind-Value="_raid.Description" /> <InputTextArea rows="8" style="width: 400px;" @bind-Value="_raid.Description" />
</label> </label>
</p> </p>
<p> <p>

View file

@ -0,0 +1,2 @@
body {
}

View file

@ -14,56 +14,28 @@
</thead> </thead>
<tbody> <tbody>
@{ @{
RaidSignUp userRole = _raid.SignUps.Where(s => s.LiebUserId == _liebUserId).FirstOrDefault(); bool isSignedUp = _raid.SignUps.Where(s => s.LiebUserId == _liebUserId && s.SignUpType != SignUpType.SignedOff).Any();
bool isSignedUp = userRole != null;
} }
@foreach (PlannedRaidRole role in _raid.Roles.OrderBy(r => r.PlannedRaidRoleId)) @foreach (PlannedRaidRole 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> <tr>
<td><b>@role.Name</b> (@usedSpots / @role.Spots) <br> @role.Description </td> <td class="tdRole">
<td> <b>@role.Name</b> (@_raid.SignUps.Where(s => s.PlannedRaidRoleId == role.PlannedRaidRoleId && s.SignUpType == SignUpType.SignedUp).Count() / @role.Spots)
<table> <br> @role.Description
@foreach (var signUp in signUps) </td>
{ <td class="tdSignUp">
@if(signUp.SignUpType != SignUpType.SignedOff) <SignedUpUsers _raid=@_raid _usableAccounts=@_usableAccounts _liebUserId=@_liebUserId _currentRoleId=@role.PlannedRaidRoleId></SignedUpUsers>
{
<tr>
@{bool isUser = isSignedUp && userRole.PlannedRaidRole.PlannedRaidRoleId == role.PlannedRaidRoleId && signUp.LiebUserId == _liebUserId;}
@{string signUpStatus = string.Empty;}
@if (signUp.SignUpType != SignUpType.SignedUp) signUpStatus = $" - {signUp.SignUpType}";
@if (isUser && _usableAccounts.Count > 1)
{
<td>@signUp.LiebUser.Name
<select value=@signUp.GuildWars2AccountId @onchange="args => ChangeAccount(_user, args)">
@foreach (var account in _usableAccounts)
{
<option value=@account.GuildWars2AccountId>@account.AccountName</option>
}
</select> @signUpStatus </td>
}
else
{
<td>@signUp.LiebUser.Name (@signUp.GuildWars2Account.AccountName) @signUpStatus</td>
}
</tr>
}
}
</table>
</td> </td>
@if(_liebUserId > 0) @if(_liebUserId > 0)
{ {
bool notIsRoleSignUpAllowed = !RaidService.IsRoleSignUpAllowed(_raid.RaidId, _user.LiebUserId, role.PlannedRaidRoleId, SignUpType.SignedUp, false); bool notIsRoleSignUpAllowed = !RaidService.IsRoleSignUpAllowed(_raid.RaidId, _liebUserId, role.PlannedRaidRoleId, SignUpType.SignedUp, false);
bool notIsBackupAllowed = _raid.RaidType != RaidType.Planned && notIsRoleSignUpAllowed; bool notIsBackupAllowed = _raid.RaidType != RaidType.Planned && notIsRoleSignUpAllowed;
<td><button @onclick="() => SignUpClicked(role, _user, isSignedUp, SignUpType.SignedUp)" disabled="@notIsRoleSignUpAllowed">Sign Up</button></td> <td class="signUpButton"><button @onclick="() => SignUpClicked(role, SignUpType.SignedUp)" disabled="@notIsRoleSignUpAllowed">Sign Up</button></td>
<td><button @onclick="() => SignUpClicked(role, _user, isSignedUp, SignUpType.Maybe)" disabled="@notIsRoleSignUpAllowed">Maybe</button></td> <td class="signUpButton"><button @onclick="() => SignUpClicked(role, SignUpType.Maybe)" disabled="@notIsRoleSignUpAllowed">Maybe</button></td>
<td><button @onclick="() => SignUpClicked(role, _user, isSignedUp, SignUpType.Backup)" disabled="@notIsBackupAllowed">Backup</button></td> <td class="signUpButton"><button @onclick="() => SignUpClicked(role, SignUpType.Backup)" disabled="@notIsBackupAllowed">Backup</button></td>
@if (isSignedUp && userRole.SignUpType != SignUpType.SignedOff && _raid.RaidType == RaidType.Planned) @if (isSignedUp && _raid.RaidType == RaidType.Planned)
{ {
<td><button @onclick="() => SignUpClicked(role, _user, isSignedUp, SignUpType.Flex)">Flex</button></td> <td><button @onclick="() => SignUpClicked(role, SignUpType.Flex)">Flex</button></td>
} }
} }
</tr> </tr>
@ -93,23 +65,16 @@
} }
} }
async Task SignUpClicked(PlannedRaidRole role, LiebUser liebUser, bool isSignedUp, SignUpType signUpType) async Task SignUpClicked(PlannedRaidRole role, SignUpType signUpType)
{ {
if(isSignedUp && signUpType != SignUpType.Flex) if(_raid.SignUps.Where(s => s.LiebUserId == _liebUserId).Any() && signUpType != SignUpType.Flex)
{ {
await RaidService.ChangeSignUpType(_raid.RaidId, liebUser.LiebUserId, role.PlannedRaidRoleId, signUpType); await RaidService.ChangeSignUpType(_raid.RaidId, _liebUserId, role.PlannedRaidRoleId, signUpType);
} }
else else
{ {
await RaidService.SignUp(_raid.RaidId, liebUser.LiebUserId, _usableAccounts.FirstOrDefault().GuildWars2AccountId, role.PlannedRaidRoleId, signUpType); await RaidService.SignUp(_raid.RaidId, _liebUserId, _usableAccounts.FirstOrDefault().GuildWars2AccountId, role.PlannedRaidRoleId, signUpType);
} }
_raid = RaidService.GetRaid(_raid.RaidId); _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);
}
} }

View file

@ -6,10 +6,31 @@ h5 {
table { table {
column-width: auto; column-width: auto;
color: lightgray; color: lightgray;
width: fit-content;
/* border-top: none; /* border-top: none;
border-bottom: none;*/ border-bottom: none;*/
} }
button {
width: max-content;
}
.signUpButton{
width: 30px;
}
.tdSignUp {
max-width: 400px;
width: fit-content;
}
.tdRole {
max-width: 500px;
width: fit-content;
}
/*.roleTable table tr:not(:first-child) > td { /*.roleTable table tr:not(:first-child) > td {
border-top: none; border-top: none;
} }

View file

@ -0,0 +1,60 @@
@using Lieb.Data
@using Lieb.Models
@using Lieb.Models.GuildWars2
@using Lieb.Models.GuildWars2.Raid
@inject RaidService RaidService
<table>
@{RaidSignUp[] signUps = _raid.SignUps.Where(s => s.PlannedRaidRoleId == _currentRoleId).ToArray();}
@foreach (var signUp in signUps)
{
@if(signUp.SignUpType != SignUpType.SignedOff)
{
<tr>
@{
bool isUser = signUp.LiebUserId == _liebUserId;
string signUpStatus = string.Empty;
@if (signUp.SignUpType != SignUpType.SignedUp) signUpStatus = $" - {signUp.SignUpType}";
}
@if (isUser && _usableAccounts.Count > 1)
{
<td>@signUp.LiebUser.Name
<select value=@signUp.GuildWars2AccountId @onchange="args => ChangeAccount(args)">
@foreach (var account in _usableAccounts)
{
<option value=@account.GuildWars2AccountId>@account.AccountName</option>
}
</select> @signUpStatus </td>
}
else
{
<td>@signUp.LiebUser.Name (@signUp.GuildWars2Account.AccountName) @signUpStatus</td>
}
</tr>
}
}
</table>
@code {
[Parameter]
public Raid _raid { get; set; }
[Parameter]
public int _liebUserId { get; set; } = -1;
[Parameter]
public List<GuildWars2Account> _usableAccounts { get; set; }
[Parameter]
public int _currentRoleId { get; set; }
async Task ChangeAccount(ChangeEventArgs e)
{
int accountId = int.Parse(e.Value.ToString());
await RaidService.ChangeAccount(_raid.RaidId, _liebUserId, accountId);
_raid = RaidService.GetRaid(_raid.RaidId);
}
}

View file

@ -75,8 +75,8 @@
} }
<tr> <tr>
<td><input type="checkbox" checked="@isEquipped" @onchange="args => EquippedStatusChanged(build.GuildWars2BuildId, args)" /></td> <td class="checkboxfield"><input type="checkbox" checked="@isEquipped" @onchange="args => EquippedStatusChanged(build.GuildWars2BuildId, args)" /></td>
<td><input type="checkbox" checked="@canTank" disabled="@(!isEquipped)" @onchange="args => TankingStatusChanged(build.GuildWars2BuildId, args)" /></td> <td class="checkboxfield"><input type="checkbox" checked="@canTank" disabled="@(!isEquipped)" @onchange="args => TankingStatusChanged(build.GuildWars2BuildId, args)" /></td>
<td>@build.BuildName</td> <td>@build.BuildName</td>
<td>@build.Class.ToString()</td> <td>@build.Class.ToString()</td>
<td>@build.EliteSpecialization.ToString()</td> <td>@build.EliteSpecialization.ToString()</td>