Various CSS work
This commit is contained in:
parent
ef174af0e1
commit
15579acba8
52 changed files with 8001 additions and 944 deletions
|
|
@ -0,0 +1,34 @@
|
|||
@model PlanTempus.Application.Features.Employees.Components.EmployeeTableViewModel
|
||||
|
||||
<swp-users-header>
|
||||
<swp-users-count>
|
||||
<strong>@Model.CurrentCount af @Model.MaxCount</strong> @Model.CountLabel
|
||||
<swp-users-progress>
|
||||
<swp-users-progress-bar style="width: @Model.ProgressPercent.ToString("F1", System.Globalization.CultureInfo.InvariantCulture)%"></swp-users-progress-bar>
|
||||
</swp-users-progress>
|
||||
</swp-users-count>
|
||||
<swp-btn class="primary">
|
||||
<i class="ph ph-user-plus"></i>
|
||||
@Model.InviteButtonText
|
||||
</swp-btn>
|
||||
</swp-users-header>
|
||||
|
||||
<swp-employee-table-card>
|
||||
<swp-employee-table>
|
||||
<swp-employee-table-header>
|
||||
<swp-employee-row>
|
||||
<swp-employee-cell>@Model.ColumnUser</swp-employee-cell>
|
||||
<swp-employee-cell>@Model.ColumnRole</swp-employee-cell>
|
||||
<swp-employee-cell>@Model.ColumnStatus</swp-employee-cell>
|
||||
<swp-employee-cell>@Model.ColumnLastActive</swp-employee-cell>
|
||||
<swp-employee-cell></swp-employee-cell>
|
||||
</swp-employee-row>
|
||||
</swp-employee-table-header>
|
||||
<swp-employee-table-body>
|
||||
@foreach (var employeeKey in Model.EmployeeKeys)
|
||||
{
|
||||
@await Component.InvokeAsync("EmployeeRow", employeeKey)
|
||||
}
|
||||
</swp-employee-table-body>
|
||||
</swp-employee-table>
|
||||
</swp-employee-table-card>
|
||||
|
|
@ -0,0 +1,77 @@
|
|||
using Microsoft.AspNetCore.Mvc;
|
||||
using PlanTempus.Application.Features.Localization.Services;
|
||||
|
||||
namespace PlanTempus.Application.Features.Employees.Components;
|
||||
|
||||
public class EmployeeTableViewComponent : ViewComponent
|
||||
{
|
||||
private readonly ILocalizationService _localization;
|
||||
|
||||
public EmployeeTableViewComponent(ILocalizationService localization)
|
||||
{
|
||||
_localization = localization;
|
||||
}
|
||||
|
||||
public IViewComponentResult Invoke(string key)
|
||||
{
|
||||
var model = EmployeeTableCatalog.Get(key, _localization);
|
||||
return View(model);
|
||||
}
|
||||
}
|
||||
|
||||
public class EmployeeTableViewModel
|
||||
{
|
||||
public required string Key { get; init; }
|
||||
public required int CurrentCount { get; init; }
|
||||
public required int MaxCount { get; init; }
|
||||
public required string CountLabel { get; init; }
|
||||
public required string InviteButtonText { get; init; }
|
||||
public required string ColumnUser { get; init; }
|
||||
public required string ColumnRole { get; init; }
|
||||
public required string ColumnStatus { get; init; }
|
||||
public required string ColumnLastActive { get; init; }
|
||||
public required IReadOnlyList<string> EmployeeKeys { get; init; }
|
||||
public double ProgressPercent => MaxCount > 0 ? (double)CurrentCount / MaxCount * 100 : 0;
|
||||
}
|
||||
|
||||
internal class EmployeeTableData
|
||||
{
|
||||
public required string Key { get; init; }
|
||||
public required int CurrentCount { get; init; }
|
||||
public required int MaxCount { get; init; }
|
||||
public required IReadOnlyList<string> EmployeeKeys { get; init; }
|
||||
}
|
||||
|
||||
public static class EmployeeTableCatalog
|
||||
{
|
||||
private static readonly Dictionary<string, EmployeeTableData> Tables = new()
|
||||
{
|
||||
["all-employees"] = new EmployeeTableData
|
||||
{
|
||||
Key = "all-employees",
|
||||
CurrentCount = 5,
|
||||
MaxCount = 8,
|
||||
EmployeeKeys = ["employee-1", "employee-2", "employee-3", "employee-4", "employee-5"]
|
||||
}
|
||||
};
|
||||
|
||||
public static EmployeeTableViewModel Get(string key, ILocalizationService localization)
|
||||
{
|
||||
if (!Tables.TryGetValue(key, out var table))
|
||||
throw new KeyNotFoundException($"EmployeeTable with key '{key}' not found");
|
||||
|
||||
return new EmployeeTableViewModel
|
||||
{
|
||||
Key = table.Key,
|
||||
CurrentCount = table.CurrentCount,
|
||||
MaxCount = table.MaxCount,
|
||||
CountLabel = localization.Get("employees.users.count"),
|
||||
InviteButtonText = localization.Get("employees.users.inviteUser"),
|
||||
ColumnUser = localization.Get("employees.users.columns.user"),
|
||||
ColumnRole = localization.Get("employees.users.columns.role"),
|
||||
ColumnStatus = localization.Get("employees.users.columns.status"),
|
||||
ColumnLastActive = localization.Get("employees.users.columns.lastActive"),
|
||||
EmployeeKeys = table.EmployeeKeys
|
||||
};
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue