Bei neuem Eintrag die vorhandenen anzeigen.
This commit is contained in:
@@ -3,6 +3,7 @@ using CommunityToolkit.Mvvm.Input;
|
||||
using Jugenddienst_Stunden.Types;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Windows.Input;
|
||||
using static System.Runtime.InteropServices.JavaScript.JSType;
|
||||
|
||||
namespace Jugenddienst_Stunden.ViewModels;
|
||||
internal class StundeViewModel : ObservableObject, IQueryAttributable {
|
||||
@@ -15,6 +16,7 @@ internal class StundeViewModel : ObservableObject, IQueryAttributable {
|
||||
private DayTime _stunde;
|
||||
public DayTime Stunde { get => _stunde; }
|
||||
|
||||
public string Title { get; set; } = "Eintrag bearbeiten";
|
||||
|
||||
public event EventHandler<string> AlertEvent;
|
||||
public event EventHandler<string> InfoEvent;
|
||||
@@ -60,7 +62,7 @@ internal class StundeViewModel : ObservableObject, IQueryAttributable {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public List<DayTime> DayTimes {get;set; }
|
||||
|
||||
|
||||
public ICommand SaveCommand { get; private set; }
|
||||
@@ -137,7 +139,7 @@ internal class StundeViewModel : ObservableObject, IQueryAttributable {
|
||||
|
||||
//DateTime heute = DateTime.Now;
|
||||
_stunde = await Models.Stunde.LoadEntry(Convert.ToInt32(query["load"]));
|
||||
if (String.IsNullOrEmpty(_stunde.description)) {
|
||||
if (System.String.IsNullOrEmpty(_stunde.description)) {
|
||||
AlertEvent?.Invoke(this, "Eintrag hat keine Daten zurückgegeben");
|
||||
}
|
||||
SubTitle = _stunde.day.ToString("dddd, d. MMM. yyyy");
|
||||
@@ -165,10 +167,21 @@ internal class StundeViewModel : ObservableObject, IQueryAttributable {
|
||||
|
||||
}
|
||||
if (query.ContainsKey("date")) {
|
||||
SubTitle = DateTime.ParseExact((string)query["date"], "yyyy-MM-dd", System.Globalization.CultureInfo.InvariantCulture).ToString("dddd, d. MMM. yyyy");
|
||||
_stunde.day = DateTime.ParseExact((string)query["date"], "yyyy-MM-dd", System.Globalization.CultureInfo.InvariantCulture);
|
||||
Title = "Neuer Eintrag";
|
||||
|
||||
DateTime _date = DateTime.ParseExact((string)query["date"], "yyyy-MM-dd", System.Globalization.CultureInfo.InvariantCulture);
|
||||
|
||||
//Bei neuem Eintrag die vorhandenen des gleichen Tages anzeigen
|
||||
DayTimes = await Models.Stunde.LoadDay(_date);
|
||||
|
||||
|
||||
_stunde.day = _date;
|
||||
SubTitle = _date.ToString("dddd, d. MMM. yyyy");
|
||||
|
||||
_ = LoadData();
|
||||
OnPropertyChanged(nameof(Title));
|
||||
OnPropertyChanged(nameof(SubTitle));
|
||||
OnPropertyChanged(nameof(DayTimes));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
|
||||
xmlns:models="clr-namespace:Jugenddienst_Stunden.ViewModels"
|
||||
x:Class="Jugenddienst_Stunden.Views.StundePage"
|
||||
Title="Eintrag bearbeiten">
|
||||
Title="{Binding Title}">
|
||||
|
||||
<ContentPage.BindingContext>
|
||||
<models:StundeViewModel />
|
||||
@@ -45,5 +45,46 @@
|
||||
<Button Text="Speichern" Command="{Binding SaveCommand}" />
|
||||
<Button Grid.Column="1" Text="Löschen" Command="{Binding DeleteConfirmCommand}" />
|
||||
</Grid>
|
||||
|
||||
<BoxView HeightRequest="1" Color="Red" Margin="5,10"/>
|
||||
|
||||
<CollectionView
|
||||
ItemsSource="{Binding DayTimes}"
|
||||
x:Name="stundeItems" Margin="0"
|
||||
HeightRequest="350"
|
||||
SelectionMode="Single"
|
||||
SelectionChangedCommand="{Binding SelectEntryCommand}"
|
||||
SelectionChangedCommandParameter="{Binding Source={RelativeSource Self}, Path=SelectedItem}">
|
||||
|
||||
<CollectionView.ItemsLayout>
|
||||
<LinearItemsLayout Orientation="Vertical" ItemSpacing="0" />
|
||||
</CollectionView.ItemsLayout>
|
||||
|
||||
<CollectionView.ItemTemplate>
|
||||
<DataTemplate>
|
||||
<Grid Padding="5,10,5,0">
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="Auto" />
|
||||
<RowDefinition Height="Auto" />
|
||||
</Grid.RowDefinitions>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="*" />
|
||||
<ColumnDefinition Width="*" />
|
||||
</Grid.ColumnDefinitions>
|
||||
<HorizontalStackLayout Grid.Row="0" Grid.Column="0">
|
||||
<Label Grid.Column="0" 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"/>
|
||||
<Label Text="{Binding ProjektAktiv.Name}" Margin="10,0,0,0"/>
|
||||
<Label Text="{Binding FreistellungAktiv.Name}" 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>
|
||||
</DataTemplate>
|
||||
</CollectionView.ItemTemplate>
|
||||
|
||||
</CollectionView>
|
||||
</VerticalStackLayout>
|
||||
</ContentPage>
|
||||
@@ -5,7 +5,6 @@ namespace Jugenddienst_Stunden.Views;
|
||||
|
||||
public partial class StundePage : ContentPage {
|
||||
|
||||
public ICommand DeleteConfirmCommand { get; }
|
||||
|
||||
public StundePage() {
|
||||
InitializeComponent();
|
||||
|
||||
Reference in New Issue
Block a user