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'"> <PropertyGroup Condition="'$(Configuration)|$(TargetFramework)|$(Platform)'=='Debug|net8.0-maccatalyst|AnyCPU'">
<ApplicationId>com.companyname.jugenddienststunden</ApplicationId> <ApplicationId>com.companyname.jugenddienststunden</ApplicationId>
<ApplicationDisplayVersion>1.0.5</ApplicationDisplayVersion> <ApplicationDisplayVersion>1.0.6</ApplicationDisplayVersion>
<ApplicationVersion>6</ApplicationVersion> <ApplicationVersion>7</ApplicationVersion>
<Optimize>False</Optimize> <Optimize>False</Optimize>
<Deterministic>True</Deterministic> <Deterministic>True</Deterministic>
</PropertyGroup> </PropertyGroup>
@@ -53,8 +53,8 @@
<PropertyGroup Condition="'$(Configuration)|$(TargetFramework)|$(Platform)'=='Release|net8.0-maccatalyst|AnyCPU'"> <PropertyGroup Condition="'$(Configuration)|$(TargetFramework)|$(Platform)'=='Release|net8.0-maccatalyst|AnyCPU'">
<Optimize>True</Optimize> <Optimize>True</Optimize>
<ApplicationId>com.companyname.jugenddienststunden</ApplicationId> <ApplicationId>com.companyname.jugenddienststunden</ApplicationId>
<ApplicationDisplayVersion>1.0.5</ApplicationDisplayVersion> <ApplicationDisplayVersion>1.0.6</ApplicationDisplayVersion>
<ApplicationVersion>6</ApplicationVersion> <ApplicationVersion>7</ApplicationVersion>
<Deterministic>True</Deterministic> <Deterministic>True</Deterministic>
</PropertyGroup> </PropertyGroup>
@@ -64,8 +64,8 @@
<DebugSymbols>True</DebugSymbols> <DebugSymbols>True</DebugSymbols>
<Optimize>False</Optimize> <Optimize>False</Optimize>
<Deterministic>True</Deterministic> <Deterministic>True</Deterministic>
<ApplicationDisplayVersion>1.0.5</ApplicationDisplayVersion> <ApplicationDisplayVersion>1.0.6</ApplicationDisplayVersion>
<ApplicationVersion>6</ApplicationVersion> <ApplicationVersion>7</ApplicationVersion>
<AndroidKeyStore>False</AndroidKeyStore> <AndroidKeyStore>False</AndroidKeyStore>
</PropertyGroup> </PropertyGroup>
@@ -75,8 +75,8 @@
<PropertyGroup Condition="'$(Configuration)|$(TargetFramework)|$(Platform)'=='Debug|net8.0-windows10.0.26100.0|AnyCPU'"> <PropertyGroup Condition="'$(Configuration)|$(TargetFramework)|$(Platform)'=='Debug|net8.0-windows10.0.26100.0|AnyCPU'">
<ApplicationId>com.companyname.jugenddienststunden</ApplicationId> <ApplicationId>com.companyname.jugenddienststunden</ApplicationId>
<ApplicationDisplayVersion>1.0.5</ApplicationDisplayVersion> <ApplicationDisplayVersion>1.0.6</ApplicationDisplayVersion>
<ApplicationVersion>6</ApplicationVersion> <ApplicationVersion>7</ApplicationVersion>
<DefineConstants>$(DefineConstants);DISABLE_XAML_GENERATED_BREAK_ON_UNHANDLED_EXCEPTION</DefineConstants> <DefineConstants>$(DefineConstants);DISABLE_XAML_GENERATED_BREAK_ON_UNHANDLED_EXCEPTION</DefineConstants>
<Deterministic>True</Deterministic> <Deterministic>True</Deterministic>
<Optimize>False</Optimize> <Optimize>False</Optimize>
@@ -88,17 +88,17 @@
<DebugSymbols>False</DebugSymbols> <DebugSymbols>False</DebugSymbols>
<Optimize>True</Optimize> <Optimize>True</Optimize>
<Deterministic>True</Deterministic> <Deterministic>True</Deterministic>
<ApplicationDisplayVersion>1.0.5</ApplicationDisplayVersion> <ApplicationDisplayVersion>1.0.6</ApplicationDisplayVersion>
<ApplicationVersion>6</ApplicationVersion> <ApplicationVersion>7</ApplicationVersion>
<RunAOTCompilation>False</RunAOTCompilation> <RunAOTCompilation>False</RunAOTCompilation>
<PublishTrimmed>False</PublishTrimmed> <PublishTrimmed>True</PublishTrimmed>
<AndroidKeyStore>False</AndroidKeyStore> <AndroidKeyStore>False</AndroidKeyStore>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(TargetFramework)|$(Platform)'=='Release|net8.0-windows10.0.26100.0|AnyCPU'"> <PropertyGroup Condition="'$(Configuration)|$(TargetFramework)|$(Platform)'=='Release|net8.0-windows10.0.26100.0|AnyCPU'">
<ApplicationId>com.companyname.jugenddienststunden</ApplicationId> <ApplicationId>com.companyname.jugenddienststunden</ApplicationId>
<ApplicationDisplayVersion>1.0.5</ApplicationDisplayVersion> <ApplicationDisplayVersion>1.0.6</ApplicationDisplayVersion>
<ApplicationVersion>6</ApplicationVersion> <ApplicationVersion>7</ApplicationVersion>
<Optimize>True</Optimize> <Optimize>True</Optimize>
<Deterministic>True</Deterministic> <Deterministic>True</Deterministic>
</PropertyGroup> </PropertyGroup>
@@ -108,6 +108,8 @@
<SymbolPackageFormat>snupkg</SymbolPackageFormat> <SymbolPackageFormat>snupkg</SymbolPackageFormat>
<PlatformTarget>AnyCPU</PlatformTarget> <PlatformTarget>AnyCPU</PlatformTarget>
<ProduceReferenceAssembly>False</ProduceReferenceAssembly> <ProduceReferenceAssembly>False</ProduceReferenceAssembly>
<AssemblyVersion>1.0.6</AssemblyVersion>
<FileVersion>1.0.6</FileVersion>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(TargetFramework)|$(Platform)'=='Debug|net8.0-android|AnyCPU'"> <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) { internal static async Task SaveItemAsync(string url, string token, DayTime item, bool isNewItem = false) {
//Uhrzeiten sollten sinnvolle Werte haben //Uhrzeiten sollten sinnvolle Werte haben - außer bei Freistellungen, da wäre eigentlich null
if (item.TimeSpanVon == item.TimeSpanBis) { if (item.TimeSpanVon == item.TimeSpanBis && item.FreistellungAktiv == null) {
throw new Exception("Beginn und Ende sind gleich"); throw new Exception("Beginn und Ende sind gleich");
} }
@@ -134,9 +134,13 @@ internal static class BaseFunc {
throw new Exception("Projekt nicht gewählt"); throw new Exception("Projekt nicht gewählt");
} }
//Keine Beschreibung //Keine Beschreibung
if (string.IsNullOrEmpty(item.Description)) { if (string.IsNullOrEmpty(item.Description) && item.FreistellungAktiv == null) {
throw new Exception("Keine Beschreibung"); 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) }) { using (HttpClient client = new HttpClient() { Timeout = TimeSpan.FromSeconds(15) }) {
//HttpClient client = new HttpClient(); //HttpClient client = new HttpClient();
client.DefaultRequestHeaders.Add("Accept", "application/json"); client.DefaultRequestHeaders.Add("Accept", "application/json");

View File

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

View File

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

View File

@@ -49,7 +49,6 @@
<Editor Placeholder="Beschreibung" Text="{Binding DayTime.Description}" MinimumHeightRequest="40" AutoSize="TextChanges" FontSize="18" /> <Editor Placeholder="Beschreibung" Text="{Binding DayTime.Description}" MinimumHeightRequest="40" AutoSize="TextChanges" FontSize="18" />
<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}}" IsVisible="{Binding FreistellungEnabled}" /> <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"/> <BoxView HeightRequest="1" Margin="5,10"/>
<ScrollView>
<CollectionView <CollectionView
ItemsSource="{Binding DayTimes}" ItemsSource="{Binding DayTimes}"
x:Name="stundeItems" Margin="0" x:Name="stundeItems" Margin="0"
@@ -95,5 +95,6 @@
</CollectionView.ItemTemplate> </CollectionView.ItemTemplate>
</CollectionView> </CollectionView>
</ScrollView>
</VerticalStackLayout> </VerticalStackLayout>
</ContentPage> </ContentPage>

View File

@@ -2,6 +2,7 @@
<ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui" <ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:models="clr-namespace:Jugenddienst_Stunden.ViewModels" xmlns:models="clr-namespace:Jugenddienst_Stunden.ViewModels"
xmlns:mmodels="clr-namespace:Jugenddienst_Stunden.Models"
x:Class="Jugenddienst_Stunden.Views.StundenPage" x:Class="Jugenddienst_Stunden.Views.StundenPage"
Title="{Binding Title}"> Title="{Binding Title}">
@@ -52,7 +53,8 @@
<CollectionView.ItemTemplate> <CollectionView.ItemTemplate>
<DataTemplate> <DataTemplate>
<Grid Padding="5,10,5,0"> <VerticalStackLayout Padding="5,10,5,0">
<VisualStateManager.VisualStateGroups> <VisualStateManager.VisualStateGroups>
<VisualStateGroup Name="CommonStates"> <VisualStateGroup Name="CommonStates">
<VisualState Name="Normal"> <VisualState Name="Normal">
@@ -69,25 +71,35 @@
</VisualStateManager.VisualStateGroups> </VisualStateManager.VisualStateGroups>
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions> <HorizontalStackLayout>
<HorizontalStackLayout Grid.Row="0" HorizontalOptions="FillAndExpand"> <HorizontalStackLayout.Triggers>
<Label Grid.Column="0" Text="{Binding Begin}" /> <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="bis" Padding="5,0,5,0" />
<Label Text="{Binding End}" /> <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> </HorizontalStackLayout>
<Label Grid.Row="1" Grid.Column="0" Grid.ColumnSpan="2" Text="{Binding Description}" Padding="0,0,0,15"/> <HorizontalStackLayout HorizontalOptions="FillAndExpand">
</Grid> <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> </DataTemplate>
</CollectionView.ItemTemplate> </CollectionView.ItemTemplate>
@@ -105,7 +117,6 @@
<Label Grid.Row="4" Text="Restüberstunden:" /> <Label Grid.Row="4" Text="Restüberstunden:" />
<Label Grid.Row="5" Text="Resturlaub:" /> <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="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="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}" /> <Label Grid.Row="2" Grid.Column="1" HorizontalTextAlignment="End" Padding="0,0,5,0" Text="{Binding OvertimeMonth}" />
@@ -114,7 +125,6 @@
</Grid> </Grid>
</Frame> </Frame>
</VerticalStackLayout> </VerticalStackLayout>
</RefreshView> </RefreshView>