Arbeitszeit: Zeiterfassung (Kapitel 6.2)
Neuer Tab "Zeiterfassung" neben "Aufgaben" (WorkloadViewModel als Tab-Container, gleiches Muster wie GroupDetailViewModel): Timer mit Zuordnung zu Aufgabe/Kategorie, manuelle Nacherfassung (Von-Bis oder Dauer), Wochenübersicht nach Kategorie, sowie "X / Y min erfasst" direkt in der Aufgabenliste als Ist-vs-Soll-Vergleich.
This commit is contained in:
@@ -189,6 +189,8 @@ public static class AppBootstrapper
|
||||
services.AddSingleton<StudentListViewModel>();
|
||||
services.AddSingleton<TimetableViewModel>();
|
||||
services.AddSingleton<WorkTaskListViewModel>();
|
||||
services.AddSingleton<TimeTrackingViewModel>();
|
||||
services.AddSingleton<WorkloadViewModel>();
|
||||
|
||||
// Transient: neue Instanz pro Navigation (für Detailseiten)
|
||||
services.AddTransient<GroupDetailViewModel>();
|
||||
|
||||
@@ -89,10 +89,12 @@ public partial class MainWindowViewModel : ObservableObject
|
||||
return timetable;
|
||||
}
|
||||
|
||||
private WorkTaskListViewModel GetWorkload()
|
||||
private WorkloadViewModel GetWorkload()
|
||||
{
|
||||
var workload = _services.GetRequiredService<WorkTaskListViewModel>();
|
||||
workload.Load();
|
||||
var workload = _services.GetRequiredService<WorkloadViewModel>();
|
||||
workload.Tasks.Load();
|
||||
workload.TimeTracking.Load();
|
||||
workload.ActiveTabIndex = 0;
|
||||
return workload;
|
||||
}
|
||||
|
||||
|
||||
@@ -60,6 +60,7 @@ public partial class WorkTaskListViewModel : ObservableObject
|
||||
{
|
||||
private readonly IWorkTaskRepository _tasks;
|
||||
private readonly IGroupRepository _groups;
|
||||
private readonly ITimeEntryRepository _timeEntries;
|
||||
|
||||
public const string AllFilter = "Alle";
|
||||
public const string ActiveFilter = "Offene Aufgaben";
|
||||
@@ -81,10 +82,12 @@ public partial class WorkTaskListViewModel : ObservableObject
|
||||
|
||||
private Dictionary<Guid, string> _groupNames = [];
|
||||
|
||||
public WorkTaskListViewModel(IWorkTaskRepository tasks, IGroupRepository groups)
|
||||
public WorkTaskListViewModel(IWorkTaskRepository tasks, IGroupRepository groups,
|
||||
ITimeEntryRepository timeEntries)
|
||||
{
|
||||
_tasks = tasks;
|
||||
_groups = groups;
|
||||
_timeEntries = timeEntries;
|
||||
Load();
|
||||
}
|
||||
|
||||
@@ -131,7 +134,11 @@ public partial class WorkTaskListViewModel : ObservableObject
|
||||
|
||||
// Fälligkeit: fällige zuerst, unbefristete ans Ende (6.1.1).
|
||||
foreach (var t in all.OrderBy(t => t.DueDate ?? DateOnly.MaxValue).ThenBy(t => t.Title))
|
||||
Tasks.Add(new WorkTaskListItem(t, _groupNames.GetValueOrDefault(t.GroupId ?? Guid.Empty)));
|
||||
{
|
||||
// Ist-Zeit (6.2.4): Summe aller mit der Aufgabe verknüpften Zeiteinträge.
|
||||
var actualMinutes = _timeEntries.GetByTask(t.Id).Sum(e => e.DurationMinutes);
|
||||
Tasks.Add(new WorkTaskListItem(t, _groupNames.GetValueOrDefault(t.GroupId ?? Guid.Empty), actualMinutes));
|
||||
}
|
||||
|
||||
OnPropertyChanged(nameof(CountSummary));
|
||||
}
|
||||
@@ -174,7 +181,7 @@ public partial class WorkTaskListViewModel : ObservableObject
|
||||
}
|
||||
}
|
||||
|
||||
public class WorkTaskListItem(WorkTask model, string? groupName)
|
||||
public class WorkTaskListItem(WorkTask model, string? groupName, int actualMinutes = 0)
|
||||
{
|
||||
public WorkTask Model { get; } = model;
|
||||
public string Title => Model.Title;
|
||||
@@ -187,6 +194,12 @@ public class WorkTaskListItem(WorkTask model, string? groupName)
|
||||
public string StatusLabel => WorkTaskStatusDisplay.Label(Model.Status);
|
||||
public string StatusColorHex => WorkTaskStatusDisplay.ColorHex(Model.Status);
|
||||
public string EstimatedMinutesDisplay => Model.EstimatedMinutes is { } m ? $"{m} min" : "";
|
||||
|
||||
// Ist-Zeit vs. Schätzung (6.2.4) — nur anzeigen, wenn tatsächlich etwas erfasst wurde.
|
||||
public bool HasActualTime => actualMinutes > 0;
|
||||
public string ActualVsEstimateDisplay => Model.EstimatedMinutes is { } estimate
|
||||
? $"{actualMinutes} / {estimate} min erfasst"
|
||||
: $"{actualMinutes} min erfasst";
|
||||
}
|
||||
|
||||
// ── Dialog: Aufgabe anlegen/bearbeiten (6.1.2) ───────────────────────────────
|
||||
@@ -264,3 +277,224 @@ public partial class AddEditWorkTaskDialogViewModel : ObservableObject
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
// ── Zeiterfassung (6.2) ──────────────────────────────────────────────────────
|
||||
|
||||
public partial class TimeTrackingViewModel : ObservableObject
|
||||
{
|
||||
private readonly ITimeEntryRepository _entries;
|
||||
private readonly IWorkTaskRepository _tasks;
|
||||
|
||||
public const string NoTaskOption = "Keine Aufgabe";
|
||||
|
||||
[ObservableProperty] private bool _isTimerRunning;
|
||||
[ObservableProperty] private DateTime? _timerStartedAt;
|
||||
[ObservableProperty] private WorkTask? _selectedTimerTask;
|
||||
[ObservableProperty] private string _selectedTimerCategory = TaskCategoryDisplay.Options[0];
|
||||
|
||||
public List<string> CategoryOptions { get; } = [.. TaskCategoryDisplay.Options];
|
||||
public List<WorkTask> OpenTasks { get; private set; } = [];
|
||||
public string RunningSinceDisplay => TimerStartedAt is { } started
|
||||
? $"Läuft seit {started:HH:mm} Uhr"
|
||||
: "";
|
||||
|
||||
public ObservableCollection<TimeEntryListItem> WeekEntries { get; } = [];
|
||||
public ObservableCollection<CategoryWeekSummary> CategorySummaries { get; } = [];
|
||||
public string TotalWeekMinutesDisplay => $"{WeekEntries.Sum(e => e.Model.DurationMinutes)} min diese Woche";
|
||||
|
||||
public Func<Task<TimeEntry?>>? OnAddEntry { get; set; }
|
||||
|
||||
public TimeTrackingViewModel(ITimeEntryRepository entries, IWorkTaskRepository tasks)
|
||||
{
|
||||
_entries = entries;
|
||||
_tasks = tasks;
|
||||
Load();
|
||||
}
|
||||
|
||||
partial void OnSelectedTimerTaskChanged(WorkTask? value)
|
||||
{
|
||||
if (value is not null) SelectedTimerCategory = TaskCategoryDisplay.Label(value.Category);
|
||||
}
|
||||
|
||||
public void Load()
|
||||
{
|
||||
OpenTasks = _tasks.GetAll().Where(t => t.Status != WorkTaskStatus.Done).ToList();
|
||||
OnPropertyChanged(nameof(OpenTasks));
|
||||
Refresh();
|
||||
}
|
||||
|
||||
private void Refresh()
|
||||
{
|
||||
var today = DateOnly.FromDateTime(DateTime.Today);
|
||||
var monday = today.AddDays(-((int)today.DayOfWeek + 6) % 7);
|
||||
var sunday = monday.AddDays(6);
|
||||
|
||||
var weekEntries = _entries.GetByDateRange(monday, sunday);
|
||||
var taskTitles = _tasks.GetAll().ToDictionary(t => t.Id, t => t.Title);
|
||||
|
||||
WeekEntries.Clear();
|
||||
foreach (var e in weekEntries.OrderByDescending(e => e.Date).ThenByDescending(e => e.StartTime))
|
||||
WeekEntries.Add(new TimeEntryListItem(e, e.TaskId is { } id ? taskTitles.GetValueOrDefault(id) : null));
|
||||
|
||||
CategorySummaries.Clear();
|
||||
var maxMinutes = weekEntries.Count > 0
|
||||
? weekEntries.GroupBy(e => e.Category).Max(g => g.Sum(e => e.DurationMinutes))
|
||||
: 0;
|
||||
foreach (var group in weekEntries.GroupBy(e => e.Category).OrderByDescending(g => g.Sum(e => e.DurationMinutes)))
|
||||
{
|
||||
var minutes = group.Sum(e => e.DurationMinutes);
|
||||
CategorySummaries.Add(new CategoryWeekSummary(
|
||||
string.IsNullOrWhiteSpace(group.Key) ? "Ohne Kategorie" : group.Key,
|
||||
minutes, maxMinutes > 0 ? minutes / (double)maxMinutes : 0));
|
||||
}
|
||||
|
||||
OnPropertyChanged(nameof(TotalWeekMinutesDisplay));
|
||||
}
|
||||
|
||||
[RelayCommand]
|
||||
private void StartTimer()
|
||||
{
|
||||
IsTimerRunning = true;
|
||||
TimerStartedAt = DateTime.Now;
|
||||
OnPropertyChanged(nameof(RunningSinceDisplay));
|
||||
}
|
||||
|
||||
[RelayCommand]
|
||||
private void StopTimer()
|
||||
{
|
||||
if (TimerStartedAt is not { } startedAt) return;
|
||||
var endedAt = DateTime.Now;
|
||||
var minutes = Math.Max(1, (int)Math.Round((endedAt - startedAt).TotalMinutes));
|
||||
|
||||
_entries.Save(new TimeEntry
|
||||
{
|
||||
TaskId = SelectedTimerTask?.Id,
|
||||
Category = SelectedTimerCategory,
|
||||
GroupId = SelectedTimerTask?.GroupId,
|
||||
Date = DateOnly.FromDateTime(startedAt),
|
||||
StartTime = TimeOnly.FromDateTime(startedAt),
|
||||
EndTime = TimeOnly.FromDateTime(endedAt),
|
||||
DurationMinutes = minutes,
|
||||
});
|
||||
|
||||
IsTimerRunning = false;
|
||||
TimerStartedAt = null;
|
||||
OnPropertyChanged(nameof(RunningSinceDisplay));
|
||||
Refresh();
|
||||
}
|
||||
|
||||
[RelayCommand]
|
||||
private async Task AddEntry()
|
||||
{
|
||||
if (OnAddEntry is null) return;
|
||||
var result = await OnAddEntry();
|
||||
if (result is null) return;
|
||||
_entries.Save(result);
|
||||
Refresh();
|
||||
}
|
||||
|
||||
[RelayCommand]
|
||||
private void DeleteEntry(TimeEntryListItem? item)
|
||||
{
|
||||
if (item is null) return;
|
||||
_entries.Delete(item.Model.Id);
|
||||
Refresh();
|
||||
}
|
||||
}
|
||||
|
||||
public class TimeEntryListItem(TimeEntry model, string? taskTitle)
|
||||
{
|
||||
public TimeEntry Model { get; } = model;
|
||||
public string DateDisplay => Model.Date.ToString("dd.MM.yyyy", CultureInfo.InvariantCulture);
|
||||
public string Category => string.IsNullOrWhiteSpace(Model.Category) ? "Ohne Kategorie" : Model.Category;
|
||||
public string TaskTitle => taskTitle ?? "";
|
||||
public string CategoryAndTaskDisplay => string.IsNullOrEmpty(TaskTitle) ? Category : $"{Category} · {TaskTitle}";
|
||||
public string DurationDisplay => $"{Model.DurationMinutes} min";
|
||||
public string Description => Model.Description ?? "";
|
||||
}
|
||||
|
||||
public class CategoryWeekSummary(string category, int minutes, double barFraction)
|
||||
{
|
||||
public string Category { get; } = category;
|
||||
public string MinutesDisplay { get; } = $"{minutes} min";
|
||||
public double BarFraction { get; } = barFraction;
|
||||
}
|
||||
|
||||
// ── Dialog: Zeiteintrag nacherfassen (6.2.2) ─────────────────────────────────
|
||||
|
||||
public partial class AddTimeEntryDialogViewModel : ObservableObject
|
||||
{
|
||||
[ObservableProperty] private string _dateText = DateTime.Today.ToString("dd.MM.yyyy", CultureInfo.InvariantCulture);
|
||||
[ObservableProperty] private string _selectedCategory = TaskCategoryDisplay.Options[0];
|
||||
[ObservableProperty] private WorkTask? _selectedTask;
|
||||
[ObservableProperty] private string _startTimeText = "";
|
||||
[ObservableProperty] private string _endTimeText = "";
|
||||
[ObservableProperty] private string _durationText = "";
|
||||
[ObservableProperty] private string _description = "";
|
||||
[ObservableProperty] private string _dateError = "";
|
||||
[ObservableProperty] private string _timeError = "";
|
||||
|
||||
public List<string> CategoryOptions { get; } = [.. TaskCategoryDisplay.Options];
|
||||
public List<WorkTask> Tasks { get; }
|
||||
public TimeEntry? Result { get; private set; }
|
||||
|
||||
public AddTimeEntryDialogViewModel(List<WorkTask> tasks) => Tasks = tasks;
|
||||
|
||||
partial void OnSelectedTaskChanged(WorkTask? value)
|
||||
{
|
||||
if (value is not null) SelectedCategory = TaskCategoryDisplay.Label(value.Category);
|
||||
}
|
||||
|
||||
[RelayCommand]
|
||||
private void Save()
|
||||
{
|
||||
DateError = ""; TimeError = "";
|
||||
var valid = true;
|
||||
|
||||
if (!DateOnly.TryParseExact(DateText, "dd.MM.yyyy", null, DateTimeStyles.None, out var date))
|
||||
{ DateError = "Format TT.MM.JJJJ."; valid = false; }
|
||||
|
||||
TimeOnly? start = null, end = null;
|
||||
int? duration = null;
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(DurationText))
|
||||
{
|
||||
if (!int.TryParse(DurationText, out var m) || m <= 0)
|
||||
{ TimeError = "Dauer: ganze Zahl > 0 erwartet."; valid = false; }
|
||||
else duration = m;
|
||||
}
|
||||
else if (!string.IsNullOrWhiteSpace(StartTimeText) || !string.IsNullOrWhiteSpace(EndTimeText))
|
||||
{
|
||||
if (!TimeOnly.TryParseExact(StartTimeText, "HH:mm", null, DateTimeStyles.None, out var s)
|
||||
|| !TimeOnly.TryParseExact(EndTimeText, "HH:mm", null, DateTimeStyles.None, out var e)
|
||||
|| e <= s)
|
||||
{ TimeError = "Format HH:mm, Ende muss nach Beginn liegen."; valid = false; }
|
||||
else { start = s; end = e; duration = (int)(e - s).TotalMinutes; }
|
||||
}
|
||||
else { TimeError = "Dauer oder Von/Bis erforderlich."; valid = false; }
|
||||
|
||||
if (!valid) return;
|
||||
|
||||
Result = new TimeEntry
|
||||
{
|
||||
TaskId = SelectedTask?.Id,
|
||||
Category = SelectedCategory,
|
||||
GroupId = SelectedTask?.GroupId,
|
||||
Date = date,
|
||||
StartTime = start,
|
||||
EndTime = end,
|
||||
DurationMinutes = duration!.Value,
|
||||
Description = string.IsNullOrWhiteSpace(Description) ? null : Description.Trim(),
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
// ── Container: Arbeitszeit-Seite mit Tabs "Aufgaben"/"Zeiterfassung" ─────────
|
||||
|
||||
public partial class WorkloadViewModel(WorkTaskListViewModel tasks, TimeTrackingViewModel timeTracking) : ObservableObject
|
||||
{
|
||||
[ObservableProperty] private int _activeTabIndex;
|
||||
|
||||
public WorkTaskListViewModel Tasks { get; } = tasks;
|
||||
public TimeTrackingViewModel TimeTracking { get; } = timeTracking;
|
||||
}
|
||||
|
||||
@@ -55,8 +55,8 @@
|
||||
<DataTemplate DataType="vmp:TimetableViewModel">
|
||||
<vp:TimetableView/>
|
||||
</DataTemplate>
|
||||
<DataTemplate DataType="vmw:WorkTaskListViewModel">
|
||||
<vw:WorkTaskListView/>
|
||||
<DataTemplate DataType="vmw:WorkloadViewModel">
|
||||
<vw:WorkloadView/>
|
||||
</DataTemplate>
|
||||
<DataTemplate DataType="vm:PlaceholderViewModel">
|
||||
<views:PlaceholderView/>
|
||||
|
||||
@@ -0,0 +1,72 @@
|
||||
<Window xmlns="https://github.com/avaloniaui"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:vm="clr-namespace:LehrerApp.Desktop.ViewModels.Workload"
|
||||
xmlns:models="clr-namespace:LehrerApp.Core.Models;assembly=LehrerApp.Core"
|
||||
x:Class="LehrerApp.Desktop.Views.Workload.AddTimeEntryDialog"
|
||||
x:DataType="vm:AddTimeEntryDialogViewModel"
|
||||
Title="Zeit nacherfassen"
|
||||
Width="420" Height="440" MinWidth="380" MinHeight="400"
|
||||
CanResize="True" WindowStartupLocation="CenterOwner">
|
||||
|
||||
<Grid RowDefinitions="*,Auto" Margin="24">
|
||||
<ScrollViewer Grid.Row="0">
|
||||
<StackPanel Spacing="14" Margin="0,0,12,0">
|
||||
<TextBlock Text="Zeit nacherfassen" Classes="dialogtitle"/>
|
||||
|
||||
<Grid ColumnDefinitions="*,8,*">
|
||||
<StackPanel Grid.Column="0" Spacing="4">
|
||||
<TextBlock Text="Datum *" FontSize="12" Opacity="0.7"/>
|
||||
<TextBox Text="{Binding DateText}" PlaceholderText="TT.MM.JJJJ"/>
|
||||
<TextBlock Text="{Binding DateError}" Foreground="Red" FontSize="11"
|
||||
IsVisible="{Binding DateError, Converter={x:Static StringConverters.IsNotNullOrEmpty}}"/>
|
||||
</StackPanel>
|
||||
<StackPanel Grid.Column="2" Spacing="4">
|
||||
<TextBlock Text="Kategorie" FontSize="12" Opacity="0.7"/>
|
||||
<ComboBox ItemsSource="{Binding CategoryOptions}" SelectedItem="{Binding SelectedCategory}"
|
||||
HorizontalAlignment="Stretch"/>
|
||||
</StackPanel>
|
||||
</Grid>
|
||||
|
||||
<StackPanel Spacing="4">
|
||||
<TextBlock Text="Aufgabe (optional)" FontSize="12" Opacity="0.7"/>
|
||||
<ComboBox ItemsSource="{Binding Tasks}" SelectedItem="{Binding SelectedTask}"
|
||||
HorizontalAlignment="Stretch" PlaceholderText="Keine Aufgabe">
|
||||
<ComboBox.ItemTemplate>
|
||||
<DataTemplate x:DataType="models:WorkTask">
|
||||
<TextBlock Text="{Binding Title}"/>
|
||||
</DataTemplate>
|
||||
</ComboBox.ItemTemplate>
|
||||
</ComboBox>
|
||||
</StackPanel>
|
||||
|
||||
<Grid ColumnDefinitions="*,8,*">
|
||||
<StackPanel Grid.Column="0" Spacing="4">
|
||||
<TextBlock Text="Von" FontSize="12" Opacity="0.7"/>
|
||||
<TextBox Text="{Binding StartTimeText}" PlaceholderText="HH:mm"/>
|
||||
</StackPanel>
|
||||
<StackPanel Grid.Column="2" Spacing="4">
|
||||
<TextBlock Text="Bis" FontSize="12" Opacity="0.7"/>
|
||||
<TextBox Text="{Binding EndTimeText}" PlaceholderText="HH:mm"/>
|
||||
</StackPanel>
|
||||
</Grid>
|
||||
|
||||
<StackPanel Spacing="4">
|
||||
<TextBlock Text="Oder Dauer in min" FontSize="12" Opacity="0.7"/>
|
||||
<TextBox Text="{Binding DurationText}" PlaceholderText="z.B. 30"/>
|
||||
<TextBlock Text="{Binding TimeError}" Foreground="Red" FontSize="11"
|
||||
IsVisible="{Binding TimeError, Converter={x:Static StringConverters.IsNotNullOrEmpty}}"/>
|
||||
</StackPanel>
|
||||
|
||||
<StackPanel Spacing="4">
|
||||
<TextBlock Text="Notiz (optional)" FontSize="12" Opacity="0.7"/>
|
||||
<TextBox Text="{Binding Description}"/>
|
||||
</StackPanel>
|
||||
</StackPanel>
|
||||
</ScrollViewer>
|
||||
|
||||
<Grid Grid.Row="1" ColumnDefinitions="*,8,*" Margin="0,20,0,0">
|
||||
<Button Grid.Column="0" Content="Abbrechen" HorizontalAlignment="Stretch" Click="OnCancel"/>
|
||||
<Button Grid.Column="2" Content="Speichern" HorizontalAlignment="Stretch" Click="OnSave"/>
|
||||
</Grid>
|
||||
</Grid>
|
||||
</Window>
|
||||
@@ -0,0 +1,21 @@
|
||||
using Avalonia.Controls;
|
||||
using Avalonia.Interactivity;
|
||||
using LehrerApp.Desktop.ViewModels.Workload;
|
||||
|
||||
namespace LehrerApp.Desktop.Views.Workload;
|
||||
|
||||
public partial class AddTimeEntryDialog : Window
|
||||
{
|
||||
public AddTimeEntryDialog() => InitializeComponent();
|
||||
|
||||
private void OnSave(object? s, RoutedEventArgs e)
|
||||
{
|
||||
if (DataContext is AddTimeEntryDialogViewModel vm && vm.SaveCommand.CanExecute(null))
|
||||
{
|
||||
vm.SaveCommand.Execute(null);
|
||||
if (vm.Result is not null) Close(true);
|
||||
}
|
||||
}
|
||||
|
||||
private void OnCancel(object? s, RoutedEventArgs e) => Close(false);
|
||||
}
|
||||
@@ -0,0 +1,101 @@
|
||||
<UserControl xmlns="https://github.com/avaloniaui"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:vm="clr-namespace:LehrerApp.Desktop.ViewModels.Workload"
|
||||
xmlns:models="clr-namespace:LehrerApp.Core.Models;assembly=LehrerApp.Core"
|
||||
x:Class="LehrerApp.Desktop.Views.Workload.TimeTrackingView"
|
||||
x:DataType="vm:TimeTrackingViewModel">
|
||||
<ScrollViewer>
|
||||
<StackPanel Margin="20,16" Spacing="16">
|
||||
|
||||
<!-- Timer (6.2.1) -->
|
||||
<Border Background="{DynamicResource SystemControlBackgroundAltHighBrush}" CornerRadius="8" Padding="16">
|
||||
<StackPanel Spacing="10">
|
||||
<TextBlock Text="Timer" FontWeight="SemiBold" FontSize="14"/>
|
||||
<Grid ColumnDefinitions="*,8,*" IsEnabled="{Binding !IsTimerRunning}">
|
||||
<StackPanel Grid.Column="0" Spacing="4">
|
||||
<TextBlock Text="Aufgabe (optional)" FontSize="12" Opacity="0.7"/>
|
||||
<ComboBox ItemsSource="{Binding OpenTasks}" SelectedItem="{Binding SelectedTimerTask}"
|
||||
HorizontalAlignment="Stretch" PlaceholderText="Keine Aufgabe">
|
||||
<ComboBox.ItemTemplate>
|
||||
<DataTemplate x:DataType="models:WorkTask">
|
||||
<TextBlock Text="{Binding Title}"/>
|
||||
</DataTemplate>
|
||||
</ComboBox.ItemTemplate>
|
||||
</ComboBox>
|
||||
</StackPanel>
|
||||
<StackPanel Grid.Column="2" Spacing="4">
|
||||
<TextBlock Text="Kategorie" FontSize="12" Opacity="0.7"/>
|
||||
<ComboBox ItemsSource="{Binding CategoryOptions}" SelectedItem="{Binding SelectedTimerCategory}"
|
||||
HorizontalAlignment="Stretch"/>
|
||||
</StackPanel>
|
||||
</Grid>
|
||||
<Grid ColumnDefinitions="Auto,*">
|
||||
<Button Grid.Column="0" Content="▶ Start" Command="{Binding StartTimerCommand}"
|
||||
IsVisible="{Binding !IsTimerRunning}"/>
|
||||
<Button Grid.Column="0" Content="■ Stop" Command="{Binding StopTimerCommand}"
|
||||
IsVisible="{Binding IsTimerRunning}"/>
|
||||
<TextBlock Grid.Column="1" Text="{Binding RunningSinceDisplay}" VerticalAlignment="Center"
|
||||
Margin="12,0,0,0" FontWeight="SemiBold"/>
|
||||
</Grid>
|
||||
</StackPanel>
|
||||
</Border>
|
||||
|
||||
<!-- Wochenübersicht (6.2.3) -->
|
||||
<Border Background="{DynamicResource SystemControlBackgroundAltHighBrush}" CornerRadius="8" Padding="16">
|
||||
<StackPanel Spacing="10">
|
||||
<Grid ColumnDefinitions="*,Auto">
|
||||
<TextBlock Grid.Column="0" Text="Diese Woche" FontWeight="SemiBold" FontSize="14"/>
|
||||
<TextBlock Grid.Column="1" Text="{Binding TotalWeekMinutesDisplay}" Opacity="0.7" FontSize="12"/>
|
||||
</Grid>
|
||||
<ItemsControl ItemsSource="{Binding CategorySummaries}">
|
||||
<ItemsControl.ItemTemplate>
|
||||
<DataTemplate x:DataType="vm:CategoryWeekSummary">
|
||||
<Grid ColumnDefinitions="120,*,60" Margin="0,3">
|
||||
<TextBlock Grid.Column="0" Text="{Binding Category}" FontSize="12" VerticalAlignment="Center"/>
|
||||
<ProgressBar Grid.Column="1" Value="{Binding BarFraction}" Maximum="1" Height="8"
|
||||
VerticalAlignment="Center" Margin="8,0"/>
|
||||
<TextBlock Grid.Column="2" Text="{Binding MinutesDisplay}" FontSize="12"
|
||||
HorizontalAlignment="Right" VerticalAlignment="Center"/>
|
||||
</Grid>
|
||||
</DataTemplate>
|
||||
</ItemsControl.ItemTemplate>
|
||||
</ItemsControl>
|
||||
<TextBlock Text="Noch keine Zeiten diese Woche erfasst." Opacity="0.6" FontSize="12"
|
||||
IsVisible="{Binding !CategorySummaries.Count}"/>
|
||||
</StackPanel>
|
||||
</Border>
|
||||
|
||||
<!-- Einträge / Nacherfassung (6.2.2) -->
|
||||
<Grid ColumnDefinitions="*,Auto">
|
||||
<TextBlock Grid.Column="0" Text="Einträge" FontWeight="SemiBold" FontSize="14" VerticalAlignment="Center"/>
|
||||
<Button Grid.Column="1" Content="+ Nacherfassen" Command="{Binding AddEntryCommand}"/>
|
||||
</Grid>
|
||||
|
||||
<ItemsControl ItemsSource="{Binding WeekEntries}">
|
||||
<ItemsControl.ItemTemplate>
|
||||
<DataTemplate x:DataType="vm:TimeEntryListItem">
|
||||
<Border Background="{DynamicResource SystemControlBackgroundAltHighBrush}"
|
||||
CornerRadius="6" Padding="12,8" Margin="0,0,0,6">
|
||||
<Grid ColumnDefinitions="80,*,Auto,Auto">
|
||||
<TextBlock Grid.Column="0" Text="{Binding DateDisplay}" FontSize="12" Opacity="0.6"
|
||||
VerticalAlignment="Center"/>
|
||||
<StackPanel Grid.Column="1" Margin="8,0" VerticalAlignment="Center">
|
||||
<TextBlock Text="{Binding CategoryAndTaskDisplay}" FontSize="13"/>
|
||||
<TextBlock Text="{Binding Description}" FontSize="11" Opacity="0.6"
|
||||
IsVisible="{Binding Description, Converter={x:Static StringConverters.IsNotNullOrEmpty}}"/>
|
||||
</StackPanel>
|
||||
<TextBlock Grid.Column="2" Text="{Binding DurationDisplay}" VerticalAlignment="Center"
|
||||
Margin="0,0,10,0" FontSize="12"/>
|
||||
<Button Grid.Column="3" Content="Löschen" FontSize="11" Padding="8,3"
|
||||
Command="{Binding $parent[ItemsControl].((vm:TimeTrackingViewModel)DataContext).DeleteEntryCommand}"
|
||||
CommandParameter="{Binding}"/>
|
||||
</Grid>
|
||||
</Border>
|
||||
</DataTemplate>
|
||||
</ItemsControl.ItemTemplate>
|
||||
</ItemsControl>
|
||||
<TextBlock Text="Noch keine Einträge diese Woche." Opacity="0.6" Margin="4,4"
|
||||
IsVisible="{Binding !WeekEntries.Count}"/>
|
||||
</StackPanel>
|
||||
</ScrollViewer>
|
||||
</UserControl>
|
||||
@@ -0,0 +1,32 @@
|
||||
using Avalonia.Controls;
|
||||
using LehrerApp.Core.Interfaces;
|
||||
using LehrerApp.Core.Models;
|
||||
using LehrerApp.Desktop.ViewModels.Workload;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
|
||||
namespace LehrerApp.Desktop.Views.Workload;
|
||||
|
||||
public partial class TimeTrackingView : UserControl
|
||||
{
|
||||
public TimeTrackingView() => InitializeComponent();
|
||||
|
||||
protected override void OnDataContextChanged(EventArgs e)
|
||||
{
|
||||
base.OnDataContextChanged(e);
|
||||
if (DataContext is TimeTrackingViewModel vm)
|
||||
vm.OnAddEntry = ShowAddEntryDialog;
|
||||
}
|
||||
|
||||
private async Task<TimeEntry?> ShowAddEntryDialog()
|
||||
{
|
||||
var owner = TopLevel.GetTopLevel(this) as Window;
|
||||
if (owner is null) return null;
|
||||
|
||||
var tasks = App.Services.GetRequiredService<IWorkTaskRepository>()
|
||||
.GetAll().Where(t => t.Status != WorkTaskStatus.Done).ToList();
|
||||
var vm = new AddTimeEntryDialogViewModel(tasks);
|
||||
var dialog = new AddTimeEntryDialog { DataContext = vm };
|
||||
await dialog.ShowDialog<bool>(owner);
|
||||
return vm.Result;
|
||||
}
|
||||
}
|
||||
@@ -1,30 +1,20 @@
|
||||
<UserControl xmlns="https://github.com/avaloniaui"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:vm="clr-namespace:LehrerApp.Desktop.ViewModels.Workload"
|
||||
xmlns:shared="clr-namespace:LehrerApp.Desktop.Views.Shared"
|
||||
x:Class="LehrerApp.Desktop.Views.Workload.WorkTaskListView"
|
||||
x:DataType="vm:WorkTaskListViewModel">
|
||||
<Grid RowDefinitions="Auto,Auto,*">
|
||||
<Border Grid.Row="0" Padding="20,16"
|
||||
BorderBrush="{DynamicResource SystemControlForegroundBaseLowBrush}"
|
||||
BorderThickness="0,0,0,1">
|
||||
<Grid ColumnDefinitions="*,Auto">
|
||||
<shared:PageHeader Grid.Column="0" Title="Arbeitszeit" Subtitle="{Binding CountSummary}"/>
|
||||
<Button Grid.Column="1" Content="+ Neue Aufgabe"
|
||||
Command="{Binding AddTaskCommand}" VerticalAlignment="Center"/>
|
||||
</Grid>
|
||||
</Border>
|
||||
|
||||
<Grid Grid.Row="1" ColumnDefinitions="Auto,Auto,Auto" Margin="16,10" HorizontalAlignment="Left">
|
||||
<Grid RowDefinitions="Auto,*">
|
||||
<Grid Grid.Row="0" ColumnDefinitions="Auto,Auto,Auto,*,Auto" Margin="16,14,16,4" VerticalAlignment="Center">
|
||||
<ComboBox Grid.Column="0" ItemsSource="{Binding StatusFilterOptions}"
|
||||
SelectedItem="{Binding StatusFilter}" Margin="0,0,8,0"/>
|
||||
<ComboBox Grid.Column="1" ItemsSource="{Binding CategoryFilterOptions}"
|
||||
SelectedItem="{Binding CategoryFilter}" Margin="0,0,8,0"/>
|
||||
<ComboBox Grid.Column="2" ItemsSource="{Binding GroupFilterOptions}"
|
||||
SelectedItem="{Binding GroupFilter}"/>
|
||||
<Button Grid.Column="4" Content="+ Neue Aufgabe" Command="{Binding AddTaskCommand}"/>
|
||||
</Grid>
|
||||
|
||||
<ScrollViewer Grid.Row="2" Margin="16,0,16,16">
|
||||
<ScrollViewer Grid.Row="1" Margin="16,10,16,16">
|
||||
<StackPanel>
|
||||
<ItemsControl ItemsSource="{Binding Tasks}">
|
||||
<ItemsControl.ItemTemplate>
|
||||
@@ -46,11 +36,15 @@
|
||||
<Run Text=" · "/>
|
||||
<Run Text="{Binding GroupName}"/>
|
||||
</TextBlock>
|
||||
<!-- Ist-Zeit vs. Schätzung (6.2.4) -->
|
||||
<TextBlock Text="{Binding ActualVsEstimateDisplay}" FontSize="11" Opacity="0.6"
|
||||
IsVisible="{Binding HasActualTime}"/>
|
||||
</StackPanel>
|
||||
<TextBlock Grid.Column="2" Text="{Binding DueDateDisplay}" VerticalAlignment="Center"
|
||||
Margin="0,0,10,0" FontSize="12" Foreground="{Binding DueDateColorHex}"/>
|
||||
<TextBlock Grid.Column="3" Text="{Binding EstimatedMinutesDisplay}"
|
||||
VerticalAlignment="Center" Opacity="0.6" FontSize="12" Margin="0,0,10,0"/>
|
||||
VerticalAlignment="Center" Opacity="0.6" FontSize="12" Margin="0,0,10,0"
|
||||
IsVisible="{Binding !HasActualTime}"/>
|
||||
<Button Grid.Column="4" Content="Bearbeiten" FontSize="11" Padding="8,3" Margin="0,0,4,0"
|
||||
Command="{Binding $parent[ItemsControl].((vm:WorkTaskListViewModel)DataContext).EditTaskCommand}"
|
||||
CommandParameter="{Binding}"/>
|
||||
|
||||
@@ -0,0 +1,24 @@
|
||||
<UserControl xmlns="https://github.com/avaloniaui"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:vm="clr-namespace:LehrerApp.Desktop.ViewModels.Workload"
|
||||
xmlns:views="clr-namespace:LehrerApp.Desktop.Views.Workload"
|
||||
xmlns:shared="clr-namespace:LehrerApp.Desktop.Views.Shared"
|
||||
x:Class="LehrerApp.Desktop.Views.Workload.WorkloadView"
|
||||
x:DataType="vm:WorkloadViewModel">
|
||||
<Grid RowDefinitions="Auto,*">
|
||||
<Border Grid.Row="0" Padding="20,16"
|
||||
BorderBrush="{DynamicResource SystemControlForegroundBaseLowBrush}"
|
||||
BorderThickness="0,0,0,1">
|
||||
<shared:PageHeader Title="Arbeitszeit" Subtitle="{Binding Tasks.CountSummary}"/>
|
||||
</Border>
|
||||
|
||||
<TabbedPage Grid.Row="1" TabPlacement="Top" SelectedIndex="{Binding ActiveTabIndex}">
|
||||
<ContentPage Header="Aufgaben">
|
||||
<views:WorkTaskListView DataContext="{Binding Tasks}"/>
|
||||
</ContentPage>
|
||||
<ContentPage Header="Zeiterfassung">
|
||||
<views:TimeTrackingView DataContext="{Binding TimeTracking}"/>
|
||||
</ContentPage>
|
||||
</TabbedPage>
|
||||
</Grid>
|
||||
</UserControl>
|
||||
@@ -0,0 +1,8 @@
|
||||
using Avalonia.Controls;
|
||||
|
||||
namespace LehrerApp.Desktop.Views.Workload;
|
||||
|
||||
public partial class WorkloadView : UserControl
|
||||
{
|
||||
public WorkloadView() => InitializeComponent();
|
||||
}
|
||||
Reference in New Issue
Block a user