refactor initial company list

This commit is contained in:
Frede Hundewadt 2022-04-09 10:08:23 +02:00
parent b70317db4e
commit 0181ca0503
3 changed files with 23 additions and 13 deletions

View file

@ -19,20 +19,25 @@
@using Wonky.Client.Helpers; @using Wonky.Client.Helpers;
@if (Companies.Any()) @if (Companies.Any())
{ {
<table class="table"> <div class="container">
<tbody> <ul class="list-group">
@foreach (var company in Companies) @foreach (var company in Companies)
{ {
<tr> <li class="d-flex justify-content-between align-items-start list-group-item list-group-item-action" style="cursor:pointer" @onclick="() => NavigateCompany(company.CompanyId)">
<td style="width:50px;"><DisplayStateComponent StateClass="@(company.HasFolded == 1 ? "the-dead" : Utils.GetVisitState(company.NextVisit))"></DisplayStateComponent></td> <div class="me-auto">
<td>@company.Name</td> <div class="fw-bold mb-1">
<td>@company.Account</td> <DisplayStateComponent StateClass="@(company.HasFolded == 1 ? "the-dead" : Utils.GetVisitState(company.NextVisit))"></DisplayStateComponent>@company.Name
<td>@company.City</td> </div>
<td><a class="btn btn-primary mb-1" href="/company/@company.CompanyId">Vis</a></td> <div>
</tr> <span class="fw-bold me-1">Konto:</span>@company.Account<span class="fw-bold mx-1">Bynavn:</span>@company.City
</div>
</div>
<span class="badge bg-primary">Vis</span>
</li>
} }
</tbody> </ul>
</table> </div>
} }
else else
{ {

View file

@ -14,7 +14,6 @@
// along with this program. If not, see [https://www.gnu.org/licenses/agpl-3.0.en.html] // along with this program. If not, see [https://www.gnu.org/licenses/agpl-3.0.en.html]
// //
using Microsoft.AspNetCore.Components; using Microsoft.AspNetCore.Components;
using Wonky.Client.Shared; using Wonky.Client.Shared;
using Wonky.Entity.DTO; using Wonky.Entity.DTO;
@ -26,6 +25,7 @@ namespace Wonky.Client.Components
[Parameter] public List<CompanyDto> Companies { get; set; } = new(); [Parameter] public List<CompanyDto> Companies { get; set; } = new();
[Parameter] public EventCallback<string> OnDelete { get; set; } [Parameter] public EventCallback<string> OnDelete { get; set; }
[Parameter] public EventCallback<string> OnSelect { get; set; } [Parameter] public EventCallback<string> OnSelect { get; set; }
[Inject] public NavigationManager NavManager { get; set; }
private Confirmation _confirmation = new (); private Confirmation _confirmation = new ();
private string _companyId = string.Empty; private string _companyId = string.Empty;
@ -41,5 +41,10 @@ namespace Wonky.Client.Components
_confirmation.Hide(); _confirmation.Hide();
await OnDelete.InvokeAsync(_companyId); await OnDelete.InvokeAsync(_companyId);
} }
private void NavigateCompany(string companyId)
{
NavManager.NavigateTo($"/company/{companyId}");
}
} }
} }

View file

@ -15,7 +15,7 @@
// //
*@ *@
<img class="img-fluid float-start rounded-circle state @StateClass mx-3" src="state.png" alt="state"/> <img class="img-fluid float-start rounded-circle state @StateClass me-1" src="state.png" alt="state"/>
@code{ @code{
[Parameter] public string StateClass { get; set; } = "the-dead"; [Parameter] public string StateClass { get; set; } = "the-dead";
} }