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>
<div >
<div class="times">
<span class="timesblock">
<span class="times">
<h5>Date</h5>
<p>@_startTime.DateTime.ToLongDateString()</p>
</div>
<div class="times">
</span>
<span class="times">
<h5>Time</h5>
<p>from: @_startTime.DateTime.ToShortTimeString() to: @_endTime.DateTime.ToShortTimeString()</p>
</div>
</div>
</span>
</span>
<div>
<div class="details">
<span class="detailsblock">
<span class="details">
<h5>Organizer</h5>
<p>@_raid.Organizer</p>
</div>
<div class="details">
</span>
<span class="details">
<h5>Guild</h5>
<p>@_raid.Guild</p>
</div>
<div class="details">
</span>
<span class="details">
<h5>Voice chat</h5>
<p>@_raid.VoiceChat</p>
</div>
</div>
</span>
</span>
<RaidRoles _raid=@_raid _user=@_user/>

View file

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

View file

@ -24,7 +24,9 @@
<br> @role.Description
</td>
<td class="tdSignUp">
<CascadingValue Value="this">
<SignedUpUsers _raid=@_raid _usableAccounts=@_usableAccounts _liebUserId=@_liebUserId _currentRoleId=@role.PlannedRaidRoleId></SignedUpUsers>
</CascadingValue>
</td>
@if(_liebUserId > 0)
{
@ -59,8 +61,15 @@
protected override async Task OnParametersSetAsync()
{
if (_user != null)
{
if (_raid.RaidType == RaidType.Planned)
{
_usableAccounts = _user.GuildWars2Accounts.ToList();
}
else
{
_usableAccounts = _user.GuildWars2Accounts.Where(a => a.EquippedBuilds.Count > 0).ToList();
}
_liebUserId = _user.LiebUserId;
}
}
@ -77,4 +86,12 @@
}
_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 (isUser && _usableAccounts.Count > 1)
@if (isUser && _usableAccounts.Count > 1 && signUp.SignUpType != SignUpType.Flex)
{
<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)
{
<option value=@account.GuildWars2AccountId>@account.AccountName</option>
@ -37,6 +37,8 @@
}
</table>
@code {
[CascadingParameter]
public RaidRoles _Parent { get; set; }
[Parameter]
public Raid _raid { get; set; }
@ -49,12 +51,4 @@
[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);
}
}