changing the Account now updates Flex roles in the UI

This commit is contained in:
t.ruspekhofer 2022-03-16 22:29:33 +01:00
parent bca069db78
commit 408f09f650
4 changed files with 50 additions and 33 deletions

View file

@ -16,31 +16,33 @@
<label style="white-space: pre-line">@_raid.Description</label> <label style="white-space: pre-line">@_raid.Description</label>
<div >
<div class="times"> <span class="timesblock">
<span class="times">
<h5>Date</h5> <h5>Date</h5>
<p>@_startTime.DateTime.ToLongDateString()</p> <p>@_startTime.DateTime.ToLongDateString()</p>
</div> </span>
<div class="times"> <span class="times">
<h5>Time</h5> <h5>Time</h5>
<p>from: @_startTime.DateTime.ToShortTimeString() to: @_endTime.DateTime.ToShortTimeString()</p> <p>from: @_startTime.DateTime.ToShortTimeString() to: @_endTime.DateTime.ToShortTimeString()</p>
</div> </span>
</div> </span>
<div> <span class="detailsblock">
<div class="details"> <span class="details">
<h5>Organizer</h5> <h5>Organizer</h5>
<p>@_raid.Organizer</p> <p>@_raid.Organizer</p>
</div> </span>
<div class="details"> <span class="details">
<h5>Guild</h5> <h5>Guild</h5>
<p>@_raid.Guild</p> <p>@_raid.Guild</p>
</div> </span>
<div class="details"> <span class="details">
<h5>Voice chat</h5> <h5>Voice chat</h5>
<p>@_raid.VoiceChat</p> <p>@_raid.VoiceChat</p>
</div> </span>
</div> </span>
<RaidRoles _raid=@_raid _user=@_user/> <RaidRoles _raid=@_raid _user=@_user/>

View file

@ -11,22 +11,26 @@ h5 {
color: lightgrey; color: lightgrey;
} }
.timesblock {
display: block;
}
.times { .times {
float: left; display: inline-block;
display: inline; width: 250px;
width: 49%;
padding-top: 15px; padding-top: 15px;
} }
.detailsblock {
display: block;
}
.details { .details {
float: left; display: inline-block;
display: inline; width: 250px;
width: 33%;
padding-top: 15px; padding-top: 15px;
} }
.controlButton { .controlButton {
margin-right: 10px; margin-right: 10px;
} }

View file

@ -24,7 +24,9 @@
<br> @role.Description <br> @role.Description
</td> </td>
<td class="tdSignUp"> <td class="tdSignUp">
<CascadingValue Value="this">
<SignedUpUsers _raid=@_raid _usableAccounts=@_usableAccounts _liebUserId=@_liebUserId _currentRoleId=@role.PlannedRaidRoleId></SignedUpUsers> <SignedUpUsers _raid=@_raid _usableAccounts=@_usableAccounts _liebUserId=@_liebUserId _currentRoleId=@role.PlannedRaidRoleId></SignedUpUsers>
</CascadingValue>
</td> </td>
@if(_liebUserId > 0) @if(_liebUserId > 0)
{ {
@ -59,8 +61,15 @@
protected override async Task OnParametersSetAsync() protected override async Task OnParametersSetAsync()
{ {
if (_user != null) if (_user != null)
{
if (_raid.RaidType == RaidType.Planned)
{
_usableAccounts = _user.GuildWars2Accounts.ToList();
}
else
{ {
_usableAccounts = _user.GuildWars2Accounts.Where(a => a.EquippedBuilds.Count > 0).ToList(); _usableAccounts = _user.GuildWars2Accounts.Where(a => a.EquippedBuilds.Count > 0).ToList();
}
_liebUserId = _user.LiebUserId; _liebUserId = _user.LiebUserId;
} }
} }
@ -77,4 +86,12 @@
} }
_raid = RaidService.GetRaid(_raid.RaidId); _raid = RaidService.GetRaid(_raid.RaidId);
} }
public async Task ChangeAccount(ChangeEventArgs e)
{
int accountId = int.Parse(e.Value.ToString());
await RaidService.ChangeAccount(_raid.RaidId, _liebUserId, accountId);
_raid = RaidService.GetRaid(_raid.RaidId);
this.StateHasChanged();
}
} }

View file

@ -18,10 +18,10 @@
@if (signUp.SignUpType != SignUpType.SignedUp) signUpStatus = $" - {signUp.SignUpType}"; @if (signUp.SignUpType != SignUpType.SignedUp) signUpStatus = $" - {signUp.SignUpType}";
} }
@if (isUser && _usableAccounts.Count > 1) @if (isUser && _usableAccounts.Count > 1 && signUp.SignUpType != SignUpType.Flex)
{ {
<td>@signUp.LiebUser.Name <td>@signUp.LiebUser.Name
<select value=@signUp.GuildWars2AccountId @onchange="args => ChangeAccount(args)"> <select value=@signUp.GuildWars2AccountId @onchange="args => _Parent.ChangeAccount(args)">
@foreach (var account in _usableAccounts) @foreach (var account in _usableAccounts)
{ {
<option value=@account.GuildWars2AccountId>@account.AccountName</option> <option value=@account.GuildWars2AccountId>@account.AccountName</option>
@ -37,6 +37,8 @@
} }
</table> </table>
@code { @code {
[CascadingParameter]
public RaidRoles _Parent { get; set; }
[Parameter] [Parameter]
public Raid _raid { get; set; } public Raid _raid { get; set; }
@ -49,12 +51,4 @@
[Parameter] [Parameter]
public int _currentRoleId { get; set; } 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);
}
} }