Add PNG icon support for shift types (#18)
* Initial plan * Add PNG icon support for shifts with sample coffee cup icon Co-authored-by: clayschaad <11883505+clayschaad@users.noreply.github.com> * Add more icons --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: clayschaad <11883505+clayschaad@users.noreply.github.com> Co-authored-by: Claudio Schaad <c.schaad@pog.ch>
|
|
@ -40,7 +40,14 @@ else
|
|||
}
|
||||
else
|
||||
{
|
||||
@shift.Icon
|
||||
@if (shift.IsPngIcon)
|
||||
{
|
||||
<img src="icons\@shift.Icon" alt="@shift.Name" style="width: 24px; height: 24px;" />
|
||||
}
|
||||
else
|
||||
{
|
||||
@shift.Icon
|
||||
}
|
||||
}
|
||||
</button>
|
||||
<span class="tooltip">@shift.Name</span>
|
||||
|
|
|
|||
|
|
@ -16,4 +16,31 @@
|
|||
<ProjectReference Include="..\Services\ShiftScheduler.Services.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Content Update="wwwroot\break-icon.png">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</Content>
|
||||
<Content Update="wwwroot\icons\break-icon.png">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</Content>
|
||||
<Content Update="wwwroot\icons\G2.png">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</Content>
|
||||
<Content Update="wwwroot\icons\Bg.png">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</Content>
|
||||
<Content Update="wwwroot\icons\F1.png">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</Content>
|
||||
<Content Update="wwwroot\icons\G1.png">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</Content>
|
||||
<Content Update="wwwroot\icons\G2TS.png">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</Content>
|
||||
<Content Update="wwwroot\icons\Kompensation.png">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</Content>
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
|
|
|||
BIN
Client/wwwroot/icons/Bg.png
Normal file
|
After Width: | Height: | Size: 2.8 KiB |
BIN
Client/wwwroot/icons/F1.png
Normal file
|
After Width: | Height: | Size: 2.8 KiB |
BIN
Client/wwwroot/icons/G1.png
Normal file
|
After Width: | Height: | Size: 2.8 KiB |
BIN
Client/wwwroot/icons/G2.png
Normal file
|
After Width: | Height: | Size: 15 KiB |
BIN
Client/wwwroot/icons/G2TS.png
Normal file
|
After Width: | Height: | Size: 23 KiB |
BIN
Client/wwwroot/icons/Kompensation.png
Normal file
|
After Width: | Height: | Size: 3 KiB |
BIN
Client/wwwroot/icons/break-icon.png
Normal file
|
After Width: | Height: | Size: 186 B |
|
|
@ -28,6 +28,12 @@
|
|||
"MorningTime": "",
|
||||
"AfternoonTime": ""
|
||||
},
|
||||
{
|
||||
"Name": "Pause",
|
||||
"Icon": "break-icon.png",
|
||||
"MorningTime": "10:00-10:15",
|
||||
"AfternoonTime": "15:00-15:15"
|
||||
},
|
||||
{
|
||||
"Name": "Früh",
|
||||
"Icon": "🌅",
|
||||
|
|
|
|||
|
|
@ -98,20 +98,27 @@ namespace ShiftScheduler.Services
|
|||
foreach (var day in Enumerable.Range(0, dayInWeek))
|
||||
{
|
||||
var shiftWithTransport = shiftsWithTransport.GetValueOrDefault(weekDates.ElementAtOrDefault(day));
|
||||
var icon = shiftWithTransport?.Shift.Icon ?? "";
|
||||
table.Cell().Element(CellStyleMiddle).Text(icon);
|
||||
}
|
||||
foreach (var day in Enumerable.Range(dayInWeek, 7 - dayInWeek))
|
||||
{
|
||||
RenderEmptyCell(table);
|
||||
}
|
||||
var shift = shiftWithTransport?.Shift;
|
||||
|
||||
// Shifname
|
||||
foreach (var day in Enumerable.Range(0, dayInWeek))
|
||||
{
|
||||
var shiftWithTransport = shiftsWithTransport.GetValueOrDefault(weekDates.ElementAtOrDefault(day));
|
||||
var shiftName = shiftWithTransport?.Shift.Name ?? "";
|
||||
table.Cell().Element(CellStyleMiddle).Text(shiftName);
|
||||
if (shift != null && shift.IsPngIcon)
|
||||
{
|
||||
// For PNG icons, embed the image
|
||||
var iconPath = Path.Combine(AppContext.BaseDirectory, "wwwroot", "icons", shift.Icon);
|
||||
if (File.Exists(iconPath))
|
||||
{
|
||||
table.Cell().Height(24).Element(CellStyleMiddle).Image(iconPath).FitArea();
|
||||
}
|
||||
else
|
||||
{
|
||||
table.Cell().Element(CellStyleMiddle).Text(shift.Name);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// For text/emoji icons, render as text
|
||||
var icon = shift?.Icon ?? shift?.Name;
|
||||
table.Cell().Element(CellStyleMiddle).Text(icon);
|
||||
}
|
||||
}
|
||||
foreach (var day in Enumerable.Range(dayInWeek, 7 - dayInWeek))
|
||||
{
|
||||
|
|
@ -122,7 +129,7 @@ namespace ShiftScheduler.Services
|
|||
foreach (var day in Enumerable.Range(0, dayInWeek))
|
||||
{
|
||||
var shiftWithTransport = shiftsWithTransport.GetValueOrDefault(weekDates.ElementAtOrDefault(day));
|
||||
var morningTime = $"🌅 {shiftWithTransport?.Shift.MorningTime}";
|
||||
var morningTime = shiftWithTransport?.Shift.MorningTime.Length > 0 ? $"🌅 {shiftWithTransport?.Shift.MorningTime}" : "";
|
||||
table.Cell().Element(CellStyleMiddle).Text(morningTime);
|
||||
}
|
||||
foreach (var day in Enumerable.Range(dayInWeek, 7 - dayInWeek))
|
||||
|
|
@ -134,7 +141,7 @@ namespace ShiftScheduler.Services
|
|||
foreach (var day in Enumerable.Range(0, dayInWeek))
|
||||
{
|
||||
var shiftWithTransport = shiftsWithTransport.GetValueOrDefault(weekDates.ElementAtOrDefault(day));
|
||||
var afternoonTime = $"🌆 {shiftWithTransport?.Shift.AfternoonTime}";
|
||||
var afternoonTime = shiftWithTransport?.Shift.AfternoonTime.Length > 0 ? $"🌆 {shiftWithTransport?.Shift.AfternoonTime}" : "";
|
||||
table.Cell().Element(CellStyleMiddle).Text(afternoonTime);
|
||||
}
|
||||
foreach (var day in Enumerable.Range(dayInWeek, 7 - dayInWeek))
|
||||
|
|
@ -181,7 +188,7 @@ namespace ShiftScheduler.Services
|
|||
transportLines.Add(afternoonInfo);
|
||||
}
|
||||
|
||||
return transportLines.Count > 0 ? string.Join("\n", transportLines) : "-";
|
||||
return transportLines.Count > 0 ? string.Join("\n", transportLines) : "";
|
||||
}
|
||||
|
||||
private static string FormatTransportConnection(TransportConnection transport)
|
||||
|
|
|
|||
|
|
@ -6,5 +6,7 @@ namespace ShiftScheduler.Shared.Models
|
|||
public string Icon { get; set; } = string.Empty;
|
||||
public string MorningTime { get; set; } = string.Empty;
|
||||
public string AfternoonTime { get; set; } = string.Empty;
|
||||
|
||||
public bool IsPngIcon => Icon.EndsWith(".png", StringComparison.OrdinalIgnoreCase);
|
||||
}
|
||||
}
|
||||
|
|
|
|||