4 Commits

7 changed files with 116 additions and 66 deletions

View File

@@ -0,0 +1,22 @@
using System;
using System.Globalization;
using System.Linq;
using Microsoft.Maui.Controls;
namespace Jugenddienst_Stunden.Converter;
public class AnyTrueMultiConverter : IMultiValueConverter {
public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture) {
foreach (object value in values) {
if (value is bool b && b) {
return true;
}
}
return false;
}
public object[] ConvertBack(object value, Type[] targetTypes, object parameter, CultureInfo culture) {
throw new NotSupportedException();
}
}

View File

@@ -109,8 +109,8 @@
<SymbolPackageFormat>snupkg</SymbolPackageFormat>
<PlatformTarget>AnyCPU</PlatformTarget>
<ProduceReferenceAssembly>False</ProduceReferenceAssembly>
<AssemblyVersion>1.0.9</AssemblyVersion>
<FileVersion>1.0.9</FileVersion>
<AssemblyVersion>1.1.0</AssemblyVersion>
<FileVersion>1.1.0</FileVersion>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(TargetFramework)|$(Platform)'=='Debug|net8.0-android|AnyCPU'">
@@ -181,6 +181,26 @@
<!-- <TargetFrameworks>;net9.0-android35.0</TargetFrameworks> -->
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(TargetFramework)|$(Platform)'=='Debug|net10.0-android36.0|AnyCPU'">
<ApplicationDisplayVersion>1.1.0</ApplicationDisplayVersion>
<ApplicationVersion>11</ApplicationVersion>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(TargetFramework)|$(Platform)'=='Debug|net10.0-windows10.0.26100.0|AnyCPU'">
<ApplicationDisplayVersion>1.1.0</ApplicationDisplayVersion>
<ApplicationVersion>11</ApplicationVersion>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(TargetFramework)|$(Platform)'=='Release|net10.0-android36.0|AnyCPU'">
<ApplicationDisplayVersion>1.1.0</ApplicationDisplayVersion>
<ApplicationVersion>11</ApplicationVersion>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(TargetFramework)|$(Platform)'=='Release|net10.0-windows10.0.26100.0|AnyCPU'">
<ApplicationDisplayVersion>1.1.0</ApplicationDisplayVersion>
<ApplicationVersion>11</ApplicationVersion>
</PropertyGroup>
<ItemGroup>
<!-- App Icon -->
<MauiIcon Include="Resources\AppIcon\appicon.svg" ForegroundFile="Resources\AppIcon\appiconfg.svg" Color="#512BD4" />

View File

@@ -74,6 +74,7 @@ public partial class StundeViewModel : ObservableObject, IQueryAttributable {
public ICommand SaveCommand { get; private set; }
public ICommand DeleteCommand { get; private set; }
public ICommand DeleteConfirmCommand { get; private set; }
public ICommand SelectEntryCommand { get; }
//public ICommand LoadDataCommand { get; private set; }
@@ -83,6 +84,7 @@ public partial class StundeViewModel : ObservableObject, IQueryAttributable {
_alertService = alertService;
SaveCommand = new AsyncRelayCommand(Save);
DeleteConfirmCommand = new Command(async () => await DeleteConfirm());
SelectEntryCommand = new AsyncRelayCommand<DayTime>(SelectEntryAsync);
_alertService.AlertRaised += (s, msg) => AlertEvent?.Invoke(this, msg);
}
@@ -136,7 +138,8 @@ public partial class StundeViewModel : ObservableObject, IQueryAttributable {
if (!exceptionOccurred) {
if (DayTime.Id != null) {
await Shell.Current.GoToAsync($"..?saved={DayTime.Id}");
//await Shell.Current.GoToAsync($"..?saved={DayTime.Id}");
await Shell.Current.GoToAsync($"//StundenPage?saved={DayTime.Id}");
} else {
await Shell.Current.GoToAsync($"..?date={DayTime.Day.ToString("yyyy-MM-dd")}");
}
@@ -173,6 +176,19 @@ public partial class StundeViewModel : ObservableObject, IQueryAttributable {
}
}
/// <summary>
/// Öffnet eine bestehende Stundeneingabe
/// </summary>
private async Task SelectEntryAsync(DayTime entry) {
if (entry != null && entry.Id != null) {
//var navigationParameters = new Dictionary<string, object> { { "load", entry.id } };
//await Shell.Current.GoToAsync($"{nameof(Views.StundePage)}", navigationParameters);
await Shell.Current.GoToAsync($"{nameof(Views.StundePage)}?load={entry.Id}");
} else AlertEvent?.Invoke(this, "Auswahl enthält keine Daten");
}
/// <summary>
/// Anwenden der Query-Parameter
/// </summary>

View File

@@ -51,13 +51,7 @@ public partial class StundenViewModel : ObservableObject, IQueryAttributable, IN
/// </summary>
[ObservableProperty] private List<DayTime> dayTimes = new List<DayTime>();
/// <summary>
/// Der Titel der Stundenübersicht ist der aktuelle Benutzername
/// </summary>
public string Title {
get => _settings.Name + " " + _settings.Surname;
set;
}
public string Title => _settings.Name + " " + _settings.Surname;
[ObservableProperty] private Hours hours;
@@ -178,16 +172,6 @@ public partial class StundenViewModel : ObservableObject, IQueryAttributable, IN
RefreshListCommand = new AsyncRelayCommand(RefreshList);
RefreshCommand = new Command(async () => await RefreshItemsAsync());
// Task task = LoadDay(DateTime.Today);
// Beim Startup NICHT direkt im CTOR laden (kann Startup/Navigation blockieren)
// Stattdessen via Dispatcher "nach" dem Aufbau starten:
MainThread.BeginInvokeOnMainThread(async () => {
try {
await LoadDay(DateTime.Today);
} catch (Exception ex) {
AlertEvent?.Invoke(this, ex.Message);
}
});
}
@@ -338,7 +322,7 @@ public partial class StundenViewModel : ObservableObject, IQueryAttributable, IN
/// <summary>
/// Refreshes all properties
/// </summary>
private void RefreshProperties() {
public void RefreshProperties() {
OnPropertyChanged(nameof(Hours));
OnPropertyChanged(nameof(Title));
OnPropertyChanged(nameof(Nominal));

View File

@@ -21,12 +21,12 @@
StatusBarStyle="LightContent" />
</ContentPage.Behaviors>
<Grid>
<Grid Padding="10,0,10,0">
<Grid.RowDefinitions>
<RowDefinition Height="50"/>
<RowDefinition Height="180"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="50"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="45"/>
<RowDefinition Height="20"/>
<RowDefinition Height="40"/>
<RowDefinition Height="*"/>
@@ -36,7 +36,7 @@
<Label Text="{Binding SubTitle}" FontSize="Medium" FontAttributes="Bold" Margin="4,0,0,0" Grid.Row="0" />
<FlexLayout Direction="Row" AlignItems="Start" Wrap="Wrap" AlignContent="Start" JustifyContent="Start" Grid.Row="1" >
<FlexLayout Direction="Row" AlignItems="Start" Wrap="Wrap" AlignContent="Start" JustifyContent="Start" Grid.Row="1" Margin="0,0,0,10" >
<Border Margin="0,0,0,10" MinimumHeightRequest="72" FlexLayout.Grow="1">
<Border.Padding>
@@ -93,7 +93,7 @@
<Editor Placeholder="Beschreibung" Text="{Binding DayTime.Description}" MinimumHeightRequest="40"
AutoSize="TextChanges" FontSize="18" Grid.Row="2" />
AutoSize="TextChanges" FontSize="18" Grid.Row="2" Margin="0,0,0,10" />
<Grid ColumnDefinitions="*,*" ColumnSpacing="4" Grid.Row="3">
<Button Grid.Column="1" Text="Speichern"
@@ -127,7 +127,6 @@
</StackLayout>
<CollectionView
ItemsSource="{Binding DayTimes}"
x:Name="stundeItems" Margin="0"

View File

@@ -13,6 +13,7 @@
<ContentPage.Resources>
<ResourceDictionary>
<conv:SecondsTimeConverter x:Key="secToTime" />
<conv:AnyTrueMultiConverter x:Key="AnyTrue"/>
<FontImageSource x:Key="ToolbarIcon"
Glyph="+"
Size="22"
@@ -27,7 +28,7 @@
</ContentPage.Behaviors>
<ContentPage.ToolbarItems>
<!--<ToolbarItem Text="Lade Liste" Command="{Binding RefreshListCommand}"/>-->
<ToolbarItem Text="Neuer Eintrag" IconImageSource="{StaticResource ToolbarIcon}"
Command="{Binding NewEntryCommand}" />
</ContentPage.ToolbarItems>
@@ -35,7 +36,6 @@
<RefreshView x:Name="MyRefreshView" Command="{Binding RefreshCommand}" IsRefreshing="{Binding IsRefreshing}"
Margin="10" Padding="10">
<Grid RowDefinitions="50,*,Auto,80">
<!--<VerticalStackLayout Spacing="10" Margin="10">-->
<Grid RowDefinitions="Auto" ColumnDefinitions="Auto,*" HeightRequest="50" Grid.Row="0">
<DatePicker Grid.Column="0" MinimumDate="{Binding MinimumDate}"
@@ -53,7 +53,6 @@
<CollectionView
ItemsSource="{Binding DayTimes}"
x:Name="stundeItems" Margin="0,0,0,20"
SelectionMode="Single"
SelectionChangedCommand="{Binding SelectEntryCommand}"
SelectionChangedCommandParameter="{Binding Source={RelativeSource Self}, Path=SelectedItem}"
@@ -61,12 +60,18 @@
Grid.Row="1">
<CollectionView.ItemsLayout>
<LinearItemsLayout Orientation="Vertical" ItemSpacing="0" />
<LinearItemsLayout Orientation="Vertical" ItemSpacing="10" />
</CollectionView.ItemsLayout>
<CollectionView.ItemTemplate>
<DataTemplate>
<VerticalStackLayout Padding="5,10,5,0">
<Border Padding="5" StrokeShape="RoundRectangle 0,30,0,30" >
<Border.Triggers>
<DataTrigger TargetType="Border" Binding="{Binding Approved}" Value="True">
<Setter Property="Background" Value="LightCoral"/>
<Setter Property="Padding" Value="4"/>
</DataTrigger>
</Border.Triggers>
<VisualStateManager.VisualStateGroups>
<VisualStateGroup Name="CommonStates">
@@ -85,15 +90,9 @@
</VisualStateGroup>
</VisualStateManager.VisualStateGroups>
<Grid RowDefinitions="Auto,Auto,Auto" ColumnDefinitions="*" >
<HorizontalStackLayout>
<HorizontalStackLayout.Triggers>
<DataTrigger TargetType="HorizontalStackLayout" Binding="{Binding Approved}"
Value="True">
<Setter Property="BackgroundColor" Value="LightCoral" />
<Setter Property="Padding" Value="4" />
</DataTrigger>
</HorizontalStackLayout.Triggers>
<HorizontalStackLayout Grid.Row="0" >
<Label Text="{Binding Day, StringFormat='{0:dddd, dd. MMMM}'}" />
<Label Text="von" Padding="5,0,5,0" />
<Label Text="{Binding Begin}" />
@@ -101,39 +100,43 @@
<Label Text="{Binding End}" />
</HorizontalStackLayout>
<HorizontalStackLayout HorizontalOptions="FillAndExpand">
<HorizontalStackLayout.Triggers>
<DataTrigger TargetType="HorizontalStackLayout" Binding="{Binding Approved}"
Value="True">
<Setter Property="BackgroundColor" Value="LightCoral" />
<Setter Property="Padding" Value="4" />
</DataTrigger>
</HorizontalStackLayout.Triggers>
<Label Text="{Binding GemeindeAktiv.Name}" Margin="0,0,10,0"
<HorizontalStackLayout Grid.Row="1" >
<!--<HorizontalStackLayout.IsVisible>
<MultiBinding Converter="{StaticResource AnyTrue}">
<Binding Path="Approved"/>
<Binding Path="BindingContext.GemeindeAktivSet" Source="{RelativeSource AncestorType={x:Type ContentPage}}"/>
<Binding Path="BindingContext.ProjektAktivSet" Source="{RelativeSource AncestorType={x:Type ContentPage}}"/>
</MultiBinding>
</HorizontalStackLayout.IsVisible>-->
<Label Text="{Binding GemeindeAktiv.Name}" Padding="0,0,10,0"
IsVisible="{Binding Source={RelativeSource AncestorType={x:Type ContentPage}}, Path=BindingContext.GemeindeAktivSet}" />
<Label Text="{Binding ProjektAktiv.Name}" Margin="0,0,10,0"
<Label Text="{Binding ProjektAktiv.Name}" Padding="0,0,10,0"
IsVisible="{Binding Source={RelativeSource AncestorType={x:Type ContentPage}}, Path=BindingContext.ProjektAktivSet}" />
<Label Text="{Binding FreistellungAktiv.Name}" IsVisible="{Binding Approved}" />
</HorizontalStackLayout>
<Label Text="{Binding Description}" Padding="0,0,0,15" />
</VerticalStackLayout>
<!-- Ensure description row does not paint background -->
<Label Text="{Binding Description}" Grid.Row="2" />
</Grid>
</Border>
</DataTemplate>
</CollectionView.ItemTemplate>
</CollectionView>
<!--<BoxView HeightRequest="1" Grid.Row="2" Margin="0,5,0,15" />-->
<Button Text="{Binding LoadOverview}"
Grid.Row="2"
Command="{Binding LoadDataCommand}"
TextColor="{AppThemeBinding Dark={StaticResource White}, Light={StaticResource White}}" />
<Border Padding="2" Grid.Row="3" Margin="0,10,0,0">
<Grid RowDefinitions="Auto,Auto,Auto,Auto,Auto,*" ColumnDefinitions="Auto,Auto,*,Auto" Margin="10,2">
<Grid RowDefinitions="Auto,Auto,Auto" ColumnDefinitions="Auto,Auto,*" Margin="10,2">
<Label Grid.Row="0" Text="Soll:" />
<Label Grid.Row="1" Text="Summe:" />
<Label Grid.Row="2" Text="Differenz:" Margin="0,0,15,0" />
<!--<BoxView Grid.Row="3" Grid.ColumnSpan="4" HeightRequest="1" Color="LightGrey" Margin="0,5"/>-->
<Label Grid.Row="0" Grid.Column="2" Text="Restüberstunden:" Margin="15,0,0,0" />
<Label Grid.Row="1" Grid.Column="2" Text="Zeitausgleich:" Margin="15,0,0,0" />
<Label Grid.Row="2" Grid.Column="2" Text="Resturlaub:" Margin="15,0,0,0" />
@@ -156,7 +159,7 @@
</Border>
</Grid>
<!--</VerticalStackLayout>-->
</RefreshView>
</ContentPage>

View File

@@ -58,6 +58,12 @@ public partial class StundenPage : ContentPage {
} catch (Exception ex) {
await DisplayAlert("Fehler:", ex.Message, "OK");
}
} else {
// Wenn eingeloggt, sicherstellen dass die Daten aktuell sind (besonders nach dem Login)
if (BindingContext is StundenViewModel vm) {
vm.RefreshProperties(); // Aktualisiert den Titel (Name/Vorname)
await vm.LoadDay(vm.DateToday);
}
}
}