reworked RaidDetails Layout

This commit is contained in:
t.ruspekhofer 2022-03-13 20:20:14 +01:00
parent 2e92bdee5f
commit e22eea7fca
9 changed files with 92 additions and 142 deletions

View file

@ -210,12 +210,18 @@ namespace Lieb.Data
} }
} }
public async Task SignOff(int raidId, int liebUserId, int plannedRoleId) public async Task SignOff(int raidId, int liebUserId)
{ {
await ChangeSignUpType(raidId, liebUserId, plannedRoleId, SignUpType.SignedOff);
using var context = _contextFactory.CreateDbContext(); using var context = _contextFactory.CreateDbContext();
List<RaidSignUp> signUps = context.RaidSignUps.Where(x => x.RaidId == raidId && x.LiebUserId == liebUserId && x.SignUpType == SignUpType.Flex).ToList(); List<RaidSignUp> signUps = context.RaidSignUps.Where(x => x.RaidId == raidId && x.LiebUserId == liebUserId && x.SignUpType == SignUpType.Flex).ToList();
context.RaidSignUps.RemoveRange(signUps); context.RaidSignUps.RemoveRange(signUps);
RaidSignUp? signUp = context.RaidSignUps.FirstOrDefault(x => x.RaidId == raidId && x.LiebUserId == liebUserId && x.SignUpType != SignUpType.Flex);
if (signUp != null)
{
signUp.SignUpType = SignUpType.SignedOff;
}
await context.SaveChangesAsync(); await context.SaveChangesAsync();
} }

View file

@ -59,6 +59,7 @@
<AuthorizeView Policy="@Constants.Roles.RaidLead"> <AuthorizeView Policy="@Constants.Roles.RaidLead">
<td><button @onclick="() => SignOffClicked()">Sign Off</button></td>
<div class="nav-item px-3"> <div class="nav-item px-3">
@{string navLink = $"raidedit/{_raid.RaidId}";} @{string navLink = $"raidedit/{_raid.RaidId}";}
<NavLink class="nav-link" href="@navLink"> <NavLink class="nav-link" href="@navLink">
@ -96,22 +97,9 @@
_freeForAllTime = await TimeZoneService.GetLocalDateTime(_raid.FreeForAllTimeUTC); _freeForAllTime = await TimeZoneService.GetLocalDateTime(_raid.FreeForAllTimeUTC);
} }
async Task SignUpClicked(PlannedRaidRole role, LiebUser liebUser, bool isSignedUp, SignUpType signUpType) async Task SignOffClicked()
{ {
if(isSignedUp) await RaidService.SignOff(_raid.RaidId, _user.LiebUserId);
{
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); _raid = RaidService.GetRaid(_raid.RaidId);
} }
@ -120,11 +108,4 @@
await RaidRandomizerService.RandomizeRaid(_raid.RaidId); await RaidRandomizerService.RandomizeRaid(_raid.RaidId);
_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

@ -2,7 +2,7 @@
background-color: rgb(38 38 38); background-color: rgb(38 38 38);
border-radius: 25px; border-radius: 25px;
padding: 25px; padding: 25px;
width: 700px; width: 900px;
/*width: fit-content;*/ /*width: fit-content;*/
color: lightgray; color: lightgray;
} }
@ -22,7 +22,7 @@ h5 {
.details { .details {
float: left; float: left;
display: inline; display: inline;
width: 150px; width: 33%;
padding-top: 15px; padding-top: 15px;
} }

View file

@ -9,19 +9,21 @@
int usedSpots = signUps.Where(s => s.SignUpType == SignUpType.SignedUp).Count(); int usedSpots = signUps.Where(s => s.SignUpType == SignUpType.SignedUp).Count();
<tr> <tr>
<td><h5>@role.Name: @role.Description (@usedSpots /@role.Spots)</h5></td> <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> </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> </tbody>
</table> </table>

View file

@ -15,6 +15,36 @@
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>
@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)) @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.SignedUp)">Sign Up</button></td>
@ -30,53 +60,11 @@
{ {
<td><button @onclick="() => SignUpClicked(role, _user, isSignedUp, SignUpType.Flex)">Flex</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> </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 && _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>
}
}
} }
</tbody> </tbody>
</table> </table>
@code { @code {
@ -99,12 +87,6 @@
_raid = RaidService.GetRaid(_raid.RaidId); _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) async Task ChangeAccount(LiebUser liebUser, ChangeEventArgs e)
{ {
int accountId = int.Parse(e.Value.ToString()); int accountId = int.Parse(e.Value.ToString());

View file

@ -16,57 +16,42 @@
int usedSpots = signUps.Where(s => s.SignUpType == SignUpType.SignedUp).Count(); int usedSpots = signUps.Where(s => s.SignUpType == SignUpType.SignedUp).Count();
<tr> <tr>
@if (role.IsRandomSignUpRole && _raid.SignUps.Where(s => s.SignUpType == SignUpType.SignedUp).Count() < 10) <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 && _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>
}
}
</td>
@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.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.Maybe)">Maybe</button></td>
<td><button @onclick="() => SignUpClicked(role, _user, isSignedUp, SignUpType.Backup)">Backup</button></td> <td><button @onclick="() => SignUpClicked(role, _user, isSignedUp, SignUpType.Backup)">Backup</button></td>
} }
else
{
<td></td>
<td></td>
<td></td>
}
<td><h5>@role.Name: @role.Description (@usedSpots /@role.Spots)</h5></td>
</tr> </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(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 && _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>
}
}
} }
</tbody> </tbody>
</table> </table>
@ -100,12 +85,6 @@
_raid = RaidService.GetRaid(_raid.RaidId); _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) async Task ChangeAccount(LiebUser liebUser, ChangeEventArgs e)
{ {
int accountId = int.Parse(e.Value.ToString()); int accountId = int.Parse(e.Value.ToString());

View file

@ -50,7 +50,7 @@
@foreach (var role in _template.Roles.OrderBy(r => r.PlannedRaidRoleId)) @foreach (var role in _template.Roles.OrderBy(r => r.PlannedRaidRoleId))
{ {
<tr> <tr>
<td><h5>@role.Name: @role.Description (@role.Spots)</h5></td> <td><Label> <b>@role.Name</b> (@role.Spots) <br> @role.Description </Label></td>
</tr> </tr>
} }
</tbody> </tbody>

View file

@ -22,7 +22,7 @@ h5 {
.details { .details {
float: left; float: left;
display: inline; display: inline;
width: 150px; width: 33%;
padding-top: 15px; padding-top: 15px;
} }

View file

@ -52,10 +52,10 @@
} }
</select> </select>
</label> </label>
<table> <table id="classTable">
<tr> <tr>
<th>Equipped</th> <th>Equipped</th>
<th>can Tank</th> <th>Tank</th>
<th>Build</th> <th>Build</th>
<th>Class</th> <th>Class</th>
<th>Elite</th> <th>Elite</th>