This commit is contained in:
@@ -44,6 +44,8 @@ public partial class CreateLetterDialogViewModel : ObservableObject
|
||||
public bool HasCustomPlaceholders => CustomPlaceholders.Count > 0;
|
||||
public bool HasNoTemplates => Templates.Count == 0;
|
||||
public bool HasNoContacts => Contacts.Count == 0;
|
||||
public string AddressPreview => LetterPlaceholderBuilder.FormatAddress(SelectedContact?.Model);
|
||||
public bool HasAddressPreview => !string.IsNullOrWhiteSpace(AddressPreview);
|
||||
public bool UsesAttendanceAdvancedContent => UsesAttendanceCalendar || UsesAbsenceDayList;
|
||||
public string SuggestedFileName => SanitizeFileName(
|
||||
$"{SelectedTemplate?.Name ?? "Elternbrief"}_{_student.LastName}_{_student.FirstName}.pdf");
|
||||
@@ -82,6 +84,8 @@ public partial class CreateLetterDialogViewModel : ObservableObject
|
||||
partial void OnSelectedContactChanged(LetterContactChoice? value)
|
||||
{
|
||||
Anrede = value?.Model.LetterSalutation ?? "";
|
||||
OnPropertyChanged(nameof(AddressPreview));
|
||||
OnPropertyChanged(nameof(HasAddressPreview));
|
||||
RefreshValidation();
|
||||
}
|
||||
partial void OnAnredeChanged(string value) => RefreshValidation();
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
using CommunityToolkit.Mvvm.ComponentModel;
|
||||
using LehrerApp.Desktop.Services;
|
||||
|
||||
namespace LehrerApp.Desktop.ViewModels.Students;
|
||||
|
||||
public partial class SelectContactDialogViewModel : ObservableObject
|
||||
{
|
||||
[ObservableProperty] private LetterContactChoice? _selectedContact;
|
||||
|
||||
public IReadOnlyList<LetterContactChoice> Contacts { get; }
|
||||
public string AddressPreview => LetterPlaceholderBuilder.FormatAddress(SelectedContact?.Model);
|
||||
public bool HasAddressPreview => !string.IsNullOrWhiteSpace(AddressPreview);
|
||||
|
||||
public SelectContactDialogViewModel(IReadOnlyList<LetterContactChoice> contacts, LetterContactChoice? current)
|
||||
{
|
||||
Contacts = contacts;
|
||||
SelectedContact = current ?? contacts.FirstOrDefault();
|
||||
}
|
||||
|
||||
partial void OnSelectedContactChanged(LetterContactChoice? value)
|
||||
{
|
||||
OnPropertyChanged(nameof(AddressPreview));
|
||||
OnPropertyChanged(nameof(HasAddressPreview));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user