Diverse Änderungen

Sollstunden werden jetzt angezeigt.
Genehmigte Freistellungen können nicht mehr geändert werden
Projekte und Gemeinden werden ausgeblendet, sofern vom Portal so vorgesehen.
etc.
This commit is contained in:
2024-10-20 22:06:17 +02:00
parent 996dbadaf1
commit 08a3550062
7 changed files with 43 additions and 14 deletions

View File

@@ -49,7 +49,7 @@ public class DayTime {
/// <summary> /// <summary>
/// Freistellung genehmigt? /// Freistellung genehmigt?
/// </summary> /// </summary>
public bool? Approved { get; set; } public bool Approved { get; set; }
/// <summary> /// <summary>
@@ -91,4 +91,6 @@ public class DayTime {
/// </summary> /// </summary>
public Freistellung? FreistellungAktiv { get; set; } public Freistellung? FreistellungAktiv { get; set; }
public int TimeTable { get; set; }
} }

View File

@@ -28,4 +28,6 @@ public class Settings {
/// Liste der Freistellungen /// Liste der Freistellungen
/// </summary> /// </summary>
public List<Freistellung>? Freistellungen { get; set; } public List<Freistellung>? Freistellungen { get; set; }
public List<Sollstunden> Nominal { get; set; }
} }

View File

@@ -0,0 +1,7 @@
namespace Jugenddienst_Stunden.Types;
public class Sollstunden {
public int Timetable { get; set; }
public int Wochentag { get; set; }
public float Zeit { get; set; }
}

View File

@@ -64,6 +64,8 @@ public class StundeViewModel : ObservableObject, IQueryAttributable {
/// </summary> /// </summary>
public bool ProjektAktivSet { get; set; } public bool ProjektAktivSet { get; set; }
public bool FreistellungEnabled { get; set; }
public ICommand SaveCommand { get; private set; } public ICommand SaveCommand { get; private set; }
@@ -178,6 +180,9 @@ public class StundeViewModel : ObservableObject, IQueryAttributable {
_dayTime.FreistellungAktiv = OptionsFreistellung.FirstOrDefault(Freistellung => Freistellung.Id == DayTime.Free) ?? new Freistellung(); _dayTime.FreistellungAktiv = OptionsFreistellung.FirstOrDefault(Freistellung => Freistellung.Id == DayTime.Free) ?? new Freistellung();
FreistellungEnabled = !_dayTime.Approved;
OnPropertyChanged(nameof(FreistellungEnabled));
OnPropertyChanged(nameof(DayTime)); OnPropertyChanged(nameof(DayTime));
OnPropertyChanged(nameof(SubTitle)); OnPropertyChanged(nameof(SubTitle));

View File

@@ -31,7 +31,7 @@ internal class StundenViewModel : ObservableObject, IQueryAttributable, INotifyP
private HoursBase HoursBase = new HoursBase(); private HoursBase HoursBase = new HoursBase();
internal Settings Settings = new Settings(); internal Settings Settings = new Settings();
public TimeOnly Sollstunden { get; set; }
private string _title = HoursBase.name + " " + HoursBase.surname; private string _title = HoursBase.name + " " + HoursBase.surname;
public string Title { public string Title {
@@ -226,22 +226,31 @@ internal class StundenViewModel : ObservableObject, IQueryAttributable, INotifyP
try { try {
DayTimes = await HoursBase.LoadDay(date); DayTimes = await HoursBase.LoadDay(date);
//TODO: Hier muss noch die Berechnung der Stunden erfolgen
//Es werden im Moment nur die eingetragenen Stunden gezählt
//Auf der Website bekommt der Benutzer hingegen die berechneten Stunden angezeigt (Nachstunden außerhalb des Stundenplanes zählen mehr ...)
List<Sollstunden> _soll;
TimeSpan span = TimeSpan.Zero; TimeSpan span = TimeSpan.Zero;
bool merker = false;
foreach (DayTime dt in DayTimes) { foreach (DayTime dt in DayTimes) {
span += dt.End - dt.Begin; span += dt.End - dt.Begin;
//Nachtstunden dazurechnen
if (dt.Night.Ticks > 0 && !merker) {
span += dt.Night.ToTimeSpan() * .5;
merker = true;
}
_soll = Settings.Nominal.Where(w => w.Timetable == dt.TimeTable && w.Wochentag == dt.Wday).ToList();
if (_soll.Count > 0)
Sollstunden = TimeOnly.FromTimeSpan(TimeSpan.FromHours(_soll[0].Zeit));
} }
DayTotal = TimeOnly.FromTimeSpan(span); DayTotal = TimeOnly.FromTimeSpan(span);
} catch (Exception e) { } catch (Exception e) {
DayTimes = new List<DayTime>(); DayTimes = new List<DayTime>();
//TODO: hier könnte auch ein Fehler kommen, dann wäre InfoEvent falsch. //TODO: hier könnte auch ein Fehler kommen, dann wäre InfoEvent falsch.
InfoEvent?.Invoke(this, e.Message); InfoEvent?.Invoke(this, e.Message);
} finally { } finally {
OnPropertyChanged(nameof(DayTotal)); OnPropertyChanged(nameof(DayTotal));
OnPropertyChanged(nameof(Sollstunden));
//OnPropertyChanged(nameof(DayTimes)); //OnPropertyChanged(nameof(DayTimes));
} }

View File

@@ -42,7 +42,7 @@
</Picker> </Picker>
<Picker x:Name="pick_projekt" Title="Projekt" ItemsSource="{Binding OptionsProjekt}" SelectedItem="{Binding DayTime.ProjektAktiv, Mode=TwoWay}" ItemDisplayBinding="{Binding Name}" Grid.Column="1" IsVisible="{Binding ProjektAktivSet}"> <Picker x:Name="pick_projekt" Title="Projekt" ItemsSource="{Binding OptionsProjekt}" SelectedItem="{Binding DayTime.ProjektAktiv, Mode=TwoWay}" ItemDisplayBinding="{Binding Name}" Grid.Column="1" IsVisible="{Binding ProjektAktivSet}">
</Picker> </Picker>
<Picker x:Name="pick_freistellung" Title="Freistellung" ItemsSource="{Binding OptionsFreistellung}" SelectedItem="{Binding DayTime.FreistellungAktiv, Mode=TwoWay}" ItemDisplayBinding="{Binding Name}" Grid.Column="2" > <Picker x:Name="pick_freistellung" Title="Freistellung" ItemsSource="{Binding OptionsFreistellung}" SelectedItem="{Binding DayTime.FreistellungAktiv, Mode=TwoWay}" ItemDisplayBinding="{Binding Name}" Grid.Column="2" IsEnabled="{Binding FreistellungEnabled}">
</Picker> </Picker>
</Grid> </Grid>
</Frame> </Frame>
@@ -52,7 +52,7 @@
<Grid ColumnDefinitions="*,*" ColumnSpacing="4"> <Grid ColumnDefinitions="*,*" ColumnSpacing="4">
<Button Text="Speichern" Command="{Binding SaveCommand}" /> <Button Text="Speichern" Command="{Binding SaveCommand}" />
<Button Grid.Column="1" Text="Löschen" Command="{Binding DeleteConfirmCommand}" IsEnabled="{Binding DayTime.Id, Converter={StaticResource IntBoolConverter}}" /> <Button Grid.Column="1" Text="Löschen" Command="{Binding DeleteConfirmCommand}" IsEnabled="{Binding DayTime.Id, Converter={StaticResource IntBoolConverter}}" IsVisible="{Binding FreistellungEnabled}" />
</Grid> </Grid>
<BoxView HeightRequest="1" Margin="5,10"/> <BoxView HeightRequest="1" Margin="5,10"/>

View File

@@ -30,10 +30,14 @@
MaximumDate="{Binding MaximumDate}" MaximumDate="{Binding MaximumDate}"
Date="{Binding DateToday}" Format="dddd, d. MMMM yyyy" /> Date="{Binding DateToday}" Format="dddd, d. MMMM yyyy" />
<Border Grid.Column="1" Margin="15,0,0,0" Padding="15,0,0,0" ToolTipProperties.Text="Tagessumme"> <Border Grid.Column="1" Margin="15,0,0,0" Padding="15,0,0,0" ToolTipProperties.Text="Tagessumme">
<Label Text="{Binding DayTotal,StringFormat='{}{0:HH:mm}'}" VerticalOptions="Center"></Label> <HorizontalStackLayout>
<Label Text="{Binding DayTotal,StringFormat='{}{0:HH:mm}'}" VerticalOptions="Center"></Label>
<Label Text=" / " VerticalOptions="Center"></Label>
<Label Text="{Binding Sollstunden,StringFormat='{}{0:HH:mm}'}" VerticalOptions="Center"></Label>
</HorizontalStackLayout>
</Border> </Border>
</Grid> </Grid>
<CollectionView <CollectionView
ItemsSource="{Binding DayTimes}" ItemsSource="{Binding DayTimes}"
x:Name="stundeItems" Margin="0" x:Name="stundeItems" Margin="0"
@@ -88,8 +92,8 @@
</CollectionView.ItemTemplate> </CollectionView.ItemTemplate>
</CollectionView> </CollectionView>
<BoxView HeightRequest="1" /> <BoxView HeightRequest="1" />
<Button Text="{Binding LoadOverview}" Command="{Binding LoadDataCommand}" /> <Button Text="{Binding LoadOverview}" Command="{Binding LoadDataCommand}" />
<Frame Padding="2" HeightRequest="125"> <Frame Padding="2" HeightRequest="125">
@@ -109,9 +113,9 @@
<Label Grid.Row="5" Grid.Column="1" HorizontalTextAlignment="End" Padding="0,0,5,0" Text="{Binding Holiday}" /> <Label Grid.Row="5" Grid.Column="1" HorizontalTextAlignment="End" Padding="0,0,5,0" Text="{Binding Holiday}" />
</Grid> </Grid>
</Frame> </Frame>
</VerticalStackLayout>
</VerticalStackLayout>
</RefreshView> </RefreshView>
</ContentPage> </ContentPage>