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
|
else
|
||||||
{
|
{
|
||||||
@shift.Icon
|
@if (shift.IsPngIcon)
|
||||||
|
{
|
||||||
|
<img src="icons\@shift.Icon" alt="@shift.Name" style="width: 24px; height: 24px;" />
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
@shift.Icon
|
||||||
|
}
|
||||||
}
|
}
|
||||||
</button>
|
</button>
|
||||||
<span class="tooltip">@shift.Name</span>
|
<span class="tooltip">@shift.Name</span>
|
||||||
|
|
|
||||||
|
|
@ -16,4 +16,31 @@
|
||||||
<ProjectReference Include="..\Services\ShiftScheduler.Services.csproj" />
|
<ProjectReference Include="..\Services\ShiftScheduler.Services.csproj" />
|
||||||
</ItemGroup>
|
</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>
|
</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": "",
|
"MorningTime": "",
|
||||||
"AfternoonTime": ""
|
"AfternoonTime": ""
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"Name": "Pause",
|
||||||
|
"Icon": "break-icon.png",
|
||||||
|
"MorningTime": "10:00-10:15",
|
||||||
|
"AfternoonTime": "15:00-15:15"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"Name": "Früh",
|
"Name": "Früh",
|
||||||
"Icon": "🌅",
|
"Icon": "🌅",
|
||||||
|
|
|
||||||
|
|
@ -98,20 +98,27 @@ namespace ShiftScheduler.Services
|
||||||
foreach (var day in Enumerable.Range(0, dayInWeek))
|
foreach (var day in Enumerable.Range(0, dayInWeek))
|
||||||
{
|
{
|
||||||
var shiftWithTransport = shiftsWithTransport.GetValueOrDefault(weekDates.ElementAtOrDefault(day));
|
var shiftWithTransport = shiftsWithTransport.GetValueOrDefault(weekDates.ElementAtOrDefault(day));
|
||||||
var icon = shiftWithTransport?.Shift.Icon ?? "";
|
var shift = shiftWithTransport?.Shift;
|
||||||
table.Cell().Element(CellStyleMiddle).Text(icon);
|
|
||||||
}
|
if (shift != null && shift.IsPngIcon)
|
||||||
foreach (var day in Enumerable.Range(dayInWeek, 7 - dayInWeek))
|
{
|
||||||
{
|
// For PNG icons, embed the image
|
||||||
RenderEmptyCell(table);
|
var iconPath = Path.Combine(AppContext.BaseDirectory, "wwwroot", "icons", shift.Icon);
|
||||||
}
|
if (File.Exists(iconPath))
|
||||||
|
{
|
||||||
// Shifname
|
table.Cell().Height(24).Element(CellStyleMiddle).Image(iconPath).FitArea();
|
||||||
foreach (var day in Enumerable.Range(0, dayInWeek))
|
}
|
||||||
{
|
else
|
||||||
var shiftWithTransport = shiftsWithTransport.GetValueOrDefault(weekDates.ElementAtOrDefault(day));
|
{
|
||||||
var shiftName = shiftWithTransport?.Shift.Name ?? "";
|
table.Cell().Element(CellStyleMiddle).Text(shift.Name);
|
||||||
table.Cell().Element(CellStyleMiddle).Text(shiftName);
|
}
|
||||||
|
}
|
||||||
|
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))
|
foreach (var day in Enumerable.Range(dayInWeek, 7 - dayInWeek))
|
||||||
{
|
{
|
||||||
|
|
@ -122,7 +129,7 @@ namespace ShiftScheduler.Services
|
||||||
foreach (var day in Enumerable.Range(0, dayInWeek))
|
foreach (var day in Enumerable.Range(0, dayInWeek))
|
||||||
{
|
{
|
||||||
var shiftWithTransport = shiftsWithTransport.GetValueOrDefault(weekDates.ElementAtOrDefault(day));
|
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);
|
table.Cell().Element(CellStyleMiddle).Text(morningTime);
|
||||||
}
|
}
|
||||||
foreach (var day in Enumerable.Range(dayInWeek, 7 - dayInWeek))
|
foreach (var day in Enumerable.Range(dayInWeek, 7 - dayInWeek))
|
||||||
|
|
@ -134,7 +141,7 @@ namespace ShiftScheduler.Services
|
||||||
foreach (var day in Enumerable.Range(0, dayInWeek))
|
foreach (var day in Enumerable.Range(0, dayInWeek))
|
||||||
{
|
{
|
||||||
var shiftWithTransport = shiftsWithTransport.GetValueOrDefault(weekDates.ElementAtOrDefault(day));
|
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);
|
table.Cell().Element(CellStyleMiddle).Text(afternoonTime);
|
||||||
}
|
}
|
||||||
foreach (var day in Enumerable.Range(dayInWeek, 7 - dayInWeek))
|
foreach (var day in Enumerable.Range(dayInWeek, 7 - dayInWeek))
|
||||||
|
|
@ -181,7 +188,7 @@ namespace ShiftScheduler.Services
|
||||||
transportLines.Add(afternoonInfo);
|
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)
|
private static string FormatTransportConnection(TransportConnection transport)
|
||||||
|
|
|
||||||
|
|
@ -6,5 +6,7 @@ namespace ShiftScheduler.Shared.Models
|
||||||
public string Icon { get; set; } = string.Empty;
|
public string Icon { get; set; } = string.Empty;
|
||||||
public string MorningTime { get; set; } = string.Empty;
|
public string MorningTime { get; set; } = string.Empty;
|
||||||
public string AfternoonTime { get; set; } = string.Empty;
|
public string AfternoonTime { get; set; } = string.Empty;
|
||||||
|
|
||||||
|
public bool IsPngIcon => Icon.EndsWith(".png", StringComparison.OrdinalIgnoreCase);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||