Funktioniert nicht mehr unter Windows ...
This commit is contained in:
2024-10-23 14:32:42 +02:00
parent 88a79d6548
commit 00e37f9edf
6 changed files with 113 additions and 144 deletions

View File

@@ -44,8 +44,8 @@
<PropertyGroup Condition="'$(Configuration)|$(TargetFramework)|$(Platform)'=='Debug|net8.0-maccatalyst|AnyCPU'">
<ApplicationId>com.companyname.jugenddienststunden</ApplicationId>
<ApplicationDisplayVersion>1.0.5</ApplicationDisplayVersion>
<ApplicationVersion>6</ApplicationVersion>
<ApplicationDisplayVersion>1.0.6</ApplicationDisplayVersion>
<ApplicationVersion>7</ApplicationVersion>
<Optimize>False</Optimize>
<Deterministic>True</Deterministic>
</PropertyGroup>
@@ -53,8 +53,8 @@
<PropertyGroup Condition="'$(Configuration)|$(TargetFramework)|$(Platform)'=='Release|net8.0-maccatalyst|AnyCPU'">
<Optimize>True</Optimize>
<ApplicationId>com.companyname.jugenddienststunden</ApplicationId>
<ApplicationDisplayVersion>1.0.5</ApplicationDisplayVersion>
<ApplicationVersion>6</ApplicationVersion>
<ApplicationDisplayVersion>1.0.6</ApplicationDisplayVersion>
<ApplicationVersion>7</ApplicationVersion>
<Deterministic>True</Deterministic>
</PropertyGroup>
@@ -64,8 +64,8 @@
<DebugSymbols>True</DebugSymbols>
<Optimize>False</Optimize>
<Deterministic>True</Deterministic>
<ApplicationDisplayVersion>1.0.5</ApplicationDisplayVersion>
<ApplicationVersion>6</ApplicationVersion>
<ApplicationDisplayVersion>1.0.6</ApplicationDisplayVersion>
<ApplicationVersion>7</ApplicationVersion>
<AndroidKeyStore>False</AndroidKeyStore>
</PropertyGroup>
@@ -75,8 +75,8 @@
<PropertyGroup Condition="'$(Configuration)|$(TargetFramework)|$(Platform)'=='Debug|net8.0-windows10.0.26100.0|AnyCPU'">
<ApplicationId>com.companyname.jugenddienststunden</ApplicationId>
<ApplicationDisplayVersion>1.0.5</ApplicationDisplayVersion>
<ApplicationVersion>6</ApplicationVersion>
<ApplicationDisplayVersion>1.0.6</ApplicationDisplayVersion>
<ApplicationVersion>7</ApplicationVersion>
<DefineConstants>$(DefineConstants);DISABLE_XAML_GENERATED_BREAK_ON_UNHANDLED_EXCEPTION</DefineConstants>
<Deterministic>True</Deterministic>
<Optimize>False</Optimize>
@@ -88,17 +88,17 @@
<DebugSymbols>False</DebugSymbols>
<Optimize>True</Optimize>
<Deterministic>True</Deterministic>
<ApplicationDisplayVersion>1.0.5</ApplicationDisplayVersion>
<ApplicationVersion>6</ApplicationVersion>
<ApplicationDisplayVersion>1.0.6</ApplicationDisplayVersion>
<ApplicationVersion>7</ApplicationVersion>
<RunAOTCompilation>False</RunAOTCompilation>
<PublishTrimmed>False</PublishTrimmed>
<PublishTrimmed>True</PublishTrimmed>
<AndroidKeyStore>False</AndroidKeyStore>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(TargetFramework)|$(Platform)'=='Release|net8.0-windows10.0.26100.0|AnyCPU'">
<ApplicationId>com.companyname.jugenddienststunden</ApplicationId>
<ApplicationDisplayVersion>1.0.5</ApplicationDisplayVersion>
<ApplicationVersion>6</ApplicationVersion>
<ApplicationDisplayVersion>1.0.6</ApplicationDisplayVersion>
<ApplicationVersion>7</ApplicationVersion>
<Optimize>True</Optimize>
<Deterministic>True</Deterministic>
</PropertyGroup>
@@ -108,6 +108,8 @@
<SymbolPackageFormat>snupkg</SymbolPackageFormat>
<PlatformTarget>AnyCPU</PlatformTarget>
<ProduceReferenceAssembly>False</ProduceReferenceAssembly>
<AssemblyVersion>1.0.6</AssemblyVersion>
<FileVersion>1.0.6</FileVersion>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(TargetFramework)|$(Platform)'=='Debug|net8.0-android|AnyCPU'">

View File

@@ -109,8 +109,8 @@ internal static class BaseFunc {
internal static async Task SaveItemAsync(string url, string token, DayTime item, bool isNewItem = false) {
//Uhrzeiten sollten sinnvolle Werte haben
if (item.TimeSpanVon == item.TimeSpanBis) {
//Uhrzeiten sollten sinnvolle Werte haben - außer bei Freistellungen, da wäre eigentlich null
if (item.TimeSpanVon == item.TimeSpanBis && item.FreistellungAktiv == null) {
throw new Exception("Beginn und Ende sind gleich");
}
@@ -134,9 +134,13 @@ internal static class BaseFunc {
throw new Exception("Projekt nicht gewählt");
}
//Keine Beschreibung
if (string.IsNullOrEmpty(item.Description)) {
if (string.IsNullOrEmpty(item.Description) && item.FreistellungAktiv == null) {
throw new Exception("Keine Beschreibung");
}
//Keine Beschreibung
if (string.IsNullOrEmpty(item.Description)) {
item.Description = item.FreistellungAktiv.Name;
}
using (HttpClient client = new HttpClient() { Timeout = TimeSpan.FromSeconds(15) }) {
//HttpClient client = new HttpClient();
client.DefaultRequestHeaders.Add("Accept", "application/json");

View File

@@ -2,6 +2,7 @@
using CommunityToolkit.Mvvm.Input;
using Jugenddienst_Stunden.Models;
using Jugenddienst_Stunden.Types;
using System.ComponentModel;
using System.Windows.Input;
using static System.Runtime.InteropServices.JavaScript.JSType;
@@ -9,7 +10,7 @@ namespace Jugenddienst_Stunden.ViewModels;
/// <summary>
/// Viewmodel für die einzelnen Stundeneinträge / Bearbeitung
/// </summary>
public class StundeViewModel : ObservableObject, IQueryAttributable {
public partial class StundeViewModel : ObservableObject, IQueryAttributable {
public int Id { get; set; }
public string Title { get; set; } = "Eintrag bearbeiten";
@@ -25,84 +26,68 @@ public class StundeViewModel : ObservableObject, IQueryAttributable {
/// <summary>
/// Gemeinden für die Auswahlliste
/// </summary>
public List<Gemeinde> OptionsGemeinde { get; private set; }
[ObservableProperty]
private List<Gemeinde> optionsGemeinde;
/// <summary>
/// Projekte für die Auswahlliste
/// </summary>
public List<Projekt> OptionsProjekt { get; private set; }
[ObservableProperty]
private List<Projekt> optionsProjekt;
/// <summary>
/// Freistellungen für die Auswahlliste
/// </summary>
public List<Freistellung> OptionsFreistellung { get; private set; }
[ObservableProperty]
private List<Freistellung> optionsFreistellung;
/// <summary>
/// Vorhandene Zeiten anzeigen, wenn neuer Eintrag erstellt wird
/// </summary>
public List<DayTime> DayTimes { get; set; }
[ObservableProperty]
private List<DayTime> dayTimes;
private DayTime _dayTime;
/// <summary>
/// Aktueller Stundeneintrag
/// </summary>
public DayTime DayTime {
get => _dayTime;
set {
if (_dayTime != value) {
_dayTime = value;
}
OnPropertyChanged(nameof(DayTime));
}
}
[ObservableProperty]
private DayTime dayTime;
/// <summary>
/// Dürfen Gemeinden verwendet werden?
/// </summary>
public bool GemeindeAktivSet { get; set; }
[ObservableProperty]
private bool gemeindeAktivSet;
/// <summary>
/// Dürfen Projekte verwendet werden?
/// </summary>
public bool ProjektAktivSet { get; set; }
public bool FreistellungEnabled { get; set; }
[ObservableProperty]
private bool projektAktivSet;
[ObservableProperty]
private bool freistellungEnabled;
public ICommand SaveCommand { get; private set; }
public ICommand DeleteCommand { get; private set; }
public ICommand DeleteConfirmCommand { get; private set; }
//public ICommand LoadDataCommand { get; private set; }
public StundeViewModel() {
DayTime = new DayTime();
SaveCommand = new AsyncRelayCommand(Save);
//DeleteCommand = new AsyncRelayCommand(Delete);
DeleteConfirmCommand = new Command(async () => await DeleteConfirm());
//LoadSettingsAsync();
}
public StundeViewModel(DayTime stunde) {
DayTime = new DayTime();
SaveCommand = new AsyncRelayCommand(Save);
DeleteConfirmCommand = new AsyncRelayCommand(DeleteConfirm);
//LoadSettingsAsync();
}
private async void LoadSettingsAsync() {
try {
Settings = await HoursBase.LoadSettings();
GlobalVar.Settings = Settings;
OptionsGemeinde = Settings.Gemeinden;
OptionsProjekt = Settings.Projekte;
@@ -110,20 +95,10 @@ public class StundeViewModel : ObservableObject, IQueryAttributable {
GemeindeAktivSet = Settings.GemeindeAktivSet;
ProjektAktivSet = Settings.ProjektAktivSet;
GlobalVar.Settings = Settings;
OnPropertyChanged(nameof(OptionsGemeinde));
OnPropertyChanged(nameof(OptionsFreistellung));
OnPropertyChanged(nameof(OptionsProjekt));
OnPropertyChanged(nameof(GemeindeAktivSet));
OnPropertyChanged(nameof(ProjektAktivSet));
} catch (Exception e) {
AlertEvent?.Invoke(this, e.Message);
}
}
async Task Save() {
@@ -159,64 +134,63 @@ public class StundeViewModel : ObservableObject, IQueryAttributable {
//nicht Löschen
}
}
}
/// <summary>
/// Anwenden der Query-Parameter
/// </summary>
async void IQueryAttributable.ApplyQueryAttributes(IDictionary<string, object> query) {
var probe = query;
if (query.ContainsKey("load")) {
//DateTime heute = DateTime.Now;
try {
//_dayTime = await HoursBase.LoadEntry(Convert.ToInt32(query["load"]));
BaseResponse dat = await HoursBase.LoadBase("id=" + Convert.ToInt32(query["load"]));
_dayTime = dat.daytime;
_dayTime.TimeSpanVon = dat.daytime.Begin.ToTimeSpan();
_dayTime.TimeSpanBis = dat.daytime.End.ToTimeSpan();
OptionsGemeinde = dat.settings.Gemeinden;
OptionsProjekt = dat.settings.Projekte;
OptionsFreistellung = dat.settings.Freistellungen;
GlobalVar.Settings = dat.settings;
GemeindeAktivSet = dat.settings.GemeindeAktivSet;
ProjektAktivSet = dat.settings.ProjektAktivSet;
GlobalVar.Settings = dat.settings;
DayTime = dat.daytime;
DayTime.TimeSpanVon = dat.daytime.Begin.ToTimeSpan();
DayTime.TimeSpanBis = dat.daytime.End.ToTimeSpan();
OptionsGemeinde = dat.settings.Gemeinden ?? new List<Gemeinde>();
OptionsProjekt = dat.settings.Projekte ?? new List<Projekt>();
OptionsFreistellung = dat.settings.Freistellungen ?? new List<Freistellung>();
DayTime.GemeindeAktiv = OptionsGemeinde.FirstOrDefault(Gemeinde => Gemeinde.Id == DayTime.Gemeinde) ?? new Gemeinde();
DayTime.ProjektAktiv = OptionsProjekt.FirstOrDefault(Projekt => Projekt.Id == DayTime.Projekt) ?? new Projekt();
DayTime.FreistellungAktiv = OptionsFreistellung.FirstOrDefault(Freistellung => Freistellung.Id == DayTime.Free) ?? new Freistellung();
OnPropertyChanged(nameof(DayTime));
} catch (Exception e) {
AlertEvent?.Invoke(this, e.Message);
} finally {
}
if (System.String.IsNullOrEmpty(DayTime.Description)) {
AlertEvent?.Invoke(this, "Eintrag hat keinen Beschreibungstext");
}
SubTitle = DayTime.Day.ToString("dddd, d. MMMM yyyy");
OnPropertyChanged(nameof(SubTitle));
FreistellungEnabled = !DayTime.Approved;
//OnPropertyChanged(nameof(DayTime));
_dayTime.GemeindeAktiv = OptionsGemeinde.FirstOrDefault(Gemeinde => Gemeinde.Id == DayTime.Gemeinde) ?? new Gemeinde();
_dayTime.ProjektAktiv = OptionsProjekt.FirstOrDefault(Projekt => Projekt.Id == DayTime.Projekt) ?? new Projekt();
_dayTime.FreistellungAktiv = OptionsFreistellung.FirstOrDefault(Freistellung => Freistellung.Id == DayTime.Free) ?? new Freistellung();
FreistellungEnabled = !_dayTime.Approved;
}
if (query.ContainsKey("date")) {
} else if (query.ContainsKey("date")) {
Title = "Neuer Eintrag";
OnPropertyChanged(nameof(Title));
DateTime _date = DateTime.ParseExact((string)query["date"], "yyyy-MM-dd", System.Globalization.CultureInfo.InvariantCulture);
//Bei neuem Eintrag die vorhandenen des gleichen Tages anzeigen
try {
//DayTimes = await HoursBase.LoadDay(_date);
BaseResponse dat = await HoursBase.LoadBase("date=" + _date.ToString("yyyy-MM-dd"));
GlobalVar.Settings = dat.settings;
DayTimes = dat.daytimes;
OptionsGemeinde = dat.settings.Gemeinden;
OptionsProjekt = dat.settings.Projekte;
OptionsFreistellung = dat.settings.Freistellungen;
@@ -224,35 +198,27 @@ public class StundeViewModel : ObservableObject, IQueryAttributable {
GemeindeAktivSet = dat.settings.GemeindeAktivSet;
ProjektAktivSet = dat.settings.ProjektAktivSet;
GlobalVar.Settings = dat.settings;
} catch (Exception) {
//Ein Tag ohne Einträge gibt eine Fehlermeldung,
//die soll aber ignoriert werden, weil beim Neueintrag ist das ja Wurscht
//In dem Fall müssen die Settings aber nochmal geholt werden, weil die dann nicht geladen wurden
LoadSettingsAsync();
} finally {
DayTime = new DayTime();
DayTime.Day = _date;
DayTime.EmployeeId = GlobalVar.EmployeeId;
DayTime.GemeindeAktiv = new Gemeinde();
DayTime.ProjektAktiv = new Projekt();
DayTime.FreistellungAktiv = new Freistellung();
SubTitle = _date.ToString("dddd, d. MMMM yyyy");
FreistellungEnabled = true;
DayTime.EmployeeId = GlobalVar.EmployeeId;
}
}
OnPropertyChanged(nameof(FreistellungEnabled));
OnPropertyChanged(nameof(DayTime));
OnPropertyChanged(nameof(DayTimes));
OnPropertyChanged(nameof(SubTitle));
OnPropertyChanged(nameof(Title));
OnPropertyChanged(nameof(OptionsGemeinde));
OnPropertyChanged(nameof(OptionsFreistellung));
OnPropertyChanged(nameof(OptionsProjekt));
OnPropertyChanged(nameof(GemeindeAktivSet));
OnPropertyChanged(nameof(ProjektAktivSet));
OnPropertyChanged(nameof(DayTime));
}
}
}
}

View File

@@ -154,8 +154,6 @@ internal class StundenViewModel : ObservableObject, IQueryAttributable, INotifyP
public StundenViewModel() {
_hour = new Hours();
//LoadSettingsAsync();
//HoursBase.tokendata = new TokenData(HoursBase.apiKey);
LoadDataCommand = new AsyncRelayCommand(LoadData);
NewEntryCommand = new AsyncRelayCommand(NewEntryAsync);
SelectEntryCommand = new AsyncRelayCommand<DayTime>(SelectEntryAsync);
@@ -163,27 +161,9 @@ internal class StundenViewModel : ObservableObject, IQueryAttributable, INotifyP
RefreshCommand = new Command(async () => await RefreshItemsAsync());
Task task = LoadDay(DateTime.Today);
}
private async Task LoadSettingsAsync() {
try {
Settings = await HoursBase.LoadSettings();
GemeindeAktivSet = Settings.GemeindeAktivSet;
ProjektAktivSet = Settings.ProjektAktivSet;
OnPropertyChanged(nameof(GemeindeAktivSet));
OnPropertyChanged(nameof(ProjektAktivSet));
doContinue = true;
} catch (Exception e) {
doContinue = false;
AlertEvent?.Invoke(this, e.Message);
}
}
/// <summary>
/// Öffnet eine neue Stundeneingabe
/// </summary>
@@ -213,7 +193,9 @@ internal class StundenViewModel : ObservableObject, IQueryAttributable, INotifyP
/// </summary>
private async Task LoadData() {
try {
_hour = await HoursBase.LoadData();
BaseResponse dat = await HoursBase.LoadBase("hours");
_hour = dat.hour;
//_hour = await HoursBase.LoadData();
RefreshProperties();
} catch (Exception e) {
AlertEvent?.Invoke(this, e.Message);
@@ -226,11 +208,10 @@ internal class StundenViewModel : ObservableObject, IQueryAttributable, INotifyP
/// </summary>
public async Task LoadDay(DateTime date) {
DayTotal = new TimeOnly(0);
//await LoadSettingsAsync();
//if (doContinue) {
try {
//_dayTimes = await HoursBase.LoadDay(date);
BaseResponse dat = await HoursBase.LoadBase("date=" + date.ToString("yyyy-MM-dd"));
_dayTimes = dat.daytimes;
Settings = dat.settings;
GemeindeAktivSet = Settings.GemeindeAktivSet;
@@ -256,6 +237,12 @@ internal class StundenViewModel : ObservableObject, IQueryAttributable, INotifyP
}
DayTotal = TimeOnly.FromTimeSpan(span);
//Nach der Tagessumme die anderen Tage anhängen
if (_dayTimes != null) {
BaseResponse dat1 = await HoursBase.LoadBase("date=" + date.ToString("yyyy-MM-dd") + "&tilldate=" + date.AddDays(3).ToString("yyyy-MM-dd"));
if (dat1.daytimes != null)
_dayTimes = dat.daytimes.Concat(dat1.daytimes).ToList();
}
} catch (Exception e) {
_dayTimes = new List<DayTime>();
@@ -266,7 +253,6 @@ internal class StundenViewModel : ObservableObject, IQueryAttributable, INotifyP
OnPropertyChanged(nameof(Sollstunden));
OnPropertyChanged(nameof(DayTimes));
}
//}
}

View File

@@ -49,7 +49,6 @@
<Editor Placeholder="Beschreibung" Text="{Binding DayTime.Description}" MinimumHeightRequest="40" AutoSize="TextChanges" FontSize="18" />
<Grid ColumnDefinitions="*,*" ColumnSpacing="4">
<Button Text="Speichern" Command="{Binding SaveCommand}" />
<Button Grid.Column="1" Text="Löschen" Command="{Binding DeleteConfirmCommand}" IsEnabled="{Binding DayTime.Id, Converter={StaticResource IntBoolConverter}}" IsVisible="{Binding FreistellungEnabled}" />
@@ -57,6 +56,7 @@
<BoxView HeightRequest="1" Margin="5,10"/>
<ScrollView>
<CollectionView
ItemsSource="{Binding DayTimes}"
x:Name="stundeItems" Margin="0"
@@ -95,5 +95,6 @@
</CollectionView.ItemTemplate>
</CollectionView>
</ScrollView>
</VerticalStackLayout>
</ContentPage>

View File

@@ -2,6 +2,7 @@
<ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:models="clr-namespace:Jugenddienst_Stunden.ViewModels"
xmlns:mmodels="clr-namespace:Jugenddienst_Stunden.Models"
x:Class="Jugenddienst_Stunden.Views.StundenPage"
Title="{Binding Title}">
@@ -52,7 +53,8 @@
<CollectionView.ItemTemplate>
<DataTemplate>
<Grid Padding="5,10,5,0">
<VerticalStackLayout Padding="5,10,5,0">
<VisualStateManager.VisualStateGroups>
<VisualStateGroup Name="CommonStates">
<VisualState Name="Normal">
@@ -69,25 +71,35 @@
</VisualStateManager.VisualStateGroups>
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<HorizontalStackLayout Grid.Row="0" HorizontalOptions="FillAndExpand">
<Label Grid.Column="0" Text="{Binding Begin}" />
<HorizontalStackLayout>
<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 Day, StringFormat='{0:dddd, dd. MMMM}'}"/>
<Label Text="von" Padding="5,0,5,0" />
<Label Text="{Binding Begin}" />
<Label Text="bis" Padding="5,0,5,0" />
<Label Text="{Binding End}" />
<Label Text="{Binding GemeindeAktiv.Name}" Margin="10,0,0,0" IsVisible="{Binding Source={RelativeSource AncestorType={x:Type ContentPage}}, Path=BindingContext.GemeindeAktivSet}" />
<Label Text="{Binding ProjektAktiv.Name}" Margin="10,0,0,0" IsVisible="{Binding Source={RelativeSource AncestorType={x:Type ContentPage}}, Path=BindingContext.ProjektAktivSet}" />
<Label Text="{Binding FreistellungAktiv.Id}" Margin="10,0,0,0" />
</HorizontalStackLayout>
<Label Grid.Row="1" Grid.Column="0" Grid.ColumnSpan="2" Text="{Binding Description}" Padding="0,0,0,15"/>
</Grid>
<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}" IsVisible="{Binding Source={RelativeSource AncestorType={x:Type ContentPage}}, Path=BindingContext.GemeindeAktivSet}" />
<Label Text="{Binding ProjektAktiv.Name}" Margin="10,0,0,0" IsVisible="{Binding Source={RelativeSource AncestorType={x:Type ContentPage}}, Path=BindingContext.ProjektAktivSet}" />
<Label Text="{Binding FreistellungAktiv.Name}" Margin="10,0,0,0" />
</HorizontalStackLayout>
<Label Text="{Binding Description}" Padding="0,0,0,15"/>
</VerticalStackLayout>
</DataTemplate>
</CollectionView.ItemTemplate>
@@ -105,7 +117,6 @@
<Label Grid.Row="4" Text="Restüberstunden:" />
<Label Grid.Row="5" Text="Resturlaub:" />
<Label Grid.Row="0" Grid.Column="1" HorizontalTextAlignment="End" Padding="0,0,5,0" Text="{Binding Nominal}" ToolTipProperties.Text="Sollstunden" />
<Label Grid.Row="1" Grid.Column="1" HorizontalTextAlignment="End" Padding="0,0,5,0" Text="{Binding ZeitCalculated}" ToolTipProperties.Text="Geleistete Stunden" />
<Label Grid.Row="2" Grid.Column="1" HorizontalTextAlignment="End" Padding="0,0,5,0" Text="{Binding OvertimeMonth}" />
@@ -114,7 +125,6 @@
</Grid>
</Frame>
</VerticalStackLayout>
</RefreshView>